ソースを参照

Merge remote-tracking branch 'origin/wip/flm190de' into wip/rollup027

# Conflicts:
#	src/ui/ChannelSettings.cpp
Ka1-S 3 週間 前
親
コミット
77026c3a2

+ 2 - 0
CMakeLists.txt

@@ -59,6 +59,8 @@ add_library(lynx_core STATIC
     src/core/FlmImport.cpp
     src/core/FlmImport.cpp
     src/core/FlmEffects.cpp
     src/core/FlmEffects.cpp
     src/core/FlmNoteFx.cpp
     src/core/FlmNoteFx.cpp
+    src/core/FlmDwSampler.cpp
+    src/core/FlmSlicer.cpp
     src/core/AlsExport.cpp
     src/core/AlsExport.cpp
     src/flp/FlpWrite.cpp
     src/flp/FlpWrite.cpp
     src/core/Effects.cpp
     src/core/Effects.cpp

+ 148 - 4
docs/analise/FLM_FORMAT.md

@@ -503,7 +503,7 @@ inside its key range (`ADD1`), so a rack with two generators is a layer or a key
 - **Randomizer**: Pitch = round(24v) semitones either way (a whole number, drawn evenly), Velocity ± v, Pan ± v of the
 - **Randomizer**: Pitch = round(24v) semitones either way (a whole number, drawn evenly), Velocity ± v, Pan ± v of the
   whole width, Gate = the chance a note plays (0 = none). Defaults 0, 0, 0, 1: nothing. FLM draws at every playback;
   whole width, Gate = the chance a note plays (0 = none). Defaults 0, 0, 0, 1: nothing. FLM draws at every playback;
   LYNX draws once at import (listed in the report).
   LYNX draws once at import (listed in the report).
-- **Note Echo** and **Arpeggiator** are not converted (listed in the report).
+- **Note Echo** and **Arpeggiator** act in time: §7.8 (round 190de).
 
 
 ### 7.3 SoundFont Player (round 190bs)
 ### 7.3 SoundFont Player (round 190bs)
 
 
@@ -520,6 +520,150 @@ index follows the file's preset order is INFERRED; no sample project uses the mo
 LYNX imports it as LYNX Soundfont: the font and preset, the linear velocity curve, and for Custom the four overrides
 LYNX imports it as LYNX Soundfont: the font and preset, the linear velocity curve, and for Custom the four overrides
 (decay and release as 2.5·T on LYNX's 100 dB time knobs). The level and the envelope's exact shape are approximations.
 (decay and release as 2.5·T on LYNX's 100 dB time knobs). The level and the envelope's exact shape are approximations.
 
 
+### 7.4 The module wrapper on instruments; instrument and Pitch Bend automation (round 190de)
+
+PROVEN-REA 0x180799750 (the wrapper the rack's render 0x18059d3b0 calls for every module, generators included):
+- Enable (parameter 0) below 0.5, or Mix 0: the module's render is **not called** — a switched-off instrument makes
+  no sound and its voices stand still until it is switched on again.
+- Otherwise the module renders into its own buffer; the result × the Post Gain 10^(2g − 1) (40g − 20 dB) is mixed into
+  the rack's buffer at Mix, the wet side through the Wet Pan's balance (min(1, 2(1 − p)) left, min(1, 2p) right),
+  both smoothed per sample (one-pole 0.001). With Mix 1 and Wet Pan ½ the module renders straight into the rack's
+  buffer and the Post Gain then scales that whole buffer (what earlier modules and the drum slots put there too).
+- LYNX: a generator's channel is muted when its Enable is off; Post Gain × Mix is the channel's level (above 0 dB: the
+  sampler's gain, capped at 0 dB on other engines and listed); Wet Pan is added to the channel's pan. Exact for the
+  first generator of a rack without drum slots (its "dry" buffer is silent); with other sounds before it in the rack
+  a Mix below 1 would also lower them in FLM, which is listed. In FL's 20 sample projects: 3 generators switched off,
+  one Post Gain (−6 dB) and one Mix (0.045).
+
+Automation lanes on a generator's parameters (their names in §7.1, values the module's own 0…1): every FLM engine
+LYNX has keeps FLM's values, so a lane becomes LYNX automation of the same value — Pocket SuperSaw (FLM k → k − 1),
+MiniSynth's FLM build (FLM k → desktop k − 1; MW Dest folded as on import), GMSynth (FLM) (P[k]), Transistor Bass
+(the 13 knobs through the import's map). Enable lanes drive the channel's volume (on / silent): approximate, as
+FLM freezes the module's voices while LYNX's run on silently. The sample projects hold 19 such lanes: MiniSynth FLT
+Freq (9) and AMP Rel, SuperSaw Filter Cutoff, Transpose and Enable (2), GMSynth Transpose (2), DW Sampler Pitch (3).
+
+The rack's Pitch Bend (module 0, parameter 4; its held value and its lanes, PROVEN-REA 0x18059e0c0) is not one law:
+the rack hands b = 4v − 2 to every module's bend input and plays its drum slots at 2^b (±24 semitones). The modules
+bend by their own range: DW Sampler b/2 × its PB Range (CSTM `MIDI`, default 4; PROVEN-REA 0x18077f560), SuperSaw b/2 ×
+int(11·P37 + 1), GMSynth b/2 × its CSTM range {1, 2, 7, 12}, MiniSynth b semitones (PROVEN-REA 0x1806aea20: stored as
+is and added to the note). LYNX: the channel's bend range is set to that range (24 on drum slots); a held value moves
+the channel's PITCH knob by (2v − 1) × range, a lane becomes LYNX pitch-bend automation of every such channel (LYNX
+bends by (2v − 1) × the range: the same semitones). Modules whose bend was not traced (Transistor Bass, 3x Osc,
+SoundFont Player) are listed. Three sample projects bend this way (one lane holds 114 clips). Aftertouch and MIDI CC
+lanes stay listed.
+
+### 7.5 DW Sampler (round 190de)
+
+PROVEN-REA (class CSmpSynth, vtable 0x180a0ecd8: CSTM reader 0x180785550, preset loader 0x180787410, note slot
+0x180783980, render 0x180783e90, voice 0x18078bf00 / 0x18078b3f0, filter update 0x18078c440, setter 0x180784a50);
+PROVEN-FILE on the 42 CSTM bodies and 56 parameter sets of FL's sample projects and the 6 shipped `.dwp`. LYNX's
+code: `core/FlmDwSampler.h` (FLM's own engine on a Sampler channel's zones).
+
+**CSTM** = `10WD` + chunks (unknown tags skipped): one `ZONE` per zone **or** one `PATh` / `PATH`, then `MIDI`.
+- `ZONE` (1065 bytes): 1024-byte path (root marker `@R@` / `@L@`, NUL, relative path; bytes after the next NUL are
+  stale and ignored — 13 sample bodies carry such text), then root key, key low, key high (128 in a default zone),
+  velocity low, velocity high (u8 each), f32 gain (used only above 0.0001 **and with Loop on**; old files hold the
+  integer 63 here, i.e. gain 1), f32 pan (not used), i32 loop mode (loops only from 2), i32 loop start, i32 loop end
+  (exclusive; start = end → the file's own loop), f32 attack, decay (only its sign: ≤ 0 = instant decay), sustain (not
+  used), release.
+- `PATh`: lp32 path + f32 Attack + f32 Release (they replace parameters 1 and 2 after the file loads); `PATH`: path only.
+  The file is a `.dwp` (FLM reads it itself: `DwPr`, version > 35, entries u32 id + u64 size; program id 1, zone id 3,
+  end id 2; zone entries 500 = root / ranges / gain / pan, 502 = the sample's path, 503 = frames, channels, bits, rate,
+  loop mode / start / end, 509 = A / D / S / R; after loading, Attack / Release = the last zone's) or a single sample
+  (one zone: root 48, every key and velocity, looping on the file's own loop).
+- `MIDI`: [PB Range in semitones (default 4), smooth attack (default 1: an Attack of 0 still takes 1 ms)].
+
+**Parameters** (v = stored 0…1; float32 where it matters): 1 Attack, 2 Release, 5 Decay: T = 10·v⁴ + 0.001 s, fixed
+at the note's start; 3 Pitch = int(48v − 24) semitones (it also moves the key a zone is chosen with); 4 Fine Tune =
+2v − 1 semitones; 6 Sustain = the envelope's level; 7 Slide: glide time (v/2)³ s (none below 1e-5), re-planned every
+render call; 8 Reverse (no loop); 9 Loop (zone loops and zone gains); 10 Legato; 11 Mono (last-note priority, glides
+without retrigger); 12 Cutoff c, 13 Resonance (ladder feedback v, biquad Q = 16v³ + 0.5), 14 Kbd. Track, 15 Vel. Track
+(adds v × velocity to c); 16 Filter type = int(3v): off, 4-pole ladder low-pass, band-pass, high-pass (the corpus value
+0x3EAAAAAB is the ladder only in float32); 17…21 / 22…26 filter / pitch envelope attack, decay, sustain, release,
+amount; 27 LFO shape int(3v + 0.5): sine, falling saw, square, sample-and-hold; 28 rate 1 / ((1 − v)³·30 + 1/30) Hz;
+29 mode int(2v): free, one shot, tempo sync ({1/8 … 32} beats by 30, aligned to the song position); 31 amount ±(2v −
+1)²; 32 destination int(3v): cutoff, pitch, volume, pan; 33 LFO fade-in.
+
+**Voice**: zone = the one whose key and velocity ranges hold key + Pitch and int(127·velocity + 0.5) (several: a
+seeded draw, never the same twice in a row on a key; none: no sound); rate = 2^((key − root)/12) × file rate / output
+rate × 2^((Fine Tune + Pitch + bend)/12) × glide × pitch envelope × LFO, linear interpolation at the file's own rate;
+the level is the velocity (× the zone's gain with Loop on), **linear**; the amp envelope is linear and heard **squared**
+(attack 0→1 in TA, decay 1→S in (1 − S)·TD, release from the level in level·TR); filter and pitch envelopes are
+one-pole segments (rate 0.0002 / ((0.95v + 0.05)⁴ × 500 for attacks, 50 otherwise), per sample whatever the rate, the
+attack aiming at 4 and clipped at 1); the pitch envelope bends 2^(4·(2v − 1)³·e³); cutoff = min(22 kHz,
+2^((key + glide − 48)·kbd/12 + 10.4c + 4 + (2·amount − 1)·8·e)), filters and LFO updated every 16 samples; note pan is
+a balance. 128 voices, no stealing. A voice ends past its sample's end, or silent after its attack.
+
+LYNX: the channel is a Sampler channel whose zones carry the files, ranges, gain and loops, and whose `modelParams`
+start with the engine's marker, the PB Range, the smooth flag, the 34 values, then one decay flag per zone; the rack
+plays FLM's voice on it (`core/FlmDwSampler.h`). The module's values are automatable (`automationBase` + k; FL's sample
+projects automate Pitch). Editing the Sampler's envelope by hand drops the module's values (LYNX's own voice).
+Approximate: the shared random generator is one per channel; the render call is LYNX's block cut to 512 samples (FLM
+plans its glides per host call); reverse starts on the last frame. Not read: the old `INST` preset format and audio
+embedded in a `.dwp` (no sample file uses either).
+
+### 7.6 Pitcher and Pitcher 2 (round 190de)
+
+PROVEN-REA (Pitcher: vtable 0x1809fd4c8, CSTM 0x1806359f0 / 0x180635aa0, target choice 0x1806347c0; Pitcher 2:
+vtable 0x1809e6ed0, engine setter 0x18072f7f0, note choice 0x18078ee90). Both correct the sung pitch towards the
+nearest of twelve allowed pitch classes. **Pitcher** (25): 1 Speed (a one-pole of τ = (3(1 − v)³ + 0.001) / 8.82 s,
+instant from 0.99), 2 Pitch (int(24(v − ½)) semitones), 3 Fine Tune (int(100(v − ½)) cents), 4 formant mode, 5 formant
+shift 2^(2v − 1), 6 detector input (left, sum, right), 7 Base Freq (A4 = 440·2^((2v − 1)/12)), 8 Stability, 9 Mix,
+10…21 per-note bypass (on at 1), 22 bypass snapping; CSTM = 12 mask bytes (C…B) + Key and Scale menu floats (the mask
+is what plays; its "Pentatonic" holds four notes). **Pitcher 2** (45): 1…12 the notes (default C minor), 13 Speed (four
+one-poles at (200^v − 0.9)·2.29896 Hz), 16 Formant Mode (inverted), 17 formant ratio, 18 detector input (labels rotated
+against the engine), 19 Stability, 20 Humanization, 22 Mix, 23 Sensitivity, 24 Vibrato, 25 low latency; 14, 15 unused;
+CSTM = Key and Scale menu floats only.
+
+LYNX: LYNX Tune with Scale = Custom and the same twelve note switches (exact), the retune time from the Speed law
+(Pitcher: the same one-pole; Pitcher 2: matched at its half-way time), transpose, mix, formant preserve / shift
+(wide range), per-note bypass, bypass snapping (correction 0), the reference pitch from Base Freq and the fine tune
+(430…450 Hz), Pitcher 2's Stability as LYNX's tolerance. Approximate and listed: the detectors and shifters (LYNX's
+own), Pitcher's Stability, Pitcher 2's Humanization and Vibrato. No shipped file uses either module.
+
+### 7.7 Slicer (round 190de)
+
+PROVEN-REA (class CSynthSlicer: setter 0x1807d54f0, CSTM 0x1807d6540 / 0x1807d5f40, detector 0x180591160 /
+0x1805915d0, voice 0x1807d6e60 / 0x1807d4ec0). Parameters: 1 PITCH int(48v − 24), 3 ATTACK and 4 DECAY (the drum
+pad's laws, §6.1; DECAY above 0.99 holds), 5 SUST int(2v): one-shot slice / to the sample's end while held / to the
+end, 6 MONO (a note fades the others at 0.01). CSTM: `SENS` (f32 sensitivity, 0 = the file's markers; u8 editor
+flag) and `PATH` (u32 n + path). Slicing: the left channel normalised, three float passes of a gentle high-pass,
+128-point frames every 16 samples with a periodic Hamming window, power in bins 1…5 and 6…63, per band a hold (55 / 41
+frames), release (0.9761 / 0.9644) and a rise above the held level (× 0.9 / 1.0, floor 1e-10 / 1.8 or 20), the
+strength × sensitivity; an onset where it reaches 1, started at the earliest frame of the last 28 above 0.75 and then
+at the first sample louder than 5 % of the peak, at least 60 ms apart, at most 128. Slice i plays on the saved low key
++ i (FLM saves the key range it gave the slices). Voice: linear interpolation, linear velocity and balance, every note
+its own voice, a 512-sample dip before the slice's end, a fade at 0.01 per sample at the end point.
+
+LYNX: a Sampler channel with the sample and `modelParams` = { marker, sensitivity, first key, the 7 values }; the rack
+slices the decoded sample and plays FLM's voice (`core/FlmSlicer.h`). The shipped break (`Parrik - Initiated`) slices
+at 0.25 into the 11 starts FLM saved (also the starts at 0.05, 0.5 and 1.0 of round 190de's simulation, to the frame).
+
+### 7.8 Arpeggiator and Note Echo (round 190de)
+
+PROVEN-REA (Arpeggiator: vtable 0x1809e5c50, engine 0x18044a2c0, sequence builder 0x18044b610, grid 0x18044d510;
+Note Echo: vtable 0x1809e69b0, scheduler 0x18045ffc0, emit 0x180460380). Both run on the rack's notes before its
+instruments, in the rack's order with the other note effects (§7.2), and both act **in time**:
+- **Arpeggiator** (51): two independent arps fed the same notes, which they replace. Global: 1 Rate (1/16 … 1/2, or
+  one bar), 2 Rate in ms (50 + 950v, Sync off), 3 Sync, 4 Swing, 5 swing rate (1/8, 1/16), 6 Latch, 7 / 8 the arps'
+  velocity (× 2v). Per arp (arp 1 at 9…15, 31, 17…19; arp 2 at 20…26, 32, 28…30): Gate 0.1 + 0.9v, Arp = one of 24
+  modes (As Played, Chord, Up, Down, Up-Down, Down-Up, Outward, Inward, Anchor, Bass Up, Bass Up-Down, Treble Down,
+  Treble Down-Up, Jump Up, Jump Down, Jump Up-Down, SuperSaw, Cascade Up / Down / Up-Down, Random, Random No Repeat,
+  Random Once, Random Walk), Range 1…4 octaves, Octave shift ±3, Start note ±8, Rhythm (21 patterns) and Rotate, a
+  rate multiplier ×1/8…×8 (31-value files keep it at 16 / 27 in 11 steps), Repeats, Retrig (notes, 1/8 … 8 bars),
+  Enable. Steps sit on multiples of the step from song position 0; a chord plays from the next grid point; releasing
+  every key ends the arp's notes.
+- **Note Echo** (47): the dry notes pass; up to 32 echoes, the first after D (beats: 1/32 + 7.96875v², or the nearest of
+  1/8 … 8 with Sync), the next gaps D·d², D·d³… (Time Drift d = 0.7…1.3), each echo + Pitch semitones and × Velocity,
+  the first with the offsets, pan drift and ping-pong, lengths × Length Drift (capped by the gaps); the chain stops at
+  velocity ≤ 1/127 or a length under 1/128 beat; a dry note still held at its first echo ends there.
+
+LYNX bakes them: a rack with an active Arpeggiator or Note Echo takes its notes from every note lane as the song plays
+them, runs the rack's note effects in order and writes one pattern over the song, on its first note lane's row.
+Exact for every mode but the random ones (Random… and Delay Rand.: one seeded draw, listed) and up to FLM's audio-block
+jitter. Left out: slide notes and note repeats in such a rack, the same-key rules of Note Echo (an echo under a held
+dry note of its key), the editor's Stop.
+
 ## 8. Relation to FLM-exported .flp (issue #88)
 ## 8. Relation to FLM-exported .flp (issue #88)
 
 
 FL Studio desktop hosts FLM instruments as the "FL Studio Mobile Rack" generator (`FL Studio Mobile Rack_x64.dll`).
 FL Studio desktop hosts FLM instruments as the "FL Studio Mobile Rack" generator (`FL Studio Mobile Rack_x64.dll`).
@@ -541,13 +685,13 @@ decoder serves both paths: opening a `.flm` directly, and replacing the inert Mo
    Round 188h added MultiFX, Trance Delay, Distortion, both Limiters, Leveller, Gate and Tape Delay (the Pocket
    Round 188h added MultiFX, Trance Delay, Distortion, both Limiters, Leveller, Gate and Tape Delay (the Pocket
    engines) and proved how the module wrapper applies Mix (linear dry/wet), Post Gain (40g − 20 dB on the output) and
    engines) and proved how the module wrapper applies Mix (linear dry/wet), Post Gain (40g − 20 dB on the output) and
    Wet Pan (a balance of the wet). Left: Chorus, Spacer, Wow & Flutter, Phaser, Waveshaper, Compressor, Spreader,
    Wet Pan (a balance of the wet). Left: Chorus, Spacer, Wow & Flutter, Phaser, Waveshaper, Compressor, Spreader,
-   Stereoizer, Flanger, Autoduck (29), Tremolo, Note Echo and the Arpeggiator (Transpose, Scale and Randomizer:
-   round 190bs, §7.2).
+   Stereoizer, Flanger, Autoduck (29), Tremolo (Transpose, Scale and Randomizer: round 190bs, §7.2; Note Echo and the
+   Arpeggiator: round 190de, §7.8).
    Round 190by: SuperSaw (Pocket SuperSaw), Comb Filter, Multiband Compressor and Tape Stop are LYNX engines; Reverb
    Round 190by: SuperSaw (Pocket SuperSaw), Comb Filter, Multiband Compressor and Tape Stop are LYNX engines; Reverb
    (32) maps to Reeverb 2 and Tuned EQ (30) to the Parametric EQ (REA_rodada190by.md). Parameter counts read in the
    (32) maps to Reeverb 2 and Tuned EQ (30) to the Parametric EQ (REA_rodada190by.md). Parameter counts read in the
    code: 30 = 11, 32 = 16 (14 and 15 are unnamed wet and dry levels), 42 = 8.
    code: 30 = 11, 32 = 16 (14 and 15 are unnamed wet and dry levels), 42 = 8.
 5. HEAD 272/280 (loop range).
 5. HEAD 272/280 (loop range).
 6. (round 190bs) The sample slot: the third `MAIN` tail field (f32 0.5) and `LINk`'s second word; where a slot with
 6. (round 190bs) The sample slot: the third `MAIN` tail field (f32 0.5) and `LINk`'s second word; where a slot with
    an output link plays; the stretch modes' algorithms (LYNX uses its own stretcher); how a kit sample's legacy `STRC`
    an output link plays; the stretch modes' algorithms (LYNX uses its own stretcher); how a kit sample's legacy `STRC`
-   stretch sounds (two samples of one demo song; LYNX plays them as recorded and says so); the module's octave shift
+   stretch sounds (two samples of one demo song; since round 190de LYNX stretches them with its own stretcher); the module's octave shift
    and the second dispatch switch next to the key range (0x420 / 0x42c in the module object: not found in the file).
    and the second dispatch switch next to the key range (0x420 / 0x42c in the module object: not found in the file).

ファイルの差分が大きいため隠しています
+ 0 - 0
scripts/build-local.sh


ファイルの差分が大きいため隠しています
+ 0 - 0
scripts/build-windows-zig.sh


+ 876 - 0
src/core/FlmDwSampler.cpp

@@ -0,0 +1,876 @@
+#include "core/FlmDwSampler.h"
+
+#include <algorithm>
+#include <array>
+#include <atomic>
+#include <cmath>
+#include <cstring>
+
+#include "core/Instruments.h"
+
+// FL Studio Mobile's DW Sampler (round 190de; FLM_FORMAT §7.5). Clean-room: the laws below are the behaviour read in
+// FLM's FL plugin, written in LYNX's own words and code.
+
+namespace lynx::flmdw
+{
+const float defaults[paramCount] = { 1.0f, 0.0f, 0.1f, 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+                                     0.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f };
+
+const char* paramName (int k) noexcept
+{
+    static const char* const names[paramCount] = { "Enable", "Attack", "Release", "Pitch", "Fine Tune", "Decay", "Sustain", "Slide", "Reverse",
+                                                   "Loop", "Legato", "Mono", "Cutoff", "Resonance", "Kbd. Track", "Vel. Track", "Filter type",
+                                                   "Filter Attack", "Filter Decay", "Filter Sustain", "Filter Release", "Filter Env. Amount",
+                                                   "Pitch Attack", "Pitch Decay", "Pitch Sustain", "Pitch Release", "Pitch Env. Amount", "LFO Shape",
+                                                   "LFO Rate", "LFO Mode", "LFO Sync Rate", "LFO Amount", "LFO Destination", "LFO Attack" };
+    return k >= 0 && k < paramCount ? names[k] : "";
+}
+
+// ------------------------------------------------------------------------------------------------- saved state
+namespace
+{
+struct Reader
+{
+    std::span<const std::uint8_t> b;
+    std::size_t at = 0;
+    bool fits (std::size_t n) const noexcept { return at + n <= b.size(); }
+    std::uint32_t u32 (std::size_t p) const noexcept
+    {
+        std::uint32_t v = 0;
+        for (int k = 0; k < 4; ++k)
+            v |= (std::uint32_t) b[p + (std::size_t) k] << (8 * k);
+        return v;
+    }
+    std::uint64_t u64 (std::size_t p) const noexcept { return (std::uint64_t) u32 (p) | ((std::uint64_t) u32 (p + 4) << 32); }
+    float f32 (std::size_t p) const noexcept
+    {
+        const auto v = u32 (p);
+        float f;
+        std::memcpy (&f, &v, 4);
+        return f;
+    }
+};
+
+// a saved path: the root marker, a NUL, the relative path up to the next NUL (later bytes are stale text, ignored)
+void splitPath (const std::uint8_t* p, std::size_t n, std::string& root, std::string& path)
+{
+    std::string text ((const char*) p, n);
+    root.clear();
+    path.clear();
+    if (text.size() >= 4 && text[0] == '@' && text[2] == '@' && text[3] == '\0')
+    {
+        root = text.substr (0, 3);
+        text = text.substr (4);
+    }
+    if (const auto zero = text.find ('\0'); zero != std::string::npos)
+        text.resize (zero);
+    std::replace (text.begin(), text.end(), '\\', '/');
+    path = text;
+}
+} // namespace
+
+std::optional<Custom> parseCustom (std::span<const std::uint8_t> bytes)
+{
+    if (bytes.size() < 4 || std::memcmp (bytes.data(), "10WD", 4) != 0)
+        return std::nullopt;
+    Custom out;
+    Reader r { bytes, 4 };
+    while (r.fits (8))
+    {
+        const auto* tag = bytes.data() + r.at;
+        const auto size = (std::size_t) r.u32 (r.at + 4);
+        const auto body = r.at + 8;
+        if (body + size > bytes.size())
+            break;
+        if (std::memcmp (tag, "ZONE", 4) == 0 && size >= 1065 && ! out.hasPath)
+        {
+            ZoneRecord z;
+            splitPath (bytes.data() + body, 1024, z.root, z.path);
+            const auto t = body + 1024;
+            z.rootKey = bytes[t];
+            z.keyLow = bytes[t + 1];
+            z.keyHigh = bytes[t + 2];
+            z.velLow = bytes[t + 3];
+            z.velHigh = bytes[t + 4];
+            z.gain = r.f32 (t + 5);
+            z.pan = r.f32 (t + 9);
+            z.loopMode = (int) r.u32 (t + 13);
+            z.loopStart = (std::int32_t) r.u32 (t + 17);
+            z.loopEnd = (std::int32_t) r.u32 (t + 21);
+            z.attack = r.f32 (t + 25);
+            z.decay = r.f32 (t + 29);
+            z.sustain = r.f32 (t + 33);
+            z.release = r.f32 (t + 37);
+            out.zones.push_back (std::move (z));
+        }
+        else if ((std::memcmp (tag, "PATh", 4) == 0 || std::memcmp (tag, "PATH", 4) == 0) && size >= 4 && out.zones.empty() && ! out.hasPath)
+        {
+            const auto n = (std::size_t) r.u32 (body);
+            if (4 + n <= size)
+            {
+                out.hasPath = true;
+                splitPath (bytes.data() + body + 4, n, out.pathRoot, out.path);
+                if (tag[3] == 'h' && 4 + n + 8 <= size)
+                {
+                    out.pathFloats = true;
+                    out.pathAttack = r.f32 (body + 4 + n);
+                    out.pathRelease = r.f32 (body + 8 + n);
+                }
+            }
+        }
+        else if (std::memcmp (tag, "MIDI", 4) == 0 && size >= 2)
+        {
+            out.pbRange = bytes[body];
+            out.smoothAttack = bytes[body + 1] != 0;
+        }
+        r.at = body + size;
+    }
+    return out;
+}
+
+std::vector<ZoneRecord> parseProgram (std::span<const std::uint8_t> bytes)
+{
+    std::vector<ZoneRecord> out;
+    if (bytes.size() < 8 || std::memcmp (bytes.data(), "DwPr", 4) != 0)
+        return out;
+    const Reader r { bytes, 0 };
+    if (r.u32 (4) <= 35)
+        return out;
+    // entries: u32 id, u64 size, body
+    const auto walk = [&] (std::size_t from, std::size_t to, auto&& each) {
+        auto p = from;
+        while (p + 12 <= to)
+        {
+            const auto id = r.u32 (p);
+            const auto size = r.u64 (p + 4);
+            if (size > to - p - 12)
+                return;
+            if (! each (id, p + 12, (std::size_t) size))
+                return;
+            p += 12 + (std::size_t) size;
+        }
+    };
+    walk (8, bytes.size(), [&] (std::uint32_t id, std::size_t p, std::size_t n) {
+        if (id != 1)
+            return true;
+        walk (p, p + n, [&] (std::uint32_t sub, std::size_t q, std::size_t m) {
+            if (sub == 2)
+                return false; // the program's end
+            if (sub != 3)
+                return true;
+            ZoneRecord z;
+            z.keyHigh = 127;
+            bool ok = true;
+            walk (q, q + m, [&] (std::uint32_t k, std::size_t s, std::size_t len) {
+                if (k == 500 && len >= 17)
+                {
+                    z.rootKey = bytes[s], z.keyLow = bytes[s + 1], z.keyHigh = bytes[s + 2], z.velLow = bytes[s + 3], z.velHigh = bytes[s + 4];
+                    z.gain = r.f32 (s + 9);
+                    z.pan = r.f32 (s + 13);
+                }
+                else if (k == 502)
+                    splitPath (bytes.data() + s, len, z.root, z.path);
+                else if (k == 503 && len >= 32)
+                {
+                    const auto channels = r.u32 (s + 8);
+                    ok = channels == 1 || channels == 2;
+                    z.loopMode = (int) r.u32 (s + 20);
+                    z.loopStart = r.u32 (s + 24);
+                    z.loopEnd = r.u32 (s + 28);
+                }
+                else if (k == 509 && len >= 16)
+                {
+                    z.attack = r.f32 (s), z.decay = r.f32 (s + 4), z.sustain = r.f32 (s + 8), z.release = r.f32 (s + 12);
+                }
+                return true;
+            });
+            if (ok && ! z.path.empty())
+                out.push_back (std::move (z));
+            return true;
+        });
+        return false;
+    });
+    return out;
+}
+
+// ------------------------------------------------------------------------------------------------- the channel
+bool isChannel (const ChannelDef& c) noexcept
+{
+    return c.instrument == InstrumentKind::sampler && c.modelParams.size() >= (std::size_t) (head + paramCount) && c.modelParams[0] == marker;
+}
+
+float value (const ChannelDef& c, int k) noexcept
+{
+    if (k < 0 || k >= paramCount)
+        return 0.0f;
+    if (! isChannel (c))
+        return defaults[k];
+    const auto v = c.modelParams[(std::size_t) (head + k)];
+    return std::isfinite (v) ? std::clamp (v, 0.0f, 1.0f) : defaults[k];
+}
+
+std::vector<float> channelParams (const std::vector<float>& values, int pbRange, bool smoothAttack, const std::vector<bool>& zoneDecays)
+{
+    std::vector<float> out { marker, (float) std::clamp (pbRange, 0, 48), smoothAttack ? 1.0f : 0.0f };
+    for (int k = 0; k < paramCount; ++k)
+        out.push_back (k < (int) values.size() && std::isfinite (values[(std::size_t) k]) ? std::clamp (values[(std::size_t) k], 0.0f, 1.0f) : defaults[k]);
+    for (const auto d : zoneDecays)
+        out.push_back (d ? 1.0f : 0.0f);
+    return out;
+}
+
+SampleZone sampleZone (const ZoneRecord& z, const std::string& resolvedPath)
+{
+    SampleZone s;
+    s.path = resolvedPath;
+    s.rootKey = std::clamp (z.rootKey, 0, 127);
+    s.lowKey = z.keyLow;
+    s.highKey = z.keyHigh;
+    s.lowVelocity = z.velLow;
+    s.highVelocity = z.velHigh;
+    s.gain = std::isfinite (z.gain) ? z.gain : 1.0f; // (FLM applies it above 0.0001 only, and only with Loop on)
+    s.loopMode = z.loopMode >= 2 ? 1 : 0;
+    s.loopStart = std::max<std::int64_t> (0, z.loopStart);
+    s.loopEnd = std::max<std::int64_t> (0, z.loopEnd);
+    return s;
+}
+
+// ------------------------------------------------------------------------------------------------- laws
+double envelopeSeconds (float v) noexcept
+{
+    const auto x = (double) std::clamp (v, 0.0f, 1.0f);
+    return 10.0 * x * x * x * x + 0.001;
+}
+
+double onePoleRate (float v, double k) noexcept
+{
+    if (v < 0.001f)
+        return 1.0;
+    const auto a = 0.95f * v + 0.05f;
+    return 0.0002 / ((double) (a * a * a * a) * k);
+}
+
+int pitchSemitones (float v) noexcept { return (int) (v * 48.0f - 24.0f); }
+int filterKind (float v) noexcept { return std::clamp ((int) (v * 3.0f), 0, 3); }
+
+double cutoffHz (float cutoff, double keyTerm, double envTerm) noexcept
+{
+    return std::min (std::exp2 (keyTerm + 10.4 * (double) std::clamp (cutoff, 0.0f, 1.0f) + 4.0 + envTerm), 22000.0);
+}
+
+double lfoHz (float v) noexcept
+{
+    const auto x = 1.0 - (double) std::clamp (v, 0.0f, 1.0f);
+    return 1.0 / (x * x * x * 30.0 + 1.0 / 30.0);
+}
+
+// ------------------------------------------------------------------------------------------------- the engine
+namespace
+{
+constexpr int voiceCount = 128;
+constexpr int block = 512; // the render call FLM plans its glides and global tune for (FL's rack hands it 512 samples)
+
+// FLM's 4-pole ladder low-pass: four one-pole stages with the output fed back, as 4096 explicit steps per sample with
+// the input held; the step's 4×4 transition is squared 12 times into the sample's (y ← A·y + B·x)
+struct Ladder
+{
+    // in float and in FLM's order of operations (measured against FLM inside FL: the ladder nulls at −73 dB only so)
+    float m[16] {}, b[4] {};   // column-major M[r + 4c]
+    float y[2][4] {};
+
+    void design (double fcD, double fs, double kD) noexcept
+    {
+        const auto fc = (float) fcD;
+        auto g = (float) ((0.000244140625 / fs) * (double) (fc * 6.25f));
+        g = std::clamp (g, 0.0f, 1.0f);
+        const auto k = std::clamp ((float) kD, 0.0f, 1.0f);
+        const float h = 1.0f - g;
+        float a = k * -4.0f * g;
+        for (auto& v : m) v = 0.0f;
+        const float hg = h * g;
+        m[0] = h; m[12] = a;
+        a = a * g; m[13] = a;
+        a = a * g; m[14] = a;
+        const float hgg = hg * g;
+        m[1] = hg; m[5] = h; m[15] = a * g + h; m[2] = hgg; m[6] = hg; m[10] = h;
+        m[3] = hgg * g; m[7] = hgg; m[11] = hg;
+        b[0] = g; b[1] = g * g; b[2] = g * g * g; b[3] = g * g * g * g;
+        for (int r = 0; r < 12; ++r)
+        {
+            float n[16], nb[4];
+            for (int i = 0; i < 4; ++i)
+            {
+                float acc = b[i];
+                for (int j = 0; j < 4; ++j) acc += m[i + 4 * j] * b[j];
+                nb[i] = acc;
+            }
+            for (int rr = 0; rr < 4; ++rr)
+                for (int c = 0; c < 4; ++c)
+                {
+                    float acc = 0.0f;
+                    for (int j = 0; j < 4; ++j) acc += m[rr + 4 * j] * m[j + 4 * c];
+                    n[rr + 4 * c] = acc;
+                }
+            std::memcpy (m, n, sizeof (m));
+            std::memcpy (b, nb, sizeof (b));
+        }
+    }
+
+    double run (int ch, double xD) noexcept
+    {
+        const auto x = (float) xD;
+        float n[4];
+        auto& st = y[ch];
+        for (int i = 0; i < 4; ++i)
+            n[i] = m[i] * st[0] + m[i + 4] * st[1] + m[i + 8] * st[2] + m[i + 12] * st[3] + b[i] * x;
+        std::memcpy (st, n, sizeof (n));
+        return st[3];
+    }
+};
+
+// FLM's band-pass (RBJ constant skirt) and its high-pass (RBJ poles with Q / 2, numerator as RBJ's with Q)
+struct Biquad
+{
+    double b0 = 0, b2 = 0, a1 = 0, a2 = 0, bb1 = 0; // y = b0·x + bb1·x1 + b2·x2 − a1·y1 − a2·y2
+    double x1[2] {}, x2[2] {}, y1[2] {}, y2[2] {};
+    double lastFc = -1, lastQ = -1, lastFs = -1;
+    int lastKind = 0;
+
+    static double flush (double v) noexcept { return std::abs (v) < 1.0e-9 ? 0.0 : v; }
+
+    void design (int kind, double fc, double q, double fs) noexcept
+    {
+        if (fc == lastFc && q == lastQ && fs == lastFs && kind == lastKind)
+            return;
+        lastFc = fc, lastQ = q, lastFs = fs, lastKind = kind;
+        const auto w = 2.0 * 3.14159265358979323846 * fc / fs, sn = std::sin (w), cs = std::cos (w);
+        if (kind == 2)
+        {
+            const auto alpha = sn / (2.0 * q), n = 1.0 / (1.0 + alpha);
+            b0 = flush (n * sn * 0.5), bb1 = 0.0, b2 = flush (-n * sn * 0.5);
+            a1 = flush (-n * 2.0 * cs), a2 = flush (n * (1.0 - alpha));
+        }
+        else
+        {
+            b0 = flush ((1.0 + cs) / (sn / q + 2.0));
+            bb1 = -2.0 * b0, b2 = b0;
+            a1 = flush (-2.0 * q * cs / (sn + q));
+            a2 = flush ((q - sn) / (q + sn));
+        }
+    }
+
+    double run (int ch, double x) noexcept
+    {
+        const auto y = flush (b0 * x + bb1 * x1[ch] + b2 * x2[ch] - a1 * y1[ch] - a2 * y2[ch]);
+        x2[ch] = x1[ch], x1[ch] = x;
+        y2[ch] = y1[ch], y1[ch] = y;
+        return y;
+    }
+};
+
+struct Voice
+{
+    bool active = false;
+    int key = 60, zone = -1;
+    double pos = 0.0, baseRate = 1.0;
+    bool looping = false, backwards = false;
+    double loopStart = 0.0, loopEnd = 0.0;
+    float velocity = 0.0f;               // the note's velocity × the zone's gain (Loop on)
+    float panL = 1.0f, panR = 1.0f;
+    float pitchOffset = 0.0f;            // the note's own pitch (semitones)
+    int state = 0;                       // 0 attack, 1 decay, 2 release
+    double env = 0.0, atk = 1.0, dec = 1.0, rel = 1.0, sus = 1.0;
+    double fenv = 0.0, ftgt = 4.0, frate = 1.0;
+    double penv = 0.0, ptgt = 4.0, prate = 1.0;
+    double glide = 0.0, glideTarget = 0.0, glideStep = 0.0;
+    double lfoPhase = 0.0, lfoFade = 0.0, lfo = 0.0, lfoPitch = 1.0, held = 0.0;
+    double gL = 1.0, gR = 1.0;
+    bool firstSample = true;
+    int counter = 0;
+    Ladder ladder;
+    Biquad biquad;
+};
+} // namespace
+
+class FlmDwSamplerInstrument final : public Instrument
+{
+public:
+    explicit FlmDwSamplerInstrument (std::vector<EngineZone> z) : zones (std::move (z))
+    {
+        for (int k = 0; k < paramCount; ++k)
+            values[(std::size_t) k].store (defaults[k]);
+        lastPick.fill (-1);
+    }
+
+    void prepare (double sampleRate) noexcept override
+    {
+        fs = sampleRate > 0.0 ? sampleRate : 44100.0;
+        reset();
+    }
+
+    void configure (const ChannelDef& c, double bpm) noexcept override
+    {
+        tempo.store (bpm > 0.0 ? (float) bpm : 120.0f);
+        knobCents.store (c.sampler.pitch * 100.0f);
+        if (! isChannel (c))
+            return;
+        for (int k = 0; k < paramCount; ++k)
+            values[(std::size_t) k].store (value (c, k));
+        pbRange.store ((int) c.modelParams[1]);
+        smooth.store (c.modelParams[2] != 0.0f);
+        for (std::size_t z = 0; z < zones.size(); ++z)
+        {
+            const auto at = (std::size_t) (head + paramCount) + z;
+            zones[z].decay = at >= c.modelParams.size() || c.modelParams[at] != 0.0f;
+        }
+    }
+
+    void setParameter (int index, float v) noexcept override
+    {
+        const auto k = index - automationBase;
+        if (k >= 0 && k < paramCount && std::isfinite (v))
+            values[(std::size_t) k].store (std::clamp (v, 0.0f, 1.0f));
+    }
+
+    void setChannelPitchNow (float knob, float rest) noexcept override { liveCents = knob + rest; }
+    void setNextNoteExpression (float pan, float cents, bool) noexcept override
+    {
+        nextPan = pan;
+        nextCents = cents;
+    }
+    void setSongPosition (double ticks) noexcept override
+    {
+        playing = lastTicks >= 0.0 && ticks != lastTicks;
+        lastTicks = ticks;
+        songBeats = ticks / (double) ppq;
+    }
+
+    void noteOn (int key, float velocity) noexcept override
+    {
+        const auto pan = std::clamp (0.5f + 0.5f * nextPan, 0.0f, 1.0f);
+        const auto cents = nextCents;
+        nextPan = 0.0f, nextCents = 0.0f;
+        key = std::clamp (key, 0, 127);
+        heldVelocity[(std::size_t) key] = std::clamp (velocity, 0.0f, 1.0f);
+        pressTime[(std::size_t) key] = ++clock;
+        if (P (param::enable) < 0.5f)
+            return;
+        if (P (param::mono) != 0.0f)
+            monoNoteOn (key, velocity, pan, cents);
+        else
+        {
+            for (auto& v : voices)
+                if (! v.active)
+                {
+                    start (v, key, velocity, pan, cents, glideFrom (key), false);
+                    break;
+                }
+        }
+        lastKey = key;
+    }
+
+    void noteOff (int key) noexcept override
+    {
+        key = std::clamp (key, 0, 127);
+        heldVelocity[(std::size_t) key] = 0.0f;
+        pressTime[(std::size_t) key] = 0;
+        if (P (param::mono) != 0.0f && mono >= 0 && voices[(std::size_t) mono].active && voices[(std::size_t) mono].key == key)
+        {
+            // last-note priority: glide back to the most recent key still held, else release
+            int best = -1;
+            std::uint64_t when = 0;
+            for (int k = 0; k < 128; ++k)
+                if (pressTime[(std::size_t) k] > when)
+                    when = pressTime[(std::size_t) k], best = k;
+            auto& v = voices[(std::size_t) mono];
+            if (best >= 0)
+                v.glideTarget = best - v.key;
+            else
+                release (v, false);
+            return;
+        }
+        for (auto& v : voices)
+            if (v.active && v.key == key && v.state != 2)
+                release (v, false);
+    }
+
+    void allNotesOff() noexcept override
+    {
+        for (auto& v : voices)
+            if (v.active)
+                release (v, false);
+        heldVelocity.fill (0.0f);
+        pressTime.fill (0);
+    }
+    void cut() noexcept override
+    {
+        for (auto& v : voices)
+            if (v.active)
+                release (v, true);
+    }
+    void panic() noexcept override { reset(); }
+    bool idle() const noexcept override
+    {
+        return std::none_of (voices.begin(), voices.end(), [] (const Voice& v) { return v.active; });
+    }
+
+    void render (float* left, float* right, int n, float gainLeft, float gainRight) noexcept override
+    {
+        if (P (param::enable) < 0.5f)
+            return;
+        for (int pos = 0; pos < n; pos += block)
+        {
+            const auto c = std::min (block, n - pos);
+            renderCall (left + pos, right + pos, c, gainLeft, gainRight, playing ? songBeats + (double) pos * tempo.load() / (60.0 * fs) : -1.0);
+        }
+    }
+
+private:
+    float P (int k) const noexcept { return values[(std::size_t) k].load (std::memory_order_relaxed); }
+
+    void reset() noexcept
+    {
+        for (auto& v : voices)
+            v = Voice {};
+        lastPick.fill (-1);
+        heldVelocity.fill (0.0f);
+        pressTime.fill (0);
+        mono = 0;
+        lastKey = 0;
+        rng = 0;
+    }
+
+    double random() noexcept
+    {
+        const auto r = (double) rng / 4294967296.0;
+        rng = rng * 0x4D66B561u + 0x16C0A8E8u;
+        return r;
+    }
+
+    // the glide a new note starts from: from the previous note's key; with Legato only while another key is held
+    double glideFrom (int key) const noexcept
+    {
+        if (P (param::legato) != 0.0f)
+        {
+            bool other = false;
+            for (int k = 0; k < 128; ++k)
+                other = other || (k != key && pressTime[(std::size_t) k] != 0);
+            if (! other)
+                return 0.0;
+        }
+        return (double) (lastKey - key);
+    }
+
+    // the zone a note plays (FLM's choice: the key moved by the Pitch knob, several matches drawn, never the same twice in a row per key)
+    int zoneFor (int key, float velocity) noexcept
+    {
+        const auto kz = key + pitchSemitones (P (param::pitch));
+        const auto vz = (int) (velocity * 127.0f + 0.5f);
+        int match[voiceCount];
+        int count = 0;
+        for (int i = 0; i < (int) zones.size() && count < voiceCount; ++i)
+        {
+            const auto& z = zones[(std::size_t) i].zone;
+            if (z.lowKey <= kz && kz <= z.highKey && z.lowVelocity <= vz && vz <= z.highVelocity)
+                match[count++] = i;
+        }
+        if (count == 0)
+            return -1;
+        if (count == 1)
+            return match[0];
+        int i = 0;
+        for (int guard = 0; guard < 64; ++guard)
+        {
+            i = (int) std::lround (std::min (random(), 1.0) * (double) (count - 1));
+            if (i != lastPick[(std::size_t) key])
+                break;
+        }
+        lastPick[(std::size_t) key] = i;
+        return match[i];
+    }
+
+    void start (Voice& v, int key, float velocity, float pan, float cents, double glideOffset, bool fromRelease) noexcept
+    {
+        const auto zi = zoneFor (key, velocity);
+        if (zi < 0)
+            return;
+        const auto& z = zones[(std::size_t) zi];
+        const auto wasActive = v.active;
+        if (! wasActive)
+            v = Voice {};
+        v.active = true;
+        v.key = key;
+        v.zone = zi;
+        v.pitchOffset = cents * 0.01f;
+        const auto fileRate = z.sample != nullptr ? z.sample->sampleRate : 44100.0;
+        v.baseRate = std::exp2 ((double) (key - z.zone.rootKey) / 12.0) * fileRate / fs;
+        // amp envelope (times fixed now)
+        const auto attack = P (param::attack);
+        v.atk = (attack * attack * attack * attack == 0.0f && ! smooth.load()) ? 1.0 : 1.0 / (envelopeSeconds (attack) * fs);
+        v.dec = z.decay ? 1.0 / (envelopeSeconds (P (param::decay)) * fs) : 1.0;
+        v.rel = 1.0 / (envelopeSeconds (P (param::release)) * fs);
+        v.sus = P (param::sustain);
+        v.state = 0;
+        if (! fromRelease && ! wasActive)
+            v.env = 0.0;
+        // loop and the zone's gain, only with Loop on
+        auto gain = 1.0f;
+        v.looping = false;
+        if (P (param::loop) != 0.0f)
+        {
+            if (z.zone.gain > 0.0001f)
+                gain = z.zone.gain;
+            auto ls = (double) z.zone.loopStart, le = (double) z.zone.loopEnd;
+            if (ls == le && z.sample != nullptr && z.sample->loopStart >= 0 && z.sample->loopEnd > z.sample->loopStart)
+                ls = (double) z.sample->loopStart, le = (double) z.sample->loopEnd;
+            v.looping = z.zone.loopMode != 0 && ls != le && le > ls;
+            v.loopStart = ls, v.loopEnd = le;
+        }
+        v.velocity = velocity * gain;
+        const auto frames = z.sample != nullptr ? (double) z.sample->left.size() : 0.0;
+        v.backwards = P (param::reverse) != 0.0f;
+        if (v.backwards)
+            v.looping = false;
+        v.pos = v.backwards ? frames - 1.0 : 0.0;
+        // pan: a balance of the note's pan
+        const auto d = 2.0f * pan - 1.0f;
+        v.panL = d > 0.0f ? 1.0f - d : 1.0f;
+        v.panR = d < 0.0f ? 1.0f + d : 1.0f;
+        // the envelopes start their attack from where they are
+        v.ftgt = 4.0, v.frate = (float) onePoleRate (P (param::filterAttack), 500.0);
+        v.ptgt = 4.0, v.prate = onePoleRate (P (param::pitchAttack), 500.0);
+        v.lfoPhase = 0.0, v.lfoFade = 0.0;
+        v.glide = glideOffset, v.glideTarget = 0.0;
+        v.counter = 0;
+        v.firstSample = true;
+    }
+
+    void release (Voice& v, bool fast) noexcept
+    {
+        v.state = 2;
+        v.ftgt = 0.0, v.frate = (float) onePoleRate (P (param::filterRelease), 50.0);
+        v.ptgt = 0.0, v.prate = onePoleRate (P (param::pitchRelease), 50.0);
+        if (fast)
+            v.rel = 1.0 / (0.001 * fs);
+    }
+
+    void monoNoteOn (int key, float velocity, float pan, float cents) noexcept
+    {
+        auto& m = voices[(std::size_t) mono];
+        if (! m.active)
+        {
+            start (m, key, velocity, pan, cents, glideFrom (key), false);
+            return;
+        }
+        if (m.state != 2)
+        {
+            m.glideTarget = key - m.key; // no retrigger: the voice glides
+            return;
+        }
+        const auto oldKey = m.key;
+        for (auto& v : voices)
+            if (v.active)
+                release (v, true);
+        for (int i = voiceCount - 1; i >= 0; --i)
+            if (! voices[(std::size_t) i].active)
+            {
+                mono = i;
+                break;
+            }
+        start (voices[(std::size_t) mono], key, velocity, pan, cents, (double) (oldKey - key), false);
+    }
+
+    void renderCall (float* left, float* right, int n, float gainLeft, float gainRight, double songPos) noexcept
+    {
+        // per call: the LFO's step, the global tune, the glides' plan
+        const auto bpm = (double) tempo.load();
+        static constexpr double syncBeats[] = { 0.125, 0.25, 0.5, 0.75, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0 };
+        const auto lfoMode = std::clamp ((int) (P (param::lfoMode) * 2.0f), 0, 2);
+        const auto beats = syncBeats[std::clamp ((int) (P (param::lfoSync) * 9.0f), 0, 9)];
+        const auto period = lfoMode == 2 ? beats * 60.0 / std::max (1.0, bpm) : 1.0 / lfoHz (P (param::lfoRate));
+        const auto dPhase = 1.0 / (period * fs);
+        const auto channelSemis = (std::isnan (liveCents) ? knobCents.load() : liveCents) * 0.01;
+        const auto tune = (double) std::pow (2.0f, ((float) (2.0f * P (param::fineTune)) + (float) pitchSemitones (P (param::pitch)) - 1.0f + (float) channelSemis) / 12.0f);
+        const auto slide = P (param::slide) * 0.5f;
+        const auto glideTime = (double) (slide * slide * slide);
+        const auto pitchAmount = std::pow (2.0 * (double) P (param::pitchAmount) - 1.0, 3.0);
+        const auto shape = std::clamp ((int) (P (param::lfoShape) * 3.0f + 0.5f), 0, 3);
+        const auto amountRaw = 2.0 * (double) P (param::lfoAmount) - 1.0;
+        const auto amount = amountRaw < 0.0 ? -amountRaw * amountRaw : amountRaw * amountRaw;
+        const auto dest = std::clamp ((int) (P (param::lfoDest) * 3.0f), 0, 3);
+        const auto fade = 16.0 * onePoleRate (P (param::lfoAttack), 500.0);
+        const auto kind = filterKind (P (param::filterType));
+        const auto res = (double) P (param::resonance);
+        const auto q = 16.0 * res * res * res + 0.5;
+        const auto cutoff = P (param::cutoff), kbd = P (param::kbdTrack), velTrack = P (param::velTrack);
+        const auto fSus = (double) P (param::filterSustain), fDec = onePoleRate (P (param::filterDecay), 50.0);
+        const auto pSus = (double) P (param::pitchSustain), pDec = onePoleRate (P (param::pitchDecay), 50.0);
+
+        for (auto& v : voices)
+        {
+            if (! v.active)
+                continue;
+            const auto& z = zones[(std::size_t) v.zone];
+            if (z.sample == nullptr || z.sample->left.empty())
+                continue; // (FLM keeps such a voice: no sound)
+            const auto& L = z.sample->left;
+            const auto& R = z.sample->right.empty() ? z.sample->left : z.sample->right;
+            const auto stereo = ! z.sample->right.empty();
+            const auto len = (std::int64_t) L.size();
+            v.glideStep = glideTime > 1.0e-5 ? (v.glideTarget - v.glide) / (glideTime * fs) : 0.0;
+            if (lfoMode == 2 && songPos >= 0.0)
+                v.lfoPhase = songPos / beats - std::floor (songPos / beats);
+            const auto w = (double) std::clamp (v.velocity, 0.0f, 1.0f);
+            const auto rate = v.baseRate * tune * (v.backwards ? -1.0 : 1.0);
+            for (int i = 0; i < n; ++i)
+            {
+                if (v.counter == 0)
+                {
+                    updateLfo (v, shape, amount, fade, dPhase, lfoMode, dest);
+                    if (kind != 0)
+                    {
+                        // (in float, in FLM's order: the cutoff law of FLM_FORMAT §7.5)
+                        const auto c = std::clamp ((cutoff + (dest == 0 ? (float) v.lfo : 0.0f)) + velTrack * v.velocity, 0.0f, 1.0f);
+                        const float envT = ((P (param::filterAmount) * 2.0f - 1.0f) * (float) v.fenv) * 8.0f;
+                        const float base = (float) ((double) c * 10.4 + 4.0) + envT;
+                        const float kt = (((float) v.key + (float) v.glide) - 48.0f) * kbd * 0.083333336f + base;
+                        const auto fc = (double) std::min (std::pow (2.0f, kt), 22000.0f);
+                        if (kind == 1)
+                            v.ladder.design (fc, fs, std::clamp (res, 0.0, 1.0));
+                        else
+                            v.biquad.design (kind, fc, q, fs);
+                    }
+                }
+                v.counter = (v.counter + 1) & 15;
+                // glide
+                if (v.glide != v.glideTarget)
+                {
+                    const auto next = v.glide + v.glideStep;
+                    v.glide = (v.glideStep == 0.0 || (v.glideStep > 0.0 ? next >= v.glideTarget : next <= v.glideTarget)) ? v.glideTarget : next;
+                }
+                auto pf = (double) std::pow (2.0f, (float) ((double) v.pitchOffset + v.glide) / 12.0f);
+                // pitch envelope
+                v.penv += (v.ptgt - v.penv) * v.prate;
+                if (v.penv > 1.0)
+                    v.penv = 1.0, v.ptgt = pSus, v.prate = pDec;
+                if (pitchAmount != 0.0)
+                    pf *= std::exp2 (4.0 * pitchAmount * v.penv * v.penv * v.penv);
+                // read
+                const auto idx = (std::int64_t) std::floor (v.pos);
+                const auto f = v.pos - (double) idx;
+                auto j = idx + 1;
+                if (v.looping && (double) j >= v.loopEnd)
+                    j = (std::int64_t) v.loopStart;
+                const auto at = [len] (const std::vector<float>& b, std::int64_t k) { return k >= 0 && k < len ? (double) b[(std::size_t) k] : 0.0; };
+                auto xl = at (L, idx) * (1.0 - f) + at (L, j) * f;
+                auto xr = stereo ? at (R, idx) * (1.0 - f) + at (R, j) * f : xl;
+                // advance
+                v.pos += v.lfoPitch * pf * rate;
+                if (v.looping && v.pos >= v.loopEnd)
+                    v.pos -= v.loopEnd - v.loopStart;
+                // filter envelope, filter
+                v.fenv = (double) (((float) v.ftgt - (float) v.fenv) * (float) v.frate + (float) v.fenv);
+                if (v.fenv > 1.0)
+                    v.fenv = 1.0, v.ftgt = (float) fSus, v.frate = (float) fDec;
+                if (kind == 1)
+                {
+                    xl = v.ladder.run (0, xl);
+                    xr = stereo ? v.ladder.run (1, xr) : xl;
+                }
+                else if (kind != 0)
+                {
+                    xl = v.biquad.run (0, xl);
+                    xr = v.biquad.run (1, xr);
+                }
+                // amp envelope (linear, heard squared)
+                if (v.state == 0)
+                {
+                    v.env += v.atk;
+                    if (v.env >= 1.0)
+                        v.env = 1.0, v.state = 1;
+                }
+                else if (v.state == 1)
+                {
+                    v.env -= v.dec;
+                    if (v.env < v.sus)
+                        v.env = v.sus;
+                }
+                else
+                {
+                    v.env -= v.rel;
+                    if (v.env < 0.0)
+                        v.env = 0.0;
+                }
+                // the LFO's volume / pan gains, smoothed
+                double tl = 1.0, tr = 1.0;
+                if (dest == 2)
+                    tl = tr = 1.0 + v.lfo;
+                else if (dest == 3)
+                    tl = std::min (1.0, 1.0 + v.lfo), tr = std::min (1.0, 1.0 - v.lfo);
+                if (v.firstSample)
+                    v.gL = tl, v.gR = tr, v.firstSample = false;
+                else
+                    v.gL += (tl - v.gL) * 0.01, v.gR += (tr - v.gR) * 0.01;
+                const auto e2 = v.env * v.env * w;
+                left[i] += (float) (v.gL * xl * e2 * v.panL) * gainLeft;
+                right[i] += (float) (v.gR * xr * e2 * v.panR) * gainRight;
+            }
+            // the voice ends past its sample, or silent after its attack
+            const auto ip = (std::int64_t) std::floor (v.pos);
+            if ((! v.backwards && ip > len) || (v.backwards && ip < 0) || (v.state != 0 && v.env <= 0.0))
+                v.active = false;
+        }
+    }
+
+    void updateLfo (Voice& v, int shape, double amount, double fade, double dPhase, int mode, int dest) noexcept
+    {
+        constexpr double twoPi = 6.283185307179586;
+        double raw;
+        switch (shape)
+        {
+            case 0: raw = std::sin (twoPi * v.lfoPhase); break;
+            case 1: raw = 1.0 - 2.0 * v.lfoPhase; break;
+            case 2: raw = v.lfoPhase >= 0.5 ? 1.0 : -1.0; break;
+            default: raw = v.held; break;
+        }
+        v.lfoFade = std::min (1.0, v.lfoFade + fade);
+        v.lfo = raw * amount * v.lfoFade;
+        v.lfoPhase += 16.0 * dPhase;
+        if (v.lfoPhase >= 1.0)
+        {
+            if (mode == 1)
+                v.lfoPhase = 1.0;
+            else
+            {
+                v.lfoPhase -= 1.0;
+                if (shape == 3)
+                {
+                    v.held = random();
+                    v.lfo = v.held * amount;
+                }
+            }
+        }
+        v.lfoPitch = dest == 1 ? std::exp2 ((v.lfo < 0.0 ? -1.0 : 1.0) * v.lfo * v.lfo) : 1.0;
+    }
+
+    std::vector<EngineZone> zones;
+    std::array<std::atomic<float>, paramCount> values {};
+    std::atomic<float> tempo { 120.0f }, knobCents { 0.0f };
+    std::atomic<int> pbRange { 4 };
+    std::atomic<bool> smooth { true };
+    double fs = 44100.0;
+    std::array<Voice, voiceCount> voices {};
+    std::array<int, 128> lastPick {};
+    std::array<float, 128> heldVelocity {};
+    std::array<std::uint64_t, 128> pressTime {};
+    std::uint64_t clock = 0;
+    int mono = 0, lastKey = 0;
+    std::uint32_t rng = 0;
+    float nextPan = 0.0f, nextCents = 0.0f;
+    float liveCents = std::numeric_limits<float>::quiet_NaN();
+    double lastTicks = -1.0, songBeats = 0.0;
+    bool playing = false;
+};
+
+std::unique_ptr<Instrument> makeInstrument (std::vector<EngineZone> zones) { return std::make_unique<FlmDwSamplerInstrument> (std::move (zones)); }
+} // namespace lynx::flmdw

+ 106 - 0
src/core/FlmDwSampler.h

@@ -0,0 +1,106 @@
+#pragma once
+
+// FL Studio Mobile's "DW Sampler" module (type 1) as LYNX plays an imported .flm (round 190de). Clean-room: written
+// from the behaviour described in docs/analise/FLM_FORMAT.md §7.5 (static analysis of FLM's FL plugin, laws in our own
+// words); no Image-Line code, table or sample is used.
+//
+// The module is a 128-voice multisample player: zones (key × velocity range, root key, gain, loop points) read at
+// the file's own rate with linear interpolation, a linear amp envelope heard squared, one of three filters (a 4-pole
+// ladder low-pass, a band-pass, a high-pass), one-pole filter and pitch envelopes, one LFO per voice, mono / legato
+// with a glide. Velocity sets the level linearly.
+//
+// In LYNX the channel is a Sampler channel (InstrumentKind::sampler) whose ChannelDef::zones hold the zones (path,
+// root, key and velocity ranges, gain, loop points; loopMode 1 = FLM's mode 2) and whose ChannelDef::modelParams start
+// with `marker`: { marker, PB Range, smooth attack, the 34 module values, then per zone 1 when its decay is used }.
+// The rack builds the engine below for such a channel instead of LYNX's own sampler voice. Editing the Sampler's
+// envelope by hand turns it back into a plain LYNX sampler (the module's values are dropped), as FL's imported voices.
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <span>
+#include <string>
+#include <vector>
+
+#include "core/Song.h"
+
+namespace lynx
+{
+class Instrument;
+struct SampleData;
+struct EngineParam;
+
+namespace flmdw
+{
+constexpr float marker = 1901.0f; // modelParams[0] of a channel playing this engine (engine version 1)
+constexpr int paramCount = 34;
+constexpr int head = 3;           // modelParams before the module's values: marker, PB Range, smooth attack
+// automation of the module's value k: AutomationTarget { channelParam, channel, 0, automationBase + k } (clear of the
+// Sampler's own knobs and of the MIDI indices)
+constexpr int automationBase = 0x2400;
+
+namespace param
+{
+enum : int
+{
+    enable, attack, release, pitch, fineTune, decay, sustain, slide, reverse, loop, legato, mono, cutoff, resonance, kbdTrack,
+    velTrack, filterType, filterAttack, filterDecay, filterSustain, filterRelease, filterAmount, pitchAttack, pitchDecay,
+    pitchSustain, pitchRelease, pitchAmount, lfoShape, lfoRate, lfoMode, lfoSync, lfoAmount, lfoDest, lfoAttack
+};
+}
+extern const float defaults[paramCount];
+const char* paramName (int k) noexcept; // FLM's own names ("Attack", "Filter Env. Amount"…)
+
+// --- the module's saved state (CSTM "10WD") and DirectWave programs (.dwp) as FLM reads them
+struct ZoneRecord
+{
+    std::string root;          // "@R@" (the app's resources), "@L@" (the user's library) or empty
+    std::string path;          // relative, '/' separated (or a full path as a program saved it)
+    int rootKey = 48, keyLow = 0, keyHigh = 128, velLow = 0, velHigh = 127;
+    float gain = 1.0f, pan = 0.0f;
+    int loopMode = 0;          // FLM loops only from mode 2 (DirectWave's forward loop)
+    std::int64_t loopStart = 0, loopEnd = 0; // frames, end exclusive
+    float attack = 0.0f, decay = 1.0f, sustain = 1.0f, release = 0.1f;
+};
+struct Custom
+{
+    std::vector<ZoneRecord> zones;
+    bool hasPath = false;      // a PATh / PATH chunk: the zones come from that preset file
+    std::string pathRoot, path;
+    bool pathFloats = false;   // PATh (not PATH): Attack and Release follow the path and replace parameters 1 and 2
+    float pathAttack = 0.0f, pathRelease = 0.1f;
+    int pbRange = 4;           // MIDI chunk byte 0 (semitones of a full bend)
+    bool smoothAttack = true;  // MIDI chunk byte 1: an Attack of 0 still takes 1 ms
+};
+// nullopt: not a "10WD" container
+std::optional<Custom> parseCustom (std::span<const std::uint8_t> bytes);
+// The zones of a DirectWave program file ("DwPr", version > 35): empty when it is not one FLM reads
+std::vector<ZoneRecord> parseProgram (std::span<const std::uint8_t> bytes);
+
+// --- the channel
+bool isChannel (const ChannelDef& c) noexcept;
+// the module's value k of a channel (its default when absent)
+float value (const ChannelDef& c, int k) noexcept;
+// modelParams for a channel: the module's values (fewer = the defaults), its MIDI settings, per zone its decay flag
+std::vector<float> channelParams (const std::vector<float>& values, int pbRange, bool smoothAttack, const std::vector<bool>& zoneDecays);
+// the zone for ChannelDef::zones (its file already resolved)
+SampleZone sampleZone (const ZoneRecord& z, const std::string& resolvedPath);
+
+// --- laws (exposed for tests; v = the stored 0…1 value)
+double envelopeSeconds (float v) noexcept;   // Attack / Decay / Release: 10·v⁴ + 0.001
+double onePoleRate (float v, double k) noexcept; // filter / pitch envelopes, LFO fade: per sample, 1 below 0.001
+int pitchSemitones (float v) noexcept;       // int(48v − 24), float32
+int filterKind (float v) noexcept;           // int(3v), float32: 0 off, 1 ladder low-pass, 2 band-pass, 3 high-pass
+double cutoffHz (float cutoff, double keyTerm, double envTerm) noexcept; // 2^(10.4·c + 4 + …) capped at 22 kHz
+double lfoHz (float v) noexcept;             // free rate
+
+// --- the engine
+struct EngineZone
+{
+    SampleZone zone;
+    bool decay = true;                        // the zone's decay field was above 0
+    std::shared_ptr<const SampleData> sample; // null = a zone whose file is missing (silent, as in FLM)
+};
+std::unique_ptr<Instrument> makeInstrument (std::vector<EngineZone> zones);
+} // namespace flmdw
+} // namespace lynx

+ 104 - 0
src/core/FlmEffects.cpp

@@ -5,6 +5,8 @@
 #include <functional>
 #include <functional>
 
 
 #include "core/Effects.h"
 #include "core/Effects.h"
+#include "core/LynxTune.h"
+#include "core/VocalPitch.h"
 #include "core/ParametricEqFl.h"
 #include "core/ParametricEqFl.h"
 #include "core/PocketFx.h"
 #include "core/PocketFx.h"
 #include "core/Reeverb2.h"
 #include "core/Reeverb2.h"
@@ -455,6 +457,106 @@ int rawControl (float v, float lo, float hi) noexcept
     return (int) std::floor ((hi - lo) * c + lo + 0.5f);
     return (int) std::floor ((hi - lo) * c + lo + 0.5f);
 }
 }
 
 
+// --- round 190de (FLM_FORMAT §7.6): Pitcher (25) and Pitcher 2 (45) → LYNX Tune with a custom scale. Both correct the
+// sung pitch towards the nearest of twelve allowed pitch classes (Pitcher: a 12-byte mask in its CSTM; Pitcher 2: its
+// parameters 1…12), so Scale = Custom with the same note switches is exact; the rest is mapped law by law.
+namespace
+{
+EffectSlot tuneSlot (std::uint16_t allowed)
+{
+    namespace lt = lynxtune;
+    auto slot = makeEffectSlot (EffectKind::lynxTune);
+    slot.params[lt::scale] = 1.0f; // Custom (the last of LYNX Tune's 14 scales)
+    for (int k = 0; k < 12; ++k)
+        slot.params[(std::size_t) (lt::noteC + k)] = (allowed >> k) & 1u ? 1.0f : 0.0f;
+    slot.params[lt::humanize] = 0.0f;
+    slot.params[lt::flexTune] = 0.0f;
+    if (allowed == 0)
+        slot.params[lt::correction] = 0.0f; // (FLM corrects nothing without an allowed note)
+    return slot;
+}
+float retuneValue (double ms) noexcept { return (float) std::sqrt (std::clamp (ms, 0.0, 400.0) / 400.0); }
+} // namespace
+
+void pitcher (const flm::Module& m, Mapped& out)
+{
+    namespace lt = lynxtune;
+    out.label = "FL Studio Mobile: Pitcher (LYNX Tune)";
+    const auto v = [&m] (int i, float fallback) { return param (m, i, fallback); };
+    // CSTM: 12 bytes (pitch class C … B allowed when not 0), then the Key and Scale menus (the mask is what plays)
+    std::uint16_t allowed = 0;
+    if (m.custom.size() >= 12)
+        for (int k = 0; k < 12; ++k)
+            allowed |= m.custom[(std::size_t) k] != 0 ? (std::uint16_t) (1u << k) : 0;
+    else
+        allowed = 0x0AB5; // (no mask saved: the menus' default, C major)
+    auto slot = tuneSlot (allowed);
+    // Speed: a one-pole at τ = (3(1 − v)³ + 0.001) / 8.82 s, instant from 0.99 — LYNX's retune is the same one-pole
+    const auto u = 1.0 - (double) v (1, 0.0f);
+    slot.params[lt::retune] = u < 0.01 ? 0.0f : retuneValue (1000.0 * (3.0 * u * u * u + 0.001) / 8.82);
+    const auto st = (int) ((v (2, 0.5f) - 0.5f) * 24.0f);
+    slot.params[lt::transpose] = (float) (st + 12) / 24.0f;
+    const auto cents = (int) ((v (3, 0.5f) - 0.5f) * 100.0f);
+    slot.params[lt::formantPreserve] = v (4, 0.0f) != 0.0f ? 1.0f : 0.0f;
+    if (v (4, 0.0f) != 0.0f && std::abs (v (5, 0.5f) - 0.5f) > 1e-4f)
+    {
+        slot.params[lt::wideFormant] = 1.0f;
+        slot.params[lt::formantShift] = v (5, 0.5f);
+        out.partial.push_back ("FL Studio Mobile: Pitcher formant shift (LYNX Tune's formant shift)");
+    }
+    // Base Freq A4 = 440·2^((2v − 1)/12), the fine tune folded into it (LYNX Tune's reference: 430…450 Hz)
+    const auto a4 = 440.0 * std::exp2 ((2.0 * (double) v (7, 0.5f) - 1.0) / 12.0) * std::exp2 ((double) cents / 1200.0);
+    slot.params[lt::reference] = (float) std::clamp ((a4 - 430.0) / 20.0, 0.0, 1.0);
+    if (a4 < 430.0 || a4 > 450.0)
+        out.partial.push_back ("FL Studio Mobile: Pitcher base frequency outside 430…450 Hz (capped)");
+    if (cents != 0)
+        out.partial.push_back ("FL Studio Mobile: Pitcher fine tune (on the reference pitch)");
+    slot.params[lt::mix] = std::clamp (v (9, 1.0f), 0.0f, 1.0f);
+    for (int k = 0; k < 12; ++k)
+        slot.params[(std::size_t) (lt::bypassC + k)] = v (10 + k, 0.0f) >= 1.0f ? 1.0f : 0.0f;
+    if (v (22, 0.0f) != 0.0f)
+        slot.params[lt::correction] = 0.0f; // Bypass snapping: transpose only
+    slot.params[lt::range] = 1.0f; // (FLM's detector: 55…1500 Hz; LYNX Tune's widest range)
+    if (v (8, 0.0f) > 1e-4f)
+        out.partial.push_back ("FL Studio Mobile: Pitcher Stability (not reproduced)");
+    out.partial.push_back ("FL Studio Mobile: Pitcher (LYNX Tune's detector and shifter)");
+    out.slots.push_back (slot);
+}
+
+void pitcher2 (const flm::Module& m, Mapped& out)
+{
+    namespace lt = lynxtune;
+    out.label = "FL Studio Mobile: Pitcher 2 (LYNX Tune)";
+    const auto v = [&m] (int i, float fallback) { return param (m, i, fallback); };
+    static constexpr std::uint16_t cMinor = 0x05AD; // C, D, Eb, F, G, Ab, Bb: the module's defaults
+    std::uint16_t allowed = 0;
+    for (int k = 0; k < 12; ++k)
+        if (v (1 + k, (cMinor >> k) & 1u ? 1.0f : 0.0f) > 0.5f)
+            allowed |= (std::uint16_t) (1u << k);
+    auto slot = tuneSlot (allowed);
+    // Speed: four one-poles at (200^v − 0.9)·2.29896 Hz on the target; LYNX's one pole matched at the half-way time
+    const auto fc = (std::pow (200.0, (double) v (13, 0.5f)) - 0.9) * 2.29896;
+    slot.params[lt::retune] = retuneValue (1000.0 * 5.30 / (2.0 * 3.14159265358979 * std::max (fc, 1.0e-3)));
+    slot.params[lt::formantPreserve] = v (16, 0.0f) == 0.0f ? 1.0f : 0.0f; // (the module's flag is inverted)
+    if (std::abs (v (17, 0.5f) - 0.5f) > 1e-4f)
+    {
+        slot.params[lt::wideFormant] = 1.0f;
+        slot.params[lt::formantShift] = v (17, 0.5f);
+    }
+    const auto stability = (double) v (19, 0.5f);
+    slot.params[lt::toleranceCents] = (float) std::clamp ((50.0 * stability - 3.0) / 40.0, 0.0, 1.0);
+    slot.params[lt::mix] = std::clamp (v (22, 1.0f), 0.0f, 1.0f);
+    slot.params[lt::lowLatency] = v (25, 0.0f) != 0.0f ? 1.0f : 0.0f;
+    slot.params[lt::range] = 1.0f;
+    out.partial.push_back ("FL Studio Mobile: Pitcher 2 (LYNX Tune's detector, shifter and retune curve)");
+    if (v (20, 0.0f) > 1e-4f)
+        out.partial.push_back ("FL Studio Mobile: Pitcher 2 Humanization (not reproduced)");
+    if (v (24, 0.0f) > 1e-4f)
+        out.partial.push_back ("FL Studio Mobile: Pitcher 2 Vibrato (not reproduced)");
+    out.slots.push_back (slot);
+}
+// --- end of round 190de
+
 Mapped map (const flm::Module& m, bool live, bool postGainLive)
 Mapped map (const flm::Module& m, bool live, bool postGainLive)
 {
 {
     Mapped out;
     Mapped out;
@@ -499,6 +601,8 @@ Mapped map (const flm::Module& m, bool live, bool postGainLive)
         case 32: reverb32 (m, live, out); break;
         case 32: reverb32 (m, live, out); break;
         case 30: tunedEq (m, live, out); break;
         case 30: tunedEq (m, live, out); break;
         // --- end of round 190by
         // --- end of round 190by
+        case 25: pitcher (m, out); break;  // round 190de
+        case 45: pitcher2 (m, out); break; // round 190de
         default: return out;
         default: return out;
     }
     }
     // FLM's module wrapper (PROVEN, REA_rodada182c "F5 effects, round 188h"): Mix is a linear dry/wet blend (a LYNX
     // FLM's module wrapper (PROVEN, REA_rodada182c "F5 effects, round 188h"): Mix is a linear dry/wet blend (a LYNX

ファイルの差分が大きいため隠しています
+ 741 - 100
src/core/FlmImport.cpp


+ 580 - 0
src/core/FlmNoteFx.cpp

@@ -2,6 +2,10 @@
 
 
 #include <algorithm>
 #include <algorithm>
 #include <cmath>
 #include <cmath>
+#include <cstring>
+#include <map>
+#include <numeric>
+#include <random>
 
 
 namespace lynx::flmnotefx
 namespace lynx::flmnotefx
 {
 {
@@ -204,3 +208,579 @@ bool Chain::apply (Note& n)
     return true;
     return true;
 }
 }
 } // namespace lynx::flmnotefx
 } // namespace lynx::flmnotefx
+
+// --- round 190de: Arpeggiator and Note Echo (FLM_FORMAT §7.8; PROVEN-REA in FLM's FL plugin, laws in LYNX's words) ---
+namespace lynx::flmnotefx
+{
+namespace
+{
+int roundAway (double x) noexcept { return (int) (x >= 0.0 ? std::floor (x + 0.5) : -std::floor (-x + 0.5)); }
+// a stored value → one of n steps (round half away from zero)
+int steps (float v, int n) noexcept { return std::clamp (roundAway ((double) (n - 1) * std::clamp ((double) v, 0.0, 1.0)), 0, n - 1); }
+int cmod (int a, int b) noexcept { return b == 0 ? 0 : a % b; } // (C's remainder)
+
+constexpr double rateBeats[] = { 0.25, 1.0 / 3.0, 0.5, 2.0 / 3.0, 1.0, 4.0 / 3.0, 2.0, -1.0 }; // −1 = one bar
+constexpr double rateMul[] = { 1.0 / 8, 1.0 / 6, 1.0 / 4, 1.0 / 3, 1.0 / 2, 2.0 / 3, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+constexpr int oldRate[] = { 0, 2, 4, 6, 8, 9, 10, 11, 12, 13, 14 }; // 31-value files: per-arp rate at 16 / 27, 11 steps
+struct Retrig { bool notes; double beats; int bars; };
+constexpr Retrig retrigs[] = { { false, 0, 0 }, { true, 0, 0 }, { false, 0.5, 0 }, { false, 1, 0 }, { false, 1.5, 0 }, { false, 2, 0 },
+                               { false, 3, 0 }, { false, 0, 1 }, { false, 0, 2 }, { false, 0, 3 }, { false, 0, 4 }, { false, 0, 8 } };
+const char* const rhythms[] = { "10", "101", "1001", "1011", "10101", "100101", "100110", "101011", "1001010", "1001011", "1001101",
+                                "1010101", "1011011", "10001011", "10001101", "10010010", "10010110", "10010111", "10011010", "10101011", "10101101" };
+
+std::vector<int> cascade (const std::vector<int>& a, bool up, bool first)
+{
+    std::vector<int> out;
+    const auto n = (int) a.size();
+    if (n == 0)
+        return out;
+    const int stepsUp[] = { 1, 1, -1 }, stepsDown[] = { -1, -1, 1 };
+    const auto* st = up ? stepsUp : stepsDown;
+    const auto i0 = up ? 0 : n - 1;
+    if (first)
+        out.push_back (a[(std::size_t) i0]);
+    int k = 0, u = i0 + st[0];
+    while (u >= 0 && u < n)
+    {
+        k = (k + 1) % 3;
+        out.push_back (a[(std::size_t) u]);
+        u += st[k];
+    }
+    return out;
+}
+
+// the sequence of a mode over the held keys (arrival order), and each played key's source key
+std::vector<int> buildSequence (int mode, const std::vector<int>& held, int range, int start, std::map<int, int>& source)
+{
+    const auto R = range + 1;
+    source.clear();
+    std::vector<int> expanded;
+    for (const auto key : held)
+        for (int o = 0; o < R; ++o)
+        {
+            const auto k = key + 12 * o;
+            if (k >= 128)
+                continue;
+            const auto it = source.find (k);
+            if (it == source.end())
+            {
+                source[k] = key;
+                expanded.push_back (k);
+            }
+            else if (key == k || (it->second != k && key < it->second))
+                it->second = key;
+        }
+    if (mode == 0)
+        return expanded;
+    std::vector<int> a;
+    for (const auto& [k, src] : source)
+        a.push_back (k);
+    const auto n = (int) a.size();
+    const auto at = [&a] (int i) { return a[(std::size_t) i]; };
+    std::vector<int> out;
+    const auto upDown = [] (std::vector<int> s) {
+        if (s.size() > 1)
+            for (auto i = (int) s.size() - 2; i >= 1; --i)
+                s.push_back (s[(std::size_t) i]);
+        return s;
+    };
+    switch (mode)
+    {
+        case 1: case 2: return a;
+        case 3: return std::vector<int> (a.rbegin(), a.rend());
+        case 4: return upDown (a);
+        case 5: return upDown (std::vector<int> (a.rbegin(), a.rend()));
+        case 6:
+        {
+            const auto h = n / 2;
+            int lo, hi;
+            if (n % 2 == 0)
+                out = { at (h - 1), at (h) }, lo = h - 2, hi = h + 1;
+            else
+                out = { at (h) }, lo = h - 1, hi = h + 1;
+            for (; lo >= 0 || hi < n; --lo, ++hi)
+            {
+                if (lo >= 0)
+                    out.push_back (at (lo));
+                if (hi < n)
+                    out.push_back (at (hi));
+            }
+            return out;
+        }
+        case 7:
+            for (int i = 0, j = n - 1; i <= j; ++i, --j)
+            {
+                if (i != j)
+                    out.push_back (at (i));
+                out.push_back (at (j));
+            }
+            return out;
+        case 8:
+        {
+            auto s = held;
+            std::sort (s.begin(), s.end());
+            const auto m = (int) s.size();
+            const auto anchor = s[(std::size_t) ((m + cmod (start, m)) % m)];
+            for (int o = 0; o < R; ++o)
+                if (anchor + 12 * o < 128)
+                    out.push_back (anchor + 12 * o);
+            return out;
+        }
+        case 9: case 10:
+            if (n == 1)
+                return a;
+            for (int i = 1; i < n; ++i)
+                out.push_back (at (0)), out.push_back (at (i));
+            if (mode == 10)
+                for (int i = n - 2; i > 1; --i)
+                    out.push_back (at (0)), out.push_back (at (i));
+            return out;
+        case 11: case 12:
+            if (n == 1)
+                return a;
+            for (int i = n - 2; i >= 0; --i)
+                out.push_back (at (n - 1)), out.push_back (at (i));
+            if (mode == 12)
+                for (int i = 1; i < n - 2; ++i)
+                    out.push_back (at (n - 1)), out.push_back (at (i));
+            return out;
+        case 13: case 14: case 15:
+        {
+            std::vector<int> upJ, downJ;
+            for (int i = 0; i < n; i += 2)
+                upJ.push_back (at (i));
+            for (int i = 1; i < n; i += 2)
+                upJ.push_back (at (i));
+            for (int i = n - 1; i >= 0; i -= 2)
+                downJ.push_back (at (i));
+            for (int i = n - 2; i >= 0; i -= 2)
+                downJ.push_back (at (i));
+            if (mode == 13)
+                return upJ;
+            if (mode == 14)
+                return downJ;
+            upJ.insert (upJ.end(), downJ.begin(), downJ.end());
+            return upJ;
+        }
+        case 16:
+        {
+            auto s = held;
+            std::sort (s.begin(), s.end());
+            const auto m = (int) s.size();
+            if (m == 1)
+                return { s[0] };
+            const auto D = m < 3 ? 1 : (m - 2) * 3;
+            const auto iters = m == 2 ? R / std::gcd (R, 2) : (m - 2) * R;
+            int c = 0, j = m > 2 ? 2 : 1;
+            const auto octave = [&] (int idx) {
+                const auto v = s[(std::size_t) idx] + 12 * ((c / D) % R);
+                ++c;
+                if (v < 128)
+                    out.push_back (v);
+            };
+            for (int it = 0; it < iters; ++it)
+            {
+                out.push_back (s[0]);
+                octave (1);
+                if (j < 2)
+                    out.push_back (s[0]);
+                else
+                {
+                    const auto i = std::clamp (j - 1, 1, m - 1);
+                    octave (i);
+                }
+                octave (std::clamp (j, 1, m - 1));
+                j = m < 3 ? 1 : (j < m - 1 ? j + 1 : 2);
+            }
+            return out;
+        }
+        case 17: return cascade (a, true, true);
+        case 18: return cascade (a, false, true);
+        case 19:
+        {
+            out = n > 1 ? cascade (a, true, true) : a;
+            if (n > 1)
+            {
+                const int st[] = { -1, -1, 1 };
+                int k = 0, u = n - 2;
+                while (u >= 0 && u < n)
+                {
+                    k = (k + 1) % 3;
+                    out.push_back (at (u));
+                    u += st[k];
+                }
+            }
+            return out;
+        }
+        default: return a; // the random modes draw from the sorted set
+    }
+}
+
+struct ArpSettings
+{
+    double base = 0.5, ms = 250.0;
+    bool sync = true, latch = false, enabled = true;
+    double swing = 0.0, swingRate = 0.5, velocity = 0.0, gate = 0.5, mul = 1.0;
+    int mode = 0, range = 0, octave = 0, start = 0, rhythm = 0, rotate = 0, repeats = 0, retrig = 0;
+
+    double step (double bpm) const noexcept { return (sync ? base : std::max (ms * 0.001 * bpm / 60.0, 1.0e-6)) * mul; }
+};
+
+ArpSettings arpSettings (std::span<const float> raw, int arp, int beatsPerBar)
+{
+    std::vector<float> p (raw.begin(), raw.end());
+    if (p.size() < 32) // a 31-value file: the per-arp rate is at 16 / 27, in 11 old steps
+    {
+        p.resize (33, 0.0f);
+        p[31] = (float) oldRate[steps (p[16], 11)] / 14.0f;
+        p[32] = (float) oldRate[steps (p[27], 11)] / 14.0f;
+    }
+    p.resize (33, 0.0f);
+    const auto g = [&p] (int k) { return p[(std::size_t) k]; };
+    const int map[] = { arp == 0 ? 9 : 20, arp == 0 ? 10 : 21, arp == 0 ? 11 : 22, arp == 0 ? 12 : 23, arp == 0 ? 13 : 24, arp == 0 ? 14 : 25,
+                        arp == 0 ? 15 : 26, arp == 0 ? 31 : 32, arp == 0 ? 17 : 28, arp == 0 ? 18 : 29, arp == 0 ? 19 : 30 };
+    ArpSettings a;
+    const auto rate = rateBeats[steps (g (1), 8)];
+    a.base = rate < 0.0 ? (double) beatsPerBar : rate;
+    a.sync = g (3) > 0.5f;
+    a.ms = 50.0 + 950.0 * (double) g (2);
+    a.swing = std::clamp ((double) g (4), 0.0, 1.0);
+    a.swingRate = steps (g (5), 2) == 0 ? 0.5 : 0.25;
+    a.latch = g (6) > 0.5f;
+    a.velocity = std::clamp (2.0 * (double) g (7 + arp) - 1.0, -1.0, 1.0);
+    a.gate = std::clamp ((double) g (map[0]), 0.0, 1.0) * 0.9 + 0.1;
+    a.mode = steps (g (map[1]), 24);
+    a.range = steps (g (map[2]), 4);
+    a.octave = steps (g (map[3]), 7) - 3;
+    a.start = steps (g (map[4]), 17) - 8;
+    a.rhythm = steps (g (map[5]), 22);
+    const auto length = a.rhythm > 0 ? (int) std::strlen (rhythms[a.rhythm - 1]) : 0;
+    a.rotate = length > 1 ? roundAway ((double) (length - 1) * std::clamp (2.0 * (double) g (map[6]) - 1.0, -1.0, 1.0)) : 0;
+    a.mul = rateMul[steps (g (map[7]), 15)];
+    a.repeats = steps (g (map[8]), 17);
+    a.retrig = steps (g (map[9]), 12);
+    a.enabled = g (map[10]) > 0.5f;
+    return a;
+}
+
+std::vector<TimedNote> runArp (const ArpSettings& a, const std::vector<TimedNote>& in, double bpm, int beatsPerBar, std::mt19937& rng)
+{
+    std::vector<TimedNote> out;
+    if (in.empty())
+        return out;
+    const auto st = a.step (bpm);
+    struct Ev { double t; bool on; int key; float velocity, pan; };
+    std::vector<Ev> evs;
+    for (const auto& n : in)
+    {
+        evs.push_back ({ n.end, false, n.key, n.velocity, n.pan });
+        evs.push_back ({ n.start, true, n.key, n.velocity, n.pan });
+    }
+    // (note-offs before note-ons at the same time: FLM's order there is not fixed)
+    std::stable_sort (evs.begin(), evs.end(), [] (const Ev& x, const Ev& y) { return x.t < y.t || (x.t == y.t && ! x.on && y.on); });
+    std::vector<int> held, seq, bag;
+    std::map<int, int> source;
+    std::map<int, float> vel, pan;
+    int idx = 0, cycles = 0, lastPlayed = -1, walkPos = -1, walkDir = 1;
+    bool done = false, haveNext = false;
+    double next = 0.0, anchor = 0.0, retrigAt = 0.0;
+    const auto& rt = retrigs[a.retrig];
+    const auto period = a.retrig >= 2 ? std::max (rt.beats + rt.bars * (double) beatsPerBar, st) : 0.0;
+    const auto oneSample = bpm / 60.0 / 44100.0;
+    const auto rhythmLength = a.rhythm > 0 ? (int) std::strlen (rhythms[a.rhythm - 1]) : 0;
+    double end = 0.0;
+    for (const auto& e : evs)
+        end = std::max (end, e.t);
+    end += 8.0;
+    const auto cutFrom = [&out] (double t) {
+        for (auto& o : out)
+            if (o.end > t && o.start < t)
+                o.end = t;
+    };
+    const auto pick = [&] () -> int {
+        const auto n = (int) seq.size();
+        if (n < 2)
+            return seq.empty() ? -1 : seq[0];
+        switch (a.mode)
+        {
+            case 20: return seq[(std::size_t) std::uniform_int_distribution<int> (0, n - 1) (rng)];
+            case 21:
+                if (bag.empty() || (int) bag.size() > n)
+                {
+                    bag.resize ((std::size_t) n);
+                    std::iota (bag.begin(), bag.end(), 0);
+                    std::shuffle (bag.begin(), bag.end(), rng);
+                    if (seq[(std::size_t) bag.back()] == lastPlayed)
+                        for (std::size_t i = 0; i + 1 < bag.size(); ++i)
+                            if (seq[(std::size_t) bag[i]] != lastPlayed)
+                            {
+                                std::swap (bag[i], bag.back());
+                                break;
+                            }
+                }
+                {
+                    const auto i = bag.back();
+                    bag.pop_back();
+                    return seq[(std::size_t) i];
+                }
+            case 22: return seq[(std::size_t) (idx % n)];
+            default:
+            {
+                if (walkPos < 0 || walkPos >= n)
+                {
+                    walkPos = std::uniform_int_distribution<int> (0, n - 1) (rng);
+                    walkDir = std::uniform_int_distribution<int> (0, 1) (rng) != 0 ? 1 : -1;
+                    return seq[(std::size_t) walkPos];
+                }
+                int cand[3], weight[3], count = 0;
+                for (const auto& [d, w] : { std::pair<int, int> { walkDir, 50 }, { -walkDir, 30 }, { 2 * walkDir, 20 } })
+                    if (walkPos + d >= 0 && walkPos + d < n)
+                        cand[count] = walkPos + d, weight[count++] = w;
+                if (count == 0)
+                    return seq[(std::size_t) walkPos];
+                int total = 0;
+                for (int i = 0; i < count; ++i)
+                    total += weight[i];
+                auto r = std::uniform_int_distribution<int> (0, total - 1) (rng), chosen = cand[0];
+                for (int i = 0; i < count; ++i)
+                {
+                    if (r < weight[i])
+                    {
+                        chosen = cand[i];
+                        break;
+                    }
+                    r -= weight[i];
+                }
+                walkDir = chosen >= walkPos ? 1 : -1;
+                walkPos = chosen;
+                return seq[(std::size_t) walkPos];
+            }
+        }
+    };
+    const auto rebuild = [&] {
+        seq = buildSequence (a.mode, held, a.range, a.start, source);
+        if (a.mode == 22)
+            std::shuffle (seq.begin(), seq.end(), rng);
+        bag.clear();
+    };
+    const auto fireUntil = [&] (double until) {
+        while (true)
+        {
+            if (period > 0.0 && ! held.empty() && retrigAt < until && (! haveNext || retrigAt <= next))
+            {
+                cutFrom (retrigAt);
+                idx = 0, cycles = 0, done = false, next = retrigAt, anchor = retrigAt, haveNext = true;
+                retrigAt += period;
+                continue;
+            }
+            if (period > 0.0 && held.empty() && retrigAt < until)
+                retrigAt += period * std::max (1.0, std::ceil ((until - retrigAt) / period));
+            if (held.empty() || ! haveNext || next >= until || done)
+                return;
+            const auto t = next;
+            auto play = true;
+            if (rhythmLength > 0)
+            {
+                const auto k = (long long) std::floor ((t - anchor) / st + 1e-9);
+                const auto r = (int) (((k % rhythmLength) - a.rotate) % rhythmLength + rhythmLength) % rhythmLength;
+                play = rhythms[a.rhythm - 1][r] == '1';
+            }
+            if (play)
+            {
+                auto ts = t;
+                const auto off = a.swing > 0.0 ? std::min (a.swing * 0.5 * a.swingRate, st * 0.5) : 0.0;
+                if (off > 0.0)
+                {
+                    auto ph = std::fmod (t, 2.0 * a.swingRate);
+                    if (ph < 0.0)
+                        ph += 2.0 * a.swingRate;
+                    if (ph >= a.swingRate)
+                        ts = t + off * std::clamp (1.0 - (ph - a.swingRate) / a.swingRate, 0.0, 1.0);
+                }
+                auto length = a.gate * st;
+                if (a.gate >= 0.999999 && oneSample < length)
+                    length -= oneSample;
+                auto cycle = (int) seq.size();
+                const auto emit = [&] (int key, int src) {
+                    if (key < 0 || key >= 128 || ! a.enabled)
+                        return;
+                    out.push_back ({ ts, ts + length, key, (float) std::clamp ((1.0 + a.velocity) * (double) vel[src], 0.0, 1.0), pan[src] });
+                };
+                if (a.mode == 1)
+                {
+                    cycle = a.range + 1;
+                    auto sorted = held;
+                    std::sort (sorted.begin(), sorted.end());
+                    for (const auto k : sorted)
+                        emit (k + 12 * ((cycle + idx % cycle) % cycle) + 12 * a.octave, k);
+                }
+                else if (! seq.empty())
+                {
+                    const auto L = (int) seq.size();
+                    const auto key = a.mode >= 20 ? pick() : seq[(std::size_t) (a.mode == 8 ? idx % L : (L + cmod (a.start + idx, L)) % L)];
+                    const auto src = source.count (key) != 0 ? source[key] : key;
+                    lastPlayed = key;
+                    emit (key + 12 * a.octave, vel.count (src) != 0 ? src : held.front());
+                }
+                ++idx;
+                if (idx >= std::max (1, cycle))
+                {
+                    idx = 0;
+                    ++cycles;
+                    if (a.repeats > 0 && cycles >= a.repeats)
+                        done = true;
+                }
+            }
+            next = t + st;
+        }
+    };
+    for (const auto& e : evs)
+    {
+        fireUntil (e.t);
+        if (e.on)
+        {
+            const auto wasEmpty = held.empty();
+            if (std::find (held.begin(), held.end(), e.key) == held.end())
+                held.push_back (e.key);
+            vel[e.key] = e.velocity;
+            pan[e.key] = e.pan;
+            if (wasEmpty)
+            {
+                next = std::ceil (e.t / st - 1e-12) * st;
+                idx = 0, cycles = 0, done = false, anchor = next, haveNext = true;
+                walkPos = -1;
+                if (period > 0.0)
+                    retrigAt = std::ceil (e.t / period - 1e-12) * period;
+            }
+            else if (rt.notes)
+                idx = 0, cycles = 0, done = false, anchor = next;
+            rebuild();
+        }
+        else
+        {
+            if (! a.latch)
+                if (const auto it = std::find (held.begin(), held.end(), e.key); it != held.end())
+                    held.erase (it);
+            if (held.empty())
+            {
+                cutFrom (e.t); // (the sounding arp notes end at the release)
+                haveNext = false;
+            }
+            else
+            {
+                rebuild();
+                if (idx >= (int) held.size())
+                    idx = std::max (0, (int) held.size() - 1);
+            }
+        }
+    }
+    fireUntil (end);
+    return out;
+}
+} // namespace
+
+bool timeEffectActive (std::uint32_t type, std::span<const float> p) noexcept
+{
+    if (p.empty() || p[0] < 0.5f)
+        return false; // (switched off: the notes pass)
+    if (type == noteEcho)
+        return p.size() > 1 && roundAway (32.0 * (double) p[1]) > 0;
+    return type == arpeggiator;
+}
+
+std::vector<TimedNote> arpeggiate (std::span<const float> params, const std::vector<TimedNote>& in, double bpm, int beatsPerBar, bool& random)
+{
+    std::mt19937 rng (0x190DEu);
+    std::vector<TimedNote> out;
+    random = false;
+    for (int arp = 0; arp < 2; ++arp)
+    {
+        const auto a = arpSettings (params, arp, std::max (1, beatsPerBar));
+        if (! a.enabled)
+            continue;
+        random = random || a.mode >= 20;
+        const auto notes = runArp (a, in, bpm, std::max (1, beatsPerBar), rng);
+        out.insert (out.end(), notes.begin(), notes.end());
+    }
+    std::stable_sort (out.begin(), out.end(), [] (const TimedNote& x, const TimedNote& y) { return x.start < y.start; });
+    return out;
+}
+
+std::vector<TimedNote> echo (std::span<const float> params, const std::vector<TimedNote>& in, double bpm, bool& random)
+{
+    std::vector<float> p (params.begin(), params.end());
+    static constexpr float defaultsEcho[16] = { 1.0f, 0.25f, 0.24253564f, 0.24253564f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f };
+    for (auto k = p.size(); k < 16; ++k)
+        p.push_back (defaultsEcho[k]);
+    const auto g = [&p] (int k) { return (double) std::clamp (p[(std::size_t) k], 0.0f, 1.0f); };
+    const auto reps = roundAway (32.0 * g (1));
+    const auto sync = g (4) > 0.5;
+    const auto x = 0.03125 + 7.96875 * std::pow (g (sync ? 3 : 2), 2.0);
+    auto D = x;
+    if (sync)
+    {
+        static constexpr double grid[] = { 0.125, 0.25, 0.375, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 8.0 };
+        D = grid[0];
+        for (const auto v : grid)
+            if (std::abs (v - x) < std::abs (D - x))
+                D = v;
+    }
+    const auto signedLaw = [] (double v) { return v > 0.5 ? 2.0 * (v - 0.5) : 1.8 * v - 0.9; };
+    const auto pitchOffset = roundAway (48.0 * g (5) - 24.0), pitch = roundAway (24.0 * g (8) - 12.0);
+    const auto velOffset = signedLaw (g (6)), factor = 1.0 + signedLaw (g (7));
+    const auto drift = 0.7 + 0.6 * g (9), lengthDrift = g (10) > 0.5 ? 2.0 * g (10) : 0.5 + g (10);
+    const auto rho = g (11), panOffset = 2.0 * g (12) - 1.0, panDrift = g (13) - 0.5;
+    const auto pingPong = g (14) > 0.5;
+    random = rho > 0.0;
+    std::mt19937 rng (0x190DEu);
+    std::uniform_real_distribution<double> u (0.0, 1.0);
+    // (times in samples at 44.1 kHz, as FLM counts them, then back to beats)
+    const auto sr = 44100.0, spb = sr * 60.0 / bpm;
+    const auto tick = (long long) (sr * 0.46875 / bpm);
+    const auto ds = (long long) (D * spb);
+    std::vector<TimedNote> out;
+    for (const auto& n : in)
+    {
+        auto dry = n;
+        if (reps <= 0)
+        {
+            out.push_back (dry);
+            continue;
+        }
+        auto k = std::clamp (n.key + pitchOffset, 0, 127);
+        auto v = std::clamp ((double) n.velocity + velOffset, 0.0, 1.0);
+        auto pn = std::clamp (panOffset + std::clamp (2.0 * (double) n.pan - 1.0, -1.0, 1.0), -1.0, 1.0);
+        const auto l0 = (long long) std::llround ((n.end - n.start) * spb);
+        double gap = (double) ds, pos = n.start * spb + (double) ds;
+        long long length = l0 <= ds ? l0 : -1;
+        if ((n.end - n.start) * spb > (double) ds)
+            dry.end = n.start + (double) ds / spb; // (still held at the first echo: it ends there)
+        out.push_back (dry);
+        for (int r = reps - 1;; --r)
+        {
+            const auto echoNo = reps - r;
+            v = std::clamp (v * factor, 0.0, 1.0);
+            k = std::clamp (k + pitch, 0, 127);
+            const auto q = pingPong && echoNo % 2 == 0 ? -pn : pn;
+            auto nextGap = r > 0 ? std::pow (drift, echoNo + 1) * (double) ds : 0.0;
+            if (r > 0 && rho > 0.0)
+                nextGap = std::max (0.0, nextGap * (1.0 + rho * (2.0 * u (rng) - 1.0)));
+            if (length == -1)
+                length = (long long) gap;
+            auto ln = (long long) ((double) length * lengthDrift + 0.5);
+            ln = std::max (0LL, std::min (ln, (long long) gap));
+            if (r > 0)
+                ln = std::max (0LL, std::min (ln, std::max (0LL, (long long) nextGap - 1)));
+            out.push_back ({ pos / spb, (pos + (double) ln) / spb, k, (float) v, (float) std::clamp ((q + 1.0) * 0.5, 0.0, 1.0) });
+            length = ln;
+            if (! (r > 0 && v > 0.007874016 && ln >= tick))
+                break;
+            pn = std::clamp (panDrift + pn, -1.0, 1.0);
+            pos += (double) (long long) nextGap;
+            gap = nextGap;
+        }
+    }
+    std::stable_sort (out.begin(), out.end(), [] (const TimedNote& a, const TimedNote& b) { return a.start < b.start; });
+    return out;
+}
+} // namespace lynx::flmnotefx

+ 19 - 1
src/core/FlmNoteFx.h

@@ -19,7 +19,7 @@
 //   below), a custom set looks upwards first.
 //   below), a custom set looks upwards first.
 // - Randomizer (type 49): 1 Pitch (range = round(24v) semitones either way), 2 Velocity (± v), 3 Pan (± v of the
 // - Randomizer (type 49): 1 Pitch (range = round(24v) semitones either way), 2 Velocity (± v), 3 Pan (± v of the
 //   whole width), 4 Gate (the chance a note plays; 0 = none).
 //   whole width), 4 Gate (the chance a note plays; 0 = none).
-// Note Echo (47) and Arpeggiator (51) are not converted.
+// Note Echo (47) and Arpeggiator (51) act in time: see arpeggiate() and echo() below (round 190de).
 
 
 #include <cstdint>
 #include <cstdint>
 #include <span>
 #include <span>
@@ -91,4 +91,22 @@ private:
     std::uint32_t state = 0x190B5u; // the draws repeat from import to import
     std::uint32_t state = 0x190B5u; // the draws repeat from import to import
     double uniform() noexcept;      // 0 ≤ x < 1
     double uniform() noexcept;      // 0 ≤ x < 1
 };
 };
+// --- round 190de (FLM_FORMAT §7.8): the note effects that act in time, baked on the rack's song timeline. A note in
+// song beats; pan 0…1.
+struct TimedNote
+{
+    double start = 0.0, end = 0.0;
+    int key = 60;
+    float velocity = 0.8f, pan = 0.5f;
+};
+// The Arpeggiator (type 51): both arps over the notes the rack receives (all of them, in song time from 0 at `bpm`,
+// `beatsPerBar` beats a bar); the input notes are replaced by what the arps play. `random` = a random mode was used
+// (LYNX draws with its own seed; FLM's draws change at every playback).
+std::vector<TimedNote> arpeggiate (std::span<const float> params, const std::vector<TimedNote>& in, double bpm, int beatsPerBar, bool& random);
+// Note Echo (type 47): the dry notes (a dry note still held at its first echo ends there) and their echoes.
+// `random` = Delay Rand. is above 0 (LYNX draws with its own seed).
+std::vector<TimedNote> echo (std::span<const float> params, const std::vector<TimedNote>& in, double bpm, bool& random);
+// The module does something to the notes: Note Echo with repetitions, an Arpeggiator (a module switched off passes
+// them; an Arpeggiator with both arps off is silent)
+bool timeEffectActive (std::uint32_t type, std::span<const float> params) noexcept;
 } // namespace lynx::flmnotefx
 } // namespace lynx::flmnotefx

+ 380 - 0
src/core/FlmSlicer.cpp

@@ -0,0 +1,380 @@
+#include "core/FlmSlicer.h"
+
+#include <algorithm>
+#include <array>
+#include <atomic>
+#include <cmath>
+#include <complex>
+
+#include "core/FlmPad.h"
+#include "core/Instruments.h"
+
+// FL Studio Mobile's Slicer (round 190de; FLM_FORMAT §7.7). Clean-room: the detector and the voice below are the
+// behaviour read in FLM's FL plugin, written in LYNX's own words and code.
+
+namespace lynx::flmslicer
+{
+const float defaults[paramCount] = { 1.0f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f };
+
+bool isChannel (const ChannelDef& c) noexcept
+{
+    return c.instrument == InstrumentKind::sampler && c.modelParams.size() >= (std::size_t) (head + paramCount) && c.modelParams[0] == marker;
+}
+
+std::vector<float> channelParams (const std::vector<float>& values, float sensitivity, int firstKey)
+{
+    std::vector<float> out { marker, std::max (0.0f, sensitivity), (float) std::clamp (firstKey, 0, 127) };
+    for (int k = 0; k < paramCount; ++k)
+        out.push_back (k < (int) values.size() && std::isfinite (values[(std::size_t) k]) ? std::clamp (values[(std::size_t) k], 0.0f, 1.0f) : defaults[k]);
+    return out;
+}
+
+// ------------------------------------------------------------------------------------------------- the detector
+namespace
+{
+void fft128 (std::array<std::complex<double>, 128>& a) noexcept
+{
+    constexpr int n = 128;
+    for (int i = 1, j = 0; i < n; ++i)
+    {
+        int bit = n >> 1;
+        for (; j & bit; bit >>= 1)
+            j ^= bit;
+        j ^= bit;
+        if (i < j)
+            std::swap (a[(std::size_t) i], a[(std::size_t) j]);
+    }
+    for (int len = 2; len <= n; len <<= 1)
+    {
+        const auto w = std::polar (1.0, -2.0 * 3.14159265358979323846 / len);
+        for (int i = 0; i < n; i += len)
+        {
+            std::complex<double> wn (1.0, 0.0);
+            for (int k = 0; k < len / 2; ++k)
+            {
+                const auto u = a[(std::size_t) (i + k)], v = a[(std::size_t) (i + k + len / 2)] * wn;
+                a[(std::size_t) (i + k)] = u + v;
+                a[(std::size_t) (i + k + len / 2)] = u - v;
+                wn *= w;
+            }
+        }
+    }
+}
+
+// one band's onset rise: hold `w` frames, release `c`, rise above the previous level × `g` × 5, floor 1e-10 / `d`
+std::vector<double> rise (const std::vector<double>& band, int w, double c, double g, double d)
+{
+    const auto n = band.size();
+    std::vector<double> r (n, 0.0);
+    const auto floor = 1.0e-10 / d;
+    double prev = 0.0;
+    for (std::size_t k = 0; k + 1 < n; ++k)
+    {
+        double h = 0.0;
+        for (std::size_t j = k >= (std::size_t) w ? k - (std::size_t) w : 0; j <= k; ++j)
+            h = std::max (h, band[j]);
+        const auto e = h <= prev ? h * (1.0 - c) + prev * c : h;
+        const auto m = k == 0 ? floor : std::max (floor, prev);
+        r[k] = e < m ? 0.0 : (e / m - 1.0) * g * 5.0;
+        prev = e;
+    }
+    return r;
+}
+} // namespace
+
+std::vector<std::int64_t> slices (const SampleData& sample, float sensitivity)
+{
+    const auto L = (std::int64_t) sample.left.size();
+    std::vector<std::int64_t> out;
+    if (L <= 0)
+        return out;
+    if (! (sensitivity > 0.0f))
+    {
+        for (const auto m : sample.markerStarts)
+            if (m >= 0 && m < L && (out.empty() || m > out.back()) && out.size() < 128)
+                out.push_back (m);
+        if (out.empty())
+            out.push_back (0);
+        return out;
+    }
+    const auto fs = sample.sampleRate > 0.0 ? sample.sampleRate : 44100.0;
+    const auto& R = sample.right.empty() ? sample.left : sample.right;
+    const auto channels = sample.right.empty() ? 1 : 2;
+    float peak = 0.0f;
+    for (std::int64_t i = 0; i < L; ++i)
+        peak = std::max ({ peak, std::abs (sample.left[(std::size_t) i]), std::abs (R[(std::size_t) i]) });
+    if (peak <= 0.0f)
+        return { 0 };
+    // the analysis copy: the left channel normalised, three passes of a gentle high-pass (float, as FLM)
+    std::vector<float> x (sample.left.begin(), sample.left.end());
+    const auto inv = 1.0f / peak;
+    for (auto& v : x)
+        v *= inv;
+    for (int pass = 0; pass < 3; ++pass)
+    {
+        float v = 0.0f, lp = 0.0f;
+        for (auto& s : x)
+        {
+            v += (s - lp) * 9.134e-5f;
+            lp += v;
+            v *= 0.96f;
+            s = s - lp;
+        }
+    }
+    // frames of 128 every 16, a periodic Hamming window, power in two bands
+    const auto frames = (std::size_t) ((L + 143) / 16);
+    std::array<double, 128> window {};
+    double sum = 0.0;
+    for (int i = 0; i < 128; ++i)
+        sum += window[(std::size_t) i] = 0.53836 - 0.46164 * std::cos (2.0 * 3.14159265358979323846 * i / 128.0);
+    const auto scale = 1.0 / sum;
+    std::vector<double> low (frames, 0.0), high (frames, 0.0);
+    std::array<std::complex<double>, 128> buf {};
+    for (std::size_t k = 0; k < frames; ++k)
+    {
+        for (int i = 0; i < 128; ++i)
+        {
+            const auto at = (std::int64_t) (16 * k) + i;
+            buf[(std::size_t) i] = { at < L ? (double) x[(std::size_t) at] * window[(std::size_t) i] : 0.0, 0.0 };
+        }
+        fft128 (buf);
+        double lo = 0.0, hi = 0.0;
+        for (int b = 1; b <= 63; ++b)
+        {
+            const auto p = std::norm (buf[(std::size_t) b]) * scale * scale;
+            (b <= 5 ? lo : hi) += p;
+        }
+        low[k] = lo * 0.2;
+        high[k] = hi / 58.0;
+    }
+    const auto rl = rise (low, 55, 0.9761027, 0.9, 1.8), rh = rise (high, 41, 0.9643691, 1.0, 20.0);
+    std::vector<double> on (frames);
+    for (std::size_t k = 0; k < frames; ++k)
+        on[k] = std::max (rl[k], rh[k]) * (double) sensitivity;
+    // picking: an onset where the strength passes 1, started at the earliest frame of the last 28 above 0.75, at the
+    // first sample louder than 5 % of the peak; at least 60 ms apart
+    const auto ratio = fs / 44100.0;
+    const auto minLen = (std::int64_t) std::round (0.060 * fs);
+    const auto threshold = 0.05 * (double) peak;
+    std::size_t k = 0;
+    while (k < frames && out.size() < 128)
+    {
+        if (on[k] < 1.0)
+        {
+            ++k;
+            continue;
+        }
+        auto j = k >= 28 ? k - 28 : 0;
+        while (j < k && ! (on[j] > 0.75))
+            ++j;
+        const auto p = std::clamp ((std::int64_t) std::round ((double) (16 * j) * ratio), (std::int64_t) 0, L - 1);
+        std::int64_t start = 0;
+        if (p >= 1)
+        {
+            start = L;
+            for (auto q = p; q < L; ++q)
+            {
+                const auto a = (double) sample.left[(std::size_t) q], b = channels == 2 ? (double) R[(std::size_t) q] : 0.0;
+                if (std::sqrt ((a * a + b * b) / channels) > threshold)
+                {
+                    start = q;
+                    break;
+                }
+            }
+        }
+        if (start <= L - minLen && (out.empty() || start > out.back()))
+            out.push_back (start);
+        k = std::max (k + 1, (std::size_t) std::round (std::round ((double) (start + minLen) / ratio + 64.0) / 16.0));
+    }
+    if (out.empty())
+        out.push_back (0);
+    return out;
+}
+
+// ------------------------------------------------------------------------------------------------- the voice
+namespace
+{
+constexpr int voiceCount = 256;
+
+struct Voice
+{
+    bool active = false;
+    int key = 0;
+    double pos = 0.0, end = 0.0, sliceEnd = 0.0;
+    double level = 0.0, target = 5.0, rate = 1.0;
+    float gainL = 1.0f, gainR = 1.0f;
+    bool decaying = false, ending = false;
+};
+
+class SlicerInstrument final : public Instrument
+{
+public:
+    explicit SlicerInstrument (std::shared_ptr<const SampleData> s) : sample (std::move (s))
+    {
+        for (int k = 0; k < paramCount; ++k)
+            values[(std::size_t) k].store (defaults[k]);
+    }
+
+    void prepare (double sampleRate) noexcept override
+    {
+        fs = sampleRate > 0.0 ? sampleRate : 44100.0;
+        for (auto& v : voices)
+            v = Voice {};
+    }
+
+    void configure (const ChannelDef& c, double) noexcept override
+    {
+        knobCents.store (c.sampler.pitch * 100.0f);
+        if (! isChannel (c))
+            return;
+        for (int k = 0; k < paramCount; ++k)
+            values[(std::size_t) k].store (std::clamp (c.modelParams[(std::size_t) (head + k)], 0.0f, 1.0f));
+        firstKey.store ((int) c.modelParams[2]);
+        sensitivity = c.modelParams[1];
+    }
+
+    // (the rack slices the sample once it is decoded: not on the audio thread)
+    void settleNew() override
+    {
+        if (sample == nullptr)
+            return;
+        starts.clear();
+        for (const auto s : flmslicer::slices (*sample, sensitivity))
+            starts.push_back ((double) s);
+    }
+
+    void setChannelPitchNow (float knob, float rest) noexcept override { liveCents = knob + rest; }
+    void setNextNoteExpression (float pan, float, bool) noexcept override { nextPan = pan; }
+    void setParameter (int index, float v) noexcept override
+    {
+        const auto k = index - automationBase;
+        if (k >= 0 && k < paramCount && std::isfinite (v))
+            values[(std::size_t) k].store (std::clamp (v, 0.0f, 1.0f));
+    }
+
+    void noteOn (int key, float velocity) noexcept override
+    {
+        const auto pan = std::clamp (nextPan, -1.0f, 1.0f);
+        nextPan = 0.0f;
+        if (P (0) < 0.5f || sample == nullptr || starts.empty())
+            return;
+        if (P (6) != 0.0f) // MONO: every sounding voice fades out at 0.01
+            for (auto& v : voices)
+                if (v.active)
+                    fade (v);
+        const auto index = key - firstKey.load();
+        if (index < 0 || index >= (int) starts.size())
+            return;
+        const auto frames = (double) sample->left.size();
+        const auto mode = std::clamp ((int) (P (5) * 2.0f), 0, 2);
+        for (auto& v : voices)
+            if (! v.active)
+            {
+                v = Voice {};
+                v.active = true;
+                v.key = key;
+                v.pos = starts[(std::size_t) index];
+                v.sliceEnd = index + 1 < (int) starts.size() ? starts[(std::size_t) index + 1] : frames;
+                v.end = mode == 0 ? v.sliceEnd : frames;
+                v.level = 0.0, v.target = 5.0;
+                v.rate = flmpad::rateAt (flmpad::attackRate (P (3)), fs);
+                const auto vel = std::clamp (velocity, 0.0f, 1.0f);
+                v.gainL = pan > 0.0f ? vel * (1.0f - pan) : vel;
+                v.gainR = pan < 0.0f ? vel * (1.0f + pan) : vel;
+                break;
+            }
+    }
+
+    void noteOff (int key) noexcept override
+    {
+        if (std::clamp ((int) (P (5) * 2.0f), 0, 2) != 1) // (only "to the end while held" ends at the note's end)
+            return;
+        for (auto& v : voices)
+            if (v.active && v.key == key)
+                fade (v);
+    }
+    void allNotesOff() noexcept override
+    {
+        for (auto& v : voices)
+            if (v.active)
+                fade (v);
+    }
+    void panic() noexcept override
+    {
+        for (auto& v : voices)
+            v = Voice {};
+    }
+    bool idle() const noexcept override
+    {
+        return std::none_of (voices.begin(), voices.end(), [] (const Voice& v) { return v.active; });
+    }
+
+    void render (float* left, float* right, int n, float gainLeft, float gainRight) noexcept override
+    {
+        if (sample == nullptr || P (0) < 0.5f)
+            return;
+        const auto& L = sample->left;
+        const auto& R = sample->right.empty() ? sample->left : sample->right;
+        const auto len = (std::int64_t) L.size();
+        const auto semis = (double) flmpad::speedSemitones (P (1)) + (std::isnan (liveCents) ? knobCents.load() : liveCents) * 0.01;
+        const auto speed = std::exp2 (semis / 12.0) * sample->sampleRate / fs;
+        const auto decay = P (4) > 0.99f ? 0.0 : flmpad::rateAt (flmpad::decayRate (P (4)), fs);
+        for (auto& v : voices)
+        {
+            if (! v.active)
+                continue;
+            for (int i = 0; i < n; ++i)
+            {
+                v.level += (v.target - v.level) * v.rate;
+                if (! v.decaying && v.level > 1.0)
+                    v.level = 1.0, v.target = 0.0, v.rate = decay, v.decaying = true;
+                const auto idx = (std::int64_t) std::floor (v.pos);
+                const auto f = v.pos - (double) idx;
+                double xl = 0.0, xr = 0.0;
+                if (idx >= 0 && idx < len)
+                {
+                    xl = (double) L[(std::size_t) idx] * (1.0 - f);
+                    xr = (double) R[(std::size_t) idx] * (1.0 - f);
+                    if (idx + 1 < len)
+                        xl += (double) L[(std::size_t) idx + 1] * f, xr += (double) R[(std::size_t) idx + 1] * f;
+                }
+                if (const auto toEnd = v.sliceEnd - v.pos; toEnd > 0.0 && toEnd < 512.0)
+                    xl *= toEnd / 512.0, xr *= toEnd / 512.0;
+                left[i] += (float) (xl * v.level * v.gainL) * gainLeft;
+                right[i] += (float) (xr * v.level * v.gainR) * gainRight;
+                v.pos += speed;
+                if (! v.ending && (v.pos >= v.end || v.pos >= (double) len))
+                    fade (v);
+                if (v.level < 0.001 && v.target < 0.001)
+                {
+                    v.active = false;
+                    break;
+                }
+            }
+        }
+    }
+
+private:
+    float P (int k) const noexcept { return values[(std::size_t) k].load (std::memory_order_relaxed); }
+    void fade (Voice& v) noexcept
+    {
+        v.target = 0.0, v.rate = flmpad::rateAt (0.01f, fs), v.ending = true, v.decaying = true;
+    }
+
+    std::shared_ptr<const SampleData> sample;
+    std::vector<double> starts;
+    float sensitivity = 0.25f;
+    std::array<std::atomic<float>, paramCount> values {};
+    std::atomic<int> firstKey { 60 };
+    std::atomic<float> knobCents { 0.0f };
+    float liveCents = std::numeric_limits<float>::quiet_NaN(), nextPan = 0.0f;
+    double fs = 44100.0;
+    std::array<Voice, voiceCount> voices {};
+};
+} // namespace
+
+std::unique_ptr<Instrument> makeInstrument (std::shared_ptr<const SampleData> sample)
+{
+    return std::make_unique<SlicerInstrument> (std::move (sample));
+}
+} // namespace lynx::flmslicer

+ 42 - 0
src/core/FlmSlicer.h

@@ -0,0 +1,42 @@
+#pragma once
+
+// FL Studio Mobile's "Slicer" module (type 33) as LYNX plays an imported .flm (round 190de). Clean-room: written from
+// the behaviour described in docs/analise/FLM_FORMAT.md §7.7 (static analysis of FLM's FL plugin, laws in LYNX's own
+// words); no Image-Line code, table or sample is used.
+//
+// One sample cut into slices where FLM's onset detector finds hits (or at the file's markers with sensitivity 0);
+// slice i plays on key firstKey + i, every note its own voice (no limit), FLM's drum-pad envelope laws, whole-semitone
+// transposition, linear interpolation, a linear balance and velocity, and an optional choke (MONO).
+//
+// In LYNX the channel is a Sampler channel with the sample and ChannelDef::modelParams = { marker, sensitivity, first
+// key, the module's 7 values }; the rack slices the decoded sample and plays the engine below on it.
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "core/Song.h"
+
+namespace lynx
+{
+class Instrument;
+struct SampleData;
+
+namespace flmslicer
+{
+constexpr float marker = 1902.0f;
+constexpr int paramCount = 7; // 0 Enable, 1 PITCH, 2 (unused), 3 ATTACK, 4 DECAY, 5 SUST, 6 MONO
+constexpr int head = 3;       // marker, sensitivity, first key
+constexpr int automationBase = 0x2400; // automation of value k: channelParam automationBase + k (as the DW Sampler's)
+extern const float defaults[paramCount];
+
+bool isChannel (const ChannelDef& c) noexcept;
+std::vector<float> channelParams (const std::vector<float>& values, float sensitivity, int firstKey);
+
+// The slice starts (frames) FLM's detector finds in a sample at `sensitivity` (> 0), at most 128; the file's markers
+// (or one slice at 0) at sensitivity 0
+std::vector<std::int64_t> slices (const SampleData& sample, float sensitivity);
+
+std::unique_ptr<Instrument> makeInstrument (std::shared_ptr<const SampleData> sample);
+} // namespace flmslicer
+} // namespace lynx

+ 3 - 2
src/core/Instruments.cpp

@@ -1941,8 +1941,9 @@ public:
         target->stage = attackSeconds > 0.0f ? 0 : 1;
         target->stage = attackSeconds > 0.0f ? 0 : 1;
 
 
         // FL Studio Mobile's pad (core/FlmPad.h): the level starts at 0 and takes its first step before the first
         // FL Studio Mobile's pad (core/FlmPad.h): the level starts at 0 and takes its first step before the first
-        // sample, as FLM's voice does; Sample Start moves the read position (seconds of the file) or delays the voice
-        target->padEnv = ! clipMode && padOn.load (std::memory_order_relaxed);
+        // sample, as FLM's voice does; Sample Start moves the read position (seconds of the file) or delays the voice.
+        // An imported FLM audio clip plays the same slot voice (round 190de): its clip channel may carry the envelope too
+        target->padEnv = padOn.load (std::memory_order_relaxed);
         target->padDelay = 0;
         target->padDelay = 0;
         if (target->padEnv)
         if (target->padEnv)
         {
         {

+ 34 - 1
src/core/RackRenderer.cpp

@@ -8,6 +8,8 @@
 #include "core/SlicexInstrument.h"
 #include "core/SlicexInstrument.h"
 #include "core/TempoMap.h"
 #include "core/TempoMap.h"
 #include "core/ModelParams.h"
 #include "core/ModelParams.h"
+#include "core/FlmDwSampler.h"
+#include "core/FlmSlicer.h"
 #include "core/SamplePrecompute.h"
 #include "core/SamplePrecompute.h"
 #include "core/TimeStretch.h"
 #include "core/TimeStretch.h"
 #include "core/MetronomeVoice.h"
 #include "core/MetronomeVoice.h"
@@ -265,6 +267,28 @@ std::shared_ptr<Instrument> buildInstrument (const ChannelDef& channel, double s
         return instrument;
         return instrument;
     }
     }
 
 
+    // FL Studio Mobile's Slicer (round 190de, core/FlmSlicer.h): FLM's slices of the decoded sample, FLM's voice
+    if (kind == InstrumentKind::sampler && flmslicer::isChannel (channel))
+    {
+        std::shared_ptr<Instrument> instrument = flmslicer::makeInstrument (samples && ! channel.samplePath.empty() ? samples (channel.samplePath) : nullptr);
+        instrument->prepare (sampleRate);
+        instrument->configure (channel, bpm);
+        instrument->settleNew();
+        return instrument;
+    }
+
+    // FL Studio Mobile's DW Sampler (round 190de, core/FlmDwSampler.h): FLM's own voice on the channel's zones
+    if (kind == InstrumentKind::sampler && flmdw::isChannel (channel))
+    {
+        std::vector<flmdw::EngineZone> zones;
+        for (const auto& z : channel.zones)
+            zones.push_back ({ z, true, samples && ! z.path.empty() ? samples (z.path) : nullptr });
+        std::shared_ptr<Instrument> instrument = flmdw::makeInstrument (std::move (zones));
+        instrument->prepare (sampleRate);
+        instrument->configure (channel, bpm);
+        return instrument;
+    }
+
     // multi-sample sampler: one zone per sample (DirectWave, FPC layers...)
     // multi-sample sampler: one zone per sample (DirectWave, FPC layers...)
     if (kind == InstrumentKind::sampler && ! channel.zones.empty())
     if (kind == InstrumentKind::sampler && ! channel.zones.empty())
     {
     {
@@ -1698,7 +1722,16 @@ void RackState::buildAutomationTables()
                                   || (song.channels[(std::size_t) t.index].instrument == InstrumentKind::sampler && t.param >= 0
                                   || (song.channels[(std::size_t) t.index].instrument == InstrumentKind::sampler && t.param >= 0
                                       && t.param < samplerparam::count)
                                       && t.param < samplerparam::count)
                                   // the knobs of an FL engine kept in the channel's state (round 168n)
                                   // the knobs of an FL engine kept in the channel's state (round 168n)
-                                  || modelparams::find (song.channels[(std::size_t) t.index].instrument, t.param) != nullptr))
+                                  || modelparams::find (song.channels[(std::size_t) t.index].instrument, t.param) != nullptr
+                                  // FL Studio Mobile's DW Sampler: its own 34 values (round 190de)
+                                  || (flmdw::isChannel (song.channels[(std::size_t) t.index]) && t.param >= flmdw::automationBase
+                                      && t.param < flmdw::automationBase + flmdw::paramCount)
+                                  || (flmslicer::isChannel (song.channels[(std::size_t) t.index]) && t.param >= flmslicer::automationBase
+                                      && t.param < flmslicer::automationBase + flmslicer::paramCount)
+                                  // FL Studio Mobile's GMSynth: its own 75 values P[k] (an imported .flm's lanes, round 190de)
+                                  || (song.channels[(std::size_t) t.index].instrument == InstrumentKind::gms
+                                      && song.channels[(std::size_t) t.index].modelParams.size() == 1
+                                      && song.channels[(std::size_t) t.index].modelParams[0] == 1.0f && t.param >= 0 && t.param < 75)))
                     pluginParams.push_back ({ a, t.index, 0, 0, t.param });
                     pluginParams.push_back ({ a, t.index, 0, 0, t.param });
                 else
                 else
                     used = false;
                     used = false;

+ 6 - 1
src/ui/ChannelSettings.cpp

@@ -3,6 +3,7 @@
 #include "core/NoteNames.h"
 #include "core/NoteNames.h"
 #include "ui/ChannelSettings.h"
 #include "ui/ChannelSettings.h"
 #include "core/FlControlMenus.h"
 #include "core/FlControlMenus.h"
+#include "core/FlmDwSampler.h"
 #include "ui/FileChoosers.h"
 #include "ui/FileChoosers.h"
 #include "ui/Icons.h"
 #include "ui/Icons.h"
 #include "ui/LayerEditor.h"
 #include "ui/LayerEditor.h"
@@ -3480,6 +3481,7 @@ private:
         for (const auto& [slider, param] : tweakTargets)
         for (const auto& [slider, param] : tweakTargets)
             if (slider != changed && std::find (automatedShown.begin(), automatedShown.end(), slider) != automatedShown.end())
             if (slider != changed && std::find (automatedShown.begin(), automatedShown.end(), slider) != automatedShown.end())
                 keepSongValue (s, current()->sampler, param);
                 keepSongValue (s, current()->sampler, param);
+        bool dropFlmVoice = false;
         {
         {
             // an ADSR edited by hand replaces FL's imported volume envelope
             // an ADSR edited by hand replaces FL's imported volume envelope
             const auto& old = current()->sampler;
             const auto& old = current()->sampler;
@@ -3489,6 +3491,7 @@ private:
             {
             {
                 s.flVolumeEnvelope.clear();
                 s.flVolumeEnvelope.clear();
                 s.flmPad.clear(); // and FL Studio Mobile's pad envelope (round 190bs)
                 s.flmPad.clear(); // and FL Studio Mobile's pad envelope (round 190bs)
+                dropFlmVoice = flmdw::isChannel (*current()); // and FL Studio Mobile's DW Sampler voice (round 190de)
             }
             }
             // so does an edited envelope or filter for FL's whole sampler voice (REA_rodada76)
             // so does an edited envelope or filter for FL's whole sampler voice (REA_rodada76)
             if (adsr || moved (s.cutoff, old.cutoff) || moved (s.resonance, old.resonance) || s.filterType != old.filterType)
             if (adsr || moved (s.cutoff, old.cutoff) || moved (s.resonance, old.resonance) || s.filterType != old.filterType)
@@ -3498,8 +3501,10 @@ private:
             return;
             return;
 
 
         const auto before = current()->sampler;
         const auto before = current()->sampler;
-        ref.edit (engine, [s, cutChanged, index = ref.index] (ChannelDef& channelDef) {
+        ref.edit (engine, [s, cutChanged, dropFlmVoice, index = ref.index] (ChannelDef& channelDef) {
             channelDef.sampler = s;
             channelDef.sampler = s;
+            if (dropFlmVoice) // (the Sampler's own voice from now on: the module's values go, its zones stay)
+                channelDef.modelParams.clear();
             if (cutChanged)
             if (cutChanged)
                 setChannelCutsItself (channelDef, index, s.cut);
                 setChannelCutsItself (channelDef, index, s.cut);
         });
         });

+ 7 - 5
tests/FlmImport182cTests.inc

@@ -2,6 +2,7 @@
 // tests, field by field as the format page describes them; no file of Image-Line's or of a user is committed. Real
 // tests, field by field as the format page describes them; no file of Image-Line's or of a user is committed. Real
 // projects (FL's FLM demos, a user's share-zip) are imported only by the opt-in test at the end (LYNX_FLM_DIR).
 // projects (FL's FLM demos, a user's share-zip) are imported only by the opt-in test at the end (LYNX_FLM_DIR).
 
 
+#include "core/FlmDwSampler.h"
 #include "core/FlmFormat.h"
 #include "core/FlmFormat.h"
 #include "core/FlmImport.h"
 #include "core/FlmImport.h"
 #include "core/MiniSynth.h"
 #include "core/MiniSynth.h"
@@ -483,7 +484,7 @@ TEST (flm182c_imports_a_project)
         const auto clip = std::find_if (s.playlist.begin(), s.playlist.end(), [] (const Clip& c) { return c.kind == ClipKind::automation; });
         const auto clip = std::find_if (s.playlist.begin(), s.playlist.end(), [] (const Clip& c) { return c.kind == ClipKind::automation; });
         CHECK (clip != s.playlist.end() && clip->start == 8 * ppq && clip->length == 16 * ppq && clip->automation == 0);
         CHECK (clip != s.playlist.end() && clip->start == 8 * ppq && clip->length == 16 * ppq && clip->automation == 0);
     }
     }
-    CHECK (report.converted.count ("FL Studio Mobile: DW Sampler (one sample)") == 1);
+    CHECK (report.converted.count ("FL Studio Mobile: DW Sampler (FLM's engine)") == 1); // (round 190de: FLM's own voice)
 
 
     // patterns: 808 content 1 and 2, the drum pattern, the lead's
     // patterns: 808 content 1 and 2, the drum pattern, the lead's
     CHECK (s.patterns.size() == 4);
     CHECK (s.patterns.size() == 4);
@@ -600,7 +601,7 @@ TEST (flm182c_real_projects)
         for (const auto& c : song->channels)
         for (const auto& c : song->channels)
         {
         {
             samplers += c.instrument == InstrumentKind::sampler && ! c.samplePath.empty();
             samplers += c.instrument == InstrumentKind::sampler && ! c.samplePath.empty();
-            directWaves += c.instrument == InstrumentKind::directwave;
+            directWaves += c.instrument == InstrumentKind::directwave || flmdw::isChannel (c);
         }
         }
         std::printf ("  %s: %.1f ms, bpm %.3f %d/4, %zu inserts, %zu channels (%d samplers with a sample, %d DirectWave), %zu patterns (%d notes), "
         std::printf ("  %s: %.1f ms, bpm %.3f %d/4, %zu inserts, %zu channels (%d samplers with a sample, %d DirectWave), %zu patterns (%d notes), "
                      "%zu clips (%d audio), end %.3f beats, %d samples missing, %zu dropped effects, %zu unsupported\n",
                      "%zu clips (%d audio), end %.3f beats, %d samples missing, %zu dropped effects, %zu unsupported\n",
@@ -611,7 +612,8 @@ TEST (flm182c_real_projects)
 }
 }
 
 
 // Opt-in (LYNX_FLM_RESOURCES = FL's "…/FL Studio Mobile/Installed"): a DW Sampler playing one of the DirectWave programs
 // Opt-in (LYNX_FLM_RESOURCES = FL's "…/FL Studio Mobile/Installed"): a DW Sampler playing one of the DirectWave programs
-// FL ships there becomes LYNX's DirectWave with the program's zones (slice F3)
+// FL ships there plays the program's zones (slice F3; since round 190de on FLM's own DW Sampler voice, which reads the
+// program itself, core/FlmDwSampler.h)
 TEST (flm182c_directwave_program)
 TEST (flm182c_directwave_program)
 {
 {
     using namespace lynx;
     using namespace lynx;
@@ -637,8 +639,8 @@ TEST (flm182c_directwave_program)
     o.resourceRoot = resources;
     o.resourceRoot = resources;
     const auto song = importFlm (bytes, o);
     const auto song = importFlm (bytes, o);
     const auto* keys = song ? t::channelNamed (*song, "Keys") : nullptr;
     const auto* keys = song ? t::channelNamed (*song, "Keys") : nullptr;
-    CHECK (keys != nullptr && keys->instrument == InstrumentKind::directwave && keys->zones.size() > 1);
-    CHECK (report.converted.count ("FL Studio Mobile: DW Sampler (DirectWave program)") == 1 && report.missingSamples == 0);
+    CHECK (keys != nullptr && keys->instrument == InstrumentKind::sampler && flmdw::isChannel (*keys) && keys->zones.size() > 1);
+    CHECK (report.converted.count ("FL Studio Mobile: DW Sampler (multisample, FLM's engine)") == 1 && report.missingSamples == 0);
     if (keys != nullptr)
     if (keys != nullptr)
         std::printf ("  Electric.dwp: %zu zones, first %s\n", keys->zones.size(), keys->zones.empty() ? "-" : keys->zones[0].path.c_str());
         std::printf ("  Electric.dwp: %zu zones, first %s\n", keys->zones.size(), keys->zones.empty() ? "-" : keys->zones[0].path.c_str());
 }
 }

+ 9 - 5
tests/FlmImport187dTests.inc

@@ -134,10 +134,12 @@ TEST (flm187d_mixer_and_rack_automation)
     // F2: Keys is muted and soloed, panned left (0.25 → −0.5); the master's Mute is the Master's
     // F2: Keys is muted and soloed, panned left (0.25 → −0.5); the master's Mute is the Master's
     CHECK (s.mixer[1].name == "Keys" && s.mixer[1].muted && s.mixer[1].solo && std::abs (s.mixer[1].pan + 0.5f) < 1e-6f);
     CHECK (s.mixer[1].name == "Keys" && s.mixer[1].muted && s.mixer[1].solo && std::abs (s.mixer[1].pan + 0.5f) < 1e-6f);
     CHECK (s.mixer[0].muted && ! s.mixer[0].solo && ! s.mixer[2].muted && ! s.mixer[2].solo);
     CHECK (s.mixer[0].muted && ! s.mixer[0].solo && ! s.mixer[2].muted && ! s.mixer[2].solo);
-    // the held pitch bend (0.6875 → 2^(4·0.6875 − 2) = +9 semitones) on the sampler's pitch; aftertouch reported
+    // the held pitch bend 0.6875 on the channel's pitch: the rack hands 4v − 2 = 0.75 to the DW Sampler, which bends by
+    // half of it × its PB Range (4 without a MIDI chunk) = +1.5 semitones (round 190de; until then +9, the drum slots'
+    // 2^(4v − 2)); aftertouch reported
     const auto* keys = flm182c::channelNamed (s, "Keys");
     const auto* keys = flm182c::channelNamed (s, "Keys");
-    CHECK (keys != nullptr && keys->instrument == InstrumentKind::sampler && std::abs (keys->sampler.pitch - 9.0f) < 1e-4f);
-    CHECK (report.converted.count ("FL Studio Mobile: channel pitch bend (on the sampler's pitch)") == 1
+    CHECK (keys != nullptr && keys->instrument == InstrumentKind::sampler && std::abs (keys->sampler.pitch - 1.5f) < 1e-4f);
+    CHECK (report.converted.count ("FL Studio Mobile: channel pitch bend (on the channel's pitch)") == 1
            && report.partialEffects.count ("FL Studio Mobile: channel aftertouch (not imported)") == 1);
            && report.partialEffects.count ("FL Studio Mobile: channel aftertouch (not imported)") == 1);
     // Vocal → Master and the bus at FLM's send levels
     // Vocal → Master and the bus at FLM's send levels
     CHECK (s.mixer[2].toMaster && s.mixer[2].sends.size() == 1 && s.mixer[2].sends[0].target == 3);
     CHECK (s.mixer[2].toMaster && s.mixer[2].sends.size() == 1 && s.mixer[2].sends[0].target == 3);
@@ -154,7 +156,8 @@ TEST (flm187d_mixer_and_rack_automation)
         if (t.kind == AutomationTargetKind::mixerSend && t.index == 2 && t.slot == 0)
         if (t.kind == AutomationTargetKind::mixerSend && t.index == 2 && t.slot == 0)
             toMaster = (int) i;
             toMaster = (int) i;
     }
     }
