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.

(feat) Shutter Pattern tab for rhytmic gate

Egor Khindikaynen7f212b941d39
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 714f62ad..4783fe38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,14 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Nota Shutter · Pattern:** a fourth tab turns the gate into a rhythmic, tempo-synced
+ gate. Draw the steps (Draw, Line, Erase, Flip) on an 8, 16 or 32-step grid, flip through
+ pattern shapes or roll a new one with the dice and Complexity, and shape the gain with Smooth
+ and Swing. Rate runs from a quarter note to 4 bars in Sync (or 4 to 0.25 Hz in Free), Depth
+ sets how far an empty step drops, a MIDI note can restart the pattern, and Gated plays it only
+ while the threshold gate is open. Target Map leaves the audio alone and sends the pattern out
+ as a CV source for the Modular view. Every step and pattern setting can be automated, and 15
+ new pattern presets come with it.
- **Clips between the Arrangement and Session:** copy MIDI and audio clips across with the
clipboard — ⌘C (or ⌘X) on the timeline, then ⌘V on a session slot, and the other way round.
**⌘⇧C** (and **Copy to Session** / **Copy to Arrangement** in the right-click menus and the
diff --git a/FEATURES.md b/FEATURES.md
index 201ca090..9488988f 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -539,7 +539,12 @@ and user presets, automation, persistence and cloning.
(ducker), Retrigger (trigger mode), a 12 dB/oct detector band-pass (switchable) with Listen,
Peak hold, internal or external key; Signal / Envelope / Sidechain graphs (drag the
threshold, the envelope nodes and the key filter), a STATE column, a state box, meters
- with peak GR and openings per bar; 30 factory presets; MCP `read_shutter`.
+ with peak GR and openings per bar; a Pattern tab — a tempo-synced rhythmic gate: an 8 / 16 / 32
+ step grid at 4 / 8 / 16 levels drawn with Draw / Line / Erase / Flip, pattern shapes, a
+ Complexity-weighted dice, Smooth and Swing on the gain curve, Rate (1/4 … 4 bars in Sync,
+ 4 … 0.25 Hz in Free), Depth, Copy / Paste / Clear, MIDI-note retrigger, Gated (pattern × gate)
+ and a Volume or Map target (Map drives the Pattern Out CV source instead of the audio), every
+ step automatable; 45 factory presets (15 pattern); MCP `read_shutter`.
- **Nota Chamber** (20) — hybrid reverb: a zero-latency convolution engine (16 synthesised
IRs — halls, rooms, plates, spring, spaces, FX — or your own WAV/FLAC/MP3, mono / stereo /
4-ch true stereo, dropped on the IR view) with Start/Decay trims, Attack, Size, Reverse,
diff --git a/src/managed/Nota.App/ArrangementView.Automation.cs b/src/managed/Nota.App/ArrangementView.Automation.cs
index fc0891c6..4bd3937e 100644
--- a/src/managed/Nota.App/ArrangementView.Automation.cs
+++ b/src/managed/Nota.App/ArrangementView.Automation.cs
@@ -430,7 +430,8 @@ public sealed partial class ArrangementView
// ("SC HP", "SC Gain" …), the Auto Filter its sources ("Env", "LFO", "Mod"), Nota
// Vintage its tone and wow ("Tone Low", "Wow Rate" …), Nota Valve its mic ("Mic Distance" …),
// Nota Utility its mono, phase and true-peak params ("Mono Freq", "Invert L", "TP Ceiling" …),
- // Nota Shutter its detector ("Det HP", "Det LP", "Det Filter"), Nota Auto Shift its
+ // Nota Shutter its detector ("Det HP", "Det LP", "Det Filter") and its pattern ("Pattern Rate",
+ // "Step 5" …), Nota Auto Shift its
// scale notes, detector and MIDI target ("Note C#", "Det Low", "MIDI Glide" …) and Nota
// Beat Repeat its repeat filter ("Filter Freq", "Filter Type", "Filter Narrow" …), and
// Nota EQ-8 and Nota Dynamic EQ-8 their eight bands ("3 Freq", "3 Slope" … under "Band 3"),
@@ -444,6 +445,9 @@ public sealed partial class ArrangementView
var groups = new System.Collections.Generic.Dictionary<string, MenuItem>();
for (int p = 0; p < builtinPc; p++)
{
+ // Nota Shutter: Pattern Out is the pattern's read-only output (a CV source) and
+ // Complexity only steers the dice — neither is a sound parameter to automate.
+ if (bkind == 19 && names[p] is "Pattern Out" or "Pattern Complexity") continue;
int dd = d, pp = p;
string head = grouped ? Head(names[p]) : "";
bool sub = head.Length > 0 && names.Count(n => Head(n) == head) >= 2;
diff --git a/src/managed/Nota.App/Controls/ShutterViews.cs b/src/managed/Nota.App/Controls/ShutterViews.cs
index 7cf6be5f..7ff228b2 100644
--- a/src/managed/Nota.App/Controls/ShutterViews.cs
+++ b/src/managed/Nota.App/Controls/ShutterViews.cs
@@ -13,6 +13,9 @@
// or down.
// · ShKeyView — the Sidechain tab: the detector band-pass (teal, 12 dB/oct) with its HP /
// LP nodes to drag, under the reduction over the window (brass).
+// · ShPatternView — the Pattern tab: the step grid (a column per step, quantised to the
+// levels) with the gain it makes on top — smooth and swing bend the curve — the current
+// step lit and the playhead. Draw / Line / Erase / Flip edit the steps with the mouse.
// Shared drag contract (ShDragView): left button only, a gesture per drag, double-click
// resets the handle, right-click bubbles to the MIDI-learn menu.
@@ -450,3 +453,159 @@ internal sealed class ShKeyView : ShDragView
}
}
}
+
+internal sealed class ShPatternView : Control
+{
+ public const int ToolDraw = 0, ToolLine = 1, ToolErase = 2, ToolFlip = 3;
+ private float[] _steps = new float[16];
+ private int _levels = 8, _cur = -1;
+ private double _phase = -1, _smooth, _swing, _depth = 1;
+ private bool _map, _active = true;
+ private string _label = "gain";
+
+ // Drag state.
+ private bool _drag;
+ private float[] _base = Array.Empty<float>();
+ private int _c0;
+ private float _v0, _flipTo;
+
+ public int Tool { get; set; }
+ public event Action? GestureBegin;
+ public event Action? GestureEnd;
+ /// <summary>The edited steps (a copy, already quantised) after every move of a drag.</summary>
+ public event Action<float[]>? StepsChanged;
+ public bool Dragging => _drag;
+
+ public ShPatternView() { ClipToBounds = true; MinHeight = 40; Cursor = new Cursor(StandardCursorType.Cross); }
+
+ /// <summary>Steps 0..1, levels, the step / phase playing now (−1 = none), smooth 0..1 (½ step at 1),
+ /// swing in steps, depth, Map (teal), active (pattern on), the curve's label.</summary>
+ public void Set(float[] steps, int n, int levels, int cur, double phase, double smooth, double swing, double depth, bool map, bool active, string label)
+ {
+ if (_drag) { _cur = cur; _phase = phase; InvalidateVisual(); return; } // the hand owns the steps
+ if (_steps.Length != n) _steps = new float[n];
+ Array.Copy(steps, _steps, Math.Min(n, steps.Length));
+ _levels = Math.Max(1, levels); _cur = cur; _phase = phase; _smooth = smooth; _swing = swing; _depth = depth;
+ _map = map; _active = active; _label = label;
+ InvalidateVisual();
+ }
+
+ private float Q(double v) => (float)(Math.Round(Math.Clamp(v, 0, 1) * _levels) / _levels);
+ private (int c, float v) At(Point p)
+ {
+ int n = _steps.Length;
+ double w = Math.Max(1, Bounds.Width), h = Math.Max(1, Bounds.Height);
+ return (Math.Clamp((int)(p.X / w * n), 0, n - 1), Q(1 - p.Y / h));
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ base.OnPointerPressed(e);
+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ _base = (float[])_steps.Clone();
+ (_c0, _v0) = At(e.GetPosition(this));
+ _flipTo = _base[_c0] > 0 ? 0f : 1f;
+ _drag = true;
+ GestureBegin?.Invoke();
+ e.Pointer.Capture(this); e.Handled = true;
+ Apply(e.GetPosition(this));
+ }
+ protected override void OnPointerMoved(PointerEventArgs e)
+ {
+ base.OnPointerMoved(e);
+ if (_drag) Apply(e.GetPosition(this));
+ }
+ protected override void OnPointerReleased(PointerReleasedEventArgs e)
+ {
+ base.OnPointerReleased(e);
+ if (!_drag) return;
+ _drag = false; e.Pointer.Capture(null); GestureEnd?.Invoke(); InvalidateVisual();
+ }
+
+ private void Apply(Point p)
+ {
+ var (c, v) = At(p);
+ var s = Tool == ToolLine ? (float[])_base.Clone() : _steps;
+ switch (Tool)
+ {
+ case ToolErase: s[c] = 0; break;
+ case ToolFlip: s[c] = _flipTo; break;
+ case ToolLine:
+ {
+ int a = Math.Min(_c0, c), b = Math.Max(_c0, c);
+ for (int i = a; i <= b; i++) { double k = b == a ? 0 : (double)(i - _c0) / (c - _c0); s[i] = Q(_v0 + (v - _v0) * k); }
+ break;
+ }
+ default: s[c] = v; break;
+ }
+ _steps = s;
+ StepsChanged?.Invoke((float[])s.Clone());
+ InvalidateVisual();
+ }
+
+ public override void Render(DrawingContext ctx)
+ {
+ double w = Bounds.Width, h = Bounds.Height;
+ if (w <= 0 || h <= 0) return;
+ var frame = new Rect(0, 0, w, h);
+ NotaGraph.Window(ctx, frame);
+ int n = _steps.Length;
+ double cw = w / n;
+ var ink = _map ? NotaPalette.Teal : NotaPalette.Accent;
+ var inkBright = _map ? NotaPalette.TealBright : NotaPalette.AccentBright;
+ double dim = _active ? 1 : 0.45;
+
+ // Level lines, then the step columns: the playing one lit, a stronger line every 4.
+ for (int i = 1; i < _levels; i++)
+ {
+ double y = Math.Round(h * i / _levels) + 0.5;
+ ctx.DrawLine(NotaGraph.GridPen, new Point(0, y), new Point(w, y));
+ }
+ if (_cur >= 0 && _cur < n && _active)
+ ctx.FillRectangle(NotaPalette.Wash(NotaPalette.AccentBright, 0x18), new Rect(_cur * cw, 0, cw, h));
+ var strong = new Pen(NotaPalette.BorderStrong, 1);
+ for (int i = 1; i < n; i++)
+ {
+ double x = Math.Round(i * cw) + 0.5;
+ ctx.DrawLine(i % 4 == 0 ? strong : NotaGraph.GridPen, new Point(x, 0), new Point(x, h));
+ }
+ var fill = NotaPalette.Wash(ink, (byte)(0x34 * dim));
+ for (int i = 0; i < n; i++)
+ {
+ double v = Q(_steps[i]);
+ if (v <= 0) continue;
+ double x0 = i * cw + 1, x1 = (i + 1) * cw - 1, y = h - v * h;
+ ctx.FillRectangle(fill, new Rect(x0, y, Math.Max(1, x1 - x0), h - y));
+ ctx.FillRectangle(_active ? ink : NotaPalette.BorderStrong, new Rect(x0, y, Math.Max(1, x1 - x0), 2));
+ }
+
+ // The gain curve: swing pushes the off-steps, smooth ramps into each step.
+ double Gain(double v) => 1 - _depth * (1 - Q(v));
+ double Y(double v) => 4 + (1 - Gain(v)) * (h - 8);
+ double r = _smooth * cw * 0.5;
+ var g = new StreamGeometry();
+ using (var c = g.Open())
+ {
+ c.BeginFigure(new Point(0, Y(_steps[0])), false);
+ for (int i = 0; i < n; i++)
+ {
+ double x = i * cw + (i % 2 == 1 ? _swing * cw : 0);
+ double yp = Y(_steps[(i + n - 1) % n]);
+ if (i > 0) c.LineTo(new Point(x, yp));
+ c.LineTo(new Point(x + r, Y(_steps[i])));
+ }
+ c.LineTo(new Point(w, Y(_steps[n - 1])));
+ }
+ ctx.DrawGeometry(null, new Pen(_active ? inkBright : NotaPalette.BorderStrong, 1.6, lineJoin: PenLineJoin.Round), g);
+
+ if (_phase >= 0 && _active)
+ {
+ double px = Math.Round(_phase * w) + 0.5;
+ ctx.DrawLine(new Pen(NotaPalette.Wash(NotaPalette.AccentBright, 0xB0), 1), new Point(px, 0), new Point(px, h));
+ }
+ var ft = NotaGraph.AxisText(_label, _active ? inkBright : NotaPalette.TextTertiary);
+ var chip = new Rect(w - ft.Width - 12, 5, ft.Width + 8, ft.Height + 2);
+ ctx.FillRectangle(NotaPalette.BgSunken, chip, 3);
+ ctx.DrawText(ft, new Point(chip.X + 4, chip.Y + 1));
+ }
+}
diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs
index 4ffc567d..14464ae7 100644
--- a/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs
+++ b/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs
@@ -4,10 +4,11 @@
// Detail · Devices — built-in Nota Shutter body (noise gate / ducker, device kind 19), a build
// of the "Nota Shutter" mockup (700 × 260) on the Utility / Valve / Vintage frame: an always-
// visible STATE column (input or key level with the threshold · reduction), a centre panel
-// with Signal / Envelope / Sidechain tabs — the input and the gated output over the window
-// with the threshold and the close level on it, one opening drawn from attack / hold /
-// release / shape / floor, the detector's band-pass under the reduction — a right panel with
-// Detector / Meters tabs, and a status strip. The pictures come from the engine (Shutter.h
+// with Signal / Envelope / Sidechain / Pattern tabs — the input and the gated output over the
+// window with the threshold and the close level on it, one opening drawn from attack / hold /
+// release / shape / floor, the detector's band-pass under the reduction, the rhythmic gate's
+// step grid — a right panel with Detector / Meters tabs (Rhythm / Detector on the Pattern
+// tab), and a status strip. The pictures come from the engine (Shutter.h
// scopeRead), so they show what the gate does. Every control is a device param, so
// automation / MIDI learn / presets / A-B / persistence come for free; the window length,
// Live (freeze) and Reset are view / meter actions, not params.
@@ -35,13 +36,36 @@ internal sealed class ShutterDeviceBody : IDeviceBody
private const int S_InDb = 0, S_GateGain = 1, S_GrDb = 2, S_DetDb = 3, S_Open = 4, S_State = 5, S_OutDb = 6, S_OpenRatio = 7,
S_TrigPerBar = 8, S_Triggers = 9, S_SampleRate = 10, S_Cpu = 11, S_Latency = 12, S_ExtKey = 13, S_KeyDb = 14,
S_PeakGrDb = 18, S_WindowSec = 20, S_HistN = 21, kTele = 24, kHist = 128;
- private const int kScope = kTele + 3 * kHist;
+ // Pattern (appended params + the block after the histories).
+ private const int PatTarget = 16, PatRate = 17, PatDepth = 18, PatSync = 19, PatSmooth = 20, PatSwing = 21, PatSteps = 22,
+ PatLevels = 23, PatRetrig = 24, PatGated = 25, PatComplexity = 26, Step1 = 28, kMaxSteps = 32;
+ private const int S_Bpm = 19;
+ private const int kPatAt = kTele + 3 * kHist, P_Phase = 0, P_Step = 1, P_Value = 3, kPat = 8;
+ private const int kScope = kPatAt + kPat;
private const int H_In = kTele, H_Gate = kTele + kHist, H_Det = kTele + 2 * kHist;
private const int A_ResetMeters = 0, A_Window = 1;
private static readonly string[] Shapes = { "Linear", "Log", "Snap" };
private static readonly string[] StateNames = { "closed", "attack", "open", "hold", "release" };
private static readonly string[] WindowNames = { "250\u2009ms", "1\u2009s", "4\u2009s" };
+ private static readonly string[] RateSync = { "1/4", "1/2", "1 Bar", "2 Bars", "4 Bars" };
+ private static readonly string[] RateFree = { "4\u2009Hz", "2\u2009Hz", "1\u2009Hz", "0.5\u2009Hz", "0.25\u2009Hz" };
+ private static readonly int[] StepCounts = { 8, 16, 32 }, LevelCounts = { 4, 8, 16 };
+
+ // The pattern browser's shapes (steps in eighths), resampled to the grid; the arrows walk them.
+ private static readonly (string Name, int[] Steps)[] Patterns =
+ {
+ ("Push", new[] { 8, 0, 8, 8, 0, 8, 8, 0, 8, 0, 8, 8, 0, 8, 0, 8 }),
+ ("Offbeat", new[] { 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 8, 0 }),
+ ("Trance 16", new[] { 8, 0, 8, 0, 8, 8, 0, 8, 8, 0, 8, 0, 8, 8, 0, 8 }),
+ ("Stutter", new[] { 8, 8, 8, 8, 0, 0, 0, 0, 8, 0, 8, 0, 8, 8, 0, 0 }),
+ ("Halftime", new[] { 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 0, 0, 4, 0 }),
+ ("Ramp Up", new[] { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 }),
+ ("Chop", new[] { 8, 0, 6, 0, 8, 3, 0, 5, 8, 0, 6, 2, 8, 0, 4, 0 }),
+ };
+ // Copy / Paste between every Shutter in the session.
+ private static float[]? _clipboard;
+ private static readonly Random Rng = new();
public double Width => 700;
public bool FullBleed => true;
@@ -123,10 +147,10 @@ internal sealed class ShutterDeviceBody : IDeviceBody
// Gauge knob bound to a device param (automation gesture + MIDI learn + live follow).
// `steps` > 1 snaps a discrete param (Lookahead).
- Control K(int p, string name, Func<double, string> fmt, IBrush? arc = null, int steps = 0, string? tip = null)
+ Control K(int p, string name, Func<double, string> fmt, IBrush? arc = null, int steps = 0, string? tip = null, double size = 34)
{
var val = Mono(fmt(P(p)), 7, TextPrimary);
- var knob = new Knob(P(p), 1.0) { Accent = true, ArcColor = arc, Default = Def(p), Width = 34, Height = 34 };
+ var knob = new Knob(P(p), 1.0) { Accent = true, ArcColor = arc, Default = Def(p), Width = size, Height = size };
knob.ValueChanged += v =>
{
if (steps > 1) v = Math.Round(v * (steps - 1)) / (steps - 1);
@@ -454,6 +478,223 @@ internal sealed class ShutterDeviceBody : IDeviceBody
return TabBody(head, keyView, knobs);
}
+ // ======================================================================
+ // CENTRE — Pattern (rhythmic gate)
+ // ======================================================================
+ int NSteps() => StepCounts[Sel(PatSteps, 3)];
+ int NLevels() => LevelCounts[Sel(PatLevels, 3)];
+ int RateIdx() => Sel(PatRate, 5);
+ string RateName() => On(PatSync) ? RateSync[RateIdx()] : RateFree[RateIdx()];
+ float Qz(double v) { int l = NLevels(); return (float)(Math.Round(Math.Clamp(v, 0, 1) * l) / l); }
+ float[] StepsNow() { int n = NSteps(); var a = new float[n]; for (int k = 0; k < n; k++) a[k] = P(Step1 + k); return a; }
+ static float[] Resample(float[] a, int n) { var r = new float[n]; for (int i = 0; i < n; i++) r[i] = a[(int)((long)i * a.Length / n)]; return r; }
+ float[] Template(int i) => Resample(Array.ConvertAll(Patterns[i].Steps, v => v / 8f), NSteps());
+ // The browser's name: the shape the steps match, else Custom.
+ int PatternIdx()
+ {
+ var cur = StepsNow();
+ for (int i = 0; i < Patterns.Length; i++)
+ {
+ var t = Template(i);
+ bool same = true;
+ for (int k = 0; k < cur.Length && same; k++) same = Math.Abs(Qz(t[k]) - Qz(cur[k])) < 1e-3;
+ if (same) return i;
+ }
+ return -1;
+ }
+ string PatternName() { int i = PatternIdx(); return i < 0 ? "Custom" : Patterns[i].Name; }
+ // A one-shot write of the whole grid (each changed step is its own automation gesture).
+ void WriteSteps(float[] a)
+ {
+ for (int k = 0; k < a.Length && k < kMaxSteps; k++)
+ if (Math.Abs(P(Step1 + k) - a[k]) > 1e-5) SetP(Step1 + k, a[k]);
+ RefreshAll();
+ }
+
+ var patBuf = new float[kMaxSteps];
+ ShPatternView? patView = null;
+ int patTool = 0;
+
+ // A slider drawn as a filled bar with its value inside (Complexity / Smooth / Swing).
+ Control FillBar(int p, Func<string> text, string tip)
+ {
+ var fill = new Border { HorizontalAlignment = HorizontalAlignment.Left, Background = NotaPalette.Wash(NotaPalette.Accent, 0x40) };
+ var tb = new TextBlock { FontSize = 9, Foreground = TextPrimary, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
+ var grid = new Grid { Children = { fill, tb } };
+ var host = new Border
+ {
+ Height = 18, Background = Sunken, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Badge,
+ ClipToBounds = true, Cursor = new Cursor(StandardCursorType.SizeWestEast), Child = grid,
+ };
+ bool drag = false;
+ void Paint()
+ {
+ double v = P(p);
+ fill.Width = Math.Max(0, grid.Bounds.Width * v);
+ tb.Text = text();
+ host.BorderBrush = v > 0.004 ? NotaPalette.BorderBrass : BorderDef;
+ tb.Foreground = v > 0.004 ? AccentBright : TextSecondary;
+ }
+ void SetX(double x) { Raw(p, x / Math.Max(1, grid.Bounds.Width)); Paint(); RefreshAll(); }
+ host.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(host).Properties.IsLeftButtonPressed) return;
+ if (e.ClickCount == 2) { Reset(p); Paint(); RefreshAll(); e.Handled = true; return; }
+ drag = true; Begin(p); e.Pointer.Capture(host); SetX(e.GetPosition(grid).X); e.Handled = true;
+ };
+ host.PointerMoved += (_, e) => { if (drag) SetX(e.GetPosition(grid).X); };
+ host.PointerReleased += (_, e) => { if (!drag) return; drag = false; e.Pointer.Capture(null); End(p); };
+ grid.SizeChanged += (_, _) => Paint();
+ readouts.Add(() => { if (!drag) Paint(); });
+ Learn(host, p);
+ ToolTip.SetTip(host, tip);
+ return host;
+ }
+
+ // A plain push button (fills its cell).
+ Border Button(string text, Action click, string tip, Func<bool>? enabled = null)
+ {
+ var tb = new TextBlock { Text = text, FontSize = 9, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
+ var b = new Border
+ {
+ Height = 18, Padding = new Thickness(8, 0), Background = Raised, CornerRadius = NotaRadius.Badge,
+ Cursor = new Cursor(StandardCursorType.Hand), Child = tb,
+ };
+ b.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed || enabled?.Invoke() == false) return;
+ click(); RefreshAll(); e.Handled = true;
+ };
+ readouts.Add(() => tb.Foreground = enabled?.Invoke() == false ? TextDisabled : TextPrimary);
+ ToolTip.SetTip(b, tip);
+ return b;
+ }
+
+ void Randomize()
+ {
+ double c = P(PatComplexity);
+ int n = NSteps();
+ var a = new float[n];
+ for (int i = 0; i < n; i++)
+ {
+ bool on = i == 0 || Rng.NextDouble() < 0.35 + c * 0.45;
+ a[i] = !on ? 0 : Qz(c < 0.3 ? 1 : Math.Clamp(1 - Rng.NextDouble() * c * 0.9, 0.125, 1));
+ }
+ WriteSteps(a);
+ }
+ void StepPattern(int dir)
+ {
+ int cur = PatternIdx();
+ int i = ((cur < 0 ? 0 : cur + dir) % Patterns.Length + Patterns.Length) % Patterns.Length;
+ WriteSteps(Array.ConvertAll(Template(i), v => Qz(v)));
+ }
+
+ Control PatternTab()
+ {
+ patView = new ShPatternView { Tool = patTool };
+ var touched = new HashSet<int>();
+ patView.StepsChanged += a =>
+ {
+ for (int k = 0; k < a.Length; k++)
+ {
+ if (Math.Abs(P(Step1 + k) - a[k]) < 1e-5) continue;
+ if (touched.Add(k)) Begin(Step1 + k);
+ Raw(Step1 + k, a[k]);
+ }
+ RefreshAll();
+ };
+ patView.GestureEnd += () => { foreach (int k in touched) End(Step1 + k); touched.Clear(); };
+ ToolTip.SetTip(patView, "The step pattern — each column is one step's level, the line is the gain it makes (smooth and swing bend it). Draw sets steps, Line draws a ramp, Erase clears, Flip toggles on / off.");
+
+ var tools = Segments(new[] { "Draw", "Line", "Erase", "Flip" }, () => patTool, i => { patTool = i; if (patView is not null) patView.Tool = i; }, out var toolSync, padX: 6);
+ readouts.Add(toolSync);
+ ToolTip.SetTip(tools, "Mouse tool for the grid");
+
+ Border Arrow(GlyphKind kind, int dir)
+ {
+ var b = new Border { Width = 18, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand), Child = new Glyph(kind, 7) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } };
+ b.PointerPressed += (_, e) => { if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return; StepPattern(dir); e.Handled = true; };
+ return b;
+ }
+ var pname = new TextBlock { FontSize = 9, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };
+ readouts.Add(() => pname.Text = PatternName());
+ var browser = new Border
+ {
+ Height = 18, Background = Sunken, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Badge,
+ Child = new DockPanel { Children = { Docked(Arrow(GlyphKind.ChevronLeft, -1), Dock.Left), Docked(Arrow(GlyphKind.ChevronRight, 1), Dock.Right), pname } },
+ };
+ ToolTip.SetTip(browser, "Pattern shapes — the arrows step through them (fitted to the grid)");
+ var rnd = Button("Rnd", Randomize, "Roll a new pattern — Complexity sets how busy and how varied it is");
+ var cx = FillBar(PatComplexity, () => "Complexity " + Pct(P(PatComplexity)), "Complexity — how busy and varied Rnd makes the pattern");
+ var head = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto,110"), ColumnSpacing = 5, Height = 20 };
+ head.Children.Add(tools); head.Children.Add(Col(browser, 1)); head.Children.Add(Col(rnd, 2)); head.Children.Add(Col(cx, 3));
+
+ var smooth = FillBar(PatSmooth, () => "Smooth " + Pct(P(PatSmooth)), "Smooth — ramps into each step instead of jumping (up to half a step)");
+ var swing = FillBar(PatSwing, () => NotaNum.F($"Swing {P(PatSwing) * 75:0} %"), "Swing — every second step comes late");
+ var nSt = Mono("", 9, AccentBright); var nLv = Mono("", 9, AccentBright);
+ readouts.Add(() => { nSt.Text = NSteps().ToString(); nLv.Text = NLevels().ToString(); });
+ Border Cycle(TextBlock t, Action a, string tip)
+ {
+ var b = new Border { Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand), Child = t };
+ b.PointerPressed += (_, e) => { if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return; a(); RefreshAll(); e.Handled = true; };
+ ToolTip.SetTip(b, tip);
+ return b;
+ }
+ var gridSize = new Border
+ {
+ Height = 18, Padding = new Thickness(6, 0), Background = Sunken, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Badge,
+ Child = Row(4, Caps("GRID"),
+ Cycle(nSt, () =>
+ {
+ var cur = StepsNow();
+ int si = (Sel(PatSteps, 3) + 1) % 3;
+ var next = Resample(cur, StepCounts[si]);
+ SetP(PatSteps, si / 2f);
+ WriteSteps(next);
+ }, "Steps — 8, 16 or 32 (the pattern is stretched to fit)"),
+ Mono("×", 8, TextTertiary),
+ Cycle(nLv, () =>
+ {
+ var cur = StepsNow();
+ SetP(PatLevels, (Sel(PatLevels, 3) + 1) % 3 / 2f);
+ WriteSteps(Array.ConvertAll(cur, v => Qz(v)));
+ }, "Levels — 4, 8 or 16 heights a step snaps to")),
+ };
+ var target = Seg(PatTarget, new[] { "Off", "Volume", "Map" },
+ "Target — Off; Volume: the pattern gates the audio; Map: the audio is left alone and the pattern drives Pattern Out, a CV source in the Modular view");
+ var foot = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,Auto,Auto"), ColumnSpacing = 5, Height = 20 };
+ foot.Children.Add(smooth); foot.Children.Add(Col(swing, 1)); foot.Children.Add(Col(gridSize, 2)); foot.Children.Add(Col(target, 3));
+
+ return new DockPanel
+ {
+ LastChildFill = true, Margin = new Thickness(8, 5, 8, 5),
+ Children = { Docked(head, Dock.Top), Docked(foot, Dock.Bottom), new Border { Margin = new Thickness(0, 5), Child = patView } },
+ };
+ }
+
+ Control RhythmTab()
+ {
+ var rate = K(PatRate, "RATE", _ => RateName(), steps: 5, size: 40, tip: "Rate — how long the whole pattern takes: 1/4 … 4 bars in Sync, 4 … 0.25\u2009Hz in Free");
+ var depth = K(PatDepth, "DEPTH", v => Pct((float)v), Teal, size: 40, tip: "Depth — how far an empty step turns the signal down");
+ var knobs = new UniformGrid { Columns = 2, Children = { rate, depth } };
+ var clock = Segments(new[] { "Sync", "Free" }, () => On(PatSync) ? 0 : 1, i => { SetP(PatSync, i == 0 ? 1f : 0f); RefreshAll(); }, out var clockSync, fill: true);
+ readouts.Add(clockSync);
+ Learn(clock, PatSync);
+ ToolTip.SetTip(clock, "Clock — Sync locks the pattern to the song's bars, Free runs it in Hz");
+ var clockRow = LabelRow("CLOCK", clock);
+ var btns = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,*"), ColumnSpacing = 4 };
+ btns.Children.Add(Button("Copy", () => _clipboard = StepsNow(), "Copy the steps"));
+ btns.Children.Add(Col(Button("Paste", () => { if (_clipboard is { } c) WriteSteps(Array.ConvertAll(Resample(c, NSteps()), v => Qz(v))); }, "Paste copied steps (fitted to the grid)", () => _clipboard is not null), 1));
+ btns.Children.Add(Col(Button("Clear", () => WriteSteps(new float[NSteps()]), "Clear every step"), 2));
+ return Spread(
+ knobs,
+ clockRow,
+ btns,
+ new StackPanel { Spacing = 5, Children = {
+ Toggle(PatRetrig, "Retrig on MIDI note", "Retrig — every MIDI note on this track (or the key track) restarts the pattern"),
+ Toggle(PatGated, "Only while gate open", "Gated — the pattern plays only while the threshold gate is open (gate × pattern)") } });
+ }
+
// ======================================================================
// RIGHT — Detector / Meters
// ======================================================================
@@ -561,8 +802,10 @@ internal sealed class ShutterDeviceBody : IDeviceBody
int centreTab = 0;
var centreHost = new ContentControl();
var rightHost = new ContentControl();
- var centreBodies = new Control?[3];
+ var rhythmHost = new ContentControl();
+ var centreBodies = new Control?[4];
var rightBodies = new Control?[2];
+ var rhythmBodies = new Control?[2];
var extras = Mono("", 7, TextTertiary);
var extrasHost = new Border { Background = Brushes.Transparent, Child = extras, VerticalAlignment = VerticalAlignment.Stretch };
extrasHost.PointerPressed += (_, e) =>
@@ -577,17 +820,26 @@ internal sealed class ShutterDeviceBody : IDeviceBody
{
1 => NotaNum.F($"one opening · {MsN(AtkMs() + HoldMs() + RelMs())}\u2009ms"),
2 => NotaNum.F($"key: {KeyName()} · {(On(DetFilter) ? "filter " + HpF(P(DetHP)) + "…" + LpF(P(DetLP)) : "full band")}"),
+ 3 => NotaNum.F($"step {(int)Sc(kPatAt + P_Step) + 1}/{NSteps()} · {(On(PatSync) ? $"{Sc(S_Bpm):0} BPM" : RateFree[RateIdx()])}"),
_ => NotaNum.F($"window {WindowText()} · look {LookMs()}\u2009ms"),
};
extrasHost.Cursor = centreTab == 0 ? new Cursor(StandardCursorType.Hand) : Cursor.Default;
});
ToolTip.SetTip(extrasHost, "Signal tab: click to change the window — " + string.Join(" · ", WindowNames));
- Control CentreBody(int t) => centreBodies[t] ??= t switch { 1 => EnvelopeTab(), 2 => SidechainTab(), _ => SignalTab() };
+ Control CentreBody(int t) => centreBodies[t] ??= t switch { 1 => EnvelopeTab(), 2 => SidechainTab(), 3 => PatternTab(), _ => SignalTab() };
Control RightBody(int t) => rightBodies[t] ??= t == 1 ? MetersTab() : DetectorTab();
+ Control RhythmBody(int t) => rhythmBodies[t] ??= t == 1 ? DetectorTab() : RhythmTab();
- var centre = TabFrame(new[] { "Signal", "Envelope", "Sidechain" }, centreHost, CentreBody, false, t => { centreTab = t; Refresh(); }, extrasHost);
+ // The right panel follows the centre: Rhythm / Detector beside the pattern, else Detector / Meters.
var rightFrame = TabFrame(new[] { "Detector", "Meters" }, rightHost, RightBody, true, _ => RefreshAll(), null);
+ Control? rhythmFrame = null;
var right = new Border { Width = 186, Background = Card2, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Tile, ClipToBounds = true, Child = rightFrame };
+ var centre = TabFrame(new[] { "Signal", "Envelope", "Sidechain", "Pattern" }, centreHost, CentreBody, false, t =>
+ {
+ centreTab = t;
+ right.Child = t == 3 ? rhythmFrame ??= TabFrame(new[] { "Rhythm", "Detector" }, rhythmHost, RhythmBody, true, _ => RefreshAll(), null) : rightFrame;
+ Refresh();
+ }, extrasHost);
DockPanel.SetDock(right, Dock.Right);
var centreBox = new Border { Background = Card2, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Tile, Margin = new Thickness(5, 0), ClipToBounds = true, Child = centre };
@@ -600,6 +852,16 @@ internal sealed class ShutterDeviceBody : IDeviceBody
{
string floor = P(Floor) <= 0.001f ? "−∞" : NotaNum.F($"{FloorDb():0.0}\u2009dB");
var parts = new List<string> { Duck() ? "Duck" : "Gate" };
+ if (centreTab == 3)
+ {
+ int tg = Sel(PatTarget, 3);
+ return string.Join(" · ", new[]
+ {
+ tg == 0 ? "Pattern off" : "Pattern", PatternName(), RateName(), NotaNum.F($"{NSteps()} × {NLevels()}"),
+ "smooth " + Pct(P(PatSmooth)), "swing " + NotaNum.F($"{P(PatSwing) * 75:0}\u2009%"), "depth " + Pct(P(PatDepth)),
+ }) + (tg == 0 ? "" : tg == 2 ? " → Map (Pattern Out)" : On(PatGated) ? " → Volume · gated" : " → Volume")
+ + (On(PatRetrig) ? " · MIDI retrig" : "");
+ }
switch (centreTab)
{
case 1:
@@ -656,6 +918,16 @@ internal sealed class ShutterDeviceBody : IDeviceBody
if (centreTab == 1 && envView is not null)
envView.Set(AtkMs(), HoldMs(), RelMs(), FloorLin(), Sel(Shape, 3), Duck(), On(Retrigger),
P(Floor) <= 0.001f ? "−∞\u2009dB" : NotaNum.F($"{FloorDb():0.0}\u2009dB"), MsN(AtkMs()), MsN(HoldMs()), MsF(RelMs()));
+ if (centreTab == 3 && patView is not null)
+ {
+ int ns = NSteps();
+ for (int k = 0; k < ns; k++) patBuf[k] = P(Step1 + k);
+ int tg = Sel(PatTarget, 3);
+ bool on = tg > 0 && scN >= kScope;
+ patView.Set(patBuf, ns, NLevels(), on ? (int)Sc(kPatAt + P_Step) : -1, on ? Sc(kPatAt + P_Phase) : -1,
+ P(PatSmooth), P(PatSwing) * 0.375, P(PatDepth), tg == 2, tg > 0,
+ tg == 2 ? "Map → Pattern Out" : tg == 1 ? "gain" : "off");
+ }
if (centreTab == 2 && keyView is not null)
keyView.Set(Exp(P(DetHP), 20, 2000), Exp(P(DetLP), 200, 20000), On(DetFilter), h, H_Gate, n, Duck() ? "duck" : "reduction");
RefreshAll();
diff --git a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
index 9fc3a330..f681e037 100644
--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
@@ -1227,6 +1227,26 @@ public sealed class FactoryPresetCatalog : IFactoryPresets
Fx("shutter", 19, "Bass Under Kick", ("Threshold", 0.571f), ("Flip", 1f), ("Attack", 0.425f), ("Hold", 0.622f), ("Release", 0.63f), ("Floor", 0.857f), ("Det HP", 0.088f), ("Det LP", 0.088f));
Fx("shutter", 19, "Voice-Over Duck", ("Threshold", 0.429f), ("Return", 0.25f), ("Flip", 1f), ("Attack", 0.75f), ("Hold", 0.94f), ("Release", 0.879f), ("Floor", 0.829f), ("Det HP", 0.438f), ("Det LP", 0.651f));
Fx("shutter", 19, "Key Tuning (Listen)", ("Threshold", 0.457f), ("Listen", 1f), ("Det HP", 0.349f), ("Det LP", 0.349f));
+ Section("Pattern");
+ // Rhythmic gate (the Pattern tab). Steps are written in eighths ('0'..'8' → 0..1, 8 levels);
+ // their count sets Pattern Steps. Pattern Target .5 = Volume, 1 = Map (Pattern Out, a CV
+ // source); Pattern Rate idx/4 = Sync 1/4 · 1/2 · 1 Bar · 2 Bars · 4 Bars (Free 4 · 2 · 1 ·
+ // 0.5 · 0.25 Hz); Swing 0..1 → 0..75 %; Lookahead 0 keeps the pure patterns latency-free.
+ Pat("Trance 16ths", "8080880880808808", ("Pattern Smooth", 0.1f));
+ Pat("Offbeat Pump", "0080008000800080", ("Pattern Depth", 0.85f), ("Pattern Smooth", 0.35f));
+ Pat("Four-Floor Pump", "1468146814681468", ("Pattern Depth", 0.9f), ("Pattern Smooth", 0.5f));
+ Pat("Stutter Bar", "8888000080808800");
+ Pat("Halftime Chop", "8880000088800040", ("Pattern Rate", 0.75f), ("Pattern Smooth", 0.08f));
+ Pat("Ramp Up", "1234567812345678", ("Pattern Smooth", 0.5f));
+ Pat("Chop Shop", "8060830580628040", ("Pattern Smooth", 0.05f));
+ Pat("Swung Gate", "8080808080808080", ("Pattern Swing", 0.667f), ("Pattern Smooth", 0.1f));
+ Pat("Dotted Eighths", "8008008008008008", ("Pattern Smooth", 0.15f));
+ Pat("Slow Pad Gate", "80608040", ("Pattern Rate", 1f), ("Pattern Depth", 0.75f), ("Pattern Smooth", 0.6f));
+ Pat("Free Tremolo", "84848484", ("Pattern Sync", 0f), ("Pattern Rate", 0.5f), ("Pattern Depth", 0.6f), ("Pattern Smooth", 1f));
+ Pat("32nd Roll", "80008000800080008080808080808080");
+ Pat("Gate Rider", "8080808880808088", ("Pattern Gated", 1f), ("Pattern Depth", 0.7f), ("Pattern Smooth", 0.2f), ("Lookahead", 0.5f));
+ Pat("MIDI Retrig Chop", "88088080", ("Pattern Retrig", 1f), ("Pattern Rate", 0.25f), ("Pattern Smooth", 0.05f));
+ Pat("Map Sequencer", "1357864213578642", ("Pattern Target", 1f), ("Pattern Smooth", 0.3f));
// ---- Nota Chamber (kind 20) — hybrid reverb, all params normalized 0..1 (unnamed params
// reset to their defaults). IR = index/16 (0 Concert Hall · .0625 Stone Vault · .125
@@ -2507,6 +2527,20 @@ public sealed class FactoryPresetCatalog : IFactoryPresets
private void Fx(string group, int kind, string name, params (string Name, float Value)[] ps)
=> Add(group, name, "builtin-effect", kind, isInstrument: false, isMidi: false, ps);
+ // Nota Shutter pattern preset: `steps` in eighths ('0'..'8'), 8 / 16 / 32 of them; Volume target,
+ // 1 Bar, Sync, full depth and no lookahead unless `ps` says otherwise.
+ private void Pat(string name, string steps, params (string Name, float Value)[] ps)
+ {
+ var all = new List<(string Name, float Value)>
+ {
+ ("Pattern Target", 0.5f), ("Pattern Rate", 0.5f), ("Pattern Sync", 1f), ("Pattern Depth", 1f), ("Lookahead", 0f),
+ ("Pattern Steps", steps.Length switch { 8 => 0f, 32 => 1f, _ => 0.5f }),
+ };
+ for (int k = 0; k < steps.Length; k++) all.Add(($"Step {k + 1}", (steps[k] - '0') / 8f));
+ foreach (var p in ps) { all.RemoveAll(a => a.Name == p.Name); all.Add(p); }
+ Fx("shutter", 19, name, all.ToArray());
+ }
+
// Nota Level in units → normalized pairs (see the Level block above).
private void Lv(string name, float targetLufs, int scale, bool fast = false, float window = 6, float maxG = 12, bool safe = true,
float ceil = -1, float trim = 0, float? manual = null)
diff --git a/src/managed/Nota.Mcp/Tools/DeviceTools.cs b/src/managed/Nota.Mcp/Tools/DeviceTools.cs
index 4d6bfd75..d257c823 100644
--- a/src/managed/Nota.Mcp/Tools/DeviceTools.cs
+++ b/src/managed/Nota.Mcp/Tools/DeviceTools.cs
@@ -288,7 +288,8 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
public sealed record ShutterReading(string Summary, string Live, string Mode, string State, double Gain, double ReductionDb,
double PeakReductionDb, double InputDb, double OutputDb, double DetectorDb, double KeyDb, bool ExternalKey, int KeySourceTrackId,
double ThresholdDb, double CloseDb, double FloorDb, double OpenShare, double WindowSeconds, int OpeningsLastBar, int OpeningsSinceReset,
- int LatencySamples, ShutterPoint[] History, double SampleRate);
+ int LatencySamples, ShutterPoint[] History, double SampleRate, string Pattern, int PatternStep, int PatternSteps,
+ double PatternPhase, double PatternValue);
[McpServerTool(Name = "read_shutter"), Description(
"Read what a Nota Shutter (built-in effect kind 19 — noise gate / ducker) is doing right now: Gate or Duck, its state "
@@ -298,11 +299,14 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
+ "floor (−120 = −∞), the share of the window it was open (ducking, for Duck), the openings in the last bar and since the "
+ "reset, the look-ahead latency, and the window's history in 16 steps (ms before now, input peak dB, lowest gain). Levels "
+ "move only while audio plays through the track. Use get_device_text id 2 for what each parameter value means, "
- + "set_device_sidechain to route a key (External Key must be on, its default), device_action 0 to reset the meters.")]
+ + "set_device_sidechain to route a key (External Key must be on, its default), device_action 0 to reset the meters. "
+ + "Pattern (the rhythmic gate): Off / Volume / Map, the step playing now (1-based) of how many, the phase through the "
+ + "pattern 0..1 and its value now (the gain it applies in Volume, Pattern Out in Map). Its steps are the params "
+ + "Step 1..Step 32; Pattern Target 0 / 0.5 / 1 = Off / Volume / Map.")]
public Task<ShutterReading> ReadShutter(int trackId, int deviceIndex) => Read(() =>
{
- const int tele = 24, hist = 128;
- var sc = new float[tele + 3 * hist];
+ const int tele = 24, hist = 128, pat = tele + 3 * hist;
+ var sc = new float[pat + 8];
int n = E.DeviceScope(trackId, deviceIndex, sc, sc.Length);
float V(int i) => n > i ? sc[i] : 0f;
static double R1(double v) => Math.Round(v, 1);
@@ -310,7 +314,7 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
bool duck = E.DeviceGetParam(trackId, deviceIndex, 7) >= 0.5f;
double win = V(20) > 0 ? V(20) : 1;
var pts = new List<ShutterPoint>();
- if (n >= sc.Length)
+ if (n >= pat)
for (int k = 0; k < 16; k++)
{
int a = k * hist / 16, b = (k + 1) * hist / 16;
@@ -321,7 +325,9 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
return new ShutterReading(E.DeviceText(trackId, deviceIndex, 0), E.DeviceText(trackId, deviceIndex, 1),
duck ? "Duck" : "Gate", states[Math.Clamp((int)Math.Round(V(5)), 0, 4)], Math.Round(V(1), 3), R1(V(2)), R1(V(18)),
R1(V(0)), R1(V(6)), R1(V(3)), R1(V(14)), V(13) > 0.5f, E.DeviceSidechainSource(trackId, deviceIndex),
- R1(V(15)), R1(V(16)), R1(V(17)), Math.Round(V(7), 2), win, (int)V(8), (int)V(9), (int)V(12), pts.ToArray(), V(10));
+ R1(V(15)), R1(V(16)), R1(V(17)), Math.Round(V(7), 2), win, (int)V(8), (int)V(9), (int)V(12), pts.ToArray(), V(10),
+ new[] { "Off", "Volume", "Map" }[Math.Clamp((int)Math.Round(V(pat + 4)), 0, 2)], (int)V(pat + 1) + 1, (int)V(pat + 5),
+ Math.Round(V(pat), 3), Math.Round(V(pat + 3), 3));
});
public sealed record PitchPoint(double Ms, double DetectedMidi, double OutputMidi, double MidiTarget);
diff --git a/src/native/nota.engine/src/Device.h b/src/native/nota.engine/src/Device.h
index 63441f7c..577ec85d 100644
--- a/src/native/nota.engine/src/Device.h
+++ b/src/native/nota.engine/src/Device.h
@@ -147,6 +147,9 @@ public:
// events for the block (offsets within the block) right before process(). Audio thread.
virtual bool wantsMidiKey() const { return false; }
virtual void setMidiKey(const MidiEv* /*evs*/, int32_t /*n*/) {}
+ // With no sidechain source routed, a device that returns true here gets its own track's
+ // notes through setMidiKey instead (Nota Shutter's pattern retrigger).
+ virtual bool wantsOwnMidiKey() const { return false; }
// Sidechain shaping (Phase D). Stored on the base so they
// persist/query generically; each dynamics device reads them in process():
diff --git a/src/native/nota.engine/src/Engine_Render.cpp b/src/native/nota.engine/src/Engine_Render.cpp
index 1e5040bd..02066899 100644
--- a/src/native/nota.engine/src/Engine_Render.cpp
+++ b/src/native/nota.engine/src/Engine_Render.cpp
@@ -1081,7 +1081,7 @@ void Engine::mixGraph(Graph* g, float* out, int32_t frames, double blockStart, b
: (d->sidechainTapPre() ? routeBusPre_[s].data() : routeBus_[s].data());
d->setSidechain(sc, frames);
if (d->wantsMidiKey()) feedMidiKey(g, *d, src);
- }
+ } else if (d->wantsOwnMidiKey()) feedMidiKey(g, *d, t.id()); // no key track: this track's notes
if (spb > 0.0) d->setTransport(blockStart / spb, spb, playing); // tempo-synced devices
d->setTransportInfo(ti); // hosted-plugin sync
d->process(scratch_.data(), frames);
@@ -1167,7 +1167,7 @@ void Engine::mixGraph(Graph* g, float* out, int32_t frames, double blockStart, b
: (d->sidechainTapPre() ? routeBusPre_[s].data() : routeBus_[s].data());
d->setSidechain(sc, frames);
if (d->wantsMidiKey()) feedMidiKey(g, *d, src);
- }
+ } else if (d->wantsOwnMidiKey()) feedMidiKey(g, *d, t.id()); // no key track: this track's notes
if (spb > 0.0) d->setTransport(blockStart / spb, spb, playing);
d->setTransportInfo(ti);
d->process(scratch_.data(), frames);
@@ -1234,7 +1234,7 @@ void Engine::mixGraph(Graph* g, float* out, int32_t frames, double blockStart, b
: (d->sidechainTapPre() ? routeBusPre_[s].data() : routeBus_[s].data());
d->setSidechain(sc, frames);
if (d->wantsMidiKey()) feedMidiKey(g, *d, src);
- }
+ } else if (d->wantsOwnMidiKey()) feedMidiKey(g, *d, t.id()); // no key track: this track's notes
if (spb > 0.0) d->setTransport(blockStart / spb, spb, playing);
d->setTransportInfo(ti); // hosted-plugin sync
d->process(scratch_.data(), frames);
diff --git a/src/native/nota.engine/src/Shutter.h b/src/native/nota.engine/src/Shutter.h
index b9fac1fc..f6efd22c 100644
--- a/src/native/nota.engine/src/Shutter.h
+++ b/src/native/nota.engine/src/Shutter.h
@@ -19,6 +19,14 @@
// appended ones default to the old sound). Persistence / automation / clone flow generically.
// Telemetry (scopeRead): kTele live values, then three kHist-column histories over the
// window (input peak dB, gate gain 0..1, detector dB), oldest first.
+// Pattern (appended): a tempo-synced step pattern of gain — a rhythmic gate. Off / Volume /
+// Map: Volume multiplies the output by 1 − depth·(1 − step) (in place of the threshold gate,
+// or on top of it with Gated), Map leaves the audio alone and writes the pattern into the
+// read-only "Pattern Out" param, a CV source for the Modular editor. 8 / 16 / 32 steps live in
+// "Step 1".."Step 32" (quantised to 4 / 8 / 16 levels), the pattern spans 1/4 … 4 bars (Sync,
+// locked to the song while it plays) or 4 … 0.25 Hz (Free); Smooth ramps into each step,
+// Swing delays the off-steps, Retrig restarts it on every MIDI note of this track (or the key
+// track). The pattern block (kPat values) follows the histories in scopeRead.
// deviceText: 0 = status line, 1 = live reading, 2 = parameter guide.
// deviceAction: 0 = reset the meters (peak GR, triggers, history), 1 = window (iarg 0 250 ms,
// 1 1 s, 2 4 s).
@@ -26,6 +34,7 @@
#pragma once
#include "Device.h"
+#include "MidiDevice.h"
#include "TransportInfo.h"
#include <algorithm>
@@ -60,7 +69,22 @@ public:
DetFilter, // >=0.5 the detector band-pass is in (off = full-band key)
PeakHold, // >=0.5 the detector holds peaks (~40 ms fall instead of 3 ms)
ExternalKey, // >=0.5 key off the sidechain source when one is routed
- kNumParams
+ // ---- appended (Pattern tab) ----
+ PatTarget, // 0 Off / 0.5 Volume / 1 Map
+ PatRate, // 5 steps: Sync 1/4 · 1/2 · 1 Bar · 2 Bars · 4 Bars, Free 4 · 2 · 1 · 0.5 · 0.25 Hz
+ PatDepth, // how far a 0 step pulls the gain down (0..1)
+ PatSync, // >=0.5 tempo-synced (Sync), else Free (Hz)
+ PatSmooth, // ramp into each step, 0..1 → 0..½ step
+ PatSwing, // off-step delay, 0..1 → 0..75 % (of half a step)
+ PatSteps, // 0 / 0.5 / 1 → 8 / 16 / 32 steps
+ PatLevels, // 0 / 0.5 / 1 → 4 / 8 / 16 levels
+ PatRetrig, // >=0.5 a MIDI note-on restarts the pattern
+ PatGated, // >=0.5 the pattern only plays while the threshold gate is open (gate × pattern)
+ PatComplexity, // the dice's density (editor; not a sound param)
+ PatOut, // read-only: the pattern's value now 0..1 (written by process; Map's CV source)
+ Step1, // Step 1 .. Step 32, 0..1
+ kNumSteps = 32,
+ kNumParams = Step1 + kNumSteps
};
// Telemetry slots (scopeRead). 0..4 keep the original layout.
@@ -92,7 +116,11 @@ public:
};
static constexpr int kHist = 128;
static constexpr int kHistAt = kTele; // input peak dB · gate gain · detector dB
- static constexpr int kScope = kTele + 3 * kHist;
+ // Pattern block after the histories.
+ enum { P_Phase = 0, P_Step, P_Gain, P_Value, P_Target, P_Steps, P_Beats, kPat = 8 };
+ static constexpr int kPatAt = kTele + 3 * kHist;
+ static constexpr int kScope = kPatAt + kPat;
+ static constexpr int kPushPattern[16] = { 8, 0, 8, 8, 0, 8, 8, 0, 8, 0, 8, 8, 0, 8, 0, 8 };
Shutter() {
p_[Threshold].store(0.457f); // −38 dB
@@ -111,6 +139,19 @@ public:
p_[DetFilter].store(1.0f); // the original always filtered the key
p_[PeakHold].store(0.0f);
p_[ExternalKey].store(1.0f); // a routed key is used (the original behaviour)
+ p_[PatTarget].store(0.0f); // Off — the gate sounds as before
+ p_[PatRate].store(0.5f); // 1 Bar
+ p_[PatDepth].store(1.0f);
+ p_[PatSync].store(1.0f);
+ p_[PatSmooth].store(0.0f);
+ p_[PatSwing].store(0.0f);
+ p_[PatSteps].store(0.5f); // 16
+ p_[PatLevels].store(0.5f); // 8
+ p_[PatRetrig].store(0.0f);
+ p_[PatGated].store(0.0f);
+ p_[PatComplexity].store(0.5f);
+ p_[PatOut].store(1.0f);
+ for (int k = 0; k < kNumSteps; ++k) p_[Step1 + k].store(kPushPattern[k % 16] / 8.0f); // "Push"
for (auto& h : hist_) h.fill(0.0f);
setSampleRate(44100.0, 0);
}
@@ -140,6 +181,16 @@ public:
int32_t latencySamples() const override { return laSamples(); }
+ // Tempo: the pattern locks to the song while it plays.
+ void setTransport(double beatStart, double samplesPerBeat, bool playing) override {
+ tBeat_ = beatStart; tSpb_ = samplesPerBeat; tPlaying_ = playing; tFed_ = true;
+ }
+
+ // Pattern retrigger: this track's notes (or the key track's) when Retrig is on.
+ bool wantsMidiKey() const override { return get(PatRetrig) >= 0.5f && patTarget() > 0; }
+ bool wantsOwnMidiKey() const override { return wantsMidiKey(); }
+ void setMidiKey(const MidiEv* evs, int32_t n) override { midiEvs_ = evs; midiN_ = n; }
+
void deviceAction(int32_t id, int32_t iarg, float) override {
if (id == A_ResetMeters) resetMetersReq_.store(true, std::memory_order_relaxed);
else if (id == A_Window) windowIdx_.store(std::clamp(iarg, 0, 2), std::memory_order_relaxed);
@@ -187,9 +238,51 @@ public:
const int colLen = std::max(1, (int)std::lround(winSec * sr_ / kHist));
const float ratioC = coef((float)(winSec * 1000.0));
+ // ---- Pattern ----
+ const int patT = patTarget();
+ const int nSteps = patSteps();
+ const int nLevels = patLevels();
+ const bool pSync = get(PatSync) >= 0.5f;
+ const int rateI = patRateIdx();
+ const double spb = (tFed_ && tSpb_ > 1.0) ? tSpb_ : sr_ * 60.0 / bpm_;
+ const double barBeats = (double)tsNum_ * 4.0 / (double)tsDen_;
+ static constexpr double kSyncBeats[5] = { 1.0, 2.0, 0.0, 0.0, 0.0 }; // 1/4, 1/2 · then bars
+ static constexpr double kBars[5] = { 0.0, 0.0, 1.0, 2.0, 4.0 };
+ static constexpr double kFreeHz[5] = { 4.0, 2.0, 1.0, 0.5, 0.25 };
+ const double patBeats = rateI < 2 ? kSyncBeats[rateI] : kBars[rateI] * barBeats;
+ const double phInc = pSync ? 1.0 / std::max(1.0, patBeats * spb) : kFreeHz[rateI] / sr_;
+ const bool retrigOn = get(PatRetrig) >= 0.5f;
+ // Locked to the song: the phase of the output sample (look-ahead delays the audio).
+ const bool lock = pSync && !retrigOn && tFed_ && tPlaying_ && patBeats > 0.0;
+ const double lockBeat0 = tBeat_ - (double)la / spb;
+ const float depth = get(PatDepth);
+ const float smooth = get(PatSmooth) * 0.5f; // ramp, in steps
+ const float swing = get(PatSwing) * 0.75f * 0.5f; // off-step delay, in steps
+ const bool gated = get(PatGated) >= 0.5f;
+ float stepV[kNumSteps];
+ for (int k = 0; k < nSteps; ++k) stepV[k] = std::round(std::clamp(get(Step1 + k), 0.0f, 1.0f) * nLevels) / nLevels;
+ const float patSmC = coef(1.0f); // ~1 ms de-click on the pattern gain
+ int mi = 0;
+ float patVal = patVal_;
+
float grMax = 0.0f;
for (int32_t i = 0; i < frames; ++i) {
+ // Pattern phase: song-locked, or free-running (restarted by a MIDI note-on).
+ if (patT > 0) {
+ if (retrigOn && midiEvs_)
+ for (; mi < midiN_ && midiEvs_[mi].off <= i; ++mi)
+ if (midiEvs_[mi].on) patPhase_ = 0.0;
+ if (lock) {
+ const double b = lockBeat0 + (double)i / spb;
+ patPhase_ = b / patBeats - std::floor(b / patBeats);
+ }
+ const float v = patternAt(stepV, nSteps, (float)(patPhase_ * nSteps), smooth, swing);
+ patVal = v + patSmC * (patVal - v);
+ if (!lock) { patPhase_ += phInc; if (patPhase_ >= 1.0) patPhase_ -= std::floor(patPhase_); }
+ }
+ const float patGain = 1.0f - depth * (1.0f - patVal);
+
const float l = buf[i * 2], r = buf[i * 2 + 1];
// Detector source: external key if routed and enabled, else this track.
@@ -229,6 +322,7 @@ public:
else env_ = tgt > env_ ? std::min(tgt, env_ + rAtk) : std::max(tgt, env_ - rRel);
const float f = shape == 2 ? 1.0f - (1.0f - env_) * (1.0f - env_) * (1.0f - env_) : env_;
g_ = flip ? 1.0f - (1.0f - floorLin) * f : floorLin + (1.0f - floorLin) * f;
+ if (patT == 1) g_ = gated ? g_ * patGain : patGain; // Volume: the pattern is the gate (or rides it)
// Look-ahead: apply the (anticipating) gain to the delayed audio.
laBuf_[(size_t)laW_ * 2] = l; laBuf_[(size_t)laW_ * 2 + 1] = r;
@@ -287,6 +381,15 @@ public:
bpmA_.store((float)bpm_, std::memory_order_relaxed);
winA_.store((float)winSec, std::memory_order_relaxed);
scBuf_ = nullptr;
+ midiEvs_ = nullptr; midiN_ = 0; tFed_ = false;
+
+ patVal_ = patVal;
+ const float patOut = patT > 0 ? 1.0f - depth * (1.0f - patVal) : 1.0f;
+ p_[PatOut].store(patOut, std::memory_order_relaxed);
+ patPhaseA_.store((float)patPhase_, std::memory_order_relaxed);
+ patGainA_.store(patT == 1 ? patOut : 1.0f, std::memory_order_relaxed);
+ patValA_.store(patOut, std::memory_order_relaxed);
+ patBeatsA_.store(pSync ? (float)patBeats : 0.0f, std::memory_order_relaxed);
if (frames > 0) {
const double el = std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count();
cpuS_ = cpuS_ * 0.9 + (el / (frames / sr_)) * 0.1;
@@ -329,6 +432,16 @@ public:
const int hw = histW_.load(std::memory_order_acquire);
for (int s = 0; s < 3; ++s)
for (int k = 0; k < kHist && n < maxSamples; ++k) out[n++] = hist_[(size_t)s][(size_t)((hw + k) % kHist)];
+ float pt[kPat] = {};
+ const float ph = patPhaseA_.load(std::memory_order_relaxed);
+ pt[P_Phase] = ph;
+ pt[P_Step] = (float)std::min(patSteps() - 1, (int)(ph * patSteps()));
+ pt[P_Gain] = patGainA_.load(std::memory_order_relaxed);
+ pt[P_Value] = patValA_.load(std::memory_order_relaxed);
+ pt[P_Target] = (float)patTarget();
+ pt[P_Steps] = (float)patSteps();
+ pt[P_Beats] = patBeatsA_.load(std::memory_order_relaxed);
+ for (int k = 0; k < kPat && n < maxSamples; ++k) out[n++] = pt[k];
return n;
}
@@ -337,10 +450,20 @@ public:
int32_t paramCount() const override { return kNumParams; }
const char* paramName(int32_t i) const override {
- static const char* nm[kNumParams] = { "Threshold", "Return", "Attack", "Hold", "Release", "Floor",
- "Lookahead", "Flip", "Det HP", "Det LP", "Listen",
- "Shape", "Retrigger", "Det Filter", "Peak Hold", "External Key" };
- return (i >= 0 && i < kNumParams) ? nm[i] : "";
+ static const char* nm[Step1] = { "Threshold", "Return", "Attack", "Hold", "Release", "Floor",
+ "Lookahead", "Flip", "Det HP", "Det LP", "Listen",
+ "Shape", "Retrigger", "Det Filter", "Peak Hold", "External Key",
+ "Pattern Target", "Pattern Rate", "Pattern Depth", "Pattern Sync", "Pattern Smooth",
+ "Pattern Swing", "Pattern Steps", "Pattern Levels", "Pattern Retrig", "Pattern Gated",
+ "Pattern Complexity", "Pattern Out" };
+ static const auto steps = [] {
+ std::array<std::string, kNumSteps> a;
+ for (int k = 0; k < kNumSteps; ++k) a[(size_t)k] = "Step " + std::to_string(k + 1);
+ return a;
+ }();
+ if (i >= 0 && i < Step1) return nm[i];
+ if (i >= Step1 && i < kNumParams) return steps[(size_t)(i - Step1)].c_str();
+ return "";
}
float paramMin(int32_t /*i*/) const override { return 0.0f; }
float paramMax(int32_t /*i*/) const override { return 1.0f; }
@@ -370,19 +493,44 @@ public:
else s += " - key full-band";
if (get(PeakHold) >= 0.5f) s += " - peak hold";
if (get(Listen) >= 0.5f) s += " - LISTEN (key monitor)";
+ if (patTarget() > 0) {
+ static const char* syncN[5] = { "1/4", "1/2", "1 bar", "2 bars", "4 bars" };
+ static const char* freeN[5] = { "4 Hz", "2 Hz", "1 Hz", "0.5 Hz", "0.25 Hz" };
+ std::snprintf(b, sizeof b, " - PATTERN %s %s, %d steps x %d levels, depth %.0f %%, smooth %.0f %%, swing %.0f %%%s%s",
+ patTarget() == 1 ? (get(PatGated) >= 0.5f ? "volume (gated)" : "volume") : "map (Pattern Out)",
+ get(PatSync) >= 0.5f ? syncN[patRateIdx()] : freeN[patRateIdx()], patSteps(), patLevels(),
+ get(PatDepth) * 100.0f, get(PatSmooth) * 100.0f, get(PatSwing) * 75.0f,
+ get(PatRetrig) >= 0.5f ? ", MIDI retrig" : "", "");
+ s += b;
+ s += " [";
+ for (int k = 0; k < patSteps(); ++k) {
+ const float v = std::round(get(Step1 + k) * patLevels()) / patLevels();
+ s += v <= 0.0f ? '.' : v >= 1.0f ? '#' : v >= 0.5f ? '+' : '-';
+ }
+ s += "]";
+ }
return s;
}
if (id == 1) {
float sc[kTele];
scopeRead(sc, kTele);
const int st = std::clamp((int)std::lround(sc[S_State]), 0, 4);
+ float pt[kScope];
+ const int pn = scopeRead(pt, kScope);
+ std::string pat;
+ if (patTarget() > 0 && pn >= kScope) {
+ char pb[160];
+ std::snprintf(pb, sizeof pb, " - pattern step %d/%d, phase %.2f, value %.0f %%",
+ (int)pt[kPatAt + P_Step] + 1, patSteps(), pt[kPatAt + P_Phase], pt[kPatAt + P_Value] * 100.0f);
+ pat = pb;
+ }
std::snprintf(b, sizeof b,
"%s - gain %.0f %% - GR %.1f dB (peak %.1f dB) - in %.1f dB - out %.1f dB - detector %.1f dB vs threshold %.1f dB - "
"open %.0f %% of %.2g s - %.0f openings in the last bar (%.0f since reset) - %s key %.1f dB - latency %.0f smp",
states[st], sc[S_GateGain] * 100.0f, sc[S_GrDb], sc[S_PeakGrDb], sc[S_InDb], sc[S_OutDb], sc[S_DetDb], thr,
sc[S_OpenRatio] * 100.0f, sc[S_WindowSec], sc[S_TrigPerBar], sc[S_Triggers],
sc[S_ExtKey] > 0.5f ? "external" : "internal", sc[S_KeyDb], sc[S_Latency]);
- return b;
+ return b + pat;
}
if (id == 2) {
return "All params 0..1. Threshold: -70 + 70*v dBFS (0.457 = -38 dB). Return: 24*v dB below the threshold, where the gate "
@@ -393,7 +541,12 @@ public:
"Shape: 0 Linear (straight ramps), 0.5 Log (one-pole, the classic), 1 Snap (stays open, then shuts hard). "
"Retrigger: trigger mode, each hit fires one attack-hold-release. Det Filter: the key band-pass is in. "
"Peak Hold: the detector holds peaks (steadier on low notes). External Key: use the routed sidechain source. "
- "Toggles: >= 0.5 = on.";
+ "Toggles: >= 0.5 = on. Pattern Target: 0 Off, 0.5 Volume (a rhythmic gate replacing the threshold gate, or "
+ "riding it when Pattern Gated is on), 1 Map (audio untouched; Pattern Out carries the value as a CV source). "
+ "Pattern Rate: 5 steps — Sync 1/4, 1/2, 1 bar, 2 bars, 4 bars (the whole pattern); Free 4, 2, 1, 0.5, 0.25 Hz. "
+ "Pattern Depth: gain = 1 - depth*(1 - step). Pattern Smooth: ramp into a step, up to half a step. Pattern Swing: "
+ "0..75 % (delays every second step by up to 3/8 step). Pattern Steps: 0/0.5/1 = 8/16/32. Pattern Levels: "
+ "0/0.5/1 = 4/8/16 (steps snap to them). Pattern Retrig: a MIDI note-on restarts it. Step 1..32: 0..1 each.";
}
return {};
}
@@ -426,6 +579,23 @@ private:
}
float get(int i) const { return p_[i].load(std::memory_order_relaxed); }
+ int patTarget() const { return std::clamp((int)std::lround(get(PatTarget) * 2.0f), 0, 2); }
+ int patRateIdx() const { return std::clamp((int)std::lround(get(PatRate) * 4.0f), 0, 4); }
+ int patSteps() const { static constexpr int n[3] = { 8, 16, 32 }; return n[std::clamp((int)std::lround(get(PatSteps) * 2.0f), 0, 2)]; }
+ int patLevels() const { static constexpr int n[3] = { 4, 8, 16 }; return n[std::clamp((int)std::lround(get(PatLevels) * 2.0f), 0, 2)]; }
+
+ // The pattern's value at `pos` steps into it: odd steps start `swing` late, and each step
+ // ramps over `smooth` from the one before (wrapping, so step 1 ramps from the last).
+ static float patternAt(const float* v, int n, float pos, float smooth, float swing) {
+ int i = std::clamp((int)pos, 0, n - 1);
+ float e = pos - (float)i; // time since step i's grid line
+ if ((i & 1) && e < swing) { i -= 1; e += 1.0f; } // still the even step before (swung)
+ else if (i & 1) e -= swing;
+ const float cur = v[i];
+ if (smooth <= 1e-4f || e >= smooth) return cur;
+ const float prev = v[(i + n - 1) % n];
+ return prev + (cur - prev) * (e / smooth);
+ }
int shapeIdx() const { return std::clamp((int)std::lround(get(Shape) * 2.0f), 0, 2); }
int lookIdx() const { return std::clamp((int)std::lround(get(Lookahead) * 2.0f), 0, 2); }
static double expMap(float v, double lo, double hi) { return lo * std::pow(hi / lo, std::clamp((double)v, 0.0, 1.0)); }
@@ -460,6 +630,7 @@ private:
hp_ = {}; lp_ = {};
openRatio_ = 0.0f; colIn_ = 0.0f; colGate_ = 1.0f; colDet_ = 0.0f; colN_ = 0;
for (int k = 0; k < kHist; ++k) hist_[0][(size_t)k] = -120.0f, hist_[1][(size_t)k] = 1.0f, hist_[2][(size_t)k] = -120.0f;
+ patPhase_ = 0.0; patVal_ = 1.0f;
}
double sr_ = 44100.0;
@@ -483,6 +654,12 @@ private:
std::atomic<bool> resetMetersReq_{false};
std::atomic<int> windowIdx_{1};
+ // Pattern runtime.
+ double tBeat_ = 0.0, tSpb_ = 0.0; bool tPlaying_ = false, tFed_ = false;
+ const MidiEv* midiEvs_ = nullptr; int32_t midiN_ = 0;
+ double patPhase_ = 0.0; float patVal_ = 1.0f;
+ std::atomic<float> patPhaseA_{0.0f}, patGainA_{1.0f}, patValA_{1.0f}, patBeatsA_{4.0f};
+
std::atomic<float> inDb_{-120.0f}, outDb_{-120.0f}, keyDb_{-120.0f}, gateGain_{1.0f}, grDb_{0.0f}, peakGrA_{0.0f},
detDb_{-120.0f}, openF_{0.0f}, stateA_{0.0f}, envA_{0.0f}, ratioA_{0.0f}, trigBarA_{0.0f}, trigTotA_{0.0f},
extA_{0.0f}, bpmA_{120.0f}, winA_{1.0f}, srA_{44100.0f}, cpuA_{0.0f};
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 82c49068..40b680eb 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -5186,7 +5186,10 @@ Console.WriteLine("-- Nota Shutter --");
Check(gd >= 0, "add built-in Nota Shutter");
Check(ge.DeviceName(gt, gd) == "Nota Shutter", $"name is Nota Shutter (got '{ge.DeviceName(gt, gd)}')");
Check(ge.TrackDeviceBuiltinKind(gt, gd) == 19, $"builtin kind is 19 (got {ge.TrackDeviceBuiltinKind(gt, gd)})");
- Check(ge.DeviceParamCount(gt, gd) == 16, $"Nota Shutter exposes 16 params (got {ge.DeviceParamCount(gt, gd)})");
+ Check(ge.DeviceParamCount(gt, gd) == 60, $"Nota Shutter exposes 60 params (got {ge.DeviceParamCount(gt, gd)})");
+ Check(ge.DeviceParamName(gt, gd, 16) == "Pattern Target" && ge.DeviceParamName(gt, gd, 27) == "Pattern Out"
+ && ge.DeviceParamName(gt, gd, 28) == "Step 1" && ge.DeviceParamName(gt, gd, 59) == "Step 32", "Shutter appends the Pattern params and Step 1..32");
+ Check(ge.DeviceParamDefault(gt, gd, 16) < 0.01f, "Pattern is off by default (the gate sounds as before)");
string[] appended = { "Shape", "Retrigger", "Det Filter", "Peak Hold", "External Key" };
bool namesOk = true;
for (int k = 0; k < appended.Length; k++) namesOk &= ge.DeviceParamName(gt, gd, 11 + k) == appended[k];
@@ -5319,6 +5322,62 @@ Console.WriteLine("-- Nota Shutter --");
Check(gsc[TExtKey] < 0.5f && unkeyed > toneOpen * 0.95f, $"External Key off keys off the track itself ({unkeyed:F4})");
ge.DeviceSetParam(tt, td, SExtKey, 1f);
ge.SetDeviceSidechainSource(tt, td, -1);
+
+ // Pattern (rhythmic gate) on the held tone, the burst track still shut. Steps on / off in
+ // turn at full depth keep about half the energy (RMS ≈ 1/√2); all-off steps at depth 0.5
+ // halve the level; Map leaves the audio alone and moves Pattern Out instead.
+ {
+ const int PTarget = 16, PDepth = 18, PSmooth = 20, POut = 27, PStep1 = 28, PatAt = 24 + 3 * 128;
+ ge.DeviceSetParam(tt, td, SLook, 0f);
+ for (int k = 0; k < 32; k++) ge.DeviceSetParam(tt, td, PStep1 + k, k % 2 == 0 ? 1f : 0f);
+ ge.DeviceSetParam(tt, td, PTarget, 0.5f);
+ float alt = RunTone();
+ Check(fin && alt > toneOpen * 0.55f && alt < toneOpen * 0.85f, $"Pattern Volume: alternate steps keep ≈ 1/√2 ({alt / toneOpen:0.00})");
+ var psc = new float[PatAt + 8];
+ Check(ge.DeviceScope(tt, td, psc, psc.Length) == psc.Length, $"Shutter scope carries the pattern block ({psc.Length} values)");
+ Check(psc[PatAt + 4] == 1 && psc[PatAt + 5] == 16 && psc[PatAt + 1] >= 0 && psc[PatAt + 1] < 16 && psc[PatAt] >= 0 && psc[PatAt] < 1,
+ $"pattern telemetry: target Volume, 16 steps, step {psc[PatAt + 1]:0}, phase {psc[PatAt]:0.00}");
+ for (int k = 0; k < 32; k++) ge.DeviceSetParam(tt, td, PStep1 + k, 0f);
+ ge.DeviceSetParam(tt, td, PDepth, 0.5f);
+ float half = RunTone();
+ Check(half > toneOpen * 0.42f && half < toneOpen * 0.58f, $"Pattern Depth 50 % on empty steps halves the level ({half / toneOpen:0.00})");
+ ge.DeviceSetParam(tt, td, PDepth, 1f);
+ ge.DeviceSetParam(tt, td, PSmooth, 1f);
+ for (int k = 0; k < 32; k++) ge.DeviceSetParam(tt, td, PStep1 + k, k % 2 == 0 ? 1f : 0f);
+ Check(RunTone() > 0.01f && fin, "Pattern Smooth renders finite and audible");
+ ge.DeviceSetParam(tt, td, PSmooth, 0f);
+ string ptxt = ge.DeviceText(tt, td, 0);
+ Check(ptxt.Contains("PATTERN volume") && ptxt.Contains("[#.#."), $"device text shows the pattern ('{ptxt}')");
+
+ // Map: the audio passes, Pattern Out follows the steps (a CV source).
+ ge.DeviceSetParam(tt, td, PTarget, 1f);
+ float lo = 1, hi = 0; double acc = 0; long nfr = 0;
+ ge.Seek(0); ge.Play();
+ for (int k = 0; k < 40; k++)
+ {
+ ge.RenderOffline(tb, 1024);
+ foreach (var v in tb) acc += v * v; nfr += tb.Length;
+ float o = ge.DeviceGetParam(tt, td, POut); lo = Math.Min(lo, o); hi = Math.Max(hi, o);
+ }
+ ge.StopTransport();
+ float mapRms = (float)Math.Sqrt(acc / nfr);
+ Check(lo < 0.05f && hi > 0.95f, $"Map drives Pattern Out through the steps ({lo:0.00}..{hi:0.00})");
+ Check(mapRms > toneOpen * 0.9f, $"Map leaves the audio alone ({mapRms / toneOpen:0.00})");
+
+ // Steps automate like any param and clone with the track.
+ int stLane = ge.AddAutomationLane(tt, AutomationTarget.DeviceParam, td, PStep1 + 3);
+ Check(stLane >= 0, "add a Shutter Step 4 automation lane");
+ ge.SetAutomationPoints(tt, stLane, new[] { new AutomationPoint(0.0, 0.75f), new AutomationPoint(8.0, 0.75f) });
+ ge.Seek(1.0); ge.Play(); ge.RenderOffline(tb, 1024); ge.StopTransport();
+ Check(Math.Abs(ge.DeviceGetParam(tt, td, PStep1 + 3) - 0.75f) < 0.01f, $"automation drives Shutter Step 4 ({ge.DeviceGetParam(tt, td, PStep1 + 3):F2})");
+ ge.RemoveAutomationLane(tt, stLane);
+ int ttD = ge.DuplicateTrack(tt); int tdD = ge.TrackDeviceCount(ttD) - 1;
+ Check(ttD > 0 && ge.DeviceGetParam(ttD, tdD, PTarget) > 0.99f && Math.Abs(ge.DeviceGetParam(ttD, tdD, PStep1 + 2) - 1f) < 1e-3
+ && ge.DeviceGetParam(ttD, tdD, PStep1 + 1) < 1e-3, "duplicate track clones the Shutter pattern");
+ ge.RemoveTrack(ttD);
+ ge.DeviceSetParam(tt, td, PTarget, 0f);
+ ge.DeviceSetParam(tt, td, SLook, 0.5f);
+ }
ge.DeviceSetParam(gt, gd, SThreshold, 0.457f);
// Clone: duplicating the track carries the params, the appended ones too.
@@ -5345,7 +5404,9 @@ Console.WriteLine("-- Nota Shutter --");
for (int k = 0; k < ge.DeviceParamCount(gt, gd); k++) names.Add(ge.DeviceParamName(gt, gd, k));
var cat = new FactoryPresetCatalog();
var mine = cat.All().Where(p => !p.IsInstrument && !p.IsMidiEffect && p.BuiltinKind == 19).ToList();
- Check(mine.Count >= 25, $"Nota Shutter ships ≥ 25 factory presets ({mine.Count})");
+ Check(mine.Count >= 40, $"Nota Shutter ships ≥ 40 factory presets ({mine.Count})");
+ Check(mine.Count(p => p.Id.StartsWith("shutter/") && cat.Document(p.Id)!.NamedParams!.ContainsKey("Pattern Target")) == 15,
+ "Nota Shutter ships 15 pattern presets");
var bad = mine.SelectMany(p => cat.Document(p.Id)!.NamedParams!.Keys.Where(k => !names.Contains(k)).Select(k => $"{p.DisplayName}:{k}")).ToList();
Check(bad.Count == 0, $"every Shutter preset param name exists{(bad.Count > 0 ? " — bad: " + string.Join(", ", bad) : "")}");
int pf = 0;
@@ -5363,6 +5424,11 @@ Console.WriteLine("-- Nota Shutter --");
cat.ApplyInPlace(ge, "shutter/Init", gt, gd);
Check(Math.Abs(ge.DeviceGetParam(gt, gd, SShape) - 0.5f) < 1e-4 && ge.DeviceGetParam(gt, gd, SPeakHold) < 0.5f && ge.DeviceGetParam(gt, gd, SFloor) < 0.001f,
"Init preset resets the leftovers to the defaults");
+ cat.ApplyInPlace(ge, "shutter/Slow Pad Gate", gt, gd);
+ Check(Math.Abs(ge.DeviceGetParam(gt, gd, 16) - 0.5f) < 1e-4 && ge.DeviceGetParam(gt, gd, 22) < 0.01f && ge.DeviceGetParam(gt, gd, 17) > 0.99f
+ && Math.Abs(ge.DeviceGetParam(gt, gd, 30) - 0.75f) < 1e-4, "Slow Pad Gate preset: Volume pattern, 8 steps, 4 bars");
+ cat.ApplyInPlace(ge, "shutter/Init", gt, gd);
+ Check(ge.DeviceGetParam(gt, gd, 16) < 0.01f, "Init turns the pattern off again");
}
}
finally