Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

Add Freeze and Live Freeze to the track context menu

Egor Khindikaynenb0404752393b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b0c7a53..74d10994 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,26 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
+### Added
+- **Freeze and Live Freeze from the track's context menu.** Right-clicking a track header in
+ the arrangement now offers the whole freeze workflow, not just the Devices panel buttons:
+ **Freeze track** and **Live Freeze** on a live track; **Unfreeze track** and **Flatten to
+ audio track** on a frozen one; and on either half of a live-freeze pair — the sleeping
+ source or its frozen audio track — **Edit source**, or **Done — re-freeze** / **Discard
+ edits** while you're editing, plus **Unfreeze (wake source)** and **Flatten (remove
+ source)**. Each command selects its track, so the Devices panel follows along; **Edit**
+ always jumps to the source, where the notes and devices live.
+
+### Fixed
+- **Deleting one half of a live-freeze pair no longer leaves the other half stuck.** If the
+ frozen track is deleted (or undone away), its source wakes up and plays again. If the
+ source is deleted, the frozen audio becomes an ordinary track, and if you were in the middle
+ of an edit it is no longer left muted.
+- **Flatten during a live-freeze edit no longer leaves a silent track.** The kept audio track
+ is unmuted, and its "(frozen)" suffix is dropped, since it's now an ordinary track.
+- **Unfreezing a live freeze while its frozen track is selected** now selects the source
+ track, instead of leaving the selection on a track that no longer exists.
+
## [0.37.1] — 2026-08-25
### Highlights
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index fe9248b4..6bb8f7f9 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -108,6 +108,12 @@ public sealed partial class ArrangementView : UserControl
/// <summary>Live-freeze (v1.1): per-track role for the header badge — 0 none, 1 sleeping
/// source, 2 linked frozen. Set by MainWindow; queried while rebuilding headers.</summary>
public Func<int, int>? FreezeRole;
+ /// <summary>Freeze / Live Freeze entries for a track's context menu (empty when the track
+ /// can't be frozen). Built by MainWindow, which owns the freeze state and commands.</summary>
+ public Func<int, IReadOnlyList<Control>>? FreezeMenuItems;
+ /// <summary>Called at the start of a full <see cref="Refresh"/>, before the track model is
+ /// rebuilt — MainWindow drops live-freeze links whose tracks were deleted or undone.</summary>
+ public Action? RefreshStarting;
/// <summary>A transient status line the arrangement wants shown (e.g. an automation-follow hint).</summary>
public event Action<string>? StatusMessage;
/// <summary>Raised after a clip is copied into a session slot (M5-6).</summary>
@@ -506,6 +512,7 @@ public sealed partial class ArrangementView : UserControl
/// context menu survive the 60 Hz tick instead of being torn down each frame).</summary>
public void Refresh(bool rebuildHeaders = true)
{
+ if (rebuildHeaders) RefreshStarting?.Invoke();
// Peak reuse (⑤): on a live refresh (no header rebuild) the audio content of existing
// clips can't change — recording appends a separate take drawn elsewhere, and the live
// MIDI-drag path only touches a MIDI clip. So carry each audio clip's already-fetched
@@ -1491,10 +1498,18 @@ public sealed partial class ArrangementView : UserControl
ungroup.Click += (_, _) => UngroupGroup(ungroupId);
}
+ // Freeze ▸ state-dependent entries (Freeze / Live Freeze, or Unfreeze / Edit / Flatten).
+ var freeze = FreezeMenuItems?.Invoke(trackId) ?? Array.Empty<Control>();
+
flyout.Items.Add(rename);
flyout.Items.Add(color);
if (recInput is not null) flyout.Items.Add(recInput);
if (midiFrom is not null) flyout.Items.Add(midiFrom);
+ if (freeze.Count > 0)
+ {
+ flyout.Items.Add(new Separator());
+ foreach (var item in freeze) flyout.Items.Add(item);
+ }
flyout.Items.Add(new Separator());
flyout.Items.Add(group);
if (ungroup is not null) flyout.Items.Add(ungroup);
diff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.cs
index 3319bfc3..1ada16b8 100644
--- a/src/managed/Nota.App/MainWindow.Files.cs
+++ b/src/managed/Nota.App/MainWindow.Files.cs
@@ -192,6 +192,7 @@ public partial class MainWindow
private void OnMenuNew(object? sender, EventArgs e)
{
if (_vm is null) return;
+ _links.Clear(); // no live-freeze links (cleared first: stale ids must not hit the new graph)
Engine.Reset();
// Reset transport to defaults (these setters drive the engine + UI).
_vm.Transport.Bpm = 120;
@@ -202,7 +203,6 @@ public partial class MainWindow
_vm.Transport.TimeSigDenominator = 4;
_projectPath = null;
_learn?.Clear(); // start with a clean MIDI-map for the new project
- _links.Clear(); // and no live-freeze links
RefreshAfterLoad();
UpdateWindowTitle();
_vm.StatusText = "New project.";
@@ -245,6 +245,7 @@ public partial class MainWindow
ProjectLoadResult result;
try { result = _projects.Load(Engine, dir); }
finally { Engine.SetDeferWarpBuild(false); }
+ _links.Clear(); // the old project's live-freeze ids mean nothing in the loaded graph
// Load resets the engine but leaves transport; restore it via the VM.
_vm.Transport.Bpm = (decimal)result.Transport.Bpm;
_vm.Transport.MasterVolume = result.Transport.MasterVolume;
diff --git a/src/managed/Nota.App/MainWindow.Freeze.cs b/src/managed/Nota.App/MainWindow.Freeze.cs
index 7036ad7c..dcfd9328 100644
--- a/src/managed/Nota.App/MainWindow.Freeze.cs
+++ b/src/managed/Nota.App/MainWindow.Freeze.cs
@@ -6,8 +6,10 @@
// the live chain — the mixer strip stays live. Right-click offers Flatten, which
// replaces the track with a plain audio clip of the frozen sound. Frozen state shows
// as an ice tint + snowflake on the arrangement header and a dimmed device chain.
+// The arrangement track context menu exposes the same commands (plus Live Freeze).
using System;
+using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Controls;
@@ -51,10 +53,9 @@ public partial class MainWindow
bool frozen = Engine.IsTrackFrozen(trackId);
FreezeLabel.Text = frozen ? "Frozen" : "Freeze";
- IBrush ice = new SolidColorBrush(Color.Parse("#7FC7EC"));
IBrush idle = (IBrush?)this.FindResource("Brush.TextSecondary") ?? Brushes.Gray;
- FreezeIcon.Foreground = frozen ? ice : idle;
- FreezeLabel.Foreground = frozen ? ice : idle;
+ FreezeIcon.Foreground = frozen ? IceBrush : idle;
+ FreezeLabel.Foreground = frozen ? IceBrush : idle;
EnsureFreezeMenu();
}
@@ -120,23 +121,106 @@ public partial class MainWindow
catch (Exception ex) { _vm.StatusText = $"Freeze failed: {ex.Message}"; }
finally { _vm.SuspendEnginePolling = false; }
- AfterFreezeChange(trackId);
+ AfterFreezeChange();
}
private void UnfreezeTrack(int trackId)
{
Engine.UnfreezeTrack(trackId);
if (_vm is not null) _vm.StatusText = "Track unfrozen.";
- AfterFreezeChange(trackId);
+ AfterFreezeChange();
}
- private void AfterFreezeChange(int trackId)
+ // Refresh the header buttons + chain dim for the *shown* track (not necessarily the one
+ // acted on), then repaint the arrangement header snowflake / ice tint.
+ private void AfterFreezeChange()
{
- UpdateFreezeButton(trackId);
- ApplyFrozenChainDim(trackId);
- Timeline.Refresh(); // repaint the header snowflake / ice tint
+ UpdateFreezeButton(_freezeTrackId);
+ ApplyFrozenChainDim(_freezeTrackId);
+ Timeline.Refresh();
}
+ // --- arrangement track context menu -----------------------------------
+
+ // Freeze entries for a track header's right-click menu, mirroring the header button
+ // cluster: Freeze / Live Freeze on a live track; Unfreeze / Flatten when frozen in place;
+ // Edit (or Done / Discard mid-session) + Unfreeze / Flatten on either side of a live-freeze
+ // link. Each command first selects its track so the device panel and header buttons follow.
+ private IReadOnlyList<Control> BuildTrackFreezeMenu(int trackId)
+ {
+ var items = new List<Control>();
+ if ((LinkForSource(trackId) ?? LinkForFrozen(trackId)) is { } link)
+ {
+ int src = link.SourceId;
+ if (link.State == LinkState.Editing)
+ {
+ items.Add(FreezeMenuItem("Done — re-freeze", GlyphIcon("✓", accent: true),
+ async () => { Timeline.Select(trackId, -1); await CommitEditSessionAsync(src); }));
+ items.Add(FreezeMenuItem("Discard edits", GlyphIcon("✗", accent: false),
+ () => { Timeline.Select(trackId, -1); DiscardEditSession(src); }));
+ }
+ else
+ // Editing changes the source's notes/devices, so land on the source track.
+ items.Add(FreezeMenuItem("Edit source", GlyphIcon("✎", accent: true),
+ () => { Timeline.Select(src, -1); BeginEditSession(src); }));
+ items.Add(FreezeMenuItem("Unfreeze (wake source)", null, () => UnfreezeLink(src)));
+ items.Add(FreezeMenuItem("Flatten (remove source)", null, () => FlattenLinkAsync(src)));
+ return items;
+ }
+
+ if (!IsFreezable(trackId)) return items;
+ if (Engine.IsTrackFrozen(trackId))
+ {
+ items.Add(FreezeMenuItem("Unfreeze track", SnowflakeIcon(),
+ () => { Timeline.Select(trackId, -1); UnfreezeTrack(trackId); }));
+ items.Add(FreezeMenuItem("Flatten to audio track", null,
+ async () => { Timeline.Select(trackId, -1); await FlattenTrackAsync(trackId); }));
+ }
+ else
+ {
+ items.Add(FreezeMenuItem("Freeze track", SnowflakeIcon(),
+ async () => { Timeline.Select(trackId, -1); await FreezeTrackAsync(trackId); }));
+ items.Add(FreezeMenuItem("Live Freeze", ChainLinkIcon(),
+ async () => { Timeline.Select(trackId, -1); await LiveFreezeAsync(trackId); }));
+ }
+ return items;
+ }
+
+ private static MenuItem FreezeMenuItem(string header, Control? icon, Action run)
+ {
+ var mi = new MenuItem { Header = header, Icon = icon };
+ mi.Click += (_, _) => run();
+ return mi;
+ }
+
+ private static MenuItem FreezeMenuItem(string header, Control? icon, Func<Task> run)
+ {
+ var mi = new MenuItem { Header = header, Icon = icon };
+ mi.Click += async (_, _) => await run();
+ return mi;
+ }
+
+ // Menu-icon glyphs matching the arrangement header badges (❄ / chain-link in ice blue)
+ // and the Edit / Done / Discard header buttons.
+ private static readonly IBrush IceBrush = new SolidColorBrush(Color.Parse("#7FC7EC"));
+
+ private static Control SnowflakeIcon()
+ => new TextBlock { Text = "❄", FontSize = 12, Foreground = IceBrush, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center };
+
+ private static Control ChainLinkIcon()
+ => new Avalonia.Controls.Shapes.Path
+ {
+ Data = NotaIcons.ChainLink, Stretch = Stretch.None, Stroke = IceBrush, StrokeThickness = 1.4,
+ Width = 14, Height = 14, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
+ };
+
+ private Control GlyphIcon(string glyph, bool accent)
+ => new TextBlock
+ {
+ Text = glyph, FontSize = 12, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
+ Foreground = (IBrush?)this.FindResource(accent ? "Brush.AccentBright" : "Brush.TextTertiary") ?? Brushes.Gray,
+ };
+
// --- Flatten -----------------------------------------------------------
private async Task FlattenTrackAsync(int trackId)
diff --git a/src/managed/Nota.App/MainWindow.LiveFreeze.cs b/src/managed/Nota.App/MainWindow.LiveFreeze.cs
index ba70f6e8..27bee708 100644
--- a/src/managed/Nota.App/MainWindow.LiveFreeze.cs
+++ b/src/managed/Nota.App/MainWindow.LiveFreeze.cs
@@ -46,6 +46,30 @@ public partial class MainWindow
private int FreezeRoleOf(int trackId)
=> _links.ContainsKey(trackId) ? 1 : LinkForFrozen(trackId) is not null ? 2 : 0;
+ private const string FrozenSuffix = " (frozen)";
+
+ // Drop links whose tracks no longer exist (deleted, cut, or undone away) — runs before
+ // every full arrangement refresh. A lost frozen track wakes its sleeping source; a lost
+ // source leaves the frozen audio as a plain track, un-silenced if it was mid-edit.
+ private void PruneFreezeLinks()
+ {
+ if (_links.Count == 0) return;
+ List<int>? dead = null;
+ foreach (var l in _links.Values)
+ {
+ bool hasSrc = TrackIndexOf(l.SourceId) >= 0, hasFrz = TrackIndexOf(l.FrozenId) >= 0;
+ if (hasSrc && hasFrz) continue;
+ if (hasSrc && l.State == LinkState.Frozen) Engine.SetTrackMute(l.SourceId, false);
+ if (hasFrz && l.State == LinkState.Editing) Engine.SetTrackMute(l.FrozenId, false);
+ (dead ??= new()).Add(l.SourceId);
+ }
+ if (dead is null) return;
+ foreach (int s in dead) _links.Remove(s);
+ if (_vm is not null) _vm.StatusText = "Live-freeze link removed — its track was deleted.";
+ UpdateFreezeButton(_freezeTrackId);
+ ApplyFrozenChainDim(_freezeTrackId);
+ }
+
// --- button cluster (next to the in-place Freeze button) ---------------
// Reflect the shown track's live-freeze state onto the header buttons.
@@ -107,7 +131,7 @@ public partial class MainWindow
for (int b = 0; b < 4; b++) sends[b] = Engine.GetTrackSend(sourceId, b);
int frozenId = Engine.AddAudioTrack();
- Engine.SetTrackName(frozenId, (srcName is { Length: > 0 } ? srcName : $"Track {sourceId}") + " (frozen)");
+ Engine.SetTrackName(frozenId, (srcName is { Length: > 0 } ? srcName : $"Track {sourceId}") + FrozenSuffix);
if (color >= 0) Engine.SetTrackColorIndex(frozenId, color);
Engine.SetTrackVolume(frozenId, vol);
Engine.SetTrackPan(frozenId, pan);
@@ -192,7 +216,7 @@ public partial class MainWindow
_links.Remove(sourceId);
if (_vm is not null) _vm.StatusText = "Unfrozen — the source is live again.";
Timeline.Refresh();
- ShowDevices(sourceId);
+ Timeline.Select(sourceId, -1); // the frozen track may have been selected — it's gone now
}
// Make permanent: keep the frozen audio track, drop the link, and remove the sleeping source.
@@ -207,6 +231,10 @@ public partial class MainWindow
int frozenId = link.FrozenId;
_links.Remove(sourceId);
Engine.RemoveTrack(sourceId);
+ Engine.SetTrackMute(frozenId, false); // flattened mid-edit: the bounce was silenced
+ string name = Engine.GetTrackName(frozenId);
+ if (name.EndsWith(FrozenSuffix, StringComparison.Ordinal))
+ Engine.SetTrackName(frozenId, name[..^FrozenSuffix.Length]); // no longer a "frozen" copy
_vm.StatusText = "Flattened — the frozen audio is now a plain track.";
Timeline.Refresh();
if (Engine.TryGetTrackInfo(TrackIndexOf(frozenId), out _)) Timeline.Select(frozenId, -1);
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index cd9125fc..2432056e 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -138,6 +138,8 @@ public partial class MainWindow : Window
Timeline.Engine = vm.Engine;
Timeline.FreezeRole = FreezeRoleOf; // live-freeze (v1.1) header badges
+ Timeline.FreezeMenuItems = BuildTrackFreezeMenu; // track context menu: Freeze / Live Freeze
+ Timeline.RefreshStarting = PruneFreezeLinks; // drop links to deleted / undone tracks
Timeline.MidiClipActivated += OpenClipEditor;
Timeline.AudioClipActivated += OpenAudioClipEditor;
Timeline.ItemDropped += OnArrangementDrop; // browser drag & drop (M7-5)