-    CHECK (s.automations.size() == 3 && pan >= 0 && toBus >= 0 && toMaster >= 0);
+    // (round 190de: the DW Sampler's Pitch lane is imported too, on its own value: a fourth)
+    CHECK (s.automations.size() == 4 && pan >= 0 && toBus >= 0 && toMaster >= 0);
     if (pan >= 0)
     if (pan >= 0)
     {
     {
         // every saved point kept, the jump at beat 2 as two points on one tick
         // every saved point kept, the jump at beat 2 as two points on one tick
@@ -175,7 +178,8 @@ TEST (flm187d_mixer_and_rack_automation)
     CHECK (report.converted.count ("FL Studio Mobile: Pan automation") == 1 && report.converted.count ("FL Studio Mobile: send level automation") == 1
     CHECK (report.converted.count ("FL Studio Mobile: Pan automation") == 1 && report.converted.count ("FL Studio Mobile: send level automation") == 1
            && report.converted.at ("FL Studio Mobile: send level automation") == 2);
            && report.converted.at ("FL Studio Mobile: send level automation") == 2);
     CHECK (report.unsupported.count ("FL Studio Mobile: Mute/Solo automation (LYNX automates neither)") == 1
     CHECK (report.unsupported.count ("FL Studio Mobile: Mute/Solo automation (LYNX automates neither)") == 1
-           && report.unsupported.count ("FL Studio Mobile: automation of module parameters (not imported yet)") == 1
+           && report.unsupported.count ("FL Studio Mobile: automation of module parameters (not imported yet)") == 0
+           && report.converted.count ("FL Studio Mobile: instrument parameter automation") == 1
            && report.unsupported.count ("FL Studio Mobile: send level automation without that route") == 1
            && report.unsupported.count ("FL Studio Mobile: send level automation without that route") == 1
            && report.unsupported.count ("FL Studio Mobile: MIDI CC automation (not imported)") == 1);
            && report.unsupported.count ("FL Studio Mobile: MIDI CC automation (not imported)") == 1);
     // the point shapes are FLM's saved samples, so no "straight lines" approximation is reported any more
     // the point shapes are FLM's saved samples, so no "straight lines" approximation is reported any more

+ 6 - 3
tests/FlmImport190bsTests.inc

@@ -600,7 +600,10 @@ TEST (flm190bs_note_effects_and_key_ranges_on_import)
         // an effect, the instrument (keys 36…96), then the note effects: they still run before the instrument
         // an effect, the instrument (keys 36…96), then the note effects: they still run before the instrument
         t::rack (flm::kindNormal, { flm182c::module (7, 5), t::moduleOf (1, 2, {}, 36, 96, {}, "/storage/emulated/0/Android/data/com.imageline.FLM/files/My Samples/808.wav"),
         t::rack (flm::kindNormal, { flm182c::module (7, 5), t::moduleOf (1, 2, {}, 36, 96, {}, "/storage/emulated/0/Android/data/com.imageline.FLM/files/My Samples/808.wav"),
                                     t::moduleOf (48, 3, { 1.0f, 0.625f, 0.5f }), t::moduleOf (50, 4, scale),
                                     t::moduleOf (48, 3, { 1.0f, 0.625f, 0.5f }), t::moduleOf (50, 4, scale),
-                                    t::moduleOf (51, 6, std::vector<float> (31, 1.0f)), t::moduleOf (47, 7, std::vector<float> (16, 0.0f)) }),
+                                    // (round 190de: the Arpeggiator switched off — an active one now bakes the rack's notes, see
+                                    // FlmImport190deTests.inc)
+                                    t::moduleOf (51, 6, [] { std::vector<float> v (31, 1.0f); v[0] = 0.0f; return v; }()),
+                                    t::moduleOf (47, 7, std::vector<float> (16, 0.0f)) }),
         t::rack (flm::kindNormal, {}, { t::sampleOf ({ "Kick", {} }) }),
         t::rack (flm::kindNormal, {}, { t::sampleOf ({ "Kick", {} }) }),
         t::channel (flm::kindMaster, "MASTER", 0, {}),
         t::channel (flm::kindMaster, "MASTER", 0, {}),
         t::channel (flm::kindNormal, "Keys", 1, { t::lane (0, "Keys", { t::clip (0, 4, 4, 0, 1, notes) }) }),
         t::channel (flm::kindNormal, "Keys", 1, { t::lane (0, "Keys", { t::clip (0, 4, 4, 0, 1, notes) }) }),
@@ -624,8 +627,8 @@ TEST (flm190bs_note_effects_and_key_ranges_on_import)
     CHECK (report.converted.count ("FL Studio Mobile: Transpose (note effect)") == 1 && report.converted.count ("FL Studio Mobile: Scale (note effect)") == 1);
     CHECK (report.converted.count ("FL Studio Mobile: Transpose (note effect)") == 1 && report.converted.count ("FL Studio Mobile: Scale (note effect)") == 1);
     CHECK (report.converted["FL Studio Mobile: notes a note effect holds back (silent in FLM too)"] == 1
     CHECK (report.converted["FL Studio Mobile: notes a note effect holds back (silent in FLM too)"] == 1
            && report.converted["FL Studio Mobile: notes outside the instrument's key range (silent in FLM too)"] == 1);
            && report.converted["FL Studio Mobile: notes outside the instrument's key range (silent in FLM too)"] == 1);
-    // the Arpeggiator (on) is listed; the Note Echo is switched off: nothing to say
-    CHECK (report.droppedEffects.count ("FL Studio Mobile: Arpeggiator (note effect, not converted)") == 1
+    // the Arpeggiator and the Note Echo are switched off: nothing to say (round 190de: both are converted when on)
+    CHECK (report.droppedEffects.count ("FL Studio Mobile: Arpeggiator (note effect, not converted)") == 0
            && report.droppedEffects.count ("FL Studio Mobile: Note Echo (note effect, not converted)") == 0
            && report.droppedEffects.count ("FL Studio Mobile: Note Echo (note effect, not converted)") == 0
            && report.droppedEffects.count ("FL Studio Mobile: Transpose") == 0 && report.droppedEffects.count ("FL Studio Mobile: Scale") == 0);
            && report.droppedEffects.count ("FL Studio Mobile: Transpose") == 0 && report.droppedEffects.count ("FL Studio Mobile: Scale") == 0);
     CHECK (report.partialEffects.count ("FL Studio Mobile: an instrument placed after an effect in its rack (the effect processes it too)") == 1);
     CHECK (report.partialEffects.count ("FL Studio Mobile: an instrument placed after an effect in its rack (the effect processes it too)") == 1);

+ 727 - 0
tests/FlmImport190deTests.inc

@@ -0,0 +1,727 @@
+// --- FL Studio Mobile (.flm) import, round 190de: the module wrapper on instruments, automation of instrument
+// parameters and of the rack's Pitch Bend, a kit sample's stretch and pitch, an audio clip's envelope and Sample Start
+// (docs/analise/FLM_FORMAT.md §6, §6.1, §7.4). Every project is written by the tests; no file of Image-Line's is
+// committed.
+
+#include "core/MidiControls.h"
+#include "core/ModelParams.h"
+
+namespace flm190de
+{
+using namespace flm182c;
+using Bytes = flm182c::Bytes;
+
+// a module with its own parameter values and its wrapper values (SMPR: Post Gain, Mix, Wet Pan)
+inline Bytes moduleWith (std::uint32_t type, std::uint32_t id, const std::vector<float>& params, const std::vector<float>& smpr = {},
+                         const Bytes& custom = {}, const std::string& presetFile = {}, int keyLow = 0, int keyHigh = 127)
+{
+    Bytes b;
+    u32 (b, type);
+    u32 (b, id);
+    Bytes h;
+    u32 (h, type);
+    u32 (h, 0);
+    u8 (h, 1);
+    Bytes add1 { 0, (std::uint8_t) keyLow, (std::uint8_t) keyHigh };
+    Bytes desc;
+    fixed (desc, "Default", 256);
+    fixed (desc, "", 256);
+    Bytes prst;
+    lp32 (prst, presetFile);
+    lp32 (prst, "Default/Default");
+    Bytes prms;
+    for (const auto v : params)
+        f32 (prms, v);
+    auto body = cat ({ b, chunk ("HEAD", h), chunk ("DESC", desc), chunk ("PRST", prst), chunk ("ADD1", add1), chunk ("PRMS", prms) });
+    if (! smpr.empty())
+    {
+        Bytes s;
+        for (const auto v : smpr)
+            f32 (s, v);
+        const auto c = chunk ("SMPR", s);
+        put (body, c.data(), c.size());
+    }
+    if (! custom.empty())
+    {
+        const auto c = chunk ("CSTM", custom);
+        put (body, c.data(), c.size());
+    }
+    return chunk ("RMOd", body);
+}
+
+inline std::vector<float> superSawDefaults()
+{
+    std::vector<float> p (60, 0.5f);
+    p[0] = 1.0f;
+    return p;
+}
+
+inline const lynx::Automation* automationOf (const lynx::Song& s, lynx::AutomationTargetKind kind, int index, int param = -1)
+{
+    for (const auto& a : s.automations)
+        if (a.target.kind == kind && a.target.index == index && (param < 0 || a.target.param == param))
+            return &a;
+    return nullptr;
+}
+} // namespace flm190de
+
+TEST (flm190de_instrument_wrapper_and_parameter_lanes)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    namespace rp = flm::rackparam;
+    auto off = t::superSawDefaults();
+    off[0] = 0.0f;
+    // rack 1: a SuperSaw switched off; rack 2: a SuperSaw at Post Gain 0.35 (−6 dB) and Wet Pan 0.75, its Filter Cutoff
+    // (19) and Enable (0) automated; rack 3: two SuperSaws (a Layer) whose Pitch Bend is automated
+    const auto bytes = flm190bs::song ({
+        t::rack (flm::kindMaster, {}),
+        t::rack (flm::kindNormal, { t::moduleWith (23, 2, off) }),
+        t::rack (flm::kindNormal, { t::moduleWith (23, 2, t::superSawDefaults(), { 0.35f, 1.0f, 0.75f }) }),
+        t::rack (flm::kindNormal, { t::moduleWith (23, 2, t::superSawDefaults()), t::moduleWith (23, 3, t::superSawDefaults()) }),
+        t::channel (flm::kindMaster, "MASTER", 0, {}),
+        t::channel (flm::kindNormal, "Off", 1, { t::lane (0, "Off", { t::clip (0, 4, 4, 0, 1, { { 0, 1, 60 } }) }) }),
+        t::channel (flm::kindNormal, "Saw", 2, { t::lane (0, "Saw", { t::clip (0, 4, 4, 0, 1, { { 0, 1, 60 } }) }),
+                                                 t::lane (1, "Filter Cutoff : SuperSaw", { flm187d::autoClip (0, 4, 4, 1, { { 0, 1, 0 }, { 2, -1, 32768 }, { 4, 1, 65535 } }) }, 2, 19),
+                                                 t::lane (1, "Enable : SuperSaw", { flm187d::autoClip (4, 4, 4, 2, { { 0, 1, 0 }, { 2, 1, 65535 } }) }, 2, 0) }),
+        t::channel (flm::kindNormal, "Pair", 3, { t::lane (0, "Pair", { t::clip (0, 4, 4, 0, 1, { { 0, 1, 60 } }) }),
+                                                  t::lane (1, "Pitch Bend", { flm187d::autoClip (0, 4, 4, 1, { { 0, 1, 32768 }, { 2, 1, 49151 } }) }, 0, rp::pitchBend),
+                                                  t::lane (1, "Aftertouch", { flm187d::autoClip (0, 4, 4, 1, { { 0, 1, 0 } }) }, 0, rp::aftertouch) }) });
+    FlpImportReport report;
+    const auto s = importFlm (bytes, flm190bs::anyFile (&report));
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const auto index = [&] (const std::string& n) {
+        for (std::size_t i = 0; i < s->channels.size(); ++i)
+            if (s->channels[i].name == n)
+                return (int) i;
+        return -1;
+    };
+    const auto offAt = index ("Off"), sawAt = index ("Saw"), pairAt = index ("Pair");
+    CHECK (offAt >= 0 && sawAt >= 0 && pairAt >= 0);
+    if (offAt < 0 || sawAt < 0 || pairAt < 0)
+        return;
+    const auto& offC = s->channels[(std::size_t) offAt];
+    const auto& saw = s->channels[(std::size_t) sawAt];
+    // the wrapper: Enable off = not rendered (muted); Post Gain × Mix on the level, Wet Pan on the pan
+    CHECK (offC.instrument == InstrumentKind::pocketSuperSaw && offC.muted);
+    CHECK (saw.instrument == InstrumentKind::pocketSuperSaw && ! saw.muted); // (its Enable is automated: the lane drives it)
+    CHECK (std::abs (channelGain (saw.volume) - (float) std::pow (10.0, 2.0 * 0.35 - 1.0)) < 1e-4f && std::abs (saw.pan - 0.5f) < 1e-6f);
+    // Filter Cutoff (FLM 19) = Pocket SuperSaw's value 18, FLM's own 0…1 through the engine's range
+    const auto* p = modelparams::find (InstrumentKind::pocketSuperSaw, 18);
+    const auto* cutoff = t::automationOf (*s, AutomationTargetKind::channelParam, sawAt, 18);
+    CHECK (p != nullptr && cutoff != nullptr && cutoff->points.size() == 3);
+    if (p != nullptr && cutoff != nullptr && cutoff->points.size() == 3)
+        CHECK (std::abs (cutoff->points[0].value - p->normalised (0.0f)) < 1e-6f && std::abs (cutoff->points[1].value - p->normalised (32768.0f / 65535.0f)) < 1e-6f
+               && cutoff->points[1].tick == 2 * ppq && std::abs (cutoff->points[2].value - p->normalised (1.0f)) < 1e-6f);
+    // Enable: the channel's volume, silent below 0.5, the channel's own volume above
+    const auto* enable = t::automationOf (*s, AutomationTargetKind::channelVolume, sawAt);
+    CHECK (enable != nullptr && enable->points.size() == 2);
+    if (enable != nullptr && enable->points.size() == 2)
+        CHECK (enable->points[0].value == 0.0f && enable->points[1].value == saw.volume);
+    bool enableClip = false;
+    for (const auto& c : s->playlist)
+        enableClip = enableClip || (c.kind == ClipKind::automation && c.start == 4 * ppq && s->automations[(std::size_t) c.automation].target.kind == AutomationTargetKind::channelVolume);
+    CHECK (enableClip);
+    // Pitch Bend: on both children of the Layer, LYNX's bend value as it is; the bend range is SuperSaw's own,
+    // int(11·P37 + 1) = 6 semitones at 0.5
+    const auto& layer = s->channels[(std::size_t) pairAt];
+    CHECK (layer.instrument == InstrumentKind::layer && layer.layer.children.size() == 2);
+    for (const auto child : layer.layer.children)
+    {
+        const auto* b = t::automationOf (*s, AutomationTargetKind::channelParam, child, midictl::pitchBendBase);
+        CHECK (b != nullptr && s->channels[(std::size_t) child].misc.pitchRange == 6);
+        if (b != nullptr && b->points.size() == 2)
+            CHECK (std::abs (b->points[0].value - 32768.0f / 65535.0f) < 1e-6f && std::abs (b->points[1].value - 49151.0f / 65535.0f) < 1e-6f);
+    }
+    CHECK (report.converted.count ("FL Studio Mobile: instrument parameter automation") == 1
+           && report.converted["FL Studio Mobile: instrument parameter automation"] == 2);
+    CHECK (report.converted.count ("FL Studio Mobile: Pitch Bend automation") == 1 && report.converted.count ("FL Studio Mobile: switched-off instrument (muted)") == 1);
+    CHECK (report.partialEffects.count ("FL Studio Mobile: instrument Enable automation (the channel's volume on or off)") == 1);
+    CHECK (report.unsupported.count ("FL Studio Mobile: Pitch Bend/Aftertouch automation (not imported)") == 1); // (the aftertouch lane)
+    CHECK (report.unsupported.count ("FL Studio Mobile: automation of module parameters (not imported yet)") == 0);
+    // rows: the cutoff and enable lanes on the Saw, one row per bent child
+    int rows = 0;
+    for (const auto& r : s->playlistTracks)
+        rows += r.name.rfind ("Pair Pitch Bend", 0) == 0;
+    CHECK (rows == 2);
+}
+
+// The rack's Pitch Bend plays: a kit pad of one second at +12 semitones (v = 0.75) ends after half a second
+TEST (flm190de_pitch_bend_lane_plays)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    namespace rp = flm::rackparam;
+    const auto make = [&] (bool bend) {
+        return flm190bs::song ({ t::rack (flm::kindMaster, {}), t::rack (flm::kindNormal, {}, { flm190bs::sampleOf ({ "Hit", {} }) }),
+                                 t::channel (flm::kindMaster, "MASTER", 0, {}),
+                                 bend ? t::channel (flm::kindNormal, "Kit", 1, { t::lane (3, "Kit", { t::clip (0, 4, 4, 0, 1, { { 0, 0.25, 0 } }) }),
+                                                                                 t::lane (1, "Pitch Bend", { flm187d::autoClip (0, 4, 4, 1, { { 0, 1, 49151 } }) }, 0, rp::pitchBend) })
+                                      : t::channel (flm::kindNormal, "Kit", 1, { t::lane (3, "Kit", { t::clip (0, 4, 4, 0, 1, { { 0, 0.25, 0 } }) }) }) });
+    };
+    const auto plain = importFlm (make (false), flm190bs::anyFile (nullptr));
+    const auto bent = importFlm (make (true), flm190bs::anyFile (nullptr));
+    CHECK (plain.has_value() && bent.has_value());
+    if (! plain || ! bent)
+        return;
+    const auto a = flm190bs::rendered (*plain, 1.2);
+    const auto b = flm190bs::rendered (*bent, 1.2);
+    const auto lastSound = [] (const std::vector<float>& x) {
+        int last = -1;
+        for (int i = 0; i < (int) x.size(); ++i)
+            if (std::abs (x[(std::size_t) i]) > 1e-4f)
+                last = i;
+        return last;
+    };
+    CHECK (std::abs (lastSound (a) - 44100) < 400);       // the whole second
+    CHECK (std::abs (lastSound (b) - 22050) < 400);       // twice as fast: half of it
+}
+
+TEST (flm190de_kit_sample_stretch_and_pitch)
+{
+    using namespace lynx;
+    namespace sp = flm::samplepad;
+    const std::vector<float> d (sp::defaults, sp::defaults + sp::count);
+    auto fast = d;
+    fast[sp::speed] = 0.75f; // +12 semitones (a resampling)
+    const auto bytes = flm190bs::song ({
+        flm190bs::rack (flm::kindMaster, {}),
+        flm190bs::rack (flm::kindNormal, {}, { flm190bs::sampleOf ({ "Long", d, false, 0.0, 0, true, 1, 1.5, 0.0 }),       // 1.5 × as long
+                                               flm190bs::sampleOf ({ "LongFast", fast, false, 0.0, 0, true, 1, 1.5, 3.0 }), // and Speed, pitch +3
+                                               flm190bs::sampleOf ({ "Mode0", d, false, 0.0, 0, true, 0, 2.0, 0.0 }),       // mode 0: no stretch
+                                               flm190bs::sampleOf ({ "Shift", d, false, 0.0, 0, true, 0, 1.0, -2.4 }) }),   // pitch only, whole semitones
+        flm190bs::channel (flm::kindMaster, "MASTER", 0, {}),
+        flm190bs::channel (flm::kindNormal, "Kit", 1, { flm190bs::lane (3, "Kit", { flm190bs::clip (0, 4, 4, 0, 1, { { 0, 0.25, 0 } }) }) }) }, 120.0);
+    FlpImportReport report;
+    auto o = flm190bs::anyFile (&report);
+    o.common.sampleSeconds = [] (const std::string&) { return 1.0; };
+    const auto s = importFlm (bytes, o);
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const auto* lng = flm182c::channelNamed (*s, "Long");
+    const auto* lf = flm182c::channelNamed (*s, "LongFast");
+    const auto* m0 = flm182c::channelNamed (*s, "Mode0");
+    const auto* sh = flm182c::channelNamed (*s, "Shift");
+    CHECK (lng != nullptr && lf != nullptr && m0 != nullptr && sh != nullptr);
+    if (lng == nullptr || lf == nullptr || m0 == nullptr || sh == nullptr)
+        return;
+    // 1 s × 1.5 at 120 BPM = 3 beats, pitch kept
+    CHECK (lng->sampler.keepPitch && std::abs (lng->sampler.stretchBeats - 3.0f) < 1e-5f && lng->sampler.pitch == 0.0f);
+    // Speed +12 = the same shift and half the length; the stretch's +3 on top
+    CHECK (lf->sampler.keepPitch && std::abs (lf->sampler.stretchBeats - 1.5f) < 1e-5f && lf->sampler.pitch == 15.0f);
+    CHECK (! m0->sampler.keepPitch && m0->sampler.stretchBeats == 0.0f);
+    CHECK (sh->sampler.keepPitch && std::abs (sh->sampler.stretchBeats - 2.0f) < 1e-5f && sh->sampler.pitch == -2.0f);
+    CHECK (report.converted.count ("FL Studio Mobile: drum pad time-stretch or pitch shift") == 1
+           && report.converted["FL Studio Mobile: drum pad time-stretch or pitch shift"] == 3);
+}
+
+// An audio clip's EG and Sample Start play as on a pad: −0.125 s of silence first (Sample Start 0.25)
+TEST (flm190de_audio_clip_envelope_and_sample_start)
+{
+    using namespace lynx;
+    namespace sp = flm::samplepad;
+    const std::vector<float> d (sp::defaults, sp::defaults + sp::count);
+    auto late = d, soft = d;
+    late[sp::start] = 0.25f;
+    soft[sp::egAttack] = 0.3f;
+    const auto make = [&] (const std::vector<float>& prms) {
+        return flm190bs::song ({ flm190bs::rack (flm::kindMaster, {}), flm190bs::rack (flm::kindNormal, {}), flm190bs::channel (flm::kindMaster, "MASTER", 0, {}),
+                                 flm190bs::channel (flm::kindNormal, "Audio", 1, { flm190bs::lane (2, "Audio", {
+                                     flm190bs::clip (0, 2, 256, 0, 1, {}, flm190bs::sampleOf ({ "Voice", prms }), 2) }) }) });
+    };
+    FlpImportReport report;
+    const auto plain = importFlm (make (d), flm190bs::anyFile (nullptr));
+    const auto delayed = importFlm (make (late), flm190bs::anyFile (&report));
+    const auto shaped = importFlm (make (soft), flm190bs::anyFile (nullptr));
+    CHECK (plain && delayed && shaped);
+    if (! plain || ! delayed || ! shaped)
+        return;
+    const auto padOf = [] (const Song& s) -> std::vector<float> {
+        for (const auto& c : s.channels)
+            if (c.instrument == InstrumentKind::audioClip)
+                return c.sampler.flmPad;
+        return {};
+    };
+    CHECK (padOf (*plain).empty() && padOf (*delayed).size() == 7 && padOf (*shaped).size() == 7);
+    CHECK (report.converted.count ("FL Studio Mobile: audio clip envelope, Length or Sample Start") == 1);
+    const auto a = flm190bs::rendered (*plain, 0.5);
+    const auto b = flm190bs::rendered (*delayed, 0.5);
+    const auto c = flm190bs::rendered (*shaped, 0.5);
+    const auto firstSound = [] (const std::vector<float>& x) {
+        for (int i = 0; i < (int) x.size(); ++i)
+            if (std::abs (x[(std::size_t) i]) > 1e-4f)
+                return i;
+        return -1;
+    };
+    CHECK (firstSound (a) >= 0 && firstSound (a) < 64);
+    CHECK (std::abs (firstSound (b) - (firstSound (a) + 5512)) < 64); // 0.125 s later
+    // the attack: well below the plain level after 10 ms, near it after 0.4 s (attack 0.3 ≈ 0.11 s to the top)
+    CHECK (std::abs (c[441]) < 0.5f * std::abs (a[441]) && std::abs (c[17640] - a[17640]) < 0.05f * std::abs (a[17640]));
+}
+
+// --- FL Studio Mobile's DW Sampler on FLM's own engine (core/FlmDwSampler.h, FLM_FORMAT §7.5)
+#include "core/FlmDwSampler.h"
+
+namespace flm190de
+{
+// a ZONE record: the saved path (root marker, NUL, path, then `stale` text after a NUL), the tail
+inline Bytes zoneOf (const std::string& path, int root, int lo, int hi, int vlo, int vhi, float gain = 1.0f, int loopMode = 0, int ls = 0, int le = 0,
+                     float decay = 1.0f, const std::string& stale = {})
+{
+    Bytes text (1024, 0);
+    std::string p = "@R@";
+    p.push_back ('\0');
+    p += path;
+    std::memcpy (text.data(), p.data(), p.size());
+    if (! stale.empty())
+        std::memcpy (text.data() + p.size() + 1, stale.data(), stale.size());
+    Bytes b = text;
+    b.push_back ((std::uint8_t) root), b.push_back ((std::uint8_t) lo), b.push_back ((std::uint8_t) hi), b.push_back ((std::uint8_t) vlo), b.push_back ((std::uint8_t) vhi);
+    f32 (b, gain);
+    f32 (b, 0.5f);
+    u32 (b, (std::uint32_t) loopMode);
+    u32 (b, (std::uint32_t) ls);
+    u32 (b, (std::uint32_t) le);
+    f32 (b, 0.0f);
+    f32 (b, decay);
+    f32 (b, 1.0f);
+    f32 (b, 0.25f);
+    return chunk ("ZONE", b);
+}
+inline Bytes dwCustom (std::initializer_list<Bytes> parts)
+{
+    Bytes b;
+    tag (b, "10WD");
+    for (const auto& p : parts)
+        put (b, p.data(), p.size());
+    return b;
+}
+inline Bytes midiChunk (int range, int smooth) { return chunk ("MIDI", Bytes { (std::uint8_t) range, (std::uint8_t) smooth }); }
+inline std::vector<float> dwDefaults() { return std::vector<float> (lynx::flmdw::defaults, lynx::flmdw::defaults + lynx::flmdw::paramCount); }
+
+// two zones: one with stale text after its path, one with FLM's old integer 63 as its gain; MIDI (range 2, no smoothing)
+inline Bytes twoZones()
+{
+    Bytes old = zoneOf ("DirectWave Samples/Bass/b.wav", 60, 0, 127, 64, 127);
+    const std::uint32_t sixtyThree = 63;
+    std::memcpy (old.data() + 8 + 1024 + 5, &sixtyThree, 4);
+    return dwCustom ({ zoneOf ("DirectWave Samples/Bass/a.wav", 48, 0, 127, 0, 63, 0.5f, 2, 100, 900, 0.0f, "ss a.wav"), old, midiChunk (2, 0) });
+}
+
+// a PATh: the preset file and the two values that replace Attack / Release
+inline Bytes pathCustom()
+{
+    Bytes path;
+    const std::string where = std::string ("@R@") + '\0' + "DirectWave Samples\\Guitar\\Picked Bass.dwp";
+    u32 (path, (std::uint32_t) where.size());
+    put (path, where.data(), where.size());
+    f32 (path, 0.2f);
+    f32 (path, 0.3f);
+    return dwCustom ({ chunk ("PATh", path) });
+}
+
+// a DirectWave program as FLM reads it (entries id, u64 size, body; a zone = 500 / 502 / 503 / 509), twice the same zone
+inline Bytes program (std::uint32_t version)
+{
+    const auto entry = [] (std::uint32_t id, const Bytes& body) {
+        Bytes b;
+        u32 (b, id);
+        u32 (b, (std::uint32_t) body.size());
+        u32 (b, 0);
+        put (b, body.data(), body.size());
+        return b;
+    };
+    Bytes k500 { 57, 0, 59, 0, 127, 0, 0, 0, 0 };
+    f32 (k500, 0.675f);
+    f32 (k500, 0.5f);
+    u32 (k500, 0), u32 (k500, 512);
+    const std::string file = "%ILSharedData%\\DirectWave\\Nylon Guitar\\Nylon Guitar a3.wav";
+    const Bytes k502 (file.begin(), file.end());
+    Bytes k503;
+    u32 (k503, 130802), u32 (k503, 0), u32 (k503, 1), u32 (k503, 16);
+    f32 (k503, 44100.0f);
+    u32 (k503, 2), u32 (k503, 129189), u32 (k503, 130802), u32 (k503, 0);
+    Bytes k509;
+    for (const float v : { 0.0f, 0.5f, 1.0f, 0.25f })
+        f32 (k509, v);
+    const auto zone = cat ({ entry (500, k500), entry (502, k502), entry (503, k503), entry (509, k509) });
+    Bytes dwp;
+    tag (dwp, "DwPr");
+    u32 (dwp, version);
+    const auto prog = entry (1, cat ({ entry (3, zone), entry (3, zone), entry (2, {}) }));
+    put (dwp, prog.data(), prog.size());
+    return dwp;
+}
+} // namespace flm190de
+
+TEST (flm190de_dw_sampler_state_and_laws)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    const auto cstm = t::twoZones();
+    const auto c = flmdw::parseCustom ({ cstm.data(), cstm.size() });
+    CHECK (c.has_value() && c->zones.size() == 2 && c->pbRange == 2 && ! c->smoothAttack && ! c->hasPath);
+    if (c && c->zones.size() == 2)
+    {
+        const auto& a = c->zones[0];
+        CHECK (a.root == "@R@" && a.path == "DirectWave Samples/Bass/a.wav" && a.rootKey == 48 && a.velHigh == 63 && a.gain == 0.5f && a.loopMode == 2
+               && a.loopStart == 100 && a.loopEnd == 900 && a.decay == 0.0f && a.release == 0.25f);
+        CHECK (c->zones[1].gain < 0.0001f && c->zones[1].velLow == 64); // (63 as an integer: FLM plays it at gain 1)
+        const auto z = flmdw::sampleZone (a, "C:/x.wav");
+        CHECK (z.path == "C:/x.wav" && z.loopMode == 1 && z.loopEnd == 900 && z.lowVelocity == 0 && z.highVelocity == 63);
+    }
+    CHECK (! flmdw::parseCustom ({ cstm.data() + 4, cstm.size() - 4 }).has_value());
+    const auto pc = t::pathCustom();
+    const auto p = flmdw::parseCustom ({ pc.data(), pc.size() });
+    CHECK (p && p->hasPath && p->pathRoot == "@R@" && p->path == "DirectWave Samples/Guitar/Picked Bass.dwp" && p->pathFloats && p->pathAttack == 0.2f
+           && p->pathRelease == 0.3f && p->pbRange == 4 && p->smoothAttack);
+    const auto dwp = t::program (37);
+    const auto zones = flmdw::parseProgram ({ dwp.data(), dwp.size() });
+    CHECK (zones.size() == 2);
+    if (! zones.empty())
+        CHECK (zones[0].rootKey == 57 && zones[0].keyHigh == 59 && zones[0].gain == 0.675f && zones[0].loopMode == 2 && zones[0].loopStart == 129189
+               && zones[0].loopEnd == 130802 && zones[0].path == "%ILSharedData%/DirectWave/Nylon Guitar/Nylon Guitar a3.wav" && zones[0].release == 0.25f);
+    const auto old = t::program (35); // (not read)
+    CHECK (flmdw::parseProgram ({ old.data(), old.size() }).empty());
+
+    // the laws (FLM_FORMAT §7.5's test vectors)
+    CHECK (std::abs (flmdw::envelopeSeconds (0.25f) - 0.0400625) < 1e-9 && std::abs (flmdw::envelopeSeconds (0.0f) - 0.001) < 1e-12
+           && std::abs (flmdw::envelopeSeconds (1.0f) - 10.001) < 1e-9);
+    CHECK (std::abs (flmdw::onePoleRate (0.25f, 50.0) - 5.85475e-4) < 1e-8 && std::abs (flmdw::onePoleRate (1.0f, 50.0) - 4.0e-6) < 1e-10
+           && flmdw::onePoleRate (0.0005f, 50.0) == 1.0);
+    CHECK (flmdw::pitchSemitones (0.5f) == 0 && flmdw::pitchSemitones (0.759039f) == 12 && flmdw::pitchSemitones (0.09699f) == -19);
+    float third;
+    std::uint32_t bits = 0x3EAAAAABu;
+    std::memcpy (&third, &bits, 4);
+    CHECK (flmdw::filterKind (third) == 1 && flmdw::filterKind (0.333f) == 0 && flmdw::filterKind (1.0f) == 3);
+    CHECK (std::abs (flmdw::cutoffHz (0.0f, 0.0, 0.0) - 16.0) < 1e-6 && std::abs (flmdw::cutoffHz (0.375f, 0.0, 0.0) - 238.86) < 0.01
+           && std::abs (flmdw::cutoffHz (1.0f, 0.0, 0.0) - 21618.8) < 0.1 && flmdw::cutoffHz (1.0f, 1.0, 0.0) == 22000.0);
+    CHECK (std::abs (flmdw::lfoHz (0.0f) - 0.033296) < 1e-5 && std::abs (flmdw::lfoHz (0.47f) - 0.22224) < 1e-4 && std::abs (flmdw::lfoHz (1.0f) - 30.0) < 1e-9);
+}
+
+TEST (flm190de_dw_sampler_import_and_sound)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    auto plain = t::dwDefaults();
+    plain[flmdw::param::release] = 0.0f;
+    auto up = plain;
+    up[flmdw::param::pitch] = 0.759039f; // +12
+    auto soft = plain;
+    soft[flmdw::param::attack] = 0.5f;   // 0.626 s linear, heard squared
+    // one zone of a 1-second sample, root 60, every key and velocity; a module with no zone; a rack with a Pitch lane
+    using Bytes = flm182c::Bytes;
+    const auto oneZone = t::dwCustom ({ t::zoneOf ("DirectWave Samples/Pad/p.wav", 60, 0, 127, 0, 127), t::midiChunk (2, 0) });
+    const auto empty = t::dwCustom ({});
+    const auto make = [&] (const std::vector<float>& prms, const Bytes& custom, bool lane) {
+        return flm190bs::song ({ t::rack (flm::kindMaster, {}), t::rack (flm::kindNormal, { t::moduleWith (1, 2, prms, {}, custom) }),
+                                 t::channel (flm::kindMaster, "MASTER", 0, {}),
+                                 lane ? t::channel (flm::kindNormal, "Pad", 1, { t::lane (0, "Pad", { t::clip (0, 4, 4, 0, 1, { { 0, 3.5, 60, 255 } }) }),
+                                                                                 t::lane (1, "Pitch : DirectWave", { flm187d::autoClip (0, 4, 4, 1, { { 0, 1, 40000 } }) }, 2, 3) })
+                                      : t::channel (flm::kindNormal, "Pad", 1, { t::lane (0, "Pad", { t::clip (0, 4, 4, 0, 1, { { 0, 3.5, 60, 255 } }) }) }) });
+    };
+    FlpImportReport report;
+    const auto a = importFlm (make (plain, oneZone, true), flm190bs::anyFile (&report));
+    const auto b = importFlm (make (up, oneZone, false), flm190bs::anyFile (nullptr));
+    const auto s = importFlm (make (soft, oneZone, false), flm190bs::anyFile (nullptr));
+    const auto e = importFlm (make (plain, empty, false), flm190bs::anyFile (nullptr));
+    CHECK (a && b && s && e);
+    if (! a || ! b || ! s || ! e)
+        return;
+    const auto* pad = flm182c::channelNamed (*a, "Pad");
+    CHECK (pad != nullptr && flmdw::isChannel (*pad) && pad->zones.size() == 1 && pad->zones[0].path == "C:/FLM/DirectWave Samples/Pad/p.wav"
+           && pad->modelParams[1] == 2.0f && pad->modelParams[2] == 0.0f && pad->misc.pitchRange == 2);
+    CHECK (report.converted.count ("FL Studio Mobile: DW Sampler (FLM's engine)") == 1
+           && report.unsupported.count ("FL Studio Mobile: DW Sampler (multisample)") == 0);
+    // the Pitch lane: the module's own value 3 on the channel
+    const auto* pitch = t::automationOf (*a, AutomationTargetKind::channelParam, (int) (pad - a->channels.data()), flmdw::automationBase + 3);
+    CHECK (pitch != nullptr && pitch->points.size() == 1 && std::abs (pitch->points[0].value - 40000.0f / 65535.0f) < 1e-6f);
+    // a module with no zone is silent (FLM: no sample), not LYNX's generic synth
+    const auto* none = flm182c::channelNamed (*e, "Pad");
+    CHECK (none != nullptr && none->instrument == InstrumentKind::sampler && flmdw::isChannel (*none) && none->zones.empty());
+
+    // sound: the sample (1 s of 0.5) at full velocity, release 0: level 0.5; +12 plays it in half the time; a slow
+    // attack is the square of a linear ramp
+    const auto x = flm190bs::rendered (*b, 1.2);
+    const auto y = flm190bs::rendered (*s, 1.2);
+    const auto z = flm190bs::rendered (*e, 1.2);
+    // (a's Pitch lane moves the key: render it without the lane for the plain level)
+    const auto plainSong = importFlm (make (plain, oneZone, false), flm190bs::anyFile (nullptr));
+    const auto w = flm190bs::rendered (*plainSong, 1.2);
+    const auto lastSound = [] (const std::vector<float>& v) {
+        int last = -1;
+        for (int i = 0; i < (int) v.size(); ++i)
+            if (std::abs (v[(std::size_t) i]) > 1e-4f)
+                last = i;
+        return last;
+    };
+    const auto peak = [] (const std::vector<float>& v) { float m = 0.0f; for (const auto s : v) m = std::max (m, std::abs (s)); return m; };
+    CHECK (std::abs (w[22050] - 0.5f) < 1e-3f && std::abs (lastSound (w) - 44100) < 600);
+    CHECK (std::abs (lastSound (x) - 22050) < 600 && std::abs (x[11025] - 0.5f) < 1e-3f);
+    const auto ta = flmdw::envelopeSeconds (0.5f);
+    const auto at = [&] (double sec) { const auto r = std::min (1.0, sec / ta); return 0.5 * r * r; };
+    CHECK (std::abs (y[4410] - at (0.1)) < 2e-3 && std::abs (y[22050] - at (0.5)) < 2e-3 && std::abs (y[33075] - 0.5f) < 2e-3f);
+    CHECK (peak (z) == 0.0f);
+}
+
+// --- Pitcher / Pitcher 2 → LYNX Tune (FLM_FORMAT §7.6) and the Slicer (§7.7)
+#include "core/FlmSlicer.h"
+#include "core/LynxTune.h"
+
+TEST (flm190de_pitchers_become_lynx_tune)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    namespace lt = lynxtune;
+    // Pitcher: CSTM mask = C D E G A (a pentatonic), Speed 0.5, Pitch +5 (0.71), Mix 0.8, BYP on E
+    std::vector<float> p1 (23, 0.0f);
+    p1[0] = 1.0f, p1[1] = 0.5f, p1[2] = 0.71f, p1[3] = 0.5f, p1[7] = 0.5f, p1[9] = 0.8f, p1[14] = 1.0f;
+    flm182c::Bytes mask { 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0 };
+    flm182c::f32 (mask, 0.0f), flm182c::f32 (mask, 0.5f);
+    // Pitcher 2: its defaults (C minor) with Speed 0.25 and Formant Mode 0 (= formant correction on)
+    std::vector<float> p2 (27, 0.0f);
+    p2[0] = 1.0f;
+    for (const int k : { 1, 3, 4, 6, 8, 9, 11 })
+        p2[(std::size_t) k] = 1.0f;
+    p2[13] = 0.25f, p2[17] = 0.5f, p2[18] = 1.0f, p2[19] = 0.5f, p2[22] = 1.0f, p2[23] = 0.5f;
+    const auto bytes = flm190bs::song ({ t::rack (flm::kindMaster, {}),
+                                         t::rack (flm::kindNormal, { t::moduleWith (25, 2, p1, {}, mask), t::moduleWith (45, 3, p2) }),
+                                         t::channel (flm::kindMaster, "MASTER", 0, {}), t::channel (flm::kindNormal, "Voice", 1, {}) });
+    FlpImportReport report;
+    const auto s = importFlm (bytes, flm190bs::anyFile (&report));
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const auto& fx = s->mixer[1].effects;
+    CHECK (fx.size() == 2 && fx[0].kind == EffectKind::lynxTune && fx[1].kind == EffectKind::lynxTune);
+    if (fx.size() != 2)
+        return;
+    const auto& a = fx[0].params;
+    CHECK (a[lt::scale] == 1.0f && a[lt::noteC] == 1.0f && a[lt::noteC + 1] == 0.0f && a[lt::noteC + 4] == 1.0f && a[lt::noteC + 7] == 1.0f
+           && a[lt::noteC + 11] == 0.0f);
+    // Speed 0.5: τ = (3·0.125 + 0.001) / 8.82 s = 42.63 ms → retune √(42.63 / 400)
+    CHECK (std::abs (a[lt::retune] - 0.32646f) < 1e-4f);
+    CHECK (std::abs (a[lt::transpose] - (5.0f + 12.0f) / 24.0f) < 1e-6f && std::abs (a[lt::mix] - 0.8f) < 1e-6f);
+    CHECK (a[lt::bypassC + 4] == 1.0f && a[lt::bypassC] == 0.0f && a[lt::correction] == 1.0f && std::abs (a[lt::reference] - 0.5f) < 1e-6f);
+    const auto& b = fx[1].params;
+    CHECK (b[lt::noteC] == 1.0f && b[lt::noteC + 2] == 1.0f && b[lt::noteC + 3] == 1.0f && b[lt::noteC + 4] == 0.0f && b[lt::noteC + 10] == 1.0f
+           && b[lt::noteC + 11] == 0.0f);
+    CHECK (b[lt::formantPreserve] == 1.0f && std::abs (b[lt::toleranceCents] - 0.55f) < 1e-6f && b[lt::mix] == 1.0f);
+    // Speed 0.25: fc = (200^0.25 − 0.9)·2.29896 = 6.576 Hz → 5.30 / (2π fc) = 128.3 ms
+    CHECK (std::abs (b[lt::retune] - 0.5663f) < 2e-3f);
+    CHECK (report.converted.count ("FL Studio Mobile: Pitcher (LYNX Tune)") == 1 && report.converted.count ("FL Studio Mobile: Pitcher 2 (LYNX Tune)") == 1
+           && report.droppedEffects.empty());
+}
+
+TEST (flm190de_slicer_detects_and_plays)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    // four hits of noise (60 ms each, decaying) at 0, 0.25, 0.5, 0.75 s in silence
+    SampleData d;
+    d.sampleRate = 44100.0;
+    d.left.assign (44100, 0.0f);
+    std::uint32_t seed = 1;
+    for (const int at : { 0, 11025, 22050, 33075 })
+        for (int i = 0; i < 2646 * 2; ++i)
+        {
+            seed = seed * 1664525u + 1013904223u;
+            d.left[(std::size_t) (at + i)] = ((float) (seed >> 8) / 16777216.0f - 0.5f) * std::exp (-(float) i / 900.0f);
+        }
+    const auto starts = flmslicer::slices (d, 0.25f);
+    CHECK (starts.size() == 4);
+    if (starts.size() == 4)
+        CHECK (starts[0] == 0 && std::abs (starts[1] - 11025) < 64 && std::abs (starts[2] - 22050) < 64 && std::abs (starts[3] - 33075) < 64);
+    d.markerStarts = { 0, 22050 };
+    CHECK (flmslicer::slices (d, 0.0f) == std::vector<std::int64_t> ({ 0, 22050 }));
+
+    // the module: SENS 0.25, PATH, key range 48…51; key 49 plays the second slice
+    flm182c::Bytes cstm;
+    flm182c::Bytes sens;
+    flm182c::f32 (sens, 0.25f);
+    sens.push_back (1);
+    const auto senc = flm182c::chunk ("SENS", sens);
+    flm182c::put (cstm, senc.data(), senc.size());
+    flm182c::Bytes path;
+    const std::string where = std::string ("@R@") + '\0' + "Loop Samples\\Sliced Drums\\Hits.wav";
+    flm182c::u32 (path, (std::uint32_t) where.size());
+    flm182c::put (path, where.data(), where.size());
+    const auto pathc = flm182c::chunk ("PATH", path);
+    flm182c::put (cstm, pathc.data(), pathc.size());
+    const auto bytes = flm190bs::song ({ t::rack (flm::kindMaster, {}),
+                                         t::rack (flm::kindNormal, { t::moduleWith (33, 2, { 1.0f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }, {}, cstm, {}, 48, 51) }),
+                                         t::channel (flm::kindMaster, "MASTER", 0, {}),
+                                         t::channel (flm::kindNormal, "Slices", 1, { t::lane (0, "Slices", { t::clip (0, 4, 4, 0, 1, { { 0, 1, 49, 255 } }) }) }) });
+    FlpImportReport report;
+    const auto s = importFlm (bytes, flm190bs::anyFile (&report));
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const auto* c = flm182c::channelNamed (*s, "Slices");
+    CHECK (c != nullptr && flmslicer::isChannel (*c) && c->samplePath == "C:/FLM/Loop Samples/Sliced Drums/Hits.wav" && c->modelParams[1] == 0.25f
+           && c->modelParams[2] == 48.0f && c->keyLow == 48 && c->keyHigh == 51);
+    CHECK (report.converted.count ("FL Studio Mobile: Slicer (FLM's engine)") == 1);
+    // play it on the hits: the second slice (one-shot, SUST 0) sounds for about a quarter second, then stops
+    auto inst = flmslicer::makeInstrument (std::make_shared<SampleData> (d));
+    inst->prepare (44100.0);
+    inst->configure (*c, 120.0);
+    inst->settleNew();
+    std::vector<float> l (44100, 0.0f), r (44100, 0.0f);
+    inst->noteOn (49, 1.0f);
+    inst->render (l.data(), r.data(), 44100, 1.0f, 1.0f);
+    int last = -1;
+    float first = 0.0f;
+    for (int i = 0; i < 44100; ++i)
+        if (std::abs (l[(std::size_t) i]) > 1e-4f)
+        {
+            last = i;
+            if (first == 0.0f)
+                first = (float) i;
+        }
+    // (at the slice's end the voice fades at 0.01 per sample while it reads on into the next hit: ~690 samples)
+    CHECK (first < 64.0f && last > 11025 + 400 && last < 11025 + 800);
+    CHECK (std::abs (l[100] - d.left[(std::size_t) (starts.size() == 4 ? starts[1] : 0) + 100]) < 0.05f);
+}
+
+// --- Arpeggiator and Note Echo, baked over the song (FLM_FORMAT §7.8)
+TEST (flm190de_arpeggiator_and_note_echo)
+{
+    using namespace lynx;
+    namespace nf = flmnotefx;
+    // the defaults with Arp 1 in a mode: Rate 1/8, Gate 50 %, Range 1, Octave 0, Start 0, Repeats inf, Arp 2 off
+    const auto arpParams = [] (int mode) {
+        std::vector<float> p (33, 0.0f);
+        p[0] = 1.0f, p[1] = 2.0f / 7.0f, p[2] = 4.0f / 19.0f, p[3] = 1.0f, p[7] = p[8] = 0.5f;
+        for (const int base : { 9, 20 })
+            p[(std::size_t) base] = 0.4444444f, p[(std::size_t) base + 3] = 0.5f, p[(std::size_t) base + 4] = 0.5f, p[(std::size_t) base + 6] = 0.5f;
+        p[31] = p[32] = 6.0f / 14.0f;
+        p[10] = (float) mode / 23.0f;
+        p[19] = 1.0f;
+        return p;
+    };
+    const std::vector<nf::TimedNote> chord { { 0.0, 4.0, 60, 0.8f, 0.5f }, { 0.0, 4.0, 64, 0.8f, 0.5f }, { 0.0, 4.0, 67, 0.8f, 0.5f } };
+    bool random = true;
+    const auto up = nf::arpeggiate (arpParams (2), chord, 120.0, 4, random);
+    CHECK (! random && up.size() == 8);
+    static constexpr int upKeys[] = { 60, 64, 67 };
+    if (up.size() == 8)
+        for (int i = 0; i < 8; ++i)
+            CHECK (std::abs (up[(std::size_t) i].start - 0.5 * i) < 1e-9 && std::abs (up[(std::size_t) i].end - up[(std::size_t) i].start - 0.25) < 1e-6
+                   && up[(std::size_t) i].key == upKeys[i % 3] && std::abs (up[(std::size_t) i].velocity - 0.8f) < 1e-6f);
+    // the spec's "Binary dance" Arp 1: Bass Up, rhythm R2 rotated by 2 → 0.5 60, 1.0 64, 2.0 60, 2.5 67, 3.5 60
+    auto dance = arpParams (9);
+    dance[14] = 2.0f / 21.0f, dance[15] = 1.0f;
+    const auto d = nf::arpeggiate (dance, chord, 120.0, 4, random);
+    CHECK (d.size() == 5);
+    if (d.size() == 5)
+    {
+        const double at[] = { 0.5, 1.0, 2.0, 2.5, 3.5 };
+        const int key[] = { 60, 64, 60, 67, 60 };
+        for (int i = 0; i < 5; ++i)
+            CHECK (std::abs (d[(std::size_t) i].start - at[i]) < 1e-9 && d[(std::size_t) i].key == key[i]);
+    }
+    // a chord that starts between grid points plays at the next one; the arp notes end at the release
+    const std::vector<nf::TimedNote> late { { 0.3, 1.2, 60, 1.0f, 0.5f } };
+    const auto l = nf::arpeggiate (arpParams (2), late, 120.0, 4, random);
+    CHECK (l.size() == 2 && std::abs (l[0].start - 0.5) < 1e-9 && std::abs (l[1].start - 1.0) < 1e-9 && std::abs (l[1].end - 1.2) < 1e-9);
+
+    // Note Echo: the spec's third vector (4 echoes of a 1/4 beat, ×0.55 velocity, +7 per echo, drift 1.15, length
+    // ×0.75, pan drift +0.25 with ping-pong)
+    std::vector<float> e (16, 0.5f);
+    e[0] = 1.0f, e[1] = 0.125f, e[2] = 0.24253564f, e[3] = 0.16568f, e[4] = 1.0f, e[7] = 0.25f, e[8] = 19.0f / 24.0f, e[9] = 0.75f, e[10] = 0.25f,
+    e[11] = 0.0f, e[13] = 0.75f, e[14] = 1.0f, e[15] = 0.0f;
+    const auto echoes = nf::echo (e, { { 0.0, 0.125, 60, 0.8f, 0.5f } }, 120.0, random);
+    CHECK (! random && echoes.size() == 5);
+    if (echoes.size() == 5)
+    {
+        const double start[] = { 0.25, 0.58058, 0.96079, 1.39804 }, end[] = { 0.34375, 0.65092, 1.01354, 1.43762 };
+        const int key[] = { 67, 74, 81, 88 };
+        const float vel[] = { 0.44f, 0.242f, 0.1331f, 0.0732f }, pan[] = { 0.5f, 0.375f, 0.75f, 0.125f };
+        CHECK (echoes[0].key == 60 && echoes[0].end == 0.125);
+        for (int i = 0; i < 4; ++i)
+        {
+            const auto& x = echoes[(std::size_t) i + 1];
+            CHECK (std::abs (x.start - start[i]) < 2e-4 && std::abs (x.end - end[i]) < 2e-4 && x.key == key[i] && std::abs (x.velocity - vel[i]) < 2e-4f
+                   && std::abs (x.pan - pan[i]) < 1e-6f);
+        }
+    }
+    // a dry note longer than the delay ends at its first echo
+    std::vector<float> plain (16, 0.5f);
+    plain[0] = 1.0f, plain[1] = 0.25f, plain[2] = plain[3] = 0.24253564f, plain[4] = 1.0f, plain[11] = plain[14] = plain[15] = 0.0f;
+    const auto held = nf::echo (plain, { { 0.0, 1.0, 60, 0.8f, 0.5f } }, 120.0, random);
+    CHECK (held.size() == 9 && std::abs (held[0].end - 0.5) < 1e-9 && std::abs (held[8].start - 4.0) < 1e-3);
+
+    // on import: a rack with an Arpeggiator plays its notes as one pattern over the song
+    namespace t = flm190de;
+    const auto bytes = flm190bs::song ({ t::rack (flm::kindMaster, {}), t::rack (flm::kindNormal, { t::moduleWith (23, 2, t::superSawDefaults()), t::moduleWith (51, 3, arpParams (2)) }),
+                                         t::channel (flm::kindMaster, "MASTER", 0, {}),
+                                         t::channel (flm::kindNormal, "Arp", 1, { t::lane (0, "Arp", { t::clip (0, 4, 4, 0, 1, { { 0, 4, 60 }, { 0, 4, 64 }, { 0, 4, 67 } }),
+                                                                                                    t::clip (8, 4, 4, 0, 1, {}) }) }) });
+    FlpImportReport report;
+    const auto s = importFlm (bytes, flm190bs::anyFile (&report));
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const Pattern* baked = nullptr;
+    for (const auto& p : s->patterns)
+        if (p.name == "Arp (note effects)")
+            baked = &p;
+    CHECK (baked != nullptr && baked->notes.size() == 16); // (both clips hold the chord: beats 0…4 and 8…12)
+    if (baked != nullptr && baked->notes.size() == 16)
+        CHECK (baked->notes[0].start == 0 && baked->notes[0].key == 60 && baked->notes[1].start == ppq / 2 && baked->notes[1].key == 64
+               && baked->notes[8].start == 8 * ppq && baked->notes[8].key == 60);
+    int clips = 0;
+    for (const auto& c : s->playlist)
+        clips += c.kind == ClipKind::pattern;
+    CHECK (clips == 1 && report.converted.count ("FL Studio Mobile: Arpeggiator (note effect, baked over the song)") == 1
+           && report.droppedEffects.empty());
+}
+
+// Coordinator's decision (round 190de): a DW Sampler whose every sample is missing on this PC (FLM's content packs) plays
+// a LYNX stand-in of its category, named in the report; one with some samples missing plays the others
+TEST (flm190de_dw_sampler_missing_samples)
+{
+    using namespace lynx;
+    namespace t = flm190de;
+    const auto piano = t::dwCustom ({ t::zoneOf ("DirectWave Samples EXP/Keyboard/Grand Piano/GP C3.wav", 48, 0, 59, 0, 127),
+                                      t::zoneOf ("DirectWave Samples EXP/Keyboard/Grand Piano/GP C5.wav", 72, 60, 127, 0, 127), t::midiChunk (2, 0) });
+    const auto pad = t::dwCustom ({ t::zoneOf ("DirectWave Samples/Pad/here.wav", 60, 0, 59, 0, 127),
+                                    t::zoneOf ("DirectWave Samples/Pad/gone.wav", 72, 60, 127, 0, 127), t::midiChunk (2, 0) });
+    auto prms = t::dwDefaults();
+    prms[flmdw::param::pitch] = 0.6042f; // +5 semitones
+    const auto bytes = flm190bs::song ({ t::rack (flm::kindMaster, {}), t::rack (flm::kindNormal, { t::moduleWith (1, 2, prms, {}, piano) }),
+                                         t::rack (flm::kindNormal, { t::moduleWith (1, 2, t::dwDefaults(), {}, pad) }),
+                                         t::channel (flm::kindMaster, "MASTER", 0, {}),
+                                         t::channel (flm::kindNormal, "Keys", 1, { t::lane (0, "Keys", { t::clip (0, 4, 4, 0, 1, { { 0, 2, 60, 255 } }) }) }),
+                                         t::channel (flm::kindNormal, "Pad", 2, { t::lane (0, "Pad", { t::clip (0, 4, 4, 0, 1, { { 0, 2, 50, 255 } }) }) }) });
+    FlpImportReport report;
+    auto o = flm190bs::anyFile (&report);
+    o.common.fileExists = [] (const std::string& p) { return p.find ("C:/FLM/") == 0 && p.find ("EXP") == std::string::npos && p.find ("gone") == std::string::npos; };
+    const auto s = importFlm (bytes, o);
+    CHECK (s.has_value());
+    if (! s)
+        return;
+    const auto* keys = flm182c::channelNamed (*s, "Keys");
+    const auto* padc = flm182c::channelNamed (*s, "Pad");
+    CHECK (keys != nullptr && padc != nullptr);
+    if (keys == nullptr || padc == nullptr)
+        return;
+    // every zone missing: a LYNX sound of the keys category (a piano when there is one), the module's Pitch kept
+    CHECK (! flmdw::isChannel (*keys) && keys->instrument != InstrumentKind::sampler && keys->mixerTrack == 1 && keys->sampler.pitch == 5.0f);
+    bool line = false;
+    for (const auto& [what, n] : report.partialEffects)
+        line = line || (what.find ("DW Sampler \"Grand Piano\": every sample missing, plays LYNX's") != std::string::npos);
+    CHECK (line && report.missingSamples >= 2);
+    // the keys play (not silent)
+    const auto sound = flm190bs::rendered (*s, 1.0);
+    float peak = 0.0f;
+    for (const auto x : sound)
+        peak = std::max (peak, std::abs (x));
+    CHECK (peak > 1.0e-3f);
+    // some zones missing: FLM's engine on the zones there are, the missing one listed
+    CHECK (flmdw::isChannel (*padc) && padc->zones.size() == 2 && ! padc->zones[0].path.empty() && padc->zones[1].path.empty());
+    CHECK (report.partialEffects.count ("FL Studio Mobile: DW Sampler with some samples missing (the others play; the missing ones are listed)") == 1);
+}

+ 1 - 0
tests/tests.cpp

@@ -17391,6 +17391,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "FlmImport189hCTests.inc"
 #include "FlmImport189hCTests.inc"
 #include "FlmImport190bsTests.inc"
 #include "FlmImport190bsTests.inc"
 #include "PocketFx190byTests.inc" // round 190by
 #include "PocketFx190byTests.inc" // round 190by
+#include "FlmImport190deTests.inc" // round 190de
 #include "Bridge176aTests.inc"
 #include "Bridge176aTests.inc"
 #include "Issues178aTests.inc"
 #include "Issues178aTests.inc"
 #include "Mixer177aTests.inc"
 #include "Mixer177aTests.inc"

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません