Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) Browser: double-click an instrument to swap the selected track's (#145) (#154)
Chris Laupama9ff436f3d12a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8b43daa1..5dc85b26 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -63,6 +63,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.travel with the clip when you move, copy, split, trim or consolidate it, and are saved withthe project. Polyphonic aftertouch from an ordinary keyboard is kept as each note'spressure. MCP: `get_clip_controllers`, `set_clip_controller`.+- **Double-click an instrument to swap the selected track's** (nota-daw/nota#145): with a+ MIDI / instrument track selected, double-clicking an instrument in the browser replaces+ that track's instrument and keeps its clips and effects, so you can try instruments on a+ part one after another (each swap is one undo step). With no track selected, an audio+ track, or a rack selected, it starts a new track as before; ⌥ + double-click (Alt on+ Windows and Linux) always starts a new track.### Fixed- **The clip editor shows the playhead of a playing Session clip** (nota-daw/nota#137):diff --git a/FEATURES.md b/FEATURES.mdindex 87b3efc8..37435b29 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -941,6 +941,9 @@ audio effects after it keep running and keep their settings; saved with the projloads into that track's instrument (switching it if needed; the effects stay).- A drop selects the track it lands on (a newly created one included), in thearrangement and the session view.+- **Double-click an instrument** to put it on the selected MIDI / instrument track in place+ of its instrument (clips and effects stay; one undo step), or on a new track when no such+ track is selected or a rack is. ⌥ + double-click always starts a new track.- **Preset preview**: the same player sits under the Instruments, Audio Effects, MIDIEffects and Presets tabs and plays the selected factory preset, saved preset, drum kit orbuilt-in device (its default sound). These tabs have their own **Auto**, off by default:diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.csindex 3780b9f5..21b4d533 100644--- a/src/managed/Nota.App/BrowserView.cs+++ b/src/managed/Nota.App/BrowserView.cs@@ -175,7 +175,9 @@ public sealed class BrowserView : UserControlprivate readonly Border _statusBar;private readonly TextBlock _statusText;- public event Action<BrowserItem>? ItemActivated;+ /// <summary>A row double-clicked (or opened from its menu), with the keys held — ⌥ asks+ /// an instrument for a new track instead of the selected one.</summary>+ public event Action<BrowserItem, KeyModifiers>? ItemActivated;/// <summary>The Files tab's sample player (status messages ride its StatusChanged).</summary>public PreviewPlayer Preview => _previewFooter;/// <summary>Reveal a sample / folder / project in the system file manager.</summary>@@ -1079,12 +1081,12 @@ public sealed class BrowserView : UserControlprivate void HookActivation(ListBox list){- list.DoubleTapped += (_, _) =>+ list.DoubleTapped += (_, e) =>{if (list.SelectedItem is not BrowserItem { IsGroup: false } item) return;// Folders (sample dirs, preset categories) are navigation: double-click opens them.if (item.Kind == BrowserItemKind.Folder) _vm?.ToggleExpand(item);- else { DismissPreview(); ItemActivated?.Invoke(item); }+ else { DismissPreview(); ItemActivated?.Invoke(item, e.KeyModifiers); }};list.SelectionChanged += (_, _) =>{@@ -1548,7 +1550,7 @@ public sealed class BrowserView : UserControlcase BrowserItemKind.Project:{var open = new MenuItem { Header = "Open" };- open.Click += (_, _) => ItemActivated?.Invoke(item);+ open.Click += (_, _) => ItemActivated?.Invoke(item, KeyModifiers.None);var reveal = new MenuItem { Header = "Reveal in Finder" };reveal.Click += (_, _) => RevealRequested?.Invoke(item);var del = new MenuItem { Header = "Delete…" };diff --git a/src/managed/Nota.App/MainWindow.Browser.cs b/src/managed/Nota.App/MainWindow.Browser.csindex 91ba5bf5..ed7bcda0 100644--- a/src/managed/Nota.App/MainWindow.Browser.cs+++ b/src/managed/Nota.App/MainWindow.Browser.cs@@ -66,10 +66,11 @@ public partial class MainWindowreturn ids;}- // Double-click / Return on a browser row: instruments start a track, effects go to the- // selected track (else the last instrument track), presets apply — through the same- // insert service as drag & drop and the command palette.- private void OnBrowserItemActivated(BrowserItem item)+ // Double-click on a browser row: an instrument replaces the selected instrument track's+ // instrument (clips and effects stay) — else, or with ⌥ held, it starts a track; effects+ // go to the selected track (else the last instrument track), presets apply — through the+ // same insert service as drag & drop and the command palette.+ private void OnBrowserItemActivated(BrowserItem item, KeyModifiers mods){if (_vm is null) return;try@@ -80,7 +81,7 @@ public partial class MainWindowcase BrowserItemKind.BuiltinInstrument:case BrowserItemKind.PluginInstrument:{- var r = Insertion.Insert(item, new InsertTarget(-1, NewTrack: true));+ var r = Insertion.Insert(item, Insertion.ActivationTarget(Timeline.SelectedTrackId, (mods & KeyModifiers.Alt) != 0));ApplyInsertResult(r, revealDevices: item.BuiltinKind is 1 or 3 or 4 && item.Kind == BrowserItemKind.BuiltinInstrument);break;}diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 15a2bfb4..68e5071d 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -1203,6 +1203,8 @@ public sealed partial class PreferencesWindow : NotaWindow("Mouse", new[]{("Double-click clip", "Open in the clip editor"),+ ("Double-click a browser instrument", "Swap it onto the selected instrument track · clips and effects stay · no track selected starts one"),+ ("⌥ + double-click a browser instrument", "Always start a new track with it"),("Right-click the metronome", "Count-in before Play / Record: off · 1 · 2 · 4 bars"),("Drag an audio clip's ADSR handle", "Shape attack · decay + sustain · release (top corners and the dot on hover) · double-click resets the stage"),("⇧-click track header", "Add the track to the selection · again to remove it"),diff --git a/src/managed/Nota.Presentation/DeviceInsertService.cs b/src/managed/Nota.Presentation/DeviceInsertService.csindex e852d82f..5e28381b 100644--- a/src/managed/Nota.Presentation/DeviceInsertService.cs+++ b/src/managed/Nota.Presentation/DeviceInsertService.cs@@ -170,6 +170,14 @@ public sealed class DeviceInsertService// ---- the entry points ---------------------------------------------------------------------+ /// <summary>Double-click on an instrument in the browser: it replaces the instrument of the+ /// selected plain instrument track (clips and effects stay); with no track selected, an+ /// audio track, a rack — or ⌥ held (<paramref name="alwaysNewTrack"/>) — it starts a track.</summary>+ public InsertTarget ActivationTarget(int selectedTrackId, bool alwaysNewTrack)+ => !alwaysNewTrack && CanReplaceInstrument(selectedTrackId)+ ? new InsertTarget(selectedTrackId, InsertPlacement.Replace)+ : new InsertTarget(-1, NewTrack: true);+/// <summary>Drag & drop onto an arrangement lane: an instrument replaces a plain track's/// instrument or starts its own track at the drop beat; effects and presets go to the/// track. Samples and MIDI files are imported by the view (they decode in the background).</summary>diff --git a/tests/Nota.SmokeTest/PaletteTests.cs b/tests/Nota.SmokeTest/PaletteTests.csindex f27dbb52..95aebcd9 100644--- a/tests/Nota.SmokeTest/PaletteTests.cs+++ b/tests/Nota.SmokeTest/PaletteTests.cs@@ -249,6 +249,20 @@ internal static class PaletteTestsvar r = svc.Insert(aurora, PaletteInsert.TargetFor(arr with { TrackId = g }, instItem, ApplyMode.NewTrack));yield return (r.CreatedTrack && eng.TrackCount == tracksBefore + 1, "⌘Enter puts an instrument on a new track");+ // Double-click in the browser (#145): the selected instrument track swaps its+ // instrument, clips and effects kept, one undo step; ⌥, no selection, an audio track+ // or a rack start a track instead.+ int s = Track(); int n = eng.TrackCount;+ var swap = svc.Insert(aurora, svc.ActivationTarget(s, alwaysNewTrack: false));+ yield return (swap.Ok && swap.InstrumentReplaced && !swap.CreatedTrack && eng.TrackCount == n && eng.TrackInstrumentKind(s) == 5+ && Chain(s) == "0,3" && eng.TryGetClipInfo(s, 0, out _),+ $"browser double-click swaps the selected track's instrument, keeping clips and effects ({swap.Status})");+ yield return (eng.Undo() && eng.TrackInstrumentKind(s) == 6 && Chain(s) == "0,3" && eng.TrackCount == n, "…and one undo brings the old instrument back");+ int audio = eng.AddAudioTrack(), rack = svc.CreateInstrumentTrack(Dev(3, BrowserItemKind.BuiltinInstrument), 0);+ yield return (svc.ActivationTarget(s, alwaysNewTrack: true).NewTrack && svc.ActivationTarget(-1, false).NewTrack+ && svc.ActivationTarget(audio, false).NewTrack && svc.ActivationTarget(rack, false).NewTrack,+ "…while ⌥, no selection, an audio track or a rack start a new track");+int h = Track();int devicesBefore = eng.TrackDeviceCount(h);svc.Insert(reverb, new InsertTarget(h, InsertPlacement.Insert, 1));