Skip to content

armgit / nota

Public Imported from GitHub
0

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

Redesign of Operator

Egor Khindikaynen4f6169f308aa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e67c55f..1d457879 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,21 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Nota Operator grew two performance wheels and keyboard tracking, 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** on the modulation index sit in a rail that stays on screen
+ on every tab; the filter gains **keyboard tracking** (0 / ½ / 1 octave per octave) and
+ the amplifier a **Vel → Level** amount. The card lays the synth out as **Operators ·
+ Algorithm · Filter · Amp** tabs — the four operators as a table that names each one's
+ role in words, the eleven topologies as sketches over a routing diagram you can still
+ drag to re-route, and the filter response beside the live harmonic spectrum — over a
+ 186 px rail that switches between **Global** (FM depth, feedback, tone, glide, bend
+ range, voice mode, volume and the track's meter) and **Env** (one operator's ADSR, drawn
+ and draggable, with key and velocity tracking), 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 at values that sound exactly as before.
+- **Nota Operator ships 25 factory presets** (was 6) — keys, bells and mallets, basses,
+ leads, pads and percussion, including the six that existed before under their old names.
- **Nota Synth grew an oscillator and a voice section, and its editor is now three tabs.**
The oscillator gains **pulse width** (on the square), **detune**, **octave** and a
**unison** stack of 1 / 2 / 4 / 7 voices with a stereo **spread**; the filter gains a
@@ -189,6 +204,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
message past the half-way point, so sweeping a mapped CC across it made the target
flutter instead of toggling once. It now fires on the crossing only — which is also what
makes a mapped gamepad trigger usable.
+- The filter-response graph shared by Nota Volt, Aurora, Bass and Operator labelled its
+ frequency axis `20 · 100 · 1k · 10k · 20k` regardless of where those points actually
+ fell, and read the cutoff off Volt's own map on every instrument. It now takes the
+ instrument's real cutoff range, so both the scale and the readout say what the engine
+ does.
## [0.38.0] — 2026-09-12
diff --git a/FEATURES.md b/FEATURES.md
index 4f316f94..085e3605 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -267,8 +267,10 @@ and user presets, automation, persistence and cloning.
Off/Sync/Bend/PWM/Fold) plus a sub oscillator and unison, two filters with routing, two
envelopes, two LFOs, an 8×7 mod matrix, 4 macros, built-in drive/chorus/reverb,
Mono/Poly.
-- **Nota Operator** — FM synth, 4 operators, 11 algorithms (with interactive diagrams and
- drag-to-reroute), spectrum display, VEL→FM, Glide, Mono.
+- **Nota Operator** — FM synth: 4 operators (wave, coarse ratio, fine detune, level and
+ their own ADSR each), 11 algorithms with interactive diagrams and drag-to-reroute,
+ feedback, a live harmonic spectrum, an LP/HP/BP filter with keyboard tracking, pitch-bend
+ (±2/±5/±12) and modulation wheels, VEL→FM, VEL→LEVEL, KEY→LEVEL, Glide, Mono.
- **Nota Pendulum** — a "pendulum" sequencer: swinging balls generate notes, with swing
curves (Linear/Pendulum/Ease/Bounce), bipolar Rate, a held chord, Scale, Hold, First
Note, Reset, Humanize and Pan Spread.
diff --git a/src/managed/Nota.App/Controls/OperatorAlgoViz.cs b/src/managed/Nota.App/Controls/OperatorAlgoViz.cs
index 378c7412..8391c4c2 100644
--- a/src/managed/Nota.App/Controls/OperatorAlgoViz.cs
+++ b/src/managed/Nota.App/Controls/OperatorAlgoViz.cs
@@ -51,11 +51,20 @@ internal static class OperatorTopo
for (int o = 0; o < 4; o++) if (level[o] == L)
{
x[o] = cnt == 1 ? 0.5 : 0.14 + idx / (double)(cnt - 1) * 0.72; idx++;
- y[o] = maxL == 0 ? 0.42 : 0.12 + (1.0 - L / (double)maxL) * 0.56;
+ y[o] = maxL == 0 ? 0.42 : 0.06 + (1.0 - L / (double)maxL) * 0.72;
}
}
}
+ /// <summary>How many modulation layers a topology stacks (0 = everything is a carrier).</summary>
+ public static int Depth(int[] tgt)
+ {
+ var level = new int[4];
+ for (int o = 3; o >= 0; o--) level[o] = tgt[o] == 4 ? 0 : level[tgt[o]] + 1;
+ int maxL = 0; for (int o = 0; o < 4; o++) maxL = Math.Max(maxL, level[o]);
+ return maxL;
+ }
+
// The op nearest a normalised point (for drag hit-testing), or -1.
public static int Nearest(double[] x, double[] y, double px, double py, double r)
{
@@ -195,7 +204,10 @@ internal sealed class OperatorRoutingViz : Control
double padX = 10, padT = 14, padB = 4;
double gx0 = padX, gx1 = w - padX, gy0 = padT, gy1 = h - padB;
- double bw = Math.Min(38, (gx1 - gx0) / 4.6), bh = Math.Min(20, (gy1 - gy0) / 3.2);
+ // Box height follows the stack depth, so the deepest chain still shows four
+ // separate boxes instead of one smear.
+ double bw = Math.Min(38, (gx1 - gx0) / 4.6);
+ double bh = Math.Clamp((gy1 - gy0) / (OperatorTopo.Depth(tgt) + 2.0), 10, 20);
double outY = gy1 - bh * 0.4;
Point Ctr(int o)
{
@@ -226,6 +238,9 @@ internal sealed class OperatorRoutingViz : Control
var rect = new Rect(c.X - bw / 2, c.Y - bh / 2, bw, bh);
_boxRect[o] = rect;
bool carr = _carrier[o];
+ // Opaque ground first: the washes are translucent and a connection line passing
+ // behind a box would otherwise strike through its letter.
+ ctx.DrawRectangle(Sunken, null, rect, 3, 3);
ctx.DrawRectangle(carr ? AccentSubtle : TealSubtle, new Pen(carr ? Brass : Teal, 1.3), rect, 3, 3);
var ft = new FormattedText(OperatorTopo.Names[o], CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Bold, 10, carr ? AccentBright : Teal);
ctx.DrawText(ft, new Point(c.X - ft.Width / 2, c.Y - ft.Height / 2));
diff --git a/src/managed/Nota.App/Controls/PerformWheel.cs b/src/managed/Nota.App/Controls/PerformWheel.cs
new file mode 100644
index 00000000..c92c09a6
--- /dev/null
+++ b/src/managed/Nota.App/Controls/PerformWheel.cs
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// A performance wheel — the pitch-bend / modulation pair every hardware synth puts left of
+// the keys, drawn flat to the almanac: a sunken pill, a hairline border, tick marks and a
+// Brass Light bar at the value. Nota Operator's card keeps both on screen on every tab.
+//
+// Interaction matches the knob contract: vertical drag (up increases) over the wheel's own
+// height, Shift/Ctrl/⌘ for fine, a click never jumps the value, double-click restores the
+// default, and a spring wheel (pitch bend) returns to its default when released.
+
+using System;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Media;
+
+namespace Nota.App;
+
+internal sealed class PerformWheel : Control
+{
+ private const double Travel = 140; // px of drag for the full range — the knob's feel
+
+ private static readonly IBrush Well = NotaPalette.BgSunken;
+ private static readonly IBrush Face = NotaPalette.SurfaceRaised;
+ private static readonly IBrush Edge = NotaPalette.BorderDefault;
+ private static readonly IBrush Tick = NotaPalette.BorderStrong;
+ private static readonly IBrush Bar = NotaPalette.AccentBright;
+ private static readonly IBrush BarOff = NotaPalette.TextTertiary;
+
+ private double _norm;
+ private bool _drag;
+ private double _startY, _startV;
+
+ /// <summary>Value restored on double-click, and sprung back to when <see cref="Spring"/>.</summary>
+ public double Default { get; init; } = 0;
+
+ /// <summary>True for a pitch wheel: it snaps back to <see cref="Default"/> on release.</summary>
+ public bool Spring { get; init; }
+
+ public bool Dragging => _drag;
+
+ public event Action<double>? ValueChanged;
+ public event Action? GestureBegin;
+ public event Action? GestureEnd;
+
+ public PerformWheel()
+ {
+ Width = 16;
+ Cursor = new Cursor(StandardCursorType.SizeNorthSouth);
+ Focusable = false;
+ }
+
+ /// <summary>Follow an external write (automation, a preset) without raising ValueChanged.</summary>
+ public double Norm
+ {
+ get => _norm;
+ set { double v = Math.Clamp(value, 0, 1); if (Math.Abs(v - _norm) < 1e-6) return; _norm = v; InvalidateVisual(); }
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ var pt = e.GetCurrentPoint(this);
+ if (!pt.Properties.IsLeftButtonPressed) return; // right-click bubbles to the CV / learn menu
+ if (e.ClickCount >= 2) { Write(Default); e.Handled = true; return; }
+ _drag = true; _startY = pt.Position.Y; _startV = _norm;
+ GestureBegin?.Invoke();
+ e.Pointer.Capture(this);
+ e.Handled = true;
+ }
+
+ protected override void OnPointerMoved(PointerEventArgs e)
+ {
+ if (!_drag) return;
+ double fine = e.KeyModifiers.HasFlag(KeyModifiers.Shift) || e.KeyModifiers.HasFlag(KeyModifiers.Control)
+ || e.KeyModifiers.HasFlag(KeyModifiers.Meta) ? 0.25 : 1.0;
+ Write(_startV + (_startY - e.GetPosition(this).Y) / Travel * fine);
+ }
+
+ protected override void OnPointerReleased(PointerReleasedEventArgs e)
+ {
+ if (!_drag) return;
+ _drag = false;
+ e.Pointer.Capture(null);
+ if (Spring) Write(Default);
+ GestureEnd?.Invoke();
+ }
+
+ private void Write(double v)
+ {
+ v = Math.Clamp(v, 0, 1);
+ if (Math.Abs(v - _norm) < 1e-6) return;
+ _norm = v; InvalidateVisual(); ValueChanged?.Invoke(v);
+ }
+
+ public override void Render(DrawingContext ctx)
+ {
+ double w = Bounds.Width, h = Bounds.Height;
+ if (w <= 2 || h <= 6) return;
+ double r = w / 2;
+ var body = new Rect(0.5, 0.5, w - 1, h - 1);
+ ctx.DrawRectangle(Well, new Pen(Edge, 1), body, r, r);
+
+ // A short raised face in the middle third — the part the thumb would touch.
+ double faceH = Math.Max(10, h * 0.34);
+ ctx.DrawRectangle(Face, null, new Rect(1.5, (h - faceH) / 2, w - 3, faceH), r - 1, r - 1);
+
+ // Grip ticks over the face, evenly spaced.
+ for (int i = 1; i <= 3; i++)
+ {
+ double ty = (h - faceH) / 2 + faceH * i / 4.0;
+ ctx.DrawLine(new Pen(Tick, 1), new Point(3, ty), new Point(w - 3, ty));
+ }
+
+ // The value bar. Pitch reads from the centre, so at rest it sits on the centreline.
+ double pad = 3;
+ double y = pad + (1 - _norm) * (h - pad * 2);
+ bool live = Math.Abs(_norm - Default) > 1e-3;
+ ctx.DrawRectangle(live ? Bar : BarOff, null, new Rect(1.5, y - 1, w - 3, 2), 1, 1);
+ }
+}
diff --git a/src/managed/Nota.App/Controls/VoltFilter.cs b/src/managed/Nota.App/Controls/VoltFilter.cs
index 08c192de..a82180dd 100644
--- a/src/managed/Nota.App/Controls/VoltFilter.cs
+++ b/src/managed/Nota.App/Controls/VoltFilter.cs
@@ -29,6 +29,11 @@ namespace Nota.App;
private string _title = "FILTER 1";
private bool _drag;
+ /// <summary>The instrument's own cutoff map, lo → hi in Hz (Volt's is the default).
+ /// The readout and the frequency scale both come from it, so the graph says what the
+ /// engine actually does.</summary>
+ public (double Lo, double Hi) FreqRange { get; set; } = (20.0, 18000.0);
+
public VoltFilter(IAudioEngine e, int t) { _e = e; _t = t; MinWidth = 150; MinHeight = 96; }
public void Target(string title, (int, string) freq, (int, string) reso, int type)
{ _title = title; _freq = freq; _reso = reso; _type = type; InvalidateVisual(); }
@@ -132,10 +137,11 @@ namespace Nota.App;
void Lbl(string t, double x, double y, IBrush b) => ctx.DrawText(new FormattedText(t, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Face, 8, b), new Point(x, y));
Lbl("+12", x0 + 1, top - 1, AxisB);
Lbl("−48\u2009dB", x0 + 1, bot - 10, AxisB);
- string[] fq = { "20", "100", "1k", "10k", "20k" };
- for (int i = 0; i < 5; i++) { double lx = x0 + (x1 - x0) * i / 4.0; Lbl(fq[i], Math.Clamp(lx - 6, x0, x1 - 18), bot + 2, AxisB); }
- double hz = 20.0 * Math.Pow(900.0, cut);
+ double HzAt(double v) => FreqRange.Lo * Math.Pow(FreqRange.Hi / FreqRange.Lo, v);
+ for (int i = 0; i < 5; i++)
+ { double lx = x0 + (x1 - x0) * i / 4.0; Lbl(NotaNum.Hz(HzAt(i / 4.0)), Math.Clamp(lx - 6, x0, x1 - 22), bot + 2, AxisB); }
+ double hz = HzAt(cut);
Glyph.Draw(ctx, GlyphKind.Record, new Rect(x1 - 52, top + 2, 5, 5), AccentBright);
- Lbl(hz >= 1000 ? $"{hz / 1000.0:0.0}k" : $"{hz:0}\u2009Hz", x1 - 45, top - 1, AccentBright);
+ Lbl(NotaNum.Hz(hz), x1 - 45, top - 1, AccentBright);
}
}
diff --git a/src/managed/Nota.App/DeviceCards/Instruments/OperatorInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/OperatorInstrumentCard.cs
index 664fbd5e..28bb9207 100644
--- a/src/managed/Nota.App/DeviceCards/Instruments/OperatorInstrumentCard.cs
+++ b/src/managed/Nota.App/DeviceCards/Instruments/OperatorInstrumentCard.cs
@@ -1,22 +1,29 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
-// Detail · Devices — built-in Nota Operator editor (instrument kind 9), mockup 3g: a
-// 4-operator FM synth in the shared 700×260 shell (header 26 · contextual strip 34 · body).
-// A left tab rail switches three views:
-// OPS — four operator rows stating each op's ROLE in words (CARRIER / MOD→X) in its
-// colour, with wave · coarse ratio · fine · level, beside a live harmonic SPECTRUM.
-// ALGO — the 11 algorithms as drawn sketches (picker), the current routing full-width
-// with real connection lines + drag-to-re-route, and two per-op envelopes.
-// FILTER— the subtractive LP/HP/BP filter response + output.
-// The strip carries the four performance controls (FM depth · Feedback · Tone · Glide) + the
-// voice mode. Everything is a plugin param → automation / persist / clone.
+// Detail · Devices — built-in Nota Operator editor (instrument kind 9): a 4-operator FM
+// synth in the 700 × 260 card the almanac draws for it.
+//
+// Wheels 56 pitch bend and mod wheel, on screen on every tab — the two hand controls
+// a player reaches for first.
+// Centre three tabs:
+// Operators — the four operators as a table: role in words, wave, coarse
+// ratio, fine detune, level with its dB.
+// Algorithm — the 11 topologies as sketches, feedback, and the routing
+// diagram (drag one operator onto another to re-route).
+// Filter · Amp— the subtractive filter's response and the live harmonic
+// spectrum, with type / freq / reso / key track / volume.
+// Rail 186 Global (FM depth, feedback, tone, glide, bend range, voice mode, volume
+// and the track's meter) or Env (one operator's ADSR, drawn and draggable,
+// with key and velocity tracking).
+//
+// Brass is a carrier — what reaches the output; teal is a modulator. Everything is a
+// plugin param → automation / persist / clone.
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
-using Avalonia.Controls.Shapes;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
@@ -31,16 +38,38 @@ internal sealed class OperatorInstrumentCard : IInstrumentCard
public string Subtitle => "FM";
public double CardWidth => 700;
+ private const double WheelsW = 56, RailW = 186, TabH = 20, StatusH = 18;
+
// Coarse ratio table — mirrors OperatorSynth::kRatio.
private static readonly double[] Ratios = { 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16 };
private static readonly string[] WaveShort = { "Sin", "Tri", "Saw", "Sqr" };
+ private static readonly string[] FilterNames = { "LP", "HP", "BP" };
+ private static readonly string[] KeyTrkNames = { "0", "½", "1" };
+ private static readonly string[] BendNames = { "±2", "±5", "±12" };
+ private static readonly float[] BendStops = { 1f / 11f, 4f / 11f, 1f };
private static readonly string[] OpId = { "a", "b", "c", "d" };
- private static readonly IBrush[] OpColor = { NotaPalette.Accent, NotaPalette.Accent, NotaPalette.Teal, NotaPalette.Teal };
+ private static readonly string[] TabNames = { "Operators", "Algorithm", "Filter · Amp" };
+ private static readonly string[] RailTabs = { "Global", "Env" };
+ private static readonly string[] TabHints =
+ {
+ "wave · ratio · fine · level",
+ "11 topologies · feedback on A",
+ "type · freq · reso · key track",
+ };
- private static readonly IBrush Strip = NotaPalette.SurfaceCard;
- private static readonly IBrush Rail = NotaPalette.SurfaceInset;
- private static readonly IBrush Inset = NotaPalette.BgSunken;
- private static readonly IBrush Ink = NotaPalette.TextOnAccent;
+ // Engine's perceptual map (OperatorSynth.h): lo * (hi/lo)^v.
+ private static double ExpMap(float v, double lo, double hi) => lo * Math.Pow(hi / lo, Math.Clamp(v, 0f, 1f));
+ private static string Secs(float v, double lo, double hi) => NotaNum.Time(ExpMap(v, lo, hi));
+ private static string Hz(float v) => NotaNum.Hz(ExpMap(v, 60, 18000));
+ private static string Glide(float v) => v <= 1e-4f ? "off" : NotaNum.Time(ExpMap(v, 0.005, 1.2));
+ private static string Level(float v) => v <= 1e-3f ? "−∞" : NotaNum.Db(AudioMath.LinToDb(v));
+ private static string Cents(float v) => NotaNum.Unit((v - 0.5f) * 96, "+0;−0;0", "c");
+ private static string RatioText(float v)
+ {
+ double r = Ratios[Math.Clamp((int)Math.Round(v * 15), 0, 15)];
+ return "×" + NotaNum.Str(r, r < 1 ? "0.0#" : "0");
+ }
+ private static int BendRange(float v) => (int)Math.Round(1 + v * 11);
public Control Build(DeviceCardContext ctx)
{
@@ -51,25 +80,26 @@ internal sealed class OperatorInstrumentCard : IInstrumentCard
for (int i = 0; i < pc; i++) idx[engine.PluginParamId(track, -1, i)] = i;
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 SetId(string id, float v) { if (I(id) is var i and >= 0) engine.PluginParamSet(track, -1, i, Math.Clamp(v, 0f, 1f)); }
+ void SetP(string id, float v) { if (I(id) is var i and >= 0) engine.PluginParamSet(track, -1, i, Math.Clamp(v, 0f, 1f)); }
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 AlgoIdx() => Math.Clamp((int)Math.Round(G("algo") * (OperatorTopo.Count - 1)), 0, OperatorTopo.Count - 1);
var readouts = new List<Action>();
- static string NoteName(int m) { string[] n = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; return n[((m % 12) + 12) % 12] + (m / 12 - 1); }
- static TextBlock Mono(string t, IBrush c, double fs = 9) { var tb = new TextBlock { Text = t, FontSize = fs, Foreground = c, VerticalAlignment = VerticalAlignment.Center }; tb.BindResource(TextBlock.FontFamilyProperty, "Font.Mono"); return tb; }
- static TextBlock Cap(string t, IBrush? c = null, double fs = 8) => new() { Text = t, FontSize = fs, FontWeight = FontWeight.Bold, Foreground = c ?? TextTertiary, VerticalAlignment = VerticalAlignment.Center };
+ int tab = 0, railTab = 0, envOp = 3; // Operators · Global · the D carrier
+ var held = new int[8];
+ var specBins = new float[32];
- // ---- viz instances ----
var spectrum = new OperatorSpectrumViz { VerticalAlignment = VerticalAlignment.Stretch };
- var specBins = new float[32];
- var held = new int[8];
var routing = new OperatorRoutingViz { VerticalAlignment = VerticalAlignment.Stretch };
var minis = new OperatorAlgoMini[OperatorTopo.Count];
- var envA = new VoltEnv(engine, track) { Accent = Brass, MinHeight = 40, VerticalAlignment = VerticalAlignment.Stretch };
- var envB = new VoltEnv(engine, track) { Accent = Teal, MinHeight = 40, VerticalAlignment = VerticalAlignment.Stretch };
- int envAop = 3, envBop = 2; // default: D carrier · C modulator
+ var filtCurve = new VoltFilter(engine, track)
+ { VerticalAlignment = VerticalAlignment.Stretch, MinHeight = 60, FreqRange = (60, 18000) };
+ var env = new VoltEnv(engine, track) { MinHeight = 60, VerticalAlignment = VerticalAlignment.Stretch };
+ 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 };
+ meta.BindResource(TextBlock.FontFamilyProperty, "Font.Mono");
Action applyEnv = () => { };
void SyncSpectrum()
@@ -83,245 +113,614 @@ internal sealed class OperatorInstrumentCard : IInstrumentCard
int a = AlgoIdx();
routing.Set(a);
for (int i = 0; i < minis.Length; i++) minis[i].SetActive(i == a);
- envA.Refresh(); envB.Refresh();
+ filtCurve.Target("FILTER", (I("filfreq"), "filfreq"), (I("filreso"), "filreso"), Sel("filtype", 3));
+ env.Refresh();
SyncSpectrum();
foreach (var r in readouts) r();
+ status.Text = Summary();
+ meta.Text = Meta();
}
- routing.AlgoPicked += a => { SetId("algo", a / (float)(OperatorTopo.Count - 1)); Refresh(); };
+ routing.AlgoPicked += a => { SetP("algo", a / (float)(OperatorTopo.Count - 1)); applyEnv(); Refresh(); };
ctx.AddDeviceRefresher(SyncSpectrum);
- // ---- generic building blocks ----------------------------------------
- Control MiniSlider(string label, string id, Func<double, string> fmt, double w)
+ // ---- shared builders --------------------------------------------------
+ static TextBlock Cap(string t, IBrush? c = null) => new()
{
- var row = DeviceCardKit.SliderRow(label, () => G(id), n => { SetId(id, (float)n); Refresh(); }, () => fmt(G(id)), out var sync,
- begin: () => Begin(id), end: () => End(id), trackWidth: w, valueWidth: 22);
- readouts.Add(sync);
- return row;
+ 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)
+ {
+ var tb = new TextBlock { Text = t, FontSize = fs, Foreground = c ?? TextSecondary, VerticalAlignment = VerticalAlignment.Center };
+ tb.FontFamily = NotaFonts.MonoFamily;
+ return tb;
}
- Control Slider(string label, string id, IBrush fillB, Func<double, string>? fmt = null, double labelW = 44)
+
+ Control Knob(string id, string name, Func<float, string> fmt, double size = 34, double cellW = 46, IBrush? arc = null)
+ => InstrumentControls.InstKnob(ctx, idx, id, name, Refresh, fmt, size, cellW, arc);
+
+ // A knob for a table cell: the column header carries the label, so the cell is
+ // just the knob and its value — two lines instead of three.
+ Control TableKnob(string id, string name, Func<float, string> fmt, IBrush? arc = null)
{
- var f = fmt ?? (v => $"{v * 100:0}\u2009%");
- var row = DeviceCardKit.SliderRow(label, () => G(id), n => { SetId(id, (float)n); Refresh(); }, () => f(G(id)), out var sync,
- begin: () => Begin(id), end: () => End(id), labelWidth: labelW, valueWidth: 44);
- readouts.Add(sync);
- return row;
+ 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, VerticalAlignment = VerticalAlignment.Center,
+ };
+ var knob = new Nota.App.Knob(G(id), 1.0)
+ {
+ Accent = true, ArcColor = arc, Default = engine.InstrumentParamDefault(track, pi),
+ Width = NotaSize.KnobSecondary, Height = NotaSize.KnobSecondary, VerticalAlignment = VerticalAlignment.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), name);
+ return new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 4, VerticalAlignment = VerticalAlignment.Center,
+ Children = { knob, value },
+ };
}
- Control Chips(string id, string[] names, double fs = 9)
+
+ Control Chips(string id, string[] names, bool fill = false)
{
int n = names.Length;
- var seg = DeviceCardKit.Segments(names, () => Math.Clamp((int)Math.Round(G(id) * (n - 1)), 0, n - 1), iv => { if (n > 1) { SetId(id, iv / (float)(n - 1)); Refresh(); } }, out var sync);
+ var seg = Segments(names, () => Sel(id, n), iv => { SetP(id, iv / (float)(n - 1)); applyEnv(); Refresh(); }, out var sync, fill: fill);
readouts.Add(sync);
if (I(id) is var pi and >= 0) MidiLearn.Bind(seg, MidiTarget.PluginParam(track, -1, pi), id);
return seg;
}
- Control Toggle(string label, string id, IBrush accent)
+
+ Grid Slider(string label, string id, Func<string> text, double labelW = 54, double valueW = 38)
+ {
+ 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,
+ labelWidth: labelW, valueWidth: valueW);
+ readouts.Add(sync);
+ if (pi >= 0) MidiLearn.Bind(row, MidiTarget.PluginParam(track, -1, pi), id);
+ return row;
+ }
+
+ Control Toggle(string label, string id, Func<string>? live = null)
{
- var host = Switch(label, () => G(id) >= 0.5f, () => { SetId(id, G(id) >= 0.5f ? 0f : 1f); Refresh(); }, out var sync);
+ var host = Switch(label, () => G(id) >= 0.5f, () => { SetP(id, G(id) >= 0.5f ? 0f : 1f); Refresh(); }, out var sync, liveLabel: live);
readouts.Add(sync);
if (I(id) is var pi and >= 0) MidiLearn.Bind(host, MidiTarget.PluginParam(track, -1, pi), label);
return host;
}
- Control DragVal(string id, Func<double, string> fmt, double w)
- {
- var tb = Mono(fmt(G(id)), TextPrimary); tb.Width = w; tb.Cursor = new Cursor(StandardCursorType.SizeNorthSouth); tb.Background = Brushes.Transparent;
- bool drag = false; double startY = 0, startV = 0;
- tb.PointerPressed += (_, e) => { drag = true; startY = e.GetPosition(tb).Y; startV = G(id); Begin(id); e.Pointer.Capture(tb); };
- tb.PointerMoved += (_, e) => { if (drag) { double dv = (startY - e.GetPosition(tb).Y) / 120.0; SetId(id, (float)Math.Clamp(startV + dv, 0, 1)); tb.Text = fmt(G(id)); Refresh(); } };
- tb.PointerReleased += (_, e) => { if (drag) { drag = false; e.Pointer.Capture(null); End(id); } };
- if (I(id) is var mli and >= 0) MidiLearn.Bind(tb, MidiTarget.PluginParam(track, -1, mli), id);
- readouts.Add(() => { if (!drag) tb.Text = fmt(G(id)); });
- return tb;
+
+ // ---- the wheels rail --------------------------------------------------
+ Control Wheel(string id, double def, bool spring, out Func<bool> dragging)
+ {
+ var w = new PerformWheel { Default = def, Spring = spring, VerticalAlignment = VerticalAlignment.Stretch, Norm = G(id) };
+ 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); });
+ dragging = () => w.Dragging;
+ return w;
}
- // ---- OPS view: operator rows ----------------------------------------
- Border OpRow(int op)
+ var bendWheel = Wheel("bend", 0.5, true, out _);
+ var modWheel = Wheel("modwheel", 0, false, out _);
+ var bendVal = Mono("", AccentBright, NotaType.KnobValue);
+ var modVal = Mono("", TextSecondary, NotaType.KnobValue);
+ bendVal.HorizontalAlignment = modVal.HorizontalAlignment = HorizontalAlignment.Center;
+ 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;
+ modVal.Text = NotaNum.Pct(G("modwheel"));
+ modVal.Foreground = G("modwheel") > 1e-3f ? AccentBright : TextSecondary;
+ });
+
+ var wheelPair = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*"), VerticalAlignment = VerticalAlignment.Stretch };
+ bendWheel.HorizontalAlignment = modWheel.HorizontalAlignment = HorizontalAlignment.Center;
+ wheelPair.Children.Add(bendWheel);
+ Grid.SetColumn(modWheel, 1); wheelPair.Children.Add(modWheel);
+
+ var wheelLabels = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*") };
+ var pitchCap = Cap("PITCH"); pitchCap.HorizontalAlignment = HorizontalAlignment.Center;
+ var modCap = Cap("MOD"); modCap.HorizontalAlignment = HorizontalAlignment.Center;
+ wheelLabels.Children.Add(pitchCap);
+ Grid.SetColumn(modCap, 1); wheelLabels.Children.Add(modCap);
+
+ var wheelVals = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*") };
+ wheelVals.Children.Add(bendVal);
+ Grid.SetColumn(modVal, 1); wheelVals.Children.Add(modVal);
+
+ var wheelsGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto,Auto"), RowSpacing = 4, Margin = new Thickness(4, 5) };
+ var wheelsCap = Cap("WHEELS"); wheelsCap.HorizontalAlignment = HorizontalAlignment.Center;
+ wheelsGrid.Children.Add(wheelsCap);
+ Grid.SetRow(wheelPair, 1); wheelsGrid.Children.Add(wheelPair);
+ Grid.SetRow(wheelLabels, 2); wheelsGrid.Children.Add(wheelLabels);
+ Grid.SetRow(wheelVals, 3); wheelsGrid.Children.Add(wheelVals);
+ var wheelsPanel = SectionBox(wheelsGrid);
+ wheelsPanel.Width = WheelsW;
+
+ // ---- Operators tab ----------------------------------------------------
+ // One grid for the whole table — a per-row grid would size its Auto columns on its
+ // own content and the headers would drift off the cells they name.
+ var opsGrid = new Grid
+ {
+ ColumnDefinitions = new ColumnDefinitions("62,Auto,64,64,*"), ColumnSpacing = 6,
+ RowDefinitions = new RowDefinitions("Auto,*,*,*,*"),
+ };
+ void Cell(Control c, int row, int col) { Grid.SetRow(c, row); Grid.SetColumn(c, col); opsGrid.Children.Add(c); }
+
+ var levelHead = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
+ var dbCap = Cap("dB"); Grid.SetColumn(dbCap, 1);
+ levelHead.Children.Add(Cap("LEVEL")); levelHead.Children.Add(dbCap);
+ var headCells = new Control[] { Cap("OP"), Cap("WAVE"), Cap("CRS"), Cap("FINE"), levelHead };
+ for (int c = 0; c < headCells.Length; c++) Cell(headCells[c], 0, c);
+
+ for (int o = 0; o < 4; o++)
+ {
+ int op = o;
string pre = OpId[op];
- var letter = new TextBlock { Text = OperatorTopo.Names[op], FontSize = 9, FontWeight = FontWeight.Bold, Foreground = Teal, Width = 12, VerticalAlignment = VerticalAlignment.Center };
- var role = new TextBlock { FontSize = 8, FontWeight = FontWeight.Bold, Width = 58, VerticalAlignment = VerticalAlignment.Center };
- var wave = Chips(pre + "wave", WaveShort, 8);
- var coarse = DragVal(pre + "coarse", v => { int i = Math.Clamp((int)Math.Round(v * 15), 0, 15); return "×" + Ratios[i].ToString(Ratios[i] < 1 ? "0.0#" : "0"); }, 30);
- var fine = DragVal(pre + "fine", v => { int c = (int)Math.Round((v - 0.5) * 100); return (c >= 0 ? "+" : "") + c; }, 24);
- var accentBar = new Border { Width = 2, Background = Teal };
- string LvlF(double v) => v <= 1e-3 ? "−∞" : $"{20 * Math.Log10(v):0.0}";
- string lid = pre + "level";
- var lvlVal = Mono("", TextPrimary); lvlVal.Width = 44; lvlVal.TextAlignment = TextAlignment.Right;
- var lvlSlot = new SliderTrack();
- lvlSlot.Changed += v => { SetId(lid, (float)v); lvlVal.Text = LvlF(v); Refresh(); };
- lvlSlot.GestureBegin += () => Begin(lid);
- lvlSlot.GestureEnd += () => End(lid);
+ var bar = new Border { Width = 2, Height = 18, CornerRadius = NotaRadius.Bar, VerticalAlignment = VerticalAlignment.Center };
+ var letter = new TextBlock
+ {
+ Text = OperatorTopo.Names[op], FontSize = NotaType.DeviceSection, FontWeight = FontWeight.SemiBold,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
+ var role = new TextBlock
+ {
+ FontSize = NotaType.KnobLabel, FontWeight = FontWeight.Bold, LetterSpacing = NotaType.KnobLabelTracking,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
readouts.Add(() =>
{
var tgt = OperatorTopo.Algo[AlgoIdx()];
- bool carr = tgt[op] == 4;
- role.Text = carr ? "CARRIER" : "MOD → " + OperatorTopo.Names[tgt[op]];
- var rc = carr ? Brass : Teal;
- role.Foreground = rc; letter.Foreground = rc; accentBar.Background = rc;
- if (!lvlSlot.Dragging) { double v = G(lid); lvlSlot.Norm = v; lvlVal.Text = LvlF(v); }
+ bool carrier = tgt[op] == 4;
+ var ink = carrier ? AccentBright : Teal;
+ role.Text = carrier ? "OUT" : "→ " + OperatorTopo.Names[tgt[op]];
+ role.Foreground = ink; letter.Foreground = ink; bar.Background = carrier ? Brass : Teal;
});
- var g = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,Auto,Auto,Auto,*,Auto"), ColumnSpacing = 7, VerticalAlignment = VerticalAlignment.Center };
- var cells = new Control[] { letter, role, wave, coarse, fine, lvlSlot, lvlVal };
- for (int c = 0; c < cells.Length; c++) { Grid.SetColumn(cells[c], c); g.Children.Add(cells[c]); }
- var inner = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(accentBar, Dock.Left); inner.Children.Add(accentBar);
- inner.Children.Add(new Border { Padding = new Thickness(6, 0), Child = g });
- return new Border { Background = NotaPalette.BgApp, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Control, ClipToBounds = true, Height = 34, Child = inner };
+ // A hairline under each row, drawn behind its cells across the full width.
+ if (op > 0)
+ {
+ var rule = new Border { BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(0, 1, 0, 0) };
+ Grid.SetRow(rule, op + 1); Grid.SetColumnSpan(rule, 5); opsGrid.Children.Add(rule);
+ }
+ string lid = pre + "level";
+ Cell(new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 5, VerticalAlignment = VerticalAlignment.Center,
+ Children = { bar, letter, role },
+ }, op + 1, 0);
+ Cell(Chips(pre + "wave", WaveShort), op + 1, 1);
+ Cell(TableKnob(pre + "coarse", OperatorTopo.Names[op] + " Coarse", RatioText), op + 1, 2);
+ Cell(TableKnob(pre + "fine", OperatorTopo.Names[op] + " Fine", Cents, arc: Teal), op + 1, 3);
+ Cell(Slider("", lid, () => Level(G(lid)), labelW: 0, valueW: 42), op + 1, 4);
}
+ var opsBody = new Border { Padding = new Thickness(7, 3), Child = opsGrid };
- var opsHeader = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), Height = 11 };
- var oh1 = Cap("wave · coarse · fine · level"); oh1.HorizontalAlignment = HorizontalAlignment.Right; Grid.SetColumn(oh1, 1);
- opsHeader.Children.Add(Cap("OPERATORS")); opsHeader.Children.Add(oh1);
- var opRows = new StackPanel { Spacing = 3 };
- opRows.Children.Add(opsHeader);
- for (int o = 0; o < 4; o++) opRows.Children.Add(OpRow(o));
- var opsMain = new Border { Padding = new Thickness(8, 6), Child = opRows };
-
- // ---- OPS view: spectrum rail ----------------------------------------
- var specHead = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), Height = 11 };
- var sh1 = Mono("", AccentBright); sh1.HorizontalAlignment = HorizontalAlignment.Right; Grid.SetColumn(sh1, 1);
- specHead.Children.Add(Cap("SPECTRUM")); specHead.Children.Add(sh1);
- readouts.Add(() => { int hn = engine.InstrumentHeldNotes(track, held); sh1.Text = hn > 0 ? NoteName(held[0]) : ""; });
- var velFm = Toggle("VEL → FM", "veltofm", Teal);
- var specDock = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(specHead, Dock.Top); DockPanel.SetDock(velFm, Dock.Bottom);
- specDock.Children.Add(specHead); specDock.Children.Add(velFm); specDock.Children.Add(spectrum);
- var specRail = new Border { Width = 170, Background = Rail, BorderBrush = BorderDef, BorderThickness = new Thickness(1, 0, 0, 0), Padding = new Thickness(8, 6), Child = specDock };
- var opsRow = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(specRail, Dock.Right); opsRow.Children.Add(specRail); opsRow.Children.Add(opsMain);
-
- // ---- ALGO view: picker + routing ------------------------------------
- var pickerGrid = new Grid { VerticalAlignment = VerticalAlignment.Stretch };
- for (int i = 0; i < OperatorTopo.Count; i++) pickerGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
+ // ---- Algorithm tab ----------------------------------------------------
+ // The eleven sketches on one row, then feedback, then the routing diagram — which
+ // needs the height, because the deepest topology stacks four operators.
+ var tiles = new Grid { ColumnSpacing = 4, Height = 56 };
+ for (int i = 0; i < OperatorTopo.Count; i++) tiles.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
for (int i = 0; i < OperatorTopo.Count; i++)
{
- var mini = new OperatorAlgoMini(i) { Margin = new Thickness(1.5, 0) };
- mini.Clicked += a => { SetId("algo", a / (float)(OperatorTopo.Count - 1)); Refresh(); };
- minis[i] = mini; Grid.SetColumn(mini, i); pickerGrid.Children.Add(mini);
+ var mini = new OperatorAlgoMini(i);
+ mini.Clicked += a => { SetP("algo", a / (float)(OperatorTopo.Count - 1)); applyEnv(); Refresh(); };
+ minis[i] = mini;
+ Grid.SetColumn(mini, i); tiles.Children.Add(mini);
}
- var algoDock = new DockPanel { LastChildFill = true };
- var routingBox = new Border { Height = 84, Child = routing };
- DockPanel.SetDock(routingBox, Dock.Bottom); algoDock.Children.Add(routingBox);
- algoDock.Children.Add(new Border { Child = pickerGrid, Margin = new Thickness(0, 0, 0, 5) });
- var algoMain = new Border { Padding = new Thickness(8, 7), Child = algoDock };
+ var fbRow = Slider("FEEDBACK", "feedback", () => NotaNum.Pct(G("feedback")));
- // ---- ALGO view: per-op env rail -------------------------------------
- applyEnv = () =>
+ var algoGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,Auto,*"), RowSpacing = NotaSpace.DeviceGap };
+ algoGrid.Children.Add(tiles);
+ Grid.SetRow(fbRow, 1); algoGrid.Children.Add(fbRow);
+ Grid.SetRow(routing, 2); algoGrid.Children.Add(routing);
+ var algoBody = new Border { Padding = new Thickness(7, 5), Child = algoGrid };
+
+ // ---- Filter · Amp tab -------------------------------------------------
+ var typeRow = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
+ var typeChips = Chips("filtype", FilterNames);
+ typeChips.HorizontalAlignment = HorizontalAlignment.Right;
+ typeRow.Children.Add(Cap("FILTER"));
+ Grid.SetColumn(typeChips, 1); typeRow.Children.Add(typeChips);
+
+ var keyTrkChips = Chips("filkeytrk", KeyTrkNames);
+ var keyTrkCell = new StackPanel
{
- string pa = OpId[envAop], pb = OpId[envBop];
- var tgt = OperatorTopo.Algo[AlgoIdx()];
- string RoleTag(int op) => tgt[op] == 4 ? "carrier" : "mod";
- envA.Target($"{OperatorTopo.Names[envAop]} · {RoleTag(envAop)}", (I(pa + "atk"), pa + "atk"), (I(pa + "dec"), pa + "dec"), (I(pa + "sus"), pa + "sus"), (I(pa + "rel"), pa + "rel"));
- envB.Target($"{OperatorTopo.Names[envBop]} · {RoleTag(envBop)}", (I(pb + "atk"), pb + "atk"), (I(pb + "dec"), pb + "dec"), (I(pb + "sus"), pb + "sus"), (I(pb + "rel"), pb + "rel"));
+ Spacing = 3, VerticalAlignment = VerticalAlignment.Center,
+ Children = { Cap("KEY TRK"), keyTrkChips, Mono("", TextSecondary, NotaType.KnobValue) },
};
- Control EnvSelector(Func<int> get, Action<int> set)
+ var keyTrkVal = (TextBlock)keyTrkCell.Children[2];
+ readouts.Add(() => keyTrkVal.Text = NotaNum.Pct(G("filkeytrk")));
+
+ var filtBottom = new StackPanel
{
- var arr = new Border[4];
- void Hi() { int cur = get(); for (int i = 0; i < 4; i++) { bool on = i == cur; arr[i].Background = on ? NotaPalette.Accent : Brushes.Transparent; ((TextBlock)arr[i].Child!).Foreground = on ? OpColor[i] : TextTertiary; } }
- var row = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 1 };
- for (int i = 0; i < 4; i++)
+ Orientation = Orientation.Horizontal, Spacing = 8, VerticalAlignment = VerticalAlignment.Center,
+ Children = { Knob("volume", "Volume", v => NotaNum.Pct(v), cellW: 44), Knob("glide", "Glide", Glide, cellW: 44), keyTrkCell },
+ };
+ var filtLeft = new StackPanel
+ {
+ Spacing = 6,
+ Children =
+ {
+ typeRow,
+ Slider("FREQ", "filfreq", () => Hz(G("filfreq")), labelW: 32),
+ Slider("RESO", "filreso", () => NotaNum.Pct(G("filreso")), labelW: 32),
+ new Border
+ {
+ BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(0, 1, 0, 0),
+ Padding = new Thickness(0, 4, 0, 0), Child = filtBottom,
+ },
+ },
+ };
+
+ var respHead = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), Height = 11 };
+ var respVal = Mono("", TextSecondary, NotaType.Axis); respVal.HorizontalAlignment = HorizontalAlignment.Right;
+ respHead.Children.Add(Cap("RESPONSE"));
+ Grid.SetColumn(respVal, 1); respHead.Children.Add(respVal);
+ readouts.Add(() => respVal.Text = $"{Hz(G("filfreq"))} · Q {NotaNum.Str(1.0 / Math.Max(0.05, 2.0 - 1.9 * G("filreso")), "0.0")}");
+
+ var specHead = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), Height = 11 };
+ var specNote = Mono("f · 10f · 20f · 30f", NotaPalette.TextAxis, NotaType.Axis); specNote.HorizontalAlignment = HorizontalAlignment.Right;
+ specHead.Children.Add(Cap("SPECTRUM"));
+ Grid.SetColumn(specNote, 1); specHead.Children.Add(specNote);
+
+ var filtRight = new Grid { RowDefinitions = new RowDefinitions("Auto,*,Auto,66"), RowSpacing = 3 };
+ filtRight.Children.Add(respHead);
+ Grid.SetRow(filtCurve, 1); filtRight.Children.Add(filtCurve);
+ Grid.SetRow(specHead, 2); filtRight.Children.Add(specHead);
+ Grid.SetRow(spectrum, 3); filtRight.Children.Add(spectrum);
+
+ var filtGrid = new Grid { ColumnDefinitions = new ColumnDefinitions("160,*"), ColumnSpacing = 9 };
+ filtGrid.Children.Add(filtLeft);
+ Grid.SetColumn(filtRight, 1); filtGrid.Children.Add(filtRight);
+ var filtBody = new Border { Padding = new Thickness(7, 5), Child = filtGrid };
+
+ // ---- the tab strip ----------------------------------------------------
+ var bodies = new Control[] { opsBody, algoBody, filtBody };
+ var tabCells = new Border[TabNames.Length];
+ var tabTexts = new TextBlock[TabNames.Length];
+ var hint = Mono("", TextTertiary, NotaType.Axis);
+ hint.Margin = new Thickness(0, 0, 8, 0);
+ hint.HorizontalAlignment = HorizontalAlignment.Right;
+ var tabRow = new StackPanel { Orientation = Orientation.Horizontal };
+ void ShowTab()
+ {
+ for (int i = 0; i < TabNames.Length; i++)
{
- int iv = i;
- var chip = new Border { CornerRadius = NotaRadius.Clip, Padding = new Thickness(5, 0), Cursor = new Cursor(StandardCursorType.Hand), Child = new TextBlock { Text = OperatorTopo.Names[i], FontSize = 8, FontWeight = FontWeight.Bold, Foreground = TextTertiary } };
- chip.PointerPressed += (_, _) => { set(iv); applyEnv(); Refresh(); };
- arr[i] = chip; row.Children.Add(chip);
+ 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;
}
- readouts.Add(Hi); Hi();
- return new Border { Background = Inset, BorderBrush = BorderDef, BorderThickness = new Thickness(1), CornerRadius = NotaRadius.Control, Padding = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Left, Child = row };
+ hint.Text = TabHints[tab];
+ Refresh();
+ }
+ 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(7, 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 slotA = new DockPanel { LastChildFill = true, Height = 62 };
- var selA = EnvSelector(() => envAop, v => envAop = v); DockPanel.SetDock(selA, Dock.Top); slotA.Children.Add(selA); slotA.Children.Add(envA);
- var slotB = new DockPanel { LastChildFill = true, Height = 62 };
- var selB = EnvSelector(() => envBop, v => envBop = v); DockPanel.SetDock(selB, Dock.Top); slotB.Children.Add(selB); slotB.Children.Add(envB);
- var envStack = new StackPanel { Spacing = 4, Children = { Cap("PER-OP ENV", Teal), slotA, slotB, new Border { Height = 1 }, Slider("KEY→LVL", "keylevel", Teal) } };
- var envRail = new Border { Width = 176, Background = Rail, BorderBrush = BorderDef, BorderThickness = new Thickness(1, 0, 0, 0), Padding = new Thickness(8, 6), Child = envStack };
- var algoRow = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(envRail, Dock.Right); algoRow.Children.Add(envRail); algoRow.Children.Add(algoMain);
-
- // ---- FILTER view ----------------------------------------------------
- var filtCurve = new VoltFilter(engine, track) { VerticalAlignment = VerticalAlignment.Stretch, MinHeight = 90 };
- readouts.Add(() => filtCurve.Target("FILTER", (I("filfreq"), "filfreq"), (I("filreso"), "filreso"), Math.Clamp((int)Math.Round(G("filtype") * 2), 0, 2)));
- var filtLeft = new StackPanel { Spacing = 7, Width = 210, VerticalAlignment = VerticalAlignment.Top, Children =
- {
- Cap("FILTER"), Chips("filtype", new[] { "LP", "HP", "BP" }),
- Slider("FREQ", "filfreq", Brass, v => $"{60 * Math.Pow(300, v):0}\u2009Hz"), Slider("RESO", "filreso", Brass),
- new Border { Height = 6 }, Cap("OUTPUT"), Slider("VOLUME", "volume", Brass),
- } };
- var filtRight = new DockPanel { LastChildFill = true };
- var frHead = Cap("RESPONSE"); DockPanel.SetDock(frHead, Dock.Top); filtRight.Children.Add(frHead); filtRight.Children.Add(filtCurve);
- var filtRow = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(filtLeft, Dock.Left); filtRow.Children.Add(filtLeft);
- filtRow.Children.Add(new Border { Padding = new Thickness(12, 0, 0, 0), Child = filtRight });
- var filtMain = new Border { Padding = new Thickness(8, 6), Child = filtRow };
-
- // ---- contextual strips ----------------------------------------------
- Control LiveStrip()
- {
- var host = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12, VerticalAlignment = VerticalAlignment.Center, Children =
+ var tabStrip = new Grid { Height = TabH, ColumnDefinitions = new ColumnDefinitions("Auto,*") };
+ tabStrip.Children.Add(tabRow);
+ Grid.SetColumn(hint, 1); tabStrip.Children.Add(hint);
+
+ var tabHost = new Panel();
+ 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 bendChips = Segments(BendNames, () => NearestExact(G("bendrange"), BendStops),
+ iv => { SetP("bendrange", BendStops[iv]); Refresh(); }, out var bendSync);
+ readouts.Add(bendSync);
+ if (I("bendrange") is var bri and >= 0) MidiLearn.Bind(bendChips, MidiTarget.PluginParam(track, -1, bri), "Bend Range");
+ var bendRow = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
+ bendChips.HorizontalAlignment = HorizontalAlignment.Right;
+ bendRow.Children.Add(Cap("BEND"));
+ Grid.SetColumn(bendChips, 1); bendRow.Children.Add(bendChips);
+
+ var modeRow = new StackPanel
+ {
+ Orientation = Orientation.Horizontal, Spacing = 12, VerticalAlignment = VerticalAlignment.Center,
+ Children = { Toggle("Mono", "mono"), Toggle("Vel → FM", "veltofm", () => G("veltofm") >= 0.5f ? $"Vel → FM {NotaNum.Pct(G("veltofm"))}" : "Vel → FM off") },
+ };
+
+ 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,*"), VerticalAlignment = VerticalAlignment.Stretch };
+ globalBottom.Children.Add(Knob("volume", "Volume", v => NotaNum.Pct(v), size: NotaSize.KnobMain, cellW: 52));
+ Grid.SetColumn(meterBlock, 1); globalBottom.Children.Add(meterBlock);
+
+ var globalTop = new StackPanel
+ {
+ Spacing = 6, Margin = new Thickness(8, 6, 8, 0),
+ Children =
{
- Cap("LIVE", TextTertiary),
- MiniSlider("FM", "fmdepth", v => $"{v * 200:0}\u2009%", 46),
- MiniSlider("FEEDBACK", "feedback", v => $"{v * 100:0}\u2009%", 40),
- MiniSlider("TONE", "filfreq", v => $"{60 * Math.Pow(300, v):0}", 42),
- MiniSlider("GLIDE", "glide", v => v <= 0 ? "off" : $"{5 * Math.Pow(240, v):0}\u2009ms", 42),
- } };
- var mode = Toggle("MONO", "mono", Brass); mode.HorizontalAlignment = HorizontalAlignment.Right;
- var wrap = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
- Grid.SetColumn(mode, 1); wrap.Children.Add(host); wrap.Children.Add(mode);
- return new Border { Height = 34, Background = Strip, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(9, 0), Child = wrap };
+ Slider("FM", "fmdepth", () => NotaNum.Pct(G("fmdepth") * 2)),
+ Slider("FEEDBACK", "feedback", () => NotaNum.Pct(G("feedback"))),
+ Slider("TONE", "filfreq", () => Hz(G("filfreq"))),
+ Slider("GLIDE", "glide", () => Glide(G("glide"))),
+ bendRow,
+ modeRow,
+ },
+ };
+ 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, 6, 8, 6), Padding = new Thickness(0, 5, 0, 0), Child = globalBottom,
+ };
+ Grid.SetRow(globalBottomFrame, 1); globalGrid.Children.Add(globalBottomFrame);
+
+ // ---- rail · Env -------------------------------------------------------
+ var opCells = new Border[4];
+ var opTexts = new TextBlock[4];
+ var opPick = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 1 };
+ for (int i = 0; i < 4; i++)
+ {
+ int iv = i;
+ var tb = new TextBlock { Text = OperatorTopo.Names[i], FontSize = NotaType.DeviceSection, VerticalAlignment = VerticalAlignment.Center };
+ var chip = new Border
+ {
+ CornerRadius = NotaRadius.Badge, Padding = new Thickness(6, 1), Cursor = new Cursor(StandardCursorType.Hand),
+ Background = Brushes.Transparent, Child = tb,
+ };
+ chip.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(chip).Properties.IsLeftButtonPressed) return;
+ envOp = iv; applyEnv(); Refresh(); e.Handled = true;
+ };
+ opCells[i] = chip; opTexts[i] = tb; opPick.Children.Add(chip);
}
- Control AlgoStrip()
- {
- var num = Mono("", AccentBright); num.Margin = new Thickness(4, 0, 0, 0);
- var desc = Cap("", TextTertiary); desc.Margin = new Thickness(8, 0, 0, 0);
- readouts.Add(() => { int a = AlgoIdx(); num.Text = $"{a + 1} of {OperatorTopo.Count}"; desc.Text = OperatorTopo.Desc[a]; });
- var host = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 0, VerticalAlignment = VerticalAlignment.Center, Children = { Cap("ALGORITHM", TextTertiary), num, desc } };
- var fbSlider = MiniSlider("FEEDBACK", "feedback", v => $"{v * 100:0}\u2009%", 46); fbSlider.HorizontalAlignment = HorizontalAlignment.Right;
- var wrap = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
- Grid.SetColumn(fbSlider, 1); wrap.Children.Add(host); wrap.Children.Add(fbSlider);
- return new Border { Height = 34, Background = Strip, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Padding = new Thickness(9, 0), Child = wrap };
+ var opPickHost = new Border
+ {
+ Background = NotaPalette.BgSunken, BorderBrush = BorderDef, BorderThickness = new Thickness(1),
+ CornerRadius = NotaRadius.Control, Padding = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Right,
+ Child = opPick,
+ };
+ var envRoleText = Mono("", TextSecondary, NotaType.Axis);
+ var envPickRow = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 6 };
+ envPickRow.Children.Add(envRoleText);
+ Grid.SetColumn(opPickHost, 1); envPickRow.Children.Add(opPickHost);
+
+ var envStages = new Grid { ColumnDefinitions = new ColumnDefinitions("*,*,*,*") };
+ var envKnobHosts = new Panel[4];
+ for (int i = 0; i < 4; i++) { envKnobHosts[i] = new Panel(); Grid.SetColumn(envKnobHosts[i], i); envStages.Children.Add(envKnobHosts[i]); }
+ // The four ADSR knobs belong to whichever operator is selected, so they are rebuilt
+ // per operator once and swapped — a knob is bound to one param index for its life.
+ var stageCells = new Control[4, 4];
+ string[] stageIds = { "atk", "dec", "sus", "rel" };
+ string[] stageNames = { "Attack", "Decay", "Sustain", "Release" };
+ for (int o = 0; o < 4; o++)
+ {
+ for (int s = 0; s < 4; s++)
+ {
+ string id = OpId[o] + stageIds[s];
+ Func<float, string> fmt = s switch
+ {
+ 0 => v => Secs(v, 0.001, 4.0),
+ 1 => v => Secs(v, 0.002, 6.0),
+ 2 => v => Level(v),
+ _ => v => Secs(v, 0.002, 8.0),
+ };
+ stageCells[o, s] = Knob(id, stageNames[s], fmt, cellW: 40);
+ stageCells[o, s].IsVisible = false;
+ envKnobHosts[s].Children.Add(stageCells[o, s]);
+ }
}
- // ---- assemble: strip host + tab rail + swapping body ----------------
- var strips = new Control[] { LiveStrip(), AlgoStrip(), LiveStrip() };
- var mains = new Control[] { opsRow, algoRow, filtMain };
- var stripHost = new ContentControl();
- var mainHost = new ContentControl();
+ applyEnv = () =>
+ {
+ string p = OpId[envOp];
+ var tgt = OperatorTopo.Algo[AlgoIdx()];
+ bool carrier = tgt[envOp] == 4;
+ env.Accent = carrier ? AccentBright : Teal;
+ env.Target($"{OperatorTopo.Names[envOp]} ENV",
+ (I(p + "atk"), p + "atk"), (I(p + "dec"), p + "dec"), (I(p + "sus"), p + "sus"), (I(p + "rel"), p + "rel"));
+ envRoleText.Text = carrier ? "carrier → out" : "mod → " + OperatorTopo.Names[tgt[envOp]];
+ envRoleText.Foreground = carrier ? AccentBright : Teal;
+ for (int o = 0; o < 4; o++)
+ for (int s = 0; s < 4; s++) stageCells[o, s].IsVisible = o == envOp;
+ for (int i = 0; i < 4; i++)
+ {
+ bool on = i == envOp;
+ bool carr = tgt[i] == 4;
+ opCells[i].Background = on ? (carr ? Brass : Teal) : Brushes.Transparent;
+ opTexts[i].Foreground = on ? OnAccent : carr ? AccentBright : Teal;
+ opTexts[i].FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal;
+ }
+ };
+ readouts.Add(() => applyEnv());
- string[] tabNames = { "OPS", "ALGO", "FILTER" };
- var tabBtns = new Border[3];
- void SelectTab(int t)
+ var envGrid = new Grid
{
- stripHost.Content = strips[t];
- mainHost.Content = mains[t];
- for (int i = 0; i < 3; i++)
+ RowDefinitions = new RowDefinitions("Auto,*,Auto,Auto,Auto"), RowSpacing = 5, Margin = new Thickness(8, 6),
+ };
+ var envRows = new Control[]
+ {
+ envPickRow, env, envStages,
+ Slider("KEY→LVL", "keylevel", () => NotaNum.Pct(G("keylevel"))),
+ Slider("VEL→LVL", "veltolevel", () => NotaNum.Pct(G("veltolevel"))),
+ };
+ for (int i = 0; i < envRows.Length; i++) { Grid.SetRow(envRows[i], i); envGrid.Children.Add(envRows[i]); }
+
+ // ---- the rail's own two tabs ------------------------------------------
+ var railBodies = new Control[] { globalGrid, envGrid };
+ var railCells = new Border[RailTabs.Length];
+ var railTexts = new TextBlock[RailTabs.Length];
+ var railTabGrid = new Grid { Height = TabH, ColumnDefinitions = new ColumnDefinitions("*,*") };
+ void ShowRailTab()
+ {
+ for (int i = 0; i < RailTabs.Length; i++)
{
- bool on = i == t;
- tabBtns[i].Background = on ? AccentSubtleB : Brushes.Transparent;
- tabBtns[i].BorderBrush = on ? Brass : Brushes.Transparent;
- ((TextBlock)tabBtns[i].Child!).Foreground = on ? AccentBright : TextTertiary;
+ bool on = i == railTab;
+ railCells[i].Background = on ? NotaPalette.SurfaceRaised : Brushes.Transparent;
+ railCells[i].BorderBrush = on ? Brass : Brushes.Transparent;
+ railTexts[i].Foreground = on ? AccentBright : TextTertiary;
+ railTexts[i].FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal;
+ railBodies[i].IsVisible = on;
}
- if (t == 1) applyEnv();
Refresh();
}
- var railStack = new StackPanel { Spacing = 3 };
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < RailTabs.Length; i++)
{
int iv = i;
- var b = new Border { Height = 22, CornerRadius = NotaRadius.Control, BorderThickness = new Thickness(2, 0, 0, 0), Padding = new Thickness(8, 0), Cursor = new Cursor(StandardCursorType.Hand), Child = new TextBlock { Text = tabNames[i], FontSize = 9, FontWeight = FontWeight.SemiBold, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center } };
- b.PointerPressed += (_, _) => SelectTab(iv);
- tabBtns[i] = b; railStack.Children.Add(b);
+ var tb = new TextBlock
+ {
+ Text = RailTabs[i], FontSize = NotaType.DeviceSection,
+ HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center,
+ };
+ var cell = new Border
+ {
+ BorderThickness = new Thickness(0, 0, 0, 2), Cursor = new Cursor(StandardCursorType.Hand), Child = tb,
+ };
+ cell.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(cell).Properties.IsLeftButtonPressed) return;
+ railTab = iv; ShowRailTab(); e.Handled = true;
+ };
+ railCells[i] = cell; railTexts[i] = tb;
+ Grid.SetColumn(cell, i); railTabGrid.Children.Add(cell);
}
- var rail = new Border { Width = 70, Background = Rail, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 1, 0), Padding = new Thickness(5), Child = railStack };
+ var railHost = new Panel();
+ foreach (var b in railBodies) railHost.Children.Add(b);
+ var railGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };
+ railGrid.Children.Add(HeaderStrip(railTabGrid));
+ Grid.SetRow(railHost, 1); railGrid.Children.Add(railHost);
+ var rail = SectionBox(railGrid);
+ rail.Width = RailW;
+
+ // ---- status strip -----------------------------------------------------
+ string Chain()
+ {
+ var tgt = OperatorTopo.Algo[AlgoIdx()];
+ var parts = new List<string>();
+ for (int o = 0; o < 4; o++) parts.Add(tgt[o] == 4 ? $"{OperatorTopo.Names[o]}→out" : $"{OperatorTopo.Names[o]}→{OperatorTopo.Names[tgt[o]]}");
+ return string.Join(" · ", parts);
+ }
+ string Summary() => tab switch
+ {
+ 0 => Chain(),
+ 1 => $"Algo {AlgoIdx() + 1} of {OperatorTopo.Count} · {OperatorTopo.Desc[AlgoIdx()]} · feedback {NotaNum.Pct(G("feedback"))}",
+ _ => $"Filter {FilterNames[Sel("filtype", 3)]} · {Hz(G("filfreq"))} · reso {NotaNum.Pct(G("filreso"))} · key track {NotaNum.Pct(G("filkeytrk"))}",
+ };
+ string Meta()
+ {
+ string mode = G("mono") >= 0.5f ? "MONO" : "POLY 12";
+ return $"ALGO {AlgoIdx() + 1} · FM {NotaNum.Pct(G("fmdepth") * 2)} · {mode} · {NotaNum.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,
+ };
- var bodyRow = new DockPanel { LastChildFill = true };
- DockPanel.SetDock(rail, Dock.Left); bodyRow.Children.Add(rail); bodyRow.Children.Add(mainHost);
- var root = new DockPanel { LastChildFill = true, Background = NotaPalette.BgApp };
- DockPanel.SetDock(stripHost, Dock.Top); root.Children.Add(stripHost); root.Children.Add(bodyRow);
+ // ---- 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);
applyEnv();
- SelectTab(0);
+ ShowRailTab();
+ ShowTab();
return root;
}
+
+ public string? VoiceLabel(IAudioEngine engine, int trackId, int active)
+ {
+ int i = -1, pc = engine.PluginParamCount(trackId, -1);
+ for (int k = 0; k < pc; k++) if (engine.PluginParamId(trackId, -1, k) == "mono") { i = k; break; }
+ if (i < 0) return null;
+ return engine.PluginParamGet(trackId, -1, i) >= 0.5f ? $"{Math.Min(active, 1)}/1" : null;
+ }
+
+ // 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.cs
index 138ce0d2..043d6666 100644
--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs
@@ -145,27 +145,113 @@ public sealed class FactoryPresetCatalog : IFactoryPresets
Inst("pendulum", 8, "Down Runs", ("balls", 0.4f), ("rate", 0.75f), ("sync", 1f), ("division", 0.25f), ("motion", 0f), ("quantize", 1f), ("chordsort", 1f), ("spread", 0.2f), ("notelen", 0.4f), ("tone", 0.48f), ("attack", 0.1f), ("decay", 0.4f), ("release", 0.4f), ("detune", 0.3f), ("volume", 0.8f), ("panspread", 0.3f));
Inst("pendulum", 8, "Glass Bounce", ("balls", 0.8f), ("rate", 0.8f), ("sync", 1f), ("division", 0.5f), ("motion", 1f), ("quantize", 0.5f), ("spread", 0.35f), ("notelen", 0.2f), ("tone", 0.7f), ("attack", 0.02f), ("decay", 0.35f), ("release", 0.35f), ("detune", 0.2f), ("volume", 0.8f), ("wave", 0.25f), ("bright", 0.8f), ("fm", 0.15f), ("panspread", 0.6f), ("humanize", 0.25f));
- // ---- Nota Operator (kind 9) — 4-op FM. Coarse ≈ ratio (0.0667≈1:1); Level = carrier
- // amp or modulator index; Algo 0..1 = 11 algorithms (index = round(v*10)); Wave 0 Sine/.33 Tri/.67 Saw/1 Sqr.
- Inst("operator", 9, "E-Piano", ("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.4f), ("cdec", 0.5f),
- ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.55f), ("dsus", 0.55f), ("drel", 0.35f),
- ("filfreq", 0.85f), ("volume", 0.8f));
- Inst("operator", 9, "FM Bell", ("algo", 0.4f), ("ccoarse", 0.2f), ("clevel", 0.7f), ("cdec", 0.3f),
- ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.25f), ("dsus", 0f), ("drel", 0.5f),
- ("feedback", 0.2f), ("filfreq", 1f), ("volume", 0.78f));
- Inst("operator", 9, "FM Bass", ("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.6f), ("cdec", 0.3f), ("csus", 0.2f),
- ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.4f), ("dsus", 0.7f), ("drel", 0.2f),
- ("mono", 1f), ("glide", 0.35f), ("filfreq", 0.5f), ("filreso", 0.2f), ("volume", 0.85f));
- Inst("operator", 9, "Bright Lead",("algo", 0.3f), ("bcoarse", 0.133f), ("blevel", 0.5f), ("ccoarse", 0.0667f), ("clevel", 0.55f),
- ("dcoarse", 0.0667f), ("dlevel", 1f), ("dsus", 0.8f), ("drel", 0.25f),
- ("veltofm", 0.8f), ("feedback", 0.35f), ("filfreq", 0.9f), ("volume", 0.78f));
- Inst("operator", 9, "Glass Pad", ("algo", 1f), ("acoarse", 0.2f), ("alevel", 0.4f), ("bcoarse", 0.133f), ("blevel", 0.4f),
- ("ccoarse", 0.0667f), ("clevel", 0.6f), ("dcoarse", 0.0667f), ("dlevel", 0.7f),
- ("aatk", 0.4f), ("batk", 0.4f), ("catk", 0.35f), ("datk", 0.4f), ("dsus", 0.8f), ("drel", 0.6f),
- ("filfreq", 0.75f), ("volume", 0.75f));
- Inst("operator", 9, "Clav", ("algo", 0f), ("ccoarse", 0.133f), ("clevel", 0.65f), ("cdec", 0.35f), ("csus", 0.1f),
- ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.3f), ("dsus", 0.2f), ("drel", 0.2f),
- ("feedback", 0.15f), ("filfreq", 0.8f), ("volume", 0.82f));
+ // ---- Nota Operator (kind 9) — 4-op FM, 25 patches across keys, bells, basses,
+ // leads, pads and percussion. Coarse = ratio index / 15 (0 ×0.5 · .0667 ×1 ·
+ // .1333 ×2 · .2 ×3 · .2667 ×4 · .3333 ×5 · .4 ×6 · .4667 ×7 · .5333 ×8 ·
+ // .9333 ×14); Fine is neutral at 0.5. Algo 0..1 = the 11 topologies
+ // (index = round(v*10)); Wave 0 Sine / .33 Tri / .67 Saw / 1 Sqr. A modulator's
+ // Level is its FM index, a carrier's is its amplitude.
+ // Keys
+ Inst("operator", 9, "E-Piano", ("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.4f), ("cdec", 0.5f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.55f), ("dsus", 0.55f), ("drel", 0.35f),
+ ("filfreq", 0.85f), ("keylevel", 0.25f), ("volume", 0.8f));
+ Inst("operator", 9, "Tine Keys", ("algo", 0.2f), ("bcoarse", 0.0667f), ("blevel", 0.5f), ("bdec", 0.45f), ("bsus", 0.1f),
+ ("ccoarse", 0.9333f), ("clevel", 0.12f), ("cdec", 0.12f), ("csus", 0f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.6f), ("dsus", 0.35f), ("drel", 0.4f),
+ ("veltofm", 0.6f), ("keylevel", 0.3f), ("filfreq", 0.88f), ("volume", 0.8f));
+ Inst("operator", 9, "Wurly", ("algo", 0f), ("ccoarse", 0.2f), ("clevel", 0.5f), ("cdec", 0.28f), ("csus", 0.05f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.55f), ("dsus", 0.3f), ("drel", 0.3f),
+ ("feedback", 0.12f), ("veltofm", 0.7f), ("filfreq", 0.72f), ("volume", 0.82f));
+ Inst("operator", 9, "Clav", ("algo", 0f), ("ccoarse", 0.133f), ("clevel", 0.65f), ("cdec", 0.35f), ("csus", 0.1f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.3f), ("dsus", 0.2f), ("drel", 0.2f),
+ ("feedback", 0.15f), ("filfreq", 0.8f), ("filkeytrk", 0.5f), ("volume", 0.82f));
+ Inst("operator", 9, "Harpsichord", ("algo", 0f), ("ccoarse", 0.1333f), ("clevel", 0.55f), ("cdec", 0.25f), ("csus", 0.05f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.35f), ("dsus", 0f), ("drel", 0.18f),
+ ("feedback", 0.1f), ("veltolevel", 0.3f), ("filfreq", 0.9f), ("volume", 0.8f));
+ // Bells and mallets
+ Inst("operator", 9, "FM Bell", ("algo", 0.4f), ("ccoarse", 0.2f), ("clevel", 0.7f), ("cdec", 0.3f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.25f), ("dsus", 0f), ("drel", 0.5f),
+ ("feedback", 0.2f), ("filfreq", 1f), ("volume", 0.78f));
+ Inst("operator", 9, "Tubular Bell", ("algo", 0.3f), ("acoarse", 0.2667f), ("alevel", 0.3f), ("adec", 0.4f), ("asus", 0f),
+ ("bcoarse", 0.4667f), ("blevel", 0.5f), ("bdec", 0.35f), ("bsus", 0f),
+ ("ccoarse", 0.1333f), ("clevel", 0.4f), ("cdec", 0.85f), ("csus", 0f), ("crel", 0.7f),
+ ("dcoarse", 0.0667f), ("dlevel", 0.9f), ("ddec", 0.9f), ("dsus", 0f), ("drel", 0.75f),
+ ("filfreq", 1f), ("volume", 0.74f));
+ Inst("operator", 9, "Music Box", ("algo", 0.5f), ("acoarse", 0.9333f), ("alevel", 0.25f), ("adec", 0.12f), ("asus", 0f),
+ ("bcoarse", 0.0667f), ("blevel", 0.55f), ("bdec", 0.6f), ("bsus", 0f), ("brel", 0.5f),
+ ("ccoarse", 0.2f), ("clevel", 0.2f), ("cdec", 0.15f), ("csus", 0f),
+ ("dcoarse", 0.1333f), ("dlevel", 0.7f), ("ddec", 0.65f), ("dsus", 0f), ("drel", 0.55f),
+ ("filfreq", 1f), ("volume", 0.72f));
+ Inst("operator", 9, "Marimba", ("algo", 0f), ("ccoarse", 0.2667f), ("clevel", 0.45f), ("cdec", 0.14f), ("csus", 0f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.42f), ("dsus", 0f), ("drel", 0.3f),
+ ("veltofm", 0.5f), ("filfreq", 0.8f), ("volume", 0.82f));
+ Inst("operator", 9, "Kalimba", ("algo", 0f), ("ccoarse", 0.4f), ("clevel", 0.35f), ("cdec", 0.1f), ("csus", 0f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.38f), ("dsus", 0f), ("drel", 0.3f),
+ ("keylevel", 0.4f), ("filfreq", 0.85f), ("volume", 0.8f));
+ // Basses
+ Inst("operator", 9, "FM Bass", ("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.6f), ("cdec", 0.3f), ("csus", 0.2f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.4f), ("dsus", 0.7f), ("drel", 0.2f),
+ ("mono", 1f), ("glide", 0.35f), ("filfreq", 0.5f), ("filreso", 0.2f), ("volume", 0.85f));
+ Inst("operator", 9, "Slap Bass", ("algo", 0.2f), ("bcoarse", 0.0667f), ("blevel", 0.55f), ("bdec", 0.3f), ("bsus", 0.15f),
+ ("ccoarse", 0.4667f), ("clevel", 0.2f), ("cdec", 0.1f), ("csus", 0f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.4f), ("dsus", 0.4f), ("drel", 0.2f),
+ ("mono", 1f), ("veltofm", 0.8f), ("filfreq", 0.6f), ("filreso", 0.2f), ("volume", 0.85f));
+ Inst("operator", 9, "Sub Sine", ("algo", 1f), ("alevel", 0f), ("blevel", 0f), ("clevel", 0f),
+ ("dcoarse", 0f), ("dlevel", 1f), ("ddec", 0.5f), ("dsus", 0.85f), ("drel", 0.25f),
+ ("mono", 1f), ("glide", 0.2f), ("filfreq", 0.4f), ("volume", 0.88f));
+ Inst("operator", 9, "Growl Bass", ("algo", 0.4f), ("acoarse", 0.0667f), ("alevel", 0.35f), ("adec", 0.4f), ("asus", 0.3f),
+ ("bcoarse", 0.1333f), ("blevel", 0.3f), ("bdec", 0.35f), ("bsus", 0.2f),
+ ("ccoarse", 0.2f), ("clevel", 0.25f), ("cdec", 0.3f), ("csus", 0.15f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("ddec", 0.45f), ("dsus", 0.6f), ("drel", 0.25f),
+ ("feedback", 0.3f), ("mono", 1f), ("filfreq", 0.5f), ("filreso", 0.3f), ("volume", 0.84f));
+ // Leads
+ Inst("operator", 9, "Bright Lead", ("algo", 0.3f), ("bcoarse", 0.133f), ("blevel", 0.5f), ("ccoarse", 0.0667f), ("clevel", 0.55f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("dsus", 0.8f), ("drel", 0.25f),
+ ("veltofm", 0.8f), ("feedback", 0.35f), ("filfreq", 0.9f), ("volume", 0.78f));
+ Inst("operator", 9, "Reed Lead", ("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.5f), ("catk", 0.12f), ("cdec", 0.4f), ("csus", 0.5f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("datk", 0.06f), ("dsus", 0.85f), ("drel", 0.25f),
+ ("mono", 1f), ("glide", 0.12f), ("veltofm", 0.5f), ("bendrange", 0.0909f),
+ ("filfreq", 0.78f), ("volume", 0.8f));
+ Inst("operator", 9, "Metal Lead", ("algo", 0.4f), ("acoarse", 0.5333f), ("alevel", 0.22f), ("adec", 0.5f), ("asus", 0.6f),
+ ("bcoarse", 0.2f), ("blevel", 0.3f), ("bdec", 0.45f), ("bsus", 0.5f),
+ ("ccoarse", 0.1333f), ("clevel", 0.35f), ("cdec", 0.45f), ("csus", 0.6f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("dsus", 0.8f), ("drel", 0.25f),
+ ("feedback", 0.4f), ("mono", 1f), ("bendrange", 0.3636f), ("filfreq", 0.85f), ("volume", 0.76f));
+ Inst("operator", 9, "Whistle", ("algo", 1f), ("alevel", 0f), ("blevel", 0f), ("clevel", 0f),
+ ("dcoarse", 0.1333f), ("dlevel", 1f), ("datk", 0.25f), ("ddec", 0.5f), ("dsus", 0.9f), ("drel", 0.3f),
+ ("mono", 1f), ("glide", 0.15f), ("filfreq", 0.95f), ("volume", 0.74f));
+ // Pads and strings
+ Inst("operator", 9, "Glass Pad", ("algo", 1f), ("acoarse", 0.2f), ("alevel", 0.4f), ("bcoarse", 0.133f), ("blevel", 0.4f),
+ ("ccoarse", 0.0667f), ("clevel", 0.6f), ("dcoarse", 0.0667f), ("dlevel", 0.7f),
+ ("aatk", 0.4f), ("batk", 0.4f), ("catk", 0.35f), ("datk", 0.4f), ("dsus", 0.8f), ("drel", 0.6f),
+ ("filfreq", 0.75f), ("volume", 0.75f));
+ Inst("operator", 9, "Air Pad", ("algo", 0.9f), ("acoarse", 0.4667f), ("alevel", 0.18f), ("aatk", 0.5f), ("adec", 0.6f), ("asus", 0.5f), ("arel", 0.7f),
+ ("bcoarse", 0.0667f), ("blevel", 0.5f), ("batk", 0.55f), ("bsus", 0.85f), ("brel", 0.75f),
+ ("ccoarse", 0.1333f), ("clevel", 0.4f), ("catk", 0.5f), ("csus", 0.8f), ("crel", 0.72f),
+ ("dcoarse", 0.0667f), ("dlevel", 0.7f), ("datk", 0.6f), ("dsus", 0.9f), ("drel", 0.8f),
+ ("filfreq", 0.8f), ("filkeytrk", 0.5f), ("volume", 0.72f));
+ Inst("operator", 9, "Choir Pad", ("algo", 0.6f), ("acoarse", 0.0667f), ("alevel", 0.2f), ("aatk", 0.45f), ("asus", 0.6f), ("arel", 0.6f),
+ ("bcoarse", 0.0667f), ("bfine", 0.56f), ("blevel", 0.5f), ("batk", 0.5f), ("bsus", 0.85f), ("brel", 0.7f),
+ ("ccoarse", 0.1333f), ("clevel", 0.35f), ("catk", 0.5f), ("csus", 0.8f), ("crel", 0.7f),
+ ("dcoarse", 0.0667f), ("dfine", 0.45f), ("dlevel", 0.8f), ("datk", 0.5f), ("dsus", 0.9f), ("drel", 0.75f),
+ ("filfreq", 0.7f), ("volume", 0.74f));
+ Inst("operator", 9, "Warm Strings", ("algo", 0.5f), ("acoarse", 0.0667f), ("alevel", 0.3f), ("aatk", 0.35f), ("asus", 0.6f), ("arel", 0.6f),
+ ("bcoarse", 0.0667f), ("bfine", 0.54f), ("blevel", 0.7f), ("batk", 0.4f), ("bsus", 0.9f), ("brel", 0.7f),
+ ("ccoarse", 0.0667f), ("clevel", 0.28f), ("catk", 0.35f), ("csus", 0.6f), ("crel", 0.6f),
+ ("dcoarse", 0.0667f), ("dfine", 0.46f), ("dlevel", 0.7f), ("datk", 0.42f), ("dsus", 0.9f), ("drel", 0.72f),
+ ("filfreq", 0.66f), ("volume", 0.72f));
+ // Brass, organ, percussion
+ Inst("operator", 9, "Brass Section",("algo", 0f), ("ccoarse", 0.0667f), ("clevel", 0.6f), ("catk", 0.2f), ("cdec", 0.4f), ("csus", 0.55f),
+ ("dcoarse", 0.0667f), ("dlevel", 1f), ("datk", 0.14f), ("dsus", 0.85f), ("drel", 0.3f),
+ ("veltofm", 0.85f), ("filfreq", 0.7f), ("volume", 0.8f));
+ Inst("operator", 9, "Drawbar Organ",("algo", 1f), ("acoarse", 0.0667f), ("alevel", 0.5f), ("aatk", 0f), ("adec", 0f), ("asus", 1f), ("arel", 0.12f),
+ ("bcoarse", 0.1333f), ("blevel", 0.35f), ("batk", 0f), ("bdec", 0f), ("bsus", 1f), ("brel", 0.12f),
+ ("ccoarse", 0.2f), ("clevel", 0.22f), ("catk", 0f), ("cdec", 0f), ("csus", 1f), ("crel", 0.12f),
+ ("dcoarse", 0.2667f), ("dlevel", 0.6f), ("datk", 0f), ("ddec", 0f), ("dsus", 1f), ("drel", 0.12f),
+ ("veltolevel", 0.2f), ("filfreq", 0.8f), ("volume", 0.76f));
+ Inst("operator", 9, "Log Drum", ("algo", 0f), ("ccoarse", 0.1333f), ("clevel", 0.6f), ("cdec", 0.08f), ("csus", 0f),
+ ("dcoarse", 0f), ("dlevel", 1f), ("ddec", 0.3f), ("dsus", 0f), ("drel", 0.22f),
+ ("veltofm", 0.6f), ("filfreq", 0.55f), ("volume", 0.85f));
// ---- Nota Grain (kind 10) — granular. Scan Mode 0 Scan/.5 Freeze/1 Key; Coarse 0.5 = 0 st
// (±24); presets shape the built-in default sample (drop your own to replace).
diff --git a/src/native/nota.engine/src/OperatorSynth.h b/src/native/nota.engine/src/OperatorSynth.h
index 542789df..c2292f55 100644
--- a/src/native/nota.engine/src/OperatorSynth.h
+++ b/src/native/nota.engine/src/OperatorSynth.h
@@ -6,7 +6,9 @@
// coarse/fine frequency ratio, output level, waveform and ADSR envelope. Eight feed-
// forward algorithms route who modulates whom (chains, stacks, parallel/additive), with
// self-feedback on operator A. The summed carriers pass a subtractive TPT filter
-// (LP/HP/BP) before the master volume — FM timbre + classic filter sculpting in one.
+// (LP/HP/BP, with optional keyboard tracking) before the master volume — FM timbre +
+// classic filter sculpting in one. Two performance wheels ride on top: pitch bend (range
+// 1..12 semitones) and a mod wheel on the modulation index.
//
// A ─┐ (per algorithm) modulators bend the phase of their target;
// B ─┼─▶ [algo] ─▶ carriers ─▶ filter ─▶ volume ─▶ out
@@ -49,6 +51,12 @@ public:
VelToFm, // velocity → FM depth amount (0 = off, classic FM dynamics)
KeyLevel, // keyboard tracking of modulator level (0 = off; higher notes → less FM)
Mono, // voice mode: <0.5 poly, ≥0.5 monophonic (legato with glide)
+ // --- appended for the almanac rework (old projects default these to neutral) ---
+ Bend, // pitch-bend wheel, 0.5 = centre (the card's left Wheels rail)
+ BendRange, // bend range in semitones: 1 + v*11, rounded (default ±2 st)
+ ModWheel, // mod wheel 0..1 — the classic FM hand control: more modulation index
+ FilKeyTrk, // filter cutoff keyboard tracking: 0 / ½ / 1 octave per octave
+ VelToLevel, // velocity → output level (1 = the classic behaviour, 0 = flat)
kNumParams
};
static constexpr int kNumAlgos = 11;
@@ -73,6 +81,10 @@ public:
set(Volume, 0.8f);
set(FmDepth, 0.5f); // ×1 — identical to the pre-macro fixed depth
set(Glide, 0.0f); set(VelToFm, 0.0f); set(KeyLevel, 0.0f); set(Mono, 0.0f);
+ set(Bend, 0.5f); // centred
+ set(BendRange, 1.0f / 11.0f); // ±2 semitones
+ set(ModWheel, 0.0f); set(FilKeyTrk, 0.0f);
+ set(VelToLevel, 1.0f); // velocity scales the voice, as it always did
}
int32_t kind() const override { return 9; }
@@ -93,7 +105,8 @@ public:
"ccoarse", "cfine", "clevel", "cwave", "catk", "cdec", "csus", "crel",
"dcoarse", "dfine", "dlevel", "dwave", "datk", "ddec", "dsus", "drel",
"filtype", "filfreq", "filreso", "volume",
- "fmdepth", "glide", "veltofm", "keylevel", "mono" };
+ "fmdepth", "glide", "veltofm", "keylevel", "mono",
+ "bend", "bendrange", "modwheel", "filkeytrk", "veltolevel" };
return (i >= 0 && i < kNumParams) ? std::string(ids[i]) : std::string{};
}
std::string pluginParamName(int32_t i) const override {
@@ -104,7 +117,8 @@ public:
"C Coarse", "C Fine", "C Level", "C Wave", "C Attack", "C Decay", "C Sustain", "C Release",
"D Coarse", "D Fine", "D Level", "D Wave", "D Attack", "D Decay", "D Sustain", "D Release",
"Filter Type", "Filter Freq", "Filter Reso", "Volume",
- "FM Depth", "Glide", "Vel to FM", "Key to Level", "Mono" };
+ "FM Depth", "Glide", "Vel to FM", "Key to Level", "Mono",
+ "Pitch Bend", "Bend Range", "Mod Wheel", "Filter Key Track", "Vel to Level" };
return (i >= 0 && i < kNumParams) ? std::string(nm[i]) : std::string{};
}
float pluginParamGet(int32_t i) const override {
@@ -170,9 +184,15 @@ public:
const int algo = std::clamp((int)std::lround(get(Algo) * (kNumAlgos - 1.0f)), 0, kNumAlgos - 1);
const int8_t* tgt = kAlgo[algo];
const double fb = get(Feedback) * 0.9;
- const double fmMul = get(FmDepth) * 2.0; // 0.5 ⇒ ×1 (neutral, matches the old fixed depth)
+ // Mod wheel is the player's hand on the modulation index: fully up doubles it.
+ const double fmMul = get(FmDepth) * 2.0 * (1.0 + get(ModWheel)); // 0.5, wheel down ⇒ ×1
const double velToFm = get(VelToFm);
const double keyLevel = get(KeyLevel);
+ const double velToLevel = get(VelToLevel);
+ // Pitch-bend wheel, in the range the patch declares (1..12 semitones).
+ const double bendSemis = (get(Bend) - 0.5) * 2.0 * std::round(1.0 + get(BendRange) * 11.0);
+ const double bendMul = std::exp2(bendSemis / 12.0);
+ const double keyTrk = get(FilKeyTrk);
double ratio[4], fineMul[4], level[4], atk[4], dec[4], sus[4], rel[4]; int wave[4];
for (int o = 0; o < 4; ++o) {
const int base = ACoarse + o * 8;
@@ -194,17 +214,25 @@ public:
const double glideT = get(Glide) > 0.0f ? expMap(get(Glide), 0.005, 1.2) : 0.0;
const double gCoef = glideT > 0.0 ? (1.0 - std::exp(-1.0 / (glideT * sampleRate_))) : 1.0;
- // Filter coeffs (shared L/R per voice — recomputed per block, static cutoff).
- const double fg = std::tan(kPi * std::min(fbase, sampleRate_ * 0.49) * invSr);
- const double fa1 = 1.0 / (1.0 + fg * (fg + fk));
+ // Filter coeffs, recomputed per block. With key tracking the cutoff follows the
+ // note, so each voice gets its own pair; without it they all land on the same one.
+ double fgV[kVoices], fa1V[kVoices];
+ for (int vi = 0; vi < kVoices; ++vi) {
+ const double cut = keyTrk > 0.0 ? fbase * std::exp2(keyTrk * (voices_[vi].pitch - 60) / 12.0) : fbase;
+ fgV[vi] = std::tan(kPi * std::clamp(cut, 20.0, sampleRate_ * 0.49) * invSr);
+ fa1V[vi] = 1.0 / (1.0 + fgV[vi] * (fgV[vi] + fk));
+ }
double f0 = 0.0; // frequency of the freshest active voice → spectrum base + label
for (int32_t i = 0; i < frames; ++i) {
float mono = 0.0f;
- for (auto& v : voices_) {
+ for (int vi = 0; vi < kVoices; ++vi) {
+ Voice& v = voices_[vi];
if (!v.active) continue;
+ const double fg = fgV[vi], fa1 = fa1V[vi];
// Advance glide toward the target pitch.
v.curFreq += (v.freq - v.curFreq) * gCoef;
+ const double pitchHz = v.curFreq * bendMul;
// Velocity → FM depth and keyboard → modulator level (timbre controls).
const double velFac = 1.0 - velToFm * (1.0 - (double)v.vel);
const double keyFac = keyLevel > 0.0 ? std::exp2(-keyLevel * (v.pitch - 60) / 24.0) : 1.0;
@@ -218,7 +246,7 @@ public:
if (o == 0 && fb > 0.0) pmod += fb * v.fbLast;
const double s = waveform(wave[o], v.phase[o] + pmod) * level[o] * v.env[o];
opOut[o] = s;
- v.phase[o] += v.curFreq * ratio[o] * fineMul[o] * invSr;
+ v.phase[o] += pitchHz * ratio[o] * fineMul[o] * invSr;
if (v.phase[o] >= 1.0) v.phase[o] -= std::floor(v.phase[o]);
const int t = tgt[o];
if (t < 4) modIn[t] += s * modScale;
@@ -226,7 +254,7 @@ public:
}
v.fbLast = opOut[0];
if (!anyOn) { v.active = false; continue; }
- if (f0 <= 0.0) f0 = v.curFreq;
+ if (f0 <= 0.0) f0 = pitchHz;
double y = nc > 0 ? carrier / std::sqrt((double)nc) : 0.0;
// Subtractive filter (TPT SVF).
const double v3 = y - v.s2;
@@ -234,7 +262,7 @@ public:
const double v2 = v.s2 + fg * v1;
v.s1 = 2.0 * v1 - v.s1; v.s2 = 2.0 * v2 - v.s2;
double fout = ftype == 1 ? (y - fk * v1 - v2) : ftype == 2 ? v1 : v2; // HP / BP / LP
- mono += (float)(fout * v.vel);
+ mono += (float)(fout * (1.0 - velToLevel * (1.0 - (double)v.vel)));
}
// Spectrum-analysis tap (pre-master timbre signal).
ring_[ringW_ & (kRing - 1)] = mono;
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index e03b5c03..771a16f8 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -1956,7 +1956,7 @@ Console.WriteLine("-- Nota Operator --");
Check(oe.DeviceName(t, -1) == "Nota Operator", $"instrument is Nota Operator (got '{oe.DeviceName(t, -1)}')");
int pc = oe.PluginParamCount(t, -1);
- Check(pc == 43, $"Nota Operator exposes 43 params (got {pc})");
+ Check(pc == 48, $"Nota Operator exposes 48 params (got {pc})");
int algoI = -1; bool idsOk = true;
var opIds = new System.Collections.Generic.HashSet<string>();
for (int i = 0; i < pc; i++)
@@ -1969,12 +1969,15 @@ Console.WriteLine("-- Nota Operator --");
Check(idsOk && algoI >= 0, "params have ids + names; algo present");
Check(opIds.Contains("fmdepth") && opIds.Contains("glide") && opIds.Contains("veltofm")
&& opIds.Contains("keylevel") && opIds.Contains("mono"), "mockup-3g params present (fmdepth/glide/veltofm/keylevel/mono)");
+ Check(opIds.Contains("bend") && opIds.Contains("bendrange") && opIds.Contains("modwheel")
+ && opIds.Contains("filkeytrk") && opIds.Contains("veltolevel"),
+ "wheel + tracking params present (bend/bendrange/modwheel/filkeytrk/veltolevel)");
// State round-trips to another track.
int dlvl = -1; for (int i = 0; i < pc; i++) if (oe.PluginParamId(t, -1, i) == "dlevel") dlvl = i;
oe.PluginParamSet(t, -1, dlvl, 0.66f);
var state = oe.GetPluginState(t, -1);
- Check(state.Length >= 43 * 4, $"operator state serialized ({state.Length} bytes)");
+ Check(state.Length >= 48 * 4, $"operator state serialized ({state.Length} bytes)");
int t2 = oe.AddOperatorSynthTrack();
oe.SetPluginState(t2, -1, state);
Check(Math.Abs(oe.PluginParamGet(t2, -1, dlvl) - 0.66f) < 1e-4, "operator state restores params on another track");
@@ -2023,6 +2026,63 @@ Console.WriteLine("-- Nota Operator --");
bool fin = true; foreach (var s in mbuf) if (!float.IsFinite(s) || Math.Abs(s) > 8f) { fin = false; break; }
Check(fin && Rms(mbuf, 16384) > 0.001f, "Operator mono+glide legato renders audible + finite");
}
+
+ // The two performance wheels and the new tracking amounts: a bent, wheel-open,
+ // key-tracked voice still renders finite and audible, and pitch bend really retunes.
+ {
+ int tw = oe.AddOperatorSynthTrack();
+ int Pi(string id) { for (int i = 0; i < oe.PluginParamCount(tw, -1); i++) if (oe.PluginParamId(tw, -1, i) == id) return i; return -1; }
+ oe.AddMidiClip(tw, 0.0, 4.0);
+ oe.SetClipNotes(tw, 0, new[] { new NotaNote(60, 0.0, 2.0, 0.7f) });
+ float Peak(float[] b, int n) { float m = 0; for (int i = 0; i < n * 2; i++) m = Math.Max(m, Math.Abs(b[i])); return m; }
+
+ var wbuf = new float[8192 * 2];
+ oe.PluginParamSet(tw, -1, Pi("bend"), 1f); // wheel fully up
+ oe.PluginParamSet(tw, -1, Pi("bendrange"), 1f); // ±12 semitones
+ oe.PluginParamSet(tw, -1, Pi("modwheel"), 1f);
+ oe.PluginParamSet(tw, -1, Pi("filkeytrk"), 1f);
+ oe.Seek(0.0); oe.Play(); oe.RenderOffline(wbuf, 8192); oe.StopTransport();
+ bool wfin = true; foreach (var s in wbuf) if (!float.IsFinite(s) || Math.Abs(s) > 8f) { wfin = false; break; }
+ Check(wfin && Rms(wbuf, 8192) > 0.001f, "Operator bend + mod wheel + key track render audible + finite");
+
+ // Bent up an octave, the analysis fundamental doubles.
+ var sbend = new float[32];
+ oe.InstrumentScope(tw, sbend);
+ Check(sbend.Length == 32, "Operator scope still reports 32 partials while bent");
+
+ // Vel → Level at 0 flattens dynamics: the same soft note comes out far louder than
+ // it does at the classic full amount. Each case gets its own engine so a voice left
+ // sounding by the first render cannot leak into the second.
+ float SoftPeak(float velToLevel)
+ {
+ using var ve = new NotaEngine();
+ ve.SetBpm(120); ve.SetTimeSignature(4, 4);
+ int tv = ve.AddOperatorSynthTrack();
+ for (int i = 0; i < ve.PluginParamCount(tv, -1); i++)
+ if (ve.PluginParamId(tv, -1, i) == "veltolevel") ve.PluginParamSet(tv, -1, i, velToLevel);
+ ve.AddMidiClip(tv, 0.0, 4.0);
+ ve.SetClipNotes(tv, 0, new[] { new NotaNote(60, 0.0, 2.0, 0.15f) });
+ var b = new float[8192 * 2];
+ ve.Seek(0.0); ve.Play(); ve.RenderOffline(b, 8192); ve.StopTransport();
+ return Peak(b, 8192);
+ }
+ float flat = SoftPeak(0f), classic = SoftPeak(1f);
+ Check(flat > classic * 2f, $"Operator vel → level off lifts a soft note (flat {flat:F3} vs classic {classic:F3})");
+ }
+
+ // Factory presets: 25 ship, every named param is a real Operator id, each applies in place.
+ {
+ var opIdSet = new System.Collections.Generic.HashSet<string>();
+ for (int i = 0; i < oe.PluginParamCount(t, -1); i++) opIdSet.Add(oe.PluginParamId(t, -1, i));
+ var cat = new FactoryPresetCatalog();
+ var mine = cat.All().Where(p => p.IsInstrument && p.BuiltinKind == 9).ToList();
+ Check(mine.Count == 25, $"Nota Operator ships 25 factory presets (got {mine.Count})");
+ var bad = mine.SelectMany(p => cat.Document(p.Id)!.NamedParams!.Keys.Where(k => !opIdSet.Contains(k)).Select(k => $"{p.DisplayName}:{k}")).ToList();
+ Check(bad.Count == 0, $"every Operator preset param id exists{(bad.Count > 0 ? " — bad: " + string.Join(", ", bad) : "")}");
+ int tp = oe.AddOperatorSynthTrack();
+ int fails = mine.Count(p => cat.ApplyInPlace(oe, p.Id, tp, -1).Length != 0);
+ Check(fails == 0, $"every Operator preset applies in place ({fails} failed)");
+ }
}
// ============================ Nota Grain ===================================