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 Bass
Egor Khindikaynen9fe1ea6ab19a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 06c8e8d6..39e11f77 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,23 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Nota Bass grew performance wheels, a Legato switch and an output pan, and its editor+ is now the almanac's card.** A **pitch-bend** wheel with a selectable **range** (±2 / ±5+ / ±12 semitones) and a **mod wheel** that opens the LFO onto the cutoff — a wobble you+ play by hand — sit in a rail that stays on screen on both tabs. **Legato** decides what+ a note played over a held one does in mono: slide into it without a new attack (the+ 303 way), or — the default — attack afresh with the glide still sliding the pitch. The+ card shrinks from the full window width to **700 × 260** and lays the synth out as+ **Signal** (Osc, Sub and Filter as three rows: wave chips, shape, pulse width, tuning and+ level; the sub's wave, octave and level with the mix sum; the filter's type and slope,+ its response as a drag pad and cutoff, resonance, drive, env and key amounts) and+ **Mod** (both envelopes drawn and draggable, the LFO with its destinations and the+ velocity amounts), beside a **Global** rail — voice mode, glide, unison, drive, bend+ range, legato, volume, pan and the track's meter — and a status strip that reads the+ patch back in words. Projects saved before this load unchanged: the existing parameters+ keep their index and the new ones start neutral.+- **Nota Bass ships 25 factory presets** (was 6) — subs, plucks, acid lines, wobbles,+ reeses, stabs and slides, including the six that existed before under their old names.- **Nota Aurora grew performance wheels, eight macros and a switchable FX chain, and itseditor is now the almanac's card.** A **pitch-bend** wheel with a selectable **range**(±2 / ±5 / ±12 semitones) joins the mod wheel in a rail that stays on screen on every@@ -242,6 +259,17 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.tokens its own comments named.### Fixed+- **Nota Bass: back-to-back notes no longer drop out.** Two things silenced the next note of+ a tight line. A note-off released *every* note of its pitch, so when a repeated note+ started a sample before the previous one ended (float rounding, a Note Length or arp+ device, notes drawn overlapping) the new note was cut off the moment the old one ended —+ in mono and poly alike. And in mono with glide on, any overlap was taken as legato and+ skipped the attack, so on a plucky patch whose envelope had already decayed the next+ note never sounded. A note-off now releases only the oldest held instance of its pitch,+ and an overlapping note attacks afresh unless the new **Legato** switch is on. A+ retrigger of a still-sounding voice starts from where its envelopes are, so it never+ clicks. Switching Poly → Mono while chords are held no longer leaves those voices+ hanging.- A MIDI mapping onto a switch (mute, solo, a transport button) fired on every incomingmessage past the half-way point, so sweeping a mapped CC across it made the targetflutter instead of toggling once. It now fires on the crossing only — which is also whatdiff --git a/FEATURES.md b/FEATURES.mdindex 125a1f44..dc99efbe 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -281,7 +281,12 @@ and user presets, automation, persistence and cloning.- **Nota Pendulum** — a "pendulum" sequencer: swinging balls generate notes, with swingcurves (Linear/Pendulum/Ease/Bounce), bipolar Rate, a held chord, Scale, Hold, FirstNote, Reset, Humanize and Pan Spread.-- **Nota Bass** — bass synth, mono (legato with glide) and poly modes.+- **Nota Bass** — mono-first bass synth: a morphing oscillator (sine → tri → saw → pulse,+ pulse width), a sub oscillator (sine/square/tri, −1/−2 oct), a filter (LP/HP/BP/Notch,+ 12/24 dB) with pre-drive, its own envelope, key tracking and LFO, amp envelope, LFO to+ cutoff and pitch, unison, output drive and pan, glide, Legato, pitch-bend (±2/±5/±12)+ and mod wheels (the wheel opens the LFO onto the cutoff), VEL→AMP, VEL→FILTER,+ Mono/Poly. 25 factory presets.- **Nota Physical** — physical modelling.- **Nota Flux** — vector-morphing analog synth: an XY pad with four "timbre worlds"(WARM/GLASS/MOOG/GRAIN), **React** (sidechain modulation from another track:diff --git a/src/managed/Nota.App/Controls/SliderTrack.cs b/src/managed/Nota.App/Controls/SliderTrack.csindex 9c789329..7920fa2c 100644--- a/src/managed/Nota.App/Controls/SliderTrack.cs+++ b/src/managed/Nota.App/Controls/SliderTrack.cs@@ -4,7 +4,9 @@// The horizontal slider from the almanac's slider row: a 3px track in the well colour, a// brass fill, and a 6×7 Brass Light handle. Bipolar sliders fill from the centre and show// a 1px centre mark. An inactive slider (IsDim) loses brass — fill Border strong, handle-// Ink 5 — but keeps its position, so the number next to it stays meaningful.+// Ink 5 — but keeps its position, so the number next to it stays meaningful. A+// modulation-depth slider (Modulation) draws in teal instead of brass, like the teal+// arc of a modulation knob.//// It works in normalised 0..1; the caller maps to the parameter (linear, log, stepped).// Interaction follows the almanac (§ States · cursors): ns-resize, a vertical drag — up@@ -28,6 +30,8 @@ internal sealed class SliderTrack : Controlprivate static readonly IBrush Fill = NotaPalette.Accent;private static readonly IBrush FillDim = NotaPalette.BorderStrong;private static readonly IBrush Handle = NotaPalette.AccentBright;+ private static readonly IBrush ModFill = NotaPalette.Teal;+ private static readonly IBrush ModHandle = NotaPalette.TealBright;private static readonly IBrush HandleDim = NotaPalette.TextTertiary;private static readonly IBrush Centre = NotaPalette.BorderStrong;@@ -39,6 +43,9 @@ internal sealed class SliderTrack : Controlpublic bool Bipolar { get; init; }+ /// <summary>A modulation depth: teal fill and handle instead of brass.</summary>+ public bool Modulation { get; init; }+/// <summary>Double-click handler (restore the default). Null disables double-click.</summary>public Action? Reset { get; init; }@@ -121,12 +128,12 @@ internal sealed class SliderTrack : Controldouble x = _norm * w;double a = Bipolar ? Math.Min(w / 2, x) : 0, b = Bipolar ? Math.Max(w / 2, x) : x;if (b - a > 0.5)- ctx.DrawRectangle(_dim ? FillDim : Fill, null, new RoundedRect(new Rect(a, ty, b - a, TrackH), NotaRadius.ClipValue));+ ctx.DrawRectangle(_dim ? FillDim : Modulation ? ModFill : Fill, null, new RoundedRect(new Rect(a, ty, b - a, TrackH), NotaRadius.ClipValue));if (Bipolar)ctx.FillRectangle(Centre, new Rect(Math.Round(w / 2) - 0.5, cy - 3, 1, 6));double hx = Math.Clamp(x, HandleW / 2, w - HandleW / 2) - HandleW / 2;- ctx.DrawRectangle(_dim ? HandleDim : Handle, null,+ ctx.DrawRectangle(_dim ? HandleDim : Modulation ? ModHandle : Handle, null,new RoundedRect(new Rect(hx, cy - HandleH / 2, HandleW, HandleH), NotaRadius.ClipValue));}}diff --git a/src/managed/Nota.App/Controls/VoltEnv.cs b/src/managed/Nota.App/Controls/VoltEnv.csindex 3b135188..a24d7c40 100644--- a/src/managed/Nota.App/Controls/VoltEnv.cs+++ b/src/managed/Nota.App/Controls/VoltEnv.cs@@ -32,6 +32,10 @@ namespace Nota.App;// Curve accent (Nota Operator tints modulator envelopes teal); defaults to brass.public IBrush Accent { get; set; } = AccentBright;+ // Draw the title in the plot's corner. Off when the card already names the graph+ // in a header above it (Nota Bass).+ public bool ShowTitle { get; set; } = true;+public VoltEnv(IAudioEngine e, int t) { _e = e; _t = t; MinWidth = 150; MinHeight = 96; }public void Target(string title, (int, string) a, (int, string) d, (int, string) s, (int, string) r){ _title = title; _a = a; _d = d; _s = s; _r = r; InvalidateVisual(); }@@ -109,6 +113,7 @@ namespace Nota.App;ctx.DrawLine(pen, new Point(xh, sy), new Point(xr, bot));foreach (var pt in new[] { new Point(xa, top), new Point(xd, sy), new Point(xr, bot) })ctx.DrawEllipse(Accent, null, pt, 3.2, 3.2);- ctx.DrawText(new FormattedText(_title, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Face, 8, TextTertiary), new Point(x0, 5));+ if (ShowTitle)+ ctx.DrawText(new FormattedText(_title, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Face, 8, TextTertiary), new Point(x0, 5));}}diff --git a/src/managed/Nota.App/DeviceCardKit.cs b/src/managed/Nota.App/DeviceCardKit.csindex 691a8259..87bbd73e 100644--- a/src/managed/Nota.App/DeviceCardKit.cs+++ b/src/managed/Nota.App/DeviceCardKit.cs@@ -113,10 +113,11 @@ internal static class DeviceCardKit// Segments, as the almanac draws them: a recessed container, and the chosen segment in// solid brass with dark text — a fill, not an outline. 9px inside a device. Two to four// choices; more than four is a dropdown. `current` returns the lit index, or −1 when- // the value sits between choices. `fill` spreads the segments over the full width.+ // the value sits between choices. `fill` spreads the segments over the full width;+ // `padX` narrows each segment's side padding where a strip must fit a tight column.// Left button picks; right-click bubbles. `sync` repaints — register it with the card.internal static Border Segments(string[] names, Func<int> current, Action<int> pick, out Action sync,- bool fill = false, double minSegWidth = 0, Func<bool>? dim = null)+ bool fill = false, double minSegWidth = 0, Func<bool>? dim = null, double padX = 6){int n = names.Length;var cells = new Border[n];@@ -132,7 +133,7 @@ internal static class DeviceCardKit};var c = new Border{- CornerRadius = NotaRadius.Badge, Padding = new Thickness(6, 1), MinWidth = minSegWidth,+ CornerRadius = NotaRadius.Badge, Padding = new Thickness(padX, 1), MinWidth = minSegWidth,Cursor = new Cursor(StandardCursorType.Hand), Background = Brushes.Transparent, Child = tb,};c.PointerPressed += (_, e) =>@@ -188,13 +189,14 @@ internal static class DeviceCardKit// Works in normalised 0..1: `norm` reads, `setNorm` writes (the caller maps to the// parameter and does its own follow-up); `text` formats the value for display.// `trackWidth` fixes the track, otherwise it stretches. An empty label drops the- // label column. `sync` repaints from `norm` and skips while the hand is on the slider.+ // label column. `modulation` draws a modulation depth in teal. `sync` repaints from+ // `norm` and skips while the hand is on the slider.internal static Grid SliderRow(string label, Func<double> norm, Action<double> setNorm, Func<string> text, out Action sync,Action? begin = null, Action? end = null, Action? reset = null, bool bipolar = false, Func<bool>? dim = null,- double labelWidth = 0, double trackWidth = double.NaN, double valueWidth = 42)+ double labelWidth = 0, double trackWidth = double.NaN, double valueWidth = 42, bool modulation = false){Action repaint = () => { };- var track = new SliderTrack { Bipolar = bipolar, Reset = reset is null ? null : () => { reset(); repaint(); } };+ var track = new SliderTrack { Bipolar = bipolar, Modulation = modulation, Reset = reset is null ? null : () => { reset(); repaint(); } };if (!double.IsNaN(trackWidth)) track.Width = trackWidth;var val = new TextBlock{diff --git a/src/managed/Nota.App/DeviceCards/Instruments/BassInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/BassInstrumentCard.csindex 58c32852..06b640e6 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/BassInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/BassInstrumentCard.cs@@ -1,13 +1,24 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Detail · Devices — built-in Nota Bass editor (instrument kind 7): a mono-first-// subtractive bass synth laid out as a signal chain over two tabs — SIGNAL PATH-// (Osc → Sub → Filter → Output) and MODULATION (Amp/Filter envelopes → LFO →-// Global/glide/mono). The filter response and both envelopes are interactive drag-// graphs (VoltFilter / VoltEnv); the main oscillator uses a continuous Shape/PW-// morph; sub-wave, filter type/slope, LFO wave and mono/poly are chips.-// Modulation depths use teal knobs. Follows automation live via SetInstLiveViz.+// Detail · Devices — built-in Nota Bass editor (instrument kind 7): a mono-first bass+// synth in the 700 × 260 card the almanac draws for it.+//+// Wheels 56 pitch bend and mod wheel (the wheel opens the LFO onto the cutoff), on+// screen on both tabs.+// Centre two tabs:+// Signal — Osc, Sub and Filter as three rows top to bottom: the main+// oscillator's wave, shape, pulse width, tuning and level; the sub's+// wave, octave and level with the mix sum; the filter's type and+// slope, its response as a drag pad, and cutoff, resonance, drive,+// env and key amounts.+// Mod — the amp and filter envelopes drawn and draggable, and the LFO+// with its two destinations and the velocity amounts.+// Rail 186 Global: voice mode, glide, unison, output drive, bend range, legato,+// volume, pan and the track's meter.+//+// Brass is the parameter itself; teal is modulation and what receives it. Everything is a+// plugin param → automation / persist / clone, and the card follows automation live.using System;using System.Collections.Generic;@@ -23,25 +34,49 @@ namespace Nota.App;internal sealed class BassInstrumentCard : IInstrumentCard{- // Mockup palette (matches the Nota Bass Mockup.html and VoltInstrumentCard).- private static readonly IBrush CardBg = NotaPalette.BgApp;- private static readonly IBrush HdrBg = NotaPalette.SurfaceCard;- private static readonly IBrush RailBg = NotaPalette.SurfaceInset;- private static readonly IBrush Border2 = NotaPalette.BorderDefault;- private static readonly IBrush Inset = NotaPalette.BgSunken;- private static readonly IBrush Amber = NotaPalette.Accent;- private static readonly IBrush AmberLit = NotaPalette.AccentBright;- private static readonly IBrush TealC = NotaPalette.Teal;- private static readonly IBrush TealLit = NotaPalette.TealBright;- private static readonly IBrush TxtC = NotaPalette.TextPrimary;- private static readonly IBrush MutedC = NotaPalette.TextTertiary;- private static readonly IBrush Handle = NotaPalette.TextSecondary;- private static readonly IBrush AmberSubtle = NotaPalette.Wash(NotaPalette.Accent, 0x28);- private static readonly IBrush ArrowC = NotaPalette.BorderStrong;-public bool BodyOnly => true;public string Subtitle => "BASS SYNTH";- public double CardWidth => 1060;+ public double CardWidth => 700;++ private const double WheelsW = 56, RailW = 186, TabH = 20, StatusH = 18, BodyH = 186;++ private static readonly string[] TabNames = { "Signal", "Mod" };+ // The main oscillator is a continuous morph sine → tri → saw → pulse; its chips jump to+ // the four corners and light the band the shape sits in. Drawn saw · square · tri · sine.+ private static readonly int[] OscIcons = { 0, 1, 2, 3 };+ private static readonly float[] OscStops = { 2f / 3f, 1f, 1f / 3f, 0f };+ private static readonly string[] ShapeWords = { "sine", "tri", "saw", "pulse" };+ // Sub oscillator: sine · square · triangle, the engine's order.+ private static readonly int[] SubIcons = { 3, 1, 2 };+ private static readonly float[] SubStops = { 0f, 0.5f, 1f };+ private static readonly string[] SubWords = { "sine", "square", "tri" };+ private static readonly string[] FilterNames = { "LP", "HP", "BP", "Notch" };+ private static readonly string[] LfoNames = { "Sin", "Tri", "Saw", "Sqr", "S&H" };+ private static readonly string[] BendNames = { "±2", "±5", "±12" };+ private static readonly float[] BendStops = { 1f / 11f, 4f / 11f, 1f };++ // The engine's own maps (BassSynth.h), so a readout says what it does.+ private static double ExpMap(float v, double lo, double hi) => lo * Math.Pow(hi / lo, Math.Clamp(v, 0f, 1f));+ private static string Hz(float v) => NotaNum.Hz(ExpMap(v, 30, 18000));+ // An LFO runs well below 1 Hz, where NotaNum.Hz would round every slow rate to "0 Hz".+ private static string SlowHz(double hz) => hz >= 9.995 ? NotaNum.Hz(hz)+ : NotaNum.Unit(hz, hz < 0.995 ? "0.00" : "0.0", "Hz");+ private static string Secs(float v, double lo, double hi) => NotaNum.Time(ExpMap(v, lo, hi));+ private static string Pct(float v) => NotaNum.Pct(v);+ private static string Bip(float v) => NotaNum.Unit((v - 0.5f) * 200, "+0;−0;0", "%");+ private static string Oct(float v) => NotaNum.Unit(Math.Round((v - 0.5) * 4), "+0;−0;0", "oct");+ private static string Semi(float v) => NotaNum.Unit(Math.Round((v - 0.5) * 24), "+0;−0;0", "st");+ private static string PulseW(float v) => NotaNum.Pct(0.05 + 0.9 * v);+ private static string LfoPitch(float v) => NotaNum.Unit((v - 0.5) * 24, "+0.0;−0.0;0", "st");+ private static string GlideT(float v) => v <= 0.001f ? "off" : NotaNum.Time(ExpMap(v, 0.005, 0.6));+ private static string Unison(float v) => v <= 0.001f ? "off" : NotaNum.Pct(v);+ private static string PanText(float v)+ {+ double p = (v - 0.5) * 200;+ return Math.Abs(p) < 0.5 ? "C" : (p < 0 ? "L" : "R") + NotaNum.Str(Math.Abs(p), "0");+ }+ private static int ShapeBand(float v) => Math.Clamp((int)Math.Round(v * 3), 0, 3); // 0 sine … 3 pulse+ private static int BendRange(float v) => (int)Math.Round(1 + v * 11);public Control Build(DeviceCardContext ctx){@@ -50,187 +85,627 @@ internal sealed class BassInstrumentCard : IInstrumentCardint pc = engine.PluginParamCount(track, -1);var idx = new Dictionary<string, int>();for (int i = 0; i < pc; i++) idx[engine.PluginParamId(track, -1, i)] = i;- float G(string id) => idx.TryGetValue(id, out var i) ? engine.PluginParamGet(track, -1, i) : 0f;int I(string id) => idx.TryGetValue(id, out var i) ? i : -1;+ float G(string id) => I(id) is var i and >= 0 ? engine.PluginParamGet(track, -1, i) : 0f;void SetP(string id, float v) { if (I(id) is var i and >= 0) engine.PluginParamSet(track, -1, i, Math.Clamp(v, 0f, 1f)); }- (int, string) P(string id) => (I(id), id);+ void Begin(string id) { if (I(id) >= 0) engine.BeginAutomationWrite(track, AutomationTarget.PluginParam, -1, -1, id); }+ void End(string id) { if (I(id) >= 0) engine.EndAutomationWrite(track, AutomationTarget.PluginParam, -1, -1, id); }int Sel(string id, int n) => Math.Clamp((int)Math.Round(G(id) * (n - 1)), 0, n - 1);+ (int, string) P(string id) => (I(id), id);+ bool IsMono() => G("mono") >= 0.5f;var readouts = new List<Action>();- var filtGraph = new VoltFilter(engine, track);- var ampEnv = new VoltEnv(engine, track);- var filtEnv = new VoltEnv(engine, track) { Accent = TealLit };+ int tab = 0;++ var filtGraph = new VoltFilter(engine, track)+ {+ FreqRange = (30.0, 18000.0), VerticalAlignment = VerticalAlignment.Stretch, MinWidth = 100, MinHeight = 50,+ };+ var ampEnv = new VoltEnv(engine, track) { ShowTitle = false, VerticalAlignment = VerticalAlignment.Stretch, MinWidth = 100, MinHeight = 50 };+ var filtEnv = new VoltEnv(engine, track) { ShowTitle = false, VerticalAlignment = VerticalAlignment.Stretch, MinWidth = 100, MinHeight = 50, Accent = NotaPalette.TealBright };+ var hint = new TextBlock+ {+ FontSize = NotaType.Axis, Foreground = TextTertiary, FontFamily = NotaFonts.MonoFamily,+ VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right,+ Margin = new Thickness(0, 0, 8, 0), TextTrimming = TextTrimming.CharacterEllipsis,+ };+ var status = new TextBlock { FontSize = 8, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };+ var meta = new TextBlock { FontSize = 8, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center, FontFamily = NotaFonts.MonoFamily };+ Action showTab = () => { };void Refresh(){- int ft = Sel("filtype", 4);- filtGraph.Target("FILTER", P("filfreq"), P("filreso"), ft);+ filtGraph.Target("FILTER", P("filfreq"), P("filreso"), Sel("filtype", 4));filtGraph.Refresh(); ampEnv.Refresh(); filtEnv.Refresh();- foreach (var a in readouts) a();+ foreach (var r in readouts) r();+ hint.Text = Hint();+ status.Text = Summary();+ meta.Text = Meta();}- // ---- shared builders ----- Control K(string id, string name, bool mod = false, double sz = 34, double cw = 44)- => InstrumentControls.InstKnob(ctx, idx, id, name, Refresh, sz, cw, mod ? TealC : null);- Control Row(double spacing, params Control[] cs)- { var sp = new StackPanel { Orientation = Orientation.Horizontal, Spacing = spacing, VerticalAlignment = VerticalAlignment.Center }; foreach (var c in cs) sp.Children.Add(c); return sp; }- Control Lbl(string t, double fs, IBrush c) => new TextBlock { Text = t, FontSize = fs, FontWeight = FontWeight.Bold, Foreground = c, VerticalAlignment = VerticalAlignment.Center };- Control Cap(string t, IBrush? c = null) => new TextBlock { Text = t, FontSize = 9, Foreground = c ?? MutedC, VerticalAlignment = VerticalAlignment.Center };- Control Arrow() => new Glyph(GlyphKind.ChevronRight, 9) { Foreground = ArrowC, Margin = new Thickness(1, 0) };+ // ---- shared builders --------------------------------------------------+ static TextBlock Cap(string t, IBrush? c = null) => new()+ {+ Text = t, FontSize = NotaType.KnobLabel, FontWeight = FontWeight.Bold,+ LetterSpacing = NotaType.KnobLabelTracking, Foreground = c ?? TextTertiary,+ VerticalAlignment = VerticalAlignment.Center,+ };+ static TextBlock Mono(string t, IBrush? c = null, double fs = 8) => new()+ {+ Text = t, FontSize = fs, Foreground = c ?? TextSecondary,+ VerticalAlignment = VerticalAlignment.Center, FontFamily = NotaFonts.MonoFamily,+ };+ static TextBlock Section(string t) => new()+ {+ Text = t, FontSize = NotaType.DeviceSection, FontWeight = FontWeight.SemiBold,+ Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center,+ };+ static Border Rule(Control child, bool top = true) => new()+ {+ BorderBrush = NotaPalette.GraphBorder, BorderThickness = top ? new Thickness(0, 1, 0, 0) : new Thickness(1, 0, 0, 0),+ Child = child,+ };++ // Every knob is a table cell: a short label on the card while MIDI learn and the CV+ // menu keep the parameter's full name.+ Control PKnob(string id, string label, string learn, Func<float, string> fmt,+ double size = 26, double cellW = 44, IBrush? arc = null)+ {+ if (!idx.TryGetValue(id, out var pi)) return new Panel();+ var value = new TextBlock+ {+ Text = fmt(G(id)), FontSize = NotaType.KnobValue, FontFamily = NotaFonts.MonoFamily,+ Foreground = TextPrimary, HorizontalAlignment = HorizontalAlignment.Center,+ TextAlignment = TextAlignment.Center, LineHeight = 10,+ };+ var knob = new Knob(G(id), 1.0)+ {+ Accent = true, ArcColor = arc, Default = engine.InstrumentParamDefault(track, pi),+ Width = size, Height = size, HorizontalAlignment = HorizontalAlignment.Center,+ };+ knob.ValueChanged += v => { engine.PluginParamSet(track, -1, pi, (float)v); value.Text = fmt((float)v); Refresh(); };+ knob.GestureBegin += () => Begin(id);+ knob.GestureEnd += () => End(id);+ ctx.AddInstFader(pi, knob, value, fmt);+ MidiLearn.Bind(knob, MidiTarget.PluginParam(track, -1, pi), learn);+ var cell = KnobCell(label, knob, value, cellW);+ cell.VerticalAlignment = VerticalAlignment.Center;+ return cell;+ }- // Param-backed chip strip.- Control Chips(string id, string[] names, double fs = 9)+ Border Chips(string id, string[] names, Func<int>? current = null, Action<int>? pick = null, bool fill = false, double padX = 6){int n = names.Length;- var seg = DeviceCardKit.Segments(names, () => Sel(id, n), iv => { SetP(id, iv / (float)(n - 1)); Refresh(); }, out var sync);+ var seg = Segments(names, current ?? (() => Sel(id, n)),+ pick ?? (iv => { SetP(id, iv / (float)(n - 1)); Refresh(); }), out var sync, fill: fill, padX: padX);readouts.Add(sync);if (I(id) is var pi and >= 0) MidiLearn.Bind(seg, MidiTarget.PluginParam(track, -1, pi), id);return seg;}- // Waveform icon chips for sub oscillator (Sine=3, Square=1, Triangle=2).- Control SubWaveChips()+ Grid Slider(string label, string id, Func<string> text, double labelW = 0, double valueW = 40,+ bool mod = false, Func<bool>? dim = null){- int[] waveIcon = { 3, 1, 2 }; int n = 3; var arr = new Border[n]; var ic = new WaveIcon[n];- void Hi() { int cur = Sel("subwave", 3); for (int i = 0; i < n; i++) { bool on = i == cur; arr[i].Background = on ? Amber : Inset; arr[i].BorderBrush = on ? Amber : Border2; ic[i].Stroke = on ? NotaPalette.TextOnAccent : MutedC; ic[i].InvalidateVisual(); } }- var row = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 3, VerticalAlignment = VerticalAlignment.Center };- for (int i = 0; i < n; i++)- { int iv = i; var wi = new WaveIcon(waveIcon[i]) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var b = new Border { Width = 30, Height = 22, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Control, Cursor = new Cursor(StandardCursorType.Hand), Child = wi }; b.PointerPressed += (_, _) => { SetP("subwave", iv / 2f); Hi(); Refresh(); }; arr[i] = b; ic[i] = wi; row.Children.Add(b); }- readouts.Add(Hi); Hi();- if (I("subwave") is var pi and >= 0) MidiLearn.Bind(row, MidiTarget.PluginParam(track, -1, pi), "subwave");+ int pi = I(id);+ var row = SliderRow(label, () => G(id), v => { SetP(id, (float)v); Refresh(); }, text, out var sync,+ begin: pi >= 0 ? () => Begin(id) : null,+ end: pi >= 0 ? () => End(id) : null,+ reset: pi >= 0 ? () => { SetP(id, engine.InstrumentParamDefault(track, pi)); Refresh(); } : null,+ dim: dim, labelWidth: labelW, valueWidth: valueW, modulation: mod);+ readouts.Add(sync);+ if (pi >= 0) MidiLearn.Bind(row, MidiTarget.PluginParam(track, -1, pi), label);return row;}- // Local (non-param) segmented toggle.- Control Seg(string[] names, int initial, Action<int> onPick, double fs = 9)- {- int cur = initial;- return DeviceCardKit.Segments(names, () => cur, iv => { cur = iv; onPick(iv); }, out _);- }-- // Panel frame: header + body in a bordered box. Set stretchBody=true when the- // body should fill (e.g. filter graph); otherwise the body is centered.- Border Panel(double width, Control header, Control body, bool stretchBody = false)- {- var grid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };- grid.Children.Add(header);- var host = new Border { Child = body };- if (!stretchBody) { host.VerticalAlignment = VerticalAlignment.Center; host.HorizontalAlignment = HorizontalAlignment.Center; }- Grid.SetRow(host, 1); grid.Children.Add(host);- return new Border { Width = width, Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Panel, Padding = new Thickness(9, 8), Child = grid };- }-- // ---- readout formatters ----- string ShapeName(float s) => s < 0.17f ? "sine" : s < 0.42f ? "tri" : s < 0.75f ? "saw" : "pulse";- string OctLabel(float v) { int o = (int)Math.Round((v - 0.5f) * 4f); return o.ToString("+0;−0;0"); }- string ModLabel(float v) { int m = (int)Math.Round((v - 0.5f) * 200f); return m.ToString("+0;−0;0"); }-- // ---- SIGNAL PATH tab ----- // OSC: continuous Shape + PW + tuning + level.- var oscCap = new TextBlock { FontSize = 9, Foreground = MutedC, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right };- oscCap.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");- readouts.Add(() => oscCap.Text = ShapeName(G("oscshape")) + " · " + OctLabel(G("oscoctave")) + "\u2009oct");- var oscHead = new DockPanel { Children = { oscCap, Lbl("OSC", 10, TxtC) } };- DockPanel.SetDock(oscCap, Dock.Right);- var oscBody = Row(2, K("oscshape", "SHAPE"), K("oscpw", "PW"), K("oscoctave", "OCTAVE"), K("oscsemi", "SEMI"), K("osclevel", "LEVEL"));- var oscBox = Panel(300, oscHead, oscBody);-- // SUB: wave icon chips + octave + level (stacked vertically).- var subBody = new StackPanel { Spacing = 8, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = {- SubWaveChips(),- new StackPanel { Spacing = 3, HorizontalAlignment = HorizontalAlignment.Center, Children = { new TextBlock { Text = "OCT", FontSize = 8, FontWeight = FontWeight.Bold, Foreground = MutedC, HorizontalAlignment = HorizontalAlignment.Center }, Chips("suboctave", new[] { "-1", "-2" }) } },- K("sublevel", "LEVEL") } };- var subBox = Panel(168, Lbl("SUB", 10, TxtC), subBody);-- // FILTER: type/slope chips + response graph + knobs.- var filtKnobHost = new StackPanel { Spacing = 2, VerticalAlignment = VerticalAlignment.Center };- filtKnobHost.Children.Add(Row(2, K("filfreq", "CUTOFF"), K("filreso", "RESO")));- filtKnobHost.Children.Add(Row(2, K("fildrive", "DRIVE"), K("filenv", "ENV", true), K("filkey", "KEY", true)));- filtGraph.VerticalAlignment = VerticalAlignment.Stretch; filtGraph.MinHeight = 90;- var filterBody = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8, VerticalAlignment = VerticalAlignment.Stretch };- filterBody.Children.Add(filtGraph);- Grid.SetColumn(filtKnobHost, 1); filterBody.Children.Add(filtKnobHost);- var filtCap = new TextBlock { FontSize = 9, Foreground = TealC, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right };- filtCap.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");- readouts.Add(() => filtCap.Text = "← env " + ModLabel(G("filenv")) + " · lfo " + ModLabel(G("fillfo")));- var filtHeadLeft = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, VerticalAlignment = VerticalAlignment.Center, Children = {- Lbl("FILTER", 10, TxtC), Chips("filtype", new[] { "LP", "HP", "BP", "Notch" }),- new TextBlock { Text = "dB", FontSize = 8, Foreground = MutedC, VerticalAlignment = VerticalAlignment.Center },- Chips("filslope", new[] { "12", "24" }) } };- DockPanel.SetDock(filtCap, Dock.Right);- var filterHeader = new DockPanel { Margin = new Thickness(0, 0, 0, 6), Children = { filtCap, filtHeadLeft } };- DockPanel.SetDock(filterHeader, Dock.Top);- var filterBox = new Border { Width = 404, Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Panel, Padding = new Thickness(9, 8), Child = new DockPanel { LastChildFill = true, Children = { filterHeader, filterBody } } };-- // OUTPUT: drive + volume.- var outBody = new StackPanel { Spacing = 8, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = { K("drive", "DRIVE"), K("volume", "VOLUME") } };- var outBox = Panel(90, new TextBlock { Text = "OUTPUT", FontSize = 9, FontWeight = FontWeight.Bold, Foreground = TxtC, HorizontalAlignment = HorizontalAlignment.Center }, outBody);-- var signalPath = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, VerticalAlignment = VerticalAlignment.Stretch,- Children = { oscBox, Arrow(), subBox, Arrow(), filterBox, Arrow(), outBox } };-- // ---- MODULATION tab ----- // Envelope panel: interactive graph + A/D/S/R readout cells.- Border EnvPanel(string title, string route, VoltEnv gView, string[] ids, IBrush accent)- {- gView.Target(title, P(ids[0]), P(ids[1]), P(ids[2]), P(ids[3]));- gView.Accent = accent;- gView.VerticalAlignment = VerticalAlignment.Stretch; gView.MinHeight = 84;- string[] lbl = { "A", "D", "S", "R" };- var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,*,*"), ColumnSpacing = 4, Margin = new Thickness(0, 5, 0, 0) };+ // Waveform chips: the recessed strip of Segments with a drawn wave in each cell.+ // `current` lights a cell (−1 for none); a click writes that cell's stop.+ Control WaveChips(string id, int[] icons, float[] stops, Func<int> current)+ {+ int n = icons.Length;+ var cells = new Border[n];+ var marks = new WaveIcon[n];+ var row = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 1 };+ for (int i = 0; i < n; i++)+ {+ int iv = i;+ var ic = new WaveIcon(icons[i]) { Width = 16, Height = 10, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };+ var c = new Border+ {+ CornerRadius = NotaRadius.Badge, Padding = new Thickness(2, 2), Background = Brushes.Transparent,+ Cursor = new Cursor(StandardCursorType.Hand), Child = ic,+ };+ c.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(c).Properties.IsLeftButtonPressed) return;+ Begin(id); SetP(id, stops[iv]); End(id); Refresh(); e.Handled = true;+ };+ cells[i] = c; marks[i] = ic; row.Children.Add(c);+ }+ void Paint()+ {+ int cur = current();+ for (int i = 0; i < n; i++)+ {+ bool on = i == cur;+ cells[i].Background = on ? Brass : Brushes.Transparent;+ marks[i].Stroke = on ? OnAccent : TextTertiary;+ marks[i].InvalidateVisual();+ }+ }+ readouts.Add(Paint); Paint();+ if (I(id) is var pi and >= 0) MidiLearn.Bind(row, MidiTarget.PluginParam(track, -1, pi), id);+ var host = new Border+ {+ Background = NotaPalette.BgSunken, BorderBrush = BorderDef, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Control, Padding = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Left,+ VerticalAlignment = VerticalAlignment.Center, Child = row,+ };+ host.BindResource(Border.BoxShadowProperty, "Shadow.Sunken");+ return host;+ }++ // The filter type as a 2 × 2 block of segments — four words in a 62 px column.+ Control TypeGrid(string id)+ {+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*"), RowDefinitions = new RowDefinitions("Auto,Auto"), ColumnSpacing = 1, RowSpacing = 1 };+ var cells = new Border[4];+ var texts = new TextBlock[4];+ for (int i = 0; i < 4; i++)+ {+ int iv = i;+ var tb = new TextBlock { Text = FilterNames[i], FontSize = NotaType.KnobLabel, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };+ var c = new Border+ {+ CornerRadius = NotaRadius.Badge, Padding = new Thickness(0, 1), Background = Brushes.Transparent,+ Cursor = new Cursor(StandardCursorType.Hand), Child = tb,+ };+ c.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(c).Properties.IsLeftButtonPressed) return;+ Begin(id); SetP(id, iv / 3f); End(id); Refresh(); e.Handled = true;+ };+ Grid.SetColumn(c, i % 2); Grid.SetRow(c, i / 2);+ cells[i] = c; texts[i] = tb; g.Children.Add(c);+ }+ void Paint()+ {+ int cur = Sel(id, 4);+ for (int i = 0; i < 4; i++)+ {+ bool on = i == cur;+ cells[i].Background = on ? Brass : Brushes.Transparent;+ texts[i].Foreground = on ? OnAccent : TextTertiary;+ texts[i].FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal;+ }+ }+ readouts.Add(Paint); Paint();+ if (I(id) is var pi and >= 0) MidiLearn.Bind(g, MidiTarget.PluginParam(track, -1, pi), "Filter Type");+ var host = new Border+ {+ Background = NotaPalette.BgSunken, BorderBrush = BorderDef, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Control, Padding = new Thickness(1), Child = g,+ };+ host.BindResource(Border.BoxShadowProperty, "Shadow.Sunken");+ return host;+ }++ // ---- the wheels rail --------------------------------------------------+ Control Wheel(string id, double def, bool spring)+ {+ var w = new PerformWheel { Default = def, Spring = spring, VerticalAlignment = VerticalAlignment.Stretch, Norm = G(id), HorizontalAlignment = HorizontalAlignment.Center };+ w.ValueChanged += v => { SetP(id, (float)v); Refresh(); };+ w.GestureBegin += () => Begin(id);+ w.GestureEnd += () => End(id);+ if (I(id) is var pi and >= 0) MidiLearn.Bind(w, MidiTarget.PluginParam(track, -1, pi), id);+ readouts.Add(() => { if (!w.Dragging) w.Norm = G(id); });+ return w;+ }++ var bendWheel = Wheel("bend", 0.5, true);+ var modWheel = Wheel("modwheel", 0, false);+ var bendVal = Mono("", TextSecondary, NotaType.KnobValue);+ var modVal = Mono("", TextSecondary, NotaType.KnobValue);+ bendVal.HorizontalAlignment = modVal.HorizontalAlignment = HorizontalAlignment.Center;+ var pitchCap = Cap("PITCH"); pitchCap.HorizontalAlignment = HorizontalAlignment.Center;+ var modCap = Cap("MOD"); modCap.HorizontalAlignment = HorizontalAlignment.Center;+ ToolTip.SetTip(modWheel, "Mod wheel — opens the LFO onto the cutoff");+ readouts.Add(() =>+ {+ int range = BendRange(G("bendrange"));+ double semis = (G("bend") - 0.5) * 2 * range;+ bool centred = Math.Abs(semis) < 0.05;+ bendVal.Text = centred ? $"±{range} st" : NotaNum.Unit(semis, "+0.0;−0.0;0", "st");+ bendVal.Foreground = centred ? TextSecondary : AccentBright;+ bool modOn = G("modwheel") > 1e-3f;+ modVal.Text = NotaNum.Pct(G("modwheel"));+ modVal.Foreground = modOn ? AccentBright : TextSecondary;+ // On the Mod tab the wheel is part of what's on screen — it drives the LFO.+ modCap.Foreground = tab == 1 ? AccentBright : TextTertiary;+ });++ Grid Pair(Control a, Control b)+ {+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*") };+ g.Children.Add(a); Grid.SetColumn(b, 1); g.Children.Add(b);+ return g;+ }+ var wheelsCap = Cap("WHEELS"); wheelsCap.HorizontalAlignment = HorizontalAlignment.Center;+ var wheelsGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto,Auto"), RowSpacing = 4, Margin = new Thickness(4, 5) };+ var wheelRows = new Control[] { wheelsCap, Pair(bendWheel, modWheel), Pair(pitchCap, modCap), Pair(bendVal, modVal) };+ for (int i = 0; i < wheelRows.Length; i++) { Grid.SetRow(wheelRows[i], i); wheelsGrid.Children.Add(wheelRows[i]); }+ var wheelsPanel = SectionBox(wheelsGrid);+ wheelsPanel.Width = WheelsW;++ // ---- Signal tab -------------------------------------------------------+ // OSC: the morph oscillator's corners, then shape, pulse width, tuning and level.+ var oscRow = new Grid { ColumnDefinitions = new ColumnDefinitions("34,Auto,*,*,*,*,*"), ColumnSpacing = 4 };+ {+ var cs = new Control[]+ {+ Section("OSC"),+ WaveChips("oscshape", OscIcons, OscStops, () => ShapeBand(G("oscshape")) switch { 0 => 3, 1 => 2, 2 => 0, _ => 1 }),+ PKnob("oscshape", "SHAPE", "Osc Shape", Pct),+ PKnob("oscpw", "PW", "Pulse Width", PulseW),+ PKnob("oscoctave", "OCTAVE", "Osc Octave", Oct),+ PKnob("oscsemi", "SEMI", "Osc Semi", Semi),+ PKnob("osclevel", "LEVEL", "Osc Level", Pct),+ };+ for (int i = 0; i < cs.Length; i++) { Grid.SetColumn(cs[i], i); oscRow.Children.Add(cs[i]); }+ }++ // SUB: its wave, the octave below, level — and what osc + sub add up to.+ var subRow = new Grid { ColumnDefinitions = new ColumnDefinitions("34,Auto,Auto,*,*"), ColumnSpacing = 6 };+ {+ var octChips = Chips("suboctave", new[] { "−1", "−2" });+ var octCell = new StackPanel { Spacing = 2, VerticalAlignment = VerticalAlignment.Center, Children = { Cap("OCT"), octChips } };++ var mixBar = new MixBar(engine, track, new[] { I("osclevel"), I("sublevel"), -1 }) { Height = 4 };+ readouts.Add(mixBar.Refresh);+ var mixVal = Mono("", TextSecondary, NotaType.KnobValue);+ readouts.Add(() =>+ {+ float sum = G("osclevel") + G("sublevel");+ mixVal.Text = sum <= 1e-3f ? "silent" : NotaNum.Db(AudioMath.LinToDb(Math.Min(1f, sum)));+ });+ var mixCell = new StackPanel { Spacing = 3, VerticalAlignment = VerticalAlignment.Center, Children = { Cap("MIX SUM"), mixBar, mixVal } };++ var cs = new Control[]+ {+ Section("SUB"),+ WaveChips("subwave", SubIcons, SubStops, () => Sel("subwave", 3)),+ octCell,+ PKnob("sublevel", "LEVEL", "Sub Level", Pct),+ mixCell,+ };+ for (int i = 0; i < cs.Length; i++) { Grid.SetColumn(cs[i], i); subRow.Children.Add(cs[i]); }+ }++ // FILTER: type and slope, the response pad, and its five knobs.+ var filtRow = new Grid { ColumnDefinitions = new ColumnDefinitions("62,*,Auto"), ColumnSpacing = 6, Margin = new Thickness(0, 3, 0, 0) };+ {+ var envCap = Mono("", Teal, NotaType.Axis);+ readouts.Add(() => envCap.Text = "env " + NotaNum.Str((G("filenv") - 0.5f) * 200, "+0;−0;0"));+ var left = new StackPanel+ {+ Spacing = 2, VerticalAlignment = VerticalAlignment.Center,+ Children =+ {+ Cap("FILTER"),+ TypeGrid("filtype"),+ Chips("filslope", new[] { "12", "24" }, () => G("filslope") >= 0.5f ? 1 : 0, iv => { SetP("filslope", iv); Refresh(); }, fill: true),+ envCap,+ },+ };+ var knobs = new StackPanel+ {+ Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center,+ Children =+ {+ PKnob("filfreq", "CUTOFF", "Filter Freq", Hz, 26, 38),+ PKnob("filreso", "RESO", "Filter Reso", Pct, 26, 30),+ PKnob("fildrive", "DRIVE", "Filter Drive", Pct, 26, 32),+ PKnob("filenv", "ENV", "Filter Env", Bip, 26, 30, Teal),+ PKnob("filkey", "KEY", "Filter Key", Pct, 26, 30, Teal),+ },+ };+ filtRow.Children.Add(left);+ Grid.SetColumn(filtGraph, 1); filtRow.Children.Add(filtGraph);+ Grid.SetColumn(knobs, 2); filtRow.Children.Add(knobs);+ }++ var signalGrid = new Grid { RowDefinitions = new RowDefinitions("56,54,*") };+ signalGrid.Children.Add(oscRow);+ var subHost = Rule(subRow); Grid.SetRow(subHost, 1); signalGrid.Children.Add(subHost);+ var filtHost = Rule(filtRow); Grid.SetRow(filtHost, 2); signalGrid.Children.Add(filtHost);+ var signalBody = new Border { Padding = new Thickness(7, 0, 7, 4), Child = signalGrid };++ // ---- Mod tab ----------------------------------------------------------+ Control EnvPanel(string title, string route, VoltEnv view, string[] ids)+ {+ view.Target(title, P(ids[0]), P(ids[1]), P(ids[2]), P(ids[3]));+ string[] stage = { "A", "D", "S", "R" };+ Func<float, string>[] fmt =+ {+ v => Secs(v, 0.001, 2.0), v => Secs(v, 0.002, 4.0), Pct, v => Secs(v, 0.002, 5.0),+ };+ var cells = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,*,*"), ColumnSpacing = 3 };for (int k = 0; k < 4; k++){- var v = new TextBlock { Text = Pct(G(ids[k])), FontSize = 9, Foreground = TxtC, HorizontalAlignment = HorizontalAlignment.Center };- v.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");- string pid = ids[k]; var tv = v; readouts.Add(() => tv.Text = Pct(G(pid)));- var cell = new Border { Background = Inset, BorderBrush = Border2, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Control, Padding = new Thickness(2, 2),- Child = new StackPanel { Children = { new TextBlock { Text = lbl[k], FontSize = 8, FontWeight = FontWeight.Bold, Foreground = MutedC, HorizontalAlignment = HorizontalAlignment.Center }, v } } };- Grid.SetColumn(cell, k); grid.Children.Add(cell);+ string id = ids[k];+ var fk = fmt[k];+ var v = Mono(fk(G(id)), TextPrimary, NotaType.KnobValue);+ v.HorizontalAlignment = HorizontalAlignment.Center;+ readouts.Add(() => v.Text = fk(G(id)));+ var cap = Cap(stage[k]); cap.HorizontalAlignment = HorizontalAlignment.Center;+ var cell = new Border+ {+ Background = NotaPalette.BgSunken, BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Badge, Padding = new Thickness(1, 1),+ Child = new StackPanel { Children = { cap, v } },+ };+ if (I(id) is var pi and >= 0) MidiLearn.Bind(cell, MidiTarget.PluginParam(track, -1, pi), title + " · " + stage[k]);+ Grid.SetColumn(cell, k); cells.Children.Add(cell);}- DockPanel.SetDock(grid, Dock.Bottom);- var head = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, Children = { Lbl(title, 10, TxtC), new TextBlock { Text = route, FontSize = 9, Foreground = TealC, VerticalAlignment = VerticalAlignment.Center } } };- DockPanel.SetDock(head, Dock.Top);- var body = new DockPanel { LastChildFill = true, Children = { head, grid, gView } };- return new Border { Width = 300, Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Panel, Padding = new Thickness(9, 8), Child = body };- }-- var ampEnvBox = EnvPanel("AMP ENV", "→ Level", ampEnv, new[] { "attack", "decay", "sustain", "release" }, AmberLit);- var filtEnvBox = EnvPanel("FILTER ENV", "→ Cutoff", filtEnv, new[] { "fattack", "fdecay", "fsustain", "frelease" }, TealLit);-- // LFO: wave chips + rate + targets.- var lfoBody = new StackPanel { Spacing = 8, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = {- Chips("lfowave", new[] { "Sin", "Tri", "Saw", "Sqr", "S&H" }),- Row(2, K("lforate", "RATE"), K("fillfo", "→ FLT", true), K("lfopitch", "→ PIT", true)) } };- var lfoHead = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, Children = { Lbl("LFO", 10, TxtC), Cap("→ Cut/Pitch", TealC) } };- var lfoBox = Panel(196, lfoHead, lfoBody);-- // GLOBAL: glide, unison, velocity, voice mode.- var globalBody = new StackPanel { Spacing = 6, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Children = {- Row(2, K("glide", "GLIDE"), K("unison", "UNISON"), K("velamp", "VEL→A", true), K("velfilter", "VEL→F", true)),- new StackPanel { Spacing = 3, VerticalAlignment = VerticalAlignment.Center, Children = { new TextBlock { Text = "VOICE", FontSize = 8, FontWeight = FontWeight.Bold, Foreground = MutedC, HorizontalAlignment = HorizontalAlignment.Center }, Chips("mono", new[] { "Poly", "Mono" }) } } } };- var globalBox = Panel(226, Lbl("GLOBAL", 10, TxtC), globalBody);-- var modulation = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, VerticalAlignment = VerticalAlignment.Stretch,- Children = { ampEnvBox, filtEnvBox, lfoBox, globalBox } };-- // ---- tabs + body ----- var tabHost = new ContentControl { VerticalAlignment = VerticalAlignment.Stretch };- // Cache tab bodies to avoid re-parenting shared controls (VoltFilter, VoltEnv).- Control?[] tabCache = new Control?[2];- Control TabBody(int t) => tabCache[t] ??= t == 0 ? signalPath : modulation;- int tabSel = 0;- var tabs = Seg(new[] { "Signal Path", "Modulation" }, 0, i => { tabSel = i; tabHost.Content = TabBody(i); }, 11);- var tabStrip = new Border { Height = 26, Background = HdrBg, BorderBrush = Border2, BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(10, 0),- Child = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center, Children = { tabs } } };- DockPanel.SetDock(tabStrip, Dock.Top);- var contentHost = new Border { Padding = new Thickness(10, 8), Child = tabHost };- var dockRoot = new DockPanel { LastChildFill = true, Background = CardBg, Children = { tabStrip, contentHost } };-- tabHost.Content = TabBody(tabSel);- ampEnv.Target("AMP ENV", P("attack"), P("decay"), P("sustain"), P("release"));- filtEnv.Target("FILTER ENV", P("fattack"), P("fdecay"), P("fsustain"), P("frelease"));+ var head = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5, Height = 11, Children = { Cap(title), Mono(route, Teal, NotaType.Axis) } };+ var g = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto"), RowSpacing = 4 };+ g.Children.Add(head);+ Grid.SetRow(view, 1); g.Children.Add(view);+ Grid.SetRow(cells, 2); g.Children.Add(cells);+ return g;+ }+ var ampPanel = EnvPanel("AMP ENV", "→ level", ampEnv, new[] { "attack", "decay", "sustain", "release" });+ var filtEnvPanel = EnvPanel("FILTER ENV", "→ cutoff", filtEnv, new[] { "fattack", "fdecay", "fsustain", "frelease" });++ // LFO: shape, rate and where it lands — cutoff and pitch — then the velocity amounts.+ var lfoDest = Mono("", Teal, NotaType.Axis);+ readouts.Add(() => lfoDest.Text = G("modwheel") > 1e-3f ? "→ cut/pitch · wheel" : "→ cut/pitch");+ var lfoKnobs = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,*"), VerticalAlignment = VerticalAlignment.Center };+ {+ var ks = new[]+ {+ PKnob("lforate", "RATE", "LFO Rate", v => SlowHz(ExpMap(v, 0.05, 30)), 26, 40),+ PKnob("fillfo", "→ FLT", "Filter LFO", Bip, 26, 40, Teal),+ PKnob("lfopitch", "→ PIT", "LFO → Pitch", LfoPitch, 26, 40, Teal),+ };+ for (int i = 0; i < ks.Length; i++) { Grid.SetColumn(ks[i], i); lfoKnobs.Children.Add(ks[i]); }+ }+ var velRows = new StackPanel+ {+ Spacing = 4, Margin = new Thickness(0, 0, 0, 1),+ Children =+ {+ Slider("VEL→AMP", "velamp", () => Pct(G("velamp")), labelW: 46, valueW: 26, mod: true),+ Slider("VEL→FIL", "velfilter", () => Pct(G("velfilter")), labelW: 46, valueW: 26, mod: true),+ },+ };+ var lfoGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,Auto,*,Auto"), RowSpacing = 4 };+ {+ var head = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5, Height = 11, Children = { Cap("LFO"), lfoDest } };+ var rows = new Control[]+ {+ head,+ Chips("lfowave", LfoNames, fill: true, padX: 1),+ lfoKnobs,+ new Border { BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(0, 1, 0, 0), Padding = new Thickness(0, 4, 0, 0), Child = velRows },+ };+ for (int i = 0; i < rows.Length; i++) { Grid.SetRow(rows[i], i); lfoGrid.Children.Add(rows[i]); }+ }+ var lfoHost = Rule(lfoGrid, top: false);+ lfoHost.Padding = new Thickness(6, 0, 0, 0);+ lfoHost.Width = 140;++ var modGrid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,Auto"), ColumnSpacing = 6 };+ modGrid.Children.Add(ampPanel);+ Grid.SetColumn(filtEnvPanel, 1); modGrid.Children.Add(filtEnvPanel);+ Grid.SetColumn(lfoHost, 2); modGrid.Children.Add(lfoHost);+ var modBody = new Border { Padding = new Thickness(7, 5), Child = modGrid };++ // ---- the tab strip ----------------------------------------------------+ var bodies = new Control[] { signalBody, modBody };+ var tabCells = new Border[TabNames.Length];+ var tabTexts = new TextBlock[TabNames.Length];+ var tabRow = new StackPanel { Orientation = Orientation.Horizontal };+ for (int i = 0; i < TabNames.Length; i++)+ {+ int iv = i;+ var tb = new TextBlock { Text = TabNames[i], FontSize = NotaType.DeviceSection, VerticalAlignment = VerticalAlignment.Center };+ var cell = new Border+ {+ Padding = new Thickness(8, 0), BorderThickness = new Thickness(0, 0, 0, 2),+ Cursor = new Cursor(StandardCursorType.Hand), Child = tb,+ };+ cell.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(cell).Properties.IsLeftButtonPressed) return;+ tab = iv; showTab(); e.Handled = true;+ };+ tabCells[i] = cell; tabTexts[i] = tb; tabRow.Children.Add(cell);+ }+ var tabStrip = new Grid { Height = TabH, ColumnDefinitions = new ColumnDefinitions("Auto,*") };+ tabStrip.Children.Add(tabRow);+ Grid.SetColumn(hint, 1); tabStrip.Children.Add(hint);++ showTab = () =>+ {+ for (int i = 0; i < TabNames.Length; i++)+ {+ bool on = i == tab;+ tabCells[i].Background = on ? NotaPalette.SurfaceRaised : Brushes.Transparent;+ tabCells[i].BorderBrush = on ? Brass : Brushes.Transparent;+ tabTexts[i].Foreground = on ? AccentBright : TextTertiary;+ tabTexts[i].FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal;+ bodies[i].IsVisible = on;+ }+ Refresh();+ };++ var tabHost = new Panel { MinHeight = BodyH - TabH };+ foreach (var b in bodies) tabHost.Children.Add(b);+ var tabGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };+ tabGrid.Children.Add(HeaderStrip(tabStrip));+ Grid.SetRow(tabHost, 1); tabGrid.Children.Add(tabHost);+ var tabPanel = SectionBox(tabGrid);++ // ---- rail · Global ----------------------------------------------------+ var monoChips = Chips("mono", new[] { "Poly", "Mono" }, () => IsMono() ? 1 : 0, iv => { SetP("mono", iv); Refresh(); });+ monoChips.HorizontalAlignment = HorizontalAlignment.Right;+ monoChips.Margin = new Thickness(0, 0, 6, 0);+ var globalCap = Cap("GLOBAL"); globalCap.Margin = new Thickness(8, 0, 0, 0);+ var globalHead = new Grid { Height = TabH, ColumnDefinitions = new ColumnDefinitions("Auto,*") };+ globalHead.Children.Add(globalCap);+ Grid.SetColumn(monoChips, 1); globalHead.Children.Add(monoChips);++ var bendChips = Segments(BendNames, () => NearestExact(G("bendrange"), BendStops),+ iv => { SetP("bendrange", BendStops[iv]); Refresh(); }, out var bendSync, padX: 3);+ readouts.Add(bendSync);+ if (I("bendrange") is var bri and >= 0) MidiLearn.Bind(bendChips, MidiTarget.PluginParam(track, -1, bri), "Bend Range");+ var legato = Switch("Legato", () => G("legato") >= 0.5f, () => { Begin("legato"); SetP("legato", G("legato") >= 0.5f ? 0f : 1f); End("legato"); Refresh(); },+ out var legatoSync, dim: () => !IsMono());+ readouts.Add(legatoSync);+ if (I("legato") is var lgi and >= 0) MidiLearn.Bind(legato, MidiTarget.PluginParam(track, -1, lgi), "Legato");+ ToolTip.SetTip(legato, "Slide into a note played over a held one without a new attack");+ legato.HorizontalAlignment = HorizontalAlignment.Right;+ var bendRow = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*"), ColumnSpacing = 5 };+ bendRow.Children.Add(Cap("BEND"));+ Grid.SetColumn(bendChips, 1); bendRow.Children.Add(bendChips);+ Grid.SetColumn(legato, 2); bendRow.Children.Add(legato);++ var meter = new MeterBar { VerticalAlignment = VerticalAlignment.Stretch, Width = MeterScale.StereoWidth };+ ctx.AddDeviceRefresher(() => { if (engine.TryGetTrackMeter(track, out var m)) meter.Push(m); });+ var meterScale = new Grid+ {+ VerticalAlignment = VerticalAlignment.Stretch,+ RowDefinitions = new RowDefinitions(string.Join(",", ScaleRows(0, -12, -48))),+ };+ for (int i = 0; i < 3; i++)+ {+ var c = Mono(i == 0 ? "0" : i == 1 ? "−12" : "−48", NotaPalette.TextAxis, NotaType.Axis);+ Grid.SetRow(c, i * 2 + 1); meterScale.Children.Add(c);+ }+ var meterBlock = new Grid+ {+ ColumnDefinitions = new ColumnDefinitions("Auto,Auto"), ColumnSpacing = 4,+ HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 0, 0, 9),+ };+ meterBlock.Children.Add(meter);+ Grid.SetColumn(meterScale, 1); meterBlock.Children.Add(meterScale);++ var globalBottom = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*"), VerticalAlignment = VerticalAlignment.Stretch };+ var volCell = PKnob("volume", "VOLUME", "Volume", Pct, NotaSize.KnobMain, 48);+ var panCell = PKnob("outpan", "PAN", "Out Pan", PanText, NotaSize.KnobRegular, 44);+ globalBottom.Children.Add(volCell);+ Grid.SetColumn(panCell, 1); globalBottom.Children.Add(panCell);+ Grid.SetColumn(meterBlock, 2); globalBottom.Children.Add(meterBlock);++ var globalTop = new StackPanel+ {+ Spacing = 5, Margin = new Thickness(8, 6, 8, 0),+ Children =+ {+ // Glide and legato belong to the mono voice — poly starts every note on its own pitch.+ Slider("GLIDE", "glide", () => GlideT(G("glide")), labelW: 38, dim: () => !IsMono()),+ Slider("UNISON", "unison", () => Unison(G("unison")), labelW: 38),+ Slider("DRIVE", "drive", () => Pct(G("drive")), labelW: 38),+ bendRow,+ },+ };+ var globalGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };+ globalGrid.Children.Add(globalTop);+ var globalBottomFrame = new Border+ {+ BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(0, 1, 0, 0),+ Margin = new Thickness(8, 5, 8, 5), Padding = new Thickness(0, 4, 0, 0), Child = globalBottom,+ };+ Grid.SetRow(globalBottomFrame, 1); globalGrid.Children.Add(globalBottomFrame);++ var railGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };+ railGrid.Children.Add(HeaderStrip(globalHead));+ Grid.SetRow(globalGrid, 1); railGrid.Children.Add(globalGrid);+ var rail = SectionBox(railGrid);+ rail.Width = RailW;++ // ---- status strip -----------------------------------------------------+ string Shape() => ShapeWords[ShapeBand(G("oscshape"))];+ string SubOct() => G("suboctave") >= 0.5f ? "−2" : "−1";+ string FilterWord() => $"{FilterNames[Sel("filtype", 4)]} {(G("filslope") >= 0.5f ? "24" : "12")}";+ string AdsrSum(string a, string d, string s, string r)+ => $"{Secs(G(a), 0.001, 2.0)} · {Secs(G(d), 0.002, 4.0)} · {Pct(G(s))} · {Secs(G(r), 0.002, 5.0)}";++ // The line at the right of the tab strip: what this tab holds, in three words.+ string Hint() => tab switch+ {+ 0 => $"{Shape()} · {SubWords[Sel("subwave", 3)]} {SubOct()} · {FilterWord()}",+ _ => $"amp · flt · lfo {LfoNames[Sel("lfowave", 5)].ToLowerInvariant()}",+ };+ string Summary() => tab switch+ {+ 0 => $"Osc {Shape()} {Pct(G("osclevel"))} · sub {SubWords[Sel("subwave", 3)]} {SubOct()} oct {Pct(G("sublevel"))} → "+ + $"{FilterWord()} dB/oct {Hz(G("filfreq"))} · env {Bip(G("filenv"))} · drive {Pct(G("fildrive"))}",+ _ => $"Amp env {AdsrSum("attack", "decay", "sustain", "release")} → level · "+ + $"filter env {AdsrSum("fattack", "fdecay", "fsustain", "frelease")} → cutoff · "+ + $"LFO {LfoNames[Sel("lfowave", 5)].ToLowerInvariant()} {SlowHz(ExpMap(G("lforate"), 0.05, 30))} → flt {Bip(G("fillfo"))} · pit {LfoPitch(G("lfopitch"))}",+ };+ string Meta()+ {+ string mode = IsMono() ? (G("legato") >= 0.5f ? "MONO LEGATO" : "MONO") : "POLY 16";+ return $"{mode} · ±{BendRange(G("bendrange"))} ST · VOL {Pct(G("volume"))}";+ }+ var statusBar = new Grid { Height = StatusH, ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 10 };+ statusBar.Children.Add(status);+ Grid.SetColumn(meta, 1); statusBar.Children.Add(meta);+ var statusHost = new Border+ {+ Height = StatusH, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 1, 0, 0),+ Background = NotaPalette.SurfaceAbyss, Padding = new Thickness(8, 0), Child = statusBar,+ };++ // ---- assembly ---------------------------------------------------------+ var body = new Grid+ {+ ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto"), ColumnSpacing = NotaSpace.DeviceGap,+ Margin = new Thickness(NotaSpace.DeviceGap),+ };+ body.Children.Add(wheelsPanel);+ Grid.SetColumn(tabPanel, 1); body.Children.Add(tabPanel);+ Grid.SetColumn(rail, 2); body.Children.Add(rail);++ DockPanel.SetDock(statusHost, Dock.Bottom);+ var root = new DockPanel+ {+ LastChildFill = true, Background = NotaPalette.Gutter,+ Children = { statusHost, body },+ };+ctx.SetInstLiveViz(Refresh);- Refresh();- return dockRoot;+ showTab();+ return root;+ }++ // A device section: card ground, hairline, radius 6 — the almanac's section box.+ private static Border SectionBox(Control child) => new()+ {+ Background = NotaPalette.SurfaceCard, BorderBrush = BorderDef, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Tile, ClipToBounds = true, Child = child,+ };++ // A section's own header strip: a hairline under it, nothing else.+ private static Border HeaderStrip(Control child) => new()+ {+ BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Child = child,+ };++ /// <summary>Row definitions that put a caption for each dB mark at its place on the+ /// meter's scale: a star gap, the caption (Auto), … and a star gap for the remainder.</summary>+ private static IEnumerable<string> ScaleRows(params double[] dbs)+ {+ double prev = 0;+ foreach (var db in dbs)+ {+ double fromTop = 1.0 - MeterScale.NormDb(db);+ yield return Math.Max(0, fromTop - prev).ToString("0.000", NotaNum.Culture) + "*";+ yield return "Auto";+ prev = fromTop;+ }+ yield return Math.Max(0, 1.0 - prev).ToString("0.000", NotaNum.Culture) + "*";}}diff --git a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.csindex 8ff919d6..daa6184f 100644--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs@@ -363,9 +363,12 @@ public sealed class FactoryPresetCatalog : IFactoryPresets("amp1level", 0.0f), ("amp2level", 0.9f),("attack", 0.0f), ("decay", 0.4f), ("sustain", 0.7f), ("release", 0.25f), ("volume", 0.82f));- // ---- Nota Bass (kind 7) — bass synth. Osc Shape morphs sine 0 → tri → saw → pulse 1.- // Bipolar knobs (octave/semi/env/lfo-amt/pitch) are neutral at 0.5. Filter type:- // LP 0 / HP .33 / BP .66 / Notch 1; slope 12 = 0 / 24 = 1; mono Poly 0 / Mono 1.+ // ---- Nota Bass (kind 7) — bass synth. Osc Shape morphs sine 0 → tri .333 → saw .667 →+ // pulse 1. Bipolar knobs (octave/semi/env/lfo-amt/pitch) are neutral at 0.5; octave+ // −2 0 / −1 .25 / 0 .5 / +1 .75. Sub wave sine 0 / square .5 / tri 1; sub octave+ // −1 0 / −2 1. Filter type LP 0 / HP .333 / BP .667 / Notch 1; slope 12 = 0 / 24 = 1.+ // LFO wave Sin 0 / Tri .25 / Saw .5 / Sqr .75 / S&H 1. Mono: Poly 0 / Mono 1; Legato+ // 1 = a note played over a held one slides in without a new attack.Inst("bass", 7, "Sub Rumble", ("oscshape", 0.0f), ("osclevel", 0.5f), ("subwave", 0.0f), ("sublevel", 0.95f),("filfreq", 0.3f), ("filreso", 0.1f), ("filenv", 0.55f), ("fildrive", 0.1f),("attack", 0.0f), ("decay", 0.5f), ("sustain", 0.9f), ("release", 0.2f), ("drive", 0.1f), ("volume", 0.9f), ("mono", 1.0f));@@ -375,7 +378,7 @@ public sealed class FactoryPresetCatalog : IFactoryPresetsInst("bass", 7, "Acid 303", ("oscshape", 0.66f), ("osclevel", 0.9f), ("sublevel", 0.2f),("filslope", 1.0f), ("filfreq", 0.32f), ("filreso", 0.75f), ("fildrive", 0.4f), ("filenv", 0.86f), ("filkey", 0.4f),("fdecay", 0.25f), ("fsustain", 0.1f), ("attack", 0.0f), ("decay", 0.35f), ("sustain", 0.6f), ("release", 0.12f),- ("glide", 0.2f), ("drive", 0.4f), ("volume", 0.82f), ("mono", 1.0f));+ ("glide", 0.2f), ("legato", 1.0f), ("drive", 0.4f), ("volume", 0.82f), ("mono", 1.0f));Inst("bass", 7, "Growl Bass", ("oscshape", 0.88f), ("oscpw", 0.35f), ("osclevel", 0.85f), ("sublevel", 0.5f),("filfreq", 0.4f), ("filreso", 0.5f), ("fildrive", 0.5f), ("fillfo", 0.72f), ("lforate", 0.45f), ("lfowave", 0.25f),("drive", 0.55f), ("volume", 0.8f), ("mono", 1.0f));@@ -385,6 +388,72 @@ public sealed class FactoryPresetCatalog : IFactoryPresetsInst("bass", 7, "Wobble Bass", ("oscshape", 0.7f), ("osclevel", 0.85f), ("sublevel", 0.4f),("filslope", 1.0f), ("filfreq", 0.35f), ("filreso", 0.55f), ("fillfo", 0.85f), ("lforate", 0.6f), ("lfowave", 0.0f),("drive", 0.35f), ("volume", 0.8f), ("mono", 1.0f));+ // Sine an octave down with a long pluck and a slide between notes — the 808 shape.+ Inst("bass", 7, "808 Sub", ("oscshape", 0.0f), ("oscoctave", 0.25f), ("osclevel", 0.95f), ("sublevel", 0.0f),+ ("filfreq", 0.8f), ("filenv", 0.5f), ("filkey", 0.0f), ("fildrive", 0.15f),+ ("attack", 0.0f), ("decay", 0.78f), ("sustain", 0.0f), ("release", 0.35f),+ ("glide", 0.25f), ("drive", 0.35f), ("volume", 0.85f));+ Inst("bass", 7, "Classic Mono", ("oscshape", 0.667f), ("subwave", 0.5f), ("sublevel", 0.6f),+ ("filfreq", 0.33f), ("filreso", 0.3f), ("filenv", 0.75f), ("fdecay", 0.4f), ("fsustain", 0.2f),+ ("decay", 0.45f), ("sustain", 0.8f), ("glide", 0.1f), ("volume", 0.82f));+ Inst("bass", 7, "Pulse Bass", ("oscshape", 1.0f), ("oscpw", 0.3f), ("osclevel", 0.8f), ("sublevel", 0.55f),+ ("filfreq", 0.42f), ("filreso", 0.2f), ("filenv", 0.65f), ("fdecay", 0.3f), ("fsustain", 0.2f),+ ("sustain", 0.75f), ("volume", 0.8f));+ Inst("bass", 7, "Finger Bass", ("oscshape", 0.4f), ("osclevel", 0.85f), ("sublevel", 0.5f),+ ("filslope", 0.0f), ("filfreq", 0.3f), ("filreso", 0.1f), ("filenv", 0.66f), ("fdecay", 0.3f), ("fsustain", 0.25f),+ ("attack", 0.08f), ("decay", 0.5f), ("sustain", 0.35f), ("release", 0.2f),+ ("velamp", 0.6f), ("velfilter", 0.5f), ("glide", 0.0f), ("volume", 0.86f));+ Inst("bass", 7, "Picked Bass", ("oscshape", 0.667f), ("sublevel", 0.45f),+ ("filfreq", 0.36f), ("filreso", 0.25f), ("filenv", 0.82f), ("fdecay", 0.22f), ("fsustain", 0.05f),+ ("decay", 0.45f), ("sustain", 0.3f), ("release", 0.15f), ("velfilter", 0.6f), ("glide", 0.0f), ("volume", 0.82f));+ Inst("bass", 7, "Rubber Bass", ("oscshape", 0.333f), ("osclevel", 0.9f), ("sublevel", 0.5f),+ ("filfreq", 0.28f), ("filreso", 0.55f), ("filenv", 0.78f), ("fdecay", 0.38f), ("fsustain", 0.1f),+ ("decay", 0.5f), ("sustain", 0.5f), ("glide", 0.3f), ("legato", 1.0f), ("volume", 0.84f));+ Inst("bass", 7, "Funk Slap", ("oscshape", 0.85f), ("oscpw", 0.4f), ("sublevel", 0.35f),+ ("filfreq", 0.45f), ("filreso", 0.6f), ("filenv", 0.85f), ("fdecay", 0.15f), ("fsustain", 0.0f),+ ("decay", 0.35f), ("sustain", 0.35f), ("release", 0.12f),+ ("velamp", 0.7f), ("velfilter", 0.8f), ("glide", 0.0f), ("volume", 0.8f));+ Inst("bass", 7, "Hoover Bass", ("oscshape", 0.667f), ("osclevel", 0.9f), ("sublevel", 0.3f),+ ("filfreq", 0.6f), ("filreso", 0.15f), ("filenv", 0.55f),+ ("unison", 1.0f), ("lfopitch", 0.53f), ("lforate", 0.55f),+ ("glide", 0.45f), ("legato", 1.0f), ("drive", 0.35f), ("volume", 0.72f));+ Inst("bass", 7, "Dub Sub", ("oscshape", 0.2f), ("osclevel", 0.7f), ("sublevel", 0.8f),+ ("filslope", 0.0f), ("filfreq", 0.25f), ("filreso", 0.15f), ("filenv", 0.55f), ("fillfo", 0.56f), ("lforate", 0.3f),+ ("decay", 0.5f), ("sustain", 0.9f), ("release", 0.3f), ("glide", 0.12f), ("volume", 0.88f));+ Inst("bass", 7, "Techno Rumble", ("oscshape", 0.667f), ("subwave", 0.5f), ("sublevel", 0.7f),+ ("filfreq", 0.22f), ("filreso", 0.35f), ("fildrive", 0.75f), ("filenv", 0.8f), ("fdecay", 0.25f), ("fsustain", 0.0f),+ ("decay", 0.4f), ("sustain", 0.2f), ("release", 0.15f), ("drive", 0.45f), ("glide", 0.0f), ("volume", 0.76f));+ Inst("bass", 7, "Fuzz Bass", ("oscshape", 1.0f), ("oscpw", 0.45f), ("subwave", 0.5f), ("sublevel", 0.5f),+ ("filfreq", 0.5f), ("filreso", 0.2f), ("fildrive", 0.8f), ("filenv", 0.6f),+ ("drive", 0.8f), ("volume", 0.66f));+ // A square 303 line: notes that overlap slide into each other without a new attack.+ Inst("bass", 7, "Acid Slide", ("oscshape", 1.0f), ("oscpw", 0.5f), ("osclevel", 0.9f), ("sublevel", 0.0f),+ ("filfreq", 0.28f), ("filreso", 0.85f), ("fildrive", 0.5f), ("filenv", 0.9f), ("filkey", 0.3f),+ ("fdecay", 0.3f), ("fsustain", 0.0f), ("decay", 0.4f), ("sustain", 0.55f), ("release", 0.1f),+ ("glide", 0.35f), ("legato", 1.0f), ("drive", 0.45f), ("velfilter", 0.6f), ("volume", 0.78f));+ Inst("bass", 7, "Vowel Bass", ("oscshape", 0.667f), ("sublevel", 0.55f),+ ("filtype", 0.667f), ("filslope", 0.0f), ("filfreq", 0.45f), ("filreso", 0.6f), ("filenv", 0.5f),+ ("fillfo", 0.75f), ("lforate", 0.42f), ("lfowave", 0.25f), ("drive", 0.3f), ("volume", 0.86f));+ // The wobble is on the mod wheel — ride it.+ Inst("bass", 7, "Wheel Wobble", ("oscshape", 0.7f), ("sublevel", 0.5f),+ ("filfreq", 0.3f), ("filreso", 0.5f), ("fildrive", 0.35f), ("filenv", 0.55f), ("fillfo", 0.5f),+ ("lforate", 0.6f), ("lfowave", 0.25f), ("modwheel", 0.6f), ("drive", 0.3f), ("volume", 0.8f));+ Inst("bass", 7, "Stab Bass", ("mono", 0.0f), ("oscshape", 0.667f), ("unison", 0.35f), ("sublevel", 0.35f),+ ("filfreq", 0.38f), ("filreso", 0.3f), ("filenv", 0.8f), ("fdecay", 0.25f), ("fsustain", 0.0f),+ ("decay", 0.35f), ("sustain", 0.0f), ("release", 0.2f), ("glide", 0.0f), ("volume", 0.72f));+ Inst("bass", 7, "Octave Bass", ("oscshape", 0.667f), ("oscoctave", 0.75f), ("osclevel", 0.55f),+ ("subwave", 0.0f), ("suboctave", 1.0f), ("sublevel", 0.9f),+ ("filfreq", 0.4f), ("filreso", 0.2f), ("filenv", 0.65f), ("volume", 0.82f));+ Inst("bass", 7, "Soft Round", ("oscshape", 0.333f), ("osclevel", 0.8f), ("sublevel", 0.6f),+ ("filslope", 0.0f), ("filfreq", 0.3f), ("filreso", 0.1f), ("filenv", 0.58f),+ ("attack", 0.35f), ("decay", 0.5f), ("sustain", 0.9f), ("release", 0.4f),+ ("glide", 0.35f), ("legato", 1.0f), ("velamp", 0.2f), ("drive", 0.05f), ("volume", 0.88f));+ Inst("bass", 7, "Drift Bass", ("oscshape", 0.667f), ("unison", 0.45f), ("sublevel", 0.55f),+ ("filfreq", 0.38f), ("filreso", 0.25f), ("filenv", 0.66f),+ ("lfopitch", 0.515f), ("lforate", 0.3f), ("fillfo", 0.55f), ("glide", 0.15f), ("volume", 0.82f));+ Inst("bass", 7, "S&H Bass", ("oscshape", 0.8f), ("sublevel", 0.45f),+ ("filfreq", 0.38f), ("filreso", 0.55f), ("fildrive", 0.4f), ("filenv", 0.55f),+ ("fillfo", 0.8f), ("lforate", 0.62f), ("lfowave", 1.0f), ("drive", 0.3f), ("volume", 0.8f));// ---- Nota Pendulum (kind 8) — generative keys. Sync Free 0 / Sync 1; Division 0 1/1..// 1 1/16; Rate 0.5 = stop, <0.5 reverse; Motion 0 Linear/.33 Pendulum/.67 Ease/diff --git a/src/native/nota.engine/src/BassSynth.h b/src/native/nota.engine/src/BassSynth.hindex e644c74d..a1a8466f 100644--- a/src/native/nota.engine/src/BassSynth.h+++ b/src/native/nota.engine/src/BassSynth.h@@ -13,9 +13,18 @@// A single morphing oscillator (continuous shape blend with pulse-width for the square// end), a dedicated sub oscillator, a TPT state-variable filter (optional 24 dB cascade)// with its own envelope, key-tracking and LFO, plus pre-filter and output saturation for-// grit. Mono mode with legato glide (note stack, last-note priority) makes it a proper-// bass; poly mode is available too. All parameters ride the Instrument plugin-param-// interface (normalized 0..1, stable ids) → automation / persist / clone for free.+// grit. Mono mode (note stack, last-note priority) with glide makes it a proper bass;+// every new note retriggers the envelopes unless Legato is on, in which case a note+// played over a held one slides into it without a new attack. Poly mode is available+// too. Two performance wheels ride on top — pitch bend with a selectable range (1..12+// semitones) and a mod wheel that opens the LFO onto the cutoff (a hand-played wobble)+// — plus an output pan. All parameters ride the Instrument plugin-param interface+// (normalized 0..1, stable ids) → automation / persist / clone for free.+//+// Note bookkeeping counts instances, not pitches: a note-off releases the oldest held+// instance of that pitch only. Two overlapping notes of the same pitch (a repeated note+// whose on lands a sample before the previous off) therefore no longer silence the new+// one.//// Header-only like the other built-in synths. Allocation-free after construction; a// per-sample loop keeps filter/LFO modulation smooth. Filter coefficients update at@@ -47,6 +56,8 @@ public:Attack, Decay, Sustain, Release,LfoRate, LfoWave, LfoPitch,Glide, Unison, Drive, Volume, VelAmp, VelFilter, Mono,+ // ---- appended (v2, almanac rework): wheels, output pan, legato ----+ Bend, BendRange, ModWheel, OutPan, Legato,kNumParams};@@ -62,6 +73,11 @@ public:set(LfoRate, 0.35f); set(LfoWave, 0.0f); set(LfoPitch, 0.5f);set(Glide, 0.08f); set(Unison, 0.0f); set(Drive, 0.15f); set(Volume, 0.85f);set(VelAmp, 0.4f); set(VelFilter, 0.35f); set(Mono, 1.0f);+ set(Bend, 0.5f); // centred+ set(BendRange, 1.0f / 11.0f); // ±2 semitones+ set(ModWheel, 0.0f);+ set(OutPan, 0.5f); // centre+ set(Legato, 0.0f); // every note retriggers}int32_t kind() const override { return 7; }@@ -79,7 +95,8 @@ public:"fattack", "fdecay", "fsustain", "frelease","attack", "decay", "sustain", "release","lforate", "lfowave", "lfopitch",- "glide", "unison", "drive", "volume", "velamp", "velfilter", "mono" };+ "glide", "unison", "drive", "volume", "velamp", "velfilter", "mono",+ "bend", "bendrange", "modwheel", "outpan", "legato" };return (i >= 0 && i < kNumParams) ? std::string(ids[i]) : std::string{};}std::string pluginParamName(int32_t i) const override {@@ -90,7 +107,8 @@ public:"Filter Attack", "Filter Decay", "Filter Sustain", "Filter Release","Attack", "Decay", "Sustain", "Release","LFO Rate", "LFO Wave", "LFO →Pitch",- "Glide", "Unison", "Drive", "Volume", "Vel→Amp", "Vel→Filter", "Mono" };+ "Glide", "Unison", "Drive", "Volume", "Vel→Amp", "Vel→Filter", "Mono",+ "Pitch Bend", "Bend Range", "Mod Wheel", "Out Pan", "Legato" };return (i >= 0 && i < kNumParams) ? std::string(nm[i]) : std::string{};}float pluginParamGet(int32_t i) const override {@@ -130,59 +148,77 @@ public:// ---- note events ------------------------------------------------------void noteOn(int32_t pitch, float velocity) override {- const bool mono = get(Mono) >= 0.5f;const bool glideOn = get(Glide) > 0.001f;- if (mono) {- const bool hadHeld = monoCount_ > 0; // another key already down → true legato overlap- if (monoCount_ < kMonoStack) monoStack_[monoCount_++] = pitch;+ const double target = mtof(pitch);+ const uint32_t seq = ++noteSeq_;+ if (get(Mono) >= 0.5f) {+ const bool hadHeld = monoCount_ > 0; // another key already down → an overlap+ if (monoCount_ == kMonoStack) { // full: forget the oldest key+ for (int r = 1; r < kMonoStack; ++r) monoStack_[r - 1] = monoStack_[r];+ --monoCount_;+ }+ monoStack_[monoCount_++] = pitch;Voice& v = voices_[0];- const double target = 440.0 * std::pow(2.0, (pitch - 69) / 12.0);- // Legato (no envelope retrigger, glide the pitch) only when another note is still- // held. A note struck while the voice is merely releasing (all keys were lifted)- // must retrigger, otherwise it keeps decaying and never actually sounds.- const bool releasing = v.aStage == Stage::Release;- const bool legato = hadHeld && v.active && !releasing && glideOn;- if (!v.active || releasing) v.freqCur = (glideOn && lastFreq_ > 0.0) ? lastFreq_ : target;- else if (!glideOn) v.freqCur = target;+ const bool sounding = v.active && v.aStage != Stage::Release;+ // Legato (no new attack, slide the pitch) only when the patch asks for it AND+ // another note is still held. Otherwise every note is a fresh attack — before,+ // an overlap with glide on skipped it, so on a plucky patch the next note of a+ // tight line was silent.+ const bool legato = get(Legato) >= 0.5f && hadHeld && sounding;+ if (!v.active) v.freqCur = (glideOn && lastFreq_ > 0.0) ? lastFreq_ : target;+ else if (!glideOn) v.freqCur = target; // else glide on from where it is nowv.freqTarget = target;- v.pitch = pitch; v.ktOct = (pitch - 60) / 12.0; v.vel = velocity;- if (!legato) startVoice(v, /*resetPitch=*/false);+ v.pitch = pitch; v.ktOct = (pitch - 60) / 12.0;+ v.seq = seq;+ if (!legato) { v.vel = velocity; startVoice(v); }v.active = true;lastFreq_ = target;return;}Voice* v = findFreeVoice();v->pitch = pitch;- v->freqTarget = 440.0 * std::pow(2.0, (pitch - 69) / 12.0);+ v->freqTarget = target;// Poly: each voice starts at its own pitch. Gliding a fresh voice from the last// note's frequency (a mono/legato notion) makes chord/sequence voices sweep through// one another and beat — so no portamento in poly.v->freqCur = v->freqTarget;v->ktOct = (pitch - 60) / 12.0;v->vel = velocity;- startVoice(*v, /*resetPitch=*/false);+ v->seq = seq;+ v->active = false; // a stolen voice starts clean, not from its old envelope+ startVoice(*v);v->active = true;lastFreq_ = v->freqTarget;}void noteOff(int32_t pitch) override {- if (get(Mono) >= 0.5f) {- int w = 0;- for (int r = 0; r < monoCount_; ++r) if (monoStack_[r] != pitch) monoStack_[w++] = monoStack_[r];- monoCount_ = w;+ // Drop one instance of the key from the mono stack (the oldest), whatever the mode:+ // a key pressed in mono and released after switching to poly must not stay "held".+ int found = -1;+ for (int r = 0; r < monoCount_; ++r) if (monoStack_[r] == pitch) { found = r; break; }+ if (found >= 0) {+ for (int r = found + 1; r < monoCount_; ++r) monoStack_[r - 1] = monoStack_[r];+ --monoCount_;+ }+ if (get(Mono) >= 0.5f && found >= 0) {Voice& v = voices_[0];- if (monoCount_ == 0) { v.aStage = Stage::Release; v.fStage = Stage::Release; }- else {- const int top = monoStack_[monoCount_ - 1];+ if (monoCount_ == 0) { release(v); return; }+ // Back to the newest key still held (or keep sounding the same one, when the+ // key just lifted was an older repeat of it). No new attack — it's one phrase.+ const int top = monoStack_[monoCount_ - 1];+ if (top != v.pitch) {v.pitch = top; v.ktOct = (top - 60) / 12.0;- v.freqTarget = 440.0 * std::pow(2.0, (top - 69) / 12.0);+ v.freqTarget = mtof(top);lastFreq_ = v.freqTarget;}return;}+ // Poly (or a note that was struck in poly before switching to mono): release the+ // oldest held voice of this pitch — only one, so a newer repeat keeps sounding.+ Voice* oldest = nullptr;for (auto& v : voices_)- if (v.active && v.pitch == pitch && v.aStage != Stage::Release) {- v.aStage = Stage::Release; v.fStage = Stage::Release;- }+ if (v.active && v.pitch == pitch && v.aStage != Stage::Release && (!oldest || v.seq < oldest->seq))+ oldest = &v;+ if (oldest) release(*oldest);}void allNotesOff() override { for (auto& v : voices_) v.active = false; monoCount_ = 0; }@@ -219,6 +255,14 @@ public:const double glide = get(Glide);const double glideCoef = glide > 0.001 ? (1.0 - std::exp(-1.0 / (expMap(glide, 0.005, 0.6) * sampleRate_))) : 1.0;const float velAmp = get(VelAmp), velFilt = get(VelFilter);+ // Pitch-bend wheel, in the range the patch declares (1..12 semitones); the mod+ // wheel opens the LFO onto the cutoff, up to ±2 octaves on top of the patch's own.+ const double bendMul = std::exp2((get(Bend) - 0.5) * 2.0 * std::round(1.0 + get(BendRange) * 11.0) / 12.0);+ const double wheelLfo = get(ModWheel) * 2.0;+ // Balance-law pan: centre is unity on both sides, so a centred patch sounds as it+ // always has; a side fades the other channel out.+ const float pan = (get(OutPan) - 0.5f) * 2.0f;+ const float panL = std::min(1.0f, 1.0f - pan), panR = std::min(1.0f, 1.0f + pan);const double outDrive = 1.0 + get(Drive) * 7.0; // 1..8const double outMakeup = 1.0 / std::tanh(outDrive);const float volume = get(Volume);@@ -228,7 +272,7 @@ public:// Shared LFO.const double lfo = lfoValue(lfoWave, lfoPhase_, lfoSH_);lfoPhase_ += lfoInc; if (lfoPhase_ >= 1.0) { lfoPhase_ -= 1.0; lfoSH_ = noise() * 2.0f - 1.0f; }- const double pitchMod = lfoPitchSemis != 0.0 ? std::exp2(lfoPitchSemis * lfo / 12.0) : 1.0;+ const double pitchMod = (lfoPitchSemis != 0.0 ? std::exp2(lfoPitchSemis * lfo / 12.0) : 1.0) * bendMul;float mono = 0.0f;for (auto& v : voices_) {@@ -258,7 +302,7 @@ public:if (v.modCount-- <= 0) {v.modCount = 15;const double velF = 1.0f - velFilt + velFilt * v.vel;- const double octs = fEnvAmt * 4.0 * v.fEnv * velF + fKey * v.ktOct + fLfoAmt * 2.0 * lfo;+ const double octs = fEnvAmt * 4.0 * v.fEnv * velF + fKey * v.ktOct + (fLfoAmt * 2.0 + wheelLfo) * lfo;const double fc = std::clamp(fbase * std::exp2(octs), 20.0, sampleRate_ * 0.49);setSvf(v.a1, v.a2, v.a3, fc, k);}@@ -271,8 +315,8 @@ public:if (outDrive > 1.001) mono = (float)(std::tanh(mono * outDrive) * outMakeup);const float o = mono * volume * 0.5f;- out[i * 2] += o;- out[i * 2 + 1] += o;+ out[i * 2] += o * panL;+ out[i * 2 + 1] += o * panR;}}@@ -291,21 +335,33 @@ private:double s1[2] = {0, 0}, s2[2] = {0, 0}; // SVF integrator state (two cascaded stages)double a1 = 0, a2 = 0, a3 = 0;int32_t modCount = 0;+ uint32_t seq = 0; // note-on order: a note-off releases the oldest};void set(Param p, float v) { pn_[p].store(v, std::memory_order_relaxed); }float get(Param p) const { return pn_[p].load(std::memory_order_relaxed); }double bip(Param p) const { return (get(p) - 0.5f) * 2.0; } // 0..1 → -1..+1- // Fresh note: reset phases + retrigger both envelopes.- void startVoice(Voice& v, bool /*resetPitch*/) {- v.phM = 0.0; v.phMu = 0.25; v.phS = 0.0;- v.aEnv = 0.0f; v.aStage = Stage::Attack;- v.fEnv = 0.0f; v.fStage = Stage::Attack;- v.s1[0] = v.s1[1] = v.s2[0] = v.s2[1] = 0.0;- v.a1 = v.a2 = v.a3 = 0.0;+ static double mtof(int32_t pitch) { return 440.0 * std::pow(2.0, (pitch - 69) / 12.0); }++ // New attack. A silent voice starts clean — phases at zero, envelopes and filter from+ // rest. A voice that is still sounding (a mono retrigger) keeps its phases, filter+ // state and envelope levels and attacks from where it is, so the retrigger never clicks.+ void startVoice(Voice& v) {+ if (!v.active) {+ v.phM = 0.0; v.phMu = 0.25; v.phS = 0.0;+ v.aEnv = 0.0f; v.fEnv = 0.0f;+ v.s1[0] = v.s1[1] = v.s2[0] = v.s2[1] = 0.0;+ v.a1 = v.a2 = v.a3 = 0.0;+ }+ v.aStage = Stage::Attack;+ v.fStage = Stage::Attack;v.modCount = 0;}+ static void release(Voice& v) {+ if (!v.active) return;+ v.aStage = Stage::Release; v.fStage = Stage::Release;+ }static void advanceEnv(float& env, Stage& st, float atk, float dec, float sus, float rel) {switch (st) {@@ -408,6 +464,7 @@ private:double lfoPhase_ = 0.0;float lfoSH_ = 0.0f;double lastFreq_ = 0.0; // portamento reference+ uint32_t noteSeq_ = 0;uint32_t rng_ = 0x9E3779B9u;std::atomic<float> pn_[kNumParams];};diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 452c9c01..79774c73 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -1539,7 +1539,7 @@ Console.WriteLine("-- Nota Bass --");Check(be.DeviceName(t, -1) == "Nota Bass", $"instrument is Nota Bass (got '{be.DeviceName(t, -1)}')");int pc = be.PluginParamCount(t, -1);- Check(pc == 34, $"Nota Bass exposes 34 params (got {pc})");+ Check(pc == 39, $"Nota Bass exposes 39 params (got {pc})");int cut = -1; bool idsOk = true;for (int i = 0; i < pc; i++){@@ -1551,7 +1551,7 @@ Console.WriteLine("-- Nota Bass --");// State round-trips to another track (project save/load path).be.PluginParamSet(t, -1, cut, 0.77f);var state = be.GetPluginState(t, -1);- Check(state.Length >= 34 * 4, $"bass state serialized ({state.Length} bytes)");+ Check(state.Length >= 39 * 4, $"bass state serialized ({state.Length} bytes)");int t2 = be.AddBassSynthTrack();be.SetPluginState(t2, -1, state);Check(Math.Abs(be.PluginParamGet(t2, -1, cut) - 0.77f) < 1e-4, "bass state restores params on another track");@@ -1589,6 +1589,131 @@ Console.WriteLine("-- Nota Bass --");float after = be.PluginParamGet(ta, -1, fi);Check(after > 0.7f, $"automation drives Bass cutoff (filfreq = {after:F2})");}++ // A project saved before v2 (34 floats) loads: the old params keep their values and+ // the five appended ones start at their defaults.+ {+ int told = be.AddBassSynthTrack();+ be.SetPluginState(told, -1, state.AsSpan(0, 34 * 4).ToArray());+ int ci = -1, pi = -1, li = -1;+ for (int i = 0; i < be.PluginParamCount(told, -1); i++)+ {+ string id = be.PluginParamId(told, -1, i);+ if (id == "filfreq") ci = i; else if (id == "outpan") pi = i; else if (id == "legato") li = i;+ }+ Check(Math.Abs(be.PluginParamGet(told, -1, ci) - 0.77f) < 1e-4+ && Math.Abs(be.PluginParamGet(told, -1, pi) - 0.5f) < 1e-4 && be.PluginParamGet(told, -1, li) < 0.5f,+ "a 34-param Bass state loads; the appended params stay at their defaults");+ }++ // Each case renders on its own engine so nothing sounding in one leaks into the next.+ float[] BassRender(NotaNote[] notes, int frames, params (string Id, float Value)[] ps)+ {+ using var we = new NotaEngine();+ we.SetBpm(120); we.SetTimeSignature(4, 4);+ int tw = we.AddBassSynthTrack();+ foreach (var (id, value) in ps)+ for (int i = 0; i < we.PluginParamCount(tw, -1); i++)+ if (we.PluginParamId(tw, -1, i) == id) we.PluginParamSet(tw, -1, i, value);+ we.AddMidiClip(tw, 0.0, 4.0);+ we.SetClipNotes(tw, 0, notes);+ var b = new float[frames * 2];+ we.Seek(0.0); we.Play(); we.RenderOffline(b, frames); we.StopTransport();+ return b;+ }+ static float BassRms(float[] b, int from, int to, int ch = -1)+ {+ double sum = 0; int n = 0;+ for (int i = from; i < to; i++)+ {+ if (ch != 1) { sum += b[i * 2] * (double)b[i * 2]; n++; }+ if (ch != 0) { sum += b[i * 2 + 1] * (double)b[i * 2 + 1]; n++; }+ }+ return (float)Math.Sqrt(sum / Math.Max(1, n));+ }+ double bassSpb = (be.SampleRate > 0 ? be.SampleRate : 48000.0) * 60.0 / 120.0; // 120 BPM+ int BF(double beats) => (int)Math.Round(beats * bassSpb);++ // Regression: back-to-back notes of the same pitch where the next note starts a hair+ // before the previous one ends. The previous note's off used to release every note of+ // that pitch — the new one too — so the line went silent. Mono (with glide, the+ // default) and poly alike; the second note must still sound in the middle of its span.+ for (int m = 0; m < 2; m++)+ {+ var b = BassRender(new[] { new NotaNote(36, 0.0, 0.52, 0.9f), new NotaNote(36, 0.5, 0.5, 0.9f) }, BF(1.2),+ ("mono", m), ("release", 0f));+ float mid = BassRms(b, BF(0.7), BF(0.95));+ Check(mid > 0.01f, $"Nota Bass {(m == 1 ? "mono" : "poly")}: an overlapping repeat of the same note keeps sounding (RMS {mid:F3})");+ }++ // Mono, overlapping different pitches on a plucky patch (sustain 0, glide on): every+ // note is a new attack unless Legato is on — before, the overlap skipped the attack and+ // the second note of a tight line was silent.+ {+ var line = new[] { new NotaNote(36, 0.0, 0.55, 0.9f), new NotaNote(43, 0.5, 0.5, 0.9f) };+ (string, float)[] pluck = { ("mono", 1f), ("glide", 0.3f), ("decay", 0.55f), ("sustain", 0f) };+ var retrig = BassRender(line, BF(1.0), pluck);+ var legato = BassRender(line, BF(1.0), pluck.Append(("legato", 1f)).ToArray());+ float rAtt = BassRms(retrig, BF(0.5), BF(0.6)), lAtt = BassRms(legato, BF(0.5), BF(0.6));+ Check(rAtt > 0.02f, $"Nota Bass mono: an overlapping note attacks afresh (RMS {rAtt:F3})");+ Check(rAtt > lAtt * 2f, $"Nota Bass legato: an overlapping note slides without a new attack ({rAtt:F3} vs {lAtt:F3})");+ }++ // v2: the pitch-bend wheel and the output pan.+ {+ int Crossings(float[] b, int n)+ {+ int c = 0; for (int i = 2; i < n * 2; i += 2) if ((b[i - 2] < 0) != (b[i] < 0)) c++;+ return c;+ }+ var note = new[] { new NotaNote(45, 0.0, 2.0, 0.9f) };+ (string, float)[] sine = { ("oscshape", 0f), ("sublevel", 0f), ("filfreq", 1f), ("filenv", 0.5f) };+ var flat = BassRender(note, 8192, sine);+ var bent = BassRender(note, 8192, sine.Append(("bend", 1f)).Append(("bendrange", 1f)).ToArray());+ bool fin = true; foreach (var x in bent) if (!float.IsFinite(x) || Math.Abs(x) > 8f) { fin = false; break; }+ int cf = Crossings(flat, 8192), cb = Crossings(bent, 8192);+ Check(fin && cb > cf * 1.5, $"Nota Bass: pitch bend +12 st raises the pitch ({cf} → {cb} crossings)");++ var left = BassRender(note, 8192, ("outpan", 0f));+ float l = BassRms(left, 0, 8192, 0), r = BassRms(left, 0, 8192, 1);+ Check(l > 0.01f && r < l * 0.01f, $"Nota Bass: pan hard left silences the right channel (L {l:F3} / R {r:F3})");+ var centre = BassRender(note, 8192);+ float cl = BassRms(centre, 0, 8192, 0), cr = BassRms(centre, 0, 8192, 1);+ Check(Math.Abs(cl - cr) < 1e-5f && Math.Abs(cl - l) < l * 0.05f, $"Nota Bass: centred pan keeps unity level on both sides ({cl:F3} / {cr:F3})");++ // The mod wheel opens the LFO onto the cutoff: silent at 0, audible when up.+ (string, float)[] wob = { ("filfreq", 0.35f), ("fillfo", 0.5f), ("lforate", 0.6f), ("filenv", 0.5f) };+ var down = BassRender(note, 8192, wob);+ var up = BassRender(note, 8192, wob.Append(("modwheel", 1f)).ToArray());+ float d = 0; for (int i = 0; i < down.Length; i++) d += Math.Abs(down[i] - up[i]);+ Check(d / down.Length > 1e-3f, "Nota Bass: the mod wheel moves the cutoff through the LFO");+ }++ // Factory presets: 25 ship, every named param is a real Bass id, each applies in place.+ {+ var bassIds = new System.Collections.Generic.HashSet<string>();+ for (int i = 0; i < pc; i++) bassIds.Add(be.PluginParamId(t, -1, i));+ var cat = new FactoryPresetCatalog();+ var mine = cat.All().Where(p => p.IsInstrument && p.BuiltinKind == 7).ToList();+ Check(mine.Count == 25, $"Nota Bass ships 25 factory presets (got {mine.Count})");+ var bad = mine.SelectMany(p => cat.Document(p.Id)!.NamedParams!.Keys.Where(k => !bassIds.Contains(k)).Select(k => $"{p.DisplayName}:{k}")).ToList();+ Check(bad.Count == 0, $"every Bass preset param id exists{(bad.Count > 0 ? " — bad: " + string.Join(", ", bad) : "")}");+ int tp = be.AddBassSynthTrack();+ int fails = mine.Count(p => cat.ApplyInPlace(be, p.Id, tp, -1).Length != 0);+ Check(fails == 0, $"every Bass preset applies in place ({fails} failed)");+ // Each preset is audible and finite on a short bass line.+ var quiet = new System.Collections.Generic.List<string>();+ foreach (var p in mine)+ {+ var doc = cat.Document(p.Id)!;+ var b = BassRender(new[] { new NotaNote(36, 0.0, 0.5, 0.9f), new NotaNote(43, 0.5, 0.5, 0.9f), new NotaNote(36, 1.0, 0.5, 0.9f) },+ BF(1.6), doc.NamedParams!.Select(kv => (kv.Key, kv.Value)).ToArray());+ bool ok = true; foreach (var x in b) if (!float.IsFinite(x) || Math.Abs(x) > 4f) { ok = false; break; }+ float rms = BassRms(b, 0, BF(1.6));+ if (!ok || rms < 0.01f || rms > 0.9f) quiet.Add($"{p.DisplayName} ({rms:F3})");+ }+ Check(quiet.Count == 0, $"every Bass preset renders audible and finite{(quiet.Count > 0 ? " — off: " + string.Join(", ", quiet) : "")}");+ }}// ============================ Nota Monolith ================================