Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
Redesign of EQ-3
Egor Khindikaynenb77756d8395f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2f65eb94..28a67cb6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -55,6 +55,34 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.level, the effective attack and release, look-ahead latency and how often it kicked in.### Changed+- **Nota EQ-3 is redrawn as a DJ isolator.** The card follows the new mockup on the+ 700 × 260 frame. The crossover slider row is gone; you now drag the crossovers on the graph:+ - **Band strips.** LOW, MID and HIGH each get a strip in their own colour with the band's+ frequency span, a fader from −24 to +6 dB, the value and a KILL. The fader moves by+ relative drag in 0.5 dB steps with a 0 dB detent; hold Shift for 0.1 dB steps.+ Double-click returns it to 0 dB and lifts the kill.+ - **Graph.** Each band's own curve is drawn thin in its colour, the sum in brass, and the+ output spectrum (now from the engine's FFT) behind them. The two crossovers are dashed+ lines with handles along the top. Drag a handle left or right; the low/mid crossover stays+ at most half the mid/high one. Drag anywhere else to ride the gain of the band under the+ pointer. Double-click a handle or a band to reset it.+ - **Over the graph.** The crossover readouts, Output (drag, double-click resets), Range and+ Slope (24 / 48 dB). A status strip closes the card: slope, crossovers, kills, range,+ output, then sample rate, latency and CPU.+ - **Range** is a new parameter. It picks the fader throw: +6 (−24 … +6 dB, the default for+ a new EQ-3) or ±15 (the classic range). Switching it keeps each band's dB. Projects,+ racks and presets saved before it open in the ±15 range and sound exactly as before.+ - **30 factory presets**: DJ kills, bass swaps and isolations, scoops and smiles, clean-up+ curves, and character presets (telephone, AM radio, megaphone). The six earlier presets+ keep their names.+ - **MCP: `read_eq3` and `set_eq3`.** `read_eq3` reports the settings, each band's gain,+ kill, level and gain now, the in / out peaks and the output spectrum. `set_eq3` plays the+ EQ in dB and Hz in one call, recorded like a hand edit. `get_device_text` gives a summary,+ a live reading and a parameter guide, and `device_action` 0 resets the meters.+- **Nota EQ-3 now sums flat.** The 48 dB/oct slope is now a true Linkwitz-Riley 8.+ Before, it left a 6 dB dip at each crossover. The low band is also phase-aligned with the+ mid/high split, so with every band at 0 dB the output matches the input at any crossover+ setting and either slope.- **Nota Dynamic EQ-8 is redrawn around its graph, and each band gets its own key.** The cardfollows the new mockup on the 700 × 260 frame: the response graph takes almost the wholewidth, a row of eight band chips sits over it, the selected band is edited in a panel on thediff --git a/FEATURES.md b/FEATURES.mdindex d37d0150..70f9df21 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -424,9 +424,12 @@ and user presets, automation, persistence and cloning.(Tube/Diode/Tape/Fuzz/Digital/Fold), Serial/Parallel/Mid-Side/Multiband routings,Amount/Tone/Wet, Bias/Width, LFO→Drive and Env→Tone; a transfer curve and a harmonicschart; **OVERSAMPLE** (Off/2×/4×/8×).-- **Nota EQ-3** (16) — 3-band performance EQ: Low/Mid/High faders with a 0 dB detent and- KILL buttons, two crossover frequencies, 24/48 dB/oct slope (Linkwitz-Riley); a response- curve with a real-time spectrum.+- **Nota EQ-3** (16) — three-band DJ isolator: Low / Mid / High faders (−24 … +6 dB, or the+ Classic ±15 dB range) with a 0 dB detent and KILL buttons, two crossovers, 24 / 48 dB/oct+ Linkwitz-Riley slopes (phase-aligned, flat at unity), output gain. A response graph with each+ band's curve, the brass sum and the output spectrum (engine FFT) — drag the crossover handles,+ or ride a band's gain in its zone; a status strip; 30 factory presets; MCP `read_eq3`,+ `set_eq3`.- **Nota Level** (18) — automatic loudness matching (LUFS): LUFS measurement (BS.1770),AUTO/MATCH, true-peak safe, sidechain (match to reference); loudness history andIN/OUT/TP/correlation meters.diff --git a/src/managed/Nota.App/Controls/ControlExtensions.cs b/src/managed/Nota.App/Controls/ControlExtensions.csindex 9a2c2f2e..44cda6bd 100644--- a/src/managed/Nota.App/Controls/ControlExtensions.cs+++ b/src/managed/Nota.App/Controls/ControlExtensions.cs@@ -18,4 +18,7 @@ internal static class ControlExtensions/// </summary>public static void BindResource(this Control control, AvaloniaProperty property, string key)=> control.Bind(property, control.GetResourceObservable(key));++ /// <summary>Adds <paramref name="child"/> to a DockPanel, docked to <paramref name="dock"/>.</summary>+ public static Control AddDock(this DockPanel dp, Control child, Dock dock) { DockPanel.SetDock(child, dock); dp.Children.Add(child); return child; }}diff --git a/src/managed/Nota.App/Controls/Eq3Views.cs b/src/managed/Nota.App/Controls/Eq3Views.csnew file mode 100644index 00000000..43dae3d5--- /dev/null+++ b/src/managed/Nota.App/Controls/Eq3Views.cs@@ -0,0 +1,435 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Nota EQ-3 (device kind 16) card controls:+// · Eq3Fader — a band's gain fader: a sunken slot, a fill from 0 dB to the value in the band's+// hue, the range's ends and 0 dB marked, a 22 × 9 cap. Vertical drag (relative — a click never+// jumps), 0.5 dB steps with a 0 dB detent; Shift / Ctrl / ⌘ for fine 0.1 dB steps;+// double-click resets (0 dB, and the kill off).+// · Eq3Graph — the response window: the output spectrum (engine FFT) behind, each band's own+// curve thin in its hue, the sum in brass, the two crossovers as dashed lines with handles+// along the top that drag left / right (the low/mid one held to at most half the mid/high+// one). A drag anywhere else in a band's zone rides that band's gain up / down; double-click+// a handle or a zone to reset it.+// Eq3Math mirrors Eq3.h (Linkwitz-Riley tree, the low band's allpass) so the curves are the DSP.++using System;+using System.Globalization;+using System.Numerics;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Input;+using Avalonia.Media;++namespace Nota.App;++internal static class Eq3Math+{+ public const double FMin = 20, FMax = 20000;+ public static readonly string[] Names = { "LOW", "MID", "HIGH" };++ /// <summary>The band hues: rose, brass, teal — the strips, the graph labels and the band curves.</summary>+ public static SolidColorBrush Hue(int band) => band switch { 0 => NotaPalette.Rose, 1 => NotaPalette.Accent, _ => NotaPalette.Teal };++ /// <summary>The band curve's ink on the graph: the mid curve stays neutral so the brass sum reads.</summary>+ public static SolidColorBrush CurveInk(int band) => band switch { 0 => NotaPalette.Rose, 1 => NotaPalette.TextSecondary, _ => NotaPalette.Teal };++ public static double X(double f) => Math.Log(Math.Clamp(f, FMin, FMax) / FMin) / Math.Log(FMax / FMin);+ public static double F(double x) => FMin * Math.Pow(FMax / FMin, Math.Clamp(x, 0, 1));++ public static double GainDb(double v, bool iso) => iso ? -24 + 30 * v : (v - 0.5) * 30;+ public static double GainNorm(double db, bool iso) => Math.Clamp(iso ? (db + 24) / 30 : db / 30 + 0.5, 0, 1);+ public static double TopDb(bool iso) => iso ? 6 : 15;+ public static double BottomDb(bool iso) => iso ? -24 : -15;++ public static double LoHz(double v) => 50 * Math.Pow(40, Math.Clamp(v, 0, 1));+ public static double LoNorm(double hz) => Math.Log(Math.Clamp(hz, 50, 2000) / 50) / Math.Log(40);+ public static double HiHz(double v) => 500 * Math.Pow(36, Math.Clamp(v, 0, 1));+ public static double HiNorm(double hz) => Math.Log(Math.Clamp(hz, 500, 18000) / 500) / Math.Log(36);++ public static string Hz(double hz) => hz >= 1000 ? NotaNum.F($"{hz / 1000:0.0}\u2009kHz") : NotaNum.F($"{hz:0}\u2009Hz");+ /// <summary>Compact, for the strip ranges: 250 · 2.5k.</summary>+ public static string HzShort(double hz) => hz >= 1000 ? NotaNum.F($"{hz / 1000:0.#}k") : NotaNum.F($"{hz:0}");+ public static string Db(double db) => NotaNum.F($"{db:+0.0;−0.0;0.0}");++ // One Butterworth-2 section at s = j·f/fc with damping k = 1/Q.+ private static Complex Sec(double w, double k, bool hp)+ {+ var s = new Complex(0, w);+ var d = s * s + k * s + 1;+ return (hp ? s * s : Complex.One) / d;+ }+ private static Complex Cascade(double f, double fc, bool lr8, bool hp)+ {+ double w = f / fc;+ Complex h = Complex.One;+ int n = lr8 ? 4 : 2;+ for (int i = 0; i < n; i++) h *= Sec(w, lr8 ? (i % 2 == 0 ? 1.8477590650 : 0.7653668647) : 1.4142135624, hp);+ return h;+ }++ /// <summary>The three bands' complex responses at <paramref name="f"/> (unity gains).</summary>+ public static (Complex Low, Complex Mid, Complex High) Bands(double f, double f1, double f2, bool lr8)+ {+ Complex lp1 = Cascade(f, f1, lr8, false), hp1 = Cascade(f, f1, lr8, true);+ Complex lp2 = Cascade(f, f2, lr8, false), hp2 = Cascade(f, f2, lr8, true);+ return (lp1 * (lp2 + hp2), hp1 * lp2, hp1 * hp2);+ }++ public static double ToDb(double mag) => 20 * Math.Log10(Math.Max(mag, 1e-6));+}++internal sealed class Eq3Fader : Control+{+ private double _db, _top = 6, _bottom = -24;+ private bool _killed, _drag, _hover;+ private double _startY, _startDb;+ private IBrush _hue = NotaPalette.Accent;++ public event Action? GestureBegin;+ public event Action? GestureEnd;+ public event Action<double>? Changed; // dB+ public event Action? ResetRequested;+ public bool Dragging => _drag;++ public Eq3Fader() { Cursor = new Cursor(StandardCursorType.SizeNorthSouth); MinHeight = 60; }++ public void Set(double db, bool killed, double top, double bottom, IBrush hue)+ {+ if (Math.Abs(db - _db) < 1e-6 && killed == _killed && top == _top && bottom == _bottom && ReferenceEquals(hue, _hue)) return;+ _db = db; _killed = killed; _top = top; _bottom = bottom; _hue = hue;+ InvalidateVisual();+ }++ private const double Pad = 4;+ private double Y(double db) => Pad + (_top - Math.Clamp(db, _bottom, _top)) / (_top - _bottom) * Math.Max(1, Bounds.Height - 2 * Pad);++ protected override void OnPointerEntered(PointerEventArgs e) { base.OnPointerEntered(e); _hover = true; InvalidateVisual(); }+ protected override void OnPointerExited(PointerEventArgs e) { base.OnPointerExited(e); _hover = false; InvalidateVisual(); }++ protected override void OnPointerPressed(PointerPressedEventArgs e)+ {+ base.OnPointerPressed(e);+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return; // right-click bubbles (MIDI learn)+ e.Handled = true;+ if (e.ClickCount == 2) { ResetRequested?.Invoke(); return; }+ _drag = true; _startY = e.GetPosition(this).Y; _startDb = _db;+ e.Pointer.Capture(this);+ GestureBegin?.Invoke();+ }+ protected override void OnPointerMoved(PointerEventArgs e)+ {+ base.OnPointerMoved(e);+ if (!_drag) return;+ bool fine = (e.KeyModifiers & (KeyModifiers.Shift | KeyModifiers.Control | KeyModifiers.Meta)) != 0;+ double span = _top - _bottom;+ double px = Math.Max(140, Bounds.Height - 2 * Pad); // the full range over the slot (≥ 140 px)+ double db = _startDb + (_startY - e.GetPosition(this).Y) / px * span * (fine ? 0.2 : 1);+ if (fine) db = Math.Round(db * 10) / 10;+ else { db = Math.Round(db * 2) / 2; if (Math.Abs(db) < 0.75) db = 0; } // 0.5 dB steps, 0 dB detent+ db = Math.Clamp(db, _bottom, _top);+ if (Math.Abs(db - _db) < 1e-9) return;+ _startY = e.GetPosition(this).Y; _startDb = db; // re-anchor so a mode change (fine) never jumps+ _db = db; InvalidateVisual(); Changed?.Invoke(db);+ }+ protected override void OnPointerReleased(PointerReleasedEventArgs e)+ {+ base.OnPointerReleased(e);+ if (!_drag) return;+ _drag = false; e.Pointer.Capture(null); GestureEnd?.Invoke(); InvalidateVisual();+ }++ public override void Render(DrawingContext ctx)+ {+ double w = Bounds.Width, h = Bounds.Height;+ if (w <= 0 || h <= 0) return;+ double cx = Math.Round(w / 2);+ // Slot.+ ctx.DrawRectangle(NotaPalette.BgSunken, new Pen(NotaPalette.BorderDefault, 1), new Rect(cx - 2, Pad, 4, h - 2 * Pad), 2, 2);+ // Scale: the ends and 0 dB on the left, ticks at 0 dB and half the cut on the right.+ double y0 = Y(0), yHalf = Y(_bottom / 2);+ void Lbl(string t, double y, IBrush ink, bool centre)+ {+ var ft = new FormattedText(t, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NotaFonts.Mono, 7, ink);+ ctx.DrawText(ft, new Point(Math.Max(0, cx - 22), Math.Clamp(centre ? y - ft.Height / 2 : y, 0, h - ft.Height)));+ }+ Lbl(NotaNum.F($"+{_top:0}"), Pad - 1, NotaPalette.TextAxis, false);+ Lbl("0", y0, NotaPalette.TextTertiary, true);+ Lbl(NotaNum.F($"{_bottom:0}"), h - Pad - 8, NotaPalette.TextAxis, false);+ ctx.DrawLine(new Pen(NotaPalette.BorderStrong, 1), new Point(cx + 9, Math.Round(y0) + 0.5), new Point(cx + 15, Math.Round(y0) + 0.5));+ ctx.DrawLine(new Pen(NotaPalette.BorderDefault, 1), new Point(cx + 9, Math.Round(yHalf) + 0.5), new Point(cx + 13, Math.Round(yHalf) + 0.5));+ // Fill from 0 dB to the value (gone while killed).+ double yv = Y(_db);+ if (!_killed && Math.Abs(yv - y0) > 0.5)+ ctx.FillRectangle(_hue, new Rect(cx - 1, Math.Min(yv, y0), 2, Math.Abs(yv - y0)));+ // Cap.+ var cap = new Rect(cx - 11, Math.Round(yv - 4.5), 22, 9);+ ctx.DrawRectangle(NotaPalette.SurfaceHover, new Pen(_drag || _hover ? NotaPalette.BorderStrong : NotaPalette.TextAxis, 1), cap, 2, 2);+ ctx.FillRectangle(_killed ? NotaPalette.TextDisabled : _hue, new Rect(cx - 6, cap.Y + 3.5, 12, 2));+ }+}++internal sealed class Eq3Graph : Control+{+ private readonly double[] _db = new double[3];+ private readonly bool[] _kill = new bool[3];+ private double _f1 = 250, _f2 = 2500, _top = 6;+ private bool _lr8, _iso = true, _specValid;+ private readonly float[] _spec = new float[96];+ private int _specN;++ // Drag state: 0 / 1 = a crossover handle, 2 + b = band b's gain.+ private int _drag = -1, _hover = -1;+ private double _grabDx, _startY, _startDb;++ public event Action<int>? XoverBegin;+ public event Action<int, double>? XoverChanged; // which (0 low/mid, 1 mid/high), Hz+ public event Action<int>? XoverEnd;+ public event Action<int>? XoverReset;+ public event Action<int>? GainBegin;+ public event Action<int, double>? GainChanged; // band, dB+ public event Action<int>? GainEnd;+ public event Action<int>? GainReset;+ public bool Dragging => _drag >= 0;++ public Eq3Graph() { ClipToBounds = true; MinHeight = 60; MinWidth = 160; Cursor = new Cursor(StandardCursorType.SizeNorthSouth); }++ public void Set(double lowDb, double midDb, double highDb, bool kLow, bool kMid, bool kHigh, double f1, double f2, bool lr8, bool iso)+ {+ _db[0] = lowDb; _db[1] = midDb; _db[2] = highDb;+ _kill[0] = kLow; _kill[1] = kMid; _kill[2] = kHigh;+ _f1 = f1; _f2 = f2; _lr8 = lr8; _iso = iso; _top = Eq3Math.TopDb(iso);+ InvalidateVisual();+ }++ /// <summary>The engine's output spectrum (dB per log band 20 Hz … 20 kHz).</summary>+ public void SetSpectrum(float[] src, int offset, int count, bool valid)+ {+ _specN = Math.Min(count, _spec.Length);+ Array.Copy(src, offset, _spec, 0, _specN);+ _specValid = valid && _specN > 1;+ InvalidateVisual();+ }++ // dB → y: the fader's top at 10 %, −36 dB at 90 % (as the mockup draws it).+ private double Y(double db, double h) => Math.Clamp(0.1 + (_top - db) / (_top + 36) * 0.8, 0, 1) * h;++ private Rect Handle(int which, out FormattedText text)+ {+ double f = which == 0 ? _f1 : _f2;+ text = new FormattedText(Eq3Math.Hz(f), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NotaFonts.Mono, 7, NotaPalette.AccentBright);+ double w = text.Width + 10, x = Eq3Math.X(f) * Bounds.Width;+ x = Math.Clamp(x - w / 2, 1, Math.Max(1, Bounds.Width - w - 1));+ return new Rect(Math.Round(x), 16, Math.Round(w), 13);+ }++ private int HitHandle(Point p)+ {+ for (int i = 1; i >= 0; i--) if (Handle(i, out _).Inflate(new Thickness(2, 3)).Contains(p)) return i;+ return -1;+ }+ private int ZoneAt(double x)+ {+ double f = Eq3Math.F(x / Math.Max(1, Bounds.Width));+ return f < _f1 ? 0 : f < _f2 ? 1 : 2;+ }++ protected override void OnPointerExited(PointerEventArgs e) { base.OnPointerExited(e); if (_hover != -1) { _hover = -1; InvalidateVisual(); } }++ protected override void OnPointerPressed(PointerPressedEventArgs e)+ {+ base.OnPointerPressed(e);+ if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return; // right-click bubbles (MIDI learn)+ e.Handled = true;+ var p = e.GetPosition(this);+ int h = HitHandle(p);+ if (e.ClickCount == 2)+ {+ if (h >= 0) XoverReset?.Invoke(h); else GainReset?.Invoke(ZoneAt(p.X));+ return;+ }+ if (h >= 0)+ {+ _drag = h;+ _grabDx = p.X - Eq3Math.X(h == 0 ? _f1 : _f2) * Bounds.Width; // no jump: keep where it was grabbed+ XoverBegin?.Invoke(h);+ }+ else+ {+ int b = ZoneAt(p.X);+ _drag = 2 + b; _startY = p.Y; _startDb = _db[b];+ GainBegin?.Invoke(b);+ }+ e.Pointer.Capture(this);+ InvalidateVisual();+ }++ protected override void OnPointerMoved(PointerEventArgs e)+ {+ base.OnPointerMoved(e);+ var p = e.GetPosition(this);+ if (_drag < 0)+ {+ int h = HitHandle(p);+ if (h != _hover) { _hover = h; InvalidateVisual(); }+ Cursor = new Cursor(h >= 0 ? StandardCursorType.SizeWestEast : StandardCursorType.SizeNorthSouth);+ return;+ }+ if (_drag < 2)+ {+ double f = Eq3Math.F((p.X - _grabDx) / Math.Max(1, Bounds.Width));+ f = _drag == 0 ? Math.Clamp(f, 50, Math.Min(2000, _f2 / 2)) : Math.Clamp(f, Math.Max(500, _f1 * 2), 18000);+ if (_drag == 0) _f1 = f; else _f2 = f;+ XoverChanged?.Invoke(_drag, f);+ InvalidateVisual();+ return;+ }+ int b = _drag - 2;+ bool fine = (e.KeyModifiers & (KeyModifiers.Shift | KeyModifiers.Control | KeyModifiers.Meta)) != 0;+ double top = Eq3Math.TopDb(_iso), bot = Eq3Math.BottomDb(_iso);+ double px = Math.Max(140, Bounds.Height);+ double db = _startDb + (_startY - p.Y) / px * (top - bot) * (fine ? 0.2 : 1);+ if (fine) db = Math.Round(db * 10) / 10;+ else { db = Math.Round(db * 2) / 2; if (Math.Abs(db) < 0.75) db = 0; }+ db = Math.Clamp(db, bot, top);+ if (Math.Abs(db - _db[b]) < 1e-9) return;+ _startY = p.Y; _startDb = db;+ _db[b] = db;+ GainChanged?.Invoke(b, db);+ InvalidateVisual();+ }++ protected override void OnPointerReleased(PointerReleasedEventArgs e)+ {+ base.OnPointerReleased(e);+ if (_drag < 0) return;+ int d = _drag; _drag = -1;+ e.Pointer.Capture(null);+ if (d < 2) XoverEnd?.Invoke(d); else GainEnd?.Invoke(d - 2);+ InvalidateVisual();+ }++ public override void Render(DrawingContext ctx)+ {+ double w = Bounds.Width, h = Bounds.Height;+ if (w <= 0 || h <= 0) return;+ var r = new Rect(0, 0, w, h);+ NotaGraph.Window(ctx, r);++ // Grid: decades, 0 dB brighter, the cut's steps faint.+ foreach (double f in new[] { 100.0, 1000, 10000 })+ {+ double x = Math.Round(Eq3Math.X(f) * w) + 0.5;+ ctx.DrawLine(NotaGraph.GridPen, new Point(x, 0), new Point(x, h));+ }+ var faint = new Pen(NotaPalette.GridSubBeat, 1);+ foreach (double db in new[] { -12.0, -24 }) { double y = Math.Round(Y(db, h)) + 0.5; ctx.DrawLine(faint, new Point(0, y), new Point(w, y)); }+ double y0 = Math.Round(Y(0, h)) + 0.5;+ ctx.DrawLine(new Pen(NotaPalette.GridBar, 1), new Point(0, y0), new Point(w, y0));++ // Output spectrum, behind everything: 0 dBFS at the top, −84 at the bottom.+ if (_specValid)+ {+ var g = new StreamGeometry();+ using (var gc = g.Open())+ {+ for (int i = 0; i < _specN; i++)+ {+ double x = (i + 0.5) / _specN * w;+ double y = Math.Clamp(-_spec[i] / 84.0, 0, 1) * h;+ if (i == 0) gc.BeginFigure(new Point(x, y), false); else gc.LineTo(new Point(x, y));+ }+ gc.EndFigure(false);+ }+ ctx.DrawGeometry(null, new Pen(NotaPalette.BorderStrong, 1, lineJoin: PenLineJoin.Round), g);+ }++ // Band curves and the sum.+ int n = (int)Math.Clamp(w / 2, 60, 320);+ var lin = new double[3];+ for (int b = 0; b < 3; b++) lin[b] = _kill[b] ? 0 : Math.Pow(10, _db[b] / 20);+ var band = new StreamGeometry[3];+ var bc = new StreamGeometryContext[3];+ for (int b = 0; b < 3; b++) { band[b] = new StreamGeometry(); bc[b] = band[b].Open(); }+ var sum = new StreamGeometry();+ using (var sc = sum.Open())+ {+ for (int i = 0; i < n; i++)+ {+ double fx = (double)i / (n - 1), f = Eq3Math.F(fx), x = fx * w;+ var (lo, mid, hi) = Eq3Math.Bands(f, _f1, _f2, _lr8);+ Complex[] c = { lo, mid, hi };+ Complex s = Complex.Zero;+ for (int b = 0; b < 3; b++)+ {+ s += lin[b] * c[b];+ var pt = new Point(x, Y(Eq3Math.ToDb(lin[b] * c[b].Magnitude), h));+ if (i == 0) bc[b].BeginFigure(pt, false); else bc[b].LineTo(pt);+ }+ var ps = new Point(x, Y(Eq3Math.ToDb(s.Magnitude), h));+ if (i == 0) sc.BeginFigure(ps, false); else sc.LineTo(ps);+ }+ sc.EndFigure(false);+ }+ for (int b = 0; b < 3; b++)+ {+ bc[b].EndFigure(false); bc[b].Dispose();+ if (_kill[b]) continue;+ ctx.DrawGeometry(null, new Pen(NotaPalette.Wash(Eq3Math.CurveInk(b), b == 1 ? (byte)0x99 : (byte)0xCC), 1.2, lineJoin: PenLineJoin.Round), band[b]);+ }+ ctx.DrawGeometry(null, NotaGraph.PrimaryPen, sum);++ // Crossovers: dashed lines and their handles.+ var dash = new Pen(NotaPalette.BorderBrass, 1) { DashStyle = new DashStyle(new double[] { 3, 3 }, 0) };+ foreach (double f in new[] { _f1, _f2 })+ {+ double x = Math.Round(Eq3Math.X(f) * w) + 0.5;+ ctx.DrawLine(dash, new Point(x, 0), new Point(x, h));+ }++ // Band labels along the top, centred in each band's zone.+ double xl = Eq3Math.X(_f1) * w, xh = Eq3Math.X(_f2) * w;+ double[] centres = { xl / 2, (xl + xh) / 2, (xh + w) / 2 };+ var names = new FormattedText[3];+ var vals = new FormattedText[3];+ var lx = new double[3];+ var lw = new double[3];+ for (int b = 0; b < 3; b++)+ {+ names[b] = new FormattedText(Eq3Math.Names[b], CultureInfo.InvariantCulture, FlowDirection.LeftToRight, NotaFonts.SansBold, 7, Eq3Math.Hue(b));+ vals[b] = new FormattedText(_kill[b] ? "kill" : Eq3Math.Db(_db[b]), CultureInfo.InvariantCulture, FlowDirection.LeftToRight,+ NotaFonts.Mono, 7, _kill[b] ? NotaPalette.TextTertiary : NotaPalette.TextPrimary);+ lw[b] = names[b].Width + 4 + vals[b].Width;+ lx[b] = centres[b] - lw[b] / 2;+ }+ // Keep them inside and apart: push right from the left edge, then back from the right one.+ lx[0] = Math.Max(3, lx[0]);+ for (int b = 1; b < 3; b++) lx[b] = Math.Max(lx[b], lx[b - 1] + lw[b - 1] + 8);+ lx[2] = Math.Min(lx[2], w - lw[2] - 3);+ for (int b = 1; b >= 0; b--) lx[b] = Math.Min(lx[b], lx[b + 1] - lw[b] - 8);+ for (int b = 0; b < 3; b++)+ {+ ctx.DrawText(names[b], new Point(lx[b], 4));+ ctx.DrawText(vals[b], new Point(lx[b] + names[b].Width + 4, 4));+ }+ for (int i = 0; i < 2; i++)+ {+ var rect = Handle(i, out var text);+ bool hot = _drag == i || _hover == i;+ ctx.DrawRectangle(hot ? NotaPalette.Accent : NotaPalette.SurfaceCard, new Pen(NotaPalette.Accent, 1), rect.Deflate(0.5), 3, 3);+ if (hot) text.SetForegroundBrush(NotaPalette.TextOnAccent);+ ctx.DrawText(text, new Point(rect.X + 5, rect.Y + (rect.Height - text.Height) / 2));+ }++ // Axis labels: 0 and the fader's floor on the right, the range in the bottom corners.+ void RightLbl(string t, double db)+ {+ var ft = NotaGraph.AxisText(t);+ ctx.DrawText(ft, new Point(w - ft.Width - 5, Y(db, h) - ft.Height / 2));+ }+ RightLbl("0", 0);+ RightLbl(NotaNum.F($"{Eq3Math.BottomDb(_iso):0}"), Eq3Math.BottomDb(_iso));+ NotaGraph.Axis(ctx, r, NotaGraph.Corner.BottomLeft, "20");+ NotaGraph.Axis(ctx, r, NotaGraph.Corner.BottomRight, "20k Hz");+ }+}diff --git a/src/managed/Nota.App/Controls/EqThreeCurve.cs b/src/managed/Nota.App/Controls/EqThreeCurve.csdeleted file mode 100644index 6498cff5..00000000--- a/src/managed/Nota.App/Controls/EqThreeCurve.cs+++ /dev/null@@ -1,203 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-only-// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.-//-// EQ-3 response curve (device kind 16). Display-only — the EQ-3 is *played* on the band-// faders, not edited on the curve — so this just visualises what the faders do. Layers,-// over a log-frequency grid:-// 1) a real-time spectrum analyzer of the pre-EQ signal (FFT of the device scope), in-// muted olive so it reads as material, not a control;-// 2) the summed three-band magnitude response (brass line + fill), rebuilt from the two-// crossover frequencies, the slope, and the per-band gains/kills;-// 3) the two crossover frequencies as amber vertical markers.-// Band colours (rust / amber / slate) match the fader strips so a band reads as one thing.--using System;-using Avalonia;-using Avalonia.Controls;-using Avalonia.Media;-using Nota.Application;--namespace Nota.App;--internal sealed class EqThreeCurve : Control-{- private static readonly IBrush Bg = NotaPalette.BgSunken;- private static readonly IBrush BorderB = NotaPalette.BorderDefault;- private static readonly IPen GridPen = NotaGraph.GridPen;- private static readonly IPen CurvePen = new Pen(NotaPalette.Accent, 1.8);- private static readonly IBrush CurveFill = NotaPalette.Wash(NotaPalette.Accent, 0x18);- private static readonly IBrush SpecFill = NotaPalette.Wash(NotaPalette.SignalInFill, 0x22);- private static readonly IPen SpecPen = new Pen(NotaPalette.Wash(NotaPalette.SignalIn, 0x44), 1);- private static readonly IPen XoverPen = new Pen(NotaPalette.Wash(NotaPalette.Accent, 0x66), 1) { DashStyle = new DashStyle(new double[] { 3, 3 }, 0) };- private static readonly IBrush AxisB = NotaPalette.TextTertiary;- private static readonly IBrush LowB = NotaPalette.Ink("#C4756A");- private static readonly IBrush MidB = NotaPalette.Ink("#C99C55");- private static readonly IBrush HighB = NotaPalette.Ink("#6D8FB5");- private static readonly IBrush KillB = NotaPalette.AccentHover; // a state, not an alert: red is kept for recording and overload- private static readonly Typeface Face = NotaFonts.Mono;-- private const double FMin = 20.0, FMax = 20000.0;- private const double DbTop = 18.0, DbBot = -24.0;- private const int FftN = 2048, Bins = FftN / 2;-- private readonly IAudioEngine _engine;- private readonly int _track, _device;-- // Band state (linear gains after kill), crossovers (Hz), cascade depth.- private double _gLow = 1, _gMid = 1, _gHigh = 1;- private bool _kLow, _kMid, _kHigh;- private double _f1 = 250, _f2 = 2500;- private int _nSec = 2;-- private readonly float[] _scope = new float[FftN];- private readonly double[] _re = new double[FftN], _im = new double[FftN];- private readonly double[] _specDb = new double[Bins];- private readonly double[] _hann = new double[FftN];- private double _sr = 48000;-- public EqThreeCurve(IAudioEngine engine, int track, int device)- {- _engine = engine; _track = track; _device = device;- MinHeight = 90; MinWidth = 180; ClipToBounds = true;- for (int i = 0; i < FftN; i++) _hann[i] = 0.5 - 0.5 * Math.Cos(2 * Math.PI * i / (FftN - 1));- for (int i = 0; i < Bins; i++) _specDb[i] = -120;- }-- // Band gains/kills + crossovers + slope from the device params.- public void Set(double lowDbNorm, double midDbNorm, double highDbNorm,- bool kLow, bool kMid, bool kHigh, double f1, double f2, bool slope48)- {- _gLow = kLow ? 0 : DbToLin((lowDbNorm - 0.5) * 30);- _gMid = kMid ? 0 : DbToLin((midDbNorm - 0.5) * 30);- _gHigh = kHigh ? 0 : DbToLin((highDbNorm - 0.5) * 30);- _kLow = kLow; _kMid = kMid; _kHigh = kHigh;- _f1 = f1; _f2 = f2; _nSec = slope48 ? 4 : 2;- InvalidateVisual();- }-- public void Tick()- {- int n = _engine.DeviceScope(_track, _device, _scope, FftN);- if (n < FftN) { for (int k = 1; k < Bins; k++) _specDb[k] = -120; InvalidateVisual(); return; }- for (int i = 0; i < FftN; i++) { _re[i] = _scope[i] * _hann[i]; _im[i] = 0; }- Fft(_re, _im);- _sr = _engine.SampleRate > 0 ? _engine.SampleRate : 48000;- double refMag = FftN / 4.0;- for (int k = 1; k < Bins; k++)- {- double mag = Math.Sqrt(_re[k] * _re[k] + _im[k] * _im[k]);- double db = 20 * Math.Log10(mag / refMag + 1e-9);- _specDb[k] = db; // no release ballistics: the spectrum shows this frame (almanac § no meter animation)- }- InvalidateVisual();- }-- private static double DbToLin(double db) => Math.Pow(10, db / 20);-- // n cascaded Butterworth-2 sections → 2n-th-order Linkwitz-Riley magnitude.- private double LpMag(double f, double fc) { double w = f / fc; return Math.Pow(1.0 / Math.Sqrt(1 + w * w * w * w), _nSec); }- private double HpMag(double f, double fc) { double w = f / fc; return Math.Pow(w * w / Math.Sqrt(1 + w * w * w * w), _nSec); }-- private double RespDb(double f)- {- double rest = HpMag(f, _f1);- double low = LpMag(f, _f1);- double mid = rest * LpMag(f, _f2);- double high = rest * HpMag(f, _f2);- double m = _gLow * low + _gMid * mid + _gHigh * high;- return 20 * Math.Log10(Math.Max(m, 1e-5));- }-- private double YForDb(double db, double h) => Math.Clamp((DbTop - db) / (DbTop - DbBot) * h, 0, h);-- 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 logMin = Math.Log10(FMin), logMax = Math.Log10(FMax), logSpan = logMax - logMin;- double X(double f) => (Math.Log10(f) - logMin) / logSpan * w;- foreach (double f in new[] { 100.0, 1000, 10000 }) ctx.DrawLine(GridPen, new Point(X(f), 0), new Point(X(f), h));- ctx.DrawLine(GridPen, new Point(0, YForDb(0, h)), new Point(w, YForDb(0, h)));-- // --- 1) spectrum analyzer (behind) ---- var spec = new StreamGeometry();- using (var g = spec.Open())- {- g.BeginFigure(new Point(0, h), true);- for (int k = 1; k < Bins; k++)- {- double f = k * _sr / FftN;- if (f < FMin || f > FMax) continue;- double norm = Math.Clamp((_specDb[k] + 84) / 84, 0, 1);- g.LineTo(new Point(X(f), h - norm * h));- }- g.LineTo(new Point(w, h));- g.EndFigure(true);- }- ctx.DrawGeometry(null, SpecPen, spec);-- // --- crossover markers ---- ctx.DrawLine(XoverPen, new Point(X(_f1), 0), new Point(X(_f1), h));- ctx.DrawLine(XoverPen, new Point(X(_f2), 0), new Point(X(_f2), h));-- // --- 2) summed band response (interactive-looking, but display-only) ---- int n = (int)Math.Max(48, Math.Min(480, w));- var pts = new Point[n];- for (int i = 0; i < n; i++)- {- double fx = (double)i / (n - 1);- double f = Math.Pow(10, logMin + fx * logSpan);- pts[i] = new Point(fx * w, YForDb(RespDb(f), h));- }- var geo = new StreamGeometry();- using (var gc = geo.Open())- {- gc.BeginFigure(new Point(0, h), true);- foreach (var pt in pts) gc.LineTo(pt);- gc.LineTo(new Point(w, h));- gc.EndFigure(true);- }- for (int i = 1; i < n; i++) ctx.DrawLine(CurvePen, pts[i - 1], pts[i]);-- // --- 3) band labels sitting in each band's frequency zone ---- void Lbl(string t, double x, double y, IBrush b) => ctx.DrawText(new FormattedText(t, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Face, 8, b), new Point(x, y));- double xLow = X(Math.Sqrt(FMin * _f1)), xMid = X(Math.Sqrt(_f1 * _f2)), xHigh = X(Math.Sqrt(_f2 * FMax));- Lbl(_kLow ? "LOW kill" : $"LOW {(_gLow > 0 ? 20 * Math.Log10(_gLow) : 0):+0.0;−0.0;0.0}", Math.Clamp(xLow - 14, 3, w - 40), 3, _kLow ? KillB : LowB);- Lbl(_kMid ? "MID kill" : $"MID {(_gMid > 0 ? 20 * Math.Log10(_gMid) : 0):+0.0;−0.0;0.0}", Math.Clamp(xMid - 14, 3, w - 40), 3, _kMid ? KillB : MidB);- Lbl(_kHigh ? "HIGH kill" : $"HIGH {(_gHigh > 0 ? 20 * Math.Log10(_gHigh) : 0):+0.0;−0.0;0.0}", Math.Clamp(xHigh - 14, 3, w - 44), 3, _kHigh ? KillB : HighB);-- // The range, in the bottom corners only.- NotaGraph.Axis(ctx, new Rect(0, 0, w, h), NotaGraph.Corner.BottomLeft, "20");- NotaGraph.Axis(ctx, new Rect(0, 0, w, h), NotaGraph.Corner.BottomRight, "20k Hz");- }-- private static void Fft(double[] re, double[] im)- {- int n = re.Length;- for (int i = 1, j = 0; i < n; i++)- {- int bit = n >> 1;- for (; (j & bit) != 0; bit >>= 1) j ^= bit;- j ^= bit;- if (i < j) { (re[i], re[j]) = (re[j], re[i]); (im[i], im[j]) = (im[j], im[i]); }- }- for (int len = 2; len <= n; len <<= 1)- {- double ang = -2 * Math.PI / len, wr = Math.Cos(ang), wi = Math.Sin(ang);- for (int i = 0; i < n; i += len)- {- double cr = 1, ci = 0;- for (int k = 0; k < len / 2; k++)- {- int a = i + k, b = i + k + len / 2;- double tr = re[b] * cr - im[b] * ci, ti = re[b] * ci + im[b] * cr;- re[b] = re[a] - tr; im[b] = im[a] - ti;- re[a] += tr; im[a] += ti;- double ncr = cr * wr - ci * wi; ci = cr * wi + ci * wr; cr = ncr;- }- }- }- }-}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/Eq3DeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/Eq3DeviceBody.csindex e97b6e96..54e8fdf3 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/Eq3DeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/Eq3DeviceBody.cs@@ -1,13 +1,15 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Detail · Devices — built-in EQ-3 (device kind 16) body, built to mockup 3j: a-// PERFORMANCE EQ, not a small EQ-8. A CROSSOVER strip (Low/Mid & Mid/High crossover-// sliders as real Hz + a 24/48 dB slope toggle) over a body of three band strips-// (Low / Mid / High, each a vertical fader with a centre detent + KILL button, hued-// rust / amber / slate from the track palette) next to a large response graph with the-// pre-EQ spectrum behind it. The bands are grabbed and dropped, so they get faders — the-// curve is display-only.+// Detail · Devices — built-in Nota EQ-3 body (three-band isolator, device kind 16), a build of+// the "Nota EQ-3" mockup (700 × 260) on the Crush / Dynamic EQ-8 frame: three band strips on the+// left (LOW / MID / HIGH, each its span, a fader −24 … +6 dB — ±15 dB in the Classic range — its+// value and a KILL), and the response window on the right — the crossover readouts, Output, Range+// and Slope over it; inside, each band's curve in its hue, the brass sum, the output spectrum+// behind, and the two crossovers as handles along the top that drag left / right (a drag+// elsewhere rides the band under the pointer). A status strip closes the card. 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;@@ -23,166 +25,284 @@ namespace Nota.App;internal sealed class Eq3DeviceBody : IDeviceBody{- // Param indices — must match Eq3.h.+ // ── Parameter indices (must match Eq3.h) ─────────────────────────────────private const int Low = 0, Mid = 1, High = 2, LowKill = 3, MidKill = 4, HighKill = 5,- FreqLo = 6, FreqHi = 7, Slope = 8, Gain = 9;-- private static readonly IBrush HdrBg = NotaPalette.SurfaceCard;- private static readonly IBrush Border2 = NotaPalette.BorderDefault;- private static readonly IBrush Inset = NotaPalette.BgSunken;- private static readonly IBrush FieldBorder = NotaPalette.GraphBorder;- private static readonly IBrush Amber = NotaPalette.Accent;- private static readonly IBrush AmberLit = NotaPalette.AccentBright;- private static readonly IBrush AmberSubtle = NotaPalette.Wash(NotaPalette.Accent, 0x28);- private static readonly IBrush TxtC = NotaPalette.TextPrimary;- private static readonly IBrush MutedC = NotaPalette.TextTertiary;- private static readonly IBrush LabelC = NotaPalette.TextSecondary;- private static readonly IBrush KillC = NotaPalette.AccentHover; // a state, not an alert: red is kept for recording and overload- private static readonly IBrush KillSubtle = NotaPalette.AccentSubtle;- private static readonly IBrush DetentC = NotaPalette.BorderStrong;- private static readonly IBrush HandleC = NotaPalette.TextSecondary;-- private static readonly (string name, string span, IBrush hue)[] Bands =- {- ("LOW", "20 – 250\u2009Hz", NotaPalette.Ink("#C4756A")),- ("MID", "250\u2009Hz – 2.5 k", NotaPalette.Ink("#C99C55")),- ("HIGH", "2.5 – 20\u2009kHz", NotaPalette.Ink("#6D8FB5")),- };+ FreqLo = 6, FreqHi = 7, Slope = 8, Gain = 9, Range = 10;+ // Scope layout (Eq3::S_* / kTele / kSpec).+ private const int S_SampleRate = 5, S_Cpu = 6, S_Analysed = 7, S_Latency = 8,+ kTele = 16, kSpec = 96, kScope = kTele + kSpec;public double Width => 700;-- public string? Subtitle => "EQ"; // the processing type, shown as the header badgepublic bool FullBleed => true;+ public string? Subtitle => "EQ";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 SetP(int p, float v) => engine.DeviceSetParam(track, di, p, v);+ int pc = engine.DeviceParamCount(track, di);+ float P(int p) => p < pc ? engine.DeviceGetParam(track, di, p) : 0f;void Begin(int p) => engine.BeginAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");void End(int p) => engine.EndAutomationWrite(track, AutomationTarget.DeviceParam, di, p, "");- static double Exp(double v, double lo, double hi) => lo * Math.Pow(hi / lo, Math.Clamp(v, 0, 1));+ void Raw(int p, double v) { if (p < pc) 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 Learn(Control c, int p) => MidiLearn.Bind(c, MidiTarget.DeviceParam(track, di, p), engine.DeviceParamName(track, di, p));++ bool Iso() => pc <= Range || P(Range) >= 0.5f;+ bool Killed(int b) => P(LowKill + b) >= 0.5f;+ double BandDb(int b) => Eq3Math.GainDb(P(Low + b), Iso());+ double F1() => Eq3Math.LoHz(P(FreqLo));+ double F2() => Eq3Math.HiHz(P(FreqHi));+ bool Lr8() => P(Slope) >= 0.5f;+ static double OutDb(double v) => (v - 0.5) * 48;var readouts = new List<Action>();- Control Cap(string t, IBrush? c = null) => new TextBlock { Text = t, FontSize = 8, FontWeight = FontWeight.Bold, Foreground = c ?? MutedC, VerticalAlignment = VerticalAlignment.Center };+ void RefreshAll() { for (int i = 0; i < readouts.Count; i++) readouts[i](); }+ var scope = new float[kScope];+ int scN = 0;+ double Sc(int i) => scN > i ? scope[i] : 0;++ // ---- small builders ---------------------------------------------------------+ static TextBlock Caps(string t, IBrush? c = null, double fs = 7) => new()+ { Text = t, FontSize = fs, FontWeight = FontWeight.Bold, Foreground = c ?? TextTertiary, LetterSpacing = 0.8, 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 StackPanel Row(double sp, params Control[] cs)+ { var s = new StackPanel { Orientation = Orientation.Horizontal, Spacing = sp, VerticalAlignment = VerticalAlignment.Center }; foreach (var c in cs) s.Children.Add(c); return s; }+ static T Docked<T>(T c, Dock d) where T : Control { DockPanel.SetDock(c, d); return c; }++ // Band edits in dB (the Range law decides the param value).+ void GainRaw(int b, double db) => Raw(Low + b, Eq3Math.GainNorm(db, Iso()));+ void ResetBand(int b)+ {+ Begin(Low + b); GainRaw(b, 0); End(Low + b);+ if (Killed(b)) SetP(LowKill + b, 0);+ RefreshAll();+ }- // ---- response curve (display-only) ----- var curve = new EqThreeCurve(engine, track, di) { VerticalAlignment = VerticalAlignment.Stretch };- void SyncCurve() => curve.Set(P(Low), P(Mid), P(High), P(LowKill) >= 0.5f, P(MidKill) >= 0.5f, P(HighKill) >= 0.5f,- Exp(P(FreqLo), 50, 2000), Exp(P(FreqHi), 500, 18000), P(Slope) >= 0.5f);- ctx.AddDeviceRefresher(curve.Tick);+ // ======================================================================+ // Band strips+ // ======================================================================+ string Span(int b) => b switch+ {+ 0 => "20 – " + Eq3Math.HzShort(F1()),+ 1 => Eq3Math.HzShort(F1()) + " – " + Eq3Math.HzShort(F2()),+ _ => Eq3Math.HzShort(F2()) + " – 20k",+ };- // ---- formatters ----- static string BandDb(double v) => $"{(v - 0.5) * 30:+0.0;−0.0;0.0}";- string HzLo(double v) { double f = Exp(v, 50, 2000); return f >= 1000 ? $"{f / 1000:0.0}\u2009k" : $"{(int)Math.Round(f)}\u2009Hz"; }- string HzHi(double v) { double f = Exp(v, 500, 18000); return f >= 1000 ? $"{f / 1000:0.0}\u2009k" : $"{(int)Math.Round(f)}\u2009Hz"; }+ Control KillButton(int b)+ {+ var hue = Eq3Math.Hue(b);+ var tb = new TextBlock { Text = "KILL", FontSize = 8, FontWeight = FontWeight.SemiBold, LetterSpacing = 0.5, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };+ var btn = new Border+ {+ Width = 48, Height = 15, CornerRadius = NotaRadius.Badge, BorderThickness = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Center,+ Cursor = new Cursor(StandardCursorType.Hand), Child = tb,+ };+ void Paint()+ {+ bool on = Killed(b);+ btn.Background = on ? hue : Brushes.Transparent;+ btn.BorderBrush = on ? hue : NotaPalette.BorderStrong;+ tb.Foreground = on ? NotaPalette.TextOnAccent : TextSecondary;+ }+ btn.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(btn).Properties.IsLeftButtonPressed) return; // right-click bubbles (MIDI learn)+ SetP(LowKill + b, Killed(b) ? 0 : 1); RefreshAll(); e.Handled = true;+ };+ ToolTip.SetTip(btn, $"Kill the {Eq3Math.Names[b].ToLowerInvariant()} band — removes it outright, with a 5\u2009ms glide");+ Learn(btn, LowKill + b);+ readouts.Add(Paint); Paint();+ return btn;+ }- // ---- vertical band fader with a centre (0 dB) detent ----- Control VFader(int p, IBrush hue)+ Control Strip(int b){- var trackBar = new Border { Width = 4, Background = Inset, CornerRadius = NotaRadius.Clip, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch };- var detent = new Border { Height = 1, Background = DetentC, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center };- var handle = new Border { Width = 22, Height = 9, Background = NotaPalette.SurfaceHover, BorderBrush = NotaPalette.TextDisabled, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Badge, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top,- Child = new Border { Height = 2, Background = hue, CornerRadius = NotaRadius.Bar, Margin = new Thickness(3, 2.5, 3, 0), VerticalAlignment = VerticalAlignment.Top } };- var slot = new Panel { Width = 26, Children = { trackBar, detent, handle } };- bool drag = false;- void Upd() { double v = P(p); double H = slot.Bounds.Height; double y = (1 - v) * (H - 9); handle.Margin = new Thickness(0, Math.Clamp(y, 0, Math.Max(0, H - 9)), 0, 0); }- void SetFromY(double yPos) { double H = slot.Bounds.Height; double v = Math.Clamp(1 - yPos / Math.Max(1, H - 9), 0, 1); if (Math.Abs(v - 0.5) < 0.025) v = 0.5; SetP(p, (float)v); SyncCurve(); Upd(); }- slot.PointerPressed += (_, e) => { drag = true; e.Pointer.Capture(slot); Begin(p); SetFromY(e.GetPosition(slot).Y - 4.5); };- slot.PointerMoved += (_, e) => { if (drag) SetFromY(e.GetPosition(slot).Y - 4.5); };- slot.PointerReleased += (_, e) => { if (drag) { drag = false; e.Pointer.Capture(null); End(p); } };- MidiLearn.Bind(slot, MidiTarget.DeviceParam(track, di, p), engine.DeviceParamName(track, di, p));- readouts.Add(() => { if (!drag) Upd(); });- return slot;+ var hue = Eq3Math.Hue(b);+ var name = Caps(Eq3Math.Names[b], hue, 8); name.HorizontalAlignment = HorizontalAlignment.Center; name.LetterSpacing = 1;+ var span = Mono("", 7, TextTertiary); span.HorizontalAlignment = HorizontalAlignment.Center;+ var val = Mono("", 9, TextPrimary); val.HorizontalAlignment = HorizontalAlignment.Center;+ var fader = new Eq3Fader { Margin = new Thickness(0, 3, 0, 0) };+ fader.GestureBegin += () => Begin(Low + b);+ fader.GestureEnd += () => End(Low + b);+ fader.Changed += db => { GainRaw(b, db); RefreshAll(); };+ fader.ResetRequested += () => ResetBand(b);+ ToolTip.SetTip(fader, "Drag up / down for the band's gain (Shift for fine steps); double-click resets to 0\u2009dB and lifts the kill");+ Learn(fader, Low + b);+ readouts.Add(() =>+ {+ bool k = Killed(b), iso = Iso();+ double db = BandDb(b);+ if (!fader.Dragging) fader.Set(db, k, Eq3Math.TopDb(iso), Eq3Math.BottomDb(iso), hue);+ span.Text = Span(b);+ val.Text = k ? "−∞" : Eq3Math.Db(db);+ val.Foreground = k ? TextTertiary : Math.Abs(db) > 0.05 ? AccentBright : TextPrimary;+ });+ var col = new DockPanel+ {+ LastChildFill = true, Margin = new Thickness(0, 4, 0, 6),+ Children =+ {+ Docked(name, Dock.Top), Docked(span, Dock.Top),+ Docked(new Border { Margin = new Thickness(0, 3, 0, 0), Child = KillButton(b) }, Dock.Bottom),+ Docked(new Border { Margin = new Thickness(0, 3, 0, 0), Child = val }, Dock.Bottom),+ fader,+ },+ };+ var bar = new Border { Height = 2, Background = hue, CornerRadius = NotaRadius.Top(NotaRadius.TileValue) };+ return new Border+ {+ Width = 62, Margin = new Thickness(0, 0, 5, 0), Background = Card2, BorderBrush = BorderDef, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Tile, ClipToBounds = true,+ Child = new DockPanel { Children = { Docked(bar, Dock.Top), col } },+ };}- // ---- KILL toggle ----- Control KillBtn(int p)+ // ======================================================================+ // Response window+ // ======================================================================+ var graph = new Eq3Graph();+ graph.XoverBegin += w => Begin(w == 0 ? FreqLo : FreqHi);+ graph.XoverEnd += w => End(w == 0 ? FreqLo : FreqHi);+ graph.XoverChanged += (w, hz) => { if (w == 0) Raw(FreqLo, Eq3Math.LoNorm(hz)); else Raw(FreqHi, Eq3Math.HiNorm(hz)); RefreshAll(); };+ graph.XoverReset += w =>+ {+ if (w == 0) SetP(FreqLo, Eq3Math.LoNorm(Math.Min(250, F2() / 2)));+ else SetP(FreqHi, Eq3Math.HiNorm(Math.Max(2500, F1() * 2)));+ RefreshAll();+ };+ graph.GainBegin += b => Begin(Low + b);+ graph.GainEnd += b => End(Low + b);+ graph.GainChanged += (b, db) => { GainRaw(b, db); RefreshAll(); };+ graph.GainReset += ResetBand;+ Learn(graph, FreqLo);+ ToolTip.SetTip(graph, "Each band in its colour, the sum in brass, the output spectrum behind. Drag a crossover handle left / right; drag anywhere else to ride that band's gain. Double-click resets.");++ // Header: crossover readouts · Output · Range · Slope.+ Control XRead(string label, Func<string> text){- var tb = new TextBlock { Text = "KILL", FontSize = 8, FontWeight = FontWeight.Bold, HorizontalAlignment = HorizontalAlignment.Center };- var b = new Border { BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Badge, Padding = new Thickness(0, 1), HorizontalAlignment = HorizontalAlignment.Stretch, Cursor = new Cursor(StandardCursorType.Hand), Child = tb };- void Sync() { bool on = P(p) >= 0.5f; b.Background = on ? KillSubtle : Brushes.Transparent; b.BorderBrush = on ? NotaPalette.BorderBrass : DetentC; tb.Foreground = on ? KillC : MutedC; }- b.PointerPressed += (_, e) => { e.Handled = true; Begin(p); SetP(p, P(p) >= 0.5f ? 0f : 1f); End(p); Sync(); SyncCurve(); };- MidiLearn.Bind(b, MidiTarget.DeviceParam(track, di, p), "KILL");- readouts.Add(Sync);- return b;+ var v = Mono("", 8, TextPrimary);+ readouts.Add(() => v.Text = text());+ return Row(4, new TextBlock { Text = label, FontSize = 7, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center }, v);}- // ---- one band strip ----- Control BandStrip(int idx, int gainP, int killP)+ // Output: a mono readout that drags up / down, ±24 dB.+ Control OutControl(){- var (name, span, hue) = Bands[idx];- var db = new TextBlock { Text = BandDb(P(gainP)), FontSize = 9, Foreground = TxtC, HorizontalAlignment = HorizontalAlignment.Center };- db.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");- readouts.Add(() => db.Text = BandDb(P(gainP)));- var span2 = new TextBlock { Text = span, FontSize = 8, Foreground = MutedC, HorizontalAlignment = HorizontalAlignment.Center };- span2.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");- var col = new DockPanel { LastChildFill = true, Margin = new Thickness(5, 5) };- DockPanel.SetDock(col.AddDock(new TextBlock { Text = name, FontSize = 8, FontWeight = FontWeight.Bold, Foreground = LabelC, HorizontalAlignment = HorizontalAlignment.Center }, Dock.Top), Dock.Top);- col.AddDock(span2, Dock.Top);- col.AddDock(KillBtn(killP), Dock.Bottom);- col.AddDock(db, Dock.Bottom);- col.Children.Add(new Border { Child = VFader(gainP, hue), Margin = new Thickness(0, 4) });- return new Border { Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Panel, Width = 84,- Child = new Border { BorderBrush = hue, BorderThickness = new Thickness(0, 2, 0, 0), CornerRadius = NotaRadius.Top(NotaRadius.PanelValue), Child = col } };+ var v = Mono("", 8, TextPrimary);+ var box = new Border { Background = Brushes.Transparent, Padding = new Thickness(2, 0), Cursor = new Cursor(StandardCursorType.SizeNorthSouth), Child = v, VerticalAlignment = VerticalAlignment.Center };+ bool drag = false; double y0 = 0, v0 = 0;+ box.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(box).Properties.IsLeftButtonPressed) return;+ e.Handled = true;+ if (e.ClickCount == 2) { SetP(Gain, 0.5); RefreshAll(); return; }+ drag = true; y0 = e.GetPosition(box).Y; v0 = P(Gain);+ e.Pointer.Capture(box); Begin(Gain);+ };+ box.PointerMoved += (_, e) =>+ {+ if (!drag) return;+ bool fine = (e.KeyModifiers & (KeyModifiers.Shift | KeyModifiers.Control | KeyModifiers.Meta)) != 0;+ double y = e.GetPosition(box).Y;+ double db = Math.Round(OutDb(Math.Clamp(v0 + (y0 - y) / 140.0 * (fine ? 0.2 : 1), 0, 1)) * 10) / 10; // 0.1 dB steps+ y0 = y; v0 = 0.5 + db / 48;+ Raw(Gain, v0); RefreshAll();+ };+ box.PointerReleased += (_, e) => { if (!drag) return; drag = false; e.Pointer.Capture(null); End(Gain); };+ readouts.Add(() =>+ {+ double db = OutDb(P(Gain));+ v.Text = Eq3Math.Db(db) + "\u2009dB";+ v.Foreground = Math.Abs(db) > 0.05 ? AccentBright : TextPrimary;+ });+ ToolTip.SetTip(box, "Output gain, ±24\u2009dB — drag up / down (Shift for fine), double-click resets");+ Learn(box, Gain);+ return Row(4, Caps("OUT"), box);}- // Crossover slider (label + slider + Hz) for the CROSSOVER strip.- Control Xover(int p, string label, IBrush hue, Func<double, string> fmt)+ Control RangeSeg(){- var row = DeviceCardKit.SliderRow(label, () => P(p), n => { SetP(p, (float)n); SyncCurve(); }, () => fmt(P(p)), out var sync,- begin: () => Begin(p), end: () => End(p), trackWidth: 64, valueWidth: 52);+ var seg = Segments(new[] { "+6", "±15" }, () => Iso() ? 0 : 1, i =>+ {+ bool want = i == 0, iso = Iso();+ if (want == iso || pc <= Range) return;+ var dbs = new double[3];+ for (int b = 0; b < 3; b++) dbs[b] = BandDb(b);+ SetP(Range, want ? 1 : 0);+ for (int b = 0; b < 3; b++) SetP(Low + b, Eq3Math.GainNorm(dbs[b], want)); // keep each band's dB+ RefreshAll();+ }, out var sync, padX: 4);readouts.Add(sync);- MidiLearn.Bind(row, MidiTarget.DeviceParam(track, di, p), label);- return row;+ Learn(seg, Range);+ ToolTip.SetTip(seg, "Fader range — +6: −24 … +6\u2009dB, the isolator throw; ±15: −15 … +15\u2009dB, the classic EQ-3 range. The bands keep their dB.");+ return Row(4, Caps("RANGE"), seg);}- // Slope segmented toggle (24 / 48 dB).Control SlopeSeg(){- var seg = DeviceCardKit.Segments(new[] { "24\u2009dB", "48\u2009dB" }, () => P(Slope) >= 0.5f ? 1 : 0, i => { SetP(Slope, i == 1 ? 1f : 0f); SyncCurve(); }, out var sync);+ var seg = Segments(new[] { "24\u2009dB", "48\u2009dB" }, () => Lr8() ? 1 : 0, i => { SetP(Slope, i); RefreshAll(); }, out var sync, padX: 4);readouts.Add(sync);- MidiLearn.Bind(seg, MidiTarget.DeviceParam(track, di, Slope), engine.DeviceParamName(track, di, Slope));- return seg;+ Learn(seg, Slope);+ ToolTip.SetTip(seg, "Crossover slope — Linkwitz-Riley 24 or 48\u2009dB/oct: steeper touches the neighbours less");+ return Row(4, Caps("SLOPE"), seg);}- // ================= CROSSOVER strip =================- var strip = new Border { Height = 34, Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(0, 0, 0, 1),- Child = new DockPanel { LastChildFill = false, Margin = new Thickness(9, 0), Children = {- WithDock(new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12, VerticalAlignment = VerticalAlignment.Center, Children = {- Cap("CROSSOVER"),- Xover(FreqLo, "LOW / MID", Bands[0].hue, HzLo),- Xover(FreqHi, "MID / HIGH", Bands[2].hue, HzHi) } }, Dock.Left),- WithDock(new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, VerticalAlignment = VerticalAlignment.Center, Children = { Cap("SLOPE"), SlopeSeg() } }, Dock.Right) } } };-- // ================= band strips =================- var strips = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, Margin = new Thickness(8, 7), VerticalAlignment = VerticalAlignment.Stretch };- strips.Children.Add(BandStrip(0, Low, LowKill));- strips.Children.Add(BandStrip(1, Mid, MidKill));- strips.Children.Add(BandStrip(2, High, HighKill));- var stripsPanel = new Border { Width = 276, Child = strips };-- // ================= graph =================- var graph = new Border { Padding = new Thickness(0, 7, 8, 7), Child = new Border { Background = Inset, BorderBrush = FieldBorder, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Panel, Child = curve, ClipToBounds = true } };-- // ================= assemble =================- DockPanel.SetDock(stripsPanel, Dock.Left);- var body = new DockPanel { LastChildFill = true, Children = { stripsPanel, graph } };- DockPanel.SetDock(strip, Dock.Top);- var root = new DockPanel { LastChildFill = true, Background = NotaPalette.BgApp, Children = { strip, body } };-- void RefreshAll() { foreach (var a in readouts) a(); }- SyncCurve();- ctx.AddDeviceRefresher(() => { SyncCurve(); RefreshAll(); });- RefreshAll();- return root;- }+ var headLeft = Row(8, Caps("CROSSOVER"),+ XRead("low / mid", () => Eq3Math.Hz(F1())),+ XRead("mid / high", () => Eq3Math.Hz(F2())));+ var head = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8, Margin = new Thickness(8, 0) };+ head.Children.Add(new Border { ClipToBounds = true, Child = headLeft }); // trims rather than runs under the controls+ var headRight = Row(8, OutControl(), RangeSeg(), SlopeSeg());+ Grid.SetColumn(headRight, 1); head.Children.Add(headRight);+ var headBar = new Border { Height = 20, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Child = head };+ var graphBox = new Border+ {+ Background = Card2, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Tile, ClipToBounds = true,+ Child = new DockPanel { Children = { Docked(headBar, Dock.Top), new Border { Padding = new Thickness(5), Child = graph } } },+ };- private static Control WithDock(Control c, Dock d) { DockPanel.SetDock(c, d); return c; }-}+ // ======================================================================+ // Status strip+ // ======================================================================+ var statusLeft = new TextBlock { FontSize = 8, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };+ var statusRight = Mono("", 8, TextSecondary);+ readouts.Add(() =>+ {+ var parts = new List<string> { (Lr8() ? "LR 48" : "LR 24") + "\u2009dB/oct", Eq3Math.Hz(F1()) + " / " + Eq3Math.Hz(F2()) };+ var killed = new List<string>();+ for (int b = 0; b < 3; b++) if (Killed(b)) killed.Add(Eq3Math.Names[b].ToLowerInvariant());+ if (killed.Count > 0) parts.Add("kill " + string.Join(", ", killed));+ if (!Iso()) parts.Add("range ±15\u2009dB");+ double o = OutDb(P(Gain));+ if (Math.Abs(o) > 0.05) parts.Add("out " + Eq3Math.Db(o) + "\u2009dB");+ statusLeft.Text = string.Join(" · ", parts);+ double sr = Sc(S_SampleRate);+ statusRight.Text = sr > 0 ? NotaNum.F($"{sr / 1000:0.#}\u2009kHz · latency {Sc(S_Latency):0} smp · CPU {Sc(S_Cpu) * 100:0.0}\u2009%") : "";+ });+ var statusGrid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8 };+ statusGrid.Children.Add(statusLeft);+ Grid.SetColumn(statusRight, 1); statusGrid.Children.Add(statusRight);+ var status = new Border { Height = 18, Background = Sunken, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 1, 0, 0), Padding = new Thickness(8, 0), Child = statusGrid };-internal static class Eq3DockExt-{- public static Control AddDock(this DockPanel dp, Control child, Dock dock) { DockPanel.SetDock(child, dock); dp.Children.Add(child); return child; }+ // ---- assemble ---------------------------------------------------------------+ var bodyRow = new DockPanel { LastChildFill = true, Margin = new Thickness(5) };+ for (int b = 0; b < 3; b++) bodyRow.Children.Add(Docked(Strip(b), Dock.Left));+ bodyRow.Children.Add(graphBox);+ var root = new DockPanel { LastChildFill = true, Background = NotaPalette.SurfaceInset, Children = { Docked(status, Dock.Bottom), bodyRow } };++ void Refresh()+ {+ scN = engine.DeviceScope(track, di, scope, kScope);+ if (!graph.Dragging)+ graph.Set(BandDb(0), BandDb(1), BandDb(2), Killed(0), Killed(1), Killed(2), F1(), F2(), Lr8(), Iso());+ graph.SetSpectrum(scope, kTele, scN >= kScope ? kSpec : 0, Sc(S_Analysed) > 0.5);+ RefreshAll();+ }+ ctx.AddDeviceRefresher(Refresh);+ Refresh();+ return root;+ }}diff --git a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.csindex 9bae37f3..41c93997 100644--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs@@ -903,15 +903,49 @@ public sealed class FactoryPresetCatalog : IFactoryPresetsFx("eq", 0, "Telephone", ("1 Type", 0f), ("1 Freq", 450f), ("2 Freq", 1200f), ("2 Gain", 6f), ("2 Q", 1.2f), ("4 Type", 5f), ("4 Freq", 3000f));Fx("eq", 0, "Low Cut", ("1 Type", 0f), ("1 Freq", 80f), ("1 Q", 0.7f));- // ---- EQ-3 (kind 16) — performance EQ, all params normalized 0..1. Band gains are- // bipolar (0.5 = 0 dB, ±15 dB); "<band> Kill" = 1 mutes the band; crossovers- // "Low Freq" (50..2000 Hz) / "High Freq" (500..18000 Hz); "Slope" 0 = 24 / 1 = 48 dB.- Fx("eq3", 16, "DJ Kill Bass", ("Low Kill", 1f));- Fx("eq3", 16, "Kill Highs", ("High Kill", 1f));- Fx("eq3", 16, "Bass Boost", ("Low", 0.7f), ("High", 0.57f));- Fx("eq3", 16, "Mid Scoop", ("Mid", 0.3f), ("Low", 0.6f), ("High", 0.6f));- Fx("eq3", 16, "Telephone", ("Low Kill", 1f), ("High Kill", 1f), ("Mid", 0.6f), ("Low Freq", 0.49f), ("High Freq", 0.5f));- Fx("eq3", 16, "Warm Up", ("Low", 0.6f), ("High", 0.36f), ("Slope", 1f));+ // ---- Nota EQ-3 (kind 16) — three-band isolator, all params normalized 0..1 (unnamed ones+ // reset to their defaults: flat, 250 Hz / 2.5 kHz, 24 dB/oct). Eq3(…) presets are in the+ // Isolator law (Range 1): band gain dB = −24 + 30v (0.8 = 0 dB, 0.9 = +3, 1 = +6, 0.6 = −6,+ // 0.4 = −12, 0 = −24); "<band> Kill" 1 removes the band; "Low Freq" 50·40^v Hz (0.188 =+ // 100, 0.298 = 150, 0.376 = 200, 0.436 = 250, 0.486 = 300, 0.564 = 400, 0.812 = 1 k);+ // "High Freq" 500·36^v Hz (0.387 = 2 k, 0.449 = 2.5 k, 0.5 = 3 k, 0.58 = 4 k, 0.774 = 8 k);+ // "Slope" 0 = 24 / 1 = 48 dB/oct; "Gain" output (v − 0.5)·48 dB. A preset without "Range"+ // loads in the Classic ±15 dB law (PresetService), so Eq3 always names it.+ // Start+ Eq3("Init");+ Eq3("Isolator 48", ("Low Freq", 0.4857f), ("High Freq", 0.5f), ("Slope", 1f));+ // DJ+ Eq3("DJ Kill Bass", ("Low Kill", 1f));+ Eq3("Kill Mids", ("Mid Kill", 1f));+ Eq3("Kill Highs", ("High Kill", 1f));+ Eq3("Bass Swap", ("High", 0.8833f), ("Low Kill", 1f), ("Low Freq", 0.3472f), ("High Freq", 0.518f));+ Eq3("Bass Only", ("Mid Kill", 1f), ("High Kill", 1f), ("Low Freq", 0.2978f), ("Slope", 1f));+ Eq3("Mids Only", ("Low Kill", 1f), ("High Kill", 1f), ("Low Freq", 0.4363f), ("High Freq", 0.4491f));+ Eq3("Highs Only", ("Low Kill", 1f), ("Mid Kill", 1f), ("High Freq", 0.5803f));+ Eq3("Transition Build", ("Low", 0.4f), ("Mid", 0.7f), ("High", 0.8667f), ("Low Freq", 0.3758f), ("High Freq", 0.5f), ("Slope", 1f));+ Eq3("Breakdown Thin", ("Low", 0.0f), ("Mid", 0.6f), ("Low Freq", 0.4857f), ("Slope", 1f));+ // Shape+ Eq3("Scoop", ("Low", 0.85f), ("Mid", 0.3333f), ("Low Freq", 0.5637f), ("High Freq", 0.3575f), ("Slope", 1f));+ Eq3("Mid Scoop", ("Low", 0.9f), ("Mid", 0.6f), ("High", 0.9f));+ Eq3("Deep Scoop", ("Mid", 0.0f), ("Low Freq", 0.4857f), ("High Freq", 0.4491f), ("Slope", 1f));+ Eq3("Smile", ("Low", 0.9333f), ("Mid", 0.6667f), ("High", 0.9333f), ("Low Freq", 0.3758f), ("High Freq", 0.5803f));+ Eq3("Bass Boost", ("Low", 1.0f), ("High", 0.8667f), ("Low Freq", 0.2978f));+ Eq3("Warm Up", ("Low", 0.9f), ("High", 0.65f), ("Slope", 1f));+ Eq3("Air Lift", ("High", 0.9667f), ("High Freq", 0.6934f));+ Eq3("Presence", ("Mid", 0.9f), ("Low Freq", 0.8121f), ("High Freq", 0.6425f));+ // Clean-up+ Eq3("Sub Tighten", ("Low", 0.6f), ("Low Freq", 0.1593f));+ Eq3("Mud Cut", ("Mid", 0.6f), ("Low Freq", 0.3758f), ("High Freq", 0.0509f));+ Eq3("Vocal Focus", ("Low", 0.5333f), ("Mid", 0.8667f), ("High", 0.7333f), ("Low Freq", 0.3758f), ("High Freq", 0.5803f));+ Eq3("Kick Focus", ("Low", 0.9f), ("Mid", 0.6f), ("Low Freq", 0.2373f), ("High Freq", 0.3869f));+ Eq3("Hat Sizzle", ("Mid", 0.4667f), ("High", 0.9f), ("Low Kill", 1f), ("High Freq", 0.7737f), ("Slope", 1f));+ Eq3("Club Master", ("Low", 0.8667f), ("High", 0.85f), ("Low Freq", 0.1879f), ("High Freq", 0.7737f), ("Gain", 0.4688f));+ // Character+ Eq3("Telephone", ("Mid", 0.9f), ("Low Kill", 1f), ("High Kill", 1f), ("Low Freq", 0.5637f), ("High Freq", 0.5f), ("Slope", 1f));+ Eq3("AM Radio", ("Low Kill", 1f), ("High Kill", 1f), ("Low Freq", 0.4857f), ("High Freq", 0.4491f), ("Gain", 0.5625f));+ Eq3("Lo-Fi Dull", ("High", 0.2f), ("High Freq", 0.5f), ("Slope", 1f));+ Eq3("Megaphone", ("Mid", 0.9333f), ("High", 0.0f), ("Low Kill", 1f), ("Low Freq", 0.6736f), ("High Freq", 0.4491f), ("Slope", 1f), ("Gain", 0.4583f));+ Fx("eq3", 16, "Classic Flat", ("Range", 0f), ("Low", 0.5f), ("Mid", 0.5f), ("High", 0.5f));// ---- Nota Forge (kind 17) — multi-stage saturation, all params normalized 0..1.// Stage type: 0 Tube/0.2 Diode/0.4 Tape/0.6 Fuzz/0.8 Digital/1 Fold; gains/bias@@ -1840,6 +1874,10 @@ public sealed class FactoryPresetCatalog : IFactoryPresetsprivate void Fx(string group, int kind, string name, params (string Name, float Value)[] ps)=> Add(group, name, "builtin-effect", kind, isInstrument: false, isMidi: false, ps);+ // Nota EQ-3 in the Isolator law — names Range, so it isn't read as a pre-Range preset.+ private void Eq3(string name, params (string Name, float Value)[] ps)+ => Fx("eq3", 16, name, [("Range", 1f), .. ps]);+private void Midi(string group, int kind, string name, params (string Name, float Value)[] ps)=> Add(group, name, "builtin-midi-effect", kind, isInstrument: false, isMidi: true, ps);diff --git a/src/managed/Nota.Infrastructure/Persistence/PresetService.cs b/src/managed/Nota.Infrastructure/Persistence/PresetService.csindex f7381745..eea3f666 100644--- a/src/managed/Nota.Infrastructure/Persistence/PresetService.cs+++ b/src/managed/Nota.Infrastructure/Persistence/PresetService.cs@@ -122,6 +122,15 @@ public static class PresetService/// <summary>Applies a preset. Effect presets add to <paramref name="targetTrackId"/> (must be > 0);/// instrument presets always create a new track. Returns "" on success or a user-facing warning.</summary>+ // Nota EQ-3 (kind 16) appended Range, the fader law. A preset saved before it names no+ // Range (or holds only the first 10 values) and was made in the Classic ±15 dB law.+ private static void LegacyRange(PresetDocument doc, IAudioEngine engine, int trackId, int deviceIndex)+ {+ if (doc.BuiltinKind != 16 || engine.DeviceParamCount(trackId, deviceIndex) <= 10) return;+ bool legacy = doc.NamedParams is { Count: > 0 } named ? !named.ContainsKey("Range") : doc.Params.Length <= 10;+ if (legacy) engine.DeviceSetParam(trackId, deviceIndex, 10, 0f);+ }+public static string Apply(PresetDocument doc, IAudioEngine engine, int targetTrackId){switch (doc.Type)@@ -141,6 +150,7 @@ public static class PresetServiceelsefor (int i = 0; i < doc.Params.Length; i++)engine.DeviceSetParam(targetTrackId, di, i, doc.Params[i]);+ LegacyRange(doc, engine, targetTrackId, di);return "";}case "builtin-midi-effect":@@ -247,6 +257,7 @@ public static class PresetServicefor (int i = 0; i < doc.Params.Length && i < pc; i++)engine.DeviceSetParam(trackId, deviceIndex, i, doc.Params[i]);}+ LegacyRange(doc, engine, trackId, deviceIndex);return "";}case "builtin-midi-effect":diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectService.csindex 078b8f59..5d030c43 100644--- a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs@@ -425,6 +425,8 @@ public sealed class ProjectService{int pc = engine.DeviceParamCount(trackId, di);for (int p = 0; p < d.Params.Length && p < pc; p++) engine.DeviceSetParam(trackId, di, p, d.Params[p]);+ // Nota EQ-3 appended Range (the fader law); a save without it was made in the Classic ±15 dB law.+ if (d.BuiltinKind == 16 && d.Params.Length <= 10 && pc > 10) engine.DeviceSetParam(trackId, di, 10, 0f);if (d.State is { } devRel){var blob = ReadBlob(bundleDir, devRel);diff --git a/src/managed/Nota.Mcp/Tools/DeviceTools.cs b/src/managed/Nota.Mcp/Tools/DeviceTools.csindex 8398008d..7c102e3a 100644--- a/src/managed/Nota.Mcp/Tools/DeviceTools.cs+++ b/src/managed/Nota.Mcp/Tools/DeviceTools.cs@@ -19,7 +19,7 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I(0, "EQ-8"), (1, "Compressor"), (2, "Reverb"), (3, "Delay"), (4, "Utility"), (5, "Effect Rack"),(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, "EQ-3"), (17, "Forge"), (18, "Nota Level"), (19, "Nota Shutter"), (20, "Nota Chamber"), (21, "Nota Prism"),+ (16, "Nota EQ-3"), (17, "Forge"), (18, "Nota Level"), (19, "Nota Shutter"), (20, "Nota Chamber"), (21, "Nota Prism"),(22, "Nota Lens"),};@@ -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.")]+ [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 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.")]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). 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 EQ-3 (kind 16): id 0 resets the meters (the peaks and the spectrum average). 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));@@ -640,6 +640,119 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, IPm(81) >= 0.5f || Pm(84 + band - 1) >= 0.5f ? "Ext" : "Self", isDyn, -120, 0, gain ? Math.Round(Pm(o + 3), 1) : 0);});+ public sealed record Eq3Band(string Band, double GainDb, bool Killed, double LevelDb, double GainNowDb);+ public sealed record Eq3Reading(string Summary, string Live, string Range, double MinGainDb, double MaxGainDb, double LowMidHz, double MidHighHz,+ int SlopeDbPerOct, double OutputDb, double InputPeakDb, double OutputPeakDb, double SampleRate, Eq3Band[] Bands,+ bool SpectrumValid, DynEqSpectrumBand[] Spectrum);++ // Nota EQ-3 mappings (Eq3.h): band gain by the Range law, crossovers exp, output ±24 dB.+ private static double Eq3GainDb(double v, bool iso) => iso ? -24 + 30 * v : (v - 0.5) * 30;+ private static double Eq3GainNorm(double db, bool iso) => Math.Clamp(iso ? (db + 24) / 30 : db / 30 + 0.5, 0, 1);++ private Eq3Reading Eq3Read(int trackId, int deviceIndex, bool spectrum)+ {+ const int tele = 16, spec = 96;+ var sc = new float[tele + spec];+ int n = E.DeviceScope(trackId, deviceIndex, sc, spectrum ? sc.Length : tele);+ 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);+ int pc = E.DeviceParamCount(trackId, deviceIndex);+ float Pm(int p) => p < pc ? E.DeviceGetParam(trackId, deviceIndex, p) : 0f;+ bool iso = pc > 10 && Pm(10) >= 0.5f;+ string[] names = { "Low", "Mid", "High" };+ var bands = new Eq3Band[3];+ for (int b = 0; b < 3; b++)+ {+ double now = V(11 + b);+ bands[b] = new Eq3Band(names[b], R1(Eq3GainDb(Pm(b), iso)), Pm(3 + b) >= 0.5f, R1(Db(2 + b)),+ now > 1e-6 ? R1(Math.Max(-120, 20 * Math.Log10(now))) : -120);+ }+ var sp = new List<DynEqSpectrumBand>();+ bool valid = spectrum && n >= sc.Length && V(7) > 0.5f;+ if (valid)+ for (int k = 0; k < 24; k++)+ {+ double pw = 0;+ for (int b = 4 * k; b < 4 * k + 4; b++) pw += Math.Pow(10, sc[tele + b] / 10);+ sp.Add(new DynEqSpectrumBand(Math.Round(20 * Math.Pow(1000, (k + 0.5) / 24)), R1(Math.Max(-120, 10 * Math.Log10(Math.Max(1e-12, pw))))));+ }+ return new Eq3Reading(E.DeviceText(trackId, deviceIndex, 0), E.DeviceText(trackId, deviceIndex, 1),+ iso ? "Isolator" : "Classic", iso ? -24 : -15, iso ? 6 : 15,+ Math.Round(50 * Math.Pow(40, Pm(6))), Math.Round(500 * Math.Pow(36, Pm(7))), Pm(8) >= 0.5f ? 48 : 24, R1((Pm(9) - 0.5) * 48),+ R1(Db(0)), R1(Db(1)), V(5), bands, valid, sp.ToArray());+ }++ [McpServerTool(Name = "read_eq3"), Description(+ "Read a Nota EQ-3 (built-in effect kind 16 — three-band DJ isolator: Low / Mid / High split by two Linkwitz-Riley "+ + "crossovers, each band a gain fader and a kill): the fader range (Isolator −24 … +6 dB, or Classic ±15 dB on older "+ + "projects), the low/mid and mid/high crossovers in Hz, the slope (24 or 48 dB/oct), output; per band: its gain (dB), "+ + "whether it is killed, its level after the gain (dBFS, peak with a 300 ms fall) and the gain in effect now (dB, "+ + "−120 while killed — kills glide over 5 ms); in / out peaks; plus the output spectrum in 24 log bands (dB). Levels read "+ + "−120 while silent; they move only while audio runs through the track. set_eq3 edits it in dB and Hz.")]+ public Task<Eq3Reading> ReadEq3(int trackId, int deviceIndex) => Read(() => Eq3Read(trackId, deviceIndex, true));++ [McpServerTool(Name = "set_eq3"), Description(+ "Play a Nota EQ-3 (built-in effect kind 16) in one call — only the fields you pass change; each change is recorded like a "+ + "hand edit (so it lands in automation while recording). Gains are in dB within the fader range (Isolator −24 … +6, "+ + "Classic ±15; values outside are clamped); a kill removes the band outright (a gain move does not un-kill it — pass "+ + "kill false). lowMidHz 50 … 2000, midHighHz 500 … 18000 (the low/mid crossover is kept at most half the mid/high one). "+ + "slope 24 or 48 dB/oct. outputDb ±24. range \"Isolator\" | \"Classic\" switches the fader law and keeps each band's dB "+ + "(clamped to the new range). Returns the device as read back (without the spectrum).")]+ public Task<Eq3Reading> SetEq3(int trackId, int deviceIndex,+ [Description("Low band gain, dB")] double? lowDb = null, [Description("Mid band gain, dB")] double? midDb = null,+ [Description("High band gain, dB")] double? highDb = null, bool? lowKill = null, bool? midKill = null, bool? highKill = null,+ [Description("Low/mid crossover, 50..2000 Hz")] double? lowMidHz = null, [Description("Mid/high crossover, 500..18000 Hz")] double? midHighHz = null,+ [Description("24 or 48 dB/oct")] int? slope = null, [Description("Output, −24..+24 dB")] double? outputDb = null,+ [Description("\"Isolator\" or \"Classic\"")] string? range = null) => Mutate(() =>+ {+ if (E.TrackDeviceBuiltinKind(trackId, deviceIndex) != 16) throw new ArgumentException("not a Nota EQ-3 (kind 16)");+ int pc = E.DeviceParamCount(trackId, deviceIndex);+ float Pm(int p) => p < pc ? E.DeviceGetParam(trackId, deviceIndex, p) : 0f;+ void S(int p, double v)+ {+ E.BeginAutomationWrite(trackId, AutomationTarget.DeviceParam, deviceIndex, p, "");+ E.DeviceSetParam(trackId, deviceIndex, p, (float)Math.Clamp(v, 0, 1));+ E.EndAutomationWrite(trackId, AutomationTarget.DeviceParam, deviceIndex, p, "");+ }+ bool iso = pc > 10 && Pm(10) >= 0.5f;+ if (range is not null && pc > 10)+ {+ bool want = range.Trim().ToLowerInvariant() switch+ {+ "isolator" => true, "classic" => false,+ _ => throw new ArgumentException("range must be Isolator or Classic"),+ };+ if (want != iso)+ {+ var dbs = new double[3];+ for (int b = 0; b < 3; b++) dbs[b] = Eq3GainDb(Pm(b), iso);+ S(10, want ? 1 : 0);+ for (int b = 0; b < 3; b++) S(b, Eq3GainNorm(dbs[b], want));+ iso = want;+ }+ }+ double?[] gains = { lowDb, midDb, highDb };+ bool?[] kills = { lowKill, midKill, highKill };+ for (int b = 0; b < 3; b++)+ {+ if (gains[b] is { } g) S(b, Eq3GainNorm(g, iso));+ if (kills[b] is { } k) S(3 + b, k ? 1 : 0);+ }+ double f2 = midHighHz is { } mh ? Math.Clamp(mh, 500, 18000) : 500 * Math.Pow(36, Pm(7));+ double f1 = lowMidHz is { } lm ? Math.Clamp(lm, 50, 2000) : 50 * Math.Pow(40, Pm(6));+ if (midHighHz is not null) S(7, Math.Log(f2 / 500) / Math.Log(36));+ if (lowMidHz is not null || (midHighHz is not null && f1 > f2 / 2))+ S(6, Math.Log(Math.Clamp(Math.Min(f1, f2 / 2), 50, 2000) / 50) / Math.Log(40));+ if (slope is { } sl)+ {+ if (sl != 24 && sl != 48) throw new ArgumentException("slope is 24 or 48");+ S(8, sl == 48 ? 1 : 0);+ }+ if (outputDb is { } o) S(9, 0.5 + Math.Clamp(o, -24, 24) / 48);+ return Eq3Read(trackId, deviceIndex, false);+ });+public sealed record AnalyzerBand(double Hz, double Db);public sealed record AnalyzerPeak(double Hz, double Db, string Note);public sealed record AnalyzerReading(string Summary, string Scope, string Cursors, AnalyzerBand[] Bands, AnalyzerPeak[] Peaks);diff --git a/src/native/nota.engine/src/Device.h b/src/native/nota.engine/src/Device.hindex d5fe0bc5..98051c89 100644--- a/src/native/nota.engine/src/Device.h+++ b/src/native/nota.engine/src/Device.h@@ -105,6 +105,11 @@ public:// audio thread applies it at the next quantize boundary. Most devices ignore it.virtual void deviceAction(int32_t /*id*/, int32_t /*iarg*/, float /*farg*/) {}+ // A loader (a rack's saved state) has just restored the first `count` params from a save.+ // A device whose layout grew by appended params can put them back to what an older save+ // meant (Nota EQ-3: Range → Classic). Message thread.+ virtual void paramsRestored(int32_t /*count*/) {}+// Per-layer waveform envelope for multi-layer devices (the looper): fill up to// maxSamples peak bins of layer's buffer, oldest→newest, returning the count.virtual int32_t layerWave(int32_t /*layer*/, float* /*out*/, int32_t /*maxSamples*/) const { return 0; }diff --git a/src/native/nota.engine/src/Eq3.h b/src/native/nota.engine/src/Eq3.hindex c9cc6abc..ffc77292 100644--- a/src/native/nota.engine/src/Eq3.h+++ b/src/native/nota.engine/src/Eq3.h@@ -1,30 +1,60 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Built-in EQ-3 (device kind 16) — a three-band DJ-style PERFORMANCE EQ, not a-// small EQ-8: three fixed bands (Low / Mid / High) split by two crossover frequencies,-// each band played by a gain fader with a centre (0 dB) detent and a KILL button that-// fully removes it. The split is a Linkwitz-Riley crossover tree (24 or 48 dB/oct) built-// from cascaded TPT state-variable Butterworth sections, so at unity gains the three-// bands reconstruct flat. A core Device (JUCE-free), lock-free params. All params are-// normalized 0..1 and denormalized in process(); persistence/automation/clone flow-// generically through the base Device. A pre-EQ mono scope feeds the UI spectrum.+// Built-in Nota EQ-3 (device kind 16) — a three-band DJ-style isolator, a PERFORMANCE EQ rather+// than a small EQ-8: three fixed bands (Low / Mid / High) split by two crossover frequencies,+// each band played by a gain fader and a KILL that removes it outright.+//+// in ─▶ LR split @ low/mid ─┬─ low ─▶ allpass @ mid/high ─▶ × low gain ─┐+// └─ rest ─▶ LR split @ mid/high ┬ mid ▶ × mid ─┼─▶ × output ─▶ out+// └ high ▶ × high ─┘+//+// The split is a Linkwitz-Riley tree (24 dB/oct = LR4: two Butterworth-2 sections; 48 dB/oct = LR8:+// a Butterworth-4 twice, sections at Q 0.54 / 1.31) of TPT state-variable filters. The low band+// also runs through the mid/high split summed back (an allpass), so it stays in phase with the+// other two and at unity gains the three bands sum flat. Gains and kills glide over ~5 ms, so a+// kill never clicks.+//+// Range picks the fader law: Isolator (1, the default) spans −24 … +6 dB (0 dB at 0.8, the+// mixer-style isolator the card is drawn for); Classic (0) spans ±15 dB (0 dB at 0.5) — the+// original EQ-3 law.+//+// All params are normalized 0..1 and APPEND ONLY: 0..9 are the original layout, 10 Range is+// appended. A save from before Range carries only 0..9 and was made in the Classic law, so+// the loaders put Range back to Classic for it (paramsRestored, ProjectService, PresetService)+// — older projects, racks and presets open unchanged. Persistence / automation / clone flow+// generically through the base Device.+//+// Telemetry (scopeRead): kTele live values (peaks, per-band levels, the crossovers in use, the+// gains in effect, sample rate, CPU), then the output spectrum — kSpec log bands 20 Hz..20 kHz+// in dB from an FFT over the last ~85 ms, analysed on the reading thread (≤ 30 Hz).+// deviceText: 0 = status line, 1 = live reading, 2 = parameter guide.+// deviceAction: 0 = reset the meters (peak holds and the spectrum average).+// Header-only, allocation-free after setSampleRate. JUCE-free.#pragma once#include "Device.h"+#include "signalsmith-linear/fft.h"+#include <algorithm>#include <atomic>+#include <chrono>#include <cmath>+#include <complex>#include <cstdint>+#include <cstdio>+#include <mutex>+#include <string>+#include <vector>namespace nota {class Eq3 : public Device {public:enum {- Low = 0, // low-band gain (0.5 = 0 dB, ±15 dB, centre detent)+ Low = 0, // low-band gain (law: Range)Mid, // mid-band gainHigh, // high-band gainLowKill, // low band killed (>= 0.5)@@ -34,73 +64,158 @@ public:FreqHi, // mid/high crossover (exp 500..18000 Hz, default 2.5 kHz)Slope, // 0 = 24 dB/oct (LR4), 1 = 48 dB/oct (LR8)Gain, // output gain (0.5 = 0 dB, ±24 dB)+ Range, // fader law: 0 = Classic ±15 dB, 1 = Isolator −24 … +6 dB (appended)kNumParams};+ static constexpr int kLegacyParams = 10; // the layout before Range++ // Telemetry slots (scopeRead).+ enum {+ S_InPeak = 0, // input peak (300 ms fall), dBFS+ S_OutPeak, // output peak (300 ms fall), dBFS+ S_Level, // 3 × band peak after its gain (300 ms fall), dBFS: low, mid, high+ S_SampleRate = 5,+ S_Cpu, // share of real time spent in process()+ S_Analysed, // 1 when the spectrum is valid+ S_Latency, // samples (always 0)+ S_F1, // low/mid crossover in use, Hz+ S_F2, // mid/high crossover in use, Hz+ S_Gain, // 3 × gain in effect now (linear, after the kill glide)+ S_Bands = 14, // kSpec+ kTele = 16+ };+ static constexpr int kSpec = 96;+ static constexpr double kSpecLo = 20.0, kSpecHi = 20000.0;+ static constexpr int kScope = kTele + kSpec;Eq3() {- p_[Low].store(0.5f); p_[Mid].store(0.5f); p_[High].store(0.5f);+ p_[Low].store(0.8f); p_[Mid].store(0.8f); p_[High].store(0.8f); // 0 dB (Isolator)p_[LowKill].store(0.0f); p_[MidKill].store(0.0f); p_[HighKill].store(0.0f);p_[FreqLo].store(0.4363f); // ~250 Hzp_[FreqHi].store(0.4491f); // ~2.5 kHzp_[Slope].store(0.0f); // 24 dB/octp_[Gain].store(0.5f); // 0 dB+ p_[Range].store(1.0f); // Isolator+ for (auto& a : lvlA_) a.store(-120.0f);+ for (auto& a : gA_) a.store(1.0f);+ setSampleRate(44100.0, 0);+ }++ // Musical mappings, shared with the UI / MCP (they mirror these).+ static float gainDb(float v, bool isolator) { return isolator ? -24.0f + 30.0f * v : (v - 0.5f) * 30.0f; }+ static float gainNorm(float db, bool isolator) {+ return std::clamp(isolator ? (db + 24.0f) / 30.0f : db / 30.0f + 0.5f, 0.0f, 1.0f);}+ static double freqLoHz(float v) { return expMap(v, 50.0, 2000.0); }+ static double freqHiHz(float v) { return expMap(v, 500.0, 18000.0); }void setSampleRate(double sr, int32_t /*maxBlock*/) override {+ std::lock_guard<std::mutex> lock(mx_);sr_ = sr > 0 ? sr : 44100.0;+ srA_.store((float)sr_, std::memory_order_relaxed);for (auto& s : sec_) s.reset();gLcur_ = gMcur_ = gHcur_ = 1.0f;primed_ = false;+ inPk_ = outPk_ = 0.0f;+ for (auto& v : bandPk_) v = 0.0f;+ fftN_ = sr_ > 50000.0 ? 8192 : 4096;+ size_t ring = 1;+ while (ring < (size_t)fftN_ * 2) ring <<= 1;+ ring_.assign(ring, 0.0f);+ ringMask_ = (uint32_t)(ring - 1);+ ringW_.store(0, std::memory_order_relaxed);+ fft_.resize((size_t)fftN_);+ win_.assign((size_t)fftN_, 0.0f);+ tBuf_.assign((size_t)fftN_, 0.0f);+ fBuf_.assign((size_t)fftN_ / 2, {});+ for (int i = 0; i < fftN_; ++i) win_[(size_t)i] = (float)(0.5 - 0.5 * std::cos(2.0 * kPi * i / fftN_));+ lastAnaS_ = -1.0; lastAnaW_ = 0; anaValid_ = false;+ for (int b = 0; b < kSpec; ++b) { aSpec_[b] = 0.0; spec_[b] = -120.0f; }}- // Real-time analyzer feed: the pre-EQ mono signal, oldest→newest (like EQ-8 / Auto- // Filter), for the UI spectrum behind the response curve. Lock-free; torn reads fine.- int32_t scopeRead(float* out, int32_t maxSamples) const override {- if (!out || maxSamples <= 0) return 0;- const int32_t n = std::min(maxSamples, kScope);- const uint32_t w = scopeW_.load(std::memory_order_relaxed);- const uint32_t start = w - static_cast<uint32_t>(n);- for (int32_t k = 0; k < n; ++k) out[k] = scope_[(start + (uint32_t)k) & (kScope - 1)];- return n;+ // A loader restored the first `count` params from a save. One made before Range existed+ // was made in the Classic ±15 dB law — keep it sounding the same.+ void paramsRestored(int32_t count) override {+ if (count >= 0 && count <= kLegacyParams) p_[Range].store(0.0f, std::memory_order_relaxed);}void process(float* buf, int32_t frames) override {+ const auto t0 = std::chrono::steady_clock::now();// Crossover frequencies (keep f1 below f2 so the mid band stays sane).- double f1 = expMap(get(FreqLo), 50.0, 2000.0);- double f2 = expMap(get(FreqHi), 500.0, 18000.0);+ double f1 = freqLoHz(get(FreqLo));+ double f2 = freqHiHz(get(FreqHi));const double nyq = std::min(20000.0, sr_ * 0.45);f1 = std::clamp(f1, 20.0, nyq);f2 = std::clamp(f2, 20.0, nyq);if (f1 > f2 * 0.98) f1 = f2 * 0.98;+ f1A_.store((float)f1, std::memory_order_relaxed);+ f2A_.store((float)f2, std::memory_order_relaxed);- const int nSec = get(Slope) >= 0.5f ? 4 : 2; // LR4 (24 dB) vs LR8 (48 dB)-- // Butterworth section coeffs (Q = 1/√2) at each crossover.- const double k = 1.41421356237; // 1/Q- Coeffs c1 = coeffsFor(f1, k), c2 = coeffsFor(f2, k);+ // LR4 = Butterworth-2 twice (Q 1/√2); LR8 = Butterworth-4 twice (Q 0.5412, 1.3066).+ const bool lr8 = get(Slope) >= 0.5f;+ const int nSec = lr8 ? 4 : 2;+ Coeffs c1[kMaxSec], c2[kMaxSec];+ for (int s = 0; s < nSec; ++s) {+ const double k = lr8 ? (s % 2 == 0 ? 1.8477590650 : 0.7653668647) : 1.4142135624; // 1/Q+ c1[s] = coeffsFor(f1, k); c2[s] = coeffsFor(f2, k);+ }// Per-band linear target gains (a KILL fully removes the band).- const float gLtar = get(LowKill) >= 0.5f ? 0.0f : dbToLin((get(Low) - 0.5f) * 30.0f);- const float gMtar = get(MidKill) >= 0.5f ? 0.0f : dbToLin((get(Mid) - 0.5f) * 30.0f);- const float gHtar = get(HighKill) >= 0.5f ? 0.0f : dbToLin((get(High) - 0.5f) * 30.0f);+ const bool iso = get(Range) >= 0.5f;+ const float gLtar = get(LowKill) >= 0.5f ? 0.0f : dbToLin(gainDb(get(Low), iso));+ const float gMtar = get(MidKill) >= 0.5f ? 0.0f : dbToLin(gainDb(get(Mid), iso));+ const float gHtar = get(HighKill) >= 0.5f ? 0.0f : dbToLin(gainDb(get(High), iso));if (!primed_) { gLcur_ = gLtar; gMcur_ = gMtar; gHcur_ = gHtar; primed_ = true; }const float smooth = (float)(1.0 - std::exp(-1.0 / (0.005 * sr_))); // ~5 ms glide (click-free kills)const float outGain = std::pow(10.0f, (get(Gain) - 0.5f) * 48.0f / 20.0f);+ if (resetPk_.exchange(false, std::memory_order_acq_rel)) { inPk_ = outPk_ = 0.0f; for (auto& v : bandPk_) v = 0.0f; }+ float inPk = 0.0f, outPk = 0.0f, bPk[3] = { 0.0f, 0.0f, 0.0f };+ uint32_t w = ringW_.load(std::memory_order_relaxed);+ const bool ringOk = !ring_.empty();for (int32_t i = 0; i < frames; ++i) {const float l = buf[i * 2], r = buf[i * 2 + 1];-- // Publish the pre-EQ mono signal for the UI spectrum analyzer.- const uint32_t sw = scopeW_.load(std::memory_order_relaxed);- scope_[sw & (kScope - 1)] = 0.5f * (l + r);- scopeW_.store(sw + 1, std::memory_order_relaxed);+ inPk = std::max(inPk, std::max(std::fabs(l), std::fabs(r)));gLcur_ += (gLtar - gLcur_) * smooth;gMcur_ += (gMtar - gMcur_) * smooth;gHcur_ += (gHtar - gHcur_) * smooth;- buf[i * 2] = splitOne(0, l, nSec, c1, c2, outGain);- buf[i * 2 + 1] = splitOne(1, r, nSec, c1, c2, outGain);+ double bl[3], br[3];+ splitOne(0, l, nSec, c1, c2, bl);+ splitOne(1, r, nSec, c1, c2, br);+ const double g[3] = { gLcur_, gMcur_, gHcur_ };+ double ol = 0.0, orr = 0.0;+ for (int b = 0; b < 3; ++b) {+ const double xl = g[b] * bl[b], xr = g[b] * br[b];+ ol += xl; orr += xr;+ bPk[b] = std::max(bPk[b], (float)std::max(std::fabs(xl), std::fabs(xr)));+ }+ const float yl = (float)(ol * outGain), yr = (float)(orr * outGain);+ buf[i * 2] = yl; buf[i * 2 + 1] = yr;+ outPk = std::max(outPk, std::max(std::fabs(yl), std::fabs(yr)));+ if (ringOk) ring_[(w++) & ringMask_] = 0.5f * (yl + yr);+ }+ ringW_.store(w, std::memory_order_release);++ // Publish: peaks falling over 300 ms, band levels, gains in effect, CPU.+ const double blockS = frames > 0 ? frames / sr_ : 0.0;+ const float fall = (float)std::exp(-blockS / 0.3);+ inPk_ = std::max(inPk, inPk_ * fall);+ outPk_ = std::max(outPk, outPk_ * fall);+ inPkA_.store(db(inPk_), std::memory_order_relaxed);+ outPkA_.store(db(outPk_), std::memory_order_relaxed);+ for (int b = 0; b < 3; ++b) {+ bandPk_[b] = std::max(bPk[b], bandPk_[b] * fall);+ lvlA_[b].store(db(bandPk_[b]), std::memory_order_relaxed);+ }+ gA_[0].store(gLcur_, std::memory_order_relaxed);+ gA_[1].store(gMcur_, std::memory_order_relaxed);+ gA_[2].store(gHcur_, 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 / blockS) * 0.1;+ cpuA_.store((float)cpuS_, std::memory_order_relaxed);}}@@ -113,7 +228,7 @@ public:case Low: return "Low"; case Mid: return "Mid"; case High: return "High";case LowKill: return "Low Kill"; case MidKill: return "Mid Kill"; case HighKill: return "High Kill";case FreqLo: return "Low Freq"; case FreqHi: return "High Freq";- case Slope: return "Slope"; case Gain: return "Gain";+ case Slope: return "Slope"; case Gain: return "Gain"; case Range: return "Range";default: return "";}}@@ -123,20 +238,112 @@ public: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);+ if (i >= 0 && i < kNumParams && std::isfinite(v)) p_[i].store(std::clamp(v, 0.0f, 1.0f), std::memory_order_relaxed);+ }++ // Telemetry block, then the output spectrum. Writes as much of that layout as fits in+ // maxSamples; a read no longer than kTele skips the FFT. UI / MCP thread.+ int32_t scopeRead(float* out, int32_t maxSamples) const override {+ if (!out || maxSamples <= 0) return 0;+ float t[kTele] = {};+ t[S_InPeak] = inPkA_.load(std::memory_order_relaxed);+ t[S_OutPeak] = outPkA_.load(std::memory_order_relaxed);+ for (int b = 0; b < 3; ++b) {+ t[S_Level + b] = lvlA_[b].load(std::memory_order_relaxed);+ t[S_Gain + b] = gA_[b].load(std::memory_order_relaxed);+ }+ t[S_SampleRate] = srA_.load(std::memory_order_relaxed);+ t[S_Cpu] = cpuA_.load(std::memory_order_relaxed);+ t[S_Latency] = 0.0f;+ t[S_F1] = f1A_.load(std::memory_order_relaxed);+ t[S_F2] = f2A_.load(std::memory_order_relaxed);+ t[S_Bands] = (float)kSpec;+ int32_t n = 0;+ if (maxSamples > kTele) {+ std::lock_guard<std::mutex> lock(mx_);+ t[S_Analysed] = analyse() ? 1.0f : 0.0f;+ for (int k = 0; k < kTele && n < maxSamples; ++k) out[n++] = t[k];+ for (int b = 0; b < kSpec && n < maxSamples; ++b) out[n++] = spec_[b];+ return n;+ }+ for (int k = 0; k < kTele && n < maxSamples; ++k) out[n++] = t[k];+ return n;+ }++ void deviceAction(int32_t id, int32_t /*iarg*/, float /*farg*/) override {+ if (id != 0) return;+ std::lock_guard<std::mutex> lock(mx_);+ resetPk_.store(true, std::memory_order_release); // the audio thread drops its holds+ inPkA_.store(-120.0f, std::memory_order_relaxed);+ outPkA_.store(-120.0f, std::memory_order_relaxed);+ for (auto& a : lvlA_) a.store(-120.0f, std::memory_order_relaxed);+ lastAnaS_ = -1.0; anaValid_ = false;+ for (int b = 0; b < kSpec; ++b) { aSpec_[b] = 0.0; spec_[b] = -120.0f; }+ }++ // 0 — a one-line status; 1 — the live reading; 2 — a guide to the parameter values.+ std::string deviceText(int32_t id) const override {+ static const char* names[3] = { "low", "mid", "high" };+ char b[256];+ const bool iso = get(Range) >= 0.5f;+ if (id == 0) {+ std::snprintf(b, sizeof b, "LR%d %d dB/oct - low/mid %s - mid/high %s", get(Slope) >= 0.5f ? 8 : 4, get(Slope) >= 0.5f ? 48 : 24,+ hz(freqLoHz(get(FreqLo))).c_str(), hz(freqHiHz(get(FreqHi))).c_str());+ std::string s = b;+ for (int k = 0; k < 3; ++k) {+ if (get(LowKill + k) >= 0.5f) std::snprintf(b, sizeof b, " | %s kill", names[k]);+ else std::snprintf(b, sizeof b, " | %s %+.1f dB", names[k], gainDb(get(Low + k), iso));+ s += b;+ }+ std::snprintf(b, sizeof b, " | range %s | output %+.1f dB", iso ? "isolator -24..+6 dB" : "classic +-15 dB", (get(Gain) - 0.5f) * 48.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::snprintf(b, sizeof b, "in %s dBFS - out %s dBFS", lv(sc[S_InPeak]).c_str(), lv(sc[S_OutPeak]).c_str());+ std::string s = b;+ for (int k = 0; k < 3; ++k) {+ std::snprintf(b, sizeof b, " | %s %s dBFS (gain now %s dB)", names[k], lv(sc[S_Level + k]).c_str(),+ lv(sc[S_Gain + k] > 1e-6f ? 20.0f * std::log10(sc[S_Gain + k]) : -120.0f).c_str());+ s += b;+ }+ std::snprintf(b, sizeof b, " | crossovers %s / %s | CPU %.2f %%", hz(sc[S_F1]).c_str(), hz(sc[S_F2]).c_str(), sc[S_Cpu] * 100.0f);+ s += b;+ return s;+ }+ if (id == 2) {+ return "All params 0..1. 0 Low, 1 Mid, 2 High: the band gains - with Range = 1 (Isolator, the default) "+ "dB = -24 + 30 v (0.8 = 0 dB, 0 = -24, 1 = +6); with Range = 0 (Classic) dB = 30 (v - 0.5) (0.5 = 0 dB, "+ "+-15). 3 Low Kill, 4 Mid Kill, 5 High Kill: >= 0.5 removes the band (5 ms glide). 6 Low Freq: the low/mid "+ "crossover, 50 * 40^v Hz (0.4363 = 250 Hz). 7 High Freq: the mid/high crossover, 500 * 36^v Hz (0.4491 = "+ "2.5 kHz); the low/mid crossover is held below it. 8 Slope: 0 = 24 dB/oct (Linkwitz-Riley 4), 1 = 48 dB/oct "+ "(LR8). 9 Gain: output, (v - 0.5) * 48 dB. 10 Range: the fader law, 0 Classic / 1 Isolator (switching it "+ "does not move the gain params - re-set them to keep the same dB).";+ }+ return {};}private:- static constexpr int32_t kScope = 4096; // power of two+ static constexpr double kPi = 3.14159265358979323846;static constexpr int32_t kMaxSec = 4; // cascade depth for LR8 (48 dB/oct)+ static constexpr int32_t kGroups = 6; // per channel: f1 LP / HP, f2 LP / HP, the low band's f2 allpassfloat 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 dbToLin(float db) { return std::pow(10.0f, db / 20.0f); }+ static float db(float lin) { return lin > 1e-6f ? std::max(-120.0f, 20.0f * std::log10(lin)) : -120.0f; }+ static std::string hz(double f) {+ char t[24];+ if (f >= 1000.0) std::snprintf(t, sizeof t, "%.1f kHz", f / 1000.0); else std::snprintf(t, sizeof t, "%.0f Hz", f);+ return t;+ }struct Coeffs { double a1, a2, a3, k; };Coeffs coeffsFor(double fc, double k) const {- const double g = std::tan(3.14159265358979323846 * fc / sr_);+ const double g = std::tan(kPi * fc / sr_);const double a1 = 1.0 / (1.0 + g * (g + k));return { a1, g * a1, g * (g * a1), k };}@@ -157,35 +364,94 @@ private:// Cascade `n` sections taking the lowpass (or highpass) output forward — n identical// Butterworth-2 stages give a 2n-th-order Linkwitz-Riley response.- inline double cascadeLP(Svf* s, int n, double x, const Coeffs& c) {+ static inline double cascadeLP(Svf* s, int n, double x, const Coeffs* c) {double lp, hp;- for (int i = 0; i < n; ++i) { s[i].tick(x, c, lp, hp); x = lp; }+ for (int i = 0; i < n; ++i) { s[i].tick(x, c[i], lp, hp); x = lp; }return x;}- inline double cascadeHP(Svf* s, int n, double x, const Coeffs& c) {+ static inline double cascadeHP(Svf* s, int n, double x, const Coeffs* c) {double lp, hp;- for (int i = 0; i < n; ++i) { s[i].tick(x, c, lp, hp); x = hp; }+ for (int i = 0; i < n; ++i) { s[i].tick(x, c[i], lp, hp); x = hp; }return x;}- // Split one sample into three bands (serial LR crossover tree) and remix.- inline float splitOne(int ch, float x, int nSec, const Coeffs& c1, const Coeffs& c2, float outGain) {- Svf* g = sec_ + ch * (kMaxSec * 4);- const double low = cascadeLP(g + kMaxSec * 0, nSec, x, c1);+ // Split one sample into the three bands (serial LR crossover tree); the low band passes the+ // mid/high split summed back — an allpass that keeps it in phase with mid + high.+ inline void splitOne(int ch, float x, int nSec, const Coeffs* c1, const Coeffs* c2, double* band) {+ Svf* g = sec_ + ch * (kMaxSec * kGroups);const double rest = cascadeHP(g + kMaxSec * 1, nSec, x, c1);- const double mid = cascadeLP(g + kMaxSec * 2, nSec, rest, c2);- const double high = cascadeHP(g + kMaxSec * 3, nSec, rest, c2);- return (float)((gLcur_ * low + gMcur_ * mid + gHcur_ * high) * outGain);+ const double low = cascadeLP(g + kMaxSec * 0, nSec, x, c1);+ band[0] = cascadeLP(g + kMaxSec * 4, nSec, low, c2) + cascadeHP(g + kMaxSec * 5, nSec, low, c2);+ band[1] = cascadeLP(g + kMaxSec * 2, nSec, rest, c2);+ band[2] = cascadeHP(g + kMaxSec * 3, nSec, rest, c2);+ }++ // ---- output spectrum (reading thread, rate-limited, under mx_) -----------------------+ static double nowSeconds() {+ return std::chrono::duration<double>(std::chrono::steady_clock::now().time_since_epoch()).count();+ }+ bool analyse() const {+ if (ring_.empty() || fftN_ <= 0) return false;+ const double now = nowSeconds();+ const uint32_t w = ringW_.load(std::memory_order_acquire);+ if (lastAnaS_ >= 0 && (now - lastAnaS_ < 1.0 / 30.0 || w == lastAnaW_)) return anaValid_;+ if (w < (uint32_t)fftN_) return anaValid_;+ const int n = fftN_;+ const uint32_t start = w - (uint32_t)n;+ for (int i = 0; i < n; ++i) tBuf_[(size_t)i] = ring_[(start + (uint32_t)i) & ringMask_] * win_[(size_t)i];+ fft_.fft(tBuf_.data(), fBuf_.data());+ const int half = n / 2;+ const double binHz = sr_ / n;+ const double ref = 0.25 * (double)n * n * 0.25; // Hann: a full-scale sine's bin power+ const bool stale = lastAnaS_ < 0 || now - lastAnaS_ > 1.2;+ const double a = stale ? 1.0 : 1.0 - std::exp(-(now - lastAnaS_) / 0.2);+ double tot = 0.0;+ for (int b = 0; b < kSpec; ++b) {+ const double lo = kSpecLo * std::pow(kSpecHi / kSpecLo, (double)b / kSpec);+ const double hi = kSpecLo * std::pow(kSpecHi / kSpecLo, (double)(b + 1) / kSpec);+ int k0 = std::max(1, (int)std::ceil(lo / binHz)), k1 = std::min(half - 1, (int)std::ceil(hi / binHz) - 1);+ if (k1 < k0) k0 = k1 = std::clamp((int)std::lround(std::sqrt(lo * hi) / binHz), 1, half - 1);+ double s = 0.0;+ for (int k = k0; k <= k1; ++k) s += std::norm(fBuf_[(size_t)k]);+ tot += s;+ aSpec_[b] += a * (s - aSpec_[b]);+ spec_[b] = aSpec_[b] > ref * 1e-12 ? (float)std::max(-120.0, 10.0 * std::log10(aSpec_[b] / ref)) : -120.0f;+ }+ lastAnaS_ = now; lastAnaW_ = w;+ anaValid_ = tot > ref * 1e-10;+ return anaValid_;}double sr_ = 44100.0;std::atomic<float> p_[kNumParams] = {};- // Per channel: 4 cascade groups (f1-LP, f1-HP, f2-LP, f2-HP) × kMaxSec sections.- Svf sec_[2 * kMaxSec * 4];+ // Per channel: kGroups cascade groups × kMaxSec sections.+ Svf sec_[2 * kMaxSec * kGroups];float gLcur_ = 1.0f, gMcur_ = 1.0f, gHcur_ = 1.0f; // smoothed band gains (click-free)bool primed_ = false;- mutable float scope_[kScope] = {}; // pre-EQ mono ring (UI spectrum)- std::atomic<uint32_t> scopeW_{0};++ // Meters (audio thread) and their published values.+ float inPk_ = 0.0f, outPk_ = 0.0f, bandPk_[3] = {};+ double cpuS_ = 0.0;+ std::atomic<float> inPkA_{-120.0f}, outPkA_{-120.0f}, cpuA_{0.0f}, srA_{44100.0f}, f1A_{250.0f}, f2A_{2500.0f};+ std::atomic<float> lvlA_[3];+ std::atomic<float> gA_[3];+ std::atomic<bool> resetPk_{false};++ // Spectrum: a ring written by the audio thread, the analysis state under mx_.+ std::vector<float> ring_;+ uint32_t ringMask_ = 0;+ std::atomic<uint32_t> ringW_{0};+ int fftN_ = 0;+ mutable std::mutex mx_;+ mutable signalsmith::linear::RealFFT<float> fft_;+ std::vector<float> win_;+ mutable std::vector<float> tBuf_;+ mutable std::vector<std::complex<float>> fBuf_;+ mutable double aSpec_[kSpec] = {};+ mutable float spec_[kSpec] = {};+ mutable double lastAnaS_ = -1.0;+ mutable uint32_t lastAnaW_ = 0;+ mutable bool anaValid_ = false;};} // namespace notadiff --git a/src/native/nota.engine/src/RackCore.h b/src/native/nota.engine/src/RackCore.hindex 92bd1c10..e7ee1ea7 100644--- a/src/native/nota.engine/src/RackCore.h+++ b/src/native/nota.engine/src/RackCore.h@@ -626,6 +626,7 @@ public:if (dev) dev->setParam(static_cast<int32_t>(p), pv);}if (dev) {+ dev->paramsRestored(static_cast<int32_t>(pc));if (dsPtr && dsLen > 0) dev->setState(dsPtr, static_cast<int32_t>(dsLen));dev->setBypassed(byp);c.devices.push_back(dev);diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 437ea3cf..ffba0af9 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -4364,8 +4364,8 @@ Console.WriteLine("-- Nota Strata --");// ============================ Nota EQ-3 ====================================Console.WriteLine("-- Nota EQ-3 --");{- // EQ-3 = 3-band performance EQ (kind 16). Bands: 0 Low 1 Mid 2 High (0.5 = 0 dB),- // 3/4/5 kills, 6/7 crossovers, 8 slope, 9 output gain.+ // EQ-3 = 3-band isolator (kind 16). Bands: 0 Low 1 Mid 2 High (Isolator law: 0.8 = 0 dB),+ // 3/4/5 kills, 6/7 crossovers, 8 slope, 9 output gain, 10 Range (appended).int qt = engine.AddInstrumentTrack();engine.AddMidiClip(qt, 0.0, 4.0);engine.SetClipNotes(qt, 0, new[] { new NotaNote(45, 0.0, 3.0, 0.9f) }); // low note → energy in all bands@@ -4373,25 +4373,26 @@ Console.WriteLine("-- Nota EQ-3 --");Check(q3 >= 0, "add built-in Nota EQ-3");Check(engine.DeviceName(qt, q3) == "Nota EQ-3", $"name is Nota EQ-3 (got '{engine.DeviceName(qt, q3)}')");Check(engine.TrackDeviceBuiltinKind(qt, q3) == 16, $"builtin kind is 16 (got {engine.TrackDeviceBuiltinKind(qt, q3)})");- Check(engine.DeviceParamCount(qt, q3) == 10, $"Nota EQ-3 exposes 10 params (got {engine.DeviceParamCount(qt, q3)})");+ Check(engine.DeviceParamCount(qt, q3) == 11 && engine.DeviceParamName(qt, q3, 10) == "Range", $"Nota EQ-3 exposes 11 params, Range appended (got {engine.DeviceParamCount(qt, q3)})");+ Check(engine.DeviceGetParam(qt, q3, 10) > 0.5f && Math.Abs(engine.DeviceGetParam(qt, q3, 0) - 0.8f) < 1e-4, "a new EQ-3 is in the Isolator range at 0 dB (0.8)");// Param round-trip.engine.DeviceSetParam(qt, q3, 0, 0.75f);Check(Math.Abs(engine.DeviceGetParam(qt, q3, 0) - 0.75f) < 1e-4, "EQ-3 param set/get round-trips");// Flat (defaults) passes audio finite + audible.- engine.DeviceSetParam(qt, q3, 0, 0.5f);+ engine.DeviceSetParam(qt, q3, 0, 0.8f);var qb = new float[8192 * 2];engine.Seek(0); engine.Play(); engine.RenderOffline(qb, 8192); engine.StopTransport();bool qfin = true; foreach (var s in qb) if (!float.IsFinite(s)) { qfin = false; break; }Check(qfin && Rms(qb, 8192) > 0.001f, $"EQ-3 passes audio flat (rms {Rms(qb, 8192):F3})");- // Analyzer scope feeds the UI spectrum.- var qsc = new float[2048];+ // Telemetry + the output spectrum feed the card.+ var qsc = new float[16 + 96];engine.Seek(0); engine.Play(); engine.RenderOffline(qb, 8192);int qn = engine.DeviceScope(qt, q3, qsc, qsc.Length);engine.StopTransport();- Check(qn > 0, $"EQ-3 scope returns samples (got {qn})");+ Check(qn == 112 && qsc[5] > 1000 && qsc[1] > -60 && qsc[7] > 0.5f, $"EQ-3 scope returns the telemetry and the spectrum ({qn}, sr {qsc[5]}, out {qsc[1]:F1} dBFS)");// Killing the low band drops low-frequency energy: render bass-heavy note with low kill.float rmsFullQ = Rms(qb, 8192);@@ -4422,6 +4423,125 @@ Console.WriteLine("-- Nota EQ-3 --");engine.Seek(1.99); engine.Play(); engine.RenderOffline(qb, 4096); engine.StopTransport();Check(engine.DeviceGetParam(qt, q3, 0) > 0.7f, $"automation drives EQ-3 Low ({engine.DeviceGetParam(qt, q3, 0):F2})");}+{+ // The 440 Hz smoke sine through EQ-3 on an audio track: flat sum at a crossover, kill depth,+ // the ranges, texts, MCP and presets.+ using var qe = new NotaEngine();+ qe.SetBpm(120);+ int qt = qe.AddAudioTrack();+ qe.AddAudioClip(qt, wav, 0.0);+ int qd = qe.AddBuiltinDevice(qt, 16);+ float[] Render(int frames) { var b = new float[frames * 2]; qe.Seek(0); qe.Play(); qe.RenderOffline(b, frames); qe.StopTransport(); return b; }+ double Level() { var b = Render(22050); double a = 0; for (int i = 11025 * 2; i < 22050 * 2; i++) a += b[i] * b[i]; return 10 * Math.Log10(a / (11025 * 2) + 1e-30); }+ qe.SetDeviceBypassed(qt, qd, true);+ double dry = Level();+ qe.SetDeviceBypassed(qt, qd, false);++ // Unity: the bands sum flat — also with a crossover right on the sine, at either slope.+ float x440 = (float)(Math.Log(440.0 / 50) / Math.Log(40)), x440h = (float)(Math.Log(880.0 / 500) / Math.Log(36));+ foreach (float sl in new[] { 0f, 1f })+ {+ qe.DeviceSetParam(qt, qd, 8, sl);+ qe.DeviceSetParam(qt, qd, 6, x440); qe.DeviceSetParam(qt, qd, 7, x440h);+ double a = Level();+ qe.DeviceSetParam(qt, qd, 6, (float)(Math.Log(200.0 / 50) / Math.Log(40)));+ qe.DeviceSetParam(qt, qd, 7, (float)(Math.Log(520.0 / 500) / Math.Log(36)));+ double b = Level();+ Check(Math.Abs(a - dry) < 0.3 && Math.Abs(b - dry) < 0.3,+ $"EQ-3 at unity sums flat at {(sl > 0.5f ? 48 : 24)} dB/oct (crossover on the sine {a - dry:F2} dB, between close crossovers {b - dry:F2} dB)");+ }+ qe.DeviceSetParam(qt, qd, 6, 0.4363f); qe.DeviceSetParam(qt, qd, 7, 0.4491f);++ // Mid kill takes the sine (in the mid band) away; 48 dB/oct deeper than 24.+ qe.DeviceSetParam(qt, qd, 4, 1f);+ qe.DeviceSetParam(qt, qd, 8, 0f); double k24 = Level() - dry;+ qe.DeviceSetParam(qt, qd, 8, 1f); double k48 = Level() - dry;+ Check(k24 < -15 && k48 < k24 - 10, $"mid kill removes a 440 Hz sine ({k24:F1} dB at 24, {k48:F1} dB at 48 dB/oct)");+ qe.DeviceSetParam(qt, qd, 4, 0f); qe.DeviceSetParam(qt, qd, 8, 0f);++ // Isolator law: every band at its floor is −24 dB; +6 at the top.+ for (int b = 0; b < 3; b++) qe.DeviceSetParam(qt, qd, b, 0f);+ double floor = Level() - dry;+ for (int b = 0; b < 3; b++) qe.DeviceSetParam(qt, qd, b, 1f);+ double top = Level() - dry;+ Check(Math.Abs(floor + 24) < 0.5 && Math.Abs(top - 6) < 0.5, $"Isolator range: −24 … +6 dB ({floor:F1} / {top:+0.0})");+ // Classic law: 0.5 = 0 dB, 0 = −15 dB.+ qe.DeviceSetParam(qt, qd, 10, 0f);+ for (int b = 0; b < 3; b++) qe.DeviceSetParam(qt, qd, b, 0.5f);+ double cFlat = Level() - dry;+ for (int b = 0; b < 3; b++) qe.DeviceSetParam(qt, qd, b, 0f);+ double cFloor = Level() - dry;+ Check(Math.Abs(cFlat) < 0.3 && Math.Abs(cFloor + 15) < 0.5, $"Classic range: 0.5 = 0 dB, 0 = −15 dB ({cFlat:+0.0;-0.0} / {cFloor:F1})");+ qe.DeviceSetParam(qt, qd, 10, 1f);+ for (int b = 0; b < 3; b++) qe.DeviceSetParam(qt, qd, b, 0.8f);++ // Output gain and the telemetry: band levels, the gain in effect, crossovers in use.+ qe.DeviceSetParam(qt, qd, 9, 0.5f - 6f / 48);+ double og = Level() - dry;+ Check(Math.Abs(og + 6) < 0.3, $"output gain −6 dB ({og:F1})");+ qe.DeviceSetParam(qt, qd, 9, 0.5f);+ qe.DeviceSetParam(qt, qd, 3, 1f);+ Render(4096); // the kill's 5 ms glide+ qe.DeviceAction(qt, qd, 0, 0, 0); // fresh meters+ Render(8192);+ var qs = new float[112];+ int qn = qe.DeviceScope(qt, qd, qs, qs.Length);+ Check(qn == 112 && qs[3] > qs[2] + 20 && qs[3] > -30 && qs[11] < 0.01f && Math.Abs(qs[12] - 1) < 0.01f && Math.Abs(qs[9] - 250) < 5 && Math.Abs(qs[10] - 2500) < 30,+ $"telemetry: band levels L {qs[2]:F0} / M {qs[3]:F1} dBFS, low gain {qs[11]:F3} (killed), crossovers {qs[9]:F0} / {qs[10]:F0} Hz");+ int pk = 0; for (int b = 1; b < 96; b++) if (qs[16 + b] > qs[16 + pk]) pk = b;+ double pkHz = 20 * Math.Pow(1000, (pk + 0.5) / 96);+ Check(qs[7] > 0.5f && pkHz > 380 && pkHz < 520, $"the output spectrum peaks at the sine (~{pkHz:0} Hz)");++ // Texts.+ string t0 = qe.DeviceText(qt, qd, 0), t1 = qe.DeviceText(qt, qd, 1), tg = qe.DeviceText(qt, qd, 2);+ Check(t0.Contains("LR4") && t0.Contains("low kill") && t0.Contains("isolator") && t1.Contains("gain now") && tg.Contains("Range"),+ $"device texts: status '{t0[..Math.Min(70, t0.Length)]}…', live, guide");+ qe.DeviceSetParam(qt, qd, 3, 0f);++ // MCP: set in dB / Hz, read it back; switching the range keeps the dB.+ var qtools = new Nota.Mcp.Tools.DeviceTools(qe, new Nota.SmokeTest.SyncDispatch(), new Nota.SmokeTest.NoRefresh());+ var r1 = qtools.SetEq3(qt, qd, lowDb: -6, midDb: 3, highKill: true, lowMidHz: 300, midHighHz: 4000, slope: 48, outputDb: -2).Result;+ Check(Math.Abs(r1.Bands[0].GainDb + 6) < 0.05 && Math.Abs(r1.Bands[1].GainDb - 3) < 0.05 && r1.Bands[2].Killed && Math.Abs(r1.LowMidHz - 300) < 1+ && Math.Abs(r1.MidHighHz - 4000) < 2 && r1.SlopeDbPerOct == 48 && Math.Abs(r1.OutputDb + 2) < 0.05 && r1.Range == "Isolator",+ $"MCP set_eq3 edits in dB and Hz ({r1.Bands[0].GainDb} / {r1.Bands[1].GainDb} dB, {r1.LowMidHz} / {r1.MidHighHz} Hz)");+ var r2 = qtools.SetEq3(qt, qd, range: "Classic").Result;+ Check(r2.Range == "Classic" && Math.Abs(r2.Bands[0].GainDb + 6) < 0.05 && Math.Abs(r2.Bands[1].GainDb - 3) < 0.05 && r2.MaxGainDb == 15,+ $"MCP set_eq3 range Classic keeps each band's dB ({r2.Bands[0].GainDb} / {r2.Bands[1].GainDb})");+ var r3 = qtools.SetEq3(qt, qd, midHighHz: 500).Result;+ Check(r3.LowMidHz <= r3.MidHighHz / 2 + 1, $"MCP set_eq3 keeps low/mid at most half mid/high ({r3.LowMidHz} / {r3.MidHighHz})");+ Render(8192);+ var rr = qtools.ReadEq3(qt, qd).Result;+ Check(rr.Spectrum.Length == 24 && rr.SpectrumValid && rr.Summary.Length > 0 && rr.Live.Length > 0 && rr.SampleRate > 1000 && rr.OutputPeakDb > -60,+ $"MCP read_eq3 reports the settings, levels and spectrum (out {rr.OutputPeakDb} dBFS)");++ // A preset from before Range (no "Range" named) loads in the Classic law.+ var legacy = new PresetDocument { Type = "builtin-effect", BuiltinKind = 16, NamedParams = new Dictionary<string, float> { ["Low"] = 0.5f, ["Mid"] = 0.5f, ["High"] = 0.7f } };+ PresetService.ApplyInPlace(legacy, qe, qt, qd);+ Check(qe.DeviceGetParam(qt, qd, 10) < 0.5f, "a pre-Range EQ-3 preset loads in the Classic ±15 dB law");++ // Every factory preset names only real params and renders finite + audible.+ var qcat = new FactoryPresetCatalog();+ int qPresets = 0; bool qNamesOk = true, qPresetsOk = true;+ var qNames = new HashSet<string>();+ for (int p = 0; p < qe.DeviceParamCount(qt, qd); p++) qNames.Add(qe.DeviceParamName(qt, qd, p));+ foreach (var info in qcat.All())+ {+ if (info.IsInstrument || info.IsMidiEffect || info.BuiltinKind != 16) continue;+ var doc = qcat.Document(info.Id);+ if (doc is null) continue;+ qPresets++;+ foreach (var k in doc.NamedParams!.Keys) if (!qNames.Contains(k)) { qNamesOk = false; Console.WriteLine($" unknown param '{k}' in {info.DisplayName}"); }+ if (!doc.NamedParams.ContainsKey("Range")) { qNamesOk = false; Console.WriteLine($" {info.DisplayName} names no Range"); }+ qcat.ApplyInPlace(qe, info.Id, qt, qd);+ var pb = Render(22050);+ bool ok = true;+ foreach (var v in pb) if (!float.IsFinite(v) || Math.Abs(v) > 4f) { ok = false; break; }+ if (!ok) { qPresetsOk = false; Console.WriteLine($" preset {info.DisplayName} not finite / over"); }+ }+ Check(qPresets >= 25 && qNamesOk && qPresetsOk, $"{qPresets} EQ-3 factory presets, all params known, all render finite");+ qcat.ApplyInPlace(qe, "eq3/Init", qt, qd);+ Check(qe.DeviceGetParam(qt, qd, 10) > 0.5f && Math.Abs(qe.DeviceGetParam(qt, qd, 1) - 0.8f) < 1e-4, "the Init preset is Isolator, flat");+}// ============================ Nota Shutter =================================Console.WriteLine("-- Nota Shutter --");