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
Updated packs for Drum Rack and Rhythm (sounds, fx)
Egor Khindikaynend54805ca4ac3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1e9b88f1..05949a98 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,27 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Nota Rhythm and the Drum Rack share one set of kits.** Rhythm's own synth presets are+ gone; the 25 factory drum kits now load onto its eight voices too — from the card's kit+ picker, from the kits listed under Nota Rhythm in the browser, or by dropping a kit on a+ Rhythm track (the steps stay). Each voice takes the kit's pad on its own MIDI note (Kick,+ Snare, Clap, Rim, both hats, the high tom) plus a percussion pad, so a note plays the same+ sound in either instrument. A new Rhythm starts on *Kompakt*; a kit voice shows its+ sample's name in the kit list.+- **Every kit pad comes with its own effects,** as ordinary devices on the pad's chain (or+ the Rhythm voice's): parallel Tube saturation on the kick (Tape on the lo-fi kits), a short+ pre-delayed plate on the snare, a room on the clap, a quiet high-passed 1/16 ping-pong on+ the closed hats and a dotted-1/8 one on the open hat and percussion. Each kit scales its+ space and drive to its style, pads with room already in the sample get less reverb, and+ every effect adds to the hit without changing it (its dry stays at unity; the kick stays+ level-matched). Toms, cymbals and 808 bass stay dry.+- **Nota Rhythm: effects per voice.** Each voice has its own insert chain of built-in+ effects before the kit bus — the voice editor's new **FX** tab shows it with the Drum+ Rack's device slots: click one for the effect's own card, bypass or remove it, add from+ the menu or drop an effect from the browser. The chains save with the project and copy+ with the track; the kit list marks the voices that have effects. MCP:+ `get_rhythm_voice_fx`, `add_rhythm_voice_fx`, `set_rhythm_voice_fx`,+ `remove_rhythm_voice_fx`, and `add_rhythm_kit_track`; `load_drum_kit` also takes a Rhythm.- **Nota Rhythm's editor is now the almanac's card, with the new mockup's features.** Thedrum machine moves from its 900 px layout onto the 700 × 260 frame: the **kit** on theleft, the selected **voice** in the middle, a fixed 186 px **Perform** rail, a full-width@@ -221,6 +242,14 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.level, the effective attack and release, look-ahead latency and how often it kicked in.### Changed+- **The factory kits' kicks, snares and claps are reworked** (the kits re-render once, on+ the next launch). Kicks sit lower and read as kicks: the upper "knock" is a short tick+ instead of a ~220 Hz ring, the pitch sweep is capped at a few tens of milliseconds, the+ drive is odd-order and the click joins after it, and the kicks tuned at 58–70 Hz come down+ to 50–54. Snares were mostly shell — the wires sat 20–30 dB down; now shell and wires+ share the hit (a spectral centroid around 3–4 kHz instead of 1–2) with a 1.5–3 kHz crack,+ and the dance snares get some body. Claps gain the skin-on-skin air above the band. The+ "analog glue" no longer adds low-mid box to kicks or rolls the top off snares and claps.- **Nota Rhythm's automation menu is grouped** by voice (Kick › Tune, Closed Hat › Decay),**Perform** (Swing, Humanize, Accent) and **Master** (Volume, Glue). Ids are unchanged, soexisting lanes keep working; projects saved before keep their kits and patterns.@@ -753,6 +782,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.returns the compressor's status line.### Fixed+- **Tempo-synced effects inside a rack ignored the tempo.** A synced Delay, Auto Filter or+ Auto Pan on a Drum Rack pad, an Instrument Rack chain or an Audio Effect Rack chain ran on+ its free time; racks now pass the song tempo down to their chains.+- **A Nota Rhythm sample voice was quietly low-passed and mono.** The synth's Tone setting+ also filtered a loaded one-shot at ~6 kHz (sample mode has no Tone knob), and a stereo+ file was summed to mono. A loaded sample now plays open, and in stereo.- **A Sampler's loop could change kind on its own.** Reloading a sample turned a ping-pongloop into a forward one and a forward loop into a one-shot, and a sampler created with theloop flag (e.g. from a kit) played ping-pong instead of forward. The loop kind now survives.diff --git a/FEATURES.md b/FEATURES.mdindex 6d9414bd..b7c806d4 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -316,8 +316,12 @@ and user presets, automation, persistence and cloning.**Glue** bus compressor, and a per-voice **Sample** mode (load your own one-shot, with aStart / Length region and Reverse). The 700 × 260 card: kit list, an interactive hitcontour or sample region, Perform rail with an output meter, a full-width step strip with- a velocity lane. 29 factory kits; MCP `get_rhythm`, `set_rhythm_pattern` (text rows),- `set_rhythm_voice`, `set_rhythm_perform`, `copy_rhythm_bank`, `audition_rhythm_voice`.+ a velocity lane. Each voice has its own **FX** chain of built-in effects (the voice's FX+ tab). Its kits are the 25 factory drum kits it shares with the Drum Rack — samples and+ per-voice effects — from the card's kit picker or the browser; MCP `get_rhythm`,+ `set_rhythm_pattern` (text rows), `set_rhythm_voice`, `set_rhythm_perform`,+ `copy_rhythm_bank`, `audition_rhythm_voice`, `get_rhythm_voice_fx` / `add_rhythm_voice_fx` /+ `set_rhythm_voice_fx`, `add_rhythm_kit_track`.- **Nota Pentad** — 5-voice analog poly in the Prophet-5 mould: Osc A (saw + pulse, hardsync) and Osc B (saw + triangle + pulse, Lo-Freq, keyboard off), noise, a 24 dB/octresonant filter that self-oscillates and tracks the keyboard, two analog-curve ADSRs,@@ -538,7 +542,7 @@ and user presets, automation, persistence and cloning.oscillogram with a playhead, and each pad's own effect chain. A **kit picker** in thecard header loads any factory kit in place and names the kit a rack holds. Its clips canbe stepped in the detail panel's **Pattern** tab (see below).-- **25 factory kits** under Nota Drum Rack in the browser and in the card's kit picker:+- **25 factory kits** under Nota Drum Rack and Nota Rhythm in the browser and in their cards' kit pickers:*Volta* (warm analog boom), *Kompakt* (punchy analog house), *Micron* (small vintagerhythm box), *Linnwood* (80s PCM machine), *Atelier* (acoustic studio kit), *Cellar*(dusty vinyl break), *Neon* (modern sub-forward, tuned 808 bass), *Foundry* (industrial@@ -548,8 +552,9 @@ and user presets, automation, persistence and cloning.chip), *Lagoon* (amapiano log drums), *Titan* (trailer percussion), *Shuffle* (UKgarage), *Mirrorball* (70s disco), *Pit* (orchestral percussion), *Hyper* (hyperpop) and*Crate* (90s boom bap). 16 pads each on the General MIDI map (36–51), hats choked together,- with the kit's own swing and humanize. Load onto a new track or drop onto an existing- Drum Rack to replace its pads. The one-shots are synthesized on first launch rather than+ with the kit's own swing and humanize, and each pad's own effects (kick saturation, snare and+ clap reverb, hat and percussion delay, scaled to the kit). Load onto a new track or drop onto+ an existing Drum Rack or Rhythm to replace its pads / voices. The one-shots are synthesized on first launch rather thanshipped as audio (nothing added to the installer) and appear in the Files tab under**Nota Kits**, ready to drag anywhere a sample goes.- **Nota Audio Effect Rack** — **Parallel / Series / Select** modes (by input level),diff --git a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.csindex 16bfca67..3a06f2f6 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs@@ -4,12 +4,16 @@// Detail · Devices — the Nota Rhythm editor (instrument kind 12): an eight-voice drum// machine in the 700 × 260 card the almanac draws for it. Reading order, left to right://-// KIT 104 the voices — a hue dot, the name, SYN / SMP. Click selects and plays the-// voice; drop a file on one to load it as a sample; right-click for more.-// VOICE the selected voice's editor. Synth: the HIT contour (drag it — across is-// Decay, up / down Tune) and Tune · Decay · Punch · Tone · Drive · Level.-// Sample: the file with its Start / End region (drag the lines), Reverse,-// and Start · Length · Tune (st) · Decay · Drive · Level.+// KIT 104 the voices — a hue dot, the name (a kit voice takes its sample's name), an+// "fx" mark when it has effects, SYN / SMP. Click selects and plays the voice;+// drop a file on one to load it as a sample; right-click for more. The kit+// itself is the header's preset picker (the factory drum kits).+// VOICE the selected voice, on two tabs. Sound — Synth: the HIT contour (drag it —+// across is Decay, up / down Tune) and Tune · Decay · Punch · Tone · Drive ·+// Level; Sample: the file with its Start / End region (drag the lines),+// Reverse, and Start · Length · Tune (st) · Decay · Drive · Level. FX — the+// voice's insert chain, the Drum Rack's device slots over RhythmVoiceAccess:+// click a slot for the effect's own card, add from the menu or drop one.// PERFORM 186 Swing · Human · Accent (teal — they shape the playing, not the sound),// Master and Glue (the bus compressor), the output meter.// STEP a full-width strip: the selected voice's sixteen steps in bank A–D, a@@ -46,6 +50,19 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardprivate const double KitW = 104, RailW = 186, StepH = 46, HeadH = 18, StatusH = 18, GraphW = 112;+ private static int _voiceTab; // 0 Sound, 1 FX — kept across rebuilds (a voice click, a kit load)++ // A kit voice is named after its one-shot ("04 Clap" → "Clap"); a synth voice by its slot.+ private static string VoiceLabel(IAudioEngine engine, int track, int v, bool sample)+ {+ if (sample && engine.TryGetRhythmVoiceInfo(track, v, out var vi) && vi.SampleId != 0)+ {+ string n = System.Text.RegularExpressions.Regex.Replace(engine.SampleName(vi.SampleId), @"^\d+\s+", "");+ if (n.Length > 0) return n;+ }+ return RM.VoiceNames[v];+ }+// Kit-voice identity hues — one per voice, painted only through NotaPalette.Ink.private static readonly string[] Dots = { "#C77F55", "#D8A03D", "#3E8E8E", "#7A6FB0", "#9AA64A", "#58B368", "#5AA0B8", "#B57286" };@@ -72,7 +89,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardfor (int v = 0; v < RM.Voices; v++) isSample[v] = engine.RhythmVoiceSource(track, v) == 1;long sid = engine.TryGetRhythmVoiceInfo(track, sel, out var vinfo) ? vinfo.SampleId : 0;bool sampleMode = isSample[sel] && sid != 0;- string sampleName = sid != 0 ? engine.SampleName(sid) : "";+ string sampleName = sid != 0 ? VoiceLabel(engine, track, sel, true) : "";if (sampleName.Length == 0 && sid != 0) sampleName = "sample";double sampleSecs = sid != 0 && engine.TryGetSampleInfo(sid, out var sinfo) && sinfo.SampleRate > 0 ? sinfo.Frames / sinfo.SampleRate : 0;string P(string p) => RM.Id(sel, p);@@ -168,6 +185,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardvoid Loaded(int voice){Write(RM.Id(voice, "tune"), 0.5f);+ Write(RM.Id(voice, "tone"), 1f); // sample mode has no Tone knob: play the file openWrite(RM.Id(voice, "start"), 0f);Write(RM.Id(voice, "length"), 1f);Act(RM.A_SelectVoice, voice);@@ -219,15 +237,18 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardkitDots[v] = dot;var nm = new TextBlock{- Text = RM.VoiceNames[v], FontSize = 8, FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal,+ Text = VoiceLabel(engine, track, v, isSample[v]), FontSize = 8, FontWeight = on ? FontWeight.SemiBold : FontWeight.Normal,Foreground = on ? AccentBright : TextPrimary, VerticalAlignment = VerticalAlignment.Center,TextTrimming = TextTrimming.CharacterEllipsis, Margin = new Thickness(5, 0, 4, 0),};var tag = Mono(isSample[v] ? "SMP" : "SYN", on ? AccentBright : TextTertiary);- var row = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto"), Margin = new Thickness(5, 0) };+ var fxTag = Mono(engine.RhythmVoiceDeviceCount(track, v) > 0 ? "fx" : "", on ? AccentBright : TextTertiary);+ fxTag.Margin = new Thickness(0, 0, 3, 0);+ var row = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto,Auto"), Margin = new Thickness(5, 0) };row.Children.Add(dot);Grid.SetColumn(nm, 1); row.Children.Add(nm);- Grid.SetColumn(tag, 2); row.Children.Add(tag);+ Grid.SetColumn(fxTag, 2); row.Children.Add(fxTag);+ Grid.SetColumn(tag, 3); row.Children.Add(tag);IBrush restBorder = on ? NotaPalette.BorderBrass : Brushes.Transparent;var box = new Border{@@ -235,6 +256,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardBackground = on ? NotaPalette.AccentSubtle : Brushes.Transparent, BorderBrush = restBorder, Child = row,};ToolTip.SetTip(box, $"{RM.VoiceNames[v]} · MIDI {DeviceCardKit.NoteName(RM.MidiNotes[v])}\nClick: select and play · drop a file to load it · right-click for more");+ AttachFxTip(fxTag, v);box.PointerPressed += (_, e) =>{var pt = e.GetCurrentPoint(box);@@ -247,6 +269,14 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardAcceptDrops(box, vv, h => box.BorderBrush = h ? Teal : restBorder);Grid.SetRow(box, v); kitRows.Children.Add(box);}+ void AttachFxTip(Control c, int v)+ {+ int n = engine.RhythmVoiceDeviceCount(track, v);+ if (n == 0) return;+ var names = new List<string>();+ for (int d = 0; d < n; d++) names.Add(engine.RhythmVoiceDeviceName(track, v, d));+ ToolTip.SetTip(c, "Effects: " + string.Join(" → ", names));+ }void KitMenu(int v, Control anchor){var fly = new MenuFlyout();@@ -300,11 +330,24 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardvar voiceHead = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, Margin = new Thickness(7, 0), VerticalAlignment = VerticalAlignment.Center };voiceHead.Children.Add(Cap("VOICE"));- voiceHead.Children.Add(new TextBlock { Text = RM.VoiceNames[sel], FontSize = 9, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center });+ voiceHead.Children.Add(new TextBlock { Text = VoiceLabel(engine, track, sel, sampleMode), FontSize = 9, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center, MaxWidth = 84, TextTrimming = TextTrimming.CharacterEllipsis });+ int fxCount = engine.RhythmVoiceDeviceCount(track, sel);+ var tabSeg = Segments(new[] { "Sound", fxCount > 0 ? $"FX {fxCount}" : "FX" }, () => _voiceTab, i =>+ {+ if (i == _voiceTab) return;+ _voiceTab = i; ctx.RequestRebuild();+ }, out _, padX: 6, fontSize: 7);+ ToolTip.SetTip(tabSeg, "Sound: the voice's source and shape · FX: its own effects, before the kit bus");+ voiceHead.Children.Add(tabSeg);var voiceTools = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5, Margin = new Thickness(0, 0, 6, 0), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right };- voiceTools.Children.Add(srcSeg);- voiceTools.Children.Add(fileBtn);- if (sampleMode)+ if (_voiceTab == 0) voiceTools.Children.Add(srcSeg);+ if (_voiceTab == 0) voiceTools.Children.Add(fileBtn);+ if (_voiceTab == 1)+ {+ var hint = Mono("signal left → right", NotaPalette.TextDisabled);+ voiceTools.Children.Add(hint);+ }+ if (sampleMode && _voiceTab == 0){var revText = new TextBlock { Text = "Reverse", FontSize = 7, FontWeight = FontWeight.SemiBold, VerticalAlignment = VerticalAlignment.Center };var rev = SmallButton(revText, revText,@@ -382,9 +425,19 @@ internal sealed class RhythmInstrumentCard : IInstrumentCard};for (int i = 0; i < cells.Length; i++) { Grid.SetColumn(cells[i], i); knobs.Children.Add(cells[i]); }- var voiceBody = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), ColumnSpacing = 6, Margin = new Thickness(6, 5) };- voiceBody.Children.Add(graph);- Grid.SetColumn(knobs, 1); voiceBody.Children.Add(knobs);+ Control voiceBody;+ if (_voiceTab == 1)+ {+ var fxStrip = new RackCardView(ctx).BuildEffectStrip(new RhythmVoiceAccess(engine, track), sel);+ voiceBody = new Border { Margin = new Thickness(6, 5), Child = fxStrip };+ }+ else+ {+ var g = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), ColumnSpacing = 6, Margin = new Thickness(6, 5) };+ g.Children.Add(graph);+ Grid.SetColumn(knobs, 1); g.Children.Add(knobs);+ voiceBody = g;+ }var voice = Section(voiceHeadRow, voiceBody);// ---- PERFORM --------------------------------------------------------------------------diff --git a/src/managed/Nota.App/DeviceCards/Rack/IRackAccess.cs b/src/managed/Nota.App/DeviceCards/Rack/IRackAccess.csindex 7e75ff50..d366eac3 100644--- a/src/managed/Nota.App/DeviceCards/Rack/IRackAccess.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/IRackAccess.cs@@ -56,6 +56,8 @@ internal interface IRackAccessfloat ChainMeter(int chain);bool SetMappingRange(int index, float lo, float hi);int MappingCurve(int index); bool SetMappingCurve(int index, int curve);+ /// <summary>Whether a chain can take a hosted plug-in effect (not Nota Rhythm's voices).</summary>+ bool HostsPlugins => true;}internal sealed class InstrumentRackAccess(IAudioEngine e, int t) : IRackAccess@@ -163,3 +165,56 @@ internal sealed class EffectRackAccess(IAudioEngine e, int t, int di) : IRackAccpublic int MappingCurve(int i) => e.RackDevMappingCurve(t, di, i);public bool SetMappingCurve(int i, int curve) => e.RackDevSetMappingCurve(t, di, i, curve);}++// Nota Rhythm's eight voices as effect-only "chains": each voice's insert chain through the+// same surface a rack chain has, so the rack's device slots, add menu and full device cards+// work on a voice unchanged. The instrument / mix / macro members have no Rhythm meaning.+internal sealed class RhythmVoiceAccess(IAudioEngine e, int t) : IRackAccess+{+ public bool HasInstrumentChains => false;+ public int AutomationDeviceIndex => -1;+ public bool HostsPlugins => false;+ public int ChainCount() => RhythmModel.Voices;+ public int AddChain(int k) => -1;+ public bool RemoveChain(int c) => false;+ public bool SetChainInstrument(int c, int k) => false;+ public int ChainInstrumentKind(int c) => -2;+ public string ChainInstrumentName(int c) => "";+ public int ChainInstrumentParamCount(int c) => 0;+ public string ChainInstrumentParamName(int c, int p) => "";+ public float ChainInstrumentParamGet(int c, int p) => 0f;+ public void ChainInstrumentParamSet(int c, int p, float v) { }+ public int ChainDeviceCount(int c) => e.RhythmVoiceDeviceCount(t, c);+ public int AddChainDevice(int c, int k) => e.RhythmAddVoiceDevice(t, c, k);+ public int AddPluginInstrumentChain(int catalogIndex) => -1;+ public int AddPluginChainDevice(int c, int catalogIndex) => -1;+ public bool RemoveChainDevice(int c, int d) => e.RhythmRemoveVoiceDevice(t, c, d);+ public void MoveChainDevice(int c, int f, int to) => e.RhythmMoveVoiceDevice(t, c, f, to);+ public string ChainDeviceName(int c, int d) => e.RhythmVoiceDeviceName(t, c, d);+ public int ChainDeviceParamCount(int c, int d) => e.RhythmVoiceDeviceParamCount(t, c, d);+ public string ChainDeviceParamName(int c, int d, int p) => e.RhythmVoiceDeviceParamName(t, c, d, p);+ public float ChainDeviceParamMin(int c, int d, int p) => e.RhythmVoiceDeviceParamMin(t, c, d, p);+ public float ChainDeviceParamMax(int c, int d, int p) => e.RhythmVoiceDeviceParamMax(t, c, d, p);+ public float ChainDeviceParamGet(int c, int d, int p) => e.RhythmVoiceDeviceParamGet(t, c, d, p);+ public void ChainDeviceParamSet(int c, int d, int p, float v) => e.RhythmVoiceDeviceParamSet(t, c, d, p, v);+ public bool ChainDeviceBypassed(int c, int d) => e.RhythmVoiceDeviceBypassed(t, c, d);+ public void SetChainDeviceBypassed(int c, int d, bool b) => e.RhythmSetVoiceDeviceBypassed(t, c, d, b);+ public int ChainDeviceBuiltinKind(int c, int d) => e.RhythmVoiceDeviceBuiltinKind(t, c, d);+ public void OpenChainDeviceEditor(int c, int d) { }+ public float ChainGain(int c) => 1f; public void SetChainGain(int c, float v) { }+ public float ChainPan(int c) => 0f; public void SetChainPan(int c, float v) { }+ public bool ChainMute(int c) => false; public void SetChainMute(int c, bool b) { }+ public bool ChainSolo(int c) => false; public void SetChainSolo(int c, bool b) { }+ public int ChainTriggerNote(int c) => c is >= 0 and < RhythmModel.Voices ? RhythmModel.MidiNotes[c] : -1;+ public void SetChainTriggerNote(int c, int note) { }+ public int AddMacroMapping(int m, int c, int td, int p, float lo, float hi) => -1;+ public int MappingCount() => 0;+ public bool TryGetMapping(int i, out RackMacroMapping m) { m = default; return false; }+ public bool RemoveMapping(int i) => false;+ public string MacroName(int i) => "";+ public void SetMacroName(int i, string name) { }+ public float ChainMeter(int c) => 0f;+ public bool SetMappingRange(int i, float lo, float hi) => false;+ public int MappingCurve(int i) => 0;+ public bool SetMappingCurve(int i, int curve) => false;+}diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.csindex 944c0898..a1714f42 100644--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs@@ -343,7 +343,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)mi.Click += (_, _) => { a.AddChainDevice(sc, kk); _ctx.RequestRebuild(); };f.Items.Add(mi);}- if (App.Services?.GetService(typeof(Nota.Application.IPluginCatalog)) is Nota.Application.IPluginCatalog cat && cat.Count > 0)+ if (a.HostsPlugins && App.Services?.GetService(typeof(Nota.Application.IPluginCatalog)) is Nota.Application.IPluginCatalog cat && cat.Count > 0){var sub = new MenuItem { Header = "Plug-ins" };for (int i = 0; i < cat.Count; i++)@@ -1340,8 +1340,20 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)private static bool IsEffect(Nota.Presentation.BrowserItem? item) =>item is { Kind: Nota.Presentation.BrowserItemKind.BuiltinEffect or Nota.Presentation.BrowserItemKind.PluginEffect };+ /// <summary>One chain's insert effects as a row of device slots, then the add slot — the+ /// Drum Rack pad's chain strip without its instrument. Nota Rhythm shows a voice's FX with+ /// it, through <see cref="RhythmVoiceAccess"/>.</summary>+ public Control BuildEffectStrip(IRackAccess a, int chain)+ {+ var slots = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 5 };+ for (int d = 0; d < a.ChainDeviceCount(chain); d++) slots.Children.Add(IrDeviceSlot(a, chain, d));+ slots.Children.Add(IrAddDeviceSlot(a, chain));+ return new ScrollViewer { Content = slots, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Disabled };+ }+private void DropEffectOnChain(IRackAccess a, int chain, Nota.Presentation.BrowserItem item){+ if (item.Kind == Nota.Presentation.BrowserItemKind.PluginEffect && !a.HostsPlugins) return;if (item.Kind == Nota.Presentation.BrowserItemKind.BuiltinEffect) a.AddChainDevice(chain, item.BuiltinKind);else if (item.Kind == Nota.Presentation.BrowserItemKind.PluginEffect) a.AddPluginChainDevice(chain, item.CatalogIndex);_ctx.RequestRebuild();diff --git a/src/managed/Nota.App/DeviceChainView.Instruments.cs b/src/managed/Nota.App/DeviceChainView.Instruments.csindex 64b9ef50..5b6cbc6c 100644--- a/src/managed/Nota.App/DeviceChainView.Instruments.cs+++ b/src/managed/Nota.App/DeviceChainView.Instruments.cs@@ -28,28 +28,32 @@ public sealed partial class DeviceChainViewName: _engine.DeviceName(_trackId, -1), Subtitle: strategy.Subtitle, DeviceIndex: -1, Count: 1,Bypassed: false, Bypassable: false, CanMove: false, CanDelete: false,PresetKind: kind, IsInstrument: true, Width: strategy.CardWidth, Kind: ChainKind.Instrument,- VoiceLabel: strategy.VoiceLabel);+ VoiceLabel: strategy.VoiceLabel, Presets: kind == Nota.Application.RhythmModel.Kind ? KitPresets() : null);return BuildCardShell(spec, body);}+ // The factory drum kits as a card's presets — shared by the Drum Rack (they replace its+ // pads) and Nota Rhythm (they replace its voices' samples and FX, keeping the steps).+ private CardPresets? KitPresets()+ {+ if (_kits is not { } k) return null;+ int t = _trackId;+ var items = new System.Collections.Generic.List<(string, string)>();+ foreach (var kit in k.All()) items.Add((kit.Id, kit.Name));+ return new CardPresets(items, () => k.Identify(_engine, t), id =>+ {+ k.LoadInto(_engine, t, id, out string warn);+ _rackSelChain = 0;+ return warn;+ });+ }+// The Drum Rack in the shared shell: its presets are the factory kits, which replace the// rack's pads, and the badge counts the loaded pads.private Control DrumRackCard(){var body = new RackCardView(NewCardContext()).BuildDrumRackBody(out int pads);- CardPresets? kits = null;- if (_kits is { } k)- {- int t = _trackId;- var items = new System.Collections.Generic.List<(string, string)>();- foreach (var kit in k.All()) items.Add((kit.Id, kit.Name));- kits = new CardPresets(items, () => k.Identify(_engine, t), id =>- {- k.LoadInto(_engine, t, id, out string warn);- _rackSelChain = 0;- return warn;- });- }+ var kits = KitPresets();var spec = new ShellSpec(Name: _engine.DeviceName(_trackId, -1), Subtitle: $"DRUMS · {pads} PAD{(pads == 1 ? "" : "S")}", DeviceIndex: -1, Count: 1,Bypassed: false, Bypassable: false, CanMove: false, CanDelete: false,diff --git a/src/managed/Nota.App/MainWindow.Browser.cs b/src/managed/Nota.App/MainWindow.Browser.csindex 065439d1..0e160a99 100644--- a/src/managed/Nota.App/MainWindow.Browser.cs+++ b/src/managed/Nota.App/MainWindow.Browser.cs@@ -65,23 +65,29 @@ public partial class MainWindowreturn warn;}- /// <summary>A factory drum-kit row (browser Path "kit:<id>").</summary>+ /// <summary>A factory drum-kit row: "kit:<id>" under the Drum Rack, "rhythmkit:<id>"+ /// under Nota Rhythm — the same kits, told apart by the instrument a new track gets.</summary>private static bool IsKitRow(BrowserItem item)- => item.Kind == BrowserItemKind.Preset && item.Path.StartsWith("kit:", StringComparison.Ordinal);+ => item.Kind == BrowserItemKind.Preset+ && (item.Path.StartsWith("kit:", StringComparison.Ordinal) || item.Path.StartsWith(RhythmKitPrefix, StringComparison.Ordinal));- // Loads a factory kit. Dropped on an existing Drum Rack it replaces that rack's pads;- // anywhere else it spawns its own Drum Rack track, the way an instrument preset does.- // The kit's samples are synthesized on first use, which is why this can be slow once.+ private const string RhythmKitPrefix = "rhythmkit:";++ // Loads a factory kit. Dropped on an existing Drum Rack or Nota Rhythm it replaces that+ // instrument's pads / voices; anywhere else it spawns its own track — a Drum Rack, or a+ // Rhythm for a row under Rhythm — the way an instrument preset does. The kit's samples+ // are synthesized on first use, which is why this can be slow once.private string ApplyDrumKit(BrowserItem item, int targetTrackId){- string id = item.Path["kit:".Length..];- if (targetTrackId > 0 && Engine.TrackInstrumentKind(targetTrackId) == 4)+ bool rhythm = item.Path.StartsWith(RhythmKitPrefix, StringComparison.Ordinal);+ string id = item.Path[(rhythm ? RhythmKitPrefix.Length : "kit:".Length)..];+ if (targetTrackId > 0 && Engine.TrackInstrumentKind(targetTrackId) is 4 or RhythmModel.Kind){_kits.LoadInto(Engine, targetTrackId, id, out string replaceWarn);ShowDevices(targetTrackId);return replaceWarn;}- int track = _kits.CreateTrack(Engine, id, out string warn);+ int track = rhythm ? _kits.CreateRhythmTrack(Engine, id, out string warn) : _kits.CreateTrack(Engine, id, out warn);if (track > 0){Engine.AddMidiClip(track, 0.0, 4.0);@@ -128,6 +134,7 @@ public partial class MainWindow1 => Engine.AddSamplerInstrumentTrack(),_ => Engine.AddInstrumentTrack(),};+ if (item.BuiltinKind == RhythmModel.Kind) _kits.LoadInto(Engine, t, _kits.DefaultRhythmKit, out _); // a Rhythm starts on a factory kitEngine.AddMidiClip(t, 0.0, 4.0);if (item.BuiltinKind == 1) ShowDevices(t); // reveal the Sampler card (drop a sample onto it)_lastInstrumentTrackId = t;diff --git a/src/managed/Nota.App/MainWindow.Dnd.cs b/src/managed/Nota.App/MainWindow.Dnd.csindex 84244b14..9c0119d7 100644--- a/src/managed/Nota.App/MainWindow.Dnd.cs+++ b/src/managed/Nota.App/MainWindow.Dnd.cs@@ -43,6 +43,7 @@ public partial class MainWindow// otherwise add a new track. Racks/Sampler fall through to their own adds.if (CanReplaceInstrument(trackId) && Engine.SetTrackBuiltinInstrument(trackId, item.BuiltinKind)){+ if (item.BuiltinKind == RhythmModel.Kind) _kits.LoadInto(Engine, trackId, _kits.DefaultRhythmKit, out _);_lastInstrumentTrackId = trackId;RefreshDeviceChainIfShowing(trackId);_vm.StatusText = $"Changed instrument to {item.Name} (track {trackId})";@@ -67,6 +68,7 @@ public partial class MainWindow1 => Engine.AddSamplerInstrumentTrack(),_ => Engine.AddInstrumentTrack(),};+ if (item.BuiltinKind == RhythmModel.Kind) _kits.LoadInto(Engine, t, _kits.DefaultRhythmKit, out _); // a Rhythm starts on a factory kitEngine.AddMidiClip(t, beat, 4.0);_lastInstrumentTrackId = t;_vm.StatusText = $"Added {item.Name} (track {t})";diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.csindex fd5f848b..e0c0df08 100644--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs@@ -281,6 +281,25 @@ public interface IAudioEngine : IDisposablebool TryGetRhythmVoiceInfo(int trackId, int voice, out NotaSamplerInfo info);/// <summary>Per-voice source: 0 = Synth, 1 = Sample.</summary>int RhythmVoiceSource(int trackId, int voice);+ /// <summary>Nota Rhythm per-voice insert chains: built-in effects (rack chain kinds) run on one+ /// voice before the kit bus. Params are in each device's own units (min..max).</summary>+ int RhythmVoiceDeviceCount(int trackId, int voice);+ int RhythmAddVoiceDevice(int trackId, int voice, int kind);+ bool RhythmRemoveVoiceDevice(int trackId, int voice, int dev);+ void RhythmMoveVoiceDevice(int trackId, int voice, int from, int to);+ string RhythmVoiceDeviceName(int trackId, int voice, int dev);+ int RhythmVoiceDeviceBuiltinKind(int trackId, int voice, int dev);+ int RhythmVoiceDeviceParamCount(int trackId, int voice, int dev);+ string RhythmVoiceDeviceParamName(int trackId, int voice, int dev, int param);+ float RhythmVoiceDeviceParamMin(int trackId, int voice, int dev, int param);+ float RhythmVoiceDeviceParamMax(int trackId, int voice, int dev, int param);+ float RhythmVoiceDeviceParamGet(int trackId, int voice, int dev, int param);+ void RhythmVoiceDeviceParamSet(int trackId, int voice, int dev, int param, float value);+ bool RhythmVoiceDeviceBypassed(int trackId, int voice, int dev);+ void RhythmSetVoiceDeviceBypassed(int trackId, int voice, int dev, bool bypassed);+ /// <summary>The factory kit a Rhythm's voices were loaded from ("" = none) — display only, saved with the track.</summary>+ string RhythmKitName(int trackId);+ void RhythmSetKitName(int trackId, string name);/// <summary>Live Nota Grain read positions (0..1) of active voices into outPos; returns the count.</summary>int GrainPlayPositions(int trackId, float[] outPos);/// <summary>Active synth-voice count for a built-in instrument, or -1 if unsupported.</summary>diff --git a/src/managed/Nota.Application/Ports/IDrumKits.cs b/src/managed/Nota.Application/Ports/IDrumKits.csindex 4bc3694f..bbb49ebd 100644--- a/src/managed/Nota.Application/Ports/IDrumKits.cs+++ b/src/managed/Nota.Application/Ports/IDrumKits.cs@@ -35,11 +35,19 @@ public interface IDrumKits/// or -1; <paramref name="warning"/> is "" on success.</summary>int CreateTrack(IAudioEngine engine, string id, out string warning);- /// <summary>Replaces the pads of an existing Drum Rack track with the kit.</summary>+ /// <summary>Creates a Nota Rhythm track with the kit on its eight voices (samples, levels+ /// and effects). Returns the new track id, or -1.</summary>+ int CreateRhythmTrack(IAudioEngine engine, string id, out string warning);++ /// <summary>The kit a new Nota Rhythm starts with.</summary>+ string DefaultRhythmKit { get; }++ /// <summary>Replaces the pads of an existing Drum Rack track — or the voices of a Nota+ /// Rhythm (its steps are kept) — with the kit.</summary>bool LoadInto(IAudioEngine engine, int trackId, string id, out string warning);- /// <summary>The kit a Drum Rack track was loaded from, recognised by its pads (the- /// note and name of each), or "" when no kit fits. A rack stays recognised after a- /// pad or two is swapped or renamed, so a saved project reopens with its kit name.</summary>+ /// <summary>The kit a Drum Rack or Nota Rhythm track was loaded from, or "" when no kit+ /// fits. A rack is recognised by its pads (the note and name of each), and stays+ /// recognised after a pad or two is swapped or renamed; a Rhythm remembers its kit.</summary>string Identify(IAudioEngine engine, int trackId);}diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.csindex a8138b6a..170d3b6c 100644--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs@@ -331,6 +331,55 @@ internal static partial class NativeMethods[LibraryImport(Lib, EntryPoint = "nota_track_rhythm_voice_source")]internal static partial int RhythmVoiceSource(IntPtr engine, int trackId, int voice);+ // Nota Rhythm per-voice insert chains + kit label.+ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_count")]+ internal static partial int RhythmVoiceDeviceCount(IntPtr engine, int trackId, int voice);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_add_voice_device")]+ internal static partial int RhythmAddVoiceDevice(IntPtr engine, int trackId, int voice, int kind);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_remove_voice_device")]+ internal static partial int RhythmRemoveVoiceDevice(IntPtr engine, int trackId, int voice, int dev);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_move_voice_device")]+ internal static partial int RhythmMoveVoiceDevice(IntPtr engine, int trackId, int voice, int from, int to);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_name")]+ internal static partial IntPtr RhythmVoiceDeviceName(IntPtr engine, int trackId, int voice, int dev);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_builtin_kind")]+ internal static partial int RhythmVoiceDeviceBuiltinKind(IntPtr engine, int trackId, int voice, int dev);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_count")]+ internal static partial int RhythmVoiceDeviceParamCount(IntPtr engine, int trackId, int voice, int dev);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_name")]+ internal static partial IntPtr RhythmVoiceDeviceParamName(IntPtr engine, int trackId, int voice, int dev, int param);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_min")]+ internal static partial float RhythmVoiceDeviceParamMin(IntPtr engine, int trackId, int voice, int dev, int param);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_max")]+ internal static partial float RhythmVoiceDeviceParamMax(IntPtr engine, int trackId, int voice, int dev, int param);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_get")]+ internal static partial float RhythmVoiceDeviceParamGet(IntPtr engine, int trackId, int voice, int dev, int param);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_param_set")]+ internal static partial void RhythmVoiceDeviceParamSet(IntPtr engine, int trackId, int voice, int dev, int param, float value);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_voice_device_bypassed")]+ internal static partial int RhythmVoiceDeviceBypassed(IntPtr engine, int trackId, int voice, int dev);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_set_voice_device_bypassed")]+ internal static partial void RhythmSetVoiceDeviceBypassed(IntPtr engine, int trackId, int voice, int dev, int bypassed);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_kit_name")]+ internal static partial IntPtr RhythmKitName(IntPtr engine, int trackId);++ [LibraryImport(Lib, EntryPoint = "nota_rhythm_set_kit_name", StringMarshalling = StringMarshalling.Utf8)]+ internal static partial void RhythmSetKitName(IntPtr engine, int trackId, string name);+[LibraryImport(Lib, EntryPoint = "nota_track_grain_play_positions")]internal static partial int TrackGrainPlayPositions(IntPtr engine, int trackId, [Out] float[] outPos, int maxN);diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.csindex 85e68adf..4a77148d 100644--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs@@ -685,6 +685,39 @@ public sealed partial class NotaEnginepublic int RhythmVoiceSource(int trackId, int voice){ ThrowIfDisposed(); return NativeMethods.RhythmVoiceSource(_handle, trackId, voice); }+ public int RhythmVoiceDeviceCount(int trackId, int voice)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceCount(_handle, trackId, voice); }+ public int RhythmAddVoiceDevice(int trackId, int voice, int kind)+ { ThrowIfDisposed(); return NativeMethods.RhythmAddVoiceDevice(_handle, trackId, voice, kind); }+ public bool RhythmRemoveVoiceDevice(int trackId, int voice, int dev)+ { ThrowIfDisposed(); return NativeMethods.RhythmRemoveVoiceDevice(_handle, trackId, voice, dev) != 0; }+ public void RhythmMoveVoiceDevice(int trackId, int voice, int from, int to)+ { ThrowIfDisposed(); NativeMethods.RhythmMoveVoiceDevice(_handle, trackId, voice, from, to); }+ public string RhythmVoiceDeviceName(int trackId, int voice, int dev)+ { ThrowIfDisposed(); return System.Runtime.InteropServices.Marshal.PtrToStringUTF8(NativeMethods.RhythmVoiceDeviceName(_handle, trackId, voice, dev)) ?? ""; }+ public int RhythmVoiceDeviceBuiltinKind(int trackId, int voice, int dev)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceBuiltinKind(_handle, trackId, voice, dev); }+ public int RhythmVoiceDeviceParamCount(int trackId, int voice, int dev)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceParamCount(_handle, trackId, voice, dev); }+ public string RhythmVoiceDeviceParamName(int trackId, int voice, int dev, int param)+ { ThrowIfDisposed(); return System.Runtime.InteropServices.Marshal.PtrToStringUTF8(NativeMethods.RhythmVoiceDeviceParamName(_handle, trackId, voice, dev, param)) ?? ""; }+ public float RhythmVoiceDeviceParamMin(int trackId, int voice, int dev, int param)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceParamMin(_handle, trackId, voice, dev, param); }+ public float RhythmVoiceDeviceParamMax(int trackId, int voice, int dev, int param)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceParamMax(_handle, trackId, voice, dev, param); }+ public float RhythmVoiceDeviceParamGet(int trackId, int voice, int dev, int param)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceParamGet(_handle, trackId, voice, dev, param); }+ public void RhythmVoiceDeviceParamSet(int trackId, int voice, int dev, int param, float value)+ { ThrowIfDisposed(); NativeMethods.RhythmVoiceDeviceParamSet(_handle, trackId, voice, dev, param, value); }+ public bool RhythmVoiceDeviceBypassed(int trackId, int voice, int dev)+ { ThrowIfDisposed(); return NativeMethods.RhythmVoiceDeviceBypassed(_handle, trackId, voice, dev) != 0; }+ public void RhythmSetVoiceDeviceBypassed(int trackId, int voice, int dev, bool bypassed)+ { ThrowIfDisposed(); NativeMethods.RhythmSetVoiceDeviceBypassed(_handle, trackId, voice, dev, bypassed ? 1 : 0); }+ public string RhythmKitName(int trackId)+ { ThrowIfDisposed(); return System.Runtime.InteropServices.Marshal.PtrToStringUTF8(NativeMethods.RhythmKitName(_handle, trackId)) ?? ""; }+ public void RhythmSetKitName(int trackId, string name)+ { ThrowIfDisposed(); NativeMethods.RhythmSetKitName(_handle, trackId, name ?? ""); }+public int GrainPlayPositions(int trackId, float[] outPos){ ThrowIfDisposed(); return NativeMethods.TrackGrainPlayPositions(_handle, trackId, outPos, outPos.Length); }diff --git a/src/managed/Nota.Infrastructure/Kits/DrumKitService.cs b/src/managed/Nota.Infrastructure/Kits/DrumKitService.csindex e12145c7..b2282417 100644--- a/src/managed/Nota.Infrastructure/Kits/DrumKitService.cs+++ b/src/managed/Nota.Infrastructure/Kits/DrumKitService.cs@@ -3,13 +3,19 @@//// IDrumKits over the code-defined kit catalog: renders a kit's one-shots on demand// (KitLibrary) and assembles a Drum Rack from them — one Sampler chain per pad, with-// the pad's trigger note, choke group, pan, gain and name, plus the kit's swing and-// humanize. Loading a kit is an ordinary sequence of engine calls, so the result is an-// ordinary Drum Rack the user can take apart pad by pad.+// the pad's trigger note, choke group, pan, gain, name and effects (KitFx), plus the+// kit's swing and humanize. Loading a kit is an ordinary sequence of engine calls, so the+// result is an ordinary Drum Rack the user can take apart pad by pad.+//+// The same kits load into Nota Rhythm: each of its eight voices takes the kit's pad on the+// voice's own MIDI note (Kick 36, Snare 38, Clap 39, Rim 37, the hats 42 / 46, Tom 45) and+// a percussion pad for Perc, with that pad's effects on the voice's insert chain — so a+// kit sounds the same in either instrument.using System;using System.Collections.Generic;using System.IO;+using System.Linq;using Nota.Application;using Nota.Infrastructure.Kits;@@ -19,6 +25,8 @@ public sealed class DrumKitService : IDrumKits{public string Root => KitLibrary.Root;+ public string DefaultRhythmKit => "kompakt";+public IReadOnlyList<DrumKitInfo> All(){var list = new List<DrumKitInfo>(KitCatalog.All.Count);@@ -55,10 +63,21 @@ public sealed class DrumKitService : IDrumKitsreturn track;}+ public int CreateRhythmTrack(IAudioEngine engine, string id, out string warning)+ {+ var kit = KitCatalog.ById(id);+ if (kit is null) { warning = "Unknown drum kit."; return -1; }+ int track = engine.AddRhythmTrack();+ if (track <= 0) { warning = "Couldn't create a Nota Rhythm track."; return -1; }+ FillRhythm(engine, track, kit, out warning);+ return track;+ }+public bool LoadInto(IAudioEngine engine, int trackId, string id, out string warning){var kit = KitCatalog.ById(id);if (kit is null) { warning = "Unknown drum kit."; return false; }+ if (engine.TrackInstrumentKind(trackId) == RhythmModel.Kind) { FillRhythm(engine, trackId, kit, out warning); return true; }// Clear the existing pads first — a kit replaces the rack's contents rather than// layering onto whatever was there.for (int c = engine.RackChainCount(trackId) - 1; c >= 0; c--) engine.RackRemoveChain(trackId, c);@@ -68,6 +87,9 @@ public sealed class DrumKitService : IDrumKitspublic string Identify(IAudioEngine engine, int trackId){+ // A Rhythm remembers the kit it was loaded from.+ if (engine.TrackInstrumentKind(trackId) == RhythmModel.Kind)+ return KitCatalog.ById(engine.RhythmKitName(trackId)) is { } rk ? rk.Id : "";int chains = engine.RackChainCount(trackId);if (chains <= 0) return "";var pads = new HashSet<(int Note, string Name)>();@@ -113,6 +135,10 @@ public sealed class DrumKitService : IDrumKitsif (pad.Choke > 0) engine.RackSetChainChoke(track, chain, pad.Choke);if (pad.Pan != 0f) engine.RackSetChainPan(track, chain, pad.Pan);if (Math.Abs(pad.Gain - 1f) > 1e-3f) engine.RackSetChainGain(track, chain, pad.Gain);+ int c = chain;+ KitFx.Apply(KitFx.For(kit, pad), k => engine.RackAddChainDevice(track, c, k),+ d => engine.RackChainDeviceParamCount(track, c, d), (d, p) => engine.RackChainDeviceParamName(track, c, d, p),+ (d, p, v) => engine.RackChainDeviceParamSet(track, c, d, p, v));}engine.RackSetSwing(track, kit.Swing);@@ -122,4 +148,63 @@ public sealed class DrumKitService : IDrumKits? "": $"{kit.Name}: {missing.Count} pad(s) couldn't be loaded ({string.Join(", ", missing)}).";}++ /// <summary>The kit's pad for each Rhythm voice (null = the kit has none for it).</summary>+ public static KitPad?[] RhythmVoicePads(KitDefinition kit)+ {+ KitPad? At(int note) => kit.Pads.FirstOrDefault(p => p.Note == note);+ var pads = new KitPad?[RhythmModel.Voices];+ for (int v = 0; v < RhythmModel.Voices; v++) pads[v] = At(RhythmModel.MidiNotes[v]);+ // Tom: the high tom Rhythm's note names, else the nearest tom; Perc: the kit's own+ // percussion (the 47 / 48 / 50 slots), since Rhythm's note 41 is the low tom in a kit.+ pads[6] ??= new[] { 43, 41, 47, 48, 50 }.Select(At).FirstOrDefault(p => p is not null);+ pads[7] = new[] { 47, 50, 48, 51, 41 }.Select(At).FirstOrDefault(p => p is not null && KitFx.RoleOf(p) == PadRole.Perc)+ ?? At(47) ?? pads[7];+ return pads;+ }++ // Loads the kit's samples, levels and effects onto a Rhythm's voices. A voice's sample+ // plays as recorded — tune centred, the full file, no decay shortening, the tone open and+ // no drive (the kit's own effects do the colouring) — and the steps are left alone.+ private static void FillRhythm(IAudioEngine engine, int track, KitDefinition kit, out string warning)+ {+ KitLibrary.Ensure(kit);+ int pc = engine.PluginParamCount(track, -1);+ var idx = new Dictionary<string, int>(StringComparer.Ordinal);+ for (int i = 0; i < pc; i++) idx[engine.PluginParamId(track, -1, i)] = i;+ void Set(string id, float v) { if (idx.TryGetValue(id, out int i)) engine.PluginParamSet(track, -1, i, v); }++ var missing = new List<string>();+ var pads = RhythmVoicePads(kit);+ for (int v = 0; v < RhythmModel.Voices; v++)+ {+ while (engine.RhythmVoiceDeviceCount(track, v) > 0) engine.RhythmRemoveVoiceDevice(track, v, 0);+ var pad = pads[v];+ if (pad is null) { engine.InstrumentAction(track, RhythmModel.A_SetSource, v, 0f); continue; }+ if (!engine.SetRhythmVoiceSample(track, v, KitLibrary.PathOf(kit, pad))) { missing.Add(pad.Name); continue; }+ Set(RhythmModel.Id(v, "tune"), 0.5f);+ Set(RhythmModel.Id(v, "decay"), 1f);+ Set(RhythmModel.Id(v, "tone"), 1f);+ Set(RhythmModel.Id(v, "drive"), 0f);+ Set(RhythmModel.Id(v, "start"), 0f);+ Set(RhythmModel.Id(v, "length"), 1f);+ Set(RhythmModel.Id(v, "reverse"), 0f);+ Set(RhythmModel.Id(v, "level"), Math.Clamp(RhythmLevel * pad.Gain, 0f, 1f));+ Set(RhythmModel.Id(v, "pan"), Math.Clamp(0.5f + pad.Pan * 0.5f, 0f, 1f));+ int vv = v;+ KitFx.Apply(KitFx.For(kit, pad), k => engine.RhythmAddVoiceDevice(track, vv, k),+ d => engine.RhythmVoiceDeviceParamCount(track, vv, d), (d, p) => engine.RhythmVoiceDeviceParamName(track, vv, d, p),+ (d, p, x) => engine.RhythmVoiceDeviceParamSet(track, vv, d, p, x));+ }+ Set("swing", kit.Swing);+ Set("humanize", kit.Humanize);+ engine.RhythmSetKitName(track, kit.Id);++ warning = missing.Count == 0+ ? ""+ : $"{kit.Name}: {missing.Count} voice(s) couldn't be loaded ({string.Join(", ", missing)}).";+ }++ /// <summary>A kit voice's Level: the kit's own gain on the headroom Rhythm leaves a voice.</summary>+ private const float RhythmLevel = 0.8f;}diff --git a/src/managed/Nota.Infrastructure/Kits/KitCatalog.Genres.cs b/src/managed/Nota.Infrastructure/Kits/KitCatalog.Genres.csindex 5e1dd346..a8006508 100644--- a/src/managed/Nota.Infrastructure/Kits/KitCatalog.Genres.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitCatalog.Genres.cs@@ -26,10 +26,12 @@ public static partial class KitCatalogId = "brass-room",Name = "Brass Room",Blurb = "live rock kit · big bright room, panned toms, china",+ FxSpace = 0.7,+ FxDrive = 0.8,Humanize = 0.1f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 56, Decay = 0.55, PitchAmt = 0.8, PitchDecay = 0.022, Tone = 0.55, Body = 0.7, Click = 0.55, Drive = 0.3, Warmth = 0.55, Room = 0.3, RoomSize = 0.7, RoomDecay = 0.35, RoomDamp = 0.35, Width = 0.8, Drift = 0.2, Length = 1.4, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 52, Decay = 0.55, PitchAmt = 0.8, PitchDecay = 0.022, Tone = 0.55, Body = 0.7, Click = 0.55, Drive = 0.3, Warmth = 0.55, Room = 0.3, RoomSize = 0.7, RoomDecay = 0.35, RoomDamp = 0.35, Width = 0.8, Drift = 0.2, Length = 1.4, PeakDb = -1.5 },new() { Name = "Side Stick", Model = DrumModel.Rim, Note = 37, Freq = 510, Decay = 0.05, Tone = 0.55, Body = 0.5, Drive = 0.2, Warmth = 0.5, HpHz = 240, Room = 0.35, RoomSize = 0.7, RoomDecay = 0.35, Width = 0.8, Drift = 0.3, Length = 0.9, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 194, Decay = 0.42, Tone = 0.62, Body = 0.62, Noise = 0.9, NoiseDecay = 0.22, Click = 0.55, Drive = 0.3, Warmth = 0.5, Room = 0.42, RoomSize = 0.75, RoomDecay = 0.4, RoomDamp = 0.3, Width = 0.85, Drift = 0.25, Length = 1.6, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1100,Decay = 0.22, Tone = 0.55, Body = 0.6, Drive = 0.2, Warmth = 0.5, Room = 0.4, RoomSize = 0.7, RoomDecay = 0.35, Width = 0.9, Drift = 0.5, Length = 1.2, PeakDb = -4.5 },@@ -58,10 +60,13 @@ public static partial class KitCatalogId = "breakline",Name = "Breakline",Blurb = "jungle & breakbeat · tuned-up 12-bit break, ghosts and flams",+ FxSpace = 0.8,+ FxDrive = 1.1,+ FxTape = true,Humanize = 0.08f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 62, Decay = 0.32, PitchAmt = 0.9, PitchDecay = 0.018, Tone = 0.6, Body = 0.5, Click = 0.6, Drive = 0.4, Warmth = 0.55, Bits = 12, CrushHz = 32000, HpHz = 35, Room = 0.15, RoomSize = 0.35, RoomDecay = 0.12, Width = 0.6, Drift = 0.2, Length = 0.7, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 54, Decay = 0.32, PitchAmt = 0.9, PitchDecay = 0.018, Tone = 0.6, Body = 0.5, Click = 0.6, Drive = 0.4, Warmth = 0.55, Bits = 12, CrushHz = 32000, HpHz = 35, Room = 0.15, RoomSize = 0.35, RoomDecay = 0.12, Width = 0.6, Drift = 0.2, Length = 0.7, PeakDb = -1.5 },new() { Name = "Ghost Snare",Model = DrumModel.SnareAcoustic,Note = 37, Freq = 250, Decay = 0.12, Tone = 0.6, Body = 0.4, Noise = 0.8, NoiseDecay = 0.06, Click = 0.3, Drive = 0.35, Warmth = 0.5, Bits = 12, CrushHz = 32000, HpHz = 120, Drift = 0.4, Length = 0.35, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 238, Decay = 0.26, Tone = 0.72, Body = 0.55, Noise = 0.95, NoiseDecay = 0.13, Click = 0.7, Drive = 0.45, Warmth = 0.5, Bits = 12, CrushHz = 32000, Room = 0.22, RoomSize = 0.4, RoomDecay = 0.15, Width = 0.7, Drift = 0.25, Length = 0.7, PeakDb = -2 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1250,Decay = 0.16, Tone = 0.62, Body = 0.45, Drive = 0.3, Warmth = 0.45, Bits = 12, CrushHz = 32000, Room = 0.18, Width = 0.7, Drift = 0.5, Length = 0.5, PeakDb = -5 },@@ -90,6 +95,8 @@ public static partial class KitCatalogId = "bunker",Name = "Bunker",Blurb = "warehouse techno · driven kick, rumble, concrete clap",+ FxSpace = 1.2,+ FxDrive = 1.3,Humanize = 0.02f,Pads = new List<KitPad>{@@ -122,11 +129,13 @@ public static partial class KitCatalogId = "pixel",Name = "Pixel",Blurb = "minimal & micro-house · short clicks, blips and ticks",+ FxSpace = 0.8,+ FxDrive = 0.7,Swing = 0.08f,Humanize = 0.03f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 60, Decay = 0.22, PitchAmt = 2.4, PitchDecay = 0.008, Tone = 0.7, Body = 0.3, Click = 0.75, Drive = 0.2, Warmth = 0.4, HpHz = 32, Length = 0.45, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 52, Decay = 0.22, PitchAmt = 2.2, PitchDecay = 0.008, Tone = 0.7, Body = 0.3, Click = 0.75, Drive = 0.2, Warmth = 0.4, HpHz = 32, Length = 0.45, PeakDb = -1.5 },new() { Name = "Click", Model = DrumModel.Block, Note = 37, Freq = 3200,Decay = 0.012, Tone = 0.6, Body = 0.3, Drive = 0.1, Warmth = 0.3, HpHz = 800, Length = 0.08, PeakDb = -10 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 230, Decay = 0.12, Tone = 0.72, Body = 0.3, Noise = 0.9, NoiseDecay = 0.06, Drive = 0.2, Warmth = 0.35, HpHz = 180, Length = 0.3, PeakDb = -3 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1400,Decay = 0.12, Tone = 0.72, Body = 0.3, Drive = 0.15, Warmth = 0.35, HpHz = 400, Room = 0.2, RoomSize = 0.3, RoomDecay = 0.1, Width = 0.9, Drift = 0.4, Length = 0.4, PeakDb = -5 },@@ -155,11 +164,14 @@ public static partial class KitCatalogId = "velvet",Name = "Velvet",Blurb = "jazz brushes · sweeps and taps, soft kick, singing ride",+ FxSpace = 0.8,+ FxDrive = 0.6,+ FxTape = true,Swing = 0.33f,Humanize = 0.18f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 60, Decay = 0.4, PitchAmt = 0.4, PitchDecay = 0.03, Tone = 0.3, Body = 0.7, Click = 0.2, Drive = 0.1, Warmth = 0.65, LpHz = 7000, Room = 0.25, RoomSize = 0.45, RoomDecay = 0.25, RoomDamp = 0.6, Width = 0.6, Drift = 0.25, Length = 1.2, PeakDb = -3 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 52, Decay = 0.4, PitchAmt = 0.4, PitchDecay = 0.03, Tone = 0.3, Body = 0.7, Click = 0.2, Drive = 0.1, Warmth = 0.65, LpHz = 7000, Room = 0.25, RoomSize = 0.45, RoomDecay = 0.25, RoomDamp = 0.6, Width = 0.6, Drift = 0.25, Length = 1.2, PeakDb = -3 },new() { Name = "Cross Stick",Model = DrumModel.Rim, Note = 37, Freq = 480, Decay = 0.06, Tone = 0.45, Body = 0.55, Drive = 0.1, Warmth = 0.55, HpHz = 220, Room = 0.25, RoomSize = 0.45, Width = 0.7, Drift = 0.3, Length = 0.6, PeakDb = -8 },new() { Name = "Brush Snare",Model = DrumModel.SnareAcoustic,Note = 38, Freq = 200, Decay = 0.3, Tone = 0.3, Body = 0.35, Noise = 0.95, NoiseDecay = 0.28, Click = 0.1, Drive = 0.08, Warmth = 0.6, LpHz = 9000, Room = 0.3, RoomSize = 0.45, RoomDecay = 0.25, Width = 0.7, Drift = 0.4, Length = 1.0, PeakDb = -4 },new() { Name = "Brush Sweep",Model = DrumModel.Shaker, Note = 39, Freq = 3800,Decay = 0.22, Tone = 0.35, Body = 0.6, Click = 0.1, Drive = 0.05, Warmth = 0.5, LpHz = 8000, Room = 0.3, RoomSize = 0.45, Width = 0.8, Drift = 0.6, Length = 0.9, PeakDb = -9 },@@ -188,10 +200,12 @@ public static partial class KitCatalogId = "circuit",Name = "Circuit",Blurb = "electro box · snappy snare, sine toms, laser and clave",+ FxSpace = 1.0,+ FxDrive = 1.0,Humanize = 0.03f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAnalog, Note = 36, Freq = 58, Decay = 0.4, PitchAmt = 1.6, PitchDecay = 0.018, Tone = 0.3, Body = 0.5, Click = 0.35, Drive = 0.3, Warmth = 0.5, Drift = 0.35, Length = 0.8, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAnalog, Note = 36, Freq = 51, Decay = 0.4, PitchAmt = 1.4, PitchDecay = 0.018, Tone = 0.3, Body = 0.5, Click = 0.35, Drive = 0.3, Warmth = 0.5, Drift = 0.35, Length = 0.8, PeakDb = -1.5 },new() { Name = "Rim", Model = DrumModel.Rim, Note = 37, Freq = 610, Decay = 0.035, Tone = 0.65, Body = 0.5, Drive = 0.3, Warmth = 0.45, HpHz = 300, Drift = 0.35, Length = 0.2, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAnalog,Note = 38, Freq = 260, Decay = 0.16, Tone = 0.72, Body = 0.35, Noise = 0.95, NoiseDecay = 0.08, Click = 0.45, Drive = 0.3, Warmth = 0.45, HpHz = 150, Drift = 0.35, Length = 0.4, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1300,Decay = 0.16, Tone = 0.65, Body = 0.45, Drive = 0.25, Warmth = 0.45, Drift = 0.5, Length = 0.5, PeakDb = -4 },@@ -220,6 +234,9 @@ public static partial class KitCatalogId = "yard",Name = "Yard",Blurb = "dub & reggae · rimshot in a long room, dropping toms, siren",+ FxSpace = 1.3,+ FxDrive = 0.9,+ FxTape = true,Swing = 0.1f,Humanize = 0.12f,Pads = new List<KitPad>@@ -253,9 +270,11 @@ public static partial class KitCatalogId = "byte",Name = "Byte",Blurb = "8-bit chip · crushed noise hats, pitch drops, coin, square bass",+ FxSpace = 0.7,+ FxDrive = 0.8,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 70, Decay = 0.18, PitchAmt = 5, PitchDecay = 0.012, Tone = 0.6, Body = 0.3, Click = 0.5, Drive = 0.6, Warmth = 0.2, Bits = 5, CrushHz = 11025, HpHz = 30, Length = 0.35, PeakDb = -2 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 58, Decay = 0.18, PitchAmt = 3.6, PitchDecay = 0.012, Tone = 0.6, Body = 0.3, Click = 0.5, Drive = 0.6, Warmth = 0.2, Bits = 5, CrushHz = 11025, HpHz = 30, Length = 0.35, PeakDb = -2 },new() { Name = "Blip", Model = DrumModel.Zap, Note = 37, Freq = 520, Decay = 0.05, PitchAmt = 1, PitchDecay = 0.01, Tone = 0.2, Body = 0.4, Drive = 0.5, Warmth = 0.2, Bits = 5, CrushHz = 11025, Length = 0.12, PeakDb = -8 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 240, Decay = 0.14, Tone = 0.6, Body = 0.3, Noise = 1.0, NoiseDecay = 0.1, Drive = 0.5, Warmth = 0.2, Bits = 5, CrushHz = 11025, Length = 0.3, PeakDb = -3 },new() { Name = "Noise Clap", Model = DrumModel.Clap, Note = 39, Freq = 1200,Decay = 0.12, Tone = 0.6, Body = 0.35, Drive = 0.4, Warmth = 0.2, Bits = 5, CrushHz = 11025, Length = 0.3, PeakDb = -5 },@@ -284,6 +303,8 @@ public static partial class KitCatalogId = "lagoon",Name = "Lagoon",Blurb = "amapiano & afro-house · log drums, shakers, wood and bongo",+ FxSpace = 1.2,+ FxDrive = 0.8,Swing = 0.12f,Humanize = 0.1f,Pads = new List<KitPad>@@ -317,6 +338,8 @@ public static partial class KitCatalogId = "titan",Name = "Titan",Blurb = "cinematic trailer · boom, taiko, war snare, braam, gong",+ FxSpace = 1.5,+ FxDrive = 1.2,Humanize = 0.08f,Pads = new List<KitPad>{@@ -349,11 +372,13 @@ public static partial class KitCatalogId = "shuffle",Name = "Shuffle",Blurb = "UK garage & 2-step · crisp snare, bright hats, sub, heavy swing",+ FxSpace = 1.0,+ FxDrive = 1.0,Swing = 0.28f,Humanize = 0.05f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 54, Decay = 0.3, PitchAmt = 3.2, PitchDecay = 0.011, Tone = 0.6, Body = 0.45, Click = 0.6, Drive = 0.3, Warmth = 0.45, Length = 0.7, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 50, Decay = 0.3, PitchAmt = 2.8, PitchDecay = 0.011, Tone = 0.6, Body = 0.45, Click = 0.6, Drive = 0.3, Warmth = 0.45, Length = 0.7, PeakDb = -1.5 },new() { Name = "Rim", Model = DrumModel.Rim, Note = 37, Freq = 700, Decay = 0.03, Tone = 0.75, Body = 0.55, Drive = 0.3, Warmth = 0.4, HpHz = 400, Room = 0.2, RoomSize = 0.4, Width = 0.8, Drift = 0.3, Length = 0.4, PeakDb = -8 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 215, Decay = 0.2, Tone = 0.68, Body = 0.4, Noise = 0.95, NoiseDecay = 0.1, Drive = 0.3, Warmth = 0.4, HpHz = 160, Room = 0.2, RoomSize = 0.4, RoomDecay = 0.2, Width = 0.8, Drift = 0.2, Length = 0.6, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1350,Decay = 0.2, Tone = 0.68, Body = 0.5, Drive = 0.25, Warmth = 0.4, HpHz = 300, Room = 0.25, RoomSize = 0.45, Width = 0.9, Drift = 0.5, Length = 0.7, PeakDb = -3.5 },@@ -382,10 +407,12 @@ public static partial class KitCatalogId = "mirrorball",Name = "Mirrorball",Blurb = "70s disco · damped dry kit, sizzling open hat, syndrums",+ FxSpace = 1.0,+ FxDrive = 0.8,Humanize = 0.1f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 60, Decay = 0.3, PitchAmt = 0.7, PitchDecay = 0.018, Tone = 0.5, Body = 0.5, Click = 0.55, Drive = 0.2, Warmth = 0.6, LpHz = 9000, Room = 0.1, RoomSize = 0.25, RoomDamp = 0.8, Width = 0.4, Drift = 0.2, Length = 0.7, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 52, Decay = 0.3, PitchAmt = 0.7, PitchDecay = 0.018, Tone = 0.5, Body = 0.5, Click = 0.55, Drive = 0.2, Warmth = 0.6, LpHz = 9000, Room = 0.1, RoomSize = 0.25, RoomDamp = 0.8, Width = 0.4, Drift = 0.2, Length = 0.7, PeakDb = -1.5 },new() { Name = "Side Stick", Model = DrumModel.Rim, Note = 37, Freq = 500, Decay = 0.045, Tone = 0.5, Body = 0.5, Drive = 0.15, Warmth = 0.55, HpHz = 240, Room = 0.12, RoomSize = 0.25, Width = 0.5, Drift = 0.3, Length = 0.3, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 205, Decay = 0.28, Tone = 0.55, Body = 0.5, Noise = 0.85, NoiseDecay = 0.14, Click = 0.45, Drive = 0.2, Warmth = 0.55, LpHz = 11000, Room = 0.14, RoomSize = 0.3, RoomDamp = 0.7, Width = 0.6, Drift = 0.25, Length = 0.7, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1080,Decay = 0.2, Tone = 0.5, Body = 0.5, Drive = 0.15, Warmth = 0.5, Room = 0.2, RoomSize = 0.35, Width = 0.8, Drift = 0.5, Length = 0.7, PeakDb = -4 },@@ -415,6 +442,8 @@ public static partial class KitCatalogId = "pit",Name = "Pit",Blurb = "orchestral percussion · timpani, gran cassa, triangle, clash cymbals",+ FxSpace = 0.5,+ FxDrive = 0.4,Humanize = 0.15f,Pads = new List<KitPad>{@@ -447,9 +476,11 @@ public static partial class KitCatalogId = "hyper",Name = "Hyper",Blurb = "hyperpop & EDM · clipped kick, distorted 808, glitch and dive",+ FxSpace = 1.1,+ FxDrive = 1.3,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 56, Decay = 0.35, PitchAmt = 4.5, PitchDecay = 0.01, Tone = 0.75, Body = 0.55, Click = 0.8, Drive = 0.8, Warmth = 0.3, HpHz = 30, Length = 0.7, PeakDb = -1 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 52, Decay = 0.35, PitchAmt = 3.5, PitchDecay = 0.01, Tone = 0.75, Body = 0.55, Click = 0.8, Drive = 0.8, Warmth = 0.3, HpHz = 30, Length = 0.7, PeakDb = -1 },new() { Name = "Zip", Model = DrumModel.Zap, Note = 37, Freq = 300, Decay = 0.06, PitchAmt = 6, PitchDecay = 0.008, Tone = 0.4, Body = 0.5, Drive = 0.6, Warmth = 0.2, HpHz = 300, Length = 0.2, PeakDb = -7 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 225, Decay = 0.22, Tone = 0.8, Body = 0.45, Noise = 1.0, NoiseDecay = 0.12, Drive = 0.75, Warmth = 0.3, HpHz = 180, Room = 0.25, RoomSize = 0.5, RoomDecay = 0.3, Width = 1.0, Length = 0.8, PeakDb = -2 },new() { Name = "Clap Stack", Model = DrumModel.Clap, Note = 39, Freq = 1500,Decay = 0.25, Tone = 0.8, Body = 0.6, Drive = 0.7, Warmth = 0.3, HpHz = 400, Room = 0.35, RoomSize = 0.6, RoomDecay = 0.4, Width = 1.0, Drift = 0.5, Length = 1.1, PeakDb = -2.5 },@@ -478,11 +509,14 @@ public static partial class KitCatalogId = "crate",Name = "Crate",Blurb = "90s boom bap · 12-bit thump and crack, swung, with a scratch",+ FxSpace = 0.8,+ FxDrive = 1.1,+ FxTape = true,Swing = 0.2f,Humanize = 0.1f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 55, Decay = 0.45, PitchAmt = 0.9, PitchDecay = 0.02, Tone = 0.5, Body = 0.6, Click = 0.6, Drive = 0.5, Warmth = 0.7, Bits = 12, CrushHz = 26040, HpHz = 35, LpHz = 9000, Hiss = 0.2, Drift = 0.2, Length = 0.9, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 51, Decay = 0.45, PitchAmt = 0.9, PitchDecay = 0.02, Tone = 0.5, Body = 0.6, Click = 0.6, Drive = 0.5, Warmth = 0.7, Bits = 12, CrushHz = 26040, HpHz = 35, LpHz = 9000, Hiss = 0.2, Drift = 0.2, Length = 0.9, PeakDb = -1.5 },new() { Name = "Rim", Model = DrumModel.Rim, Note = 37, Freq = 500, Decay = 0.045, Tone = 0.5, Body = 0.5, Drive = 0.4, Warmth = 0.6, Bits = 12, CrushHz = 26040, HpHz = 220, LpHz = 9000, Hiss = 0.2, Drift = 0.3, Length = 0.3, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 200, Decay = 0.32, Tone = 0.62, Body = 0.6, Noise = 0.9, NoiseDecay = 0.16, Click = 0.65, Drive = 0.55, Warmth = 0.65, Bits = 12, CrushHz = 26040, LpHz = 10000, Hiss = 0.2, Room = 0.2, RoomSize = 0.35, RoomDecay = 0.18, RoomDamp = 0.6, Width = 0.6, Drift = 0.25, Length = 0.8, PeakDb = -2 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1000,Decay = 0.2, Tone = 0.45, Body = 0.55, Drive = 0.45, Warmth = 0.6, Bits = 12, CrushHz = 26040, LpHz = 9000, Hiss = 0.2, Room = 0.15, Width = 0.6, Drift = 0.5, Length = 0.6, PeakDb = -4 },diff --git a/src/managed/Nota.Infrastructure/Kits/KitCatalog.cs b/src/managed/Nota.Infrastructure/Kits/KitCatalog.csindex b6e24286..c34b1278 100644--- a/src/managed/Nota.Infrastructure/Kits/KitCatalog.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitCatalog.cs@@ -60,6 +60,8 @@ public static partial class KitCatalogId = "volta",Name = "Volta",Blurb = "warm analog boom · long sub kick, metal hats, cowbell",+ FxSpace = 1.0,+ FxDrive = 1.0,Swing = 0f,Humanize = 0.05f,Pads = new List<KitPad>@@ -92,10 +94,12 @@ public static partial class KitCatalogId = "kompakt",Name = "Kompakt",Blurb = "punchy analog house · clicky kick, noisy snare, bright hats",+ FxSpace = 0.9,+ FxDrive = 1.0,Humanize = 0.04f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 55, Decay = 0.48, PitchAmt = 3.6, PitchDecay = 0.013, Tone = 0.55, Body = 0.55, Click = 0.55, Drive = 0.35, Warmth = 0.5, Drift = 0.2, Length = 1.1, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 51, Decay = 0.48, PitchAmt = 3.0, PitchDecay = 0.013, Tone = 0.55, Body = 0.55, Click = 0.55, Drive = 0.35, Warmth = 0.5, Drift = 0.2, Length = 1.1, PeakDb = -1.5 },new() { Name = "Rim", Model = DrumModel.Rim, Note = 37, Freq = 448, Decay = 0.04, Tone = 0.62, Body = 0.5, Drive = 0.3, Warmth = 0.45, HpHz = 240, Drift = 0.3, Length = 0.25, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 192, Decay = 0.26, Tone = 0.55, Body = 0.45, Noise = 0.9, NoiseDecay = 0.13, Drive = 0.32, Warmth = 0.45, Drift = 0.2, Length = 0.6, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1180,Decay = 0.26, Tone = 0.6, Body = 0.6, Drive = 0.25, Warmth = 0.45, Drift = 0.5, Length = 0.7, PeakDb = -4 },@@ -124,10 +128,13 @@ public static partial class KitCatalogId = "micron",Name = "Micron",Blurb = "small vintage rhythm box · thin, hissy, band-limited",+ FxSpace = 0.7,+ FxDrive = 0.8,+ FxTape = true,Humanize = 0.08f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAnalog, Note = 36, Freq = 62, Decay = 0.42, PitchAmt = 1.9, PitchDecay = 0.02, Tone = 0.35, Body = 0.5, Click = 0.35, Drive = 0.28, Warmth = 0.7, LpHz = 6500, Hiss = 0.35, Drift = 0.6, Length = 0.9, PeakDb = -2 },+ new() { Name = "Kick", Model = DrumModel.KickAnalog, Note = 36, Freq = 54, Decay = 0.42, PitchAmt = 1.5, PitchDecay = 0.02, Tone = 0.35, Body = 0.5, Click = 0.35, Drive = 0.28, Warmth = 0.7, LpHz = 6500, Hiss = 0.35, Drift = 0.6, Length = 0.9, PeakDb = -2 },new() { Name = "Rim", Model = DrumModel.Rim, Note = 37, Freq = 530, Decay = 0.03, Tone = 0.6, Body = 0.35, Drive = 0.3, Warmth = 0.6, HpHz = 300, LpHz = 9000, Hiss = 0.3, Drift = 0.7, Length = 0.2, PeakDb = -10 },new() { Name = "Snare", Model = DrumModel.SnareAnalog,Note = 38, Freq = 238, Decay = 0.19, Tone = 0.72, Body = 0.35, Noise = 0.85, NoiseDecay = 0.09, Click = 0.35, Drive = 0.3, Warmth = 0.65, LpHz = 8500, Hiss = 0.4, Drift = 0.5, Length = 0.5, PeakDb = -3 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1250,Decay = 0.14, Tone = 0.45, Body = 0.4, Drive = 0.25, Warmth = 0.6, LpHz = 8000, Hiss = 0.35, Drift = 0.6, Length = 0.45, PeakDb = -5 },@@ -156,10 +163,12 @@ public static partial class KitCatalogId = "linnwood",Name = "Linnwood",Blurb = "80s PCM drum machine · 8-bit sampled kit, gated snare",+ FxSpace = 1.1,+ FxDrive = 0.9,Humanize = 0.03f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 58, Decay = 0.42, PitchAmt = 0.7, PitchDecay = 0.02, Tone = 0.5, Body = 0.55, Click = 0.45, Drive = 0.25, Warmth = 0.6, Bits = 9, CrushHz = 30000, LpHz = 11000, Drift = 0.15, Length = 0.9, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 52, Decay = 0.42, PitchAmt = 0.7, PitchDecay = 0.02, Tone = 0.5, Body = 0.55, Click = 0.45, Drive = 0.25, Warmth = 0.6, Bits = 9, CrushHz = 30000, LpHz = 11000, Drift = 0.15, Length = 0.9, PeakDb = -1.5 },new() { Name = "Side Stick", Model = DrumModel.Rim, Note = 37, Freq = 520, Decay = 0.045, Tone = 0.5, Body = 0.45, Drive = 0.25, Warmth = 0.5, Bits = 9, CrushHz = 30000, HpHz = 260, Length = 0.25, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 196, Decay = 0.38, Tone = 0.5, Body = 0.6, Noise = 0.85, NoiseDecay = 0.2, Click = 0.45, Drive = 0.28, Warmth = 0.55, Bits = 9, CrushHz = 30000, LpHz = 12000, Room = 0.34, RoomSize = 0.55, RoomDecay = 0.20, RoomDamp = 0.4, Width = 0.6, Length = 1.0, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1150,Decay = 0.24, Tone = 0.5, Body = 0.55, Drive = 0.22, Warmth = 0.5, Bits = 9, CrushHz = 30000, Room = 0.22, RoomSize = 0.45, Width = 0.7, Length = 0.8, PeakDb = -4 },@@ -188,10 +197,12 @@ public static partial class KitCatalogId = "atelier",Name = "Atelier",Blurb = "acoustic studio kit · close-miked, small warm room",+ FxSpace = 0.7,+ FxDrive = 0.7,Humanize = 0.14f,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 54, Decay = 0.5, PitchAmt = 0.75, PitchDecay = 0.022, Tone = 0.45, Body = 0.65, Click = 0.5, Drive = 0.18, Warmth = 0.6, Room = 0.18, RoomSize = 0.35, RoomDecay = 0.12, RoomDamp = 0.65, Width = 0.5, Drift = 0.2, Length = 1.1, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickAcoustic, Note = 36, Freq = 50, Decay = 0.5, PitchAmt = 0.75, PitchDecay = 0.022, Tone = 0.45, Body = 0.65, Click = 0.5, Drive = 0.18, Warmth = 0.6, Room = 0.18, RoomSize = 0.35, RoomDecay = 0.12, RoomDamp = 0.65, Width = 0.5, Drift = 0.2, Length = 1.1, PeakDb = -1.5 },new() { Name = "Side Stick", Model = DrumModel.Rim, Note = 37, Freq = 495, Decay = 0.05, Tone = 0.45, Body = 0.5, Drive = 0.15, Warmth = 0.55, HpHz = 240, Room = 0.2, RoomSize = 0.35, Width = 0.6, Drift = 0.3, Length = 0.35, PeakDb = -9 },new() { Name = "Snare", Model = DrumModel.SnareAcoustic,Note = 38, Freq = 188, Decay = 0.4, Tone = 0.5, Body = 0.6, Noise = 0.8, NoiseDecay = 0.19, Click = 0.42, Drive = 0.2, Warmth = 0.55, Room = 0.26, RoomSize = 0.38, RoomDecay = 0.14, RoomDamp = 0.55, Width = 0.65, Drift = 0.25, Length = 1.1, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1080,Decay = 0.2, Tone = 0.45, Body = 0.5, Drive = 0.15, Warmth = 0.5, Room = 0.25, RoomSize = 0.4, Width = 0.8, Drift = 0.5, Length = 0.8, PeakDb = -4.5 },@@ -220,6 +231,9 @@ public static partial class KitCatalogId = "cellar",Name = "Cellar",Blurb = "dusty vinyl break · filtered, crushed, tape-saturated",+ FxSpace = 0.8,+ FxDrive = 1.1,+ FxTape = true,Swing = 0.16f,Humanize = 0.12f,Pads = new List<KitPad>@@ -253,9 +267,11 @@ public static partial class KitCatalogId = "neon",Name = "Neon",Blurb = "modern sub-forward kit · tuned 808 bass, tight snares, roll hats",+ FxSpace = 1.1,+ FxDrive = 0.9,Pads = new List<KitPad>{- new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 58, Decay = 0.26, PitchAmt = 4.2, PitchDecay = 0.009, Tone = 0.65, Body = 0.4, Click = 0.7, Drive = 0.4, Warmth = 0.45, HpHz = 30, Length = 0.6, PeakDb = -1.5 },+ new() { Name = "Kick", Model = DrumModel.KickPunch, Note = 36, Freq = 51, Decay = 0.26, PitchAmt = 3.2, PitchDecay = 0.009, Tone = 0.65, Body = 0.4, Click = 0.7, Drive = 0.4, Warmth = 0.45, HpHz = 30, Length = 0.6, PeakDb = -1.5 },new() { Name = "808 Bass", Model = DrumModel.SubHit, Note = 37, Freq = 46, Decay = 1.9, PitchAmt = 0.45, PitchDecay = 0.022, Tone = 0.42, Drive = 0.4, Warmth = 0.55, Length = 3.0, PeakDb = -1.5 },new() { Name = "Snare", Model = DrumModel.SnarePunch, Note = 38, Freq = 210, Decay = 0.2, Tone = 0.62, Body = 0.4, Noise = 0.95, NoiseDecay = 0.1, Drive = 0.3, Warmth = 0.4, HpHz = 140, Length = 0.5, PeakDb = -2.5 },new() { Name = "Clap", Model = DrumModel.Clap, Note = 39, Freq = 1320,Decay = 0.18, Tone = 0.7, Body = 0.45, Drive = 0.3, Warmth = 0.4, HpHz = 300, Length = 0.55, PeakDb = -3.5 },@@ -284,6 +300,8 @@ public static partial class KitCatalogId = "foundry",Name = "Foundry",Blurb = "industrial metal · struck plate, pipe and hard-clipped kicks",+ FxSpace = 1.2,+ FxDrive = 1.4,Humanize = 0.06f,Pads = new List<KitPad>{@@ -316,6 +334,8 @@ public static partial class KitCatalogId = "terra",Name = "Terra",Blurb = "hand percussion · congas, bongos, wood and shakers",+ FxSpace = 0.9,+ FxDrive = 0.6,Swing = 0.1f,Humanize = 0.2f,Pads = new List<KitPad>@@ -349,6 +369,8 @@ public static partial class KitCatalogId = "aether",Name = "Aether",Blurb = "ambient & cinematic · soft, spacious, long tails",+ FxSpace = 1.6,+ FxDrive = 0.6,Humanize = 0.18f,Pads = new List<KitPad>{diff --git a/src/managed/Nota.Infrastructure/Kits/KitFx.cs b/src/managed/Nota.Infrastructure/Kits/KitFx.csnew file mode 100644index 00000000..88ef081c--- /dev/null+++ b/src/managed/Nota.Infrastructure/Kits/KitFx.cs@@ -0,0 +1,184 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The factory kits' per-pad effects: the insert chain a pad gets when its kit loads — as+// real built-in devices on the Drum Rack pad's chain, or on the Nota Rhythm voice it lands on,+// from the same recipe. The rendered one-shots stay dry (the Room baked into some of them+// aside); the FX are live devices the user can tweak or delete.+//+// What each voice gets, by its role in the kit:+//+// Kick parallel saturation (Forge, Tube; Tape on the lo-fi kits) — harmonics that+// carry the kick on small speakers while the dry sub and transient stay intact.+// No reverb: a reverberant kick muddies everything under 200 Hz.+// Snare a short plate with a little pre-delay and its lows cut, so the tail opens the+// hit up without clouding the low mids.+// Clap a room, a touch longer and wetter than the snare's — a clap is its space.+// Closed hat a 1/16 ping-pong echo, very quiet and high-passed: it lands on the grid, so it+// adds shimmer and motion to the groove rather than smearing it.+// Open hat, a dotted-1/8 ping-pong delay, quiet, band-limited: the off-grid echo that makes+// percussion a pattern breathe.+// Toms, cymbals, 808 bass: none — they already ring, and a sub needs to stay mono and dry.+//+// A kit scales this with FxSpace (reverb size / decay / level, delay level) and FxDrive (the+// saturation), and FxTape swaps the kick's Tube for Tape. A pad with Room baked into its+// sample gets proportionally less reverb, and none past 0.4.+//+// Params are named as the devices name them and given in the devices' own units: Reverb,+// Delay and Forge are normalized 0..1 (the helpers below map seconds / hertz / dB onto them).+// A reverb or delay keeps its dry at unity — its Dry Level is set against the mix, since the+// devices crossfade dry and wet — so an effect only ever adds to the hit.++using System;+using System.Collections.Generic;++namespace Nota.Infrastructure.Kits;++/// <summary>One effect of a pad's chain: a built-in device kind (as <c>RackAddChainDevice</c>+/// takes it) and the params to set, by the device's param name, in its own units.</summary>+public sealed record FxDevice(int Kind, IReadOnlyList<(string Param, float Value)> Params);++/// <summary>What a pad is in its kit, as far as its effects are concerned.</summary>+public enum PadRole { Kick, Sub, Snare, Clap, ClosedHat, OpenHat, Tom, Cymbal, Perc }++public static class KitFx+{+ public const int Reverb = 2, Delay = 3, Forge = 17;++ /// <summary>The insert chain for <paramref name="pad"/> of <paramref name="kit"/> (empty = none).</summary>+ public static IReadOnlyList<FxDevice> For(KitDefinition kit, KitPad pad)+ {+ double space = kit.FxSpace;+ // Room already rendered into the sample: less reverb on top, none on a wet sample.+ double baked = Math.Clamp(1.0 - pad.Room / 0.4, 0.0, 1.0);+ var fx = new List<FxDevice>();+ switch (RoleOf(pad))+ {+ case PadRole.Kick:+ fx.Add(Saturation(kit.FxTape, kit.FxDrive));+ break;+ case PadRole.Snare:+ if (baked > 0.05) fx.Add(Space(algo: Plate, seconds: 0.85 + 0.45 * space, preMs: 18, size: 0.3 + 0.25 * space,+ lowCutHz: 320, highCutHz: 9000, mix: 0.2 * space * baked));+ break;+ case PadRole.Clap:+ if (baked > 0.05) fx.Add(Space(algo: Room, seconds: 1.0 + 0.6 * space, preMs: 12, size: 0.45 + 0.25 * space,+ lowCutHz: 380, highCutHz: 10000, mix: 0.2 * space * baked));+ break;+ case PadRole.ClosedHat:+ fx.Add(Echo(div: Sixteenth, feedback: 0.12, lowCutHz: 2000, highCutHz: 12000, mix: 0.1 * Math.Sqrt(space)));+ break;+ case PadRole.OpenHat:+ fx.Add(Echo(div: DottedEighth, feedback: 0.22, lowCutHz: 1200, highCutHz: 10000, mix: 0.12 * Math.Sqrt(space)));+ break;+ case PadRole.Perc:+ fx.Add(Echo(div: DottedEighth, feedback: 0.3, lowCutHz: 450, highCutHz: 7500, mix: 0.16 * Math.Sqrt(space)));+ break;+ }+ return fx;+ }++ public static PadRole RoleOf(KitPad pad)+ {+ switch (pad.Model)+ {+ case DrumModel.KickAnalog: case DrumModel.KickPunch: case DrumModel.KickAcoustic: return PadRole.Kick;+ case DrumModel.SubHit: return PadRole.Sub;+ case DrumModel.SnareAnalog: case DrumModel.SnarePunch: case DrumModel.SnareAcoustic: return PadRole.Snare;+ case DrumModel.Clap: return PadRole.Clap;+ case DrumModel.HatMetal: case DrumModel.HatNoise:+ return pad.Name.Contains("Open", StringComparison.OrdinalIgnoreCase) ? PadRole.OpenHat : PadRole.ClosedHat;+ case DrumModel.Cymbal: return PadRole.Cymbal;+ // A tom-model pad outside the tom slots is a pitched percussion voice (log drums).+ case DrumModel.Tom: return pad.Note is 41 or 43 or 45 or 47 or 48 or 50 ? PadRole.Tom : PadRole.Perc;+ default: return PadRole.Perc;+ }+ }++ // ---- devices -------------------------------------------------------------------------++ private const int Room = 1, Plate = 2; // Reverb algorithms: Hall, Room, Plate, Chamber+ private const int Sixteenth = 0, DottedEighth = 3; // Delay's division list: 1/16, 1/8T, 1/8, 1/8., 1/4T, 1/4, 1/4., 1/2++ // Parallel saturation: a few dB of drive into one Tube (or Tape) stage, half wet. The output+ // trim takes back what the wet half adds, so the pad lands at the level it had.+ private static FxDevice Saturation(bool tape, double drive) => new(Forge, new[]+ {+ ("Amount", (float)Math.Clamp(0.14 * drive, 0, 0.5)),+ ("S1 Type", tape ? 2f / 5f : 0f), // Tube / Tape+ ("S1 Drive", (float)Math.Clamp(0.32 * drive, 0, 1)),+ ("S1 On", 1f), ("S2 On", 0f), ("S3 On", 0f),+ ("Routing", 0f),+ ("Tone", 0.46f), // a hair darker: the harmonics, not fizz+ ("Wet", 0.5f),+ ("Output", (float)(0.5 + SaturationTrimDb / 48.0)),+ });++ /// <summary>The output trim of the kick saturation, in dB — measured so the pad's RMS stays+ /// within about a dB of the dry sample's (see the smoke test).</summary>+ public const double SaturationTrimDb = -2.0;++ private static FxDevice Space(int algo, double seconds, double preMs, double size,+ double lowCutHz, double highCutHz, double mix)+ {+ mix = Math.Clamp(mix, 0, 0.6);+ return new(Reverb, new[]+ {+ ("Algorithm", algo / 3f),+ ("Decay", Exp(seconds, 0.2, 12.0)),+ ("Pre-Delay", (float)Math.Clamp(preMs / 200.0, 0, 1)),+ ("Size", (float)Math.Clamp(size, 0, 1)),+ ("Diffusion", 0.7f),+ ("HF Damp", 0.45f),+ ("Low Cut", Exp(lowCutHz, 20, 1000)),+ ("High Cut", Exp(highCutHz, 1000, 20000)),+ ("Width", 0.85f),+ ("Dry/Wet", (float)mix),+ ("Dry Level", UnityDry(mix)),+ });+ }++ private static FxDevice Echo(int div, double feedback, double lowCutHz, double highCutHz, double mix)+ {+ mix = Math.Clamp(mix, 0, 0.6);+ return new(Delay, new[]+ {+ ("Sync", 1f),+ ("Div L", div / 7f), ("Div R", div / 7f), ("Link L/R", 1f),+ ("Ping-Pong", 1f),+ ("Feedback", (float)Math.Clamp(feedback, 0, 0.9)),+ ("Low Cut", Exp(lowCutHz, 20, 2000)),+ ("High Cut", Exp(highCutHz, 200, 20000)),+ ("Wow Depth", 0.05f),+ ("Dry/Wet", (float)mix),+ ("Dry Level", UnityDry(mix)),+ });+ }++ // The devices' exponential knobs: value = lo · (hi / lo)^norm.+ private static float Exp(double v, double lo, double hi) => (float)Math.Clamp(Math.Log(v / lo) / Math.Log(hi / lo), 0, 1);++ // Dry gain is (1 - mix) · 2 · level²; this level keeps it at 1.+ private static float UnityDry(double mix) => (float)Math.Clamp(Math.Sqrt(0.5 / (1 - mix)), 0, 1);++ /// <summary>Builds <paramref name="fx"/> through a chain's device surface: <paramref name="add"/>+ /// appends a device of a kind and returns its index (-1 on failure); the rest address the+ /// device's params by index. Params the device doesn't have are skipped.</summary>+ public static int Apply(IReadOnlyList<FxDevice> fx, Func<int, int> add, Func<int, int> paramCount,+ Func<int, int, string> paramName, Action<int, int, float> set)+ {+ int added = 0;+ foreach (var d in fx)+ {+ int di = add(d.Kind);+ if (di < 0) continue;+ added++;+ int n = paramCount(di);+ var index = new Dictionary<string, int>(StringComparer.Ordinal);+ for (int p = 0; p < n; p++) index[paramName(di, p)] = p;+ foreach (var (name, value) in d.Params)+ if (index.TryGetValue(name, out int pi)) set(di, pi, value);+ }+ return added;+ }+}diff --git a/src/managed/Nota.Infrastructure/Kits/KitLibrary.cs b/src/managed/Nota.Infrastructure/Kits/KitLibrary.csindex bda10abb..ffd59838 100644--- a/src/managed/Nota.Infrastructure/Kits/KitLibrary.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitLibrary.cs@@ -22,7 +22,7 @@ public static class KitLibrary{/// <summary>Bump when the synthesis or the post chain changes in a way that should/// re-render every shipped kit. Recipe edits are caught by the per-kit hash.</summary>- private const int RendererVersion = 1;+ private const int RendererVersion = 2;private const string StampFile = ".kit-stamp";diff --git a/src/managed/Nota.Infrastructure/Kits/KitPad.cs b/src/managed/Nota.Infrastructure/Kits/KitPad.csindex 8a94f403..92c3eee0 100644--- a/src/managed/Nota.Infrastructure/Kits/KitPad.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitPad.cs@@ -165,4 +165,14 @@ public sealed record KitDefinitionpublic float Swing { get; init; }/// <summary>Drum Rack humanize, 0..1.</summary>public float Humanize { get; init; }++ // --- live pad FX (KitFx) — they don't touch the rendered samples ------------------------+ /// <summary>How much space the kit's pad FX add: scales the reverbs' size, decay and level+ /// and the delays' level. 1 = a studio-dry kit's modest room; 0 would leave only the kick+ /// saturation.</summary>+ public double FxSpace { get; init; } = 1.0;+ /// <summary>Scales the kick's parallel saturation.</summary>+ public double FxDrive { get; init; } = 1.0;+ /// <summary>Tape rather than Tube for the kick saturation — the lo-fi and vintage kits.</summary>+ public bool FxTape { get; init; }}diff --git a/src/managed/Nota.Infrastructure/Kits/KitRenderer.cs b/src/managed/Nota.Infrastructure/Kits/KitRenderer.csindex 5e7bef25..283afadd 100644--- a/src/managed/Nota.Infrastructure/Kits/KitRenderer.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitRenderer.cs@@ -94,9 +94,13 @@ public static class KitRendererdouble w = Math.Clamp(pad.Warmth, 0, 1);if (w > 0){+ // The low-mid bump is box on a kick, and the treble roll-off is exactly what a+ // snare or clap cannot spare — both are scaled by what the voice is.+ bool kick = pad.Model is DrumModel.KickAnalog or DrumModel.KickPunch or DrumModel.KickAcoustic or DrumModel.SubHit;+ bool crack = pad.Model is DrumModel.SnareAnalog or DrumModel.SnarePunch or DrumModel.SnareAcoustic or DrumModel.Clap;var shelf = Biquad.LowShelf(160, 1.6 * w, sr);- var air = Biquad.HighShelf(9000, -3.2 * w, sr);- var body = Biquad.Peaking(420, 0.8, 1.1 * w, sr);+ var air = Biquad.HighShelf(9000, -3.2 * w * (crack ? 0.35 : 1.0), sr);+ var body = Biquad.Peaking(420, 0.8, 1.1 * w * (kick ? 0.0 : 1.0), sr);for (int i = 0; i < buf.Length; i++){double x = air.Process(body.Process(shelf.Process(buf[i])));diff --git a/src/managed/Nota.Infrastructure/Kits/KitVoices.cs b/src/managed/Nota.Infrastructure/Kits/KitVoices.csindex ae9fcf2c..9eca8e72 100644--- a/src/managed/Nota.Infrastructure/Kits/KitVoices.cs+++ b/src/managed/Nota.Infrastructure/Kits/KitVoices.cs@@ -20,6 +20,16 @@ internal static class KitVoices{private const double TwoPi = Math.PI * 2;+ // Layer balances of the kick / snare / clap models, set against measured spectra of+ // the whole catalog: a kick's attack mostly below 1 kHz with the click about 10 dB+ // under the body, a snare split roughly evenly between shell (150-400 Hz) and wires+ // (2.5-10 kHz) with a centroid around 3-4 kHz, a clap with ~15 % of its energy above+ // 5 kHz. The tails and the drive stay recipe-driven.+ private const double KickKnock = 0.35, KickClick = 3.0, KickSweepMax = 0.03, KickDrive = 0.7;+ private const double AcKickShell = 1.1, AcKickBeater = 3.0;+ private const double SnShell = 1.0, SnWire = 1.6, SnPunchBody = 2.4, SnRattle = 2.5;+ private const double ClapAir = 0.65;+/// <summary>Renders the dry voice for <paramref name="p"/> into <paramref name="buf"/>/// (mono, <paramref name="sr"/> = the oversampled render rate).</summary>public static void Render(KitPad p, double[] buf, double sr, Rng rng)@@ -87,6 +97,20 @@ internal static class KitVoicesreturn (i == 0 ? 1.0 : rng.NextGauss()) * t * t;}+ // A strike with a controlled area: a half-sine pulse of unit area plus a little noise+ // for the high modes. Excite's burst sums to a random value several times its peak, and+ // a mode that rings slower than the burst integrates all of it — so the shell of a snare+ // came out at a seed-dependent level that buried the wires. Here every mode below+ // ~1 / duration rings at about unity, which is what the mix gains assume.+ private static double Strike(int i, double sr, double ms, Rng rng)+ {+ int n = Math.Max(2, (int)(sr * ms * 0.001));+ if (i >= n) return 0;+ double t = 1.0 - (double)i / n;+ return Math.PI / (2.0 * n) * Math.Sin(Math.PI * i / n)+ + 0.3 * Math.Sqrt(5.0 / n) * rng.NextGauss() * t * t;+ }+// --- kicks -------------------------------------------------------------private static void Kick(KitPad p, double[] buf, double sr, Rng rng, double freq, bool analog)@@ -94,15 +118,21 @@ internal static class KitVoicesdouble ampC = KitDsp.DecayCoef(p.Decay, sr);// The punchy variant drops faster and further: that steep sweep through the// low mids is the "thwack" a long analog ring doesn't have.- double pitchTau = p.PitchDecay * (analog ? 1.0 : 0.55);+ // The sweep is capped at a few tens of milliseconds: a kick that spends 100 ms+ // gliding down through 100-200 Hz is heard as a tom, however low it lands.+ double pitchTau = Math.Min(p.PitchDecay, KickSweepMax) * (analog ? 0.8 : 0.55);double pitchAmt = p.PitchAmt <= 0 ? (analog ? 1.6 : 3.2) : p.PitchAmt;double pitchC = Math.Exp(-1.0 / Math.Max(1e-4, pitchTau * sr));- var knock = new Modal(freq * 4.2, Math.Min(p.Decay * 0.25, 0.09), sr);- var clickBp = Biquad.BandPass(analog ? 1400 : 2600, 0.9, sr);- var clickHp = Biquad.HighPass(600, 0.7071, sr);- var clickN = new NoiseGen(rng, analog ? 9000 : 13000, sr);- double clickC = KitDsp.DecayCoef(analog ? 0.004 : 0.008, sr);+ // The knock is a short upper-body tick, not a ring: held for up to 90 ms at 4.2x the+ // fundamental it was a ~220 Hz "boing" that the ear heard as the kick's pitch.+ var knock = new Modal(freq * 3.2, Math.Min(p.Decay * 0.08, 0.03), sr);+ // The beater click sits in 2.5-4 kHz, where it gives the kick its definition — with+ // it audible, the body can stay low instead of being pushed into the low mids.+ var clickBp = Biquad.BandPass(analog ? 2600 : 3800, 0.7, sr);+ var clickHp = Biquad.HighPass(1100, 0.7071, sr);+ var clickN = new NoiseGen(rng, 15000, sr);+ double clickC = KitDsp.DecayCoef(analog ? 0.007 : 0.011, sr);double env = 1, penv = 1, cenv = 1, ph = 0;double sub = 0.55 + p.Body * 0.65;@@ -112,15 +142,18 @@ internal static class KitVoicesph += f / sr; if (ph >= 1) ph -= 1;double s = Math.Sin(TwoPi * ph) * env * sub;- // Upper body ("knock") — the mid ring that survives on a small speaker.- double exc = Excite(i, sr, 1.2, rng);- s += knock.Process(exc) * p.Tone * 1.4;+ // Upper body ("knock") — the mid tick that survives on a small speaker.+ double exc = Strike(i, sr, 0.5, rng);+ s += knock.Process(exc) * p.Tone * KickKnock;- // Trigger click: filtered noise, not a bare impulse, so it sits in the tone.- double cl = clickHp.Process(clickBp.Process(clickN.Next())) * cenv * p.Click * 2.2;- s += cl;+ // Trigger click: filtered noise, not a bare impulse, so it sits in the tone. It+ // joins after the drive, as it does in the circuits this models — summed before+ // it, the saturating body flattened it to nothing.+ double cl = clickHp.Process(clickBp.Process(clickN.Next())) * cenv * p.Click * KickClick;- buf[i] = KitDsp.Saturate(s, p.Drive, 0.6) * AttackRamp(i, sr);+ // Mostly odd-order drive: the even-order bias doubled the fundamental into the+ // 100-120 Hz range, which is the other half of the "too high" kick.+ buf[i] = (KitDsp.Saturate(s, p.Drive * KickDrive, 0.2) + Math.Tanh(cl)) * AttackRamp(i, sr);env *= ampC; penv *= pitchC; cenv *= clickC;}}@@ -130,14 +163,17 @@ internal static class KitVoices// A struck shell: three modes with different ring times over a short sub, and a// beater transient on top. The mode spacing is inharmonic — a drum shell is not// a string, and harmonic ratios here are exactly what sounds synthetic.+ // The upper shell modes ring for a fraction of the fundamental's time: a real bass+ // drum's overtones are damped by the front head and the port, and when they rang as+ // long as the body the kick read as a tom.var m1 = new Modal(freq, p.Decay * 0.55, sr);- var m2 = new Modal(freq * 1.63, p.Decay * 0.30, sr);- var m3 = new Modal(freq * 2.81, p.Decay * 0.14, sr);- var beaterBp = Biquad.BandPass(2400 + p.Tone * 3600, 0.8, sr);- var beaterHp = Biquad.HighPass(1200, 0.7071, sr);- var beaterN = new NoiseGen(rng, 13000, sr);- double beatC = KitDsp.DecayCoef(0.007, sr);- double subC = KitDsp.DecayCoef(Math.Min(p.Decay * 0.4, 0.16), sr);+ var m2 = new Modal(freq * 1.63, p.Decay * 0.16, sr);+ var m3 = new Modal(freq * 2.81, p.Decay * 0.07, sr);+ var beaterBp = Biquad.BandPass(2400 + p.Tone * 2400, 0.7, sr);+ var beaterHp = Biquad.HighPass(1100, 0.7071, sr);+ var beaterN = new NoiseGen(rng, 14000, sr);+ double beatC = KitDsp.DecayCoef(0.009, sr);+ double subC = KitDsp.DecayCoef(Math.Min(p.Decay * 0.5, 0.22), sr);double pitchC = Math.Exp(-1.0 / Math.Max(1e-4, p.PitchDecay * sr));double subEnv = 1, benv = 1, penv = 1, ph = 0;@@ -147,11 +183,11 @@ internal static class KitVoicesph += f / sr; if (ph >= 1) ph -= 1;double s = Math.Sin(TwoPi * ph) * subEnv * (0.7 + p.Body * 0.5);- double exc = Excite(i, sr, 2.0, rng);- s += (m1.Process(exc) * 1.0 + m2.Process(exc) * 0.5 + m3.Process(exc) * 0.22) * p.Body * 1.6;- s += beaterHp.Process(beaterBp.Process(beaterN.Next())) * benv * p.Click * 3.0;+ double exc = Strike(i, sr, 1.2, rng);+ s += (m1.Process(exc) * 1.0 + m2.Process(exc) * 0.4 + m3.Process(exc) * 0.15) * p.Body * AcKickShell;+ double beater = beaterHp.Process(beaterBp.Process(beaterN.Next())) * benv * p.Click * AcKickBeater;- buf[i] = KitDsp.Saturate(s, p.Drive, 0.4) * AttackRamp(i, sr);+ buf[i] = (KitDsp.Saturate(s, p.Drive * KickDrive, 0.2) + Math.Tanh(beater)) * AttackRamp(i, sr);subEnv *= subC; benv *= beatC; penv *= pitchC;}}@@ -181,31 +217,33 @@ internal static class KitVoices{// Two shell tones a rough fifth-and-a-bit apart plus high-passed noise — the// classic two-oscillator analog snare.- var t1 = new Modal(freq, p.Decay * (0.45 + p.Body * 0.5), sr);- var t2 = new Modal(freq * 1.588, p.Decay * (0.32 + p.Body * 0.4), sr);- var nHp = Biquad.HighPass(900 + p.Tone * 2200, 0.7071, sr);- var nPk = Biquad.Peaking(4200, 1.1, 4 * p.Tone, sr);- var nGen = new NoiseGen(rng, 12000, sr);+ var t1 = new Modal(freq, p.Decay * (0.3 + p.Body * 0.4), sr);+ var t2 = new Modal(freq * 1.588, p.Decay * (0.2 + p.Body * 0.3), sr);+ var nHp = Biquad.HighPass(1100 + p.Tone * 1600, 0.7071, sr);+ var nPk = Biquad.Peaking(5200, 0.9, 3 + 4 * p.Tone, sr);+ var nGen = new NoiseGen(rng, 15000, sr);double nC = KitDsp.DecayCoef(p.NoiseDecay, sr);double snapC = KitDsp.DecayCoef(0.012, sr);double nEnv = 1, snap = 1;for (int i = 0; i < buf.Length; i++){- double exc = Excite(i, sr, 1.0, rng);+ double exc = Strike(i, sr, 0.8, rng);double tone = t1.Process(exc) * 1.0 + t2.Process(exc) * 0.72;double n = nPk.Process(nHp.Process(nGen.Next()));- double s = tone * (1 - p.Tone) * 1.5- + n * nEnv * p.Noise * 2.0- + n * snap * p.Click * 1.5;- buf[i] = KitDsp.Saturate(s, p.Drive, 0.35) * AttackRamp(i, sr);+ double s = tone * (1 - p.Tone * 0.6) * SnShell+ + n * nEnv * p.Noise * SnWire+ + n * snap * p.Click * SnWire * 0.8;+ buf[i] = KitDsp.Saturate(s, p.Drive, 0.25) * AttackRamp(i, sr);nEnv *= nC; snap *= snapC;}}private static void SnarePunch(KitPad p, double[] buf, double sr, Rng rng, double freq){- var t1 = new Modal(freq, p.Decay * 0.3, sr);- var t2 = new Modal(freq * 1.47, p.Decay * 0.22, sr);+ // Body lasts a little longer than in the analog model: the dance snare's weight is a+ // short tonal thump under the noise, and without it the hit was all hiss.+ var t1 = new Modal(freq, p.Decay * 0.45, sr);+ var t2 = new Modal(freq * 1.47, p.Decay * 0.3, sr);var nHp = Biquad.HighPass(260, 0.7071, sr);var nPk = Biquad.Peaking(2600 + p.Tone * 4200, 0.9, 6, sr);var nLp = Biquad.LowPass(7000 + p.Tone * 8000, 0.7071, sr);@@ -215,8 +253,8 @@ internal static class KitVoicesdouble nEnv = 1, bEnv = 1;for (int i = 0; i < buf.Length; i++){- double exc = Excite(i, sr, 0.8, rng);- double tone = (t1.Process(exc) + t2.Process(exc) * 0.6) * p.Body * 1.6;+ double exc = Strike(i, sr, 0.8, rng);+ double tone = (t1.Process(exc) + t2.Process(exc) * 0.6) * p.Body * SnPunchBody;double raw = nGen.Next();double n = nLp.Process(nPk.Process(nHp.Process(raw)));double s = tone + n * (nEnv * 1.1 + bEnv * 0.45) * (0.4 + p.Noise);@@ -229,25 +267,31 @@ internal static class KitVoices{// Shell modes + snare wires + stick crack. The wires are noise with their own// longer, brighter decay; the crack is the 5 ms of broadband the stick makes.- var m1 = new Modal(freq, p.Decay * 0.5, sr);- var m2 = new Modal(freq * 1.52, p.Decay * 0.35, sr);- var m3 = new Modal(freq * 2.34, p.Decay * 0.2, sr);- var wireHp = Biquad.HighPass(1600 + p.Tone * 2400, 0.7071, sr);- var wirePk = Biquad.Peaking(6500, 1.0, 3 + p.Tone * 5, sr);- var crackBp = Biquad.BandPass(3200, 0.7, sr);- var nGen = new NoiseGen(rng, 14000, sr);+ var m1 = new Modal(freq, p.Decay * 0.4, sr);+ var m2 = new Modal(freq * 1.52, p.Decay * 0.28, sr);+ var m3 = new Modal(freq * 2.34, p.Decay * 0.16, sr);+ // The wires have two layers: the bright sizzle, and a lower 1.5-3 kHz rattle that+ // carries the snare on small speakers — with the sizzle alone it read as a hiss+ // sitting on a tom.+ var wireHp = Biquad.HighPass(1500 + p.Tone * 1800, 0.7071, sr);+ var wirePk = Biquad.Peaking(6000, 0.9, 3 + p.Tone * 4, sr);+ var rattleBp = Biquad.BandPass(2200, 0.8, sr);+ var crackBp = Biquad.BandPass(3000, 0.7, sr);+ var nGen = new NoiseGen(rng, 15000, sr);double wireC = KitDsp.DecayCoef(p.NoiseDecay, sr);- double crackC = KitDsp.DecayCoef(0.006, sr);- double wEnv = 1, cEnv = 1;+ double rattleC = KitDsp.DecayCoef(p.NoiseDecay * 0.6, sr);+ double crackC = KitDsp.DecayCoef(0.008, sr);+ double wEnv = 1, rEnv = 1, cEnv = 1;for (int i = 0; i < buf.Length; i++){- double exc = Excite(i, sr, 1.6, rng);- double shell = (m1.Process(exc) + m2.Process(exc) * 0.6 + m3.Process(exc) * 0.3) * p.Body * 1.5;+ double exc = Strike(i, sr, 1.0, rng);+ double shell = (m1.Process(exc) + m2.Process(exc) * 0.6 + m3.Process(exc) * 0.3) * p.Body * SnShell;double raw = nGen.Next();- double wire = wirePk.Process(wireHp.Process(raw)) * wEnv * p.Noise * 1.6;- double crack = crackBp.Process(raw) * cEnv * p.Click * 2.4;- buf[i] = KitDsp.Saturate(shell + wire + crack, p.Drive, 0.3) * AttackRamp(i, sr);- wEnv *= wireC; cEnv *= crackC;+ double wire = wirePk.Process(wireHp.Process(raw)) * wEnv * p.Noise * SnWire+ + rattleBp.Process(raw) * rEnv * p.Noise * SnWire * SnRattle;+ double crack = crackBp.Process(raw) * cEnv * p.Click * SnWire * 1.4;+ buf[i] = KitDsp.Saturate(shell + wire + crack, p.Drive, 0.25) * AttackRamp(i, sr);+ wEnv *= wireC; rEnv *= rattleC; cEnv *= crackC;}}@@ -259,10 +303,13 @@ internal static class KitVoices// then the room-ish tail that follows. The spacing jitter is what stops a clap// from sounding like one flammed noise gate.double[] offs = { 0, 0.0105, 0.0205, 0.0295 };- var bp = Biquad.BandPass(freq, 0.9 + p.Body * 0.8, sr);+ var bp = Biquad.BandPass(freq, 0.8 + p.Body * 0.6, sr);var hp = Biquad.HighPass(420, 0.7071, sr);- var pk = Biquad.Peaking(freq * 2.6, 1.2, 4 * p.Tone, sr);- var nGen = new NoiseGen(rng, 9500, sr);+ var pk = Biquad.Peaking(freq * 2.6, 1.0, 3 + 4 * p.Tone, sr);+ // The skin-on-skin crack above the band: real claps have plenty of energy up to+ // ~10 kHz, and a clap that is only the resonant band sounds muffled.+ var airHp = Biquad.HighPass(Math.Max(2800, freq * 2.4), 0.7071, sr);+ var nGen = new NoiseGen(rng, 15000, sr);double burstC = KitDsp.DecayCoef(0.018, sr);double tailC = KitDsp.DecayCoef(p.Decay, sr);@@ -277,7 +324,8 @@ internal static class KitVoicesif (next < starts.Length && i >= starts[next]) { burst = 1.0 - next * 0.12; next++; }if (i == starts[^1]) tail = 1;double n = nGen.Next();- double s = pk.Process(hp.Process(bp.Process(n))) * (burst * 1.6 + tail * p.Body * 0.8);+ double s = pk.Process(hp.Process(bp.Process(n))) * (burst * 1.6 + tail * p.Body * 0.8)+ + airHp.Process(n) * (burst + tail * p.Body * 0.35) * ClapAir;buf[i] = KitDsp.Saturate(s, p.Drive, 0.25) * AttackRamp(i, sr);burst *= burstC; tail *= tailC;}diff --git a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.csindex 2ad617d0..88eb0dd0 100644--- a/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs+++ b/src/managed/Nota.Infrastructure/Persistence/FactoryPresetCatalog.cs@@ -770,133 +770,8 @@ public sealed class FactoryPresetCatalog : IFactoryPresetsInst("flux", 11, "Vector Dance", ("vecx", 0.50f), ("vecy", 0.50f), ("age", 0.20f), ("motion", 0.60f), ("motrate", 0.6f), ("filter", 0.60f), ("env", 0.60f), ("space", 0.35f), ("listen", 0.90f), ("target", 1f));Inst("flux", 11, "Pitch Wobble", ("vecx", 0.20f), ("vecy", 0.50f), ("age", 0.30f), ("motion", 0.30f), ("filter", 0.55f), ("env", 0.55f), ("space", 0.30f), ("listen", 0.70f), ("target", 1f / 3f));- // ---- Nota Rhythm (kind 12) — drum-machine kits (the sound, not the pattern: applying a- // kit keeps the steps and each voice's sample region). Voices: 0 Kick, 1 Snare,- // 2 Clap, 3 Rim, 4 Closed Hat, 5 Open Hat, 6 Tom, 7 Perc. Param id "v{n}_{p}"- // (tune/decay/punch/tone/drive/level/pan) + globals swing/humanize/accent/volume/glue.- // Decay spans per voice: Kick .06–1.2 s, Snare .05–.5 s, Closed Hat .02–.16 s,- // Open Hat .08–.7 s; pan .5 = centre; glue 0 = off.- // Classic machines- Inst("drums", 12, "808 Kit",- ("v0_tune", 0.16f), ("v0_decay", 0.72f), ("v0_drive", 0.18f),- ("v1_tune", 0.35f), ("v1_decay", 0.4f), ("v1_tone", 0.45f),- ("v2_decay", 0.42f), ("v4_decay", 0.12f), ("v5_decay", 0.55f),- ("swing", 0f), ("accent", 0.7f), ("glue", 0.15f));- Inst("drums", 12, "909 Kit",- ("v0_tune", 0.3f), ("v0_decay", 0.5f), ("v0_punch", 0.7f), ("v0_drive", 0.3f),- ("v1_tune", 0.5f), ("v1_decay", 0.35f), ("v1_tone", 0.6f),- ("v4_decay", 0.14f), ("v5_decay", 0.45f), ("swing", 0.08f), ("accent", 0.75f), ("glue", 0.2f));- Inst("drums", 12, "Deep 808 Sub",- ("v0_tune", 0.08f), ("v0_decay", 0.95f), ("v0_punch", 0.35f), ("v0_drive", 0.12f), ("v0_level", 0.9f),- ("v1_tune", 0.3f), ("v1_decay", 0.45f), ("v1_tone", 0.4f), ("v2_decay", 0.5f),- ("v4_decay", 0.1f), ("v4_level", 0.65f), ("v5_decay", 0.6f), ("v5_level", 0.6f), ("glue", 0.1f));- Inst("drums", 12, "Tight & Dry",- ("v0_decay", 0.3f), ("v0_punch", 0.65f), ("v1_decay", 0.2f), ("v1_punch", 0.6f), ("v2_decay", 0.2f),- ("v3_decay", 0.3f), ("v4_decay", 0.05f), ("v5_decay", 0.25f), ("v6_decay", 0.3f), ("v7_decay", 0.2f),- ("v0_drive", 0.1f), ("v1_drive", 0.1f), ("glue", 0.2f));- Inst("drums", 12, "Wide Stereo",- ("v0_tune", 0.22f), ("v0_decay", 0.55f), ("v3_pan", 0.62f), ("v2_pan", 0.42f),- ("v4_pan", 0.34f), ("v4_decay", 0.13f), ("v5_pan", 0.68f), ("v5_decay", 0.5f),- ("v6_pan", 0.28f), ("v7_pan", 0.74f), ("v7_decay", 0.35f), ("glue", 0.2f));- // House · techno · electro- Inst("drums", 12, "House",- ("v0_tune", 0.28f), ("v0_decay", 0.45f), ("v0_punch", 0.6f),- ("v2_decay", 0.35f), ("v4_decay", 0.16f), ("v5_decay", 0.4f),- ("swing", 0.18f), ("accent", 0.6f), ("glue", 0.25f));- Inst("drums", 12, "Techno",- ("v0_tune", 0.24f), ("v0_decay", 0.5f), ("v0_punch", 0.7f), ("v0_drive", 0.4f),- ("v4_decay", 0.1f), ("v5_decay", 0.5f), ("v7_tune", 0.5f), ("v7_decay", 0.4f),- ("swing", 0f), ("accent", 0.8f), ("glue", 0.3f));- Inst("drums", 12, "Dub Techno",- ("v0_tune", 0.2f), ("v0_decay", 0.62f), ("v0_tone", 0.3f), ("v0_drive", 0.2f),- ("v3_tune", 0.3f), ("v3_decay", 0.75f), ("v3_level", 0.7f),- ("v4_decay", 0.12f), ("v4_tone", 0.4f), ("v5_decay", 0.75f), ("v5_level", 0.55f),- ("v7_tune", 0.35f), ("v7_decay", 0.6f), ("v7_level", 0.55f), ("glue", 0.3f));- Inst("drums", 12, "Minimal Click",- ("v0_tune", 0.3f), ("v0_decay", 0.3f), ("v0_punch", 0.85f), ("v0_drive", 0.05f),- ("v3_tune", 0.7f), ("v3_decay", 0.25f), ("v4_decay", 0.06f), ("v4_tone", 0.7f),- ("v7_tune", 0.72f), ("v7_decay", 0.2f), ("v7_tone", 0.8f), ("swing", 0.06f), ("glue", 0.15f));- Inst("drums", 12, "Big Room",- ("v0_tune", 0.26f), ("v0_decay", 0.5f), ("v0_punch", 0.9f), ("v0_drive", 0.5f), ("v0_level", 0.9f),- ("v1_decay", 0.5f), ("v1_tone", 0.6f), ("v2_decay", 0.62f), ("v2_level", 0.9f),- ("v5_decay", 0.35f), ("accent", 0.85f), ("glue", 0.5f));- Inst("drums", 12, "Electro Funk",- ("v0_tune", 0.2f), ("v0_decay", 0.6f), ("v0_drive", 0.25f), ("v1_tune", 0.42f), ("v1_decay", 0.35f),- ("v2_decay", 0.5f), ("v6_tune", 0.5f), ("v6_decay", 0.5f), ("v4_decay", 0.1f),- ("swing", 0.2f), ("accent", 0.7f), ("glue", 0.2f));- Inst("drums", 12, "Acid Rave",- ("v0_tune", 0.32f), ("v0_decay", 0.45f), ("v0_punch", 0.75f), ("v0_drive", 0.45f),- ("v1_tune", 0.55f), ("v1_tone", 0.65f), ("v1_drive", 0.35f),- ("v4_decay", 0.12f), ("v4_tone", 0.7f), ("v5_decay", 0.5f), ("v5_tone", 0.65f), ("glue", 0.35f));- Inst("drums", 12, "Industrial",- ("v0_tune", 0.2f), ("v0_decay", 0.5f), ("v0_punch", 0.9f), ("v0_drive", 0.85f),- ("v1_tune", 0.35f), ("v1_tone", 0.75f), ("v1_drive", 0.75f), ("v2_drive", 0.6f),- ("v3_drive", 0.7f), ("v4_drive", 0.5f), ("v7_drive", 0.8f), ("v7_tone", 0.9f),- ("accent", 0.9f), ("glue", 0.7f), ("volume", 0.72f));- Inst("drums", 12, "Synthwave",- ("v0_tune", 0.3f), ("v0_decay", 0.5f), ("v1_tune", 0.4f), ("v1_decay", 0.75f), ("v1_tone", 0.45f),- ("v1_punch", 0.3f), ("v2_decay", 0.6f), ("v6_tune", 0.35f), ("v6_decay", 0.62f),- ("v5_decay", 0.45f), ("glue", 0.3f));- // Hip-hop · breaks- Inst("drums", 12, "Trap",- ("v0_tune", 0.1f), ("v0_decay", 0.85f), ("v0_drive", 0.35f),- ("v1_tune", 0.4f), ("v1_decay", 0.3f), ("v4_decay", 0.08f), ("v5_decay", 0.6f),- ("swing", 0.12f), ("accent", 0.85f), ("glue", 0.2f));- Inst("drums", 12, "Lo-Fi",- ("v0_tune", 0.2f), ("v0_decay", 0.55f), ("v0_tone", 0.3f), ("v0_drive", 0.45f),- ("v1_tune", 0.32f), ("v1_decay", 0.42f), ("v1_tone", 0.35f),- ("v4_decay", 0.14f), ("swing", 0.22f), ("humanize", 0.3f), ("accent", 0.5f), ("glue", 0.25f));- Inst("drums", 12, "Boom Bap",- ("v0_tune", 0.25f), ("v0_decay", 0.5f), ("v0_tone", 0.4f), ("v0_drive", 0.35f),- ("v1_tune", 0.38f), ("v1_decay", 0.45f), ("v1_tone", 0.5f), ("v1_drive", 0.3f),- ("v4_decay", 0.12f), ("v4_tone", 0.35f), ("swing", 0.28f), ("humanize", 0.25f), ("glue", 0.35f));- Inst("drums", 12, "Dusty Hip-Hop",- ("v0_tune", 0.22f), ("v0_decay", 0.48f), ("v0_tone", 0.25f), ("v0_drive", 0.55f),- ("v1_tune", 0.3f), ("v1_tone", 0.3f), ("v1_drive", 0.5f), ("v2_drive", 0.4f),- ("v4_tone", 0.25f), ("v4_decay", 0.13f), ("swing", 0.3f), ("humanize", 0.35f), ("glue", 0.4f), ("volume", 0.75f));- Inst("drums", 12, "Breakbeat",- ("v0_tune", 0.28f), ("v0_decay", 0.45f), ("v0_punch", 0.7f), ("v0_drive", 0.3f),- ("v1_tune", 0.5f), ("v1_decay", 0.45f), ("v1_punch", 0.7f), ("v1_drive", 0.3f),- ("v5_decay", 0.4f), ("swing", 0.12f), ("humanize", 0.15f), ("glue", 0.45f));- Inst("drums", 12, "Drum & Bass",- ("v0_tune", 0.35f), ("v0_decay", 0.35f), ("v0_punch", 0.8f), ("v0_drive", 0.2f),- ("v1_tune", 0.62f), ("v1_decay", 0.35f), ("v1_tone", 0.55f), ("v1_punch", 0.7f),- ("v4_decay", 0.1f), ("v5_decay", 0.35f), ("swing", 0.05f), ("glue", 0.4f));- Inst("drums", 12, "UK Garage",- ("v0_tune", 0.27f), ("v0_decay", 0.4f), ("v1_tune", 0.55f), ("v1_decay", 0.3f), ("v2_decay", 0.38f),- ("v3_tune", 0.55f), ("v4_decay", 0.1f), ("v5_decay", 0.35f), ("swing", 0.35f), ("humanize", 0.1f), ("glue", 0.25f));- Inst("drums", 12, "Jersey Club",- ("v0_tune", 0.3f), ("v0_decay", 0.4f), ("v0_punch", 0.75f), ("v1_tune", 0.6f), ("v1_decay", 0.3f),- ("v2_tune", 0.6f), ("v2_decay", 0.35f), ("v4_decay", 0.08f), ("swing", 0.1f), ("accent", 0.8f), ("glue", 0.3f));- Inst("drums", 12, "Footwork",- ("v0_tune", 0.12f), ("v0_decay", 0.8f), ("v0_drive", 0.25f), ("v4_decay", 0.08f),- ("v7_tune", 0.8f), ("v7_decay", 0.25f), ("v6_tune", 0.6f), ("v6_decay", 0.35f), ("glue", 0.2f));- // World · acoustic-ish- Inst("drums", 12, "Afro House",- ("v0_tune", 0.26f), ("v0_decay", 0.45f), ("v6_tune", 0.4f), ("v6_decay", 0.45f), ("v6_pan", 0.4f),- ("v7_tune", 0.45f), ("v7_decay", 0.5f), ("v7_tone", 0.35f), ("v7_pan", 0.62f), ("v3_tune", 0.5f),- ("swing", 0.15f), ("humanize", 0.2f), ("glue", 0.2f));- Inst("drums", 12, "Latin Percussion",- ("v3_tune", 0.62f), ("v3_decay", 0.35f), ("v3_pan", 0.6f), ("v6_tune", 0.55f), ("v6_decay", 0.4f),- ("v6_pan", 0.38f), ("v7_tune", 0.6f), ("v7_tone", 0.7f), ("v7_decay", 0.3f), ("v7_pan", 0.66f),- ("v0_decay", 0.4f), ("swing", 0.12f), ("humanize", 0.25f));- Inst("drums", 12, "Soft Brushes",- ("v0_tune", 0.3f), ("v0_decay", 0.4f), ("v0_punch", 0.2f), ("v0_level", 0.6f),- ("v1_tone", 0.85f), ("v1_decay", 0.6f), ("v1_punch", 0.2f), ("v1_drive", 0f), ("v1_level", 0.6f),- ("v4_tone", 0.85f), ("v4_decay", 0.12f), ("v4_level", 0.55f), ("v5_tone", 0.85f), ("v5_level", 0.5f),- ("swing", 0.45f), ("humanize", 0.4f), ("accent", 0.4f), ("glue", 0.1f));- // Texture- Inst("drums", 12, "Glitch",- ("v0_tune", 0.85f), ("v0_decay", 0.1f), ("v0_punch", 1f), ("v1_decay", 0.08f), ("v1_tone", 0.9f),- ("v2_tune", 1f), ("v2_decay", 0.1f), ("v7_tone", 1f), ("v7_decay", 0.12f), ("v7_drive", 0.6f),- ("v4_decay", 0.02f), ("humanize", 0.5f), ("glue", 0.3f));- Inst("drums", 12, "Ambient Pulse",- ("v0_tune", 0.2f), ("v0_decay", 0.7f), ("v0_tone", 0.3f), ("v0_punch", 0.2f), ("v0_level", 0.65f),- ("v3_level", 0.5f), ("v3_decay", 0.8f), ("v5_decay", 0.9f), ("v5_level", 0.45f), ("v5_tone", 0.3f),- ("v7_tune", 0.3f), ("v7_decay", 0.8f), ("v7_level", 0.45f), ("humanize", 0.2f), ("volume", 0.72f));- Inst("drums", 12, "Metal Perc",- ("v4_tune", 0.8f), ("v4_tone", 0.1f), ("v5_tune", 0.75f), ("v5_tone", 0.15f), ("v5_decay", 0.6f),- ("v7_tune", 0.55f), ("v7_tone", 0.9f), ("v7_decay", 0.55f), ("v3_tune", 0.85f), ("v3_drive", 0.4f), ("glue", 0.2f));+ // ---- Nota Rhythm (kind 12): no presets of its own — its kits are the factory drum kits+ // (KitCatalog), shared with the Drum Rack and loaded by the kit picker / browser.// ---- Nota Monolith (kind 13) — mono Model-D synth. Ranges LO..2' = 0/.2/.4/.6/.8/1;// waves tri/shark/saw/square/wide/narrow = 0/.2/.4/.6/.8/1; tunes bipolar (0.5 = 0).diff --git a/src/managed/Nota.Mcp/Tools/DrumKitTools.cs b/src/managed/Nota.Mcp/Tools/DrumKitTools.csindex 7cab37e7..a69e0f44 100644--- a/src/managed/Nota.Mcp/Tools/DrumKitTools.cs+++ b/src/managed/Nota.Mcp/Tools/DrumKitTools.cs@@ -19,9 +19,10 @@ public sealed class DrumKitTools(IAudioEngine engine, IEngineDispatch dispatch,public sealed record KitLoadResult(int TrackId, int Pads, string Warning);[McpServerTool(Name = "list_drum_kits"), Description(- "List the factory Drum Rack kits: id, name, a one-line description, pad count, and "- + "whether its samples have been rendered yet. Pads follow the General MIDI drum map "- + "on notes 36-51.")]+ "List the factory drum kits (shared by the Drum Rack and Nota Rhythm): id, name, a one-line "+ + "description, pad count, and whether its samples have been rendered yet. Pads follow the "+ + "General MIDI drum map on notes 36-51; each pad carries its own effects (kick saturation, "+ + "snare / clap reverb, hat and percussion delay).")]public Task<KitRow[]> ListDrumKits() => Read(() =>{var all = kits.All();@@ -40,11 +41,30 @@ public sealed class DrumKitTools(IAudioEngine engine, IEngineDispatch dispatch,return new KitLoadResult(t, t > 0 ? E.RackChainCount(t) : 0, warning);});+ [McpServerTool(Name = "add_rhythm_kit_track"), Description(+ "Add a Nota Rhythm (16-step drum machine) track with a factory kit on its eight voices — the kit's "+ + "samples and per-voice effects, the same sounds the Drum Rack gets. Returns the new track id and the "+ + "number of voices loaded.")]+ public Task<KitLoadResult> AddRhythmKitTrack(string kitId) => Mutate(() =>+ {+ int t = kits.CreateRhythmTrack(E, kitId, out string warning);+ return new KitLoadResult(t, t > 0 ? LoadedVoices(t) : 0, warning);+ });+[McpServerTool(Name = "load_drum_kit"), Description(- "Replace the pads of an existing Drum Rack track with a factory kit.")]+ "Replace the pads of an existing Drum Rack track — or the voices of a Nota Rhythm track, keeping its "+ + "steps — with a factory kit.")]public Task<KitLoadResult> LoadDrumKit(int trackId, string kitId) => Mutate(() =>{bool ok = kits.LoadInto(E, trackId, kitId, out string warning);- return new KitLoadResult(ok ? trackId : -1, ok ? E.RackChainCount(trackId) : 0, warning);+ bool rhythm = E.TrackInstrumentKind(trackId) == RhythmModel.Kind;+ return new KitLoadResult(ok ? trackId : -1, !ok ? 0 : rhythm ? LoadedVoices(trackId) : E.RackChainCount(trackId), warning);});++ private int LoadedVoices(int trackId)+ {+ int n = 0;+ for (int v = 0; v < RhythmModel.Voices; v++) if (E.RhythmVoiceSource(trackId, v) == 1) n++;+ return n;+ }}diff --git a/src/managed/Nota.Mcp/Tools/RhythmTools.cs b/src/managed/Nota.Mcp/Tools/RhythmTools.csindex ee771810..dd129dec 100644--- a/src/managed/Nota.Mcp/Tools/RhythmTools.cs+++ b/src/managed/Nota.Mcp/Tools/RhythmTools.cs@@ -224,11 +224,81 @@ public sealed class RhythmTools(IAudioEngine engine, IEngineDispatch dispatch, Iint v = Math.Clamp(voice, 0, Voices - 1);if (!E.SetRhythmVoiceSample(trackId, v, path)) return false;var ids = Ids(trackId);- foreach (var (p, val) in new[] { ("tune", 0.5f), ("start", 0f), ("length", 1f) })+ foreach (var (p, val) in new[] { ("tune", 0.5f), ("tone", 1f), ("start", 0f), ("length", 1f) })if (ids.TryGetValue(RM.Id(v, p), out var i)) E.PluginParamSet(trackId, -1, i, val);return true;});+ // ---- voice FX: each voice's own insert chain of built-in effects ------------------------++ public sealed record FxParam(string Name, float Value, float Min, float Max);+ public sealed record FxDeviceInfo(int Index, string Name, int Kind, bool Bypassed, FxParam[] Params);++ [McpServerTool(Name = "get_rhythm_voice_fx"), Description(+ "The insert effects on one Rhythm voice (0..7 or its name), in signal order: each device's index, name, "+ + "builtin kind, bypass and params (value with its min..max). A factory kit puts saturation on the kick, a "+ + "reverb on the snare and clap and a tempo-synced delay on hats and percussion.")]+ public Task<FxDeviceInfo[]> GetRhythmVoiceFx(int trackId, string voice) => Read(() =>+ {+ int v = VoiceIndex(voice);+ if (v < 0 || E.TrackInstrumentKind(trackId) != RM.Kind) return Array.Empty<FxDeviceInfo>();+ int n = E.RhythmVoiceDeviceCount(trackId, v);+ var list = new FxDeviceInfo[n];+ for (int d = 0; d < n; d++)+ {+ int pc = E.RhythmVoiceDeviceParamCount(trackId, v, d);+ var ps = new FxParam[pc];+ for (int p = 0; p < pc; p++)+ ps[p] = new FxParam(E.RhythmVoiceDeviceParamName(trackId, v, d, p), E.RhythmVoiceDeviceParamGet(trackId, v, d, p),+ E.RhythmVoiceDeviceParamMin(trackId, v, d, p), E.RhythmVoiceDeviceParamMax(trackId, v, d, p));+ list[d] = new FxDeviceInfo(d, E.RhythmVoiceDeviceName(trackId, v, d), E.RhythmVoiceDeviceBuiltinKind(trackId, v, d),+ E.RhythmVoiceDeviceBypassed(trackId, v, d), ps);+ }+ return list;+ });++ [McpServerTool(Name = "add_rhythm_voice_fx"), Description(+ "Append a built-in effect to a Rhythm voice's insert chain. kind: 0 EQ-8, 1 Compressor, 2 Reverb, 3 Delay, "+ + "4 Utility, 6 Valve, 7 Auto Filter, 8 Vintage, 9 Orbit, 10 Auto Shift, 11 Beat Repeat, 12 Crush, "+ + "13 Dynamic EQ, 14 Ceiling, 15 Strata, 16 EQ-3, 17 Forge, 18 Level, 19 Shutter, 20 Chamber, 21 Prism. "+ + "Returns the new device index, or -1.")]+ public Task<int> AddRhythmVoiceFx(int trackId, string voice, int kind) => Mutate(() =>+ {+ int v = VoiceIndex(voice);+ return v < 0 || E.TrackInstrumentKind(trackId) != RM.Kind ? -1 : E.RhythmAddVoiceDevice(trackId, v, kind);+ });++ [McpServerTool(Name = "remove_rhythm_voice_fx"), Description("Remove effect `index` from a Rhythm voice's insert chain.")]+ public Task<bool> RemoveRhythmVoiceFx(int trackId, string voice, int index) => Mutate(() =>+ {+ int v = VoiceIndex(voice);+ return v >= 0 && E.RhythmRemoveVoiceDevice(trackId, v, index);+ });++ [McpServerTool(Name = "set_rhythm_voice_fx"), Description(+ "Set params of effect `index` on a Rhythm voice by name (as get_rhythm_voice_fx lists them, in the device's "+ + "own units — Reverb / Delay / Forge are 0..1), and/or bypass it. Returns what changed.")]+ public Task<string> SetRhythmVoiceFx(int trackId, string voice, int index, Dictionary<string, float>? values = null, bool? bypassed = null) => Mutate(() =>+ {+ int v = VoiceIndex(voice);+ if (v < 0 || index < 0 || index >= E.RhythmVoiceDeviceCount(trackId, v)) return $"error: no effect {index} on voice '{voice}'";+ var done = new List<string>();+ if (values is { Count: > 0 })+ {+ int pc = E.RhythmVoiceDeviceParamCount(trackId, v, index);+ foreach (var (name, val) in values)+ {+ int p = Enumerable.Range(0, pc).FirstOrDefault(i => string.Equals(E.RhythmVoiceDeviceParamName(trackId, v, index, i), name, StringComparison.OrdinalIgnoreCase), -1);+ if (p < 0) { done.Add($"no param '{name}'"); continue; }+ float x = Math.Clamp(val, E.RhythmVoiceDeviceParamMin(trackId, v, index, p), E.RhythmVoiceDeviceParamMax(trackId, v, index, p));+ E.RhythmVoiceDeviceParamSet(trackId, v, index, p, x);+ done.Add($"{name} = {x:0.###}");+ }+ }+ if (bypassed is { } b) { E.RhythmSetVoiceDeviceBypassed(trackId, v, index, b); done.Add(b ? "bypassed" : "active"); }+ return $"{E.RhythmVoiceDeviceName(trackId, v, index)}: {string.Join(" · ", done)}";+ });+private string VoiceLine(int trackId, int v){var p = ReadPattern(trackId);diff --git a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.csindex 4a06243d..1f064a34 100644--- a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs+++ b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs@@ -283,23 +283,24 @@ public sealed partial class BrowserViewModel : ObservableObjectDepth = 1,});}- // Factory drum kits hang under the Drum Rack alongside its presets — a kit is- // what a "preset" means for that device.+ // Factory drum kits hang under the Drum Rack and Nota Rhythm alongside their presets —+ // a kit is what a "preset" means for those two, and both share the one set of kits.if (_kits is not null)- {- var rack = _instrTree.Find(d => d.Kind == BrowserItemKind.BuiltinInstrument && d.BuiltinKind == 4);- if (rack is not null)+ foreach (var (kind, prefix, what) in new[] { (4, "kit:", "pads"), (12, "rhythmkit:", "pads, 8 on the voices") })+ {+ var dev = _instrTree.Find(d => d.Kind == BrowserItemKind.BuiltinInstrument && d.BuiltinKind == kind);+ if (dev is null) continue;foreach (var kit in _kits.All())- rack.Children.Add(new BrowserItem+ dev.Children.Add(new BrowserItem{Name = kit.Name,Kind = BrowserItemKind.Preset,Sub = "kit",- Tip = $"{kit.Blurb} · {kit.PadCount} pads",- Path = "kit:" + kit.Id,+ Tip = $"{kit.Blurb} · {kit.PadCount} {what}",+ Path = prefix + kit.Id,Depth = 1,});- }+ }// Preset groups start collapsed; the user expands a device to reveal its presets.foreach (var tree in new[] { _instrTree, _fxTree, _midiTree })diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.hindex 9c5b6406..b64d478c 100644--- a/src/native/nota.engine/include/nota/nota_engine.h+++ b/src/native/nota.engine/include/nota/nota_engine.h@@ -402,6 +402,26 @@ NOTA_API void nota_track_instrument_action(NotaEngine* engine, int32_t track_NOTA_API int32_t nota_track_rhythm_set_voice_sample(NotaEngine* engine, int32_t track_id, int32_t voice, const char* path);NOTA_API int32_t nota_track_rhythm_voice_info(const NotaEngine* engine, int32_t track_id, int32_t voice, NotaSamplerInfo* out);NOTA_API int32_t nota_track_rhythm_voice_source(const NotaEngine* engine, int32_t track_id, int32_t voice);+/* Nota Rhythm per-voice insert chains: built-in effects (the rack chain kinds 0..21 except 5) run on+ * one voice's signal before the kit bus. voice 0..7; dev indexes the voice's chain. add returns the+ * new index or -1; remove/move return 1 on success. Params use each device's own units (min..max).+ * The kit label names the factory kit the voices were loaded from ("" = none); display only. */+NOTA_API int32_t nota_rhythm_voice_device_count(const NotaEngine* engine, int32_t track_id, int32_t voice);+NOTA_API int32_t nota_rhythm_add_voice_device(NotaEngine* engine, int32_t track_id, int32_t voice, int32_t device_kind);+NOTA_API int32_t nota_rhythm_remove_voice_device(NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev);+NOTA_API int32_t nota_rhythm_move_voice_device(NotaEngine* engine, int32_t track_id, int32_t voice, int32_t from_index, int32_t to_index);+NOTA_API const char* nota_rhythm_voice_device_name(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev);+NOTA_API int32_t nota_rhythm_voice_device_builtin_kind(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev);+NOTA_API int32_t nota_rhythm_voice_device_param_count(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev);+NOTA_API const char* nota_rhythm_voice_device_param_name(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t param);+NOTA_API float nota_rhythm_voice_device_param_min(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t param);+NOTA_API float nota_rhythm_voice_device_param_max(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t param);+NOTA_API float nota_rhythm_voice_device_param_get(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t param);+NOTA_API void nota_rhythm_voice_device_param_set(NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t param, float value);+NOTA_API int32_t nota_rhythm_voice_device_bypassed(const NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev);+NOTA_API void nota_rhythm_set_voice_device_bypassed(NotaEngine* engine, int32_t track_id, int32_t voice, int32_t dev, int32_t bypassed);+NOTA_API const char* nota_rhythm_kit_name(const NotaEngine* engine, int32_t track_id);+NOTA_API void nota_rhythm_set_kit_name(NotaEngine* engine, int32_t track_id, const char* name);/* Adds an instrument track with the built-in sampler loaded from a file.* Returns id (>0), or 0 on failure (decode error). */NOTA_API int32_t nota_engine_add_sampler_track(NotaEngine* engine, const char* path_utf8,diff --git a/src/native/nota.engine/src/BuiltinDevices.h b/src/native/nota.engine/src/BuiltinDevices.hnew file mode 100644index 00000000..9b4ae0cd--- /dev/null+++ b/src/native/nota.engine/src/BuiltinDevices.h@@ -0,0 +1,68 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The built-in effects a nested chain can hold — a rack's chains (RackCore) and a Nota Rhythm+// voice's insert chain — by their builtinKind. One factory for both, so a chain device means+// the same thing wherever it lives and a kit's FX recipe (Drum Rack pad or Rhythm voice)+// builds the same devices. Kind 5 (the Audio Effect Rack itself), the Engine-only devices+// (Lens / Flanger / Phaser / Chorus) and hosted plugins are not built here.++#pragma once++#include "Device.h"++#include "Eq.h"+#include "Compressor.h"+#include "Reverb.h"+#include "Delay.h"+#include "Utility.h"+#include "Amp.h"+#include "AutoFilter.h"+#include "Vintage.h"+#include "AutoPan.h"+#include "AutoShift.h"+#include "BeatRepeat.h"+#include "Crush.h"+#include "DynamicEq.h"+#include "Ceiling.h"+#include "Strata.h"+#include "Eq3.h"+#include "Forge.h"+#include "AutoGain.h"+#include "Shutter.h"+#include "Chamber.h"+#include "Prism.h"++#include <cstdint>+#include <memory>++namespace nota {++inline std::shared_ptr<Device> makeChainDevice(int32_t kind) {+ switch (kind) {+ case 0: return std::make_shared<Eq>();+ case 1: return std::make_shared<Compressor>();+ case 2: return std::make_shared<Reverb>();+ case 3: return std::make_shared<Delay>();+ case 4: return std::make_shared<Utility>();+ case 6: return std::make_shared<Amp>();+ case 7: return std::make_shared<AutoFilter>();+ case 8: return std::make_shared<Vintage>();+ case 9: return std::make_shared<AutoPan>();+ case 10: return std::make_shared<AutoShift>();+ case 11: return std::make_shared<BeatRepeat>();+ case 12: return std::make_shared<Crush>();+ case 13: return std::make_shared<DynamicEq>();+ case 14: return std::make_shared<Ceiling>();+ case 15: return std::make_shared<Strata>();+ case 16: return std::make_shared<Eq3>();+ case 17: return std::make_shared<Forge>();+ case 18: return std::make_shared<AutoGain>();+ case 19: return std::make_shared<Shutter>();+ case 20: return std::make_shared<Chamber>();+ case 21: return std::make_shared<Prism>();+ default: return nullptr; // 5 = Effect Rack (nesting) / plugin: not via this factory+ }+}++} // namespace notadiff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex 34e33113..35a7254a 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -519,6 +519,14 @@ public:bool setRhythmVoiceSample(int32_t trackId, int32_t voice, const std::string& path); // Phase 2bool rhythmVoiceInfo(int32_t trackId, int32_t voice, NotaSamplerInfo* out) const; // sample id per voiceint32_t rhythmVoiceSource(int32_t trackId, int32_t voice) const; // 0 Synth, 1 Sample+ // Nota Rhythm per-voice insert chains (built-in devices) + the kit label.+ int32_t rhythmVoiceDeviceCount(int32_t trackId, int32_t voice) const;+ int32_t rhythmAddVoiceDevice(int32_t trackId, int32_t voice, int32_t kind);+ bool rhythmRemoveVoiceDevice(int32_t trackId, int32_t voice, int32_t dev);+ bool rhythmMoveVoiceDevice(int32_t trackId, int32_t voice, int32_t from, int32_t to);+ Device* rhythmVoiceDevice(int32_t trackId, int32_t voice, int32_t dev) const;+ std::string rhythmKitName(int32_t trackId) const;+ void setRhythmKitName(int32_t trackId, const std::string& name);bool setTrackGrainSample(int32_t trackId, const std::string& path, int32_t rootNote);int32_t addSamplerTrack(const std::string& path, int32_t rootNote, bool loop);int32_t addSamplerInstrumentTrack(); // empty Sampler (sample loaded later)diff --git a/src/native/nota.engine/src/Engine_Tracks.cpp b/src/native/nota.engine/src/Engine_Tracks.cppindex b7f13f14..d09d1c80 100644--- a/src/native/nota.engine/src/Engine_Tracks.cpp+++ b/src/native/nota.engine/src/Engine_Tracks.cpp@@ -591,6 +591,33 @@ int32_t Engine::rhythmVoiceSource(int32_t trackId, int32_t voice) const {return rh ? rh->voiceSource(voice) : 0;}+// Nota Rhythm voice FX. The machine swaps its chains as snapshots itself (like a rack), so+// these edit the live instrument in place — a clone would drop the running voices.+static RhythmMachine* rhythmOf(const std::shared_ptr<Track>& t) {+ return t ? dynamic_cast<RhythmMachine*>(t->instrument.get()) : nullptr;+}+int32_t Engine::rhythmVoiceDeviceCount(int32_t trackId, int32_t voice) const {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh ? rh->voiceDeviceCount(voice) : 0;+}+int32_t Engine::rhythmAddVoiceDevice(int32_t trackId, int32_t voice, int32_t kind) {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh ? rh->addVoiceDevice(voice, kind) : -1;+}+bool Engine::rhythmRemoveVoiceDevice(int32_t trackId, int32_t voice, int32_t dev) {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh && rh->removeVoiceDevice(voice, dev);+}+bool Engine::rhythmMoveVoiceDevice(int32_t trackId, int32_t voice, int32_t from, int32_t to) {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh && rh->moveVoiceDevice(voice, from, to);+}+Device* Engine::rhythmVoiceDevice(int32_t trackId, int32_t voice, int32_t dev) const {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh ? rh->voiceDevice(voice, dev) : nullptr;+}+std::string Engine::rhythmKitName(int32_t trackId) const {+ auto* rh = rhythmOf(findTrackAuthoring(trackId)); return rh ? rh->kitName() : std::string{};+}+void Engine::setRhythmKitName(int32_t trackId, const std::string& name) {+ if (auto* rh = rhythmOf(findTrackAuthoring(trackId))) rh->setKitName(name);+}+int32_t Engine::grainPlayPositions(int32_t trackId, float* out, int32_t maxN) const {if (!out || maxN <= 0) return 0;auto t = findTrackAuthoring(trackId);diff --git a/src/native/nota.engine/src/RackCore.h b/src/native/nota.engine/src/RackCore.hindex e7ee1ea7..d418371a 100644--- a/src/native/nota.engine/src/RackCore.h+++ b/src/native/nota.engine/src/RackCore.h@@ -35,27 +35,7 @@#include "GrainSynth.h"#include "Sampler.h"#include "SampleBuffer.h"-#include "Eq.h"-#include "Compressor.h"-#include "Reverb.h"-#include "Delay.h"-#include "Utility.h"-#include "Amp.h"-#include "AutoFilter.h"-#include "Vintage.h"-#include "AutoPan.h"-#include "AutoShift.h"-#include "BeatRepeat.h"-#include "Crush.h"-#include "DynamicEq.h"-#include "Ceiling.h"-#include "Strata.h"-#include "Eq3.h"-#include "Forge.h"-#include "AutoGain.h"-#include "Shutter.h"-#include "Chamber.h"-#include "Prism.h"+#include "BuiltinDevices.h"#include <algorithm>#include <atomic>@@ -151,6 +131,17 @@ public:}}+ // The DAW tempo for tempo-synced chain children (a synced Delay, Auto Filter, Auto Pan …):+ // without it they ran on their free times inside a rack. Audio thread, once per block.+ void forwardTempo(double beatStart, double spb, bool playing) {+ RackState* st = live();+ if (!st) return;+ for (auto& c : st->chains) {+ if (c.instrument) c.instrument->setTransport(beatStart, spb, playing);+ for (auto& d : c.devices) if (d) d->setTransport(beatStart, spb, playing);+ }+ }+// Sample rate + max block; forwarded to every child. Message thread.void setRates(double sr, int32_t maxBlock) {sampleRate_ = sr > 0 ? sr : 44100.0;@@ -675,32 +666,7 @@ public:}}protected:- static std::shared_ptr<Device> makeDevice(int32_t kind) {- switch (kind) {- case 0: return std::make_shared<Eq>();- case 1: return std::make_shared<Compressor>();- case 2: return std::make_shared<Reverb>();- case 3: return std::make_shared<Delay>();- case 4: return std::make_shared<Utility>();- case 6: return std::make_shared<Amp>();- case 7: return std::make_shared<AutoFilter>();- case 8: return std::make_shared<Vintage>();- case 9: return std::make_shared<AutoPan>();- case 10: return std::make_shared<AutoShift>();- case 11: return std::make_shared<BeatRepeat>();- case 12: return std::make_shared<Crush>();- case 13: return std::make_shared<DynamicEq>();- case 14: return std::make_shared<Ceiling>();- case 15: return std::make_shared<Strata>();- case 16: return std::make_shared<Eq3>();- case 17: return std::make_shared<Forge>();- case 18: return std::make_shared<AutoGain>();- case 19: return std::make_shared<Shutter>();- case 20: return std::make_shared<Chamber>();- case 21: return std::make_shared<Prism>();- default: return nullptr; // 5 = Effect Rack (nesting) / plugin: not via this factory- }- }+ static std::shared_ptr<Device> makeDevice(int32_t kind) { return makeChainDevice(kind); }// Macro response curve applied to the 0..1 value before mapping to [min,max].static float applyCurve(float v, int32_t curve) {diff --git a/src/native/nota.engine/src/RackDevice.h b/src/native/nota.engine/src/RackDevice.hindex 9b203f78..43fc836c 100644--- a/src/native/nota.engine/src/RackDevice.h+++ b/src/native/nota.engine/src/RackDevice.h@@ -30,6 +30,7 @@ public:// Forward the DAW transport to every chain child (nested plugins sync too).void setTransportInfo(const TransportInfo& ti) override { forwardTransport(ti); }+ void setTransport(double beatStart, double spb, bool playing) override { forwardTempo(beatStart, spb, playing); }// ---- in-place processing: Parallel / Series / Select + dry-wet + gain ----void process(float* buf, int32_t frames) override {diff --git a/src/native/nota.engine/src/RackInstrument.h b/src/native/nota.engine/src/RackInstrument.hindex 31ef1f1e..de6dfc99 100644--- a/src/native/nota.engine/src/RackInstrument.h+++ b/src/native/nota.engine/src/RackInstrument.h@@ -30,6 +30,7 @@ public:// Forward the DAW transport to every chain child (nested plugins sync too).void setTransportInfo(const TransportInfo& ti) override { forwardTransport(ti); }+ void setTransport(double beatStart, double spb, bool playing) override { forwardTempo(beatStart, spb, playing); }// ---- note fan-out: a note reaches a chain only if it's inside its key/vel zone --void noteOn(int32_t pitch, float velocity) override {diff --git a/src/native/nota.engine/src/RhythmMachine.h b/src/native/nota.engine/src/RhythmMachine.hindex 15317d0f..836c382d 100644--- a/src/native/nota.engine/src/RhythmMachine.h+++ b/src/native/nota.engine/src/RhythmMachine.h@@ -17,18 +17,26 @@//// Bus: the voices sum through Glue (a gentle compressor) into Volume.//+// Voice FX: every voice has its own insert chain of built-in effects (the same devices a+// Drum Rack pad chain holds — BuiltinDevices.h), run on that voice's stereo signal before the+// sum, so a snare can have its reverb and a kick its saturation. The chains swap as immutable+// snapshots (structural edits on the message thread, the audio thread reads one pointer) and+// keep processing after a hit ends, so tails ring out. A voice without a chain skips it.+//// The 7 per-voice knobs (Tune/Decay/Punch/Tone/Drive/Level/Pan) + 4 globals ride the plugin-// param interface (normalized 0..1) → automation / persist / clone for free. Appended after// them (param order is the persisted layout — append only): per-voice sample Start / Length /// Reverse, then Glue (a bus compressor on the kit sum). The step patterns are structural// state (getState/setState blob + the action() UI channel), not params. A step is on/off with-// a velocity (a "quiet" step is just a low one) and an accent flag. Header-only, allocation--// free after construction. Name & DSP are Nota's own.+// a velocity (a "quiet" step is just a low one) and an accent flag. The voice FX chains and a+// kit label follow the pattern data in the same blob, tagged, so an older reader stops before+// them. Header-only, allocation-free on the audio thread. Name & DSP are Nota's own.#pragma once#include "Instrument.h"#include "SampleBuffer.h"+#include "BuiltinDevices.h"#include <algorithm>#include <atomic>@@ -84,6 +92,7 @@ public:scope_[S_Step].store(-1.0f, std::memory_order_relaxed);for (int v = 0; v < kVoices; ++v) scope_[S_Pos0 + v].store(-1.0f, std::memory_order_relaxed);clearAll();+ commitFx(std::make_shared<FxState>());// A minimal four-on-the-floor so a fresh instance makes a sound.for (int s = 0; s < 16; s += 4) { on_[0][0][s] = 1; vel_[0][0][s] = 200; }on_[0][4][2] = on_[0][4][6] = on_[0][4][10] = on_[0][4][14] = 1; // closed hat off-beats@@ -93,11 +102,21 @@ public:int32_t kind() const override { return 12; }const char* displayName() const override { return "Nota Rhythm"; }- void setSampleRate(double sr) override { sampleRate_ = sr > 0 ? sr : 44100.0; }+ void setSampleRate(double sr) override {+ sampleRate_ = sr > 0 ? sr : 44100.0;+ if (fxAuthoring_)+ for (auto& ch : fxAuthoring_->chain) for (auto& d : ch) if (d) d->setSampleRate(sampleRate_, kChunk);+ }void setTransport(double beatStart, double spb, bool playing) override {if (spb > 0.0) spb_ = spb;beatStart_ = beatStart; playing_ = playing;+ if (FxState* fx = fxLive_.load(std::memory_order_acquire)) // tempo-synced voice FX (a synced Delay)+ for (auto& ch : fx->chain) for (auto& d : ch) if (d) d->setTransport(beatStart, spb, playing);+ }+ void setTransportInfo(const TransportInfo& ti) override {+ if (FxState* fx = fxLive_.load(std::memory_order_acquire))+ for (auto& ch : fx->chain) for (auto& d : ch) if (d) d->setTransportInfo(ti);}// ---- parameters -------------------------------------------------------@@ -164,18 +183,88 @@ public:int64_t voiceSampleId(int v) const { return (v >= 0 && v < kVoices && smp_[v]) ? smp_[v]->id : 0; }std::shared_ptr<SampleBuffer> voiceSampleBuf(int v) const { return (v >= 0 && v < kVoices) ? smp_[v] : nullptr; }+ // ---- per-voice FX chains (message thread; the audio thread reads the live snapshot) ----+ int32_t voiceDeviceCount(int v) const {+ FxState* fx = fxLive_.load(std::memory_order_acquire);+ return (fx && v >= 0 && v < kVoices) ? static_cast<int32_t>(fx->chain[v].size()) : 0;+ }+ Device* voiceDevice(int v, int d) const {+ FxState* fx = fxLive_.load(std::memory_order_acquire);+ if (!fx || v < 0 || v >= kVoices || d < 0 || d >= static_cast<int>(fx->chain[v].size())) return nullptr;+ return fx->chain[v][d].get();+ }+ int32_t addVoiceDevice(int v, int32_t kind) {+ if (v < 0 || v >= kVoices || voiceDeviceCount(v) >= kMaxFx) return -1;+ auto dev = makeChainDevice(kind);+ if (!dev) return -1;+ dev->setSampleRate(sampleRate_, kChunk);+ auto ns = copyFx();+ ns->chain[v].push_back(std::move(dev));+ const int32_t idx = static_cast<int32_t>(ns->chain[v].size()) - 1;+ commitFx(ns);+ return idx;+ }+ bool removeVoiceDevice(int v, int d) {+ auto ns = copyFx();+ if (v < 0 || v >= kVoices || d < 0 || d >= static_cast<int>(ns->chain[v].size())) return false;+ ns->chain[v].erase(ns->chain[v].begin() + d);+ commitFx(ns);+ return true;+ }+ bool moveVoiceDevice(int v, int from, int to) {+ auto ns = copyFx();+ if (v < 0 || v >= kVoices) return false;+ auto& c = ns->chain[v];+ const int n = static_cast<int>(c.size());+ if (from < 0 || from >= n) return false;+ to = std::clamp(to, 0, n - 1);+ if (to == from) return true;+ auto x = c[from];+ c.erase(c.begin() + from);+ c.insert(c.begin() + to, x);+ commitFx(ns);+ return true;+ }+ void clearVoiceDevices(int v) {+ auto ns = copyFx();+ if (v < 0 || v >= kVoices || ns->chain[v].empty()) return;+ ns->chain[v].clear();+ commitFx(ns);+ }+ // The factory kit the voices came from ("" = none / hand-built) — display metadata only.+ const std::string& kitName() const { return kit_; }+ void setKitName(const std::string& k) { kit_ = k.substr(0, 64); }+// ---- project state ----------------------------------------------------// Layout: [u32 magic]['kNumParams' floats]['bank','sel',2 reserved]['on,vel,acc' per bank/voice/step]// ['src' per voice]. RTH1 (before the sample region + Glue) carries kLegacyParams floats.std::vector<uint8_t> getState() const override {std::vector<uint8_t> b;b.reserve(8 + kNumParams * 4 + kBanks * kVoices * kSteps * 3);- auto putU32 = [&](uint32_t v) { for (int i = 0; i < 4; ++i) b.push_back((uint8_t)(v >> (i * 8))); };- putU32(kMagic);+ putU32(b, kMagic);for (int i = 0; i < kNumParams; ++i) { float v = pn_[i].load(std::memory_order_relaxed); uint8_t t[4]; std::memcpy(t, &v, 4); b.insert(b.end(), t, t + 4); }b.push_back(bank_); b.push_back(selVoice_); b.push_back(0); b.push_back(0);for (int bk = 0; bk < kBanks; ++bk) for (int v = 0; v < kVoices; ++v) for (int s = 0; s < kSteps; ++s) { b.push_back(on_[bk][v][s]); b.push_back(vel_[bk][v][s]); b.push_back(acc_[bk][v][s]); }for (int v = 0; v < kVoices; ++v) b.push_back(src_[v]); // per-voice source (buffers persist separately)+ // Voice FX + kit label, tagged "RFX1": per voice a device count, then per device its+ // builtinKind, bypass flag and params; then the kit label.+ putU32(b, kFxMagic);+ FxState* fx = fxLive_.load(std::memory_order_acquire);+ for (int v = 0; v < kVoices; ++v) {+ const auto* ch = fx ? &fx->chain[v] : nullptr;+ const int n = ch ? static_cast<int>(ch->size()) : 0;+ b.push_back(static_cast<uint8_t>(n));+ for (int d = 0; d < n; ++d) {+ const Device* dev = (*ch)[d].get();+ putU32(b, static_cast<uint32_t>(dev->builtinKind()));+ b.push_back(dev->bypassed() ? 1 : 0);+ const int32_t pc = dev->paramCount();+ putU32(b, static_cast<uint32_t>(pc));+ for (int32_t p = 0; p < pc; ++p) { float x = dev->getParam(p); uint32_t u; std::memcpy(&u, &x, 4); putU32(b, u); }+ }+ }+ putU32(b, static_cast<uint32_t>(kit_.size()));+ b.insert(b.end(), kit_.begin(), kit_.end());return b;}void setState(const uint8_t* data, int32_t size) override {@@ -195,6 +284,34 @@ public:on_[bk][v][s] = data[off]; vel_[bk][v][s] = data[off + 1]; acc_[bk][v][s] = data[off + 2]; off += 3;}for (int v = 0; v < kVoices; ++v) if (off < size) src_[v] = data[off++]; // source flags (buffers reloaded by the project)+ // Voice FX + kit label. A blob from before them simply ends here: the voices keep no FX.+ auto ns = std::make_shared<FxState>();+ std::string kit;+ auto getU32 = [&](uint32_t& out) { if (off + 4 > size) return false; out = 0; for (int i = 0; i < 4; ++i) out |= (uint32_t)data[off + i] << (i * 8); off += 4; return true; };+ uint32_t tag = 0;+ if (getU32(tag) && tag == kFxMagic) {+ for (int v = 0; v < kVoices && off < size; ++v) {+ const int n = data[off++];+ for (int d = 0; d < n; ++d) {+ uint32_t kind = 0, pc = 0;+ if (!getU32(kind) || off >= size) break;+ const bool byp = data[off++] != 0;+ if (!getU32(pc)) break;+ auto dev = makeChainDevice(static_cast<int32_t>(kind));+ if (dev) dev->setSampleRate(sampleRate_, kChunk);+ for (uint32_t p = 0; p < pc; ++p) {+ uint32_t u = 0; if (!getU32(u)) break;+ float x; std::memcpy(&x, &u, 4);+ if (dev && std::isfinite(x)) dev->setParam(static_cast<int32_t>(p), x);+ }+ if (dev) { dev->paramsRestored(static_cast<int32_t>(pc)); dev->setBypassed(byp); if ((int)ns->chain[v].size() < kMaxFx) ns->chain[v].push_back(std::move(dev)); }+ }+ }+ uint32_t kl = 0;+ if (getU32(kl) && kl <= 64 && off + (int)kl <= size) kit.assign(reinterpret_cast<const char*>(data + off), kl);+ }+ commitFx(ns);+ kit_ = kit;}std::shared_ptr<Instrument> clone() const override {auto r = std::make_shared<RhythmMachine>();@@ -204,6 +321,23 @@ public:r->rev_.store(rev_.load(std::memory_order_relaxed) + 1, std::memory_order_relaxed);for (int v = 0; v < kVoices; ++v) { r->smp_[v] = smp_[v]; r->src_[v] = src_[v]; } // share sample buffers (immutable)r->setSampleRate(sampleRate_);+ // The voice FX are copied device by device (kind + params + bypass): a clone must not+ // share DSP state with the original, which keeps playing until the swap.+ auto ns = std::make_shared<FxState>();+ if (FxState* fx = fxLive_.load(std::memory_order_acquire))+ for (int v = 0; v < kVoices; ++v)+ for (auto& d : fx->chain[v]) {+ auto c = d ? makeChainDevice(d->builtinKind()) : nullptr;+ if (!c) continue;+ c->setSampleRate(sampleRate_, kChunk);+ const int32_t pc = d->paramCount();+ for (int32_t p = 0; p < pc; ++p) c->setParam(p, d->getParam(p));+ c->paramsRestored(pc);+ c->setBypassed(d->bypassed());+ ns->chain[v].push_back(std::move(c));+ }+ r->commitFx(ns);+ r->kit_ = kit_;return r;}@@ -226,7 +360,6 @@ public:const float swing = get(Swing), human = get(Humanize);const float accentG = 1.0f + get(Accent) * 1.0f; // up to +6 dB-ishconst float vol = get(Volume) * 1.2f;- const double invSr = 1.0 / sampleRate_;const double stepBeats = 0.25; // 1/16int flash[kVoices] = {0};@@ -245,56 +378,85 @@ public:const float atk = std::exp(-1.0f / (0.005f * (float)sampleRate_)), rel = std::exp(-1.0f / (0.150f * (float)sampleRate_));const float avgC = std::exp(-1.0f / (0.7f * (float)sampleRate_));float grMax = 0.0f;- for (int32_t i = 0; i < frames; ++i) {- // --- sequencer clock ---- if (playing_ && spb_ > 0.0) {- double beat = beatStart_ + (double)i * invSr * (sampleRate_ / spb_) * spb_ * invSr; // = beatStart_ + i/spb_- beat = beatStart_ + (double)i / spb_;- double pos = beat / stepBeats; // in 16th-steps- long absStep = (long)std::floor(pos);- int barStep = (int)(((absStep % kSteps) + kSteps) % kSteps);- double frac = pos - std::floor(pos); // 0..1 within the step- double trigFrac = (barStep & 1) ? (double)swing * 0.5 : 0.0; // swing delays odd 16ths- if (absStep != lastAbsStep_) { lastAbsStep_ = absStep; stepArmed_ = true; }- if (stepArmed_ && frac >= trigFrac) {- stepArmed_ = false; curStep_ = barStep;- for (int v = 0; v < kVoices; ++v) if (on_[bank_][v][barStep]) {- float vv = vel_[bank_][v][barStep] / 255.0f;- if (acc_[bank_][v][barStep]) vv = std::min(1.0f, vv * accentG);- if (human > 0.0f) vv = std::clamp(vv + (noiseF() * 2.0f - 1.0f) * human * 0.25f, 0.0f, 1.0f);- trigger(v, vv);- flash[v] = 1;+ // Voices with an FX chain render into their own buffer and run through it; the rest+ // go straight to the sum. Chunks keep the buffers small and the chain's block bounded.+ FxState* fx = fxLive_.load(std::memory_order_acquire);+ bool hasFx[kVoices] = {false};+ bool anyFx = false;+ if (fx)+ for (int v = 0; v < kVoices; ++v) {+ for (auto& d : fx->chain[v]) if (d && !d->bypassed()) { hasFx[v] = true; break; }+ anyFx = anyFx || hasFx[v];+ }+ for (int32_t base = 0; base < frames; base += kChunk) {+ const int32_t n = std::min<int32_t>(kChunk, frames - base);+ std::memset(mix_, 0, sizeof(float) * n * 2);+ if (anyFx) for (int v = 0; v < kVoices; ++v) if (hasFx[v]) std::memset(vbuf_[v], 0, sizeof(float) * n * 2);+ for (int32_t j = 0; j < n; ++j) {+ const int32_t i = base + j;+ // --- sequencer clock ---+ if (playing_ && spb_ > 0.0) {+ const double beat = beatStart_ + (double)i / spb_;+ double pos = beat / stepBeats; // in 16th-steps+ long absStep = (long)std::floor(pos);+ int barStep = (int)(((absStep % kSteps) + kSteps) % kSteps);+ double frac = pos - std::floor(pos); // 0..1 within the step+ double trigFrac = (barStep & 1) ? (double)swing * 0.5 : 0.0; // swing delays odd 16ths+ if (absStep != lastAbsStep_) { lastAbsStep_ = absStep; stepArmed_ = true; }+ if (stepArmed_ && frac >= trigFrac) {+ stepArmed_ = false; curStep_ = barStep;+ for (int v = 0; v < kVoices; ++v) if (on_[bank_][v][barStep]) {+ float vv = vel_[bank_][v][barStep] / 255.0f;+ if (acc_[bank_][v][barStep]) vv = std::min(1.0f, vv * accentG);+ if (human > 0.0f) vv = std::clamp(vv + (noiseF() * 2.0f - 1.0f) * human * 0.25f, 0.0f, 1.0f);+ trigger(v, vv);+ flash[v] = 1;+ }}+ } else {+ curStep_ = -1;+ }++ // --- voices ---+ for (int v = 0; v < kVoices; ++v) {+ if (!voices_[v].active) continue;+ float sl, sr;+ voiceStereo(v, sl, sr);+ if (!std::isfinite(sl) || !std::isfinite(sr)) { sl = sr = 0.0f; voices_[v].active = false; }+ const float pan = std::clamp(get2(v, Pan) * 2.0f - 1.0f, -1.0f, 1.0f);+ const float gl = (pan <= 0.0f ? 1.0f : 1.0f - pan);+ const float gr = (pan >= 0.0f ? 1.0f : 1.0f + pan);+ float* dst = hasFx[v] ? vbuf_[v] : mix_;+ dst[j * 2] += sl * gl; dst[j * 2 + 1] += sr * gr;}- } else {- curStep_ = -1;}- // --- synth voices ---- float l = 0.0f, r = 0.0f;- for (int v = 0; v < kVoices; ++v) {- if (!voices_[v].active) continue;- float s = voiceSample(v);- if (!std::isfinite(s)) { s = 0.0f; voices_[v].active = false; }- const float pan = std::clamp(get2(v, Pan) * 2.0f - 1.0f, -1.0f, 1.0f);- const float gl = (pan <= 0.0f ? 1.0f : 1.0f - pan);- const float gr = (pan >= 0.0f ? 1.0f : 1.0f + pan);- l += s * gl; r += s * gr;+ // --- voice FX: every chain runs each chunk, so its tail rings out after the hit ---+ if (anyFx)+ for (int v = 0; v < kVoices; ++v) {+ if (!hasFx[v]) continue;+ for (auto& d : fx->chain[v]) if (d && !d->bypassed()) d->process(vbuf_[v], n);+ for (int32_t k = 0; k < n * 2; ++k) mix_[k] += std::isfinite(vbuf_[v][k]) ? vbuf_[v][k] : 0.0f;+ }++ // --- bus: glue + volume ---+ for (int32_t j = 0; j < n; ++j) {+ float l = mix_[j * 2], r = mix_[j * 2 + 1];+ if (glueOn) {+ const float pk = std::max(std::fabs(l), std::fabs(r));+ const float lvlDb = pk > 1e-6f ? 20.0f * std::log10(pk) : -120.0f;+ const float over = std::max(0.0f, lvlDb - thrDb);+ const float target = over * (1.0f - 1.0f / ratio); // dB of reduction wanted+ const float c = target > glueGr_ ? atk : rel;+ glueGr_ = target + c * (glueGr_ - target);+ glueAvg_ = glueGr_ + avgC * (glueAvg_ - glueGr_);+ const float g = std::pow(10.0f, (std::min(glueAvg_ * 0.7f, glueGr_) - glueGr_) * 0.05f);+ l *= g; r *= g;+ grMax = std::max(grMax, glueGr_);+ } else { glueGr_ = 0.0f; glueAvg_ = 0.0f; }+ out[(base + j) * 2] += l * vol;+ out[(base + j) * 2 + 1] += r * vol;}- if (glueOn) {- const float pk = std::max(std::fabs(l), std::fabs(r));- const float lvlDb = pk > 1e-6f ? 20.0f * std::log10(pk) : -120.0f;- const float over = std::max(0.0f, lvlDb - thrDb);- const float target = over * (1.0f - 1.0f / ratio); // dB of reduction wanted- const float c = target > glueGr_ ? atk : rel;- glueGr_ = target + c * (glueGr_ - target);- glueAvg_ = glueGr_ + avgC * (glueAvg_ - glueGr_);- const float g = std::pow(10.0f, (std::min(glueAvg_ * 0.7f, glueGr_) - glueGr_) * 0.05f);- l *= g; r *= g;- grMax = std::max(grMax, glueGr_);- } else { glueGr_ = 0.0f; glueAvg_ = 0.0f; }- out[i * 2] += l * vol;- out[i * 2 + 1] += r * vol;}// publish telemetry@@ -317,6 +479,21 @@ public:private:static constexpr uint32_t kMagicV1 = 0x31485452; // "RTH1" — 60 paramsstatic constexpr uint32_t kMagic = 0x32485452; // "RTH2" — + sample region, Glue+ static constexpr uint32_t kFxMagic = 0x31584652; // "RFX1" — voice FX chains + kit label, after the pattern+ static constexpr int kChunk = 256; // render chunk = the voice FX's max block+ static constexpr int kMaxFx = 8; // devices per voice chain++ struct FxState { std::vector<std::shared_ptr<Device>> chain[kVoices]; };+ std::shared_ptr<FxState> copyFx() const { return fxAuthoring_ ? std::make_shared<FxState>(*fxAuthoring_) : std::make_shared<FxState>(); }+ // Publish a new FX snapshot. The last few stay alive so a block still reading an older+ // one never sees it freed (the RackCore scheme).+ void commitFx(std::shared_ptr<FxState> ns) {+ fxAuthoring_ = ns;+ fxStates_.push_back(ns);+ if (fxStates_.size() > 16) fxStates_.erase(fxStates_.begin());+ fxLive_.store(ns.get(), std::memory_order_release);+ }+ static void putU32(std::vector<uint8_t>& b, uint32_t v) { for (int i = 0; i < 4; ++i) b.push_back((uint8_t)(v >> (i * 8))); }static constexpr double kTwoPi = 6.283185307179586;static constexpr const char* kVoiceNames[kVoices] = { "Kick", "Snare", "Clap", "Rim", "Closed Hat", "Open Hat", "Tom", "Perc" };static constexpr int kMidiMap[kVoices] = { 36, 38, 39, 37, 42, 46, 45, 41 };@@ -327,7 +504,7 @@ private:double ph = 0.0, ph2 = 0.0;float env = 0.0f, env2 = 0.0f; // amp + secondary (noise/tail) envfloat pitchEnv = 0.0f;- float lp = 0.0f, hp = 0.0f, hpPrev = 0.0f; // one-pole filter states+ float lp = 0.0f, lp2 = 0.0f, hp = 0.0f, hpPrev = 0.0f; // one-pole filter states (lp2: a sample's right channel)float bp = 0.0f, bp2 = 0.0f; // band-pass (SVF) statesint burst = 0; float burstT = 0.0f; // clap multi-burstdouble spos = 0.0; bool splay = false; // sample-voice playback@@ -353,7 +530,7 @@ private:vc.ph = 0.0; vc.ph2 = 0.0; vc.env = 1.0f; vc.env2 = 1.0f; vc.pitchEnv = 1.0f;vc.burst = 0; vc.burstT = 0.0f;vc.splay = (src_[v] == Sample && smp_[v] && !smp_[v]->empty());- vc.spos = 0.0; vc.lp = 0.0f;+ vc.spos = 0.0; vc.lp = 0.0f; vc.lp2 = 0.0f;if (vc.splay) {// The played region: Start .. Start + Length of the file (at least ~1 ms); Reverse// plays it back to front.@@ -366,32 +543,38 @@ private:if (v == 4) voices_[5].active = false; // closed hat chokes open hat (808)}- // One mono sample from a sample-voice one-shot: pitch (Tune) → playback rate, amp env- // (Decay), Tone → LP, Drive → tanh, Level. Stops at the end of the buffer.- float sampleVoice(int v) {+ // One stereo frame from a sample-voice one-shot (a stereo file keeps its image): pitch+ // (Tune) → playback rate, amp env (Decay), Tone → LP, Drive → tanh, Level. Stops at the+ // end of the region.+ void sampleVoice(int v, float& outL, float& outR) {Voice& vc = voices_[v];auto& b = *smp_[v];const float tune = get2(v, Tune), decay = get2(v, Decay), tone = get2(v, Tone), drive = get2(v, Drive);float l, r; b.readStereo((int64_t)vc.spos, l, r);- float s = 0.5f * (l + r);const double rate = (b.sourceSampleRate > 0 ? b.sourceSampleRate / sampleRate_ : 1.0) * std::exp2((tune - 0.5) * 2.0);// A 64-frame fade into the region's far edge, so a Length cut never clicks.const double left = vc.srev ? vc.spos - vc.sBeg : vc.sEnd - vc.spos;- if (left < 64.0 * rate) s *= (float)std::max(0.0, left / (64.0 * rate));+ if (left < 64.0 * rate) { const float f = (float)std::max(0.0, left / (64.0 * rate)); l *= f; r *= f; }vc.spos += vc.srev ? -rate : rate;// Tone as a gentle one-pole low-pass (0 = dark, 1 = open).const float lpc = 0.05f + tone * 0.95f;- vc.lp += lpc * (s - vc.lp); s = vc.lp;- if (drive > 0.001f) s = std::tanh(s * (1.0f + drive * 3.0f));+ vc.lp += lpc * (l - vc.lp); vc.lp2 += lpc * (r - vc.lp2);+ l = vc.lp; r = vc.lp2;+ if (drive > 0.001f) { const float g = 1.0f + drive * 3.0f; l = std::tanh(l * g); r = std::tanh(r * g); }vc.env *= decayCoef(expMap(decay, 0.05f, 2.0f));if ((vc.srev ? vc.spos < vc.sBeg : vc.spos >= vc.sEnd) || vc.env < 1e-4f) { vc.active = false; vc.splay = false; }- return s * vc.env * vc.vel * get2(v, Level);+ const float k = vc.env * vc.vel * get2(v, Level);+ outL = l * k; outR = r * k;+ }++ void voiceStereo(int v, float& l, float& r) {+ if (voices_[v].splay) { sampleVoice(v, l, r); return; }+ l = r = voiceSample(v);}// One mono sample for voice v, advancing its state. Params denormalized inline.float voiceSample(int v) {Voice& vc = voices_[v];- if (vc.splay) return sampleVoice(v); // sample-source voice (Phase 2)const float tune = get2(v, Tune), decay = get2(v, Decay), punch = get2(v, Punch);const float tone = get2(v, Tone), drive = get2(v, Drive), level = get2(v, Level);const double invSr = 1.0 / sampleRate_;@@ -500,6 +683,13 @@ private:std::atomic<float> scope_[kScopeN];std::atomic<float> pn_[kNumParams];++ std::shared_ptr<FxState> fxAuthoring_; // voice FX (message thread)+ std::vector<std::shared_ptr<FxState>> fxStates_; // recent snapshots kept alive+ std::atomic<FxState*> fxLive_{nullptr};+ std::string kit_; // factory kit label (message thread)+ float mix_[kChunk * 2]; // audio thread: the chunk's sum+ float vbuf_[kVoices][kChunk * 2]; // audio thread: FX voices, pre-chain};} // namespace notadiff --git a/src/native/nota.engine/src/nota_engine_track.cpp b/src/native/nota.engine/src/nota_engine_track.cppindex 8c3b4593..4e4dbec9 100644--- a/src/native/nota.engine/src/nota_engine_track.cpp+++ b/src/native/nota.engine/src/nota_engine_track.cpp@@ -150,6 +150,46 @@ int32_t nota_track_rhythm_voice_info(const NotaEngine* e, int32_t track_id, int3int32_t nota_track_rhythm_voice_source(const NotaEngine* e, int32_t track_id, int32_t voice) {return e ? CENG(e)->rhythmVoiceSource(track_id, voice) : 0;}+int32_t nota_rhythm_voice_device_count(const NotaEngine* e, int32_t t, int32_t v) { return e ? CENG(e)->rhythmVoiceDeviceCount(t, v) : 0; }+int32_t nota_rhythm_add_voice_device(NotaEngine* e, int32_t t, int32_t v, int32_t kind) { return e ? ENG(e)->rhythmAddVoiceDevice(t, v, kind) : -1; }+int32_t nota_rhythm_remove_voice_device(NotaEngine* e, int32_t t, int32_t v, int32_t d) { return (e && ENG(e)->rhythmRemoveVoiceDevice(t, v, d)) ? 1 : 0; }+int32_t nota_rhythm_move_voice_device(NotaEngine* e, int32_t t, int32_t v, int32_t from, int32_t to) { return (e && ENG(e)->rhythmMoveVoiceDevice(t, v, from, to)) ? 1 : 0; }+const char* nota_rhythm_voice_device_name(const NotaEngine* e, int32_t t, int32_t v, int32_t d) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->displayName() : "";+}+int32_t nota_rhythm_voice_device_builtin_kind(const NotaEngine* e, int32_t t, int32_t v, int32_t d) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->builtinKind() : -1;+}+int32_t nota_rhythm_voice_device_param_count(const NotaEngine* e, int32_t t, int32_t v, int32_t d) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->paramCount() : 0;+}+const char* nota_rhythm_voice_device_param_name(const NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t p) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->paramName(p) : "";+}+float nota_rhythm_voice_device_param_min(const NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t p) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->paramMin(p) : 0.0f;+}+float nota_rhythm_voice_device_param_max(const NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t p) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->paramMax(p) : 1.0f;+}+float nota_rhythm_voice_device_param_get(const NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t p) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return dev ? dev->getParam(p) : 0.0f;+}+void nota_rhythm_voice_device_param_set(NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t p, float value) {+ if (nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr) dev->setParam(p, value);+}+int32_t nota_rhythm_voice_device_bypassed(const NotaEngine* e, int32_t t, int32_t v, int32_t d) {+ nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr; return (dev && dev->bypassed()) ? 1 : 0;+}+void nota_rhythm_set_voice_device_bypassed(NotaEngine* e, int32_t t, int32_t v, int32_t d, int32_t bypassed) {+ if (nota::Device* dev = e ? CENG(e)->rhythmVoiceDevice(t, v, d) : nullptr) dev->setBypassed(bypassed != 0);+}+const char* nota_rhythm_kit_name(const NotaEngine* e, int32_t t) {+ static std::string s; s = e ? CENG(e)->rhythmKitName(t) : std::string{}; return s.c_str();+}+void nota_rhythm_set_kit_name(NotaEngine* e, int32_t t, const char* name) {+ if (e) ENG(e)->setRhythmKitName(t, name ? name : "");+}int32_t nota_track_set_grain_sample(NotaEngine* e, int32_t track_id, const char* path, int32_t root) {if (!e || !path) return 0;return ENG(e)->setTrackGrainSample(track_id, std::string(path), root) ? 1 : 0;diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex f251e7ef..4ffed343 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -11067,40 +11067,38 @@ Console.WriteLine("-- Nota Rhythm --");$"Glue compresses the kit (RMS {dry.Rms:F3} → {glued.Rms:F3}, peak {dry.Peak:F2} → {glued.Peak:F2})");}- // Factory kits: ≥ 25, every id exists, each plays the pattern finite and unclipped; a kit- // keeps the steps and a voice's sample region; a user kit can be saved.+ // Kits: Rhythm has no presets of its own — its kits are the factory drum kits (the Drum+ // Rack's). Every kit loads onto the eight voices, plays its pattern finite and unclipped,+ // keeps the steps, is recognised by name, and a user preset can still be saved.{- var ids = new HashSet<string>();- for (int i = 0; i < pc; i++) ids.Add(re.PluginParamId(t, -1, i));var cat = new FactoryPresetCatalog();- var mine = cat.All().Where(p => p.IsInstrument && p.BuiltinKind == 12).ToList();- Check(mine.Count >= 25, $"Nota Rhythm ships ≥ 25 factory kits (got {mine.Count})");- var bad = mine.SelectMany(p => cat.Document(p.Id)!.NamedParams!.Keys.Where(k => !ids.Contains(k)).Select(k => $"{p.DisplayName}:{k}")).ToList();- Check(bad.Count == 0, $"every Rhythm kit param id exists{(bad.Count > 0 ? " — bad: " + string.Join(", ", bad) : "")}");+ Check(!cat.All().Any(p => p.IsInstrument && p.BuiltinKind == 12), "Nota Rhythm ships no synth presets of its own");+ var kitSvc = new DrumKitService();var quiet = new List<string>();- foreach (var p in mine)+ foreach (var k in kitSvc.All()){using var ep = new NotaEngine();ep.SetBpm(120); ep.SetTimeSignature(4, 4);int tp = ep.AddRhythmTrack();- if (cat.ApplyInPlace(ep, p.Id, tp, -1).Length != 0) { quiet.Add($"{p.DisplayName} (apply)"); continue; }+ if (!kitSvc.LoadInto(ep, tp, k.Id, out string w) || w.Length > 0) { quiet.Add($"{k.Name} (load: {w})"); continue; }+ int smp = 0; for (int v = 0; v < 8; v++) if (ep.RhythmVoiceSource(tp, v) == 1) smp++;+ if (smp != 8) { quiet.Add($"{k.Name} ({smp}/8 voices)"); continue; }+ if (kitSvc.Identify(ep, tp) != k.Id) { quiet.Add($"{k.Name} (identify '{kitSvc.Identify(ep, tp)}')"); continue; }var pb = new float[44100 * 2 * 2];ep.Seek(0.0); ep.Play(); ep.RenderOffline(pb, 44100 * 2); ep.StopTransport();float r = Rms(pb, 44100 * 2), pk = pb.Max(Math.Abs);- if (!pb.All(float.IsFinite) || r < 0.003f || pk > 2f) quiet.Add($"{p.DisplayName} ({r:F3}/{pk:F2})");+ if (!pb.All(float.IsFinite) || r < 0.003f || pk > 2f) quiet.Add($"{k.Name} ({r:F3}/{pk:F2})");}- Check(quiet.Count == 0, $"every Rhythm kit plays its pattern, finite and not clipping hard{(quiet.Count > 0 ? " — " + string.Join(", ", quiet) : "")}");+ Check(quiet.Count == 0, $"every factory kit loads onto Rhythm's voices, is recognised and plays finite and unclipped{(quiet.Count > 0 ? " — " + string.Join(", ", quiet) : "")}");using var kp = new NotaEngine();int tk = kp.AddRhythmTrack();- kp.PluginParamSet(tk, -1, RIdx(kp, tk, "v2_length"), 0.4f);kp.InstrumentAction(tk, RhythmModel.A_ToggleStep, 1 * 16 + 3, 0); // snare on step 4- string trap = mine.First(p => p.DisplayName == "Trap").Id;- cat.ApplyInPlace(kp, trap, tk, -1);+ kitSvc.LoadInto(kp, tk, "neon", out _);var kpat = RhythmModel.Parse(kp.GetPluginState(tk, -1), kp.PluginParamCount(tk, -1));- Check(kpat.On[0, 1, 3] && kpat.On[0, 0, 0] && Math.Abs(kp.PluginParamGet(tk, -1, RIdx(kp, tk, "v2_length")) - 0.4f) < 1e-4f- && Math.Abs(kp.PluginParamGet(tk, -1, RIdx(kp, tk, "v0_tune")) - 0.1f) < 1e-4f,- "applying a kit sets the sound and keeps the steps and the sample region");+ Check(kpat.On[0, 1, 3] && kpat.On[0, 0, 0], "loading a kit keeps the steps");+ Check(Math.Abs(kp.PluginParamGet(tk, -1, RIdx(kp, tk, "v1_tone")) - 1f) < 1e-4f && Math.Abs(kp.PluginParamGet(tk, -1, RIdx(kp, tk, "v1_tune")) - 0.5f) < 1e-4f,+ "a kit voice plays its sample as recorded (tone open, tune centred)");var user = PresetService.Capture(kp, tk, -1, "My Kit");Check(user is { Type: "builtin-instrument", BuiltinKind: 12 } && user.NamedParams!.ContainsKey("glue"), "a Rhythm kit can be saved as a user preset");}@@ -11182,6 +11180,135 @@ Console.WriteLine("-- Nota Rhythm samples --");finally { try { if (File.Exists(smpWav)) File.Delete(smpWav); } catch { } }}++// ============ Factory kit FX: Drum Rack pad chains + Rhythm voice chains ============+// A kit brings its effects: saturation on the kick, reverb on snare / clap, synced delay on+// hats and percussion — as ordinary chain devices, adding to the hit without changing it.+Console.WriteLine("-- Kit FX --");+{+ var svc = new DrumKitService();+ const int SR = 44100; // the offline engine's rate+ static double KRms(float[] b, int from, int to) { double q = 0; to = Math.Min(to, b.Length / 2); for (int i = from; i < to; i++) q += 0.5 * (b[2 * i] * b[2 * i] + b[2 * i + 1] * b[2 * i + 1]); return to > from ? Math.Sqrt(q / (to - from)) : 0; }+ static double KDb(double x) => 20 * Math.Log10(Math.Max(x, 1e-9));+ // One hit of `note` from a fresh Drum Rack (or Rhythm) of `kit`, with or without its FX.+ float[] Hit(string kit, int note, bool fx, bool rhythm = false, double bpm = 120)+ {+ using var e = new NotaEngine();+ e.SetBpm(bpm);+ int t;+ if (!rhythm)+ {+ t = svc.CreateTrack(e, kit, out _);+ e.RackSetHumanize(t, 0); e.RackSetSwing(t, 0);+ if (!fx) for (int c = 0; c < e.RackChainCount(t); c++) while (e.RackChainDeviceCount(t, c) > 0) e.RackRemoveChainDevice(t, c, 0);+ int clip = e.AddMidiClip(t, 0, 8);+ e.SetClipNotes(t, clip, new[] { new NotaNote(note, 0.0, 0.25, 1.0f) });+ }+ else+ {+ t = svc.CreateRhythmTrack(e, kit, out _);+ e.InstrumentAction(t, RhythmModel.A_ClearBank, 0, 0);+ for (int i = 0; i < e.PluginParamCount(t, -1); i++) if (e.PluginParamId(t, -1, i) is "humanize" or "swing") e.PluginParamSet(t, -1, i, 0f);+ if (!fx) for (int v = 0; v < 8; v++) while (e.RhythmVoiceDeviceCount(t, v) > 0) e.RhythmRemoveVoiceDevice(t, v, 0);+ int v0 = Array.IndexOf(RhythmModel.MidiNotes, note);+ e.InstrumentAction(t, RhythmModel.A_ToggleStep, v0 * 16, 0);+ e.InstrumentAction(t, RhythmModel.A_SetVel, v0 * 16, 1f);+ }+ e.Seek(0); e.Play();+ int n = SR * 2; var buf = new float[n * 2]; var blk = new float[512 * 2];+ for (int done = 0; done < n; done += 512) { e.RenderOffline(blk, 512); Array.Copy(blk, 0, buf, done * 2, Math.Min(512, n - done) * 2); }+ e.StopTransport();+ return buf;+ }++ // Which pads get what (Kompakt: kick, snare, closed hat, crash).+ using (var ke = new NotaEngine())+ {+ int kt = svc.CreateTrack(ke, "kompakt", out _);+ int Chain(int note) { for (int c = 0; c < ke.RackChainCount(kt); c++) if (ke.RackChainTriggerNote(kt, c) == note) return c; return -1; }+ int[] Kinds(int note) { int c = Chain(note); return Enumerable.Range(0, ke.RackChainDeviceCount(kt, c)).Select(d => ke.RackChainDeviceBuiltinKind(kt, c, d)).ToArray(); }+ Check(Kinds(36).SequenceEqual(new[] { 17 }) && Kinds(38).SequenceEqual(new[] { 2 }) && Kinds(39).SequenceEqual(new[] { 2 })+ && Kinds(42).SequenceEqual(new[] { 3 }) && Kinds(46).SequenceEqual(new[] { 3 }) && Kinds(49).Length == 0,+ "kit pads carry their FX: Forge on the kick, Reverb on snare and clap, Delay on the hats, none on the crash");+ }++ // The effects add to the hit rather than change it.+ var snDry = Hit("kompakt", 38, false); var snFx = Hit("kompakt", 38, true);+ double headD = KDb(KRms(snFx, 0, SR / 10)) - KDb(KRms(snDry, 0, SR / 10));+ // The tail (0.3–1.5 s) against the hit (first 100 ms): the dry one-shot is long gone there.+ double tailGain = KDb(KRms(snFx, SR * 3 / 10, SR * 3 / 2)) - KDb(KRms(snFx, 0, SR / 10));+ double dryTail = KDb(KRms(snDry, SR * 3 / 10, SR * 3 / 2)) - KDb(KRms(snDry, 0, SR / 10));+ Check(Math.Abs(headD) < 0.3 && tailGain > -45 && tailGain > dryTail + 20,+ $"the snare's reverb keeps the hit at level and opens a tail (hit {headD:+0.00;-0.00} dB, tail {tailGain:0} dB under the hit)");+ var kDry = Hit("kompakt", 36, false); var kFx = Hit("kompakt", 36, true);+ double kickD = KDb(KRms(kFx, 0, SR / 4)) - KDb(KRms(kDry, 0, SR / 4));+ Check(Math.Abs(kickD) < 1.5 && kFx.All(float.IsFinite), $"the kick's saturation stays level-matched ({kickD:+0.00;-0.00} dB)");++ // A tempo-synced delay inside a pad chain follows the song tempo (dotted 1/8: 0.375 s at+ // 120 BPM, 0.5 s at 90) — the rack forwards the tempo to its chain devices.+ // Echo energy around `sec`, relative to the hit (dry: the rim is silent there).+ double EchoAt(float[] fx, float[] dry, double sec) => KDb(KRms(fx, (int)(sec * SR) - 480, (int)(sec * SR) + 1440)) - KDb(KRms(dry, 0, SR / 20));+ var rim120 = Hit("kompakt", 37, true); var rimDry = Hit("kompakt", 37, false);+ var rim90 = Hit("kompakt", 37, true, bpm: 90); var rimDry90 = Hit("kompakt", 37, false, bpm: 90);+ Check(EchoAt(rim120, rimDry, 0.375) > -40 && EchoAt(rim90, rimDry90, 0.5) > -40 && EchoAt(rim90, rimDry90, 0.375) < EchoAt(rim90, rimDry90, 0.5) - 20,+ $"a pad's synced delay echoes on the tempo's dotted 1/8 ({EchoAt(rim120, rimDry, 0.375):0} dB at 0.375 s / 120 BPM, {EchoAt(rim90, rimDry90, 0.5):0} dB at 0.5 s / 90, vs the hit)");++ // Rhythm: the same kit, the same FX, on the voices.+ var rsDry = Hit("kompakt", 38, false, rhythm: true); var rsFx = Hit("kompakt", 38, true, rhythm: true);+ double rHead = KDb(KRms(rsFx, 0, SR / 10)) - KDb(KRms(rsDry, 0, SR / 10));+ double rTail = KDb(KRms(rsFx, SR * 3 / 10, SR * 3 / 2)) - KDb(KRms(rsFx, 0, SR / 10));+ double rDryTail = KDb(KRms(rsDry, SR * 3 / 10, SR * 3 / 2)) - KDb(KRms(rsDry, 0, SR / 10));+ Check(Math.Abs(rHead) < 0.3 && rTail > -45 && rTail > rDryTail + 20,+ $"a Rhythm voice's reverb adds a tail and keeps the hit (hit {rHead:+0.00;-0.00} dB, tail {rTail:0} dB under the hit)");++ using var re = new NotaEngine();+ int rt = svc.CreateRhythmTrack(re, "kompakt", out string rw);+ Check(rt > 0 && rw.Length == 0 && re.RhythmKitName(rt) == "kompakt", $"a Rhythm track with a factory kit ({(rw.Length == 0 ? "no warnings" : rw)})");+ int[] VKinds(NotaEngine e, int t, int v) => Enumerable.Range(0, e.RhythmVoiceDeviceCount(t, v)).Select(d => e.RhythmVoiceDeviceBuiltinKind(t, v, d)).ToArray();+ Check(VKinds(re, rt, 0).SequenceEqual(new[] { 17 }) && VKinds(re, rt, 1).SequenceEqual(new[] { 2 }) && VKinds(re, rt, 4).SequenceEqual(new[] { 3 }),+ "Rhythm voices carry the kit's FX (kick Forge, snare Reverb, closed hat Delay)");+ int dev = re.RhythmAddVoiceDevice(rt, 6, 1); // a compressor on the tom+ Check(dev == 0 && re.RhythmVoiceDeviceName(rt, 6, 0).Length > 0, "a device can be added to a voice");+ int thr = Enumerable.Range(0, re.RhythmVoiceDeviceParamCount(rt, 6, 0)).First(p => re.RhythmVoiceDeviceParamName(rt, 6, 0, p) == "Thresh");+ re.RhythmVoiceDeviceParamSet(rt, 6, 0, thr, -30f);+ re.RhythmSetVoiceDeviceBypassed(rt, 1, 0, true);+ re.RhythmAddVoiceDevice(rt, 6, 16);+ re.RhythmMoveVoiceDevice(rt, 6, 1, 0);+ Check(VKinds(re, rt, 6).SequenceEqual(new[] { 16, 1 }), "voice devices reorder");++ // Save / load: the chains, their params and bypass, and the kit ride the state blob.+ var blob = re.GetPluginState(rt, -1);+ using (var le = new NotaEngine())+ {+ int lt = le.AddRhythmTrack();+ le.SetPluginState(lt, -1, blob);+ Check(VKinds(le, lt, 6).SequenceEqual(new[] { 16, 1 }) && Math.Abs(le.RhythmVoiceDeviceParamGet(lt, 6, 1, thr) + 30f) < 1e-3f+ && le.RhythmVoiceDeviceBypassed(lt, 1, 0) && VKinds(le, lt, 0).SequenceEqual(new[] { 17 }) && le.RhythmKitName(lt) == "kompakt",+ "voice FX (devices, params, bypass) and the kit restore from the state blob");+ // A blob from before voice FX ends after the source flags: it loads with none.+ int legacyLen = 4 + le.PluginParamCount(lt, -1) * 4 + 4 + 4 * 8 * 16 * 3 + 8;+ le.SetPluginState(lt, -1, blob.Take(legacyLen).ToArray());+ var lp = RhythmModel.Parse(le.GetPluginState(lt, -1), le.PluginParamCount(lt, -1));+ Check(Enumerable.Range(0, 8).All(v => le.RhythmVoiceDeviceCount(lt, v) == 0) && lp.On[0, 0, 0] && le.RhythmKitName(lt) == "",+ "an older Rhythm blob (no FX section) still loads its pattern, with no voice FX");+ }+ // Loading a sample into a voice (what a project load does after the blob) keeps every chain.+ var kk = Nota.Infrastructure.Kits.KitCatalog.ById("kompakt")!;+ Check(re.SetRhythmVoiceSample(rt, 7, Nota.Infrastructure.Kits.KitLibrary.PathOf(kk, kk.Pads[12]))+ && VKinds(re, rt, 6).SequenceEqual(new[] { 16, 1 }) && re.RhythmVoiceDeviceBypassed(rt, 1, 0) && re.RhythmKitName(rt) == "kompakt",+ "loading a voice sample keeps the voice FX and the kit");+ int copy = re.DuplicateTrack(rt);+ Check(copy > 0 && VKinds(re, copy, 6).SequenceEqual(new[] { 16, 1 }) && VKinds(re, copy, 1).SequenceEqual(new[] { 2 }),+ "duplicating a Rhythm track copies its voice FX");+ re.RhythmRemoveVoiceDevice(copy, 6, 0);+ Check(re.RhythmVoiceDeviceCount(copy, 6) == 1 && re.RhythmVoiceDeviceCount(rt, 6) == 2, "the copy's chains are its own");++ // Stereo one-shots keep their image in Rhythm (the old sample path summed them to mono).+ var clap = Hit("atelier", 39, false, rhythm: true);+ double side = 0, mid = 0;+ for (int i = 0; i < clap.Length / 2; i++) { double l = clap[2 * i], r = clap[2 * i + 1]; side += (l - r) * (l - r); mid += (l + r) * (l + r); }+ Check(side > mid * 0.005, $"a stereo kit sample plays in stereo on a Rhythm voice (side/mid {side / Math.Max(mid, 1e-12):0.000})");+}// ============ track groups (submix) ======================================Console.WriteLine("-- track groups --");{