Переглянути джерело

Sakura and Drumpad as physical models (REA round 28)

REA round 28 (docs/analise/REA_rodada28.md) decodes FL's Sakura string engine
and Drumpad drum engine and checks Python models against the DLLs' own renders
(and §4, the per-voice levels FL hands to the plugins).

- new instrument kinds `sakura` and `drumpad` (core/PhysicalModels.cpp) with
  FL's raw state in ChannelDef::modelParams (saved as "modelParams")
- Sakura: exciter (S&H noise/click, Lo-Cut, 4-pole Hi-Cut with envelope and
  drive), 4 string loops on a fractional clock with damping
  50^(2.57 − 0.8995a³)·2/44100, sharpness, saturation, feedback ±Decay^0.05,
  combs, stereo mix, amp ADSR, 32 Hz high-pass, master gain; 48 kHz internal
  rate with linear resampling; matrix level destination (velocity/note)
- Drumpad: mallet, 512-lane comb bank with folded-triangle weights,
  self-oscillating filter (float32), LOW/HIGH/MID filters, clip, hold, lo-fi,
  38 kHz internal rate; velocity morph slots
- per-voice output × 1/√2 (FL's cos/sin per-voice pan law vs LYNX's √2 law)
- C++ output matches the reference models within −138…−153 dB
Kauan 1 місяць тому
батько
коміт
eeb2714ee1

+ 1 - 0
CMakeLists.txt

@@ -32,6 +32,7 @@ add_library(lynx_core STATIC
     src/core/FlSynths.cpp
     src/core/FlSytrus.cpp
     src/core/FlGenerators.cpp
+    src/core/PhysicalModels.cpp
     src/core/FlPatcher.cpp
     src/core/Inflate.cpp
     src/core/WavPack.cpp)

+ 7 - 4
docs/STATUS.md

@@ -55,7 +55,8 @@ exports the 30 demo projects shipped with FL Studio 2026.
   reduced to series/parallel chains.
 - Generators: 3x Osc, FPC, DirectWave, FL Keys, Slicex/Fruity Slicer, Wave Traveller, DrumSynth Live (by
   sample); Sytrus, Harmor, Harmless, GMS, Kepler, Ogun/Autogun, MiniSynth, DX10, Fruit Kick, Toxic Biohazard,
