Skip to content

armgit / nota

Public Imported from GitHub
0

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

Add chorus

Egor Khindikaynenc028b5ac1498
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f9cf445..a0f4543e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,29 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Nota Chorus.** A new built-in audio effect (kind 25): modulated delay voices in three modes —
+ **Classic** (two voices, left and right, on 8 ± 5 ms), **Ensemble** (three voices 120° apart on
+ 12 ± 6 ms, the string-machine shimmer) and **Vibrato** (the pitch wobble alone, wet only). The card
+ follows the new mockup on the 700 × 260 frame:
+ - **LFO.** Hz or Sync, the mode, the rate large with its period, a free rate from 0.02 to 8 Hz or a
+ synced note value from 4/1 to 1/16 with triplets (locked to the bar while the transport plays),
+ **Offset** — the right voice behind the left, 0–180° (Ensemble spreads its voices on its own) —
+ and an **HPF** on the wet input (off, or 20 Hz – 2 kHz) that keeps the lows dry and centred.
+ - **Voices.** Every voice over two LFO cycles — its delay (τ) or its detune in cents (ct) — with a
+ running head; drag up or down for Amount, double-click resets it. Under it, the stereo field:
+ where each voice sits and how far it is detuned right now.
+ - **Voice.** Amount, a bipolar Feedback (±90 %), Width (0–200 %: mono to side +6 dB), Warmth (a
+ darker, gently saturated bucket-brigade line) and Mix (locked to wet in Vibrato), with the largest
+ detune and the delay range. The header names the state: 2 or 3 voices, wet only, or resonant
+ past ±60 % feedback. Changing the mode fades instead of jumping the delay.
+ - A status line says what you'll hear — the detune and delay range, or a warning when Mix is at
+ zero or the feedback rings.
+ All eleven controls are device parameters, so automation, MIDI learn, A/B compare and project save
+ work as everywhere else. **34 factory presets**, from Wide Duo and Dark BBD to String Machine,
+ Solina Strings, Tape Wobble and Rotary Throb.
+- **MCP: `read_chorus` and `set_chorus`.** Read what a Nota Chorus is doing (the settings in units,
+ each voice's delay and detune now, the sweep and the largest detune) and set it in units — mode,
+ rate or division, offset degrees, HPF in Hz, amount, feedback, width, warmth and mix in percent.
- **Nota Phaser.** A new built-in audio effect (kind 24): a chain of all-pass stages whose
corner an LFO sweeps, cutting moving notches into the spectrum — from a gentle 4-stage swirl to a
deep, whistling 12-stage sweep. The card follows the new mockup on the 700 × 260 frame:
diff --git a/FEATURES.md b/FEATURES.md
index c0d54c18..a7719e0d 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -496,7 +496,12 @@ and user presets, automation, persistence and cloning.
live all-pass response of L and R with the notches ticked (drag for Center, up / down for
Feedback), the corner of both channels over two cycles, the sweep and null depth, and a status
strip; 35 factory presets; MCP `read_phaser` / `set_phaser`.
-- **Nota Chorus** — modulation (chorus) effect.
+- **Nota Chorus** (25) — modulated delay voices: Classic (2 voices L / R, 8 ± 5 ms), Ensemble
+ (3 voices 120° apart, 12 ± 6 ms) and Vibrato (3 ± 2.5 ms, wet only); sine LFO free (0.02–8 Hz) or
+ synced (4/1 … 1/16 with triplets, locked to the bar), Offset 0–180°, a wet HPF (off / 20 Hz – 2 kHz),
+ Amount, bipolar Feedback ±90 %, Width 0–200 %, Warmth (dark, saturated BBD line), Mix. Every voice's
+ delay or detune over two cycles (drag for Amount), the voices' stereo field, the detune and delay
+ ranges, and a status strip; 34 factory presets; MCP `read_chorus` / `set_chorus`.
- **Forge**, **Valve** and **Vintage** each carry an **OVERSAMPLE** selector
(Off/2×/4×/8×) to suppress aliasing under heavy drive.
diff --git a/src/managed/Nota.App/Controls/ChorusViews.cs b/src/managed/Nota.App/Controls/ChorusViews.cs
new file mode 100644
index 00000000..493e6cb9
--- /dev/null
+++ b/src/managed/Nota.App/Controls/ChorusViews.cs
@@ -0,0 +1,220 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Nota Chorus views (device kind 25) — the pictures on the Chorus card:
+// ChorusVoicesView — each voice over two LFO cycles: its delay τ (0 … 2 × the mode's centre)
+// or its instantaneous detune in cents, with a running head and the dot
+// where each voice is now. Drag up / down for Amount; double-click resets it.
+// ChorusFieldView — the stereo field of the voices: where each one sits (Width) and how far
+// it is detuned right now.
+// ChorusMath mirrors Chorus.h so the picture matches the sound.
+
+using System;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Media;
+
+namespace Nota.App;
+
+internal static class ChorusMath
+{
+ public static readonly string[] Modes = { "Classic", "Ensemble", "Vibrato" };
+ // Per mode: the centre delay and the swing at Amount 100 %, ms (Chorus::kBaseMs / kDepMs).
+ public static readonly double[] BaseMs = { 8, 12, 3 };
+ public static readonly double[] DepMs = { 5, 6, 2.5 };
+ // Sync divisions, slowest → fastest (Chorus::kDivBeats / kDivNames).
+ public static readonly double[] DivBeats = { 16, 8, 4, 2, 1, 2.0 / 3, 0.5, 1.0 / 3, 0.25 };
+ public static readonly string[] DivNames = { "4/1", "2/1", "1/1", "1/2", "1/4", "1/4T", "1/8", "1/8T", "1/16" };
+ public const double FbMax = 0.9;
+
+ public static int ModeIndex(double v) => Math.Clamp((int)Math.Round(v * 2), 0, 2);
+ public static int DivIndex(double v) => Math.Clamp((int)Math.Round(v * (DivBeats.Length - 1)), 0, DivBeats.Length - 1);
+ public static double DivNorm(int i) => (double)Math.Clamp(i, 0, DivBeats.Length - 1) / (DivBeats.Length - 1);
+ public static double FreeHz(double v) => 0.02 * Math.Pow(400, Math.Clamp(v, 0, 1));
+ public static double HpHz(double v) => v < 0.01 ? 0 : 20 * Math.Pow(100, Math.Clamp(v, 0, 1));
+ public static double Fb(double v) => (Math.Clamp(v, 0, 1) - 0.5) * 2 * FbMax;
+ public static double FbNorm(double fb) => Math.Clamp(0.5 + fb / (2 * FbMax), 0, 1);
+ public static double WidthPct(double v) => Math.Clamp(v, 0, 1) * 200;
+ public static double Dep(int mode, double amount) => DepMs[mode] * Math.Clamp(amount, 0, 1);
+
+ /// <summary>The voices of a mode: their LFO phase (cycles) and side (−1 left … +1 right).</summary>
+ public static (string Name, double Phase, double Side)[] Voices(int mode, double offsetCycles) => mode == 1
+ ? new[] { ("V1", 0.0, -1.0), ("V2", 1 / 3.0, 0.0), ("V3", 2 / 3.0, 1.0) }
+ : new[] { ("L", 0.0, -1.0), ("R", offsetCycles, 1.0) };
+
+ public static double Tau(int mode, double dep, double p) => BaseMs[mode] + dep * Math.Sin(2 * Math.PI * p);
+
+ /// <summary>The detune at phase <paramref name="p"/>: the read head's speed is 1 − dτ/dt.</summary>
+ public static double Cents(double dep, double rateHz, double p)
+ {
+ double dt = dep / 1000 * 2 * Math.PI * rateHz * Math.Cos(2 * Math.PI * p);
+ return 1200 * Math.Log2(Math.Max(1 - dt, 0.01));
+ }
+ public static double MaxCents(double dep, double rateHz) => 1200 * Math.Log2(1 + dep / 1000 * 2 * Math.PI * rateHz);
+ /// <summary>The cents axis' half-range: a bit beyond the sweep, never under 4 ct.</summary>
+ public static double CentsRange(double maxCents) => Math.Max(maxCents * 1.3, 4);
+
+ public static IBrush VoiceInk(int i) => i switch { 0 => NotaPalette.Accent, 1 => NotaPalette.TealBright, _ => NotaPalette.RoseBright };
+
+ public static string Ms(double t) => t >= 10 ? NotaNum.F($"{t:0.0}") : NotaNum.F($"{t:0.00}");
+ public static string HzF(double f) => f >= 1000 ? NotaNum.F($"{f / 1000:0.00}k") : NotaNum.F($"{f:0}");
+ public static string Ct(double c) => NotaNum.F($"{c:0.0}");
+}
+
+internal sealed class ChorusVoicesView : Control
+{
+ private int _mode;
+ private double _dep = 2, _off = 0.5, _rate = 0.8, _head, _periodMs = 1250;
+ private bool _on = true, _cents, _drag;
+ private double _y0, _a0;
+
+ /// <summary>Amount (normalized 0..1) at the start of a drag.</summary>
+ public Func<double>? Value { get; set; }
+ public event Action? GestureBegin;
+ public event Action? GestureEnd;
+ public event Action<double>? Changed;
+ public event Action? ResetRequested;
+
+ public ChorusVoicesView() { ClipToBounds = true; MinHeight = 40; Cursor = new Cursor(StandardCursorType.SizeNorthSouth); }
+
+ public void Set(int mode, double dep, double offCycles, double rateHz, double head, double periodMs, bool cents, bool on)
+ {
+ _mode = mode; _dep = dep; _off = offCycles; _rate = rateHz; _head = head; _periodMs = periodMs; _cents = cents; _on = on;
+ InvalidateVisual();
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ base.OnPointerPressed(e);
+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
+ if (e.ClickCount == 2) { ResetRequested?.Invoke(); e.Handled = true; return; }
+ _a0 = Value?.Invoke() ?? 0.4; _y0 = e.GetPosition(this).Y; _drag = true;
+ GestureBegin?.Invoke(); e.Pointer.Capture(this); e.Handled = true;
+ }
+ protected override void OnPointerMoved(PointerEventArgs e)
+ {
+ base.OnPointerMoved(e);
+ if (!_drag) return;
+ bool fine = (e.KeyModifiers & (KeyModifiers.Shift | KeyModifiers.Control | KeyModifiers.Meta)) != 0;
+ double k = fine ? 0.2 : 1;
+ Changed?.Invoke(Math.Clamp(_a0 - (e.GetPosition(this).Y - _y0) * k / Math.Max(60, Bounds.Height), 0, 1));
+ }
+ protected override void OnPointerReleased(PointerReleasedEventArgs e)
+ {
+ base.OnPointerReleased(e);
+ if (!_drag) return;
+ _drag = false; e.Pointer.Capture(null); GestureEnd?.Invoke();
+ }
+
+ public override void Render(DrawingContext ctx)
+ {
+ double w = Bounds.Width, h = Bounds.Height;
+ if (w <= 0 || h <= 0) return;
+ NotaGraph.Window(ctx, new Rect(0, 0, w, h));
+ double baseMs = ChorusMath.BaseMs[_mode];
+ double cR = ChorusMath.CentsRange(ChorusMath.MaxCents(_dep, _rate));
+ double X(double p) => p / 2 * w;
+ double YTau(double t) => h * (186 - t / (baseMs * 2) * 172) / 200;
+ double YCt(double c) => h * (100 - c / cR * 80) / 200;
+ var voices = ChorusMath.Voices(_mode, _off);
+ double Val(int v, double p)
+ {
+ if (_cents) return YCt(_on ? ChorusMath.Cents(_dep, _rate, p + voices[v].Phase) : 0);
+ return YTau(_on ? ChorusMath.Tau(_mode, _dep, p + voices[v].Phase) : baseMs);
+ }
+
+ double gTop = _cents ? YCt(cR * 0.75) : YTau(baseMs * 2), gBot = _cents ? YCt(-cR * 0.75) : YTau(0), gMid = _cents ? YCt(0) : YTau(baseMs);
+ var dash = new Pen(NotaPalette.GridBeat, 1, new DashStyle(new double[] { 2, 3 }, 0));
+ ctx.DrawLine(dash, new Point(X(1), 0), new Point(X(1), h));
+ ctx.DrawLine(NotaGraph.GridPen, new Point(0, gTop), new Point(w, gTop));
+ ctx.DrawLine(NotaGraph.GridPen, new Point(0, gBot), new Point(w, gBot));
+ ctx.DrawLine(new Pen(NotaPalette.BorderDefault, 1, new DashStyle(new double[] { 3, 3 }, 0)), new Point(0, gMid), new Point(w, gMid));
+
+ // The last voice first, so V1 / L reads on top where they cross.
+ for (int v = voices.Length - 1; v >= 0; v--)
+ {
+ var ink = _on ? ChorusMath.VoiceInk(v) : NotaPalette.TextAxis;
+ var geo = new StreamGeometry();
+ using (var g = geo.Open())
+ {
+ int n = Math.Max(64, (int)w);
+ for (int i = 0; i <= n; i++)
+ {
+ double p = 2.0 * i / n;
+ var pt = new Point(X(p), Val(v, p));
+ if (i == 0) g.BeginFigure(pt, false); else g.LineTo(pt);
+ }
+ g.EndFigure(false);
+ }
+ using (ctx.PushOpacity(v == 0 ? 1 : 0.8)) ctx.DrawGeometry(null, NotaGraph.SecondaryPen(ink, v == 0 ? 1.6 : 1.2), geo);
+ }
+
+ void Label(string s, double y)
+ {
+ var ft = NotaGraph.AxisText(s, size: 6);
+ ctx.DrawText(ft, new Point(5, Math.Clamp(y - ft.Height - 1, 1, h - ft.Height - 1)));
+ }
+ Label(_cents ? "+" + ChorusMath.Ct(cR * 0.75) + " ct" : ChorusMath.Ms(baseMs * 2) + " ms", gTop + 10);
+ Label(_cents ? "0 ct" : ChorusMath.Ms(baseMs) + " ms", gMid);
+ Label(_cents ? "−" + ChorusMath.Ct(cR * 0.75) + " ct" : "0 ms", gBot);
+ string span = "2 × " + (_periodMs >= 1000 ? NotaNum.F($"{_periodMs / 1000:0.0} s") : NotaNum.F($"{_periodMs:0} ms"));
+ var br = NotaGraph.AxisText(span, size: 6);
+ ctx.DrawText(br, new Point(w - 5 - br.Width, h - 3 - br.Height));
+
+ if (_on)
+ {
+ double ph = Math.Clamp(_head, 0, 2), hx = X(ph);
+ ctx.DrawLine(new Pen(NotaPalette.TextAxis, 1), new Point(hx, 0), new Point(hx, h));
+ for (int v = voices.Length - 1; v >= 0; v--)
+ ctx.DrawEllipse(ChorusMath.VoiceInk(v), new Pen(NotaGraph.Ground, 2), new Point(hx, Val(v, ph)), 3, 3);
+ }
+ }
+}
+
+internal sealed class ChorusFieldView : Control
+{
+ private int _mode;
+ private double _width = 100, _cR = 4;
+ private double[] _cents = new double[3];
+ private double _off = 0.5;
+ private bool _on = true;
+
+ public ChorusFieldView() { ClipToBounds = true; Height = 34; }
+
+ public void Set(int mode, double offCycles, double widthPct, double[] centsNow, double centsRange, bool on)
+ {
+ _mode = mode; _off = offCycles; _width = widthPct; _cR = centsRange; _on = on;
+ for (int i = 0; i < 3; i++) _cents[i] = i < centsNow.Length ? centsNow[i] : 0;
+ InvalidateVisual();
+ }
+
+ public override void Render(DrawingContext ctx)
+ {
+ double w = Bounds.Width, h = Bounds.Height;
+ if (w <= 0 || h <= 0) return;
+ NotaGraph.Window(ctx, new Rect(0, 0, w, h));
+ var line = new Pen(NotaPalette.GraphBorder, 1);
+ ctx.DrawLine(line, new Point(w * 0.05, h / 2), new Point(w * 0.95, h / 2));
+ ctx.DrawLine(line, new Point(w / 2, 4), new Point(w / 2, h - 4));
+ double spread = Math.Min(_width / 200, 1);
+ ctx.DrawLine(new Pen(NotaPalette.BorderStrong, 1), new Point(w * (0.5 - spread * 0.45), h / 2 - 1), new Point(w * (0.5 + spread * 0.45), h / 2 - 1));
+
+ var l = NotaGraph.AxisText("L", size: 7);
+ ctx.DrawText(l, new Point(5, h / 2 - l.Height / 2 + 5));
+ var r = NotaGraph.AxisText("R", size: 7);
+ ctx.DrawText(r, new Point(w - 5 - r.Width, h / 2 - r.Height / 2 + 5));
+ ctx.DrawText(NotaGraph.AxisText("STEREO · DETUNE", size: 6), new Point(14, 2));
+ string wt = NotaNum.F($"width {_width:0} %") + (_width > 100.5 ? NotaNum.F($" · side +{20 * Math.Log10(_width / 100):0.0} dB") : "");
+ var wtt = NotaGraph.AxisText(wt, size: 6);
+ ctx.DrawText(wtt, new Point(w - 14 - wtt.Width, 2));
+
+ var voices = ChorusMath.Voices(_mode, _off);
+ for (int v = voices.Length - 1; v >= 0; v--)
+ {
+ double x = w * (0.5 + voices[v].Side * spread * 0.45);
+ double y = h * (0.5 - (_on ? _cents[v] : 0) / _cR * 0.38);
+ ctx.DrawEllipse(_on ? ChorusMath.VoiceInk(v) : NotaPalette.TextAxis, null, new Point(x, y), 3, 3);
+ }
+ }
+}
diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ChorusDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ChorusDeviceBody.cs
new file mode 100644
index 00000000..020e1187
--- /dev/null
+++ b/src/managed/Nota.App/DeviceCards/Bodies/ChorusDeviceBody.cs
@@ -0,0 +1,383 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Detail · Devices — built-in Nota Chorus body (modulated delay voices, device kind 25), a build
+// of the "Nota Chorus" mockup (700 × 260) in the Flanger / Phaser language: an LFO column (Hz or
+// Sync, the mode — Classic / Ensemble / Vibrato — the rate as a big readout with its period, Rate,
+// the Offset between the channels and the HPF on the wet input), a centre panel with every voice
+// over two cycles — its delay τ or its detune in cents (τ / ct) — with a running head (drag up /
+// down for Amount) and, under it, the voices' stereo field, and a VOICE column (Amount, the bipolar
+// Feedback, Width, Warmth, Mix, and the detune and delay ranges) with the state it is in, and a
+// status strip. In Ensemble the Offset is fixed (3 × 120°), in Vibrato the Mix (wet only). The
+// live LFO phase comes from the engine (Chorus.h scopeRead); the curves are drawn from the same
+// formulas the DSP runs. Every control is a device param (normalized 0..1), so automation / MIDI
+// learn / presets / A-B / persistence come for free. FullBleed — the shared shell draws the header
+// (name · preset · badge · bypass).
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Nota.Application;
+using static Nota.App.DeviceCardKit;
+
+namespace Nota.App;
+
+internal sealed class ChorusDeviceBody : IDeviceBody
+{
+ // ── Parameter indices (must match Chorus.h) ──────────────────────────────
+ private const int Rate = 0, Mode = 1, Sync = 2, Division = 3, Offset = 4, Hpf = 5, Amount = 6, Feedback = 7, Spread = 8, Warmth = 9, Mix = 10;
+ // Scope layout (Chorus::S_* / kTele).
+ private const int S_Cents1 = 6, S_WinPhase = 9, S_SampleRate = 14, kTele = 32;
+
+ public double Width => 700;
+ public bool FullBleed => true;
+ public string? Subtitle => "MODULATION"; // the processing type, shown as the header badge
+
+ public Control Build(DeviceCardContext ctx, int index)
+ {
+ var engine = ctx.Engine;
+ int track = ctx.TrackId, di = index;
+ float P(int p) => engine.DeviceGetParam(track, di, p);
+ void 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, double v) => engine.DeviceSetParam(track, di, p, (float)Math.Clamp(v, 0, 1));
+ // A discrete edit (a click) is one automation gesture, so it records while the transport does.
+ void SetP(int p, double v) { Begin(p); Raw(p, v); End(p); }
+ void Reset(int p) { Begin(p); Raw(p, engine.DeviceParamDefault(track, di, p)); End(p); }
+ void Learn(Control c, int p) => MidiLearn.Bind(c, MidiTarget.DeviceParam(track, di, p), engine.DeviceParamName(track, di, p));
+
+ var readouts = new List<Action>();
+ void RefreshAll() { for (int i = 0; i < readouts.Count; i++) readouts[i](); }
+ var scope = new float[kTele];
+ int scN = 0;
+ double Sc(int i, double dflt = 0) => scN > i ? scope[i] : dflt;
+
+ // ---- state and units (Chorus.h) --------------------------------------------------
+ bool On() => !engine.DeviceBypassed(track, di);
+ bool Synced() => P(Sync) >= 0.5f;
+ int ModeI() => ChorusMath.ModeIndex(P(Mode));
+ bool Vib() => ModeI() == 2;
+ bool Ens() => ModeI() == 1;
+ int DivI() => ChorusMath.DivIndex(P(Division));
+ double Bpm() => engine.Bpm > 0 ? engine.Bpm : 120;
+ double RateHz() => Synced() ? Bpm() / 60 / ChorusMath.DivBeats[DivI()] : ChorusMath.FreeHz(P(Rate));
+ double PeriodMs() => 1000 / Math.Max(1e-3, RateHz());
+ double Dep() => ChorusMath.Dep(ModeI(), P(Amount));
+ double TauMin() => ChorusMath.BaseMs[ModeI()] - Dep();
+ double TauMax() => ChorusMath.BaseMs[ModeI()] + Dep();
+ double MaxCt() => ChorusMath.MaxCents(Dep(), RateHz());
+ double Fb() => ChorusMath.Fb(P(Feedback));
+ double WidthPct() => ChorusMath.WidthPct(P(Spread));
+ string State()
+ {
+ if (!On()) return "bypass";
+ if (Vib()) return "wet only";
+ if (Math.Abs(Fb()) >= 0.6) return "resonant";
+ return Ens() ? "3 voices" : "2 voices";
+ }
+
+ static string HzF(double hz) => hz >= 10 ? NotaNum.F($"{hz:0.0}") : NotaNum.F($"{hz:0.00}");
+ static string PctF(double v) => NotaNum.F($"{v * 100:0} %");
+ static string FbF(double fb) => (fb > 0.005 ? "+" : fb < -0.005 ? "−" : "") + NotaNum.F($"{Math.Abs(fb) * 100:0} %");
+ static string PeriodF(double ms) => ms >= 1000 ? NotaNum.F($"{ms / 1000:0.00} s") : NotaNum.F($"{ms:0} ms");
+
+ // ---- small builders ---------------------------------------------------------
+ static TextBlock Caps(string t, IBrush? c = null) => new()
+ { Text = t, FontSize = 7, FontWeight = FontWeight.Bold, Foreground = c ?? TextTertiary, LetterSpacing = 0.7, VerticalAlignment = VerticalAlignment.Center };
+ static TextBlock Mono(string t, double fs, IBrush c)
+ { var tb = new TextBlock { Text = t, FontSize = fs, Foreground = c, VerticalAlignment = VerticalAlignment.Center }; tb.BindResource(TextBlock.FontFamilyProperty, "Font.Mono"); return tb; }
+ static T Docked<T>(T c, Dock d) where T : Control { DockPanel.SetDock(c, d); return c; }
+ static T Col<T>(T c, int col) where T : Control { Grid.SetColumn(c, col); return c; }
+ static T GRow<T>(T c, int row) where T : Control { Grid.SetRow(c, row); return c; }
+
+ // Slider row: caps label · track · mono value. `locked` greys it out and stops the hand
+ // (Offset in Ensemble, Mix in Vibrato); `ink` recolours the fill (Warmth in rose).
+ Grid Slider(string label, int p, Func<double, string> fmt, string tip, double labelW, double valueW,
+ bool modulation = false, bool bipolar = false, Func<double, double>? snap = null, Func<bool>? locked = null, IBrush? ink = null)
+ {
+ var bar = DeviceCardKit.SliderRow("", () => P(p), v => { Raw(p, snap is null ? v : snap(v)); RefreshAll(); }, () => fmt(P(p)), out var sync,
+ begin: () => Begin(p), end: () => End(p), reset: () => Reset(p), valueWidth: valueW, modulation: modulation, bipolar: bipolar,
+ dim: locked);
+ if (ink is not null) foreach (var t in bar.Children.OfType<SliderTrack>()) t.Ink = ink;
+ var lbl = Caps(label);
+ readouts.Add(sync);
+ if (locked is not null)
+ readouts.Add(() => { bool l = locked(); bar.IsHitTestVisible = !l; lbl.Foreground = l ? TextDisabled : TextTertiary; });
+ Learn(bar, p);
+ ToolTip.SetTip(bar, tip);
+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions($"{labelW},*"), VerticalAlignment = VerticalAlignment.Center };
+ g.Children.Add(lbl);
+ g.Children.Add(Col(bar, 1));
+ return g;
+ }
+
+ Border Island(Control head, Control body, double width = double.NaN)
+ {
+ var headBar = new Border
+ {
+ Height = 20, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(8, 0, 3, 0), Child = head,
+ };
+ return new Border
+ {
+ Width = width, Background = Card2, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Tile,
+ ClipToBounds = true, Child = new DockPanel { LastChildFill = true, Children = { Docked(headBar, Dock.Top), body } },
+ };
+ }
+ static Grid HeadRow(Control left, Control right)
+ {
+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 6, VerticalAlignment = VerticalAlignment.Center };
+ g.Children.Add(left); g.Children.Add(Col(right, 1));
+ return g;
+ }
+ // A legend sample: a drawn 8px stroke and its word (never a typed dash).
+ static Control LegendItem(TextBlock word, Border stroke) => new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 3, VerticalAlignment = VerticalAlignment.Center,
+ Children = { stroke, word },
+ };
+
+ // ======================================================================
+ // LEFT — LFO: Hz / Sync · mode · the rate · Rate · Offset · HPF
+ // ======================================================================
+ var syncSeg = Segments(new[] { "Hz", "Sync" }, () => Synced() ? 1 : 0, i => { SetP(Sync, i); RefreshAll(); }, out var syncSync, fill: true, padX: 0);
+ syncSeg.Width = 76;
+ readouts.Add(syncSync);
+ Learn(syncSeg, Sync);
+ ToolTip.SetTip(syncSeg, "Hz runs the LFO free; Sync takes its rate from the tempo and locks it to the bar while the transport plays");
+
+ var modeSeg = Segments(ChorusMath.Modes, ModeI, i => { SetP(Mode, i / 2.0); RefreshAll(); }, out var modeSync, fill: true, padX: 0);
+ readouts.Add(modeSync);
+ Learn(modeSeg, Mode);
+ ToolTip.SetTip(modeSeg, "Classic — two voices, left and right; Ensemble — three voices 120° apart, a string-machine shimmer; Vibrato — the pitch wobble alone, no dry signal");
+
+ var big = Mono("", 26, AccentBright); big.FontWeight = FontWeight.Bold; big.LineHeight = 28;
+ var bigSub = new TextBlock { FontSize = 8, Foreground = TextSecondary };
+ var period = Mono("", 7, TextTertiary); period.Margin = new Thickness(0, 2, 0, 0);
+ readouts.Add(() =>
+ {
+ double hz = RateHz();
+ if (Synced())
+ {
+ big.Text = ChorusMath.DivNames[DivI()];
+ bigSub.Text = NotaNum.F($"note · {Bpm():0.##} BPM");
+ period.Text = HzF(hz) + " Hz · period " + PeriodF(PeriodMs());
+ }
+ else
+ {
+ big.Text = HzF(hz);
+ bigSub.Text = "Hz · free";
+ period.Text = "period " + PeriodF(PeriodMs());
+ }
+ big.Foreground = On() ? AccentBright : NotaPalette.TextAxis;
+ });
+ var bigBlock = new StackPanel { Spacing = 1, VerticalAlignment = VerticalAlignment.Center, Children = { big, bigSub, period } };
+ ToolTip.SetTip(bigBlock, "The LFO rate: in Hz, or the note value it takes from the tempo");
+
+ var rateRow = Slider("RATE", Rate, v => HzF(ChorusMath.FreeHz(v)) + " Hz", "Rate — the free LFO rate, 0.02 … 8 Hz", 38, 46);
+ var divRow = Slider("RATE", Division, v => ChorusMath.DivNames[ChorusMath.DivIndex(v)],
+ "Rate — the note value of one LFO cycle, 4/1 … 1/16 with triplet (T) values", 38, 46,
+ snap: v => ChorusMath.DivNorm(ChorusMath.DivIndex(v)));
+ readouts.Add(() => { rateRow.IsVisible = !Synced(); divRow.IsVisible = Synced(); });
+ var offsetRow = Slider("OFFSET", Offset, v => Ens() ? "3 × 120°" : NotaNum.F($"{v * 180:0}°"),
+ "Offset — the right voice's LFO behind the left: 0° moves both together, 180° opposite. Ensemble spreads its three voices 120° apart on its own",
+ 38, 46, modulation: true, snap: v => Math.Round(v * 180) / 180, locked: Ens);
+ var hpfRow = Slider("HPF", Hpf, v => ChorusMath.HpHz(v) <= 0 ? "off" : ChorusMath.HzF(ChorusMath.HpHz(v)) + " Hz",
+ "HPF — a high-pass on the wet input (20 Hz … 2 kHz), so the lows stay dry and centred; far left is off", 38, 46,
+ modulation: true, snap: v => Math.Round(v / 0.005) * 0.005);
+
+ var leftBody = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto,Auto,Auto"), RowSpacing = 6, Margin = new Thickness(8, 6) };
+ leftBody.Children.Add(modeSeg);
+ leftBody.Children.Add(GRow(bigBlock, 1));
+ leftBody.Children.Add(GRow(new Panel { Children = { rateRow, divRow } }, 2));
+ leftBody.Children.Add(GRow(offsetRow, 3));
+ leftBody.Children.Add(GRow(hpfRow, 4));
+ var left = Island(HeadRow(Caps("LFO"), syncSeg), leftBody, 176);
+ DockPanel.SetDock(left, Dock.Left);
+
+ // ======================================================================
+ // CENTRE — VOICES over two cycles (τ / ct), and the stereo field
+ // ======================================================================
+ // τ or ct: a view choice, not a param. Until the hand picks one, Vibrato shows cents.
+ bool? viewCents = null;
+ bool Cents() => viewCents ?? Vib();
+
+ var legendWords = new TextBlock[3];
+ var legendStrokes = new Border[3];
+ var legendItems = new Control[3];
+ var legend = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center };
+ for (int i = 0; i < 3; i++)
+ {
+ legendWords[i] = Mono("", 7, ChorusMath.VoiceInk(i));
+ legendStrokes[i] = new Border { Width = 8, Height = 1.5, Background = ChorusMath.VoiceInk(i), VerticalAlignment = VerticalAlignment.Center };
+ legendItems[i] = LegendItem(legendWords[i], legendStrokes[i]);
+ legend.Children.Add(legendItems[i]);
+ }
+ readouts.Add(() =>
+ {
+ var vs = ChorusMath.Voices(ModeI(), 0);
+ for (int i = 0; i < 3; i++)
+ {
+ legendItems[i].IsVisible = i < vs.Length;
+ if (i < vs.Length) legendWords[i].Text = vs[i].Name;
+ }
+ });
+ var plotRead = Mono("", 7, TextTertiary);
+ plotRead.Margin = new Thickness(0, 0, 5, 0);
+ readouts.Add(() => plotRead.Text = Cents()
+ ? "pitch ±" + ChorusMath.Ct(MaxCt()) + " ct"
+ : "τ " + ChorusMath.Ms(TauMin()) + "–" + ChorusMath.Ms(TauMax()) + " ms");
+ var viewSeg = Segments(new[] { "τ", "ct" }, () => Cents() ? 1 : 0, i => { viewCents = i == 1; RefreshAll(); }, out var viewSync, fill: true, padX: 0);
+ viewSeg.Width = 52;
+ readouts.Add(viewSync);
+ ToolTip.SetTip(viewSeg, "τ draws each voice's delay; ct its detune — how far the moving delay bends the pitch");
+ var headRight = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, Children = { plotRead, viewSeg } };
+ var centreHead = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*,Auto"), VerticalAlignment = VerticalAlignment.Center };
+ centreHead.Children.Add(Caps("VOICES"));
+ centreHead.Children.Add(Col(legend, 1));
+ centreHead.Children.Add(Col(headRight, 3));
+
+ var plot = new ChorusVoicesView { Value = () => P(Amount) };
+ plot.GestureBegin += () => Begin(Amount);
+ plot.GestureEnd += () => End(Amount);
+ plot.Changed += a => { Raw(Amount, Math.Round(a * 100) / 100); RefreshAll(); };
+ plot.ResetRequested += () => { Reset(Amount); RefreshAll(); };
+ Learn(plot, Amount);
+ ToolTip.SetTip(plot, "Each voice over two LFO cycles — its delay (τ) or its detune (ct) — and where it is now. Drag up / down for Amount; double-click resets it.");
+
+ var field = new ChorusFieldView { Margin = new Thickness(0, 4, 0, 0) };
+ ToolTip.SetTip(field, "Where the voices sit in the stereo field (Width) and how far each is detuned right now");
+ var centreBody = new DockPanel { LastChildFill = true, Margin = new Thickness(5), Children = { Docked(field, Dock.Bottom), plot } };
+ var centre = Island(centreHead, centreBody);
+ centre.Margin = new Thickness(5, 0);
+
+ // ======================================================================
+ // RIGHT — VOICE: Amount · Feedback · Width · Warmth · Mix · detune / delay readouts
+ // ======================================================================
+ var stateWord = Mono("", 7, TextSecondary);
+ stateWord.Margin = new Thickness(0, 0, 5, 0);
+ readouts.Add(() =>
+ {
+ string s = State();
+ stateWord.Text = s;
+ stateWord.Foreground = s == "resonant" ? AccentBright : s == "bypass" ? NotaPalette.TextAxis : TextSecondary;
+ });
+ ToolTip.SetTip(stateWord, "How many voices sing, or that the feedback makes it ring (past 60 %), or that Vibrato plays wet only");
+
+ const double LW = 46, VW = 36;
+ var amountRow = Slider("AMOUNT", Amount, v => PctF(v), "Amount — how far the LFO swings each voice's delay: more is wider detune", LW, VW,
+ snap: v => Math.Round(v * 100) / 100);
+ var fbRow = Slider("FEEDBACK", Feedback, v => FbF(ChorusMath.Fb(v)),
+ "Feedback — the voices fed back into the line, ±90 %: a little thickens, past 60 % it rings metallic like a flanger", LW, VW,
+ modulation: true, bipolar: true, snap: v => ChorusMath.FbNorm(Math.Round(ChorusMath.Fb(v) * 100) / 100));
+ var widthRow = Slider("WIDTH", Spread, v => NotaNum.F($"{ChorusMath.WidthPct(v):0} %"),
+ "Width — the voices' stereo spread: 0 % mono, 100 % as they are, 200 % lifts the side by +6 dB", LW, VW,
+ modulation: true, snap: v => Math.Round(v * 200) / 200);
+ var warmRow = Slider("WARMTH", Warmth, v => PctF(v),
+ "Warmth — a bucket-brigade flavour on the delay line: darker (low-pass down to 2.5 kHz) and gently saturated", LW, VW,
+ snap: v => Math.Round(v * 100) / 100, ink: NotaPalette.RoseBright);
+ var mixRow = Slider("MIX", Mix, v => Vib() ? "wet" : PctF(v), "Mix — 0 % dry, 50 % dry and wet equal, 100 % the voices alone. Vibrato is always wet", LW, VW,
+ snap: v => Math.Round(v * 100) / 100, locked: Vib);
+
+ Control ReadRow(string label, FlangerBar bar, TextBlock value, string tip)
+ {
+ value.TextAlignment = TextAlignment.Right; value.Width = 44;
+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions($"{LW},*,Auto") };
+ g.Children.Add(Caps(label));
+ g.Children.Add(Col(bar, 1));
+ g.Children.Add(Col(new Border { Margin = new Thickness(6, 0, 0, 0), Child = value }, 2));
+ ToolTip.SetTip(g, tip);
+ return g;
+ }
+ var detuneBar = new FlangerBar { Ink = NotaPalette.Accent, VerticalAlignment = VerticalAlignment.Center };
+ var detuneVal = Mono("", 8, TextPrimary);
+ var delayBar = new FlangerBar { Ink = NotaPalette.BorderStrong, VerticalAlignment = VerticalAlignment.Center };
+ var delayVal = Mono("", 8, TextPrimary);
+ var reads = new Border
+ {
+ BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(0, 1, 0, 0), Padding = new Thickness(0, 5, 0, 0),
+ Child = new StackPanel
+ {
+ Spacing = 4, Children =
+ {
+ ReadRow("DETUNE", detuneBar, detuneVal, "The largest detune the sweep reaches, ± cents (0 … 60 on the bar)"),
+ ReadRow("DELAY", delayBar, delayVal, "The range each voice's delay sweeps, ms (0 … 24 on the bar)"),
+ },
+ },
+ };
+
+ var rightBody = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto,*,Auto,*,Auto,*,Auto,*,Auto"), Margin = new Thickness(8, 6) };
+ rightBody.Children.Add(amountRow);
+ rightBody.Children.Add(GRow(fbRow, 2));
+ rightBody.Children.Add(GRow(widthRow, 4));
+ rightBody.Children.Add(GRow(warmRow, 6));
+ rightBody.Children.Add(GRow(mixRow, 8));
+ rightBody.Children.Add(GRow(reads, 10));
+ var right = Island(HeadRow(Caps("VOICE"), stateWord), rightBody, 176);
+ DockPanel.SetDock(right, Dock.Right);
+
+ // ======================================================================
+ // Status strip
+ // ======================================================================
+ var statusLeft = new TextBlock { FontSize = 8, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };
+ var statusRight = Mono("", 8, TextSecondary);
+ readouts.Add(() =>
+ {
+ double fb = Fb(), afb = Math.Abs(fb);
+ bool warn = false;
+ string foot;
+ if (!On()) foot = "Chorus bypassed: the signal passes unchanged";
+ else if (!Vib() && P(Mix) < 0.01f) { foot = "Mix at zero: only the dry signal is heard"; warn = true; }
+ else if (P(Amount) < 0.01f) foot = "Amount at zero: the voices stand still, a static " + ChorusMath.Ms(ChorusMath.BaseMs[ModeI()]) + " ms delay remains";
+ else if (afb >= 0.6) { foot = "Feedback " + FbF(fb) + ": a metallic ring creeps in, like a flanger"; warn = true; }
+ else if (Vib()) foot = "Vibrato: no dry signal, the pitch swings ±" + ChorusMath.Ct(MaxCt()) + " ct at " + HzF(RateHz()) + " Hz";
+ else if (WidthPct() < 1) foot = "Width 0 %: the voices fold to mono, no space";
+ else
+ foot = "Detune up to ±" + ChorusMath.Ct(MaxCt()) + " ct · τ " + ChorusMath.Ms(TauMin()) + "–" + ChorusMath.Ms(TauMax())
+ + " ms · " + (Ens() ? "3" : "2") + " voices";
+ statusLeft.Text = foot;
+ statusLeft.Foreground = warn ? AccentBright : TextSecondary;
+ double sr = Sc(S_SampleRate);
+ statusRight.Text = (sr > 0 ? NotaNum.F($"{sr / 1000:0.#} kHz · ") : "") + NotaNum.F($"{Bpm():0.##} BPM · ")
+ + (P(Warmth) > 0.01f ? NotaNum.F($"warm {P(Warmth) * 100:0} %") : "clean");
+ });
+ var statusGrid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8 };
+ statusGrid.Children.Add(statusLeft);
+ statusGrid.Children.Add(Col(statusRight, 1));
+ var status = new Border { Height = 18, Background = Sunken, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 1, 0, 0), Padding = new Thickness(8, 0), Child = statusGrid };
+ DockPanel.SetDock(status, Dock.Bottom);
+
+ // ---- assemble ---------------------------------------------------------------
+ var bodyRow = new DockPanel { LastChildFill = true, Margin = new Thickness(5), Children = { left, right, centre } };
+ var root = new DockPanel { LastChildFill = true, Background = NotaPalette.SurfaceInset, Children = { status, bodyRow } };
+
+ var centsNow = new double[3];
+ void Refresh()
+ {
+ scN = engine.DeviceScope(track, di, scope, kTele);
+ bool on = On();
+ int mode = ModeI();
+ double dep = Dep(), rate = RateHz(), mc = MaxCt(), off = P(Offset) * 0.5;
+ double head = Sc(S_WinPhase);
+ var vs = ChorusMath.Voices(mode, off);
+ // The detune now: the engine's, or the formula at the head before the first block.
+ for (int i = 0; i < 3; i++)
+ centsNow[i] = i >= vs.Length ? 0 : scN > S_Cents1 + i && scope[S_Cents1 + i] != 0 ? scope[S_Cents1 + i]
+ : ChorusMath.Cents(dep, rate, head + vs[i].Phase);
+ plot.Set(mode, dep, off, rate, head, PeriodMs(), Cents(), on);
+ field.Set(mode, off, WidthPct(), centsNow, ChorusMath.CentsRange(mc), on);
+
+ detuneBar.Set(0, on ? Math.Clamp(mc / 60, 0, 1) : 0);
+ detuneVal.Text = on ? "±" + ChorusMath.Ct(mc) + " ct" : "—";
+ delayBar.Set(on ? TauMin() / 24 : 0, on ? (TauMax() - TauMin()) / 24 : 0);
+ delayVal.Text = on ? ChorusMath.Ms(TauMin()) + "–" + ChorusMath.Ms(TauMax()) : "—";
+ RefreshAll();
+ }
+ ctx.AddDeviceRefresher(Refresh);
+ Refresh();
+ return root;
+ }
+}
diff --git a/src/managed/Nota.App/DeviceCards/DeviceCardFactory.cs b/src/managed/Nota.App/DeviceCards/DeviceCardFactory.cs
index 96b3586d..9962fc7b 100644
--- a/src/managed/Nota.App/DeviceCards/DeviceCardFactory.cs
+++ b/src/managed/Nota.App/DeviceCards/DeviceCardFactory.cs
@@ -43,6 +43,7 @@ internal sealed class DeviceCardFactory
[22] = new LensDeviceBody(),
[23] = new FlangerDeviceBody(),
[24] = new PhaserDeviceBody(),
+ [25] = new ChorusDeviceBody(),
};
/// <summary>Resolve the body for a device: -1 = hosted plugin, a mapped built-in kind,
diff --git a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
index 81005847..132f6af4 100644
--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
@@ -1740,6 +1740,52 @@ public sealed class FactoryPresetCatalog : IFactoryPresets
Ph("Bass Motion", 4, FSine, 250, 0.50f, 0.30f, 0.35f, 0, hz: 0.20f);
Ph("Vocal Air", 2, FSine, 2500, 0.50f, 0.20f, 0.30f, 120, hz: 0.25f);
+ // ---- Nota Chorus (kind 25) — modulated delay voices. Written in units through Ch(): mode
+ // (CClassic / CEnsemble / CVibrato), Amount 0..1, Feedback −0.9..+0.9, Width % 0..200, Mix 0..1
+ // (ignored in Vibrato, which is wet only), Offset 0..180°, HPF Hz (0 = off, else 20..2000),
+ // Warmth 0..1, and either a free rate in Hz (0.02..8) or a Sync division
+ // (4/1 2/1 1/1 1/2 1/4 1/4T 1/8 1/8T 1/16).
+ // Classic
+ Ch("Wide Duo", CClassic, 0.40f, 0.00f, 100, 0.50f, 180, hz: 0.80f);
+ Ch("Subtle Thicken", CClassic, 0.20f, 0.00f, 100, 0.35f, 90, hz: 0.50f);
+ Ch("Lush Chorus", CClassic, 0.60f, 0.10f, 130, 0.50f, 180, hz: 0.60f, warmth: 0.15f);
+ Ch("Dimension Wide", CClassic, 0.30f, 0.00f, 150, 0.45f, 180, hz: 0.35f, hpHz: 150);
+ Ch("Dark BBD", CClassic, 0.55f, 0.15f, 110, 0.50f, 180, hz: 0.60f, warmth: 0.80f);
+ Ch("Slow Drift", CClassic, 0.70f, 0.00f, 120, 0.45f, 180, hz: 0.12f);
+ Ch("Mono Chorus", CClassic, 0.45f, 0.00f, 0, 0.50f, 0, hz: 0.80f);
+ Ch("Quadrature", CClassic, 0.45f, 0.00f, 100, 0.50f, 90, hz: 0.50f);
+ Ch("Fast Shimmer", CClassic, 0.25f, 0.05f, 120, 0.40f, 180, hz: 3.00f);
+ // Ensemble
+ Ch("String Machine", CEnsemble, 0.65f, 0.25f, 160, 0.60f, 180, div: "2/1", hpHz: 100, warmth: 0.35f);
+ Ch("Solina Strings", CEnsemble, 0.75f, 0.00f, 140, 0.65f, 180, hz: 0.60f, warmth: 0.30f);
+ Ch("Tri-Chorus", CEnsemble, 0.50f, 0.00f, 120, 0.50f, 180, hz: 0.90f);
+ Ch("Wide Ensemble", CEnsemble, 0.55f, 0.10f, 200, 0.55f, 180, hz: 0.40f, hpHz: 80);
+ Ch("Choir Pad", CEnsemble, 0.70f, 0.15f, 150, 0.60f, 180, hz: 0.25f, warmth: 0.40f);
+ Ch("Organ Ensemble", CEnsemble, 0.40f, 0.00f, 110, 0.50f, 180, hz: 1.20f, hpHz: 200);
+ // Vibrato
+ Ch("Tape Wobble", CVibrato, 0.60f, 0.00f, 40, 1.00f, 0, hz: 5.50f, warmth: 0.50f);
+ Ch("Gentle Vibrato", CVibrato, 0.35f, 0.00f, 60, 1.00f, 0, hz: 4.50f);
+ Ch("Stereo Vibrato", CVibrato, 0.45f, 0.00f, 150, 1.00f, 180, hz: 5.00f);
+ Ch("Rotary Throb", CVibrato, 0.50f, 0.00f, 180, 1.00f, 180, hz: 6.50f, warmth: 0.20f);
+ Ch("Warped Record", CVibrato, 0.80f, 0.00f, 30, 1.00f, 0, hz: 0.60f, warmth: 0.60f);
+ Ch("Seasick", CVibrato, 1.00f, 0.00f, 100, 1.00f, 90, hz: 0.35f);
+ // Feedback
+ Ch("Metallic Chorus", CClassic, 0.40f, 0.70f, 100, 0.50f, 180, hz: 0.40f);
+ Ch("Jet Chorus", CClassic, 0.80f, 0.60f, 120, 0.50f, 180, hz: 0.15f);
+ Ch("Negative Space", CClassic, 0.50f, -0.50f, 130, 0.50f, 180, hz: 0.30f);
+ // Synced
+ Ch("Quarter Pulse", CClassic, 0.50f, 0.10f, 120, 0.50f, 180, div: "1/4");
+ Ch("Bar Swell", CEnsemble, 0.60f, 0.10f, 140, 0.55f, 180, div: "1/1");
+ Ch("Triplet Shiver", CClassic, 0.30f, 0.00f, 120, 0.45f, 180, div: "1/8T");
+ Ch("Four-Bar Drift", CClassic, 0.90f, 0.00f, 130, 0.50f, 180, div: "4/1");
+ // Sources
+ Ch("Vocal Double", CClassic, 0.15f, 0.00f, 140, 0.35f, 180, hz: 0.40f, hpHz: 200);
+ Ch("Bass Chorus", CClassic, 0.45f, 0.00f, 110, 0.45f, 180, hz: 0.50f, hpHz: 250);
+ Ch("Electric Piano", CClassic, 0.45f, 0.05f, 130, 0.45f, 120, hz: 0.70f, warmth: 0.25f);
+ Ch("Clean Guitar", CClassic, 0.50f, 0.05f, 120, 0.50f, 180, hz: 1.00f, hpHz: 100);
+ Ch("Synth Pad Wide", CEnsemble, 0.60f, 0.10f, 170, 0.50f, 180, hz: 0.30f, hpHz: 120);
+ Ch("Drum Bus Air", CClassic, 0.15f, 0.00f, 130, 0.25f, 180, hz: 0.30f, hpHz: 400);
+
// ---- Nota Auto Shift (kind 10) — pitch correction, all params normalized 0..1 (unnamed ones
// reset to their defaults). Key round(11v) (0 C, .182 D, .364 E, .455 F, .636 G, .818 A);
// Scale 0 Chromatic/.25 Major/.5 Minor/.75 Penta Maj/1 Penta Min; Custom Scale 1 = the
@@ -2157,6 +2203,23 @@ public sealed class FactoryPresetCatalog : IFactoryPresets
("Stages", st / 4f));
}
+ // Nota Chorus modes and Sync divisions (Chorus::kModeNames / kDivNames), and its presets in units.
+ private const int CClassic = 0, CEnsemble = 1, CVibrato = 2;
+ private static readonly string[] ChDivs = { "4/1", "2/1", "1/1", "1/2", "1/4", "1/4T", "1/8", "1/8T", "1/16" };
+
+ private void Ch(string name, int mode, float amount, float fb, float widthPct, float mix, float offsetDeg, float hz = 0.8f,
+ string? div = null, float hpHz = 0, float warmth = 0)
+ {
+ int d = div is null ? 2 : Array.IndexOf(ChDivs, div);
+ if (d < 0) throw new ArgumentException($"unknown Chorus division {div}");
+ Fx("chorus", 25, name,
+ ("Rate", (float)(Math.Log(Math.Clamp(hz, 0.02f, 8f) / 0.02) / Math.Log(400))),
+ ("Mode", mode / 2f), ("Sync", div is null ? 0f : 1f), ("Division", d / 8f), ("Offset", offsetDeg / 180f),
+ ("HPF", hpHz <= 0 ? 0f : (float)(Math.Log(Math.Clamp(hpHz, 20f, 2000f) / 20.0) / Math.Log(100))),
+ ("Amount", amount), ("Feedback", 0.5f + Math.Clamp(fb, -0.9f, 0.9f) / 1.8f), ("Width", widthPct / 200f),
+ ("Warmth", warmth), ("Mix", mix));
+ }
+
// Nota Forge stage types (the S* Type step, × 1/5).
private const int FTube = 0, FDiode = 1, FTape = 2, FFuzz = 3, FDigital = 4, FFold = 5;
diff --git a/src/managed/Nota.Mcp/Tools/DeviceTools.cs b/src/managed/Nota.Mcp/Tools/DeviceTools.cs
index 0ec34a5a..4d6bfd75 100644
--- a/src/managed/Nota.Mcp/Tools/DeviceTools.cs
+++ b/src/managed/Nota.Mcp/Tools/DeviceTools.cs
@@ -20,7 +20,7 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
(6, "Nota Valve"), (7, "Auto Filter"), (8, "Nota Vintage"), (9, "Nota Orbit"), (10, "Auto Shift"),
(11, "Beat Repeat"), (12, "Crush"), (13, "Dynamic EQ-8"), (14, "Ceiling"), (15, "Strata"),
(16, "Nota EQ-3"), (17, "Forge"), (18, "Nota Level"), (19, "Nota Shutter"), (20, "Nota Chamber"), (21, "Nota Prism"),
- (22, "Nota Lens"), (23, "Nota Flanger"), (24, "Nota Phaser"),
+ (22, "Nota Lens"), (23, "Nota Flanger"), (24, "Nota Phaser"), (25, "Nota Chorus"),
};
public sealed record DeviceKind(int Kind, string Name);
@@ -67,10 +67,10 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
[McpServerTool(Name = "load_device_file"), Description("Load an audio file into a device that takes one — Nota Chamber: a user impulse response (WAV / FLAC / MP3; mono, stereo or 4-channel true stereo), which also selects it. Returns true on success.")]
public Task<bool> LoadDeviceFile(int trackId, int deviceIndex, [Description("Absolute path to the audio file")] string path) => Mutate(() => E.DeviceLoadFile(trackId, deviceIndex, path));
- [McpServerTool(Name = "get_device_text"), Description("Read a device's resource text. Nota Chamber: id 0 = current IR name, 1 = its category, 2 = the loaded user IR's name, 10 = the built-in IR list (name, category, seconds per line; the IR param selects entry round(v × 16), 1.0 = the user IR). Nota Lens: id 0 = the analysis summary, 1 = the third-octave band table, 2 = the scope measurements, 3 = the strongest spectral peaks, 4 = the A/B cursor measurements — or use read_analyzer, which returns all of it parsed. Delay (kind 3): id 0 = a one-line summary of what it is doing now (sync division or free times, ping-pong, feedback, mix, or that it is frozen). Reverb (kind 2): id 0 = a one-line summary (algorithm, RT60, pre-delay, diffusion, mix, early reflections / vintage, or that the tail is frozen). Compressor (kind 1): id 0 = a one-line summary (character, threshold, ratio, knee, attack / release, detector, range, mix, the reduction right now, external key / unlinked / Listen) — or use read_dynamics for the numbers. Auto Filter (kind 7): id 0 = a one-line summary (type, slope, cutoff, Q, what the envelope and LFO drive and by how much, drive, mix, sidechain key), 1 = the live reading (modulated cutoff with its note, resonance, envelope level, LFO value and phase, onsets counted), 2 = a guide to what each 0..1 parameter value means — or use read_filter_motion for the numbers. Nota Vintage (kind 8): id 0 = a one-line summary (character, drive, tone model and shelves, wow / flutter with their rates, noise, crackle, wear, stage, mix, output, oversampling, auto-comp), 1 = the live reading (in / out peaks, THD with the 2nd and 3rd harmonics, asymmetry, wow and flutter in cents, band-limit, hiss level, auto-comp gain), 2 = a guide to what each 0..1 parameter value means — or use read_vintage for the numbers. Nota Valve (kind 6): id 0 = a one-line summary (model, gain, the tone stack with the middle's frequency, bright / deep, even-only, cabinet with mic, distance, axis and position, low / high cut, gate, mix, output, oversampling, auto-comp), 1 = the live reading (in / out peaks, THD with the 2nd and 3rd harmonics, estimated aliasing, drive, gate open / closed, auto-comp gain, the cab's loss at 4 kHz vs on-axis), 2 = a guide to the parameter values and units — or use read_valve for the numbers. Nota Utility (kind 4): id 0 = a one-line summary (channel mode, width and its L/R or M/S law, mono below with its slope, balance, phase, mute, gain, auto match and its reference, true-peak limit), 1 = the live reading (in / out LUFS-S, peak and RMS, true peak, the delta in the meter's unit, correlation, width, energy balance, auto-match gain, limiter reduction), 2 = a guide to the parameter values and units — or use read_utility for the numbers. Nota Shutter (kind 19): id 0 = a one-line summary (Gate / Duck, threshold, return, shape with attack / hold / release, floor, lookahead, retrigger, internal / external key, the key filter band, peak hold, Listen), 1 = the live reading (state, gain, reduction now and peak, in / out / detector levels, the share of the window it was open, openings in the last bar and since reset, key level, latency), 2 = a guide to what each 0..1 parameter value means — or use read_shutter for the numbers. Nota Auto Shift (kind 10): id 0 = a one-line summary (key and scale or the MIDI target settings, key source, amount, speed, range, human, shift and fine, formant preserve and shift, mix, detection range and sensitivity, skip sibilants, follow), 1 = the live reading (detected note and cents, frequency, clarity, target and correction, ratio, input level, MIDI note held, share sung in scale, the best and runner-up key, Learn running, latency), 2 = a guide to what each 0..1 parameter value means — or use read_auto_shift for the numbers. Nota Beat Repeat (kind 11): id 0 = a one-line summary (mode, interval, grid, offset, gate, chance, variation, pitch and pitch decay, decay, volume, the repeat filter with its type, band and narrowing, mix, Repeat held, latch), 1 = the live reading (idle / capturing / repeating, the pass of how many, the slice in ms and beats, the repeat's gain, pitch and filter, in / repeat / out levels, bar and beat, bursts and skipped intervals since reset), 2 = a guide to what each 0..1 parameter value means — or use read_beat_repeat for the numbers. Nota Dynamic EQ-8 (kind 13): id 0 = a one-line summary (bands on and dynamic, the Dynamic switch, each band on with its type, frequency, gain, Q and — for a dynamic band — mode, threshold, range, attack / release and key, solo, output, whether a key track is routed), 1 = the live reading (in / out peaks, whether a key arrives, each band's detector level and — for a dynamic band — its threshold and the gain it has now of its range, CPU), 2 = a guide to the parameter layout and units — or use read_dynamic_eq for the numbers and set_dynamic_eq_band to edit a band. Nota Ceiling (kind 14): id 0 = a one-line summary (character, gain, ceiling and whether it is true-peak, release or auto, look-ahead, stereo link, key high-pass, key track, the loudness target, Delta), 1 = the live reading (gain reduction now, its mean and deepest over the last 4 s and since reset, in / out peaks and their holds, true peak, the share of time over the ceiling, the release in use and its range, transients that reached the clip, LUFS M / S / I and the distance to the target, LRA, PLR, latency), 2 = a guide to the parameter values and units — or use read_ceiling for the numbers. Nota Crush (kind 12): id 0 = a one-line summary (mode, bits, rate with the hold, drive, wet, dither / jitter / noise, post filter, output, anti-alias, auto gain, DC filter), 1 = the live reading (in / out peak and RMS, crest, peak holds, bits with the level count and quantisation noise, the reduced rate, hold and Nyquist, THD+N, images above the Nyquist, the driven peak and folds, auto gain, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_crush for the numbers. Nota Orbit (kind 9): id 0 = a one-line summary (waveform, free rate in Hz or the Sync division, shape / glide, phase with the mode it makes — tremolo, auto-pan or offset pan — amount, mix), 1 = the live reading (the LFO rate and period, locked to the song or free-running, its place in the two-cycle window, the L / R gain now, the pan and its swing, the floor, in / out levels, tempo and bar, CPU), 2 = a guide to what each 0..1 parameter value means incl. the Division table — or use read_orbit for the numbers. Nota EQ-3 (kind 16): id 0 = a one-line summary (slope, the two crossovers, each band's gain or kill, the fader range, output), 1 = the live reading (in / out peaks, each band's level after its gain and the gain in effect now, the crossovers in use, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_eq3 for the numbers and set_eq3 to play it in dB and Hz. Nota Forge (kind 17): id 0 = a one-line summary (routing, amount, wet, output, each stage on with its type, role, drive, out, feedback, bias, tone and width, the LFO → drive with its rate, env → tone, the master tone / bias / width offsets when set, oversampling and an aliasing warning), 1 = the live reading (in / out peak and RMS, THD of a −6 dB sine through the device and through each stage with its flavour, the LFO value, drive offset and rate, the envelope, the master tilt now, oversampling, latency, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_forge for the numbers and the curve, set_forge and set_forge_stage to play it in units. Nota Level (kind 18): id 0 = a one-line summary (the target or the reference track, scale, auto with its glide or manual with its gain, max gain, trim, true-peak safe with the ceiling and look-ahead), 1 = the live reading (state, input and output loudness on the scale, momentary and short-term, the target in effect, the distance to it, the correction, gain applied and wanted, limiter reduction, true peak, correlation, latency), 2 = a guide to what each 0..1 parameter value means — or use read_level for the numbers and set_level to play it in LUFS and dB. Nota EQ-8 (kind 0): id 0 = a one-line summary (bands on, scale, each band on with its type, frequency, gain, Q, slope for the cuts and channel when not stereo, output, auto gain, analyzer), 1 = the live reading (in / out peaks, the auto gain in effect, CPU), 2 = a guide to the parameter layout and units — or use read_eq8 for the numbers, set_eq8_band to edit a band and set_eq8 for the globals. Nota Flanger (kind 23): id 0 = a one-line summary, 1 = the live reading (delay per channel, the notch and its sweep, levels), 2 = a guide to the parameter values — or use read_flanger / set_flanger. Nota Phaser (kind 24): id 0 = a one-line summary (stages and notches, LFO, center, depth, feedback and its mode, mix), 1 = the live reading (fc per channel, the first notch and its sweep, null and peak depth, levels), 2 = a guide to the parameter values — or use read_phaser / set_phaser.")]
+ [McpServerTool(Name = "get_device_text"), Description("Read a device's resource text. Nota Chamber: id 0 = current IR name, 1 = its category, 2 = the loaded user IR's name, 10 = the built-in IR list (name, category, seconds per line; the IR param selects entry round(v × 16), 1.0 = the user IR). Nota Lens: id 0 = the analysis summary, 1 = the third-octave band table, 2 = the scope measurements, 3 = the strongest spectral peaks, 4 = the A/B cursor measurements — or use read_analyzer, which returns all of it parsed. Delay (kind 3): id 0 = a one-line summary of what it is doing now (sync division or free times, ping-pong, feedback, mix, or that it is frozen). Reverb (kind 2): id 0 = a one-line summary (algorithm, RT60, pre-delay, diffusion, mix, early reflections / vintage, or that the tail is frozen). Compressor (kind 1): id 0 = a one-line summary (character, threshold, ratio, knee, attack / release, detector, range, mix, the reduction right now, external key / unlinked / Listen) — or use read_dynamics for the numbers. Auto Filter (kind 7): id 0 = a one-line summary (type, slope, cutoff, Q, what the envelope and LFO drive and by how much, drive, mix, sidechain key), 1 = the live reading (modulated cutoff with its note, resonance, envelope level, LFO value and phase, onsets counted), 2 = a guide to what each 0..1 parameter value means — or use read_filter_motion for the numbers. Nota Vintage (kind 8): id 0 = a one-line summary (character, drive, tone model and shelves, wow / flutter with their rates, noise, crackle, wear, stage, mix, output, oversampling, auto-comp), 1 = the live reading (in / out peaks, THD with the 2nd and 3rd harmonics, asymmetry, wow and flutter in cents, band-limit, hiss level, auto-comp gain), 2 = a guide to what each 0..1 parameter value means — or use read_vintage for the numbers. Nota Valve (kind 6): id 0 = a one-line summary (model, gain, the tone stack with the middle's frequency, bright / deep, even-only, cabinet with mic, distance, axis and position, low / high cut, gate, mix, output, oversampling, auto-comp), 1 = the live reading (in / out peaks, THD with the 2nd and 3rd harmonics, estimated aliasing, drive, gate open / closed, auto-comp gain, the cab's loss at 4 kHz vs on-axis), 2 = a guide to the parameter values and units — or use read_valve for the numbers. Nota Utility (kind 4): id 0 = a one-line summary (channel mode, width and its L/R or M/S law, mono below with its slope, balance, phase, mute, gain, auto match and its reference, true-peak limit), 1 = the live reading (in / out LUFS-S, peak and RMS, true peak, the delta in the meter's unit, correlation, width, energy balance, auto-match gain, limiter reduction), 2 = a guide to the parameter values and units — or use read_utility for the numbers. Nota Shutter (kind 19): id 0 = a one-line summary (Gate / Duck, threshold, return, shape with attack / hold / release, floor, lookahead, retrigger, internal / external key, the key filter band, peak hold, Listen), 1 = the live reading (state, gain, reduction now and peak, in / out / detector levels, the share of the window it was open, openings in the last bar and since reset, key level, latency), 2 = a guide to what each 0..1 parameter value means — or use read_shutter for the numbers. Nota Auto Shift (kind 10): id 0 = a one-line summary (key and scale or the MIDI target settings, key source, amount, speed, range, human, shift and fine, formant preserve and shift, mix, detection range and sensitivity, skip sibilants, follow), 1 = the live reading (detected note and cents, frequency, clarity, target and correction, ratio, input level, MIDI note held, share sung in scale, the best and runner-up key, Learn running, latency), 2 = a guide to what each 0..1 parameter value means — or use read_auto_shift for the numbers. Nota Beat Repeat (kind 11): id 0 = a one-line summary (mode, interval, grid, offset, gate, chance, variation, pitch and pitch decay, decay, volume, the repeat filter with its type, band and narrowing, mix, Repeat held, latch), 1 = the live reading (idle / capturing / repeating, the pass of how many, the slice in ms and beats, the repeat's gain, pitch and filter, in / repeat / out levels, bar and beat, bursts and skipped intervals since reset), 2 = a guide to what each 0..1 parameter value means — or use read_beat_repeat for the numbers. Nota Dynamic EQ-8 (kind 13): id 0 = a one-line summary (bands on and dynamic, the Dynamic switch, each band on with its type, frequency, gain, Q and — for a dynamic band — mode, threshold, range, attack / release and key, solo, output, whether a key track is routed), 1 = the live reading (in / out peaks, whether a key arrives, each band's detector level and — for a dynamic band — its threshold and the gain it has now of its range, CPU), 2 = a guide to the parameter layout and units — or use read_dynamic_eq for the numbers and set_dynamic_eq_band to edit a band. Nota Ceiling (kind 14): id 0 = a one-line summary (character, gain, ceiling and whether it is true-peak, release or auto, look-ahead, stereo link, key high-pass, key track, the loudness target, Delta), 1 = the live reading (gain reduction now, its mean and deepest over the last 4 s and since reset, in / out peaks and their holds, true peak, the share of time over the ceiling, the release in use and its range, transients that reached the clip, LUFS M / S / I and the distance to the target, LRA, PLR, latency), 2 = a guide to the parameter values and units — or use read_ceiling for the numbers. Nota Crush (kind 12): id 0 = a one-line summary (mode, bits, rate with the hold, drive, wet, dither / jitter / noise, post filter, output, anti-alias, auto gain, DC filter), 1 = the live reading (in / out peak and RMS, crest, peak holds, bits with the level count and quantisation noise, the reduced rate, hold and Nyquist, THD+N, images above the Nyquist, the driven peak and folds, auto gain, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_crush for the numbers. Nota Orbit (kind 9): id 0 = a one-line summary (waveform, free rate in Hz or the Sync division, shape / glide, phase with the mode it makes — tremolo, auto-pan or offset pan — amount, mix), 1 = the live reading (the LFO rate and period, locked to the song or free-running, its place in the two-cycle window, the L / R gain now, the pan and its swing, the floor, in / out levels, tempo and bar, CPU), 2 = a guide to what each 0..1 parameter value means incl. the Division table — or use read_orbit for the numbers. Nota EQ-3 (kind 16): id 0 = a one-line summary (slope, the two crossovers, each band's gain or kill, the fader range, output), 1 = the live reading (in / out peaks, each band's level after its gain and the gain in effect now, the crossovers in use, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_eq3 for the numbers and set_eq3 to play it in dB and Hz. Nota Forge (kind 17): id 0 = a one-line summary (routing, amount, wet, output, each stage on with its type, role, drive, out, feedback, bias, tone and width, the LFO → drive with its rate, env → tone, the master tone / bias / width offsets when set, oversampling and an aliasing warning), 1 = the live reading (in / out peak and RMS, THD of a −6 dB sine through the device and through each stage with its flavour, the LFO value, drive offset and rate, the envelope, the master tilt now, oversampling, latency, CPU), 2 = a guide to what each 0..1 parameter value means — or use read_forge for the numbers and the curve, set_forge and set_forge_stage to play it in units. Nota Level (kind 18): id 0 = a one-line summary (the target or the reference track, scale, auto with its glide or manual with its gain, max gain, trim, true-peak safe with the ceiling and look-ahead), 1 = the live reading (state, input and output loudness on the scale, momentary and short-term, the target in effect, the distance to it, the correction, gain applied and wanted, limiter reduction, true peak, correlation, latency), 2 = a guide to what each 0..1 parameter value means — or use read_level for the numbers and set_level to play it in LUFS and dB. Nota EQ-8 (kind 0): id 0 = a one-line summary (bands on, scale, each band on with its type, frequency, gain, Q, slope for the cuts and channel when not stereo, output, auto gain, analyzer), 1 = the live reading (in / out peaks, the auto gain in effect, CPU), 2 = a guide to the parameter layout and units — or use read_eq8 for the numbers, set_eq8_band to edit a band and set_eq8 for the globals. Nota Flanger (kind 23): id 0 = a one-line summary, 1 = the live reading (delay per channel, the notch and its sweep, levels), 2 = a guide to the parameter values — or use read_flanger / set_flanger. Nota Phaser (kind 24): id 0 = a one-line summary (stages and notches, LFO, center, depth, feedback and its mode, mix), 1 = the live reading (fc per channel, the first notch and its sweep, null and peak depth, levels), 2 = a guide to the parameter values — or use read_phaser / set_phaser. Nota Chorus (kind 25): id 0 = a one-line summary (mode, LFO, offset, HPF, amount, feedback, width, warmth, mix), 1 = the live reading (each voice's delay and detune now, the sweep, levels), 2 = a guide to the parameter values — or use read_chorus / set_chorus.")]
public Task<string> GetDeviceText(int trackId, int deviceIndex, int id) => Read(() => E.DeviceText(trackId, deviceIndex, id));
- [McpServerTool(Name = "device_action"), Description("Run a device's own command — the few things that are actions rather than parameters. Delay (kind 3): id 0 clears the loop (empties the delay buffer, so whatever is still circulating stops; useful after Freeze). Reverb (kind 2): id 0 kills the tail (empties the reverb's buffers, so whatever is still ringing — or frozen — stops). Auto Filter (kind 7): id 0 restarts the LFO (from its start phase; in Sync the cycle is re-anchored to the current beat), id 1 resets the envelope follower (drops a held peak). Nota Vintage (kind 8): id 0 resets the wear (restarts the wow and flutter at their zero phase and silences a ringing crackle). Nota Valve (kind 6): id 0 resets the amp (clears the filters, the gate and the auto-comp). Nota Utility (kind 4): id 0 gain match — moves Gain once so the output meets the reference (the input's level, or Target when Match To = 1) over the last 3 s in the Meter's unit; id 1 resets the meters (level history, holds and the auto-match ride). Nota Shutter (kind 19): id 0 resets the meters (peak reduction, the opening count, the history); id 1 sets the history window read_shutter and the card show (intArg 0 = 250 ms, 1 = 1 s, 2 = 4 s). Nota Auto Shift (kind 10): id 0 resets the analysis (the sung-note histogram and the pitch history); id 1 is Learn — intArg 1 starts listening (clears the histogram), 0 stops and sets Key + Scale (Major / Minor) to the best match and Key Source to Manual, 2 cancels. Nota Beat Repeat (kind 11): id 0 resets (stops the repeat, clears the timeline, the meters and the burst count); id 1 fires a repeat now, as if the interval hit (ignores Chance; while the transport plays — to hold one, set the Repeat param to 1). Nota Ceiling (kind 14): id 0 resets the peaks (the peak and true-peak holds, the max reduction, the clip count and the 4 s level window); id 1 resets the loudness (integrated, LRA, the 60 s window) and the peaks. Nota Crush (kind 12): id 0 resets the meters (the peak holds and the spectrum average). Nota Orbit (kind 9): id 0 restarts the LFO (free run: from phase 0; with Sync on and the transport playing it stays locked to the bar), id 1 resets the meters. Nota EQ-3 (kind 16): id 0 resets the meters (the peaks and the spectrum average). Nota Forge (kind 17): id 0 restarts the LFO (free run: from phase 0) and resets the meters. Nota Level (kind 18): id 0 restarts the measurement from the loudness now (RESET — the ride catches up at once), id 1 is MATCH (switches to Manual with the gain set to the distance to the target; see level_match). Nota EQ-8 (kind 0): id 0 resets the meters (the peaks and the spectrum averages). Nota Flanger (kind 23): id 0 restarts the LFO (free run: from phase 0), id 1 clears the delay line (stops a ringing comb), id 2 resets the meters. Nota Phaser (kind 24): id 0 restarts the LFO (free run: from phase 0), id 1 clears the all-pass stages (stops a whistling loop), id 2 resets the meters. Devices without a command ignore the call.")]
+ [McpServerTool(Name = "device_action"), Description("Run a device's own command — the few things that are actions rather than parameters. Delay (kind 3): id 0 clears the loop (empties the delay buffer, so whatever is still circulating stops; useful after Freeze). Reverb (kind 2): id 0 kills the tail (empties the reverb's buffers, so whatever is still ringing — or frozen — stops). Auto Filter (kind 7): id 0 restarts the LFO (from its start phase; in Sync the cycle is re-anchored to the current beat), id 1 resets the envelope follower (drops a held peak). Nota Vintage (kind 8): id 0 resets the wear (restarts the wow and flutter at their zero phase and silences a ringing crackle). Nota Valve (kind 6): id 0 resets the amp (clears the filters, the gate and the auto-comp). Nota Utility (kind 4): id 0 gain match — moves Gain once so the output meets the reference (the input's level, or Target when Match To = 1) over the last 3 s in the Meter's unit; id 1 resets the meters (level history, holds and the auto-match ride). Nota Shutter (kind 19): id 0 resets the meters (peak reduction, the opening count, the history); id 1 sets the history window read_shutter and the card show (intArg 0 = 250 ms, 1 = 1 s, 2 = 4 s). Nota Auto Shift (kind 10): id 0 resets the analysis (the sung-note histogram and the pitch history); id 1 is Learn — intArg 1 starts listening (clears the histogram), 0 stops and sets Key + Scale (Major / Minor) to the best match and Key Source to Manual, 2 cancels. Nota Beat Repeat (kind 11): id 0 resets (stops the repeat, clears the timeline, the meters and the burst count); id 1 fires a repeat now, as if the interval hit (ignores Chance; while the transport plays — to hold one, set the Repeat param to 1). Nota Ceiling (kind 14): id 0 resets the peaks (the peak and true-peak holds, the max reduction, the clip count and the 4 s level window); id 1 resets the loudness (integrated, LRA, the 60 s window) and the peaks. Nota Crush (kind 12): id 0 resets the meters (the peak holds and the spectrum average). Nota Orbit (kind 9): id 0 restarts the LFO (free run: from phase 0; with Sync on and the transport playing it stays locked to the bar), id 1 resets the meters. Nota EQ-3 (kind 16): id 0 resets the meters (the peaks and the spectrum average). Nota Forge (kind 17): id 0 restarts the LFO (free run: from phase 0) and resets the meters. Nota Level (kind 18): id 0 restarts the measurement from the loudness now (RESET — the ride catches up at once), id 1 is MATCH (switches to Manual with the gain set to the distance to the target; see level_match). Nota EQ-8 (kind 0): id 0 resets the meters (the peaks and the spectrum averages). Nota Flanger (kind 23): id 0 restarts the LFO (free run: from phase 0), id 1 clears the delay line (stops a ringing comb), id 2 resets the meters. Nota Phaser (kind 24): id 0 restarts the LFO (free run: from phase 0), id 1 clears the all-pass stages (stops a whistling loop), id 2 resets the meters. Nota Chorus (kind 25): id 0 restarts the LFO (free run: from phase 0), id 1 clears the delay lines (stops a ringing feedback loop), id 2 resets the meters. Devices without a command ignore the call.")]
public Task DeviceAction(int trackId, int deviceIndex, [Description("Command id — see the device's list in this description")] int id,
int intArg = 0, float floatArg = 0) => Mutate(() => E.DeviceAction(trackId, deviceIndex, id, intArg, floatArg));
@@ -1012,6 +1012,98 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I
return PhaserRead(trackId, deviceIndex);
});
+ public sealed record ChorusVoiceReading(string Name, double DelayMs, double Cents);
+ public sealed record ChorusReading(string Summary, string Live, string Mode, int Voices, bool Sync, string Division, double RateHz,
+ double PeriodMs, double OffsetDeg, double HpfHz, double AmountPercent, double FeedbackPercent, double WidthPercent,
+ double WarmthPercent, double MixPercent, string State, double DelayMinMs, double DelayMaxMs, double MaxCents,
+ IReadOnlyList<ChorusVoiceReading> VoicesNow, double WindowPhase, bool Locked, bool Playing, double Bpm, double InputPeakDb,
+ double OutputPeakLDb, double OutputPeakRDb, bool Signal, double SampleRate);
+
+ private static readonly string[] ChorusModes = { "Classic", "Ensemble", "Vibrato" };
+ private static readonly string[] ChorusDivs = { "4/1", "2/1", "1/1", "1/2", "1/4", "1/4T", "1/8", "1/8T", "1/16" };
+
+ [McpServerTool(Name = "read_chorus"), Description(
+ "Read what a Nota Chorus (built-in effect kind 25 — modulated delay voices: Classic = 2 voices L / R on 8 ± 5 ms, Ensemble = "
+ + "3 voices 120° apart on 12 ± 6 ms, Vibrato = the L / R pair on 3 ± 2.5 ms, wet only) is doing: the mode and voice count, "
+ + "the sine LFO's free rate (Hz) or Sync division and period, Offset (the right voice's LFO behind the left, 0..180°; "
+ + "fixed in Ensemble), the wet HPF (Hz, 0 = off), Amount (share of the mode's swing), Feedback (−90..+90 %), Width "
+ + "(0..200 %), Warmth, Mix (Vibrato: always 100), the state (2 voices, 3 voices, wet only, resonant past ±60 % feedback, "
+ + "bypass); the delay range each voice sweeps, the largest detune (± cents), each voice's delay and detune now, the LFO's "
+ + "place in its two-cycle window, whether it is locked to the song (Sync + playing), tempo and input / L / R output peaks "
+ + "(dBFS, −120 = silence). Live values move only while audio runs through the track. Params: 0 Rate, 1 Mode, 2 Sync, "
+ + "3 Division, 4 Offset, 5 HPF, 6 Amount, 7 Feedback, 8 Width, 9 Warmth, 10 Mix — set them in units with set_chorus; "
+ + "device_action 0 restarts the LFO, 1 clears the delay lines, 2 resets the meters.")]
+ public Task<ChorusReading> ReadChorus(int trackId, int deviceIndex) => Read(() => ChorusRead(trackId, deviceIndex));
+
+ private ChorusReading ChorusRead(int trackId, int deviceIndex)
+ {
+ if (E.TrackDeviceBuiltinKind(trackId, deviceIndex) != 25) throw new ArgumentException("not a Nota Chorus (kind 25)");
+ var sc = new float[32];
+ int n = E.DeviceScope(trackId, deviceIndex, sc, sc.Length);
+ float V(int i) => n > i ? sc[i] : 0f;
+ float Db(int i) => n > i ? sc[i] : -120f;
+ static double R1(double v) => Math.Round(v, 1);
+ static double R2(double v) => Math.Round(v, 2);
+ float Pm(int p) => E.DeviceGetParam(trackId, deviceIndex, p);
+ int mode = Math.Clamp((int)Math.Round(Pm(1) * 2), 0, 2);
+ int div = Math.Clamp((int)Math.Round(Pm(3) * 8), 0, 8);
+ int voices = mode == 1 ? 3 : 2;
+ double fb = (Pm(7) - 0.5) * 1.8;
+ bool bypassed = E.DeviceBypassed(trackId, deviceIndex);
+ string state = bypassed ? "bypass" : mode == 2 ? "wet only" : Math.Abs(fb) >= 0.6 ? "resonant" : voices == 3 ? "3 voices" : "2 voices";
+ double rate = V(10);
+ double hp = Pm(5) < 0.01f ? 0 : 20 * Math.Pow(100, Pm(5));
+ string[] names = mode == 1 ? new[] { "V1", "V2", "V3" } : new[] { "L", "R" };
+ var now = names.Select((nm, i) => new ChorusVoiceReading(nm, R2(V(3 + i)), R1(V(6 + i)))).ToList();
+ return new ChorusReading(E.DeviceText(trackId, deviceIndex, 0), E.DeviceText(trackId, deviceIndex, 1),
+ ChorusModes[mode], voices, Pm(2) >= 0.5f, ChorusDivs[div], Math.Round(rate, 3), rate > 0 ? Math.Round(1000 / rate) : 0,
+ mode == 1 ? 120 : Math.Round(Pm(4) * 180), Math.Round(hp), R1(Pm(6) * 100), R1(fb * 100), Math.Round(Pm(8) * 200),
+ R1(Pm(9) * 100), mode == 2 ? 100 : R1(Pm(10) * 100), state, R2(V(16)), R2(V(17)), R1(V(18)), now,
+ Math.Round(V(9), 3), V(13) > 0.5f, V(12) > 0.5f, Math.Round(V(11), 2), R1(Db(0)), R1(Db(1)), R1(Db(2)), V(26) > 0.5f, V(14));
+ }
+
+ [McpServerTool(Name = "set_chorus"), Description(
+ "Play a Nota Chorus (built-in effect kind 25) in units — only the fields you pass change; each change is recorded like a "
+ + "hand edit (so it lands in automation while recording). mode \"Classic\" | \"Ensemble\" | \"Vibrato\" (Vibrato is wet "
+ + "only); rateHz 0.02..8 (sets free run); division \"4/1\" \"2/1\" \"1/1\" \"1/2\" \"1/4\" \"1/4T\" \"1/8\" \"1/8T\" "
+ + "\"1/16\" (sets Sync); sync true / false; offsetDeg 0..180 (Classic / Vibrato: 0 = both voices move together, 180 = "
+ + "opposite); hpfHz 0 = off or 20..2000 (keeps the lows out of the wet); amountPercent 0..100 (how far the delay swings); "
+ + "feedbackPercent −90..+90 (past ±60 it rings metallic); widthPercent 0..200 (0 = mono, 100 = as is, 200 = side +6 dB); "
+ + "warmthPercent 0..100 (a dark, saturated bucket-brigade line); mixPercent 0..100 (50 = dry and wet equal). Returns the "
+ + "device as read back.")]
+ public Task<ChorusReading> SetChorus(int trackId, int deviceIndex, string? mode = null, double? rateHz = null, string? division = null,
+ bool? sync = null, double? offsetDeg = null, double? hpfHz = null, double? amountPercent = null, double? feedbackPercent = null,
+ double? widthPercent = null, double? warmthPercent = null, double? mixPercent = null) => Mutate(() =>
+ {
+ if (E.TrackDeviceBuiltinKind(trackId, deviceIndex) != 25) throw new ArgumentException("not a Nota Chorus (kind 25)");
+ void S(int p, double v) => ForgeSet(trackId, deviceIndex, p, v);
+ if (mode is not null)
+ {
+ int m = mode.Trim().ToLowerInvariant() switch
+ {
+ "classic" => 0, "ensemble" => 1, "vibrato" => 2,
+ _ => throw new ArgumentException("mode must be Classic, Ensemble or Vibrato"),
+ };
+ S(1, m / 2.0);
+ }
+ if (rateHz is { } hz) { S(2, 0); S(0, Math.Log(Math.Clamp(hz, 0.02, 8) / 0.02) / Math.Log(400)); }
+ if (sync is { } sy) S(2, sy ? 1 : 0);
+ if (division is not null)
+ {
+ int d = Array.IndexOf(ChorusDivs, division.Trim().ToUpperInvariant());
+ if (d < 0) throw new ArgumentException("division must be one of " + string.Join(", ", ChorusDivs));
+ S(2, 1); S(3, d / 8.0);
+ }
+ if (offsetDeg is { } od) S(4, Math.Clamp(od, 0, 180) / 180);
+ if (hpfHz is { } hp) S(5, hp < 20 ? 0 : Math.Log(Math.Clamp(hp, 20, 2000) / 20) / Math.Log(100));
+ if (amountPercent is { } ap) S(6, Math.Clamp(ap, 0, 100) / 100);
+ if (feedbackPercent is { } fp) S(7, 0.5 + Math.Clamp(fp, -90, 90) / 180);
+ if (widthPercent is { } wp) S(8, Math.Clamp(wp, 0, 200) / 200);
+ if (warmthPercent is { } wm) S(9, Math.Clamp(wm, 0, 100) / 100);
+ if (mixPercent is { } mp) S(10, Math.Clamp(mp, 0, 100) / 100);
+ return ChorusRead(trackId, deviceIndex);
+ });
+
public sealed record DynEqBand(int Band, bool On, string Type, double FreqHz, double GainDb, double Q, string Mode, double ThresholdDb,
double RangeDb, double AttackMs, double ReleaseMs, string Key, bool Dynamic, double LevelDb, double GainNowDb, double ResponseDb);
public sealed record DynEqSpectrumBand(double Hz, double Db);
diff --git a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
index 69429834..4a06243d 100644
--- a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
@@ -256,6 +256,7 @@ public sealed partial class BrowserViewModel : ObservableObject
new() { Name = "Nota Orbit", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 9, Sub = "auto-pan" },
new() { Name = "Nota Flanger", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 23, Sub = "flanger" },
new() { Name = "Nota Phaser", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 24, Sub = "phaser" },
+ new() { Name = "Nota Chorus", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 25, Sub = "chorus" },
new() { Name = "Nota Auto Shift", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 10, Sub = "pitch correction" },
new() { Name = "Nota Beat Repeat", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 11, Sub = "glitch & repeats" },
new() { Name = "Nota Crush", Kind = BrowserItemKind.BuiltinEffect, BuiltinKind = 12, Sub = "bit crusher" },
diff --git a/src/native/nota.engine/src/Chorus.h b/src/native/nota.engine/src/Chorus.h
new file mode 100644
index 00000000..d3d1127c
--- /dev/null
+++ b/src/native/nota.engine/src/Chorus.h
@@ -0,0 +1,543 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Built-in Nota Chorus (device kind 25, mockup "Nota Chorus") — modulated delay voices in three
+// modes:
+//
+// Classic two voices, L and R, each on its own channel's delay line; the right voice's LFO
+// runs Offset (0 … 180°) behind the left. τ = 8 ms ± 5 ms · Amount
+// Ensemble three voices 120° apart (V1 left, V2 centre, V3 right) — the string-machine sound.
+// τ = 12 ms ± 6 ms · Amount (Offset is not used)
+// Vibrato the Classic pair on a short line, wet only (Mix is locked to 100 %).
+// τ = 3 ms ± 2.5 ms · Amount
+//
+// Per voice τ(t) = base + dep · sin(2π(p + φ)); the delay's slope detunes the voice by
+// 1200 · log2(1 − dτ/dt) cents, at most ±1200 · log2(1 + dep · 2π · rate). The wet path:
+//
+// in → HPF (off, or 20 Hz … 2 kHz, 12 dB/oct) → + Feedback · wet → Warmth → delay line
+// voices → wet L / R → Width (M/S: 0 = mono, 100 % = as is, 200 % = side +6 dB)
+// out = (dry · x + wet_gain · wet) / (dry + wet_gain) (Mix 0.5 = equal; Vibrato = wet only)
+//
+// Warmth is a bucket-brigade flavour on the line input: a one-pole low-pass that closes from
+// 20 kHz to ~2.5 kHz and a soft tanh saturation that grows with it. Feedback is bipolar ±90 %.
+// LFO: a sine, free (Rate 0.02 … 8 Hz) or Sync (Division 4/1 … 1/16 incl. triplets). In Sync the
+// LFO locks to the song position while the transport plays and restarts on the bar (a cycle longer
+// than a bar restarts on the span of bars that holds it); stopped, it free-runs at the synced rate.
+//
+// The delay is read with 4-point Hermite interpolation. Amount, Feedback, Offset, Width, Warmth and
+// Mix glide over ~15 ms; a Mode change fades the wet out and back in (~8 ms each way) instead of
+// jumping the delay.
+//
+// All params are normalized 0..1 and APPEND ONLY. Persistence / automation / clone flow
+// generically through the base Device.
+// Telemetry (scopeRead): kTele live values (levels, τ and cents now per voice, the LFO's place in
+// its two-cycle window, the rate, the tempo, the sweep and the detune range).
+// deviceText: 0 = status line, 1 = live reading, 2 = parameter guide.
+// deviceAction: 0 = restart the LFO (free run: from phase 0), 1 = clear the delay lines (stops a
+// ringing feedback loop), 2 = reset the meters.
+// Header-only, allocation-free, JUCE-free.
+
+#pragma once
+
+#include "Device.h"
+#include "TransportInfo.h"
+
+#include <algorithm>
+#include <atomic>
+#include <chrono>
+#include <cmath>
+#include <cstdint>
+#include <cstdio>
+#include <cstring>
+#include <string>
+
+namespace nota {
+
+class Chorus : public Device {
+public:
+ // Param layout — order is the persisted/automation layout. APPEND ONLY.
+ enum { Rate = 0, Mode, Sync, Division, Offset, Hpf, Amount, Feedback, Width, Warmth, Mix, kNumParams };
+
+ // Telemetry slots (scopeRead).
+ enum {
+ S_InPeak = 0, // input peak (300 ms fall), dBFS
+ S_OutPeakL, // output peak, left (300 ms fall), dBFS
+ S_OutPeakR, // output peak, right, dBFS
+ S_Tau1, // each voice's delay now, ms (V3 = 0 outside Ensemble)
+ S_Tau2,
+ S_Tau3,
+ S_Cents1, // each voice's detune now, cents
+ S_Cents2,
+ S_Cents3,
+ S_WinPhase, // the LFO's place in its two-cycle window, 0..2 (cycles)
+ S_RateHz, // the LFO rate now, Hz (Sync: from the tempo)
+ S_Bpm, // the tempo the Sync rate follows
+ S_Playing, // 1 while the transport plays
+ S_Locked, // 1 while Sync is on and the LFO is locked to the song position
+ S_SampleRate,
+ S_BaseMs, // the mode's centre delay, ms
+ S_TauMin, // the sweep's shortest / longest delay, ms
+ S_TauMax,
+ S_MaxCents, // the largest detune the sweep reaches, ± cents
+ S_Voices, // 2 or 3
+ S_Mode, // 0 Classic, 1 Ensemble, 2 Vibrato
+ S_HpHz, // the wet high-pass corner, Hz (0 = off)
+ S_WidthPct, // Width, %
+ S_DivBeats, // the Sync division, beats per cycle
+ S_BarBeats, // beats per bar (the restart span's unit)
+ S_Cpu, // share of real time spent in process()
+ S_Signal, // 1 while signal comes in (above −70 dBFS)
+ S_Cycles, // LFO cycles since load / the last restart (free run) or the song cycle (Sync)
+ kTele = 32
+ };
+
+ static constexpr int kModes = 3;
+ static constexpr const char* kModeNames[kModes] = { "Classic", "Ensemble", "Vibrato" };
+ // Per mode: the centre delay and the swing at Amount 100 %, ms.
+ static constexpr double kBaseMs[kModes] = { 8.0, 12.0, 3.0 };
+ static constexpr double kDepMs[kModes] = { 5.0, 6.0, 2.5 };
+
+ static constexpr int kDivs = 9;
+ // Sync divisions, slowest → fastest: beats per cycle, and their names.
+ static constexpr double kDivBeats[kDivs] = { 16.0, 8.0, 4.0, 2.0, 1.0, 2.0 / 3.0, 0.5, 1.0 / 3.0, 0.25 };
+ static constexpr const char* kDivNames[kDivs] = { "4/1", "2/1", "1/1", "1/2", "1/4", "1/4T", "1/8", "1/8T", "1/16" };
+ static constexpr int kDefaultDiv = 2; // 1/1
+
+ // Ranges (mirrored by the card and MCP).
+ static constexpr double kRateLo = 0.02, kRateHi = 8.0; // Hz, exponential
+ static constexpr double kHpLo = 20.0, kHpHi = 2000.0; // Hz, exponential; below 0.01 = off
+ static constexpr double kFbMax = 0.90; // feedback ±90 %
+ static constexpr double kWidthMax = 2.0; // 200 %
+
+ Chorus() {
+ p_[Rate].store(0.6157f); // 0.80 Hz
+ p_[Mode].store(0.0f); // Classic
+ p_[Sync].store(0.0f); // Free (Hz)
+ p_[Division].store((float)kDefaultDiv / (kDivs - 1));
+ p_[Offset].store(1.0f); // 180°
+ p_[Hpf].store(0.0f); // off
+ p_[Amount].store(0.40f);
+ p_[Feedback].store(0.5f); // 0
+ p_[Width].store(0.5f); // 100 %
+ p_[Warmth].store(0.0f);
+ p_[Mix].store(0.50f);
+ setSampleRate(44100.0, 0);
+ }
+
+ void setSampleRate(double sr, int32_t /*maxBlock*/) override {
+ sr_ = sr > 0 ? sr : 44100.0;
+ srA_.store((float)sr_, std::memory_order_relaxed);
+ cycle_ = 0; frac_ = 0.0;
+ clearLines();
+ snap_ = true;
+ resetMeters();
+ }
+
+ // Musical clock for Sync (engine calls this before process()).
+ void setTransport(double beatStart, double spb, bool playing) override {
+ beatStart_ = beatStart; spb_ = spb > 0 ? spb : 0.0; playing_ = playing;
+ }
+ void setTransportInfo(const TransportInfo& ti) override {
+ if (ti.tsNum > 0 && ti.tsDenom > 0) barBeats_ = std::clamp(ti.tsNum * 4.0 / ti.tsDenom, 0.5, 64.0);
+ }
+
+ void process(float* buf, int32_t frames) override {
+ const auto t0 = std::chrono::steady_clock::now();
+ if (restartReq_.exchange(false, std::memory_order_acquire)) { cycle_ = 0; frac_ = 0.0; }
+ if (clearReq_.exchange(false, std::memory_order_acquire)) clearLines();
+ if (resetReq_.exchange(false, std::memory_order_acquire)) resetMeters();
+
+ const int modeT = modeIndex();
+ const double amount = std::clamp((double)get(Amount), 0.0, 1.0);
+ const double fb = feedback();
+ const double offT = offsetDeg() / 360.0;
+ const double width = widthPct() / 100.0;
+ const double warmth = std::clamp((double)get(Warmth), 0.0, 1.0);
+ const bool sync = get(Sync) >= 0.5f;
+ const double div = kDivBeats[divIndex()];
+ const double spb = spb_ > 0.0 ? spb_ : sr_ * 0.5; // 120 BPM until the engine says otherwise
+ const double rateHz = sync ? sr_ / (spb * div) : rateFreeHz();
+ const double inc = rateHz / sr_;
+ const bool locked = sync && playing_ && spb_ > 0.0;
+ const double span = barBeats_ * std::max(1.0, std::ceil(div / barBeats_ - 1e-9));
+ const double sm = 1.0 - std::exp(-1.0 / (0.015 * sr_)); // ~15 ms parameter glide
+ const double fadeStep = 1.0 / (0.008 * sr_); // ~8 ms mode fade
+ const double msToS = sr_ * 0.001;
+ const double maxD = (double)(kBuf - 4);
+ const double hpHz = hpfHz();
+ const bool hpOn = hpHz > 0.0;
+
+ if (snap_) {
+ mode_ = modeT; amountS_ = amount; fbS_ = fb; offS_ = offT; widthS_ = width; warmS_ = warmth;
+ const MixW mw = mixWeights(modeT);
+ dryS_ = mw.dry; wetS_ = mw.wet; fade_ = 1.0; hpS_ = hpOn ? hpHz : 0.0;
+ snap_ = false;
+ }
+
+ float inPk = 0.0f, outPkL = 0.0f, outPkR = 0.0f;
+ double tau[3] = { 0.0, 0.0, 0.0 };
+ for (int32_t i = 0; i < frames; ++i) {
+ if (locked) {
+ const double beat = beatStart_ + (double)i / spb_;
+ const double spans = std::floor(beat / span);
+ const double c = (beat - spans * span) / div;
+ const double k = std::floor(c);
+ cycle_ = (int64_t)spans * 4096 + (int64_t)k;
+ frac_ = c - k;
+ }
+ // A Mode change: fade the wet out, switch while it is silent, fade back in.
+ if (modeT != mode_) {
+ fade_ -= fadeStep;
+ if (fade_ <= 0.0) { fade_ = 0.0; mode_ = modeT; }
+ } else if (fade_ < 1.0) {
+ fade_ = std::min(1.0, fade_ + fadeStep);
+ }
+ const MixW mw = mixWeights(mode_);
+ amountS_ += sm * (amount - amountS_);
+ fbS_ += sm * (fb - fbS_);
+ offS_ += sm * (offT - offS_);
+ widthS_ += sm * (width - widthS_);
+ warmS_ += sm * (warmth - warmS_);
+ dryS_ += sm * (mw.dry - dryS_);
+ wetS_ += sm * (mw.wet - wetS_);
+
+ // Control-rate coefficients: the HPF (TPT SVF, Q 0.707) and the warmth low-pass.
+ if ((i & 15) == 0) {
+ if (hpOn) {
+ hpS_ = hpS_ > 0.0 ? hpS_ + 16.0 * sm * (hpHz - hpS_) : hpHz;
+ const double g = std::tan(kPi * std::min(hpS_, sr_ * 0.45) / sr_);
+ hpG_ = g; hpK_ = 1.4142135623730951; hpA1_ = 1.0 / (1.0 + g * (g + hpK_));
+ } else {
+ hpS_ = 0.0;
+ }
+ const double lpHz = 20000.0 * std::pow(0.125, warmS_); // 20 kHz … 2.5 kHz
+ lpA_ = 1.0 - std::exp(-2.0 * kPi * std::min(lpHz, sr_ * 0.45) / sr_);
+ }
+
+ const double base = kBaseMs[mode_], dep = kDepMs[mode_] * amountS_;
+ const int nv = mode_ == 1 ? 3 : 2;
+ for (int v = 0; v < nv; ++v)
+ tau[v] = base + dep * std::sin(2.0 * kPi * (frac_ + voicePhase(mode_, v, offS_)));
+ if (nv == 2) tau[2] = 0.0;
+
+ const float xL = buf[i * 2], xR = buf[i * 2 + 1];
+ inPk = std::max(inPk, std::max(std::fabs(xL), std::fabs(xR)));
+
+ // Voices → wet L / R.
+ double wL, wR;
+ const double d0 = std::clamp(tau[0] * msToS, 2.0, maxD), d1 = std::clamp(tau[1] * msToS, 2.0, maxD);
+ if (nv == 3) {
+ const double d2 = std::clamp(tau[2] * msToS, 2.0, maxD);
+ const double v1 = readLine(lineL_, d0);
+ const double v2 = 0.5 * (readLine(lineL_, d1) + readLine(lineR_, d1));
+ const double v3 = readLine(lineR_, d2);
+ wL = (v1 + kCentre * v2) * kEnsNorm;
+ wR = (v3 + kCentre * v2) * kEnsNorm;
+ } else {
+ wL = readLine(lineL_, d0);
+ wR = readLine(lineR_, d1);
+ }
+
+ // The line input: HPF'd dry + feedback, through the warmth stage.
+ double hL = xL, hR = xR;
+ if (hpOn) { hL = hpTick(hpL_, xL); hR = hpTick(hpR_, xR); }
+ lineL_[w_] = sanitize((float)warm(lpL_, hL + fbS_ * wL));
+ lineR_[w_] = sanitize((float)warm(lpR_, hR + fbS_ * wR));
+ w_ = (w_ + 1) & kMask;
+
+ // Width on the wet (M/S).
+ const double m = 0.5 * (wL + wR), s = 0.5 * (wL - wR) * widthS_;
+ const double wet = wetS_ * fade_;
+ const double norm = 1.0 / std::max(dryS_ + wetS_, 1e-3);
+ const float oL = (float)((dryS_ * xL + wet * (m + s)) * norm);
+ const float oR = (float)((dryS_ * xR + wet * (m - s)) * norm);
+ buf[i * 2] = oL; buf[i * 2 + 1] = oR;
+ outPkL = std::max(outPkL, std::fabs(oL));
+ outPkR = std::max(outPkR, std::fabs(oR));
+
+ if (!locked) {
+ frac_ += inc;
+ if (frac_ >= 1.0) { const double wr = std::floor(frac_); frac_ -= wr; cycle_ += (int64_t)wr; }
+ }
+ }
+
+ if (frames > 0) {
+ const float fall = std::pow(10.0f, -(20.0f * frames / (0.3f * (float)sr_)) / 20.0f);
+ inPkM_ = std::max(inPk, inPkM_ * fall);
+ outPkLM_ = std::max(outPkL, outPkLM_ * fall);
+ outPkRM_ = std::max(outPkR, outPkRM_ * fall);
+ const double dep = kDepMs[mode_] * amountS_;
+ for (int v = 0; v < 3; ++v) {
+ tauA_[v].store((float)tau[v], std::memory_order_relaxed);
+ const bool live = v < (mode_ == 1 ? 3 : 2);
+ centsA_[v].store(live ? (float)centsAt(dep, rateHz, frac_ + voicePhase(mode_, v, offS_)) : 0.0f,
+ std::memory_order_relaxed);
+ }
+ modeA_.store(mode_, std::memory_order_relaxed);
+ }
+ inPkA_.store(db(inPkM_), std::memory_order_relaxed);
+ outPkLA_.store(db(outPkLM_), std::memory_order_relaxed);
+ outPkRA_.store(db(outPkRM_), std::memory_order_relaxed);
+ cycleA_.store(cycle_, std::memory_order_relaxed);
+ fracA_.store((float)frac_, std::memory_order_relaxed);
+ rateA_.store((float)rateHz, std::memory_order_relaxed);
+ bpmA_.store((float)(60.0 * sr_ / spb), std::memory_order_relaxed);
+ playingA_.store(playing_ ? 1 : 0, std::memory_order_relaxed);
+ lockedA_.store(locked ? 1 : 0, std::memory_order_relaxed);
+ barA_.store((float)barBeats_, 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;
+ cpuA_.store((float)cpuS_, std::memory_order_relaxed);
+ }
+ }
+
+ enum { A_Restart = 0, A_Clear = 1, A_ResetMeters = 2 }; // deviceAction ids
+ void deviceAction(int32_t id, int32_t /*iarg*/, float /*farg*/) override {
+ if (id == A_Restart) restartReq_.store(true, std::memory_order_release);
+ else if (id == A_Clear) clearReq_.store(true, std::memory_order_release);
+ else if (id == A_ResetMeters) resetReq_.store(true, std::memory_order_release);
+ }
+
+ // Telemetry block. Called from the UI / MCP thread; lock-free against audio.
+ int32_t scopeRead(float* out, int32_t maxSamples) const override {
+ if (!out || maxSamples <= 0) return 0;
+ float t[kTele] = {};
+ const int64_t cyc = cycleA_.load(std::memory_order_relaxed);
+ const double fr = fracA_.load(std::memory_order_relaxed);
+ const int64_t base = cyc - (((cyc % 2) + 2) % 2); // the window starts on an even cycle
+ const int md = modeIndex();
+ const double bms = kBaseMs[md], dep = depMs();
+ const float rate = rateA_.load(std::memory_order_relaxed);
+ t[S_InPeak] = inPkA_.load(std::memory_order_relaxed);
+ t[S_OutPeakL] = outPkLA_.load(std::memory_order_relaxed);
+ t[S_OutPeakR] = outPkRA_.load(std::memory_order_relaxed);
+ const bool fresh = modeA_.load(std::memory_order_relaxed) == md && tauA_[0].load(std::memory_order_relaxed) > 0.0f;
+ for (int v = 0; v < 3; ++v) {
+ const bool live = v < voices();
+ t[S_Tau1 + v] = !live ? 0.0f : fresh ? tauA_[v].load(std::memory_order_relaxed) : (float)bms;
+ t[S_Cents1 + v] = !live || !fresh ? 0.0f : centsA_[v].load(std::memory_order_relaxed);
+ }
+ t[S_WinPhase] = (float)((double)(cyc - base) + fr);
+ t[S_RateHz] = rate;
+ t[S_Bpm] = bpmA_.load(std::memory_order_relaxed);
+ t[S_Playing] = (float)playingA_.load(std::memory_order_relaxed);
+ t[S_Locked] = (float)lockedA_.load(std::memory_order_relaxed);
+ t[S_SampleRate] = srA_.load(std::memory_order_relaxed);
+ t[S_BaseMs] = (float)bms;
+ t[S_TauMin] = (float)(bms - dep);
+ t[S_TauMax] = (float)(bms + dep);
+ t[S_MaxCents] = (float)maxCents(dep, rate);
+ t[S_Voices] = (float)voices();
+ t[S_Mode] = (float)md;
+ t[S_HpHz] = (float)hpfHz();
+ t[S_WidthPct] = (float)widthPct();
+ t[S_DivBeats] = (float)kDivBeats[divIndex()];
+ t[S_BarBeats] = barA_.load(std::memory_order_relaxed);
+ t[S_Cpu] = cpuA_.load(std::memory_order_relaxed);
+ t[S_Signal] = t[S_InPeak] > -70.0f ? 1.0f : 0.0f;
+ t[S_Cycles] = (float)cyc;
+ int32_t n = 0;
+ for (int k = 0; k < kTele && n < maxSamples; ++k) out[n++] = t[k];
+ return n;
+ }
+
+ const char* displayName() const override { return "Nota Chorus"; }
+ int32_t builtinKind() const override { return 25; }
+
+ int32_t paramCount() const override { return kNumParams; }
+ const char* paramName(int32_t i) const override {
+ switch (i) {
+ case Rate: return "Rate"; case Mode: return "Mode"; case Sync: return "Sync"; case Division: return "Division";
+ case Offset: return "Offset"; case Hpf: return "HPF"; case Amount: return "Amount"; case Feedback: return "Feedback";
+ case Width: return "Width"; case Warmth: return "Warmth"; case Mix: return "Mix";
+ default: return "";
+ }
+ }
+ float paramMin(int32_t /*i*/) const override { return 0.0f; }
+ float paramMax(int32_t /*i*/) const override { return 1.0f; }
+ float getParam(int32_t i) const override {
+ return (i >= 0 && i < kNumParams) ? p_[i].load(std::memory_order_relaxed) : 0.0f;
+ }
+ void setParam(int32_t i, float v) override {
+ if (i >= 0 && i < kNumParams) p_[i].store(std::clamp(v, 0.0f, 1.0f), std::memory_order_relaxed);
+ }
+
+ // 0 — a one-line status; 1 — the live reading; 2 — a guide to the parameter values.
+ std::string deviceText(int32_t id) const override {
+ char b[1400];
+ const int md = modeIndex();
+ if (id == 0) {
+ std::string s = kModeNames[md];
+ if (get(Sync) >= 0.5f) std::snprintf(b, sizeof b, " - sync %s", kDivNames[divIndex()]);
+ else std::snprintf(b, sizeof b, " - %.2f Hz", rateFreeHz());
+ s += b;
+ if (md == 1) s += " - 3 voices 120 deg apart";
+ else { std::snprintf(b, sizeof b, " - offset %.0f deg", offsetDeg()); s += b; }
+ const double hp = hpfHz();
+ if (hp > 0.0) { std::snprintf(b, sizeof b, " - HPF %.0f Hz", hp); s += b; }
+ else s += " - HPF off";
+ std::snprintf(b, sizeof b, " - amount %.0f %% - feedback %+.0f %% - width %.0f %% - warmth %.0f %%",
+ get(Amount) * 100.0f, feedback() * 100.0, widthPct(), get(Warmth) * 100.0f);
+ s += b;
+ if (md == 2) s += " - mix wet (vibrato)";
+ else { std::snprintf(b, sizeof b, " - mix %.0f %%", get(Mix) * 100.0f); s += b; }
+ return s;
+ }
+ if (id == 1) {
+ float sc[kTele];
+ scopeRead(sc, kTele);
+ auto lv = [](float v) { char t[24]; if (v <= -119.0f) std::snprintf(t, sizeof t, "-inf"); else std::snprintf(t, sizeof t, "%.1f", v); return std::string(t); };
+ std::string s;
+ std::snprintf(b, sizeof b, "LFO %.2f Hz (period %.0f ms)%s - window phase %.2f of 2 cycles - %d voices:",
+ sc[S_RateHz], 1000.0 / std::max(1e-3f, sc[S_RateHz]),
+ sc[S_Locked] > 0.5f ? " locked to the song" : get(Sync) >= 0.5f ? " free-running at the synced rate" : "",
+ sc[S_WinPhase], (int)sc[S_Voices]);
+ s += b;
+ for (int v = 0; v < (int)sc[S_Voices]; ++v) {
+ std::snprintf(b, sizeof b, " %s %.2f ms %+.1f ct%s", voiceName(md, v), sc[S_Tau1 + v], sc[S_Cents1 + v],
+ v + 1 < (int)sc[S_Voices] ? "," : "");
+ s += b;
+ }
+ std::snprintf(b, sizeof b,
+ " - sweep %.2f .. %.2f ms - detune up to +/-%.1f ct - in %s dBFS - out L %s, R %s dBFS - "
+ "%.1f BPM, bar %.2g beats - transport %s - CPU %.2f %%",
+ sc[S_TauMin], sc[S_TauMax], sc[S_MaxCents], lv(sc[S_InPeak]).c_str(), lv(sc[S_OutPeakL]).c_str(),
+ lv(sc[S_OutPeakR]).c_str(), sc[S_Bpm], sc[S_BarBeats], sc[S_Playing] > 0.5f ? "playing" : "stopped",
+ sc[S_Cpu] * 100.0f);
+ s += b;
+ return s;
+ }
+ if (id == 2) {
+ std::string divs;
+ for (int i = 0; i < kDivs; ++i) {
+ std::snprintf(b, sizeof b, "%s%.3f = %s", i ? ", " : "", (double)i / (kDivs - 1), kDivNames[i]);
+ divs += b;
+ }
+ return "All params are normalized 0..1. Mode: 0 Classic (2 voices L / R, tau 8 ms +/- 5 ms * Amount), 0.5 Ensemble "
+ "(3 voices 120 deg apart, left / centre / right, tau 12 +/- 6 ms), 1 Vibrato (the L / R pair on 3 +/- 2.5 ms, "
+ "wet only - Mix is ignored). Rate: the free LFO rate, exponential 0.02 Hz (0) .. 8 Hz (1) (0.269 = 0.1 Hz, "
+ "0.384 = 0.2 Hz, 0.537 = 0.5 Hz, 0.616 = 0.8 Hz, 0.653 = 1 Hz, 0.769 = 2 Hz, 0.884 = 4 Hz, 0.938 = 5.5 Hz). "
+ "Offset: the right voice's LFO behind the left, 0..1 = 0..180 deg (Classic / Vibrato). HPF: the wet path's "
+ "high-pass, 0 = off, else exponential 20 Hz .. 2 kHz (0.15 = 40 Hz, 0.35 = 100 Hz, 0.5 = 200 Hz, 0.65 = 400 Hz). "
+ "Amount: how far the delay swings, 0..1 of the mode's range. Feedback: bipolar, (v - 0.5) * 1.8 = -90 % .. +90 % "
+ "(0.5 = none); past 60 % it rings like a flanger. Width: the wet's stereo width, 0..1 = 0..200 % (0.5 = 100 %; "
+ "0 = mono; above 100 % lifts the side up to +6 dB). Warmth: 0 = clean, 1 = a dark, saturated bucket-brigade "
+ "line (low-pass 20 kHz .. 2.5 kHz). Mix: 0 = dry, 0.5 = dry and wet equal, 1 = wet only. Sync: >= 0.5 takes "
+ "the rate from the tempo (Division) and locks the LFO to the song position while the transport plays, "
+ "restarting on the bar. Division (with Sync): " + divs + ".";
+ }
+ return {};
+ }
+
+ // ---- shared with the card / MCP through the guide above ----------------------------
+ int modeIndex() const { return std::clamp((int)std::lround(get(Mode) * 2.0f), 0, 2); }
+ int divIndex() const { return std::clamp((int)std::lround(get(Division) * (kDivs - 1)), 0, kDivs - 1); }
+ int voices() const { return modeIndex() == 1 ? 3 : 2; }
+ double rateFreeHz() const { return expMap(get(Rate), kRateLo, kRateHi); }
+ double hpfHz() const { const float v = get(Hpf); return v < 0.01f ? 0.0 : expMap(v, kHpLo, kHpHi); }
+ double feedback() const { return (std::clamp((double)get(Feedback), 0.0, 1.0) - 0.5) * 2.0 * kFbMax; }
+ double offsetDeg() const { return std::clamp((double)get(Offset), 0.0, 1.0) * 180.0; }
+ double widthPct() const { return std::clamp((double)get(Width), 0.0, 1.0) * kWidthMax * 100.0; }
+ double depMs() const { return kDepMs[modeIndex()] * std::clamp((double)get(Amount), 0.0, 1.0); }
+
+ // The detune of a voice whose delay swings ±dep ms at rate Hz, at LFO phase p (cycles): the
+ // read head's speed is 1 − dτ/dt.
+ static double centsAt(double depMs, double rateHz, double p) {
+ const double dt = depMs * 0.001 * 2.0 * kPi * rateHz * std::cos(2.0 * kPi * p);
+ return 1200.0 * std::log2(std::max(1.0 - dt, 0.01));
+ }
+ static double maxCents(double depMs, double rateHz) {
+ return 1200.0 * std::log2(1.0 + depMs * 0.001 * 2.0 * kPi * rateHz);
+ }
+
+private:
+ static constexpr double kPi = 3.14159265358979323846;
+ static constexpr double kCentre = 0.70710678118654752; // the centre voice into each side (−3 dB)
+ static constexpr double kEnsNorm = 1.0 / 1.4142135623730951;
+ static constexpr int kBuf = 16384; // ≥ 21 ms at 768 kHz
+ static constexpr int kMask = kBuf - 1;
+
+ struct MixW { double dry, wet; };
+ MixW mixWeights(int mode) const {
+ if (mode == 2) return { 0.0, 1.0 }; // Vibrato: wet only
+ const double mix = std::clamp((double)get(Mix), 0.0, 1.0);
+ return { std::min(1.0, 2.0 * (1.0 - mix)), std::min(1.0, 2.0 * mix) };
+ }
+ // The LFO phase of voice v (cycles): Ensemble spreads three voices 120° apart; the pair runs
+ // the right voice `off` cycles behind the left.
+ static double voicePhase(int mode, int v, double off) {
+ if (mode == 1) return v / 3.0;
+ return v == 0 ? 0.0 : off;
+ }
+ static const char* voiceName(int mode, int v) {
+ if (mode == 1) return v == 0 ? "V1" : v == 1 ? "V2" : "V3";
+ return v == 0 ? "L" : "R";
+ }
+
+ // TPT SVF high-pass, one channel.
+ struct Svf { double s1 = 0.0, s2 = 0.0; };
+ double hpTick(Svf& f, double x) {
+ const double hp = (x - (hpK_ + hpG_) * f.s1 - f.s2) * hpA1_;
+ const double v1 = hpG_ * hp, bp = v1 + f.s1; f.s1 = bp + v1;
+ const double v2 = hpG_ * bp, lp = v2 + f.s2; f.s2 = lp + v2;
+ return hp;
+ }
+ // The warmth stage: a one-pole low-pass and a soft saturation, both fading in with Warmth.
+ double warm(double& z, double x) const {
+ if (warmS_ < 1e-4) { z = x; return x; }
+ z += lpA_ * (x - z);
+ const double k = 1.0 + 2.5 * warmS_;
+ return z + warmS_ * (std::tanh(k * z) / k - z);
+ }
+
+ float get(int i) const { return p_[i].load(std::memory_order_relaxed); }
+ static double expMap(float v, double lo, double hi) { return lo * std::pow(hi / lo, std::clamp((double)v, 0.0, 1.0)); }
+ static float db(float lin) { return lin > 1e-6f ? 20.0f * std::log10(lin) : -120.0f; }
+ static float sanitize(float v) { return std::isfinite(v) && std::fabs(v) > 1e-20f ? std::clamp(v, -64.0f, 64.0f) : 0.0f; }
+
+ // 4-point Hermite read `d` samples behind the write head (d ≥ 2, so every tap is written).
+ float readLine(const float* line, double d) const {
+ const double r = (double)w_ - d;
+ const double fl = std::floor(r);
+ const float t = (float)(r - fl);
+ const int i0 = (int)((int64_t)fl & kMask);
+ const float ym1 = line[(i0 - 1) & kMask], y0 = line[i0], y1 = line[(i0 + 1) & kMask], y2 = line[(i0 + 2) & kMask];
+ const float c1 = 0.5f * (y1 - ym1);
+ const float c2 = ym1 - 2.5f * y0 + 2.0f * y1 - 0.5f * y2;
+ const float c3 = 0.5f * (y2 - ym1) + 1.5f * (y0 - y1);
+ return ((c3 * t + c2) * t + c1) * t + y0;
+ }
+
+ void clearLines() {
+ std::memset(lineL_, 0, sizeof lineL_); std::memset(lineR_, 0, sizeof lineR_); w_ = 0;
+ hpL_ = hpR_ = Svf{}; lpL_ = lpR_ = 0.0;
+ }
+ void resetMeters() { inPkM_ = outPkLM_ = outPkRM_ = 0.0f; }
+
+ double sr_ = 44100.0;
+ std::atomic<float> p_[kNumParams] = {};
+ float lineL_[kBuf] = {}, lineR_[kBuf] = {};
+ int w_ = 0;
+ int64_t cycle_ = 0;
+ double frac_ = 0.0;
+ bool snap_ = true;
+ int mode_ = 0;
+ double fade_ = 1.0;
+ double amountS_ = 0.4, fbS_ = 0.0, offS_ = 0.5, widthS_ = 1.0, warmS_ = 0.0, dryS_ = 1.0, wetS_ = 1.0;
+ double hpS_ = 0.0, hpG_ = 0.0, hpK_ = 1.4142135623730951, hpA1_ = 1.0, lpA_ = 1.0;
+ Svf hpL_, hpR_;
+ double lpL_ = 0.0, lpR_ = 0.0;
+ double beatStart_ = 0.0, spb_ = 0.0, barBeats_ = 4.0;
+ bool playing_ = false;
+ float inPkM_ = 0.0f, outPkLM_ = 0.0f, outPkRM_ = 0.0f;
+ double cpuS_ = 0.0;
+ std::atomic<bool> restartReq_{false}, clearReq_{false}, resetReq_{false};
+ std::atomic<float> srA_{44100.0f}, inPkA_{-120.0f}, outPkLA_{-120.0f}, outPkRA_{-120.0f};
+ std::atomic<float> tauA_[3] = {}, centsA_[3] = {};
+ std::atomic<float> fracA_{0.0f}, rateA_{0.8f}, bpmA_{120.0f}, barA_{4.0f}, cpuA_{0.0f};
+ std::atomic<int64_t> cycleA_{0};
+ std::atomic<int> playingA_{0}, lockedA_{0}, modeA_{0};
+};
+
+} // namespace nota
diff --git a/src/native/nota.engine/src/Engine_Devices.cpp b/src/native/nota.engine/src/Engine_Devices.cpp
index e79ed602..5c20d8bc 100644
--- a/src/native/nota.engine/src/Engine_Devices.cpp
+++ b/src/native/nota.engine/src/Engine_Devices.cpp
@@ -24,6 +24,7 @@
#include "Lens.h"
#include "Flanger.h"
#include "Phaser.h"
+#include "Chorus.h"
#include "Prism.h"
#include "Ceiling.h"
#include "Strata.h"
@@ -450,6 +451,7 @@ int32_t Engine::addTrackBuiltinDevice(int32_t trackId, int32_t kind) {
else if (kind == 22) dev = std::make_shared<Lens>();
else if (kind == 23) dev = std::make_shared<Flanger>();
else if (kind == 24) dev = std::make_shared<Phaser>();
+ else if (kind == 25) dev = std::make_shared<Chorus>();
else return -1;
dev->setSampleRate(transport_.sampleRate() > 0 ? transport_.sampleRate() : 44100.0, kMaxBlock);
if (kind == 5) if (auto* rk = dynamic_cast<RackDevice*>(dev.get())) rk->addChain(-1); // one pass-through chain
@@ -517,6 +519,7 @@ std::shared_ptr<Device> Engine::cloneDevice(const Device& src) const {
case 22: d = std::make_shared<Lens>(); break;
case 23: d = std::make_shared<Flanger>(); break;
case 24: d = std::make_shared<Phaser>(); break;
+ case 25: d = std::make_shared<Chorus>(); break;
default: d = src.clone(); break; // hosted plugin
}
if (!d) return nullptr;
@@ -596,6 +599,7 @@ static std::shared_ptr<Device> makeBuiltinDevice(int32_t kind) {
case 22: return std::make_shared<Lens>();
case 23: return std::make_shared<Flanger>();
case 24: return std::make_shared<Phaser>();
+ case 25: return std::make_shared<Chorus>();
default: return nullptr; // Rack / plugin: no simple per-param default
}
}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 4155bed7..91203e64 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -9266,6 +9266,224 @@ Console.WriteLine("-- Nota Phaser (effect kind 24) --");
}
}
+// ===================== Nota Chorus (effect kind 25) =====================
+Console.WriteLine("-- Nota Chorus (effect kind 25) --");
+{
+ // Params (Chorus.h): 0 Rate, 1 Mode, 2 Sync, 3 Division, 4 Offset, 5 HPF, 6 Amount, 7 Feedback, 8 Width, 9 Warmth, 10 Mix.
+ // Scope: 0 in, 1 out L, 2 out R (dBFS) · 3..5 τ per voice ms · 6..8 cents per voice · 9 window phase · 10 rate Hz ·
+ // 11 BPM · 12 playing · 13 locked · 14 sample rate · 15 base ms · 16 / 17 τ min / max · 18 max cents · 19 voices ·
+ // 20 mode · 21 HPF Hz · 22 width % · 23 division beats · 24 bar beats · 25 CPU · 26 signal · 27 cycles.
+ using var ce = new NotaEngine();
+ int ct = ce.AddAudioTrack();
+ ce.AddAudioClip(ct, wav, 0.0); // 1 s sine @ 440 Hz
+ int cdi = ce.AddBuiltinDevice(ct, 25);
+ Check(cdi >= 0, "add Nota Chorus device");
+ Check(ce.DeviceName(ct, cdi) == "Nota Chorus", $"device is Nota Chorus (got '{ce.DeviceName(ct, cdi)}')");
+ Check(ce.TrackDeviceBuiltinKind(ct, cdi) == 25, "device reports builtin kind 25");
+ int cpc = ce.DeviceParamCount(ct, cdi);
+ Check(cpc == 11, $"Nota Chorus exposes 11 params ({cpc})");
+ var cnames = Enumerable.Range(0, cpc).Select(i => ce.DeviceParamName(ct, cdi, i)).ToArray();
+ Check(string.Join(",", cnames) == "Rate,Mode,Sync,Division,Offset,HPF,Amount,Feedback,Width,Warmth,Mix", $"param layout ({string.Join(",", cnames)})");
+ Check(Math.Abs(ce.DeviceParamDefault(ct, cdi, 0) - 0.6157f) < 1e-3f && ce.DeviceParamDefault(ct, cdi, 1) == 0f
+ && ce.DeviceParamDefault(ct, cdi, 4) == 1f && Math.Abs(ce.DeviceParamDefault(ct, cdi, 6) - 0.4f) < 1e-4f
+ && ce.DeviceParamDefault(ct, cdi, 8) == 0.5f && ce.DeviceParamDefault(ct, cdi, 10) == 0.5f,
+ "defaults: Classic, 0.80 Hz, offset 180°, Amount 40 %, Width 100 %, Mix 50 % (Wide Duo)");
+ ce.DeviceSetParam(ct, cdi, 6, 0.42f);
+ Check(Math.Abs(ce.DeviceGetParam(ct, cdi, 6) - 0.42f) < 1e-4f, "device param set/get round-trips");
+
+ var cbuf = new float[4096 * 2];
+ var csc = new float[32];
+ bool CFinite() { foreach (var v in cbuf) if (!float.IsFinite(v) || Math.Abs(v) > 8f) return false; return true; }
+ void CRender(int frames = 4096, double at = 0.2) { ce.Seek(at); ce.Play(); ce.RenderOffline(cbuf, frames); ce.StopTransport(); }
+ int CScope() => ce.DeviceScope(ct, cdi, csc, csc.Length);
+ float CTail() { double sum = 0; for (int i = 2048 * 2; i < 4096 * 2; i++) sum += cbuf[i] * (double)cbuf[i]; return (float)Math.Sqrt(sum / (2048 * 2)); }
+ void CDefaults() { for (int i = 0; i < cpc; i++) ce.DeviceSetParam(ct, cdi, i, ce.DeviceParamDefault(ct, cdi, i)); }
+ ce.SetBpm(120);
+
+ // Every mode renders audible + finite, incl. extreme feedback both ways and full warmth.
+ for (int md = 0; md < 3; md++)
+ foreach (float fbn in new[] { 0f, 0.5f, 1f })
+ {
+ ce.DeviceSetParam(ct, cdi, 1, md / 2f);
+ ce.DeviceSetParam(ct, cdi, 7, fbn);
+ ce.DeviceSetParam(ct, cdi, 9, fbn);
+ CRender(); CRender();
+ CScope();
+ Check(Rms(cbuf, 4096) > 1e-3f && CFinite() && (int)csc[20] == md, $"Chorus mode {md} feedback {(fbn - 0.5f) * 180:+0;-0} % is audible + stable");
+ }
+ CDefaults();
+
+ // The sweep: Classic τ = 8 ± 5 · Amount ms, the detune ±1200·log2(1 + dep·2π·rate).
+ CRender(); CScope();
+ double cDep = 5 * 0.4, cRate = 0.02 * Math.Pow(400, ce.DeviceGetParam(ct, cdi, 0));
+ Check(Math.Abs(csc[15] - 8f) < 1e-3f && Math.Abs(csc[16] - (8 - cDep)) < 1e-3f && Math.Abs(csc[17] - (8 + cDep)) < 1e-3f,
+ $"Classic sweeps 8 ± 2 ms at Amount 40 % ({csc[16]:0.00} … {csc[17]:0.00})");
+ double cMax = 1200 * Math.Log2(1 + cDep / 1000 * 2 * Math.PI * cRate);
+ Check(Math.Abs(csc[18] - cMax) < 0.05 && (int)csc[19] == 2, $"max detune ±{csc[18]:0.00} ct (expected {cMax:0.00}), 2 voices");
+ Check(csc[3] >= csc[16] - 1e-3f && csc[3] <= csc[17] + 1e-3f && Math.Abs(csc[6]) <= cMax + 0.05, $"voice L now in range ({csc[3]:0.00} ms, {csc[6]:+0.0} ct)");
+ // Offset 180°: the right voice mirrors the left around the centre; 0°: they move together.
+ Check(Math.Abs(csc[3] + csc[4] - 16f) < 0.02f, $"Offset 180°: L and R mirror around 8 ms ({csc[3]:0.00} / {csc[4]:0.00})");
+ ce.DeviceSetParam(ct, cdi, 4, 0f);
+ CRender(); CRender(); CScope();
+ Check(Math.Abs(csc[3] - csc[4]) < 0.01f, $"Offset 0°: both voices move together ({csc[3]:0.00} / {csc[4]:0.00})");
+ CDefaults();
+
+ // Ensemble: three voices 120° apart around 12 ms (their sines sum to zero).
+ ce.DeviceSetParam(ct, cdi, 1, 0.5f);
+ CRender(); CRender(); CScope();
+ Check((int)csc[19] == 3 && Math.Abs(csc[15] - 12f) < 1e-3f && Math.Abs(csc[3] + csc[4] + csc[5] - 36f) < 0.03f,
+ $"Ensemble: 3 voices around 12 ms ({csc[3]:0.00} / {csc[4]:0.00} / {csc[5]:0.00})");
+ CDefaults();
+
+ // Mix 0 is dry; Vibrato is wet only whatever the Mix says.
+ ce.SetDeviceBypassed(ct, cdi, true); CRender(); var cByp = (float[])cbuf.Clone(); float cBypRms = CTail(); ce.SetDeviceBypassed(ct, cdi, false);
+ float CDiff() { double d = 0; for (int i = 2048 * 2; i < 4096 * 2; i++) d = Math.Max(d, Math.Abs(cbuf[i] - cByp[i])); return (float)d; }
+ ce.DeviceSetParam(ct, cdi, 10, 0f);
+ CRender(); CRender();
+ Check(CDiff() < 1e-3f, $"Mix 0 passes the dry signal (max diff {CDiff():0.00000})");
+ ce.DeviceSetParam(ct, cdi, 1, 1f); // Vibrato, Mix still 0
+ ce.DeviceSetParam(ct, cdi, 6, 0f); // Amount 0: a static 3 ms delay
+ CRender(); CRender();
+ Check(CDiff() > 0.05f && Math.Abs(CTail() - cBypRms) < cBypRms * 0.05f, $"Vibrato ignores Mix: wet only, level kept ({CTail():0.000} vs {cBypRms:0.000})");
+ CDefaults();
+
+ // Width 0 folds the wet to mono: L = R for the mono test tone.
+ ce.DeviceSetParam(ct, cdi, 8, 0f);
+ CRender(); CRender();
+ float lr = 0f; for (int i = 2048; i < 4096; i++) lr = Math.Max(lr, Math.Abs(cbuf[i * 2] - cbuf[i * 2 + 1]));
+ ce.DeviceSetParam(ct, cdi, 8, 0.5f);
+ CRender(); CRender();
+ float lr1 = 0f; for (int i = 2048; i < 4096; i++) lr1 = Math.Max(lr1, Math.Abs(cbuf[i * 2] - cbuf[i * 2 + 1]));
+ Check(lr < 1e-4f && lr1 > 1e-3f, $"Width 0 % is mono, 100 % is stereo (L−R {lr:0.00000} / {lr1:0.0000})");
+
+ // HPF: a 2 kHz high-pass keeps a 440 Hz tone out of the wet.
+ ce.DeviceSetParam(ct, cdi, 10, 1f);
+ CRender(); CRender(); float cWet = CTail();
+ ce.DeviceSetParam(ct, cdi, 5, 1f);
+ CRender(); CRender(); float cHp = CTail();
+ CScope();
+ Check(cHp < cWet * 0.1f && Math.Abs(csc[21] - 2000f) < 1f, $"HPF 2 kHz takes the 440 Hz tone out of the wet ({20 * Math.Log10(cHp / Math.Max(1e-9f, cWet)):0.0} dB)");
+ CDefaults();
+
+ // Sync: the rate follows the tempo and the LFO locks to the song position.
+ ce.DeviceSetParam(ct, cdi, 2, 1f);
+ ce.DeviceSetParam(ct, cdi, 3, 4f / 8f); // 1/4 → 2 Hz at 120 BPM
+ CRender(); CScope();
+ Check(Math.Abs(csc[10] - 2f) < 1e-3f && csc[13] > 0.5f, $"Sync 1/4 at 120 BPM runs at 2 Hz, locked ({csc[10]:0.000})");
+ Check(ce.DeviceText(ct, cdi, 0).Contains("sync 1/4"), $"status names the division ('{ce.DeviceText(ct, cdi, 0)}')");
+ ce.DeviceSetParam(ct, cdi, 3, 0f); // 4/1 → 0.125 Hz
+ CRender(); CScope();
+ Check(Math.Abs(csc[10] - 0.125f) < 1e-4f, $"Sync 4/1 at 120 BPM runs at 0.125 Hz ({csc[10]:0.0000})");
+ ce.SetBpm(90);
+ ce.DeviceSetParam(ct, cdi, 3, 4f / 8f);
+ CRender(); CScope();
+ Check(Math.Abs(csc[10] - 1.5f) < 1e-3f, $"the synced rate follows a tempo change (90 BPM → {csc[10]:0.000} Hz)");
+ ce.SetBpm(120);
+ CDefaults();
+
+ // A mode change mid-signal fades instead of clicking.
+ ce.DeviceSetParam(ct, cdi, 10, 1f);
+ CRender();
+ ce.Seek(0.3); ce.Play(); ce.RenderOffline(cbuf, 512);
+ ce.DeviceSetParam(ct, cdi, 1, 0.5f);
+ ce.RenderOffline(cbuf, 4096); ce.StopTransport();
+ float cjump = 0f; for (int i = 2; i < 4096 * 2; i += 2) cjump = Math.Max(cjump, Math.Abs(cbuf[i] - cbuf[i - 2]));
+ Check(cjump < 0.12f && CFinite(), $"switching Classic → Ensemble doesn't click (max step {cjump:0.000})");
+ CDefaults();
+
+ // Actions: restart the LFO, clear a ringing loop.
+ ce.DeviceSetParam(ct, cdi, 0, 1f);
+ CRender(); CScope();
+ Check(csc[27] >= 1f, $"free run: cycles run ({csc[27]:0})");
+ ce.DeviceAction(ct, cdi, 0, 0, 0f);
+ CRender(32); CScope();
+ Check(csc[27] < 1f && csc[9] < 0.05f, $"device_action 0 restarts the LFO (cycle {csc[27]:0}, phase {csc[9]:0.000})");
+ ce.DeviceSetParam(ct, cdi, 7, 1f); // +90 %
+ ce.DeviceSetParam(ct, cdi, 10, 1f); // wet only
+ CRender(4096, 0.9);
+ CRender(256, 1.05); float cring = Rms(cbuf, 256);
+ CRender(4096, 0.9);
+ ce.DeviceAction(ct, cdi, 1, 0, 0f);
+ CRender(256, 1.05); float ccleared = Rms(cbuf, 256);
+ Check(cring > 1e-2f && ccleared < 1e-5f, $"device_action 1 clears the ringing lines (ring {cring:0.0e0} → {ccleared:0.0e0})");
+ CDefaults();
+
+ Check(ce.DeviceText(ct, cdi, 1).Contains("voices") && ce.DeviceText(ct, cdi, 2).Contains("1/8T") && ce.DeviceText(ct, cdi, 2).Contains("Ensemble"),
+ "device text 1 = live reading, 2 = parameter guide with the mode and division tables");
+
+ // Clone.
+ ce.DeviceSetParam(ct, cdi, 7, 0.2f);
+ ce.DeviceSetParam(ct, cdi, 1, 1f);
+ int cdup = ce.DuplicateTrack(ct);
+ Check(cdup > 0 && ce.TrackDeviceBuiltinKind(cdup, cdi) == 25 && Math.Abs(ce.DeviceGetParam(cdup, cdi, 7) - 0.2f) < 1e-4f
+ && ce.DeviceGetParam(cdup, cdi, 1) == 1f, "duplicate track clones the Chorus params");
+ ce.RemoveTrack(cdup);
+ CDefaults();
+
+ // Automation drives Amount and Mode.
+ int clane = ce.AddAutomationLane(ct, AutomationTarget.DeviceParam, cdi, 6);
+ Check(clane >= 0, "add Chorus Amount automation lane");
+ ce.SetAutomationPoints(ct, clane, new[] { new AutomationPoint(0.0, 0.1f), new AutomationPoint(2.0, 0.9f) });
+ int clane2 = ce.AddAutomationLane(ct, AutomationTarget.DeviceParam, cdi, 1);
+ ce.SetAutomationPoints(ct, clane2, new[] { new AutomationPoint(0.0, 0f), new AutomationPoint(2.0, 1f) });
+ ce.Seek(1.99); ce.Play(); ce.RenderOffline(cbuf, 4096); ce.StopTransport();
+ CScope();
+ Check(ce.DeviceGetParam(ct, cdi, 6) > 0.8f && (int)csc[20] == 2, $"automation drives Chorus Amount ({ce.DeviceGetParam(ct, cdi, 6):F2}) and Mode ({csc[20]:0})");
+ ce.RemoveAutomationLane(ct, clane2);
+ ce.RemoveAutomationLane(ct, clane);
+ CDefaults();
+
+ // MCP: listed, read and set in units.
+ {
+ var ctools = new Nota.Mcp.Tools.DeviceTools(ce, new Nota.SmokeTest.SyncDispatch(), new Nota.SmokeTest.NoRefresh());
+ Check(ctools.ListDeviceKinds().Any(k => k.Kind == 25 && k.Name == "Nota Chorus"), "MCP lists Nota Chorus (kind 25)");
+ CRender();
+ var r0 = ctools.ReadChorus(ct, cdi).Result;
+ Check(r0.Mode == "Classic" && r0.Voices == 2 && !r0.Sync && Math.Abs(r0.RateHz - 0.8) < 0.01 && r0.OffsetDeg == 180 && r0.HpfHz == 0
+ && Math.Abs(r0.AmountPercent - 40) < 0.1 && r0.FeedbackPercent == 0 && r0.WidthPercent == 100 && r0.MixPercent == 50
+ && r0.State == "2 voices" && r0.VoicesNow.Count == 2 && Math.Abs(r0.DelayMinMs - 6) < 0.01 && r0.Summary.Length > 0 && r0.Live.Length > 0,
+ $"MCP read_chorus reports the defaults ({r0.Mode}, {r0.RateHz} Hz, {r0.AmountPercent} %, {r0.State})");
+ var r1 = ctools.SetChorus(ct, cdi, mode: "ensemble", division: "1/8T", hpfHz: 200, amountPercent: 65, feedbackPercent: -30,
+ widthPercent: 160, warmthPercent: 35, mixPercent: 60).Result;
+ Check(r1.Mode == "Ensemble" && r1.Voices == 3 && r1.Sync && r1.Division == "1/8T" && Math.Abs(r1.HpfHz - 200) < 1
+ && Math.Abs(r1.AmountPercent - 65) < 0.1 && Math.Abs(r1.FeedbackPercent + 30) < 0.6 && r1.WidthPercent == 160
+ && Math.Abs(r1.WarmthPercent - 35) < 0.1 && Math.Abs(r1.MixPercent - 60) < 0.1 && r1.OffsetDeg == 120 && r1.State == "3 voices",
+ $"MCP set_chorus writes in units ({r1.Mode}, {r1.Division}, {r1.HpfHz} Hz, {r1.FeedbackPercent} %)");
+ var r2 = ctools.SetChorus(ct, cdi, rateHz: 5.5, mode: "vibrato", hpfHz: 0).Result;
+ Check(!r2.Sync && Math.Abs(0.02 * Math.Pow(400, ce.DeviceGetParam(ct, cdi, 0)) - 5.5) < 1e-3 && r2.MixPercent == 100
+ && r2.State == "wet only" && r2.HpfHz == 0, "set_chorus rateHz switches to free run; Vibrato reads wet only");
+ bool threw = false, threw2 = false;
+ try { ctools.SetChorus(ct, cdi, division: "1/5").GetAwaiter().GetResult(); } catch (ArgumentException) { threw = true; }
+ try { ctools.SetChorus(ct, cdi, mode: "flanger").GetAwaiter().GetResult(); } catch (ArgumentException) { threw2 = true; }
+ Check(threw && threw2, "set_chorus rejects an unknown division or mode");
+ CDefaults();
+ }
+
+ // Factory presets: ≥ 25, every named param exists, each applies in place and renders.
+ {
+ var names = new HashSet<string>(cnames);
+ var cat = new FactoryPresetCatalog();
+ var mine = cat.All().Where(p => !p.IsInstrument && !p.IsMidiEffect && p.BuiltinKind == 25).ToList();
+ Check(mine.Count >= 25, $"Nota Chorus ships ≥ 25 factory presets ({mine.Count})");
+ 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 Chorus preset param name exists{(bad.Count > 0 ? " — bad: " + string.Join(", ", bad) : "")}");
+ int pf = 0;
+ foreach (var p in mine)
+ {
+ if (cat.ApplyInPlace(ce, p.Id, ct, cdi).Length != 0) { pf++; continue; }
+ CRender();
+ if (!CFinite() || Rms(cbuf, 4096) < 1e-3f) pf++;
+ }
+ Check(pf == 0, $"every Chorus preset applies and renders ({pf} failed)");
+ cat.ApplyInPlace(ce, "chorus/String Machine", ct, cdi);
+ Check(Math.Abs(ce.DeviceGetParam(ct, cdi, 1) - 0.5f) < 1e-3f && ce.DeviceGetParam(ct, cdi, 2) > 0.5f
+ && Math.Abs(ce.DeviceGetParam(ct, cdi, 3) - 1f / 8f) < 1e-3f, "String Machine preset: Ensemble, synced 2/1");
+ cat.ApplyInPlace(ce, "chorus/Wide Duo", ct, cdi);
+ bool isDefault = Enumerable.Range(0, cpc).All(i => Math.Abs(ce.DeviceGetParam(ct, cdi, i) - ce.DeviceParamDefault(ct, cdi, i)) < 2e-3f);
+ Check(isDefault, "Wide Duo preset = the device defaults");
+ }
+}
+
// ===================== Nota Auto Shift (effect kind 10) ===================
Console.WriteLine("-- Nota Auto Shift (effect kind 10) --");
{