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
Drop the automation record modes for contextual recording
Egor Khindikaynenbb662595bff0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8aecc71a..bfea2848 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,18 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.restart — and the choice is remembered.### Changed+- **Automation has no record modes any more.** Read / Touch / Latch / Write are gone, and+ the **Automation** button now only shows and edits the lanes. Automation always plays+ back, and recording is contextual, the way Live does it: engage the transport **Record**+ button and move a control, and that parameter's lane records what you do. A control you+ move with the mouse stops writing the moment you let go; a hardware knob, fader, stick+ or trigger keeps writing its last value until the transport stops, because a physical+ control has no release. The per-parameter **REC** arm button on the lane header is gone+ with the Write mode it existed for.+- **Touching an automated parameter while not recording overrides its lane**, so the knob+ answers your hand instead of being dragged back by the envelope on the next block. A+ **Re-enable Automation** button appears in the toolbar while anything is overridden;+ one click hands every overridden lane back to playback.- The colour tokens in `NotaTheme.axaml` now live in theme dictionaries, and `NotaPalette`hands out brushes that re-tint in place, so both the XAML and the custom-drawn layerfollow the active variant. The ~970 hex literals that had accumulated across the devicediff --git a/FEATURES.md b/FEATURES.mdindex b9da569c..921ac597 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -186,8 +186,13 @@ the mixer opens as a separate floating window (**View → Mixer**, ⌘M).they sort to the top of the list).- **Selection and paste**: shift-select a range, Cmd/Ctrl+D to duplicate, and paste thatdoes not leave redundant points behind.-- **Recording** automation (arm), and reading it during playback and scrubbing (volume and- pan controls follow the automation).+- **Recording** automation: there are no record modes — lanes always play back, and with+ the transport **Record** button engaged, moving a control writes that parameter's lane.+ A mouse gesture stops writing on release; a hardware control (MIDI knob, fader, gamepad+ stick or trigger) latches and keeps writing until the transport stops.+- **Overriding** — touch an automated parameter while not recording and the lane hands+ control to you; the toolbar's **Re-enable Automation** button gives it back.+- **Reading** during playback and scrubbing (volume and pan controls follow the automation).- **MIDI Learn** — the MIDI button in the top right enters learn mode: mappable controlslight up, and a click plus a move on the controller creates the binding. Mappabletargets cover every built-in instrument, effect and MIDI FX parameter (switches, ADSRdiff --git a/src/managed/Nota.App/ArrangementView.Automation.cs b/src/managed/Nota.App/ArrangementView.Automation.csindex 5ae7e4cb..de117580 100644--- a/src/managed/Nota.App/ArrangementView.Automation.cs+++ b/src/managed/Nota.App/ArrangementView.Automation.cs@@ -314,18 +314,6 @@ public sealed partial class ArrangementViewelse e.SetAutomationPoints(t.Id, lane, pts);}- // Arm the current target for Write recording (M9-C). paramIndex only matters- // for DeviceParam; PluginParam is keyed by paramId, others ignore both.- private int ArmParamIndex(TrackVM t) => t.AutoTarget is AutomationTarget.DeviceParam or AutomationTarget.MidiDeviceParam ? t.AutoParamIndex : -1;- internal bool AutoArmed(TrackVM t)- => _engine is { } e && e.IsAutomationArmed(t.Id, t.AutoTarget, t.AutoDeviceIndex, ArmParamIndex(t), t.AutoParamId);- internal void ToggleAutoArm(TrackVM t)- {- if (_engine is not { } e) return;- e.SetAutomationArm(t.Id, t.AutoTarget, t.AutoDeviceIndex, ArmParamIndex(t), t.AutoParamId, !AutoArmed(t));- Redraw();- }-/// <summary>Target picker: Volume / Pan / built-in device params, plus a/// filterable param picker + "Learn" for each hosted plugin (M9-B3).</summary>internal void ShowAutoTargetMenu(Control anchor, TrackVM t)diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex 0563dc26..f3a4c349 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -97,8 +97,8 @@ public sealed partial class ArrangementViewprivate double _rangeAnchor;public bool IsEditingPoint => _autoDrag != null || _bendLeft != null; // M9-C/D: don't clobber a hand-editprivate static double RowTop(int i) => i * ArrangementView.RowHeight;- // Target-selector pill: width fits its label so nothing clips; REC button sits after it.- private const double PillH = 16, RecW = 40, GapW = 5;+ // Target-selector pill: width fits its label so nothing clips.+ private const double PillH = 16;private static double PillWidth(string label){var ft = new FormattedText(label, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,@@ -106,7 +106,6 @@ public sealed partial class ArrangementViewreturn Math.Clamp(Math.Ceiling(ft.Width) + 12, 34, 180);}private static Rect PillRect(int i, double w) => new(4, RowTop(i) + 3, w, PillH);- private static Rect RecRect(int i, double pillW) => new(4 + pillW + GapW, RowTop(i) + 3, RecW, PillH); // write-arm (M9-C)private double ValueToY(TrackVM t, int row, float v){var (min, max) = _o.AutoRange(t);@@ -554,7 +553,6 @@ public sealed partial class ArrangementViewdouble pillW = PillWidth(t.AutoLabel);if (PillRect(i, pillW).Contains(pos)) { _o.ShowAutoTargetMenu(this, t); return; }- if (RecRect(i, pillW).Contains(pos)) { _o.ToggleAutoArm(t); return; } // write-arm (M9-C)double curBeat = Math.Max(0, _o.SnapMaybe(_o._scrollBeats + pos.X / _o._pixelsPerBeat, e.KeyModifiers));@@ -1479,16 +1477,6 @@ public sealed partial class ArrangementViewFlowDirection.LeftToRight, Typeface.Default, 9, content);using (ctx.PushClip(pill))ctx.DrawText(ft, new Point(pill.X + 6, pill.Y + (PillH - ft.Height) / 2));-- // Write-arm button (M9-C): a record-style pill — red dot + "REC", lit when armed.- var rec = RecRect(i, pillW);- bool armed = _o.AutoArmed(t);- ctx.DrawRectangle(armed ? RecBgOn : RecBgOff, AutoArmOff, rec, 3, 3);- var dotC = new Point(rec.X + 9, rec.Y + rec.Height / 2);- ctx.DrawEllipse(armed ? AutoArmOn : RecDotOff, null, dotC, 3.5, 3.5);- var rt = new FormattedText("REC", CultureInfo.InvariantCulture,- FlowDirection.LeftToRight, Typeface.Default, 8, armed ? AutoArmOn : RecTextOff);- ctx.DrawText(rt, new Point(dotC.X + 6, rec.Y + (PillH - rt.Height) / 2));}}}diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex 2a8d12bf..d63f7bc4 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -305,20 +305,14 @@ public sealed partial class ArrangementView : UserControlget => _automationMode;set { if (_automationMode == value) return; _automationMode = value; Refresh(); }}- private AutomationWriteMode _autoWriteMode;- /// <summary>Current record mode (M9-C) — drives the arm dot + live envelope refresh.</summary>- public AutomationWriteMode AutomationWriteMode- {- get => _autoWriteMode;- set { _autoWriteMode = value; if (_automationMode) Redraw(); }- }/// <summary>While recording, reload the visible envelopes so writes appear live (M9-C).</summary>public void RefreshAutomationLive(){- // Only reload while actually recording: a write mode + playing + no hand-drag- // in progress. Otherwise this would clobber manual envelope editing.- if (!_automationMode || _autoWriteMode == AutomationWriteMode.Read) return;- if (_engine is not { IsPlaying: true }) return;+ // Only reload while actually recording: automation record on + playing + no+ // hand-drag in progress. Otherwise this would clobber manual envelope editing.+ if (!_automationMode) return;+ var eng = _engine;+ if (eng is not { IsPlaying: true } || !eng.AutomationRecording) return;if (_lanes.IsEditingPoint) return;foreach (var t in _tracks) LoadAutoPoints(t);_lanes.InvalidateVisual();@@ -1946,12 +1940,6 @@ public sealed partial class ArrangementView : UserControlprivate static readonly IPen AutoBasePen = new Pen(NotaPalette.TextTertiary, 1){ DashStyle = new DashStyle(new double[] { 3, 3 }, 0) };// Write-arm REC button (M9-C): red dot + "REC", lit when armed.- private static readonly IBrush AutoArmOn = NotaPalette.Danger; // Brush.Danger-ish- private static readonly IPen AutoArmOff = new Pen(NotaPalette.TextTertiary, 1);- private static readonly IBrush RecBgOff = NotaPalette.SurfaceInset; // sunken chip- private static readonly IBrush RecBgOn = NotaPalette.Wash(NotaPalette.Danger, 0x33);- private static readonly IBrush RecDotOff = NotaPalette.TextTertiary;- private static readonly IBrush RecTextOff = NotaPalette.TextSecondary;// Hover feedback (M9-D): brass-accent brighter line + point ring under the cursor.private static readonly IPen AutoHoverPen = new Pen(PlayheadBrush, 2.6);private static readonly IPen AutoHoverRing = new Pen(PlayheadBrush, 1.5);diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.csindex 46e00e05..2d76db9d 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs@@ -79,7 +79,7 @@ internal sealed class ChamberDeviceBody : IDeviceBodyvoid Begin(int p) => engine.BeginAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");void End(int p) => engine.EndAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");void Raw(int p, float v) => engine.DeviceSetParam(track, di, p, Math.Clamp(v, 0f, 1f));- // A discrete edit (click) is one automation gesture, so Touch / Latch / Write record it.+ // A discrete edit (click) is one automation gesture, so it records while the transport does.void SetP(int p, float v) { Begin(p); Raw(p, v); End(p); }bool On(int p) => P(p) >= 0.5f;int Sel(int p, int n) => Math.Clamp((int)Math.Round(P(p) * (n - 1)), 0, n - 1);diff --git a/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.csindex e8c45f74..d8c3cb6f 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs@@ -68,7 +68,7 @@ internal sealed class PrismDeviceBody : IDeviceBodyvoid Begin(int p) => engine.BeginAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");void End(int p) => engine.EndAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");void Raw(int p, float v) => engine.DeviceSetParam(track, di, p, Math.Clamp(v, 0f, 1f));- // A discrete edit (click) is one automation gesture, so Touch / Latch / Write record it.+ // A discrete edit (click) is one automation gesture, so it records while the transport does.void SetP(int p, float v) { Begin(p); Raw(p, v); End(p); }bool On(int p) => P(p) >= 0.5f;int Sel(int p, int n) => Math.Clamp((int)Math.Round(P(p) * (n - 1)), 0, n - 1);diff --git a/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.csindex 47228095..ff8564a1 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs@@ -98,7 +98,7 @@ internal sealed class ConsortInstrumentCard : IInstrumentCardvoid End(string id) => engine.EndAutomationWrite(track, AutomationTarget.PluginParam, -1, -1, id);List<ConsortCable>? cableCache = null; // one read of the 36 cable params per tick / editvoid Raw(string id, float v) { if (I(id) is var i and >= 0) { engine.PluginParamSet(track, -1, i, Math.Clamp(v, 0f, 1f)); cableCache = null; } }- // A discrete edit (click) is one automation gesture, so Touch/Latch/Write record it.+ // A discrete edit (click) is one automation gesture, so it records while the transport does.void SetP(string id, float v) { if (I(id) < 0) return; Begin(id); Raw(id, v); End(id); }var common = new List<Action>();diff --git a/src/managed/Nota.App/DeviceCards/Instruments/PentadInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/PentadInstrumentCard.csindex 16508020..b3101752 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/PentadInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/PentadInstrumentCard.cs@@ -72,7 +72,7 @@ internal sealed class PentadInstrumentCard : IInstrumentCardint I(string id) => idx.TryGetValue(id, out var i) ? i : -1;bool On(string id) => G(id) > 0.5f;int Sel(string id, int n) => Math.Clamp((int)Math.Round(G(id) * (n - 1)), 0, n - 1);- // A discrete edit (click) is one automation gesture, so Touch/Latch/Write record it.+ // A discrete edit (click) is one automation gesture, so it records while the transport does.void SetP(string id, float v){if (I(id) is not (var i and >= 0)) return;diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex 32b63298..89b36164 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -245,16 +245,12 @@<ToggleButton x:Name="AutomationToggle" Classes="seg" Content="Automation"Click="OnToggleAutomation" ToolTip.Tip="Show parameter-automation lanes"/></Border>- <!-- Automation record mode (M9-C): Read / Touch / Latch / Write.- Only shown while automation editing is active. -->- <Border x:Name="AutoModeBar" Classes="segmented" IsVisible="False" ToolTip.Tip="Automation record mode">- <StackPanel Orientation="Horizontal" Spacing="2">- <ToggleButton x:Name="AutoModeRead" Classes="seg" Content="Read" IsChecked="True" Click="OnAutoModeRead"/>- <ToggleButton x:Name="AutoModeTouch" Classes="seg" Content="Touch" Click="OnAutoModeTouch"/>- <ToggleButton x:Name="AutoModeLatch" Classes="seg" Content="Latch" Click="OnAutoModeLatch"/>- <ToggleButton x:Name="AutoModeWrite" Classes="seg" Content="Write" Click="OnAutoModeWrite"/>- </StackPanel>- </Border>+ <!-- Shown only while a hand-moved control has taken a lane over from+ playback (M9-C); one click hands every overridden lane back. -->+ <Button x:Name="ReenableAutoBtn" Classes="chip" Content="Re-enable Automation"+ IsVisible="False" Click="OnReenableAutomation"+ Foreground="{DynamicResource Brush.AccentBright}"+ ToolTip.Tip="A control you moved is overriding its automation — click to hand it back"/></StackPanel></Grid></Border>diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 00e30589..dbd39782 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -201,6 +201,7 @@ public partial class MainWindow : Window_masterMeter?.Push(vm.Engine.MasterMeter());Timeline.UpdateMeters(); // per-track headers (M6-2)Timeline.RefreshAutomationLive(); // show writes live (M9-C)+ SyncReenableAutomation(); // "a control is overriding its lane"if (_session?.IsVisible == true) _session.UpdateStates(); // live launch/queue/playif (_mixer?.IsVisible == true) _mixer.UpdateMeters(); // Mixer tab stripsif (_modular?.IsVisible == true) _modular.Tick(vm.Engine.IsPlaying); // graph knobs follow automation + edge pulse@@ -503,26 +504,24 @@ public partial class MainWindow : Windowif (on) Browser.ShowMidiMap();}+ // The Automation button only shows/edits the lanes: there are no record modes.+ // Recording is contextual — with the transport record engaged, moving a control+ // writes its lane (a mouse gesture stops on release, a hardware control latches).private void OnToggleAutomation(object? sender, RoutedEventArgs e)+ => Timeline.AutomationMode = AutomationToggle.IsChecked == true;++ /// <summary>Hand every lane a hand-moved control took over back to playback (M9-C).</summary>+ private void OnReenableAutomation(object? sender, RoutedEventArgs e){- bool on = AutomationToggle.IsChecked == true;- Timeline.AutomationMode = on;- AutoModeBar.IsVisible = on; // record-mode selector is only relevant in automation mode- if (!on) SetAutoMode(AutomationWriteMode.Read, AutoModeRead); // no stray recording while hidden+ _vm?.Engine.ReenableAutomation();+ SyncReenableAutomation();}- // Automation record mode (M9-C): mutually-exclusive segmented Read/Touch/Latch/Write.- private void SetAutoMode(AutomationWriteMode mode, ToggleButton active)+ /// <summary>Show the "Re-enable Automation" chip while any lane is overridden. Called+ /// from the ~30 Hz tick; the engine query is a cheap flag read.</summary>+ internal void SyncReenableAutomation(){- AutoModeRead.IsChecked = active == AutoModeRead;- AutoModeTouch.IsChecked = active == AutoModeTouch;- AutoModeLatch.IsChecked = active == AutoModeLatch;- AutoModeWrite.IsChecked = active == AutoModeWrite;- _vm?.Engine.SetAutomationWriteMode(mode);- if (Timeline is not null) Timeline.AutomationWriteMode = mode;+ bool on = _vm is { } vm && vm.Engine.AutomationOverridden;+ if (ReenableAutoBtn.IsVisible != on) ReenableAutoBtn.IsVisible = on;}- private void OnAutoModeRead(object? sender, RoutedEventArgs e) => SetAutoMode(AutomationWriteMode.Read, AutoModeRead);- private void OnAutoModeTouch(object? sender, RoutedEventArgs e) => SetAutoMode(AutomationWriteMode.Touch, AutoModeTouch);- private void OnAutoModeLatch(object? sender, RoutedEventArgs e) => SetAutoMode(AutomationWriteMode.Latch, AutoModeLatch);- private void OnAutoModeWrite(object? sender, RoutedEventArgs e) => SetAutoMode(AutomationWriteMode.Write, AutoModeWrite);}diff --git a/src/managed/Nota.App/MidiLearnService.cs b/src/managed/Nota.App/MidiLearnService.csindex 830ea9ad..0eb3b1c9 100644--- a/src/managed/Nota.App/MidiLearnService.cs+++ b/src/managed/Nota.App/MidiLearnService.cs@@ -263,6 +263,8 @@ public sealed class MidiLearnServiceif (m.Invert) norm = 1.0 - norm;double outv = m.RangeMin + norm * (m.RangeMax - m.RangeMin); // 0..1 within the mapped window+ BeginLatchWrite(t); // a hardware move is a latching automation gesture+switch (t.Kind){case MidiTargetKind.DeviceParam:@@ -296,6 +298,35 @@ public sealed class MidiLearnService}}+ // Moving a hardware control (knob, fader, stick, trigger) is a latching automation+ // gesture: while the transport is recording it writes this parameter's lane and keeps+ // writing past the release until the transport stops — a physical control has no+ // "release", so Live's Latch is the behaviour that fits. With record off, the engine+ // turns this into an override of an already-automated lane, and ignores it otherwise.+ // Targets with no automation lane of their own (master volume, rack chains) are skipped.+ private void BeginLatchWrite(MidiTarget t)+ {+ switch (t.Kind)+ {+ case MidiTargetKind.DeviceParam:+ _engine.BeginAutomationWrite(t.TrackId, AutomationTarget.DeviceParam, t.DeviceIndex, t.ParamIndex, "", latch: true);+ break;+ case MidiTargetKind.MidiDeviceParam:+ _engine.BeginAutomationWrite(t.TrackId, AutomationTarget.MidiDeviceParam, t.DeviceIndex, t.ParamIndex, "", latch: true);+ break;+ case MidiTargetKind.PluginParam:+ _engine.BeginAutomationWrite(t.TrackId, AutomationTarget.PluginParam, t.DeviceIndex, -1,+ _engine.PluginParamId(t.TrackId, t.DeviceIndex, t.ParamIndex), latch: true);+ break;+ case MidiTargetKind.TrackVolume:+ _engine.BeginAutomationWrite(t.TrackId, AutomationTarget.Volume, -1, -1, "", latch: true);+ break;+ case MidiTargetKind.TrackPan:+ _engine.BeginAutomationWrite(t.TrackId, AutomationTarget.Pan, -1, -1, "", latch: true);+ break;+ }+ }+private void Trigger(MidiTarget t){switch (t.Kind)diff --git a/src/managed/Nota.Application/Engine/EngineContracts.cs b/src/managed/Nota.Application/Engine/EngineContracts.csindex 9e388950..f5fb18e6 100644--- a/src/managed/Nota.Application/Engine/EngineContracts.cs+++ b/src/managed/Nota.Application/Engine/EngineContracts.cs@@ -117,9 +117,6 @@ public struct NotaMeter/// <summary>What a parameter-automation lane drives (M9). Matches native AutomationTarget.</summary>public enum AutomationTarget { Volume = 0, Pan = 1, DeviceParam = 2, PluginParam = 3, MidiDeviceParam = 4 }-/// <summary>Automation record mode (M9-C). Read = play back only; Touch/Latch record-/// while a control is touched; Write records armed targets from playback.</summary>-public enum AutomationWriteMode { Read = 0, Touch = 1, Latch = 2, Write = 3 }/// <summary>MIDI clip envelope target (M9 follow-up). Velocity scales note velocities;/// Volume scales the instrument output during the clip.</summary>diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.csindex 275a70bf..e6cd2818 100644--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs@@ -693,17 +693,22 @@ public interface IAudioEngine : IDisposablestring AutomationLaneParamId(int trackId, int laneIndex);int PluginLastTouchedParam(int trackId, int deviceIndex); // "Learn" (M9-B3)bool AutomationWriteSelfTest(); // M9-C: device-free write-path check- // Automation record (M9-C). deviceIndex < 0 = instrument; paramId for PluginParam.- void SetAutomationWriteMode(AutomationWriteMode mode);- AutomationWriteMode GetAutomationWriteMode();- void BeginAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId);+ // Automation record (M9-C). There are no record modes: lanes always play back, and+ // a control gesture records while automation record is on (the transport record+ // button drives it). deviceIndex < 0 = instrument; paramId for PluginParam.+ void SetAutomationRecord(bool on);+ bool AutomationRecording { get; }+ /// <summary><paramref name="latch"/> marks a hardware/MIDI control: it keeps writing past+ /// the release until the transport stops. Mouse gestures pass false.</summary>+ void BeginAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId, bool latch = false);/// <summary>Raised (UI thread) when a control begins an automation-write gesture, so the/// arrangement can follow the touched param in automation mode. Args: trackId, target,/// deviceIndex, paramIndex, paramId.</summary>event System.Action<int, AutomationTarget, int, int, string>? AutomationTouched;void EndAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId);- void SetAutomationArm(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId, bool armed);- bool IsAutomationArmed(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId);+ /// <summary>Hand every lane a hand-moved control took over back to playback.</summary>+ void ReenableAutomation();+ bool AutomationOverridden { get; }int AddAutomationLane(int trackId, AutomationTarget target, int deviceIndex, int paramIndex);int AutomationLaneCount(int trackId);AutomationLaneInfo AutomationLaneInfo(int trackId, int laneIndex);diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Automation.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Automation.csindex e6a3dde2..4edf5b5a 100644--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Automation.cs+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Automation.cs@@ -30,23 +30,23 @@ internal static partial class NativeMethods[LibraryImport(Lib, EntryPoint = "nota_engine_automation_write_selftest")]internal static partial int AutomationWriteSelfTest(IntPtr engine);- [LibraryImport(Lib, EntryPoint = "nota_engine_set_automation_write_mode")]- internal static partial void SetAutomationWriteMode(IntPtr engine, int mode);+ [LibraryImport(Lib, EntryPoint = "nota_engine_set_automation_record")]+ internal static partial void SetAutomationRecord(IntPtr engine, int on);- [LibraryImport(Lib, EntryPoint = "nota_engine_automation_write_mode")]- internal static partial int AutomationWriteMode(IntPtr engine);+ [LibraryImport(Lib, EntryPoint = "nota_engine_automation_record")]+ internal static partial int AutomationRecord(IntPtr engine);[LibraryImport(Lib, EntryPoint = "nota_track_begin_automation_write", StringMarshalling = StringMarshalling.Utf8)]- internal static partial void BeginAutomationWrite(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex, string paramId);+ internal static partial void BeginAutomationWrite(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex, string paramId, int latch);[LibraryImport(Lib, EntryPoint = "nota_track_end_automation_write", StringMarshalling = StringMarshalling.Utf8)]internal static partial void EndAutomationWrite(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex, string paramId);- [LibraryImport(Lib, EntryPoint = "nota_track_set_automation_arm", StringMarshalling = StringMarshalling.Utf8)]- internal static partial void SetAutomationArm(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex, string paramId, int armed);+ [LibraryImport(Lib, EntryPoint = "nota_engine_reenable_automation")]+ internal static partial void ReenableAutomation(IntPtr engine);- [LibraryImport(Lib, EntryPoint = "nota_track_automation_armed", StringMarshalling = StringMarshalling.Utf8)]- internal static partial int AutomationArmed(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex, string paramId);+ [LibraryImport(Lib, EntryPoint = "nota_engine_automation_overridden")]+ internal static partial int AutomationOverridden(IntPtr engine);[LibraryImport(Lib, EntryPoint = "nota_track_add_automation_lane")]internal static partial int AddAutomationLane(IntPtr engine, int trackId, int target, int deviceIndex, int paramIndex);diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Automation.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Automation.csindex bae97dee..2835bc61 100644--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Automation.cs+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Automation.cs@@ -22,29 +22,35 @@ public sealed partial class NotaEnginepublic bool RackSelfTest(){ ThrowIfDisposed(); return NativeMethods.RackSelfTest(_handle) != 0; }- /// <summary>Device-free self-test (M9-C): automation write path (Touch + Write-via-arm).</summary>+ /// <summary>Device-free self-test (M9-C): automation write path (touch, latch, override).</summary>public bool AutomationWriteSelfTest(){ ThrowIfDisposed(); return NativeMethods.AutomationWriteSelfTest(_handle) != 0; }// --- automation write / record (M9-C). deviceIndex < 0 = instrument. ---- public void SetAutomationWriteMode(AutomationWriteMode mode)- { ThrowIfDisposed(); NativeMethods.SetAutomationWriteMode(_handle, (int)mode); }- public AutomationWriteMode GetAutomationWriteMode()- { ThrowIfDisposed(); return (AutomationWriteMode)NativeMethods.AutomationWriteMode(_handle); }+ /// <summary>While on, a control gesture records into that parameter's lane. The+ /// transport record button drives this — <see cref="SetRecording"/> sets it too.</summary>+ public void SetAutomationRecord(bool on)+ { ThrowIfDisposed(); NativeMethods.SetAutomationRecord(_handle, on ? 1 : 0); }+ public bool AutomationRecording+ { get { ThrowIfDisposed(); return NativeMethods.AutomationRecord(_handle) != 0; } }/// <summary>Fires on every control gesture-begin so the arrangement can follow a touched knob.</summary>public event System.Action<int, AutomationTarget, int, int, string>? AutomationTouched;- public void BeginAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId)+ /// <summary><paramref name="latch"/> marks a hardware/MIDI control: it keeps writing+ /// past the release until the transport stops. Mouse gestures pass false.</summary>+ public void BeginAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId, bool latch = false){ThrowIfDisposed();AutomationTouched?.Invoke(trackId, target, deviceIndex, paramIndex, paramId ?? "");- NativeMethods.BeginAutomationWrite(_handle, trackId, (int)target, deviceIndex, paramIndex, paramId ?? "");+ NativeMethods.BeginAutomationWrite(_handle, trackId, (int)target, deviceIndex, paramIndex, paramId ?? "", latch ? 1 : 0);}public void EndAutomationWrite(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId){ ThrowIfDisposed(); NativeMethods.EndAutomationWrite(_handle, trackId, (int)target, deviceIndex, paramIndex, paramId ?? ""); }- public void SetAutomationArm(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId, bool armed)- { ThrowIfDisposed(); NativeMethods.SetAutomationArm(_handle, trackId, (int)target, deviceIndex, paramIndex, paramId ?? "", armed ? 1 : 0); }- public bool IsAutomationArmed(int trackId, AutomationTarget target, int deviceIndex, int paramIndex, string paramId)- { ThrowIfDisposed(); return NativeMethods.AutomationArmed(_handle, trackId, (int)target, deviceIndex, paramIndex, paramId ?? "") != 0; }+ /// <summary>Hand every lane the user took over by hand back to playback.</summary>+ public void ReenableAutomation()+ { ThrowIfDisposed(); NativeMethods.ReenableAutomation(_handle); }+ /// <summary>True while at least one lane is overridden by a hand-moved control.</summary>+ public bool AutomationOverridden+ { get { ThrowIfDisposed(); return NativeMethods.AutomationOverridden(_handle) != 0; } }public int AddAutomationLane(int trackId, AutomationTarget target, int deviceIndex, int paramIndex){ ThrowIfDisposed(); return NativeMethods.AddAutomationLane(_handle, trackId, (int)target, deviceIndex, paramIndex); }diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.hindex ce7f0227..3438bf46 100644--- a/src/native/nota.engine/include/nota/nota_engine.h+++ b/src/native/nota.engine/include/nota/nota_engine.h@@ -264,22 +264,25 @@ NOTA_API const char* nota_track_automation_lane_param_id(const NotaEngine* enginNOTA_API int32_t nota_plugin_last_touched_param(NotaEngine* engine, int32_t track_id, int32_t device_index);/* ---- automation write / record (M9-C) ------------------------------------ * Device-free self-test of the write path (Touch gesture + Write-via-arm). The- * full mode/begin/end/arm C ABI arrives in W2. */+ * Device-free self-test of the write path (touch, latch, override/re-enable). */NOTA_API int32_t nota_engine_automation_write_selftest(NotaEngine* engine);-/* Record mode: 0=Read, 1=Touch, 2=Latch, 3=Write. begin/end bracket a control- * gesture (Touch/Latch); arm marks a target for Write (records from play). For a+/* There are no record modes: lanes always play back, and gestures record while+ * automation record is on (the transport record button drives it — engaging it+ * via nota_engine_set_recording sets this too). begin/end bracket a control+ * gesture; latch != 0 means a hardware/MIDI control, which keeps writing past the+ * release until the transport stops. With record off, touching a parameter that+ * already carries automation overrides its lane until re-enable. For a* PluginParam target pass param_id; otherwise param_id may be NULL/empty. */-NOTA_API void nota_engine_set_automation_write_mode(NotaEngine* engine, int32_t mode);-NOTA_API int32_t nota_engine_automation_write_mode(const NotaEngine* engine);+NOTA_API void nota_engine_set_automation_record(NotaEngine* engine, int32_t on);+NOTA_API int32_t nota_engine_automation_record(const NotaEngine* engine);NOTA_API void nota_track_begin_automation_write(NotaEngine* engine, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id);+ int32_t target, int32_t device_index, int32_t param_index, const char* param_id,+ int32_t latch);NOTA_API void nota_track_end_automation_write(NotaEngine* engine, int32_t track_id,int32_t target, int32_t device_index, int32_t param_index, const char* param_id);-NOTA_API void nota_track_set_automation_arm(NotaEngine* engine, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id, int32_t armed);-NOTA_API int32_t nota_track_automation_armed(const NotaEngine* engine, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id);+/* Hand every hand-overridden lane back to playback, and whether any is overridden. */+NOTA_API void nota_engine_reenable_automation(NotaEngine* engine);+NOTA_API int32_t nota_engine_automation_overridden(const NotaEngine* engine);/* ---- DSP load (Phase 11) -------------------------------------------------* Smoothed real-time render load, 0..1 (render time / audio block budget).diff --git a/src/native/nota.engine/src/Engine.cpp b/src/native/nota.engine/src/Engine.cppindex 20da40e7..c0932b54 100644--- a/src/native/nota.engine/src/Engine.cpp+++ b/src/native/nota.engine/src/Engine.cpp@@ -396,6 +396,10 @@ void Engine::reset() {recording_.store(false, std::memory_order_relaxed);if (audioRecording_) stopAudioRecording();stopPreview();+ // Drop automation write/override state: its lane indices belong to the old project.+ activeWrites_.clear();+ overrides_.clear();+ autoRecord_.store(false, std::memory_order_relaxed);// Publish an empty graph (no undo checkpoint — a load is a fresh baseline)// and reset the id counter and history. A fresh master effect chain comes with it.auto empty = std::make_shared<Graph>();diff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex 3fbe8cc8..de88ef52 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -220,16 +220,20 @@ public:std::string automationLaneParamId(int32_t trackId, int32_t laneIndex) const;// --- automation write / record (M9-C) ---- // Mode gates recording: Read=0 (default), Touch=1, Latch=2, Write=3. begin/end- // bracket a control gesture; arm marks a target for Write (records from play).+ // There are no record modes. Lanes always play back; recording is contextual:+ // with the transport record engaged, a control gesture writes into that target's+ // lane. begin/end bracket the gesture — a mouse gesture stops writing on release,+ // a latching one (hardware knob / MIDI / gamepad) keeps writing until the+ // transport stops. With record off, touching a parameter that already carries+ // automation *overrides* its lane so the hand leads, until reenableAutomation().// Sampling happens in poll() while playing; suppressRead lets the control lead.- void setAutomationWriteMode(int32_t mode);- int32_t automationWriteMode() const { return autoWriteMode_.load(std::memory_order_relaxed); }- void beginAutomationWrite(int32_t trackId, int32_t target, int32_t deviceIndex, int32_t paramIndex, const char* paramId);+ void setAutomationRecord(bool on);+ bool automationRecord() const { return autoRecord_.load(std::memory_order_relaxed); }+ void beginAutomationWrite(int32_t trackId, int32_t target, int32_t deviceIndex, int32_t paramIndex, const char* paramId, bool latch);void endAutomationWrite(int32_t trackId, int32_t target, int32_t deviceIndex, int32_t paramIndex, const char* paramId);- void setAutomationArm(int32_t trackId, int32_t target, int32_t deviceIndex, int32_t paramIndex, const char* paramId, bool armed);- bool automationArmed(int32_t trackId, int32_t target, int32_t deviceIndex, int32_t paramIndex, const char* paramId) const;- bool automationWriteSelfTest(); // device-free: Touch gesture + Write-via-arm+ void reenableAutomation(); // hand the overridden lanes back to playback+ bool automationOverridden() const { return !overrides_.empty(); }+ bool automationWriteSelfTest(); // device-free: touch, latch, override/re-enable// --- debug oscillator (M0) ---void setToneEnabled(bool enabled);@@ -1008,17 +1012,17 @@ private:double recordReturnBeat_ = 0.0;// automation write/record state (M9-C, message thread only)- std::atomic<int32_t> autoWriteMode_{0}; // AutomationWriteMode+ std::atomic<bool> autoRecord_{false}; // transport record engaged -> gestures writestruct ActiveWrite {int32_t trackId; int32_t target; int32_t deviceIndex; int32_t paramIndex;- std::string paramId; int32_t laneIndex; double lastBeat;+ std::string paramId; int32_t laneIndex; double lastBeat; bool latch;};- struct ArmTarget {- int32_t trackId; int32_t target; int32_t deviceIndex; int32_t paramIndex; std::string paramId;- };- std::vector<ActiveWrite> activeWrites_;- std::vector<ArmTarget> armedWrites_;- bool wasPlaying_ = false; // poll() edge detection for Write auto-begin+ // A lane the user took over by hand while NOT recording: it stops reading until+ // reenableAutomation() (Live's "Re-Enable Automation").+ struct OverrideTarget { int32_t trackId; int32_t laneIndex; };+ std::vector<ActiveWrite> activeWrites_;+ std::vector<OverrideTarget> overrides_;+ bool wasPlaying_ = false; // poll() edge detection: stop ends latched writesbool renderWasPlaying_ = false; // audio-thread play→stop edge (flush stuck notes)// session-slot recording target (M5-4). recordSessionScene_ >= 0 selects slotdiff --git a/src/native/nota.engine/src/Engine_Automation.cpp b/src/native/nota.engine/src/Engine_Automation.cppindex 7a10f867..6a5ace08 100644--- a/src/native/nota.engine/src/Engine_Automation.cpp+++ b/src/native/nota.engine/src/Engine_Automation.cpp@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Engine — parameter automation (M9): read/apply, lane CRUD, hosted-plugin parameter surface, write recording (Touch/Latch/Write), self-tests.+// Engine — parameter automation (M9): read/apply, lane CRUD, hosted-plugin parameter surface, contextual write recording, self-tests.#include "Engine.h"#include "AudioFile.h"@@ -235,17 +235,54 @@ void Engine::setLaneSuppressRead(int32_t trackId, int32_t laneIndex, bool supprerepublishWithTrackRaw(trackId, nt); // transient flag — never an undo step}-void Engine::setAutomationWriteMode(int32_t mode) {- autoWriteMode_.store(mode, std::memory_order_relaxed);- if (mode == 0) finishAllWrites(); // leaving record mode ends any gesture+void Engine::setAutomationRecord(bool on) {+ autoRecord_.store(on, std::memory_order_relaxed);+ if (!on) finishAllWrites(); // leaving record ends any gesture in progress+}++// Find an existing lane for a target without creating one (used by the override+// path, which must not litter the project with empty lanes).+static int32_t findLaneFor(const Track& t, int32_t target, int32_t deviceIndex,+ int32_t paramIndex, const std::string& paramId) {+ for (size_t i = 0; i < t.automation.size(); ++i) {+ const AutomationLane& l = t.automation[i];+ if (l.target != static_cast<AutomationTarget>(target)) continue;+ switch (l.target) {+ case AutomationTarget::DeviceParam:+ case AutomationTarget::MidiDeviceParam:+ if (l.deviceIndex != deviceIndex || l.paramIndex != paramIndex) continue;+ break;+ case AutomationTarget::PluginParam:+ if (l.deviceIndex != deviceIndex || l.paramId != paramId) continue;+ break;+ default: break; // Volume / Pan: one lane per track+ }+ return static_cast<int32_t>(i);+ }+ return -1;}void Engine::beginAutomationWrite(int32_t trackId, int32_t target, int32_t deviceIndex,- int32_t paramIndex, const char* paramId) {+ int32_t paramIndex, const char* paramId, bool latch) {const std::string id = paramId ? paramId : "";for (auto& aw : activeWrites_) // already writing this target?- if (sameTarget(aw.target, aw.deviceIndex, aw.paramIndex, aw.paramId, target, deviceIndex, paramIndex, id))+ if (aw.trackId == trackId &&+ sameTarget(aw.target, aw.deviceIndex, aw.paramIndex, aw.paramId, target, deviceIndex, paramIndex, id))return;++ if (!autoRecord_.load(std::memory_order_relaxed)) {+ // Not recording: the lane keeps playing back unless it actually has automation,+ // in which case the hand takes over (override) until reenableAutomation().+ auto t = findTrackAuthoring(trackId);+ if (!t) return;+ const int32_t lane = findLaneFor(*t, target, deviceIndex, paramIndex, id);+ if (lane < 0 || t->automation[lane].points.empty()) return;+ for (auto& o : overrides_) if (o.trackId == trackId && o.laneIndex == lane) return;+ setLaneSuppressRead(trackId, lane, true);+ overrides_.push_back({trackId, lane});+ return;+ }+// Resolve (or create) the target's lane. PluginParam resolves paramIndex by id.int32_t laneIndex, resolvedParam = paramIndex;if (static_cast<AutomationTarget>(target) == AutomationTarget::PluginParam) {@@ -255,24 +292,28 @@ void Engine::beginAutomationWrite(int32_t trackId, int32_t target, int32_t deviclaneIndex = addAutomationLane(trackId, target, deviceIndex, paramIndex);}if (laneIndex < 0) return;+ // Recording this lane supersedes any hand override of it.+ for (size_t i = 0; i < overrides_.size(); ++i)+ if (overrides_[i].trackId == trackId && overrides_[i].laneIndex == laneIndex)+ { overrides_.erase(overrides_.begin() + i); break; }// Checkpoint the clean pre-write state once per write session (concurrent- // Write targets share one undo step); subsequent grows are raw.+ // targets share one undo step); subsequent grows are raw.if (activeWrites_.empty()) pushUndo();setLaneSuppressRead(trackId, laneIndex, true);const double beat = transport_.uiPositionBeats();- activeWrites_.push_back({trackId, target, deviceIndex, resolvedParam, id, laneIndex, beat});+ activeWrites_.push_back({trackId, target, deviceIndex, resolvedParam, id, laneIndex, beat, latch});}void Engine::endAutomationWrite(int32_t trackId, int32_t target, int32_t deviceIndex,int32_t paramIndex, const char* paramId) {- // Only Touch stops on release; Latch/Write keep writing until the transport- // stops (finishAllWrites). Read never has active writes.- if (autoWriteMode_.load(std::memory_order_relaxed) != 1 /*Touch*/) return;+ // A released mouse gesture stops writing here; a latched one (hardware control)+ // keeps writing its last value until the transport stops (finishAllWrites).const std::string id = paramId ? paramId : "";for (size_t i = 0; i < activeWrites_.size(); ++i) {auto& aw = activeWrites_[i];if (aw.trackId == trackId &&sameTarget(aw.target, aw.deviceIndex, aw.paramIndex, aw.paramId, target, deviceIndex, paramIndex, id)) {+ if (aw.latch) return;setLaneSuppressRead(aw.trackId, aw.laneIndex, false);activeWrites_.erase(activeWrites_.begin() + i);return;@@ -285,28 +326,9 @@ void Engine::finishAllWrites() {activeWrites_.clear();}-void Engine::setAutomationArm(int32_t trackId, int32_t target, int32_t deviceIndex,- int32_t paramIndex, const char* paramId, bool armed) {- const std::string id = paramId ? paramId : "";- for (size_t i = 0; i < armedWrites_.size(); ++i) {- auto& a = armedWrites_[i];- if (a.trackId == trackId &&- sameTarget(a.target, a.deviceIndex, a.paramIndex, a.paramId, target, deviceIndex, paramIndex, id)) {- if (!armed) armedWrites_.erase(armedWrites_.begin() + i);- return;- }- }- if (armed) armedWrites_.push_back({trackId, target, deviceIndex, paramIndex, id});-}--bool Engine::automationArmed(int32_t trackId, int32_t target, int32_t deviceIndex,- int32_t paramIndex, const char* paramId) const {- const std::string id = paramId ? paramId : "";- for (auto& a : armedWrites_)- if (a.trackId == trackId &&- sameTarget(a.target, a.deviceIndex, a.paramIndex, a.paramId, target, deviceIndex, paramIndex, id))- return true;- return false;+void Engine::reenableAutomation() {+ for (auto& o : overrides_) setLaneSuppressRead(o.trackId, o.laneIndex, false);+ overrides_.clear();}void Engine::sampleAutomationWritesAt(double beat) {@@ -330,9 +352,9 @@ void Engine::sampleAutomationWritesAt(double beat) {}bool Engine::automationWriteSelfTest() {- // Device-free. Touch: begin -> move control -> sample at a beat -> the lane gets- // a point ~= the control value, suppressRead clears on end. Then Write via arm:- // arm a target, "play" (begin), sample, stop (finish) records it too.+ // Device-free. Record on: a mouse gesture (latch=false) writes at the playhead and+ // stops on release; a latched gesture ignores the release and only a stop ends it.+ // Record off: touching an automated param overrides its lane until re-enable.reset();auto t = std::make_shared<Track>(1, TrackType::Instrument);t->instrument = std::make_shared<Synth>();@@ -340,9 +362,9 @@ bool Engine::automationWriteSelfTest() {g->tracks.push_back(t);publishRaw(g);- // Touch gesture on Volume.- setAutomationWriteMode(1); // Touch- beginAutomationWrite(1, 0, -1, -1, "");+ // Mouse gesture on Volume while recording.+ setAutomationRecord(true);+ beginAutomationWrite(1, 0, -1, -1, "", false);if (findTrackAuthoring(1)->automation.empty()) return false;if (!findTrackAuthoring(1)->automation[0].suppressRead) return false;setTrackVolume(1, 1.5f); // by id — targets the live authoring track (as the UI does)@@ -350,44 +372,37 @@ bool Engine::automationWriteSelfTest() {endAutomationWrite(1, 0, -1, -1, "");{auto tt = findTrackAuthoring(1);- if (tt->automation[0].suppressRead) return false; // cleared on end+ if (tt->automation[0].suppressRead) return false; // cleared on releaseconst auto& pts = tt->automation[0].points;bool ok = false;for (auto& p : pts) if (std::fabs(p.beat - 3.0) < 1e-6 && std::fabs(p.value - 1.5f) < 1e-4f) ok = true;if (!ok) return false;}- // Latch: releasing must NOT end the write (only a stop does). endAutomationWrite- // is a no-op in Latch; suppressRead stays set until finishAllWrites.- setAutomationWriteMode(2); // Latch- beginAutomationWrite(1, 0, -1, -1, "");- endAutomationWrite(1, 0, -1, -1, ""); // release — ignored in Latch+ // Latched gesture (hardware control): releasing must NOT end the write — only a+ // transport stop does, via finishAllWrites.+ beginAutomationWrite(1, 0, -1, -1, "", true);+ endAutomationWrite(1, 0, -1, -1, ""); // release — ignored when latchedif (!findTrackAuthoring(1)->automation[0].suppressRead) return false; // still writingfinishAllWrites(); // transport stopif (findTrackAuthoring(1)->automation[0].suppressRead) return false; // now cleared- // Write via arm on Pan.- setAutomationWriteMode(3); // Write- setAutomationArm(1, 1, -1, -1, "", true);- if (!automationArmed(1, 1, -1, -1, "")) return false;- beginAutomationWrite(1, 1, -1, -1, ""); // what the play edge does for armed targets- setTrackPan(1, -0.75f);- sampleAutomationWritesAt(2.0);- finishAllWrites(); // what transport stop does- {- auto tt = findTrackAuthoring(1);- int panLane = -1;- for (size_t i = 0; i < tt->automation.size(); ++i)- if (tt->automation[i].target == AutomationTarget::Pan) panLane = static_cast<int32_t>(i);- if (panLane < 0) return false;- if (tt->automation[panLane].suppressRead) return false;- bool ok = false;- for (auto& p : tt->automation[panLane].points)- if (std::fabs(p.beat - 2.0) < 1e-6 && std::fabs(p.value + 0.75f) < 1e-4f) ok = true;- if (!ok) return false;- }- setAutomationArm(1, 1, -1, -1, "", false);- setAutomationWriteMode(0);+ // Record off: a touch on a target with no automation must not create a lane...+ setAutomationRecord(false);+ const size_t lanes = findTrackAuthoring(1)->automation.size();+ beginAutomationWrite(1, 1, -1, -1, "", false); // Pan — no lane yet+ if (findTrackAuthoring(1)->automation.size() != lanes) return false;+ if (automationOverridden()) return false;+ // ...but on the automated Volume lane it overrides playback until re-enable.+ beginAutomationWrite(1, 0, -1, -1, "", false);+ if (!automationOverridden()) return false;+ if (!findTrackAuthoring(1)->automation[0].suppressRead) return false;+ endAutomationWrite(1, 0, -1, -1, ""); // release keeps the override+ if (!findTrackAuthoring(1)->automation[0].suppressRead) return false;+ reenableAutomation();+ if (automationOverridden()) return false;+ if (findTrackAuthoring(1)->automation[0].suppressRead) return false;+reset();return true;}diff --git a/src/native/nota.engine/src/Engine_Recording.cpp b/src/native/nota.engine/src/Engine_Recording.cppindex 64b9c2b6..e1097dfd 100644--- a/src/native/nota.engine/src/Engine_Recording.cpp+++ b/src/native/nota.engine/src/Engine_Recording.cpp@@ -77,6 +77,11 @@ int32_t Engine::liveHeldNotes(int32_t* out, int32_t maxN) const {}void Engine::setRecording(bool on) {+ // The record button is also the automation-record switch (M9-C): while it is+ // engaged, moving any control writes that parameter's lane. This is set even+ // when no track is armed for a take — if the UI then pops the button back up+ // it calls us again with false, which clears it.+ setAutomationRecord(on);if (!on) {recording_.store(false, std::memory_order_relaxed);stopAudioRecording(); // materialise if an audio take was rollingdiff --git a/src/native/nota.engine/src/Engine_Render.cpp b/src/native/nota.engine/src/Engine_Render.cppindex 58ace059..2f7d3797 100644--- a/src/native/nota.engine/src/Engine_Render.cpp+++ b/src/native/nota.engine/src/Engine_Render.cpp@@ -95,30 +95,26 @@ void Engine::applyMidiCcRouting(Track& t) {void Engine::poll() {if (audioRecording_) drainInputQueue(); // keep the capture buffer flowing while recording- // Automation write/record (M9-C). Message thread: detect play edges, auto-begin- // armed targets in Write mode, sample active gestures at the live playhead.+ // Automation write/record (M9-C). Message thread: a transport stop ends any+ // latched gesture, and active gestures are sampled at the live playhead.{const bool playing = transport_.uiIsPlaying();- const int32_t mode = autoWriteMode_.load(std::memory_order_relaxed);- if (playing && !wasPlaying_ && mode == 3) { // Write: arm -> record on play- auto armed = armedWrites_; // begin* mutates activeWrites_, not armed- for (auto& a : armed)- beginAutomationWrite(a.trackId, a.target, a.deviceIndex, a.paramIndex, a.paramId.c_str());- }- if (!playing && wasPlaying_) finishAllWrites(); // stop ends Latch + Write+ const bool rec = autoRecord_.load(std::memory_order_relaxed);+ if (!playing && wasPlaying_) finishAllWrites(); // stop ends latched writeswasPlaying_ = playing;// Plugin-GUI gestures (M9-C): grabbing a knob in the plugin's own editor- // begins/ends a write for that param, so Touch/Latch/Write record it just- // like our faders. Instruments/devices are stable across snapshots, so a- // copied track list stays valid while begin/end republish.- if (playing && mode != 0) {+ // begins/ends a write for that param, so it records (or overrides) just like+ // our own faders — a mouse gesture, so never latched. Instruments/devices are+ // stable across snapshots, so a copied track list stays valid while+ // begin/end republish.+ {auto snapshot = authoring_->tracks;for (auto& tptr : snapshot) {const int32_t tid = tptr->id();if (auto& inst = tptr->instrument) {int gb = inst->takePluginGestureBegin();- if (gb >= 0) beginAutomationWrite(tid, 3, -1, -1, pluginParamId(tid, -1, gb).c_str());+ if (gb >= 0) beginAutomationWrite(tid, 3, -1, -1, pluginParamId(tid, -1, gb).c_str(), false);int ge = inst->takePluginGestureEnd();if (ge >= 0) endAutomationWrite(tid, 3, -1, -1, pluginParamId(tid, -1, ge).c_str());}@@ -126,14 +122,14 @@ void Engine::poll() {auto& d = tptr->devices[di];if (!d) continue;int gb = d->takePluginGestureBegin();- if (gb >= 0) beginAutomationWrite(tid, 3, di, -1, pluginParamId(tid, di, gb).c_str());+ if (gb >= 0) beginAutomationWrite(tid, 3, di, -1, pluginParamId(tid, di, gb).c_str(), false);int ge = d->takePluginGestureEnd();if (ge >= 0) endAutomationWrite(tid, 3, di, -1, pluginParamId(tid, di, ge).c_str());}}}- if (playing && mode != 0 && !activeWrites_.empty())+ if (playing && rec && !activeWrites_.empty())sampleAutomationWritesAt(transport_.uiPositionBeats());}diff --git a/src/native/nota.engine/src/nota_engine_automation.cpp b/src/native/nota.engine/src/nota_engine_automation.cppindex b659a2b5..8c89677f 100644--- a/src/native/nota.engine/src/nota_engine_automation.cpp+++ b/src/native/nota.engine/src/nota_engine_automation.cpp@@ -2,7 +2,7 @@// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//// C ABI — parameter automation (M9): lane CRUD & points (read, A-phases),-// plugin-parameter lanes (B-phases), and write recording Touch/Latch/Write+// plugin-parameter lanes (B-phases), and contextual write recording// (C-phases), plus the automation self-tests.#include "nota_engine_internal.h"@@ -88,27 +88,26 @@ const char* nota_track_automation_lane_param_id(const NotaEngine* e, int32_t traint32_t nota_engine_automation_write_selftest(NotaEngine* e) {return (e && ENG(e)->automationWriteSelfTest()) ? 1 : 0;}-void nota_engine_set_automation_write_mode(NotaEngine* e, int32_t mode) {- if (e) ENG(e)->setAutomationWriteMode(mode);+void nota_engine_set_automation_record(NotaEngine* e, int32_t on) {+ if (e) ENG(e)->setAutomationRecord(on != 0);}-int32_t nota_engine_automation_write_mode(const NotaEngine* e) {- return e ? CENG(e)->automationWriteMode() : 0;+int32_t nota_engine_automation_record(const NotaEngine* e) {+ return (e && CENG(e)->automationRecord()) ? 1 : 0;}void nota_track_begin_automation_write(NotaEngine* e, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id) {- if (e) ENG(e)->beginAutomationWrite(track_id, target, device_index, param_index, param_id);+ int32_t target, int32_t device_index, int32_t param_index, const char* param_id,+ int32_t latch) {+ if (e) ENG(e)->beginAutomationWrite(track_id, target, device_index, param_index, param_id, latch != 0);}void nota_track_end_automation_write(NotaEngine* e, int32_t track_id,int32_t target, int32_t device_index, int32_t param_index, const char* param_id) {if (e) ENG(e)->endAutomationWrite(track_id, target, device_index, param_index, param_id);}-void nota_track_set_automation_arm(NotaEngine* e, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id, int32_t armed) {- if (e) ENG(e)->setAutomationArm(track_id, target, device_index, param_index, param_id, armed != 0);+void nota_engine_reenable_automation(NotaEngine* e) {+ if (e) ENG(e)->reenableAutomation();}-int32_t nota_track_automation_armed(const NotaEngine* e, int32_t track_id,- int32_t target, int32_t device_index, int32_t param_index, const char* param_id) {- return (e && CENG(e)->automationArmed(track_id, target, device_index, param_index, param_id)) ? 1 : 0;+int32_t nota_engine_automation_overridden(const NotaEngine* e) {+ return (e && CENG(e)->automationOverridden()) ? 1 : 0;}} // extern "C"diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 70bf8a1e..32e3edf5 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -5103,35 +5103,47 @@ Console.WriteLine("-- M9-B1: plugin-param automation core --");}// ===================== M9-C W1: automation write/record engine =============-// Device-free: a Touch gesture records the control value into the lane at the-// playhead (suppressRead clears on end); Write-via-arm records an armed target.+// Device-free: with record on, a mouse gesture writes the control value into the+// lane at the playhead and stops on release while a latched one keeps going; with+// record off, touching an automated param overrides its lane until re-enable.Console.WriteLine("-- M9-C W1: automation write/record --");{- Check(engine.AutomationWriteSelfTest(), "automation write path: Touch + Write-via-arm (device-free)");+ Check(engine.AutomationWriteSelfTest(), "automation write path: touch, latch, override (device-free)");}-// ===================== M9-C W2: write-mode C ABI + C# ======================-// Device-free: mode get/set round-trips; arm toggles; a Touch begin creates the-// target's lane and end doesn't throw. (Live sampling needs the audio clock and-// is covered by the W1 self-test.)-Console.WriteLine("-- M9-C W2: write-mode C ABI --");+// ===================== M9-C W2: record-switch C ABI + C# ===================+// Device-free: the record switch round-trips; a gesture while recording creates the+// target's lane, and the same gesture with record off creates nothing. (Live sampling+// needs the audio clock and is covered by the W1 self-test.)+Console.WriteLine("-- M9-C W2: automation-record C ABI --");{int wT = engine.AddInstrumentTrack();- engine.SetAutomationWriteMode(Nota.Application.AutomationWriteMode.Latch);- Check(engine.GetAutomationWriteMode() == Nota.Application.AutomationWriteMode.Latch, "write mode round-trips");-- Check(!engine.IsAutomationArmed(wT, Nota.Application.AutomationTarget.Volume, -1, -1, ""), "target not armed by default");- engine.SetAutomationArm(wT, Nota.Application.AutomationTarget.Volume, -1, -1, "", true);- Check(engine.IsAutomationArmed(wT, Nota.Application.AutomationTarget.Volume, -1, -1, ""), "arm toggles on");- engine.SetAutomationArm(wT, Nota.Application.AutomationTarget.Volume, -1, -1, "", false);- Check(!engine.IsAutomationArmed(wT, Nota.Application.AutomationTarget.Volume, -1, -1, ""), "arm toggles off");+ Check(!engine.AutomationRecording, "automation record off by default");+ engine.SetAutomationRecord(true);+ Check(engine.AutomationRecording, "automation record round-trips");int before = engine.AutomationLaneCount(wT);engine.BeginAutomationWrite(wT, Nota.Application.AutomationTarget.Pan, -1, -1, "");- Check(engine.AutomationLaneCount(wT) == before + 1, "begin-write creates the target lane");+ Check(engine.AutomationLaneCount(wT) == before + 1, "begin-write creates the target lane while recording");+ engine.EndAutomationWrite(wT, Nota.Application.AutomationTarget.Pan, -1, -1, "");++ engine.SetAutomationRecord(false);+ engine.BeginAutomationWrite(wT, Nota.Application.AutomationTarget.Volume, -1, -1, "");+ Check(engine.AutomationLaneCount(wT) == before + 1, "a touch with record off creates no lane");+ Check(!engine.AutomationOverridden, "an un-automated param is not overridden");+ engine.EndAutomationWrite(wT, Nota.Application.AutomationTarget.Volume, -1, -1, "");++ // The Pan lane exists but is empty, so touching it still overrides nothing; give it a+ // point and the same touch takes the lane over until re-enable.+ int pan = engine.AddAutomationLane(wT, Nota.Application.AutomationTarget.Pan, -1, -1);+ engine.SetAutomationPoints(wT, pan, new[] { new Nota.Application.AutomationPoint(0, 0.5f, 0) });+ engine.BeginAutomationWrite(wT, Nota.Application.AutomationTarget.Pan, -1, -1, "");+ Check(engine.AutomationOverridden, "touching an automated param overrides its lane");engine.EndAutomationWrite(wT, Nota.Application.AutomationTarget.Pan, -1, -1, "");- engine.SetAutomationWriteMode(Nota.Application.AutomationWriteMode.Read); // leave clean+ Check(engine.AutomationOverridden, "the override survives the release");+ engine.ReenableAutomation();+ Check(!engine.AutomationOverridden, "re-enable hands the lane back");}// ===================== M9-A2: automation lane C ABI + C# ===================