-  Sakura, Morphine, PoiZone, BassDrum, BooBass and Drumpad on the built-in synth.
+  Morphine, PoiZone, BassDrum and BooBass on the built-in synth; Sakura and Drumpad on physical models rebuilt from
+  their engines (REA round 28, within −138/−150 dB of the reference renders verified against FL's DLLs).
 - Third-party plugins in the Fruity Wrapper are matched to installed VST3/CLAP plugins (VST3 class ID, CLAP id
   or name, preferring the format FL used) and their state is restored (VST3 and CLAP); automations of a VST3
   follow FL's persistent parameter slots (record 4 → ParamID; skipped with the plugin sandbox on).
@@ -115,9 +116,11 @@ accordingly. Highlights of what is **confirmed and applied**:
   until it is stolen — LYNX uses a short declick release.
 - Effector: the Reverb's diffusion network and the role of Y are LYNX's (only FL's decay time is reproduced, within
   the LYNX reverb's ≈ 0.6…10.5 s).
-- Sakura: physical strings become saw + triangle; string decay taken at key 60; Hi-Cut applied at the output.
-- BooBass: the source is an internal sample not stored in the project (LYNX uses a saw). Drumpad: the physical
-  mesh model is not reproduced.
+- Sakura: modulation matrix only for the level destination with velocity/note sources (EG/LFO shapes, the other
+  destinations, resonators, chorus, reverb and delay were not decoded); strings longer than 9 600 samples (notes
+  below ~20 Hz) are shortened.
+- Drumpad: no key tracking (FL's DSP has none; the host's per-note pitch value is not confirmed).
+- BooBass: the source is an internal sample not stored in the project (LYNX uses a saw).
 - Toxic: the 4-pole ladder is FL's (REA round 26) with fc kept in Hz at any rate (FL's table is built for 44.1 kHz);
   linear filter envelope.
 - Kepler: the chorus is FL's (REA round 26, within −75 dB of the DLL) without its optional noise/gate and with the

+ 106 - 4
docs/analise/REA_rodada28.md

@@ -134,9 +134,9 @@ Per 48 kHz sample, per voice:
 1. **Source.** A uniform value `u ∈ [0, 1)` from a 32-bit LCG (`s ← s·0x0BB38435 + 0x3619636B`, `u = s·2⁻³²`; one
    global generator, four draws per sample for the four SIMD lanes). Sample-and-hold: the held value `h` is replaced
    by `u` only when `u > θ`, `θ = 0.996·(1 − clamp(Rate + m14))^0.25` (Rate = index 32). Source value
-   `x = (1 − L)²·h + L`, with L = index 31 as stored (`1 − x_param`): at **Exc Noise Level = 0 the source is the
-   constant 1** (a step at note-on — the "click"); at 1 it is the held noise (manual: "balance between a single click"
-   and noise **[DOC]**).
+   `x = (1 − p)²·h + p`, p = index 31 parameter value (the engine stores `1 − p` and squares it): at
+   **p = 1 the source is the constant 1** (a step at note-on — the "click"); at p = 0 it is the held noise (manual:
+   "balance between a single click" and noise **[DOC]**; the slider direction in the UI was not checked).
 2. **Lo-Cut:** 2-pole high-pass, `f_lc = 2^(9.3·u_lc + 5)` Hz (32 Hz…20.2 kHz), `u_lc = clamp(Lo-Cut + 0.5·m4)`,
    `Q = 1 + 10·Res`, `w = 2π f_lc/48000`: `y = b·(x − 2x₋₁ + x₋₂) − a1·y₋₁ − a2·y₋₂`,
    `b = (1 + cos w)/(2 + sin w/Q)`, `a1 = −2Q·cos w/(Q + sin w)`, `a2 = (Q − sin w)/(Q + sin w)`.
@@ -373,7 +373,7 @@ Not matched: noise **without** retrigger (unknown initial generator state — st
 |---|---|---|
 | S1 | Sakura rate | fixed 48 kHz internal, linear resampling to host **[DECOMP+EXEC]** |
 | S2 | Sakura pitch | integer loop `N = trunc(48000/f)` clocked at `f·L1/48000` per sample; no all-pass; S2 ratio 4,3,2,1,½,⅓,¼ by integer lengths **[DECOMP+EXEC]** |
-| S3 | Sakura exciter | click (constant 1) ↔ sample-and-hold noise (θ = 0.996(1 − Rate)^0.25); 2-pole HP 2^(9.3u+5) Hz; 4-pole LP g = Cutoff², r = −10·Res(1 − g), drive 1000x⁴; per-lane DC-blocked injection **[DECOMP+EXEC]** |
+| S3 | Sakura exciter | `(1 − p)²·noise + p` (p = Exc Noise Level; 1 = click/constant, 0 = sample-and-hold noise, θ = 0.996(1 − Rate)^0.25); 2-pole HP 2^(9.3u+5) Hz; 4-pole LP g = Cutoff², r = −10·Res(1 − g), drive 1000x⁴; per-lane DC-blocked injection **[DECOMP+EXEC]** |
 | S4 | Sakura loop | 2× 1-pole LP c = min(1, 50^(2.57 − 0.8995a³)·2/44100), far lane × (1 − Offset²); sharpness −0.5x²(1 − c); saturation v/(1 + 100x⁶v²); feedback ±Decay^0.05 **[DECOMP+EXEC]** |
 | S5 | Sakura pickup/mix | out = near lane + Level·comb(far lane, length Ratio·L, fb √Fdbk); L/R linear pan by Sep; ×5·(1 − Mix)/5·Mix **[DECOMP+EXEC]** |
 | S6 | Sakura output | HP 32 Hz Q 1, master 10^(4.8x − 1.8) **[DECOMP+EXEC]** |
@@ -443,3 +443,105 @@ Reference implementations (verified against the DLL): `tmp/r28/py/sakura_model.p
 - Sakura: EG and LFO shapes; resonator, chorus, reverb and delay laws; FL host "compute L/R volume" law.
 - Both: semantics of FL's `FinalLevels.Pitch` (decides whether Drumpad follows the key through the host value).
 - Drumpad: initial noise generator state when the noise retrigger is off.
+
+---
+
+## 4. Host per-voice levels (follow-up)
+
+**Additional target:** `FLEngine_x64.dll` `6d9c5ab09c1d5594012ac2c31cf9ed08e73f42164ed0964cccae10a95d9b8e02` (= round 18;
+Delphi). New Ghidra project `/tmp/r28gh_FLE` (imported **without** automatic analysis); because of its size, the
+relevant code was located with our own brute-force RIP-relative reference finder `tmp/r28/py/rip.py` and the
+direct-call finder `tmp/r18/calls.py`, and read with `objdump` (linear disassembly kept in `/tmp/r28_fle.dis`).
+Host functions used: host object VMT `0x13141b8` (round 18) — slot 6 `FUN_0132af20` (voice event handler), slot 31
+`FUN_0132acb0` → `FUN_006a3a00` (compute L/R volume); pan laws `0x6a3990` / `0x6a39c0` (FPU) and `0x6a6040` /
+`0x6a60b0` (SSE variants), selected by the start-up code at `0x6a6cd6…0x6a6e99`; pan-law mode setter `0x6a3a70`
+(called from `0x1363475` with a project setting at `+0x3c0`); voice FinalLevels builder `0xd265e0`; channel level
+updaters `0xfe9d20` (volume), `0xfe9c00…0xfe9ce6` (pan), `0xfe9fc0` (pitch); channel defaults `0xfe9157…0xfe91bb`;
+constants at `0x6a6913…0x6a69f2`. The harness `run/plug.c` gained optional host stand-ins (pan law A, chosen
+FinalLevels Vol/Pan) and a direct float(float) call (`PLUGCALLF`), used only for the EXEC checks below.
+
+### 4.1 What FL passes per voice **[DECOMP]**
+
+The host voice object carries the SDK's two `TLevelParams` blocks (Pan, Vol, Pitch, FCut, FRes): **InitLevels at
+voice `+0x278`** and **FinalLevels at `+0x28c`**; the generator channel object (voice `+0x260`) holds the channel
+levels at `+0x198` (Pan), `+0x19c` (Vol), `+0x1a0` (Pitch), `+0x1a4` (FCut), `+0x1a8` (FRes).
+
+- **Channel level** (recomputed when the knobs change):
+  - `chan.Vol = g(V/12800)·g(W/12800)`, `g(v) = (11^v − 1)/10` (exactly 1 when v = 1), V = channel volume
+    (`+0x170`, default **10000** → `g = 0.5510`), W = a second volume factor (`+0x188`, default 12800 → 1; its UI
+    source was not identified). `chan.Vol = 0` in one channel state (`+0x160 = 1` without `+0x32e`; not identified).
+  - `chan.Pan = (P + P_mod − 6400)/6400` (P = `+0x16c`, default 6400 = centre; `P_mod` = `+0x184`, default 0).
+  - `chan.Pitch = pitch(+0x174) + fine(+0x154 of the channel's sub-object) − 100·root(+0x15c)` in cents, plus a global
+    pitch when `+0x28f` is set (in another mode, `+0x6ec`, the pitch is sent as an event and
+    `chan.Pitch = −100·root`).
+- **FinalLevels** (`0xd265e0`, called at note start and on changes):
+  - `Final.Vol = Init.Vol·chan.Vol` **only if the voice's "link velocity" flag is set**, otherwise
+    **`Final.Vol = chan.Vol`**. The flag is the SDK voice event 6 handled by host slot 6 (`value > 0` → on).
+  - `Final.Pan = Init.Pan + chan.Pan`, then, if the voice offset `+0x25c` ≠ 0, `clamp(… + offset, −1, 1)`.
+  - `Final.Pitch = Init.Pitch + chan.Pitch + voice(+0x1e0)`; `Final.FCut/FRes = Init + chan`.
+  - Optional extra terms: a modulation matrix when the channel flag `+0x6ed` is set, and a parent level object
+    (`+0x214`: × its Vol, + its Pan, + its Pitch + 6000, × a per-index table) — both not identified in the UI.
+- **Velocity in Init.Vol.** The host answers "get velocity" (voice event 3) with
+  `ln(1 + 10·Init.Vol)/ln 11 × 0.78125` (`0x15f49f0 = 1/ln 11` from the start-up code). Reading FL's velocity as
+  0…1 with 100/128 = 0.78125 as the default, this means **`Init.Vol = (11^(vel/100) − 1)/10`** (vel = FL note velocity
+  0…128; 100 → 1.0, 128 → 2.06) — **inference** (the code that writes Init.Vol was not located).
+- **Compute L/R volume** (host slot 31, `FUN_006a3a00`): pan clamped to ±1, then
+  - mode ≠ 1 (law A, default code path): **`L = Vol·cos((1 + pan)·π/4)`, `R = Vol·sin((1 + pan)·π/4)`**
+    (centre: both `0.7071·Vol`);
+  - mode 1 (law B): `Vol' = 0.7071·Vol`; pan < 0: `L = Vol'`, `R = (1 + pan)·Vol'`; pan ≥ 0: `R = Vol'`,
+    `L = (1 − pan)·Vol'` (centre also `0.7071·Vol`).
+  The mode is a project setting (`+0x3c0` of the object read at `0x1363468`); which UI option it is was not
+  identified, and the value in the demo project was not read.
+
+### 4.2 How Sakura and Drumpad use them **[DECOMP + EXEC]**
+
+Both wrappers are the same framework code (Sakura `FUN_180004980`/`FUN_180003e60`, Drumpad `FUN_1800048f0`/
+`FUN_180003dd0`):
+- **At TriggerVoice** they send voice event 6 with value 0 → **link velocity OFF**, so `Final.Vol = chan.Vol`
+  (the note velocity never scales the output through FL's levels). The engine receives
+  `note = trunc(Init.Pitch/100)` and a MIDI velocity **`trunc(127·ln(1 + 10·Init.Vol)/ln 21)`**, clamped 0…127
+  (EXEC with the DLLs' own function: Init.Vol 0.1 → 28.91, 1.0 → 100.03, 2.0 → 127.0, identical in both). With the
+  inferred Init.Vol law this is `≈ trunc(1.0003·vel)`, i.e. the FL velocity. In Sakura that velocity only reaches the
+  sound through the matrix (source 6); in Drumpad through `√(vel/127)` in the morph slots (§2.2).
+- **Every block** (`FUN_180003e60` / `FUN_180003dd0`) they read each held note's **FinalLevels**, call the host's
+  compute-L/R-volume with `(Final.Pan, Final.Vol)`, and store **L, R** in the engine's per-note tables `+0x20`/`+0x220`
+  (the `T_L`, `T_R` of §1.6 and the per-voice gains of §2.7), the pitch offset `Final.Pitch/100 − note + 60` in
+  `+0x420`, and Final.FCut/FRes in `+0x620`/`+0x820` (not read by either DSP). Notes without levels inherit the
+  values of the nearest held note (the whole 128-entry table is filled).
+- **EXEC** (harness host using law A, `Final.Vol = g(10000/12800) = 0.5510`, pan 0): Sakura and Drumpad outputs
+  drop by **−8.19 dB** (= `20·log10(0.5510·0.7071)`) relative to unit tables; with pan −0.5 a clean Sakura patch
+  gives L/R factors 0.9239/0.3827 of the unit level (= cos/sin(π/8)) and Drumpad 0.5091·/0.2109· (= 0.551·cos/sin(π/8)).
+  The output is linear in `T_L/T_R`.
+- **Pitch:** `T_note = Final.Pitch/100 − note + 60` = `(Init.Pitch − 100·note)/100 + chan.Pitch/100 + 60 + voice/100`.
+  Since the wrapper takes the note as `trunc(Init.Pitch/100)`, Init.Pitch is the absolute key in cents (**inference**),
+  so **`T_note ≈ pitch knob + fine (in semitones) − root + 60`**: 0 for a channel with root C5 and pitch 0. Sakura
+  tracks the key through its own note number; **Drumpad follows only the channel pitch/fine/root shift (±12
+  semitones clamp), not the key**.
+
+### 4.3 Additional output scaling re-checked **[DECOMP + EXEC]**
+
+- Sakura: master `10^(4.8·x₀ − 1.8)` × CC7 × CC10 pan; the synth constructor (`FUN_18002e670`) sets CC7 = 1.0 and
+  CC10 = 0.5 (centre → unity) and the wrapper's ProcessEvent handles only tempo and max-polyphony (no MIDI volume),
+  so no other factor. The only factor left at 1 in the §1.12 harness was **`T_L/T_R`**.
+- Drumpad: the only factor left at 1 in §2.9 was likewise the per-voice gains (`T_L/T_R` → `+0x49e8/+0x49ec`); the
+  synth-level `0.5·CC7` function `FUN_18001e300` is not on the Gen_Render path (EXEC: output gain 1).
+- Host side: within the channel code only the voice FinalLevels builder, the "MIDI-style" event path and a sampler
+  L/R computation read `chan.Vol`; **no host multiplication of a native generator's Gen_Render output by the
+  channel volume/pan was found** (**inference**: channel volume and pan reach these plugins only through
+  FinalLevels). The mixer insert/master levels downstream are not part of this question.
+
+### 4.4 Formulas for LYNX
+
+Per voice, multiply the Sakura/Drumpad stereo output (which in the Python models assumes `T_L = T_R = 1`) by
+```
+Vol   = (11^(V/12800) − 1)/10 · (11^(W/12800) − 1)/10      (V = channel volume 0…12800, W normally 12800 → 1)
+pan   = clamp(note pan + (P − 6400)/6400, −1, 1)              (P = channel pan, 6400 = centre)
+T_L   = Vol·cos((1 + pan)·π/4),   T_R = Vol·sin((1 + pan)·π/4)   (centre: 0.7071·Vol)
+```
+**and do not apply the channel volume/pan again** at the channel level for these two plugins. At default settings
+this is −8.19 dB versus unit gain (−3.01 dB from the pan law if LYNX already applies `g(V)` separately). Velocity:
+pass `vel7 = trunc(127·ln(1 + 10·Init.Vol)/ln 21)` (≈ the FL velocity) to the engine; do not scale the output by
+velocity. Sakura pitch offset `T_note` = channel pitch + fine (semitones) − root + 60 (0 by default); Drumpad pitch
+factor `2^(clamp(12·bend + T_note, −12, 12)/12)`, no key tracking. **Not confirmed:** which pan-law mode (A/B) the
+project uses (both give 0.7071·Vol at centre), the UI meaning of W, `+0x6ed`, `+0x214`, the note-pan scaling of
+Init.Pan, and the code writing Init.Vol.

+ 1 - 1
scripts/build-local.sh

@@ -13,7 +13,7 @@ if [[ -z "${CXX:-}" ]]; then
 fi
 
 FLAGS="-std=c++20 -O2 -g -Wall -Wextra -Wpedantic -Isrc -Ithird_party/wavpack/include"
-CORE="src/flp/Flp.cpp src/core/Song.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp src/core/FlpImport.cpp src/core/Effects.cpp"
+CORE="src/flp/Flp.cpp src/core/Song.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp src/core/FlpImport.cpp src/core/Effects.cpp"
 
 mkdir -p build-local build-local/wavpack
 # WavPack decoder (C)

+ 1 - 1
scripts/build-windows-zig.sh

@@ -75,7 +75,7 @@ APP_SOURCES=(src/Main.cpp
              src/engine/SampleLibrary.cpp src/engine/WavPackFormat.cpp src/engine/ProjectFile.cpp src/engine/PluginHost.cpp src/engine/PluginSandbox.cpp src/engine/Exporter.cpp src/engine/StreamPrefetcher.cpp src/engine/ClapFormat.cpp src/engine/MidiFileIo.cpp src/engine/PreviewPlayer.cpp
              src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp
              src/core/Song.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp
-             src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
+             src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
              src/platform/MingwFixes.cpp)
 
 echo "WavPack (decoder, C)..."

+ 13 - 0
src/core/FlGenerators.cpp

@@ -781,6 +781,19 @@ bool synthFromOgun (const std::vector<std::uint8_t>& state, SynthSettings& synth
 
 // ---- Sakura ----
 
+std::optional<std::vector<float>> sakuraParams (const std::vector<std::uint8_t>& state)
+{
+    // "SSLF" + size + "Skr1" + 146 floats, raw (index 111 is an integer mode; REA_rodada28 §1.1)
+    if (state.size() < 12 + 146 * 4 || std::memcmp (state.data(), "SSLF", 4) != 0 || u32At (state.data(), 8) != 0x536B7231)
+        return std::nullopt;
+    std::vector<float> p (146);
+    std::memcpy (p.data(), state.data() + 12, sizeof (float) * 146);
+    for (std::size_t k = 0; k < 114; ++k) // floats 114…145 are not parameters
+        if (! std::isfinite (p[k]))
+            return std::nullopt;
+    return p;
+}
+
 bool synthFromSakura (const std::vector<std::uint8_t>& state, SynthSettings& synth)
 {
     if (state.size() < 12 + 146 * 4 || std::memcmp (state.data(), "SSLF", 4) != 0 || u32At (state.data(), 8) != 0x536B7231)

+ 2 - 0
src/core/FlSynths.h

@@ -167,5 +167,7 @@ std::optional<std::string> drumpadPatchName (const std::vector<std::uint8_t>& st
 SynthSettings drumToneForName (const std::string& patchName);
 // Drumpad: the 38 state parameters (2 Mallet Amplitude, 29 Pitch, …; REA_rodada18 §12)
 std::optional<std::array<float, 38>> drumpadParams (const std::vector<std::uint8_t>& state);
+// Sakura: the 146 raw state floats (0…113 are parameters) for the physical string model (REA_rodada28 §1)
+std::optional<std::vector<float>> sakuraParams (const std::vector<std::uint8_t>& state);
 std::vector<std::string> drumSampleCandidates (const std::string& soundName);
 } // namespace lynx

+ 27 - 2
src/core/FlpImport.cpp

@@ -383,6 +383,13 @@ std::optional<SynthSettings> synthFromFlPreset (const std::vector<std::uint8_t>&
         project.channels.front().type = flp::ChannelType::native; // native generator (the .fst doesn't say)
         const auto song = importFlp (project);
 
+        if (! song.channels.empty() && song.channels.front().instrument == InstrumentKind::sakura)
+        {
+            // the synth's preset button keeps the synth approximation of a Sakura patch
+            SynthSettings synth;
+            if (synthFromSakura (project.channels.front().pluginState, synth))
+                return synth;
+        }
         if (song.channels.empty() || song.channels.front().instrument != InstrumentKind::synth)
             return std::nullopt;
 
@@ -767,8 +774,18 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                 adopt();
             else if ((name == "ogun" || name == "autogun") && synthFromOgun (c.pluginState, fromPlugin, pluginGain))
                 adopt();
-            else if (name == "sakura" && synthFromSakura (c.pluginState, fromPlugin))
-                adopt();
+            else if (name == "sakura")
+            {
+                // the physical string model (REA_rodada28 §1); the old saw + triangle stays as a fallback
+                if (auto params = sakuraParams (c.pluginState))
+                {
+                    def.instrument = InstrumentKind::sakura;
+                    def.modelParams = std::move (*params);
+                    adoptedFromPlugin = true;
+                }
+                else if (synthFromSakura (c.pluginState, fromPlugin))
+                    adopt();
+            }
             else if (name == "kepler" && synthFromKepler (c.pluginState, fromPlugin, pluginGain))
                 adopt();
             else if (name == "boobass" && synthFromBooBass (c.pluginState, fromPlugin))
@@ -781,6 +798,14 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                 adopt();
             else if (name == "morphine" && synthFromMorphine (c.pluginState, fromPlugin, pluginGain))
                 adopt();
+            else if (name == "drumpad" && drumpadParams (c.pluginState))
+            {
+                // the physical drum model (REA_rodada28 §2)
+                const auto dp = drumpadParams (c.pluginState);
+                def.instrument = InstrumentKind::drumpad;
+                def.modelParams.assign (dp->begin(), dp->end());
+                adoptedFromPlugin = true;
+            }
             else if (name == "drumpad")
                 if (const auto patch = drumpadPatchName (c.pluginState))
                 {

+ 9 - 0
src/core/Instruments.cpp

@@ -1,5 +1,6 @@
 #include "core/Instruments.h"
 #include "core/FlSynths.h"
+#include "core/PhysicalModels.h"
 
 #include <algorithm>
 #include <atomic>
@@ -186,6 +187,8 @@ private:
             case InstrumentKind::audioClip:
             case InstrumentKind::plugin:
             case InstrumentKind::controller:
+            case InstrumentKind::sakura:
+            case InstrumentKind::drumpad:
                 break;
         }
 
@@ -1923,6 +1926,12 @@ std::unique_ptr<Instrument> makeInstrument (InstrumentKind kind, std::shared_ptr
     if (kind == InstrumentKind::synth)
         return std::make_unique<SynthInstrument>();
 
+    if (kind == InstrumentKind::sakura)
+        return makeSakuraInstrument();
+
+    if (kind == InstrumentKind::drumpad)
+        return makeDrumpadInstrument();
+
     return std::make_unique<DrumInstrument> (kind);
 }
 } // namespace lynx

+ 790 - 0
src/core/PhysicalModels.cpp

@@ -0,0 +1,790 @@
+#include "core/PhysicalModels.h"
+
+#include <algorithm>
+#include <array>
+#include <atomic>
+#include <cmath>
+#include <cstdint>
+#include <cstring>
+#include <vector>
+
+namespace lynx
+{
+namespace
+{
+constexpr double pi = 3.141592653589793;
+
+std::uint32_t lcg (std::uint32_t s) noexcept { return s * 0x0BB38435u + 0x3619636Bu; }
+double clamp01 (double x) noexcept { return std::clamp (x, 0.0, 1.0); }
+
+// 2-pole high-pass used by both engines (REA_rodada28 §1.4): numerator (1, −2, 1)·b, poles a1/a2
+struct HighPass
+{
+    double b = 0.0, a1 = 0.0, a2 = 0.0, x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
+
+    void design (double f, double q, double fs) noexcept
+    {
+        const auto w = 2.0 * pi * f / fs, s = std::sin (w), c = std::cos (w);
+        b = (1.0 + c) / (s / q + 2.0);
+        a1 = -2.0 * q * c / (q + s);
+        a2 = (q - s) / (q + s);
+        x1 = x2 = y1 = y2 = 0.0;
+    }
+
+    double tick (double x) noexcept
+    {
+        const auto y = (x - 2.0 * x1 + x2) * b - a2 * y2 - a1 * y1;
+        x2 = x1;
+        x1 = x;
+        y2 = y1;
+        y1 = y;
+        return y;
+    }
+};
+
+// Settings handed from configure() (UI thread) to the audio thread without blocking
+template <typename T>
+class Mailbox
+{
+public:
+    void write (const T& value) noexcept
+    {
+        bool expected = false;
+        while (! busy.compare_exchange_weak (expected, true))
+            expected = false;
+        pending = value;
+        fresh = true;
+        busy.store (false);
+    }
+
+    bool read (T& out) noexcept
+    {
+        bool expected = false;
+        if (! busy.compare_exchange_strong (expected, true))
+            return false;
+        const auto had = fresh;
+        if (had)
+            out = pending;
+        fresh = false;
+        busy.store (false);
+        return had;
+    }
+
+private:
+    std::atomic<bool> busy { false };
+    T pending {};
+    bool fresh = false;
+};
+
+// Linear resampler from the engine's internal rate to the host rate (one per instrument, shared by its voices)
+template <typename Source>
+void renderResampled (Source& source, double internalRate, double hostRate, double& position, float* left, float* right,
+                      int n, float gl, float gr, std::array<float, 2>& previous, std::array<float, 2>& current) noexcept
+{
+    const auto step = internalRate / hostRate;
+    for (int i = 0; i < n; ++i)
+    {
+        while (position >= 1.0)
+        {
+            previous = current;
+            current = source.tick();
+            position -= 1.0;
+        }
+        const auto f = (float) position;
+        left[i] += (previous[0] + (current[0] - previous[0]) * f) * gl;
+        right[i] += (previous[1] + (current[1] - previous[1]) * f) * gr;
+        position += step;
+    }
+}
+
+// ---------------------------------------------------------------------------
+// Sakura (REA_rodada28 §1): exciter → 4 string loops (near/far × 2 strings) → combs → stereo mix → amp envelope
+// → 32 Hz high-pass → master gain. Modulation matrix routings, EG/LFO destinations, resonators and FX are not
+// modelled (their shapes were not confirmed).
+
+using SakuraParams = std::array<float, sakuraParamCount>;
+
+struct SakuraVoice
+{
+    bool active = false;
+    int key = 0;
+    // per-note
+    int lens[4] {}, combLen[2] {};
+    std::array<std::vector<float>, 4> loops;
+    std::array<std::vector<float>, 2> combs;
+    int ptr[4] {}, combPtr[2] {};
+    double kdc[4] {}, step = 0.0;
+    // state
+    std::uint32_t seed = 0;
+    double hold = 0.0, s[3] {}, z4 = 0.0, hiCutEnv = 0.0;
+    double mean[4] {}, slow[4] {}, z[4] {};
+    double fbs[4] {}, gains[4] {};
+    double acc = 0.0, prev[2] {}, cur[2] {};
+    double env = 0.0, elapsed = 0.0, release = -1.0;
+    HighPass lowCut;
+    int blockLeft = 0;
+    double hcTarget = 0.0, hcRate = 0.0, envTarget = 0.0, envRate = 0.0;
+    double level = 1.0; // modulation-matrix level relative to the default ×5 (velocity/note routings)
+};
+
+class SakuraInstrument final : public Instrument
+{
+public:
+    static constexpr double fs = 48000.0;
+    static constexpr int maxVoices = 12;
+    static constexpr int maxLength = 9600; // FL allows 48 000 (notes down to 1 Hz); LYNX keeps ≥ 20 Hz × 4 in memory
+
+    SakuraInstrument()
+    {
+        for (auto& v : voices)
+        {
+            for (auto& l : v.loops)
+                l.assign (maxLength + 1, 0.0f);
+            for (auto& c : v.combs)
+                c.assign (maxLength + 1, 0.0f);
+        }
+    }
+
+    void prepare (double sr) noexcept override
+    {
+        hostRate = sr;
+        outHp[0].design (32.0, 1.0, sr);
+        outHp[1].design (32.0, 1.0, sr);
+        allNotesOff();
+    }
+
+    void configure (const ChannelDef& channel, double) noexcept override
+    {
+        SakuraParams p {};
+        for (std::size_t i = 0; i < p.size() && i < channel.modelParams.size(); ++i)
+            p[i] = std::isfinite (channel.modelParams[i]) ? channel.modelParams[i] : 0.0f;
+        mailbox.write (p);
+    }
+
+    void noteOn (int key, float velocity) noexcept override
+    {
+        mailbox.read (params); // the note's lengths and laws come from the latest settings
+        SakuraVoice* target = nullptr;
+        for (auto& v : voices)
+            if (! v.active)
+            {
+                target = &v;
+                break;
+            }
+        if (target == nullptr)
+            target = &voices[(std::size_t) (nextSteal++ % maxVoices)];
+        start (*target, key);
+        target->level = matrixLevel (velocity, key);
+    }
+
+    void noteOff (int key) noexcept override
+    {
+        for (auto& v : voices)
+            if (v.active && v.key == key && v.release < 0.0)
+                v.release = 0.0;
+    }
+
+    void allNotesOff() noexcept override
+    {
+        for (auto& v : voices)
+            v.active = false;
+    }
+
+    bool idle() const noexcept override
+    {
+        return std::none_of (voices.begin(), voices.end(), [] (const SakuraVoice& v) { return v.active; });
+    }
+
+    void render (float* left, float* right, int n, float gl, float gr) noexcept override
+    {
+        mailbox.read (params);
+        // × 1/√2: FL's per-voice levels are Vol·cos/sin((1 + pan)π/4) and LYNX's channel gains √2·cos/sin (§4)
+        const auto master = (float) (std::pow (10.0, 4.8 * params[0] - 1.8) * 0.70710678);
+        struct Source
+        {
+            SakuraInstrument& self;
+            std::array<float, 2> tick() noexcept { return self.tickVoices(); }
+        } source { *this };
+        // render at 48 kHz into the stereo stream, resampled to the host, then the 32 Hz HP and master gain
+        for (int i = 0; i < n; ++i)
+        {
+            float l = 0.0f, r = 0.0f;
+            renderResampled (source, fs, hostRate, position, &l, &r, 1, 1.0f, 1.0f, previous, current);
+            left[i] += (float) outHp[0].tick (l) * master * gl;
+            right[i] += (float) outHp[1].tick (r) * master * gr;
+        }
+    }
+
+private:
+    double p (int i) const noexcept { return i >= 0 && i < sakuraParamCount ? (double) params[(std::size_t) i] : 0.0; }
+
+    // modulation matrix, destination 1 (level, §1.9): m = Σ amount²·source over the slots routed to it (sign by
+    // "invert"); with no routed slot on destinations 0/1, m = 1. Level = 10^(2m)·0.05 (m = 1 → ×5, the default).
+    // Static sources only: velocity (vel/127) and note number × 0.0125; mod wheel, pressure, bend and the release
+    // gate are 0 while the note is held; EG and LFO shapes were not decoded (their slots count as 0).
+    double matrixLevel (float velocity, int key) const noexcept
+    {
+        bool routed = false;
+        double m = 0.0;
+        for (int slot = 0; slot < 8; ++slot)
+        {
+            const auto source = (int) p (79 + 4 * slot), destination = (int) p (82 + 4 * slot);
+            if (source == 0 || (destination != 0 && destination != 1))
+                continue;
+            routed = true;
+            if (destination != 1)
+                continue;
+            const auto amount = p (80 + 4 * slot) * p (80 + 4 * slot) * (p (81 + 4 * slot) != 0.0 ? -1.0 : 1.0);
+            const auto value = source == 6 ? std::clamp ((double) velocity, 0.0, 1.0) : source == 7 ? key * 0.0125 : 0.0;
+            m += amount * value;
+        }
+        if (! routed)
+            m = 1.0;
+        return std::pow (10.0, 2.0 * m) * 0.05 / 5.0;
+    }
+
+    static void damping (double a, double offsetSquared, double& nearC, double& farC) noexcept
+    {
+        const auto base = std::pow (50.0, 2.57 - 0.8995 * a * a * a) * (2.0 / 44100.0);
+        nearC = std::min (1.0, base);
+        farC = std::min (1.0, (1.0 - offsetSquared) * base);
+    }
+
+    void start (SakuraVoice& v, int key) noexcept
+    {
+        static constexpr double octaves[7] { 0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0 };
+        auto f = 220.0 * std::pow (2.0, (key - 57) / 12.0) * octaves[std::clamp ((int) (p (113) * 6.0), 0, 6)];
+        const auto base = std::max (1, (int) (48000.0 / f));
+        int l1 = base, l2 = base;
+        switch ((int) p (111))
+        {
+            case 0: l2 = base / 4; l1 = l2 * 4; break;
+            case 1: l2 = base / 3; l1 = l2 * 3; break;
+            case 2: l2 = base / 2; l1 = l2 * 2; break;
+            case 4: l2 = 2 * base; break;
+            case 5: l2 = 3 * base; break;
+            case 6: l2 = 4 * base; break;
+            default: break;
+        }
+        l1 = std::clamp (l1, 1, maxLength);
+        l2 = std::clamp (l2, 1, maxLength);
+        v.lens[0] = v.lens[1] = l1;
+        v.lens[2] = v.lens[3] = l2;
+        const auto rate = 48000.0 / l1;
+        v.kdc[0] = v.kdc[1] = 1.0 / l1;
+        v.kdc[2] = v.kdc[3] = 1.0 / l2;
+        const auto ratio = p (19);
+        v.combLen[0] = std::clamp ((int) (l1 * ratio), 1, maxLength);
+        v.combLen[1] = std::clamp ((int) (l2 * ratio), 1, maxLength);
+        for (int j = 0; j < 4; ++j)
+        {
+            std::fill (v.loops[(std::size_t) j].begin(), v.loops[(std::size_t) j].begin() + v.lens[j], 0.0f);
+            v.ptr[j] = 0;
+            v.mean[j] = v.slow[j] = v.z[j] = 0.0;
+        }
+        for (int c = 0; c < 2; ++c)
+        {
+            std::fill (v.combs[(std::size_t) c].begin(), v.combs[(std::size_t) c].begin() + v.combLen[c], 0.0f);
+            v.combPtr[c] = 0;
+        }
+        const auto tune = std::clamp ((int) (p (1) * 198.0 - 99.0), -99, 99) * 0.01;
+        v.step = f / rate * std::pow (2.0, tune / 12.0);
+        v.seed = 0;
+        v.hold = 0.0;
+        v.s[0] = v.s[1] = v.s[2] = 0.0;
+        v.z4 = v.hiCutEnv = 0.0;
+        v.acc = 0.0;
+        v.prev[0] = v.prev[1] = v.cur[0] = v.cur[1] = 0.0;
+        v.env = v.elapsed = 0.0;
+        v.release = -1.0;
+        v.lowCut.design (std::pow (2.0, 9.3 * clamp01 (p (24)) + 5.0), 10.0 * p (25) + 1.0, fs);
+        v.blockLeft = 0;
+        v.key = key;
+        v.active = true;
+        for (int j = 0; j < 4; ++j)
+            v.fbs[j] = v.gains[j] = 0.0;
+        computeStatic();
+        for (int j = 0; j < 4; ++j)
+            v.fbs[j] = feedback[j], v.gains[j] = mixGain[j];
+    }
+
+    // per-block static values (no modulation)
+    void computeStatic() noexcept
+    {
+        saturation = 100.0 * std::pow (p (16), 6.0);
+        threshold = 0.996 * std::pow (1.0 - clamp01 (p (32)), 0.25);
+        drive = 1000.0 * std::pow (p (33), 4.0);
+        noiseA = (1.0 - p (31)) * (1.0 - p (31));
+        noiseB = p (31);
+        ladderG = clamp01 (p (29) * p (29));
+        ladderR = std::max (-10.0 * p (30) * (1.0 - ladderG), -4.0);
+        double c0, c1, c2, c3;
+        damping (clamp01 (p (9)), p (8) * p (8), c0, c1);
+        damping (clamp01 (p (14)), p (13) * p (13), c2, c3);
+        const auto sh1 = -0.5 * p (10) * p (10), sh2 = -0.5 * p (15) * p (15);
+        coef[0] = c0, coef[1] = c1, coef[2] = c2, coef[3] = c3;
+        sharp[0] = (1.0 - c0) * sh1, sharp[1] = (1.0 - c1) * sh1, sharp[2] = (1.0 - c2) * sh2, sharp[3] = (1.0 - c3) * sh2;
+        const auto fb1 = std::pow (clamp01 (p (6)), 0.05) * (p (7) != 0.0 ? -1.0 : 1.0);
+        const auto fb2 = std::pow (clamp01 (p (11)), 0.05) * (p (12) != 0.0 ? -1.0 : 1.0);
+        feedback[0] = feedback[1] = fb1;
+        feedback[2] = feedback[3] = fb2;
+        const auto sep = clamp01 (p (18)), sep2 = clamp01 (1.0 - p (18));
+        const auto g1 = (1.0 - p (17)) * 100.0 * 0.05, g2 = p (17) * 100.0 * 0.05;
+        mixGain[0] = (1.0 - sep) * g1, mixGain[1] = sep * g1, mixGain[2] = (1.0 - sep2) * g2, mixGain[3] = sep2 * g2;
+        combFeedback = std::sqrt (std::max (0.0, p (20))) * (p (21) != 0.0 ? -1.0 : 1.0);
+        combLevel = p (22) * (p (23) != 0.0 ? -1.0 : 1.0);
+        auto f32 = [] (double x) { return (double) (float) x; };
+        attack = f32 (35.0 * std::pow (p (2), 5.0) + 0.001);
+        decay = f32 (50.0 * std::pow (p (3), 5.0) + 0.001);
+        sustain = f32 (p (4) * p (4));
+        releaseTime = f32 (10.0 * std::pow (p (5), 5.0) + 0.1);
+        hcAttack = f32 (p (26) * p (26) * 0.5);
+        hcDecay = p (27);
+        hcSustain = p (28) * p (28);
+    }
+
+    // one 48 kHz sample of all voices
+    std::array<float, 2> tickVoices() noexcept
+    {
+        double outL = 0.0, outR = 0.0;
+        for (auto& v : voices)
+            if (v.active)
+            {
+                const auto [l, r] = tickVoice (v);
+                outL += l;
+                outR += r;
+            }
+        return { (float) outL, (float) outR };
+    }
+
+    std::array<double, 2> tickVoice (SakuraVoice& v) noexcept
+    {
+        constexpr double blockSeconds = 48.0 / 48000.0;
+        if (v.blockLeft <= 0) // 48-sample control block: envelope targets and smoothed values reset
+        {
+            v.blockLeft = 48;
+            computeStatic();
+            if (v.release < 0.0)
+            {
+                if (hcAttack < v.elapsed)
+                    v.hcRate = 0.0002 / (3.0 * hcDecay * hcDecay * hcDecay + 0.001), v.hcTarget = hcSustain;
+                else
+                    v.hcTarget = 1.0, v.hcRate = hcAttack >= 0.001 ? 0.0002 / hcAttack : 1.0;
+                if (attack <= v.elapsed)
+                    v.envTarget = sustain, v.envRate = 8.82 / (decay * 48000.0);
+                else
+                    v.envTarget = 5.0, v.envRate = 4.658742368e-06 / attack;
+            }
+            else
+            {
+                v.hcRate = 0.002;
+                v.hcTarget = 0.0;
+                if (releaseTime < v.release)
+                {
+                    v.active = false;
+                    return { 0.0, 0.0 };
+                }
+                v.envTarget = 0.0;
+                v.envRate = 8.82 / (releaseTime * 48000.0);
+                v.release += blockSeconds;
+            }
+            for (int j = 0; j < 4; ++j)
+                v.fbs[j] = feedback[j], v.gains[j] = mixGain[j];
+            v.elapsed += blockSeconds;
+        }
+        --v.blockLeft;
+
+        // exciter: sample-and-hold noise / click → Lo-Cut → 4-pole Hi-Cut with envelope, resonance and drive
+        const auto x = v.seed * (1.0 / 4294967296.0);
+        v.seed = lcg (lcg (lcg (lcg (v.seed))));
+        if (x > threshold)
+            v.hold = x;
+        const auto y = v.lowCut.tick (noiseA * v.hold + noiseB);
+        v.hiCutEnv += (v.hcTarget - v.hiCutEnv) * v.hcRate;
+        const auto c = ladderG * v.hiCutEnv;
+        v.s[0] += ((ladderR * v.z4 + y) - v.s[0]) * c;
+        v.s[1] += (v.s[0] - v.s[1]) * c;
+        v.s[2] += (v.s[1] - v.s[2]) * c;
+        const auto w = v.z4 + (v.s[2] - v.z4) * c;
+        v.z4 = w / (w * w * drive + 1.0);
+        const auto e = v.z4;
+
+        // the loops run once per crossing of the fractional clock
+        v.acc += v.step;
+        auto k = (int) v.acc;
+        v.acc -= k;
+        double d[4];
+        for (int j = 0; j < 4; ++j)
+            d[j] = e - v.mean[j];
+        for (; k > 0; --k)
+        {
+            v.prev[0] = v.cur[0];
+            v.prev[1] = v.cur[1];
+            double rr[4];
+            for (int j = 0; j < 4; ++j)
+                if (v.ptr[j] >= v.lens[j])
+                    v.ptr[j] = 0;
+            for (int j = 0; j < 4; ++j)
+            {
+                v.mean[j] += v.kdc[j] * d[j];
+                d[j] = e - v.mean[j];
+                auto& line = v.loops[(std::size_t) j];
+                const auto r = (double) line[(std::size_t) v.ptr[j]];
+                rr[j] = r;
+                v.slow[j] += ((sharp[j] * v.z[j] + r) - v.slow[j]) * coef[j];
+                const auto vv = v.z[j] + (v.slow[j] - v.z[j]) * coef[j];
+                v.z[j] = vv / (vv * vv * saturation + 1.0);
+                line[(std::size_t) v.ptr[j]] = (float) (v.fbs[j] * v.z[j] + d[j]);
+                ++v.ptr[j];
+            }
+            for (int cIdx = 0; cIdx < 2; ++cIdx)
+                if (v.combPtr[cIdx] >= v.combLen[cIdx])
+                    v.combPtr[cIdx] = 0;
+            auto& ca = v.combs[0];
+            auto& cb = v.combs[1];
+            const auto oA = combLevel * ca[(std::size_t) v.combPtr[0]] + rr[0];
+            const auto oB = combLevel * cb[(std::size_t) v.combPtr[1]] + rr[2];
+            v.cur[0] = v.gains[2] * oB + v.gains[0] * oA;
+            v.cur[1] = v.gains[3] * oB + v.gains[1] * oA;
+            ca[(std::size_t) v.combPtr[0]] = (float) (ca[(std::size_t) v.combPtr[0]] * combFeedback + rr[1]);
+            cb[(std::size_t) v.combPtr[1]] = (float) (cb[(std::size_t) v.combPtr[1]] * combFeedback + rr[3]);
+            ++v.combPtr[0];
+            ++v.combPtr[1];
+            for (int j = 0; j < 4; ++j)
+            {
+                v.fbs[j] += (feedback[j] - v.fbs[j]) * 0.05;
+                v.gains[j] += (mixGain[j] - v.gains[j]) * 0.001;
+            }
+        }
+        const auto outL = ((v.cur[0] - v.prev[0]) * v.acc + v.prev[0]) * v.env * v.level;
+        const auto outR = ((v.cur[1] - v.prev[1]) * v.acc + v.prev[1]) * v.env * v.level;
+        v.env = std::min (1.0, (v.envTarget - v.env) * v.envRate + v.env);
+        return { outL, outR };
+    }
+
+    Mailbox<SakuraParams> mailbox;
+    SakuraParams params {};
+    std::array<SakuraVoice, maxVoices> voices {};
+    int nextSteal = 0;
+    double hostRate = 48000.0, position = 1.0;
+    std::array<float, 2> previous {}, current {};
+    HighPass outHp[2];
+    // static per-block values
+    double saturation = 0.0, threshold = 1.0, drive = 0.0, noiseA = 1.0, noiseB = 0.0, ladderG = 0.0, ladderR = 0.0;
+    double coef[4] {}, sharp[4] {}, feedback[4] {}, mixGain[4] {};
+    double combFeedback = 0.0, combLevel = 0.0;
+    double attack = 0.001, decay = 0.001, sustain = 1.0, releaseTime = 0.1, hcAttack = 0.0, hcDecay = 0.0, hcSustain = 0.0;
+};
+
+// ---------------------------------------------------------------------------
+// Drumpad (REA_rodada28 §2): mallet exciter → bank of independent comb loops (length 512 − i, low-pass x²,
+// feedback −Decay^0.3, folded-triangle output weights) → self-oscillating filter → LOW high-pass → HIGH shelf →
+// MID peak (enveloped) → clip → hold → lo-fi, at 38 kHz. No key tracking (the DSP has none).
+
+using DrumpadParams = std::array<float, drumpadParamCount>;
+
+struct Rbj
+{
+    double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, x1 = 0, x2 = 0, y1 = 0, y2 = 0;
+
+    void design (int kind, double f, double gainDb, double bandwidth, double fs) noexcept
+    {
+        const auto a = std::pow (10.0, gainDb * 0.05);
+        const auto w = std::clamp (f * 6.283185 / fs, 0.0, 3.0);
+        const auto sn = std::sin (w), cs = std::cos (w);
+        const auto sh = std::sinh (0.3465736 * bandwidth * w / sn);
+        const auto alpha = sn * sh, beta = std::sqrt (a) * 2.0 * sh * sn;
+        double nb0, nb1, nb2, na0, na1, na2;
+        if (kind == 1) // peaking
+            nb0 = 1 + alpha * a, nb1 = -2 * cs, nb2 = 1 - alpha * a, na0 = 1 + alpha / a, na1 = -2 * cs, na2 = 1 - alpha / a;
+        else // high shelf
+        {
+            nb0 = a * ((a + 1) + (a - 1) * cs + beta);
+            nb1 = -2 * a * ((a - 1) + (a + 1) * cs);
+            nb2 = a * ((a + 1) + (a - 1) * cs - beta);
+            na0 = (a + 1) - (a - 1) * cs + beta;
+            na1 = 2 * ((a - 1) - (a + 1) * cs);
+            na2 = (a + 1) - (a - 1) * cs - beta;
+        }
+        b0 = nb0 / na0, b1 = nb1 / na0, b2 = nb2 / na0, a1 = na1 / na0, a2 = na2 / na0;
+    }
+
+    double tick (double x) noexcept
+    {
+        const auto y = x * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2;
+        x2 = x1, x1 = x, y2 = y1, y1 = y;
+        return y;
+    }
+};
+
+class DrumpadInstrument final : public Instrument
+{
+public:
+    static constexpr double fs = 38000.0;
+    static constexpr int rings = 128; // groups of 4 lanes: lane i of group k has length 512 − 4k
+
+    DrumpadInstrument()
+    {
+        for (int k = 0; k < rings; ++k)
+            ring[(std::size_t) k].assign ((std::size_t) (512 - 4 * k), {});
+    }
+
+    void prepare (double sr) noexcept override
+    {
+        hostRate = sr;
+        allNotesOff();
+    }
+
+    void configure (const ChannelDef& channel, double) noexcept override
+    {
+        DrumpadParams p {};
+        for (std::size_t i = 0; i < p.size() && i < channel.modelParams.size(); ++i)
+            p[i] = std::isfinite (channel.modelParams[i]) ? channel.modelParams[i] : 0.0f;
+        mailbox.write (p);
+    }
+
+    // one voice (Drumpad retriggers it; the loops keep their contents across notes)
+    void noteOn (int, float velocity) noexcept override
+    {
+        mailbox.read (raw);
+        computeParams (std::sqrt (std::clamp ((double) velocity, 0.0, 1.0)));
+        e = amp;
+        if (retrig)
+            seed = noiseSeed;
+        lowCut.design (lowF, lowQ, fs);
+        high.design (2, highF, highDb, std::max (highBw, 1e-4), fs);
+        high.x1 = high.x2 = high.y1 = high.y2 = 0.0;
+        mid.x1 = mid.x2 = mid.y1 = mid.y2 = 0.0;
+        envMid = 1.0;
+        midCount = 0;
+        midRetrig = midRetrigCount;
+        const auto c = std::pow (2.0, (sofF * 0.5 + 0.1) * 9.3 + 5.0) * 0.00015789474;
+        sc = (float) std::clamp (c, 0.0, 1.0);
+        sk = sc * 333.3333333333333f;
+        senv = 1.0f;
+        s1 = s2 = s3 = y4 = 0.0f;
+        gain = 1.0;
+        t = 0.0;
+        sounding = true;
+        silentFor = 0;
+    }
+
+    void noteOff (int) noexcept override {}
+    void allNotesOff() noexcept override { sounding = false; }
+    bool idle() const noexcept override { return ! sounding; }
+
+    void render (float* left, float* right, int n, float gl, float gr) noexcept override
+    {
+        if (! sounding)
+            return;
+        struct Source
+        {
+            DrumpadInstrument& self;
+            std::array<float, 2> tick() noexcept
+            {
+                const auto x = (float) self.tick();
+                return { x, x };
+            }
+        } source { *this };
+        // × 1/√2: FL's per-voice levels are Vol·cos/sin((1 + pan)π/4), LYNX's channel gains √2·cos/sin (REA_rodada28 §4)
+        renderResampled (source, fs * pitch, hostRate, position, left, right, n, gl * 0.70710678f, gr * 0.70710678f, previous, current);
+        // the voice ends when the hold gain has decayed and the bank is quiet
+        if (gain < 1e-5 && std::abs (current[0]) < 1e-6f)
+            sounding = false;
+    }
+
+private:
+    double g (int k, double velocity) const noexcept
+    {
+        const auto value = (double) raw[(std::size_t) k];
+        auto alt = value;
+        for (int slot = 0; slot < 4; ++slot) // velocity morph: params 30…33 = target index − 1, 34…37 = value at velocity 1
+            if (const auto target = (int) raw[(std::size_t) (30 + slot)]; target != 0 && target + 1 == k)
+                alt = raw[(std::size_t) (34 + slot)];
+        return (1.0 - velocity) * value + alt * velocity;
+    }
+
+    void computeParams (double vel) noexcept
+    {
+        cut = std::pow (clamp01 (g (7, vel)), 2.0);
+        fb = -std::pow (clamp01 (g (6, vel)), 0.3);
+        const auto phase = clamp01 (g (9, vel)), tension = clamp01 (g (8, vel)), material = clamp01 (g (10, vel));
+        size = std::min (0x1ff, (int) (clamp01 (1.0 - g (11, vel)) * 512.0));
+        shape = std::clamp ((int) (g (12, vel) * 128.0), 1, 128);
+        amp = std::pow (10.0, (1.0 - clamp01 (g (2, vel))) * -4.0);
+        const auto md = 1.0 - clamp01 (g (3, vel));
+        malletDecay = (std::pow (md, 4.0) * 500.0 + 1.0) * 1e-4;
+        noise = clamp01 (g (4, vel));
+        retrig = raw[0] != 0.0f;
+        noiseSeed = (std::uint32_t) ((std::uint64_t) ((double) (float) g (5, vel) * 4294967295.0) & 0xffffffffu);
+        const auto lf = clamp01 (g (27, vel));
+        lofi = lf >= 0.01 ? (int) (std::pow (1.0 - lf, 5.0) * 65536.0 + 4.0) : 0;
+        holdTime = std::pow (clamp01 (g (28, vel)), 3.0) * 3.0 + 0.001;
+        pitch = std::pow (2.0, 2.0 * clamp01 (g (29, vel)) - 1.0);
+        lowOn = g (13, vel) != 0.0;
+        lowF = std::pow (2.0, clamp01 (g (13, vel)) * 11.0 + 2.0);
+        lowQ = clamp01 (g (14, vel)) * 8.0 + 1.0;
+        highF = std::pow (2.0, clamp01 (g (24, vel)) * 4.1 + 8.0);
+        highBw = (1.0 - clamp01 (g (26, vel))) * 2.0 + 0.5;
+        highDb = (clamp01 (g (25, vel)) - 0.5) * 36.0;
+        highOn = std::abs (highDb) > 0.01;
+        midF = std::pow (2.0, clamp01 (g (18, vel)) * 9.0 + 5.0);
+        midFmod = (clamp01 (g (21, vel)) - 0.5) * 32.0;
+        const auto lv = g (19, vel), lm = g (22, vel);
+        midLevelOn = lv != 0.5;
+        midDb = (clamp01 (lv) - 0.5) * 32.0;
+        midLmodOn = lm != 0.5;
+        midLmod = (clamp01 (lm) - 0.5) * 48.0;
+        midBw = (1.0 - clamp01 (g (20, vel))) * 4.0 + 0.5;
+        const auto ma = 1.0 - clamp01 (g (23, vel));
+        midAttack = (std::pow (ma, 4.0) * 1000.0 + 1.0) * 1e-5;
+        midRetrigCount = std::clamp ((int) (raw[1] * 3.0f), 0, 3);
+        sofF = clamp01 (g (15, vel));
+        const auto sd = clamp01 (g (16, vel));
+        sofDecay = (float) ((std::pow (sd, 4.0) * 0.25 * 250.0 + 1.0) * 1e-5);
+        sofOn = g (17, vel) != 0.0;
+        sofLevel = (float) (std::pow (clamp01 (g (17, vel)), 8.0) * 0.5);
+
+        // output weights: folded triangle raised to the Material exponent, over the lanes Size…Size + Shape
+        const auto m = 2.0 * material - 1.0;
+        auto ex = 1.0 + 20.0 * std::pow (m, 4.0);
+        if (m < 0.0)
+            ex = 1.0 / ex;
+        const auto stp = 0.5 * std::pow (tension, 4.0);
+        auto ph = phase;
+        weights.fill (0.0);
+        const auto top = std::min (size + shape, 0x1ff);
+        for (int i = 511; i >= 0; --i)
+        {
+            if (i >= size && i <= top)
+            {
+                auto x = (ph - 0.5) + ph - 0.5;
+                if (x > 0.5)
+                    x = 1.0 - x;
+                if (x < -0.5)
+                    x = -1.0 - x;
+                const auto x2 = x + x;
+                weights[(std::size_t) i] = x2 < 0.0 ? -std::pow (std::abs (x2), ex) : std::pow (x2, ex);
+            }
+            ph += stp;
+            if (ph > 1.0)
+                ph -= 1.0;
+        }
+        firstRing = std::clamp (size / 4, 0, 127);
+        const auto end = size + shape >= 0x200 ? 128 : std::min (128, (size + shape) / 4 + ((size + shape) % 4 != 0 ? 1 : 0));
+        ringCount = std::max (0, end - firstRing);
+    }
+
+    double tick() noexcept
+    {
+        e = (1e-7 - e) * malletDecay + e;
+        const auto nz = seed * (1.0 / 4294967296.0);
+        seed = lcg (seed);
+        const auto exc = ((nz - 0.5) * noise + (1.0 - noise)) * e;
+        double acc = 0.0;
+        for (int k = firstRing; k < firstRing + ringCount; ++k)
+        {
+            auto& r = ring[(std::size_t) k];
+            const auto len = (int) r.size();
+            auto& p = ptr[(std::size_t) k];
+            auto& lp = lowPass[(std::size_t) k];
+            // lanes 1…3 are shorter by 1…3 samples: their last cells mirror the start of the ring
+            if (p == len - 1)
+                r[(std::size_t) p][1] = r[0][1];
+            if (p == len - 2)
+                r[(std::size_t) p][2] = r[0][2], r[(std::size_t) p + 1][2] = r[1][2];
+            if (p == len - 3)
+                r[(std::size_t) p][3] = r[0][3], r[(std::size_t) p + 1][3] = r[1][3], r[(std::size_t) p + 2][3] = r[2][3];
+            auto& cell = r[(std::size_t) p];
+            for (int j = 0; j < 4; ++j)
+            {
+                acc += cell[(std::size_t) j] * weights[(std::size_t) (4 * k + j)];
+                lp[(std::size_t) j] = (cell[(std::size_t) j] - lp[(std::size_t) j]) * cut + lp[(std::size_t) j];
+                cell[(std::size_t) j] = lp[(std::size_t) j] * fb + exc;
+            }
+            if (++p == len)
+            {
+                for (int q = 0; q < len - 1; ++q)
+                    r[(std::size_t) q][1] = r[(std::size_t) q + 1][1];
+                for (int q = 0; q < len - 2; ++q)
+                    r[(std::size_t) q][2] = r[(std::size_t) q + 2][2];
+                for (int q = 0; q < len - 3; ++q)
+                    r[(std::size_t) q][3] = r[(std::size_t) q + 3][3];
+                p = 0;
+            }
+        }
+        auto x = acc;
+        if (sofOn) // self-oscillating filter, in float32 as in the DLL (its −100000 feedback needs it)
+        {
+            const auto y4o = y4;
+            const auto a = (float) ((float) x + y4o * -100000.0f);
+            x = (float) ((float) x + y4o * sofLevel);
+            const auto gg = sc / ((sk + 1.0f) - senv * sk);
+            const auto tt = a / (std::abs (a) * 0.005f + 1.0f);
+            s1 = (tt - s1) * gg + s1;
+            s2 = (s1 - s2) * gg + s2;
+            s3 = (s2 - s3) * gg + s3;
+            senv = senv - senv * sofDecay;
+            y4 = (s3 - y4o) * gg + y4o;
+        }
+        if (lowOn)
+            x = lowCut.tick (x);
+        if (highOn)
+            x = high.tick (x);
+        if (midLevelOn || midLmodOn)
+        {
+            if (midCount == 0)
+            {
+                const auto db = (1.0 - envMid) * midLmod + midDb;
+                const auto fm = midFmod * (1.0 - envMid);
+                auto f = midFmod >= 0.0 ? (fm + 1.0) * midF : midF / (1.0 - fm);
+                f = std::clamp (std::max (32.0, f), 0.0, 12000.0);
+                const auto keep = mid;
+                mid.design (1, f, db, std::max (midBw, 1e-4), fs);
+                mid.x1 = keep.x1, mid.x2 = keep.x2, mid.y1 = keep.y1, mid.y2 = keep.y2;
+            }
+            midCount = (midCount + 1) % 6;
+            envMid -= envMid * midAttack;
+            if (midRetrig != 0 && envMid < 0.01)
+                envMid = 1.0, --midRetrig;
+            x = mid.tick (x);
+        }
+        x = std::clamp (x, -1.0, 1.0);
+        if (holdTime <= t)
+            gain -= gain * 0.001;
+        else
+            gain = (1.0 - gain) * 0.1 + gain;
+        t += 2.6315789e-05;
+        x *= gain;
+        if (lofi != 0)
+            x = (double) (int) (lofi * x) / lofi;
+        return x;
+    }
+
+    Mailbox<DrumpadParams> mailbox;
+    DrumpadParams raw {};
+    std::array<std::vector<std::array<double, 4>>, rings> ring;
+    std::array<int, rings> ptr {};
+    std::array<std::array<double, 4>, rings> lowPass {};
+    std::array<double, 512> weights {};
+    int firstRing = 0, ringCount = 0;
+    double cut = 0, fb = 0, amp = 1e-4, malletDecay = 1e-4, noise = 0, holdTime = 1, pitch = 1;
+    int size = 0, shape = 1, lofi = 0, midRetrigCount = 0, midRetrig = 0, midCount = 0;
+    bool retrig = false, lowOn = false, highOn = false, midLevelOn = false, midLmodOn = false, sofOn = false, sounding = false;
+    std::uint32_t seed = 0, noiseSeed = 0;
+    double lowF = 100, lowQ = 1, highF = 1000, highBw = 1, highDb = 0, midF = 1000, midFmod = 0, midDb = 0, midLmod = 0,
+           midBw = 1, midAttack = 1e-5;
+    double sofF = 0;
+    float sofDecay = 0, sofLevel = 0, sc = 0, sk = 0, senv = 1, s1 = 0, s2 = 0, s3 = 0, y4 = 0;
+    double e = 0, envMid = 1, gain = 1, t = 0;
+    HighPass lowCut;
+    Rbj high, mid;
+    double hostRate = 48000.0, position = 1.0;
+    std::array<float, 2> previous {}, current {};
+    int silentFor = 0;
+};
+} // namespace
+
+std::unique_ptr<Instrument> makeSakuraInstrument() { return std::make_unique<SakuraInstrument>(); }
+std::unique_ptr<Instrument> makeDrumpadInstrument() { return std::make_unique<DrumpadInstrument>(); }
+} // namespace lynx

+ 19 - 0
src/core/PhysicalModels.h

@@ -0,0 +1,19 @@
+#pragma once
+
+// Physical-model instruments rebuilt from FL Studio's Sakura (strings) and Drumpad (drum) engines, following the
+// behaviour decoded in docs/analise/REA_rodada28.md (clean-room; checked against the installation's DLL renders).
+// Both run at their engine's internal rate (Sakura 48 kHz, Drumpad 38 kHz) and are resampled linearly to the
+// host rate, as the originals do. Parameters are FL's raw state values (ChannelDef::modelParams).
+
+#include <memory>
+
+#include "core/Instruments.h"
+
+namespace lynx
+{
+constexpr int sakuraParamCount = 146; // "Skr1" state floats (0…113 are parameters)
+constexpr int drumpadParamCount = 38;
+
+std::unique_ptr<Instrument> makeSakuraInstrument();
+std::unique_ptr<Instrument> makeDrumpadInstrument();
+} // namespace lynx

+ 4 - 1
src/core/Song.h

@@ -35,7 +35,9 @@ enum class InstrumentKind : std::uint8_t
     sampler,
     audioClip, // sampler without transposition that stops at the end of the clip (audio clip channel, as in FL)
     plugin,    // external instrument (VST3), created by the app
-    controller // makes no sound: notes trigger envelopes that modulate other parameters (FL's Envelope Controller)
+    controller, // makes no sound: notes trigger envelopes that modulate other parameters (FL's Envelope Controller)
+    sakura,     // physical string model (FL's Sakura engine, REA_rodada28 §1); parameters in ChannelDef::modelParams
+    drumpad     // physical drum model (FL's Drumpad engine, REA_rodada28 §2); parameters in ChannelDef::modelParams
 };
 
 // External plugin: format identifier (the app knows how to find the file) + saved state.
@@ -234,6 +236,7 @@ struct ChannelDef
     int mixerTrack = 0;     // 0 = straight to Master
     PluginRef plugin;       // used when instrument == plugin
     std::vector<std::uint8_t> controllerState; // instrument == controller: FL Envelope Controller state
+    std::vector<float> modelParams; // instrument == sakura / drumpad: FL's raw state parameters
     SamplerSettings sampler; // used when instrument == sampler
     SynthSettings synth;     // used when instrument == synth
     float swingMix = 1.0f;   // how much of the global swing applies to this channel (0..1), as in FL

+ 15 - 1
src/engine/ProjectFile.cpp

@@ -65,6 +65,8 @@ const char* instrumentId (InstrumentKind k)
         case InstrumentKind::audioClip: return "audioClip";
         case InstrumentKind::plugin: return "plugin";
         case InstrumentKind::controller: return "controller";
+        case InstrumentKind::sakura: return "sakura";
+        case InstrumentKind::drumpad: return "drumpad";
     }
     return "synth";
 }
@@ -73,7 +75,7 @@ InstrumentKind instrumentFromId (const juce::String& id)
 {
     for (auto k : { InstrumentKind::kick, InstrumentKind::snare, InstrumentKind::hat, InstrumentKind::clap,
                     InstrumentKind::synth, InstrumentKind::sampler, InstrumentKind::audioClip,
-                    InstrumentKind::plugin, InstrumentKind::controller })
+                    InstrumentKind::plugin, InstrumentKind::controller, InstrumentKind::sakura, InstrumentKind::drumpad })
         if (id == instrumentId (k))
             return k;
 
@@ -378,6 +380,13 @@ juce::String toJson (const Song& song)
 
         if (! c.controllerState.empty())
             o->setProperty ("controllerState", juce::Base64::toBase64 (c.controllerState.data(), c.controllerState.size()));
+        if (! c.modelParams.empty())
+        {
+            juce::StringArray values;
+            for (auto v : c.modelParams)
+                values.add (juce::String (v, 7));
+            o->setProperty ("modelParams", values.joinIntoString (" "));
+        }
 
         if (! c.zones.empty()) // [file, root, min key, max key, min velocity, max velocity, tune, gain]
         {
@@ -731,6 +740,11 @@ std::optional<Song> fromJson (const juce::String& json, juce::String& error)
             def.muted = (bool) c.getProperty ("muted", false);
             def.samplePath = c["sample"].toString().toStdString();
 
+            {
+                const auto values = juce::StringArray::fromTokens (c.getProperty ("modelParams", "").toString(), " ", "");
+                for (int k = 0; k < values.size() && k < 256; ++k)
+                    def.modelParams.push_back (values[k].getFloatValue());
+            }
             if (const auto encoded = c["controllerState"].toString(); encoded.isNotEmpty())
             {
                 juce::MemoryOutputStream decoded;

+ 2 - 0
src/ui/ChannelRackComponent.cpp

@@ -27,6 +27,8 @@ juce::String instrumentName (InstrumentKind k)
         case InstrumentKind::audioClip: return utf8 ("Audio clip");
         case InstrumentKind::plugin: return "Plugin";
         case InstrumentKind::controller: return "Controller";
+        case InstrumentKind::sakura: return "Sakura";
+        case InstrumentKind::drumpad: return "Drumpad";
     }
     return "?";
 }

+ 40 - 0
tests/tests.cpp

@@ -5161,3 +5161,43 @@ TEST (harmless_stereo_tremolo_and_vibrato)
     CHECK (crossingsSpread (0.0f) <= 1);
     CHECK (crossingsSpread (100.0f) >= 4);
 }
+
+TEST (physical_models_sound_and_end)
+{
+    // Sakura: a plucked string with default-ish parameters rings and fades after the release; Drumpad: a hit decays
+    for (const auto kind : { lynx::InstrumentKind::sakura, lynx::InstrumentKind::drumpad })
+    {
+        lynx::ChannelDef c;
+        c.instrument = kind;
+        if (kind == lynx::InstrumentKind::sakura)
+        {
+            c.modelParams.assign (146, 0.5f);
+            c.modelParams[111] = 3.0f;  // both strings at the note
+            c.modelParams[113] = 0.5f;  // octave ×1
+            c.modelParams[6] = c.modelParams[11] = 0.99f; // long decay
+            c.modelParams[31] = 0.0f;   // noise exciter
+        }
+        else
+        {
+            c.modelParams.assign (38, 0.5f);
+            c.modelParams[0] = 1.0f;    // retrigger noise
+            c.modelParams[30] = c.modelParams[31] = c.modelParams[32] = c.modelParams[33] = 0.0f; // no velocity morph
+        }
+        auto inst = lynx::makeInstrument (kind);
+        inst->prepare (48000.0);
+        inst->configure (c, 120.0);
+        inst->noteOn (60, 0.8f);
+        std::vector<float> l (48000), r (48000);
+        inst->render (l.data(), r.data(), 24000, 1.0f, 1.0f);
+        inst->noteOff (60);
+        inst->render (l.data() + 24000, r.data() + 24000, 24000, 1.0f, 1.0f);
+        double early = 0.0;
+        for (int i = 0; i < 12000; ++i)
+            early += (double) l[(std::size_t) i] * l[(std::size_t) i];
+        CHECK (early > 1e-6);
+        CHECK (std::all_of (l.begin(), l.end(), [] (float v) { return std::isfinite (v); }));
+        std::vector<float> tail (480000), tailR (480000);
+        inst->render (tail.data(), tailR.data(), 480000, 1.0f, 1.0f); // 10 s later the voice has ended
+        CHECK (inst->idle());
+    }
+}

+ 1 - 1
tools/renderwav.cpp

@@ -118,7 +118,7 @@ int main (int argc, char** argv)
 
     for (std::size_t i = 0; i < song.channels.size(); ++i)
     {
-        static const char* kinds[] = { "kick", "snare", "hat", "clap", "synth", "sampler", "audio clip", "plugin", "controller" };
+        static const char* kinds[] = { "kick", "snare", "hat", "clap", "synth", "sampler", "audio clip", "plugin", "controller", "sakura", "drumpad" };
         std::printf ("  %2zu %-28s -> %s\n", i, song.channels[i].name.c_str(), kinds[(int) song.channels[i].instrument]);
     }