Просмотр исходного кода

Merge remote-tracking branch 'origin/main' into feature/issue12

# Conflicts:
#	src/ui/I18nData.h
#	src/ui/WindowOwner.cpp
#	src/ui/WindowOwner.h
#	tests/tests.cpp
Ka1-S 1 месяц назад
Родитель
Сommit
a29ee3b441
43 измененных файлов с 2065 добавлено и 313 удалено
  1. 4 0
      .gitignore
  2. BIN
      Vfx.o
  3. BIN
      VfxSequencer.o
  4. 25 18
      docs/STATUS.md
  5. 104 0
      docs/analise/REA_rodada165g-flbeta165k.md
  6. 112 0
      docs/analise/REA_rodada165g-flgran165.md
  7. 18 6
      docs/analise/REA_rodada165m.md
  8. 135 0
      docs/analise/REA_rodada165q.md
  9. 18 0
      resources/i18n/pt-BR.txt
  10. 21 1
      src/Main.cpp
  11. 3 0
      src/core/FlpImport.cpp
  12. 169 18
      src/core/Granulizer.cpp
  13. 19 5
      src/core/Granulizer.h
  14. 264 19
      src/core/Kepler.cpp
  15. 11 2
      src/core/Kepler.h
  16. 2 2
      src/core/NativeEngines.cpp
  17. 62 3
      src/core/Performance.cpp
  18. 14 2
      src/core/Performance.h
  19. 3 1
      src/core/RackRenderer.cpp
  20. 33 0
      src/core/SampleFiles.h
  21. 6 0
      src/engine/SampleLibrary.cpp
  22. 4 0
      src/engine/SampleLibrary.h
  23. 1 1
      src/ui/BrowserComponent.cpp
  24. 3 3
      src/ui/ChannelRackComponent.cpp
  25. 89 1
      src/ui/ChannelSettings.cpp
  26. 317 211
      src/ui/I18nData.h
  27. 36 0
      src/ui/MainComponent.cpp
  28. 1 0
      src/ui/MainComponent.h
  29. 1 1
      src/ui/NewtoneEditor.cpp
  30. 56 13
      src/ui/PlaylistComponent.cpp
  31. 3 0
      src/ui/PlaylistComponent.h
  32. 5 0
      src/ui/PluginWindow.cpp
  33. 14 5
      src/ui/QuickAddPalette.cpp
  34. 83 0
      src/ui/WindowOwner.cpp
  35. 14 0
      src/ui/WindowOwner.h
  36. 13 0
      tests/Audit165Tests.inc
  37. 189 0
      tests/FlGran165Tests.inc
  38. 108 0
      tests/Kepler165kTests.inc
  39. 65 0
      tests/PerfMode165Tests.inc
  40. 5 0
      tests/tests.cpp
  41. 5 0
      tools/WavReader.h
  42. 21 1
      tools/granulizerrender.cpp
  43. 9 0
      tools/keplerrender.cpp

+ 4 - 0
.gitignore

@@ -10,3 +10,7 @@ build-linux/
 build-mac/
 dist/
 __pycache__/
+
+# object files (never commit build output)
+*.o
+*.obj


BIN
VfxSequencer.o


+ 25 - 18
docs/STATUS.md

@@ -150,8 +150,8 @@ Core Audio / ALSA + JACK (PipeWire).
   DX10 on its engine with the channel processor it keeps (REA round 42: bit-identical to the reference model, which is
   bit-identical to FL's DLL on all 64 distinct installation states and on the 12 project channels with their channel
   envelopes/filter); Kepler on its engine (REA round 46: the whole Kepler-1 engine with the DLL's rounding mode, LFO
-  shape and noise read from the user's own engine DLL; the default patch bit-exact against FL's DLL, the 4 demo channels
-  within −124 dB, 273 of 283 preset/demo states within −99 dB); PoiZone on its engine (REA round 44: voices, gate, arpeggiator, chorus and tape delay from the raw state;
+  shape and noise read from the user's own engine DLL; REA round 165g flbeta165k: all 277 presets + 6 demo/test states
+  bit-exact against FL's DLL at 22.05/44.1/96 kHz, FL's own renders of 253 of 277 null at the 16-bit floor — no longer "beta"); PoiZone on its engine (REA round 44: voices, gate, arpeggiator, chorus and tape delay from the raw state;
   bit-identical to FL's DLL on 384 of 385 presets with the delay off and on the render test, the delay's low/high-cut
   coefficients differ by the CRT's low-accuracy sincosf: median −79 dB, worst −48 dB); Fruit Kick and BassDrum on their engines (REA round 43: Fruit Kick bit-exact with FL's
   DLL, release fades included (REA round 74: IPP's cosine restated, 441-entry fade at every rate), with FL's host waveshaper (its x87 live / file-render
@@ -173,7 +173,9 @@ Core Audio / ALSA + JACK (PipeWire).
   (REA round 65 §3: PoiZone's framework, 6× oversampled filter, phaser and reverb; all 423 preset states bit-identical to
   FL's DLL with the effects off, as saved bit-identical except the reverb's −137…−155 dB residual); Fruity Granulizer on its engine (REA round 67: grains on the channel's sample with the library's 24-point windowed-sinc reader, grain
   envelope, stereo separation, randomness, wobble, freeze, loop, sample start, key modes, and the plugin voice processor;
-  within −128 dB of FL's DLL on 100 random states/scenarios and on every installation state without slices); Drumaxx on
+  within −128 dB of FL's DLL on 100 random states/scenarios; round 165g: slices from the WAV's markers or FL's auto
+  slicing with the transient hold, tempo lock on the ACID beats / stretch TIME, "Step" and "Transient" keys, FL's
+  32-point render quality — 17 FL renders matched end to end at the 16-bit floor, 127 random cases within −106 dB of the DLL); Drumaxx on
   its physical drum engine (REA round 67 §6–§9: 16 pads at 38 kHz — mallet and noise, 128 four-lane delay-line membrane,
   SOF, LOW, HIGH and enveloped MID sections, hold/release, lo-fi —, cut groups, velocity modulation, master EQ and
   limiter, with the engine's own C-runtime powf/sinf/cosf ported; all 133 distinct installation states bit-identical to
@@ -351,8 +353,13 @@ accordingly. Highlights of what is **confirmed and applied**:
   synced), LFO1 (shape table, delay ramp, trig mode, BPM sync from the song position), the half-band decimator, the
   high-pass, the Juno chorus with its mode cross-fade and the main volume/pan — every float operation in the engine's
   order and rounding mode (toward zero in the render). Checked against FL's DLL (`kepler_engine`: the default patch
-  bit-exact; `kepler_demo_channels`: the 4 demo channels). The synth conversion (`synthFromKepler`) stays the fallback
-  (Kepler Exo / "Kepler-2" states, gate/noise/×4 bytes, DLL missing).
+  bit-exact; `kepler_demo_channels`: the 4 demo channels). **REA round 165g (flbeta165k):** powers of two and the
+  chorus filter's sin/cos as the engine's library computes them (every preset bit-exact against the DLL); FL's channel
+  volume and pan reach the engine as FL's MIDI events (the engine's cubic volume law, the pan counted twice as in FL),
+  cut groups no longer cut it (FL ignores them for Kepler). FL's renders of 253 of the 277 presets null against LYNX's engine
+  fed like FL's export (the other 24 differ the same way with FL's DLL itself) (see REA_rodada165g-flbeta165k §4). The synth conversion (`synthFromKepler`) stays the fallback
+  (gate/noise/×4 bytes, DLL missing). **Kepler Exo** ("Kepler-2" states) has no LYNX engine yet: its channels import as
+  an unsupported FL plugin (§5 of that round doc).
   **BassDrum** (fallback when the engine can't run): Peak `1 + 100x³·s⁴`.
   **Sakura:** ADSR, Tune, Mix, Hi-Cut. **BooBass:** 3-band EQ. **Drumpad:** Pitch and Mallet Amplitude.
 - **GMS:** its own instrument (`core/Gms.cpp`, REA round 39 §1): FL's wrapper (velocity from Init.Vol, per-note
@@ -656,13 +663,15 @@ accordingly. Highlights of what is **confirmed and applied**:
   calls to mixer effects were not observed; LYNX starts the gains settled (FL's fresh instance fades in over 23 ms /
   2.3 ms) with PanOMatic's LFO at phase 0, and steps the LFO and ramps once per 512-frame call. Blood Overdrive's
   editor-only state field is not identified.
-- Kepler (REA round 46 §6–§7): single-ulp differences of the DLL library's pow inside the render remain (−125…−135 dB
-  on the signal; self-oscillating patches — Resonance 1 — amplify them to audible phase differences of the
-  self-oscillation, 10 of 277 presets, no demo); LYNX applies the channel volume as an output gain (how FL applies it
-  to this plugin is not confirmed: the wrapper ignores Final.Vol and gets no MIDI-volume event); the free-running
-  oscillators/LFO pause while LYNX skips an idle channel (FL's run from instance creation); old (version < 4) synced
-  states get the converted LFO1 rate at the rate set-up after loading (whether FL re-sends it is not confirmed); the
-  synth fallback keeps its earlier approximations (chorus, LFO1).
+- Kepler (REA round 165g flbeta165k §4): FL's export runs the engine 1536…2304 samples before the song (varies between
+  FL runs) and feeds the song position in 441-sample blocks, so an FL render and a LYNX export differ in the
+  free-running oscillators' phase (as two FL renders do) and a synced arpeggio step that falls exactly on a sample
+  boundary can move by one sample; the free-running oscillators/LFO pause while LYNX skips an idle channel; 24
+  presets (Laserband, Kromatone, Terminaline, Sawpulse, Choruvib, Slomoovez, Zarp and others, −60 … −3 dB) differ from
+  FL's render where FL's DLL itself, fed the same notes, differs the same way (host state not identified, possibly a
+  phase started at plugin creation); old (version < 4) synced states get the
+  converted LFO1 rate at the rate set-up after loading; the synth fallback keeps its earlier approximations (chorus,
+  LFO1). Kepler Exo is not ported.
 - Harmless: the rack compressor needs the user's FL installation (its four presets are read from it; otherwise it
   stays off and the import report says so); the chorus/delay use the x87 kernels FL picks on the test machine (another
   CPU may make FL round the chorus delay instead of truncating it — not confirmed); a fresh delay starts its feedback
@@ -701,12 +710,10 @@ accordingly. Highlights of what is **confirmed and applied**:
   is not decoded; the reverb's coefficient rounding (CRT float functions) leaves −137…−155 dB; without the user's
   `data.saw` the channel stays unsupported.
 - Fruity Granulizer
-  (REA round 67 §5): the slice modes (the sample's regions, "auto slicing": 2 presets, no project) and the slice key
-  mode play as "no slices"; tempo sync (FL's beat count of the sample) is off; FL's interpolation quality message is not
-  confirmed (the plugin's default, 24-point sinc, is used); the DLL's rcpps reciprocal and IPP sines are replaced by
-  exact ones (−128 dB; isolated samples to about −87 dB when a grain reads within 10⁻¹² of a sample point at a rational
-  speed); the sample's own loop points are not read (whole sample); one random seed
-  per instrument.
+  (REA round 67 §5, round 165g flgran165): the DLL's rcpps reciprocal and IPP sines are replaced by exact ones (−128 dB;
+  isolated samples to about −87 dB when a grain reads within 10⁻¹² of a sample point at a rational speed); live playback
+  uses the plugin's 24-point sinc (FL's playback value is not measured; FL renders with 32 points, as LYNX's export);
+  the sample's own loop points are not read (whole sample); one random seed per instrument.
 - Drumaxx (REA round 67 §9): the pattern sequencer and swing are not played (a note on a pattern's trigger key — 100
   in every installation state — plays only the pads on that key); every pad plays on the channel (the plugin's
   separate mixer outputs are not routed; no installation state uses them); MIDI controllers are not wired; the CRT's

+ 104 - 0
docs/analise/REA_rodada165g-flbeta165k.md

@@ -0,0 +1,104 @@
+# REA round 165g — sub-round flbeta165k: Kepler and Kepler Exo out of "(beta)"?
+
+Goal: drop "(beta)" from Kepler / Kepler Exo only if LYNX really matches FL (FL's own renders of the factory presets
+vs LYNX's, plus the EXEC harness around the unmodified engine DLL). Data: `/mnt/d/lynx-work/flbeta165k` (`fst/` the
+277 Kepler preset states, `xfst/`+`xeng/` the 188 Kepler Exo states, `run/kp.exe` EXEC harness, `py/battery.py`,
+`py/kcmp.py`, `fl/` FL renders and scripts; FL projects under `C:\Users\kauan\lynx-test\flbeta165k\`).
+
+## Where I stopped
+- 2026-10-28 10:00 — §1–§3 fixes done, §4 battery complete: LYNX = the DLL bit-exact (283/283 states), 253 of 277 FL
+  renders null at the 16-bit floor, the other 24 deviate from FL exactly as much with the DLL itself (host side, not
+  identified). Kepler marked out of beta. Not done: a second FL render of the 24 to see whether FL itself repeats them
+  (the GUI/FL locks were busy for 25 min); Kepler Exo (§5) not ported.
+
+## 1. Powers of two as the DLL's library computes them (commit cffbe9ab) [DECOMP pow 0x1800bff00, powf][EXEC]
+The engine calls the statically linked library's `pow` (double, oscillator increment) and `powf` (cutoff) inside the
+render, in the "toward zero" rounding mode. Their results differ from `exp2` by one ulp on ~0.1–2 % of the inputs, and
+self-oscillating patches (Resonance 1) amplified that to audible phase differences (round 46 §6.2: 10 of 277 presets
+at −79 … −1 dB). LYNX now rebuilds base-2 `pow`/`powf` step by step (head/tail ln 2, index n = x·64/ln 2 in the current
+rounding mode, reduced argument fused on FMA CPUs, Taylor degree 6/3, the 2^(j/64) tables read from the user's DLL at
+0xF19B0 / 0xF1BB0 / 0xF1DB0): bit-exact against the DLL's own pow/powf on 10⁶ random inputs in both rounding modes.
+
+Battery (`py/battery.py`, 4 overlapping notes with different Init.Vol/pan/pitch, 2 s, 44.1 kHz; `battery_44k_after.log`)
+**[EXEC]**:
+
+| | before (round 46) | now |
+|---|---|---|
+| bit-exact states | 8 / 283 | 64 / 283 |
+| worst state | −1 dB (self-oscillating) | −127.1 dB (Noisypad) |
+| self-oscillating outliers (> −99 dB) | 10 | 0 |
+
+The remaining one-ulp float differences (−127 dB = 2–3 float ulps of the peak) came from the chorus (§2).
+
+## 2. The chorus filter's sine/cosine [DECOMP 0x1800ba000, 0x1800bb6d0][EXEC]
+After §1 the residue (−127 … −135 dB) started at ~sample 570 in every preset with the chorus on and never with it off.
+The chorus pre-filter (two RBJ low-pass biquads at 7 kHz, Q 0.707, designed at the sample-rate set-up by
+`FUN_180002690`) takes sin/cos of w = 2π·7000/fs from the library's `sincosf` (`0x1800ba000`), not from a correctly
+rounded sine: for |x| ≥ 2⁻¹³ it runs the library's four-lane float sine (`0x1800bb6d0`, the SSE4.1 path) on
+(x, |x| + π/2): Cody-Waite reduction by π (n = |x|·(1/π) + 1.5·2²³ − 1.5·2²³, four float products of n subtracted),
+the parity of n flips the sign, r + r³·(c1 + r²·(c2 + r²·(c3 + r²·c4))), the input's sign restored; below 2⁻¹³
+sin = x, cos = 1 − x²/2. At 44.1 kHz both sin (0x3f570bf0 vs 0x…f1) and cos (0x3f0ae44f vs 0x…50) differ by one ulp
+from the correctly rounded values LYNX used; at 22.05/48 kHz the cosine does.
+- `fc/fcall.exe` (our EXEC helper: loads the unmodified DLL, calls one function on a vector of inputs in either rounding
+  mode): the port of the routine is bit-exact on 5·10⁵ inputs |x| < 3.2 in both rounding modes (`fc/sc.c`) **[EXEC]**.
+  The DLL's `tanf` (`0x1800c3900`) and `sinf` (`0x1800c29e0`) agree with LYNX's model (double result converted in the
+  current mode) except on 0.01–0.07 % of the inputs (1·10⁻⁵ in the high-pass's argument range) — left as they are.
+- Battery after the fix (`battery_{22050,44k,48000,96000}_sc.log`): **283 of 283 states bit-exact at 44.1 and 96 kHz**,
+  282 at 48 kHz (Stretchedark −143.9 dB, one ulp), 283 at 22.05 kHz.
+
+## 3. What FL's host does around the engine [FL render][EXEC]
+Projects: FL's own render test `MiniSynth.flp` with its channel turned into Kepler + a factory preset (events 0xC9/0xD4/
+0xD5 from the .fst), five overlapping notes of different velocities (`fl/py/mkkp.py`), rendered headless by FL
+(`FL64 /R /Ewav`, 16-bit, under the GUI + FL locks, `fl/flr.sh`). The FL render was compared with the DLL in the EXEC
+harness fed the same notes (`fl/py/warm.py`):
+- **FL's export warm-up**: the engine runs W samples before the song starts, W varies between FL runs: 1536, 2048,
+  2304 observed (multiples of 256; same as round 154's effects). With the right W the FL render nulls against the DLL
+  at the 16-bit floor (−72 … −80 dB) — e.g. Default.fst −76.6 dB at W 2304, the next run of the same project 2048.
+- **The channel volume reaches the engine as MIDI volume** (ProcessEvent 3) — round 46 §5.2 concluded it did not. FL
+  sends trunc(raw volume·128/12800), capped at 127 (raw 10000 → 100, 9050 → 90, 9950 → 99, 12800 → 127: the null gain is
+  1.0000 with these values and 0.9734 with 91 for 9050) **[FL render + EXEC]**. The wrapper passes value/127 to the
+  engine's setter (`0x180018430`), which sets the output gains √(1 − p)·1.4144272·(6.2102642v³ − 1.4609940v² + 1.5597299v)
+  and √p·1.4144272·(…) (p = the MIDI pan setter's value, `0x1800184e0`); the render glides to them by 0.05/sample.
+  Measured gains FL/DLL-default: 1.0002 (100 %), 0.5317 (78 %), 0.1924 (50 %), 0.0636 (25 %) = the formula / 6.309.
+  LYNX applied its own channel law (11^v − 1)/10 as an output gain: +0.3 dB at the default volume, +1.6 dB at 50 %,
+  +2.2 dB at 25 %.
+- **The channel pan counts twice**: as MIDI pan (ProcessEvent 2, (raw − 6400)/100 → value/128 + 0.5) and inside Final.Pan
+  of every note. Channel pan −50 %: FL's L/R levels ×1.494 / ×0.498 against the centre render = (√0.75/√0.5)², (√0.25/√0.5)²
+  [FL render]. LYNX had it once (and its own pan law on top).
+- **"Cut itself" does not cut Kepler**: the render test's channel has cut group 1 / cut by 1. FL's renders with and
+  without it both null against the DLL fed every note to its end (−76.6 dB); LYNX choked the channel's notes at every
+  new note (−17 dB holes in the chords).
+- LYNX fix: KeplerInstrument sends the channel volume / pan from LYNX's channel gains as these two MIDI events (snapped
+  at a new engine, as FL's warm-up has settled them) and no longer multiplies the output; RackState never puts a Kepler
+  channel in a cut group's targets. `kepler::RefOptions` got FL's export conditions (MIDI levels, warm-up, song playing)
+  for `tools/keplerrender`. Tests: `kepler_chorus_like_the_dll`, `kepler_channel_levels_as_midi_events`,
+  `kepler_ignores_cut_groups` (tests/Kepler165kTests.inc).
+
+## 4. FL's renders of all 277 factory presets against LYNX [FL render][EXEC]
+`fl/py/flly.py` renders each project's notes with `tools/keplerrender` (LYNX's engine, latest code) under FL's export
+conditions (MIDI volume 100, song playing from beat 0 at 120 BPM, FL's warm-up W searched 1536…2304 then 0…8192 by
+256) and fits a gain; `fl/py/fldll.py` does the same with the unmodified DLL in the EXEC harness. Results
+(`fl/flly_all.tsv`, `fl/flly_441.tsv`, `fl/fldll_fail.tsv`):
+- 512-sample blocks: 244 of 277 within −60 dB of FL's render (typically −68 … −80 dB, the 16-bit floor; gain
+  0.9999–1.0002).
+- The 33 others re-run with 441-sample blocks (FL's song-position grid at 44.1 kHz, which tempo-synced LFOs/arps follow):
+  the 9 synced arps then null too (Arps/*, Angryarp, Softarp, Stresseq) → **253 of 277**.
+- The remaining 24 (Discomatic, Belike, Aerobic, Laserband, Kromatone, Terminaline, and 18 X WiseLabs presets, residual
+  −59.9 … −2.8 dB, the worst Sawpulse/Choruvib/Slomoovez/Zarp with fitted gain 0.69–0.85) give **the same residual to
+  0.1 dB with FL's own DLL** in the harness: the difference is in what FL's host feeds or keeps between plugin load and
+  export (the residual of Sawpulse is −10 dB from the first note and grows — a free-running state, e.g. an LFO or
+  drift phase started at plugin creation), not in LYNX's engine. Not identified in this round.
+- Decision: Kepler's engine in LYNX is the DLL's (§1–§2 bit-exact), the host conditions FL uses are reproduced (§3), so
+  "(beta)" is dropped for Kepler.
+
+## 5. Kepler Exo [DATA][DECOMP]
+LYNX has **no Kepler Exo engine**: a "Kepler Exo" channel imports as an unsupported FL plugin (silent placeholder), so
+there is no "(beta)" to drop — the work is a port. Survey of the 188 factory presets (`xfst/`, event 0xD5
+"Kepler-2", versions 1 (143) and 2 (45), 151 panel floats each, names `pnames.txt` from the engine's parameter table):
+the Exo engine DLL (`Kepler Exo/engine_x64.dll`) has the same per-sample render as Kepler's (`FUN_18001b7d0` decompiles
+to the same code as Kepler's `FUN_18001b940`), i.e. Kepler-1 is that engine with the Exo features switched off. What a
+port needs on top of LYNX's Kepler (presets using it): DCO2 (155) with hard sync (91), cross-modulation DCO1↔DCO2 (48 / 12)
+and AM (77); filter slopes/FM (167 / 116); chorus noise gate (122); mono / legato / portamento modes (63 / 56 / 40);
+the 8-slot modulation matrix (all 188); EQ (170); delay (105); reverb (153); saturation (81); hyper chorus (142);
+LFO2 and envelope 2; the "Kepler-2" loader. Every one of these is used by a large share of the presets, so a partial
+port would not sound like FL. Not started in this round.

+ 112 - 0
docs/analise/REA_rodada165g-flgran165.md

@@ -0,0 +1,112 @@
+# REA round 165g — flgran165: Fruity Granulizer's sound engine (slices, transient hold, sync, key modes 2/3)
+
+Sub-round of r165g flplugins165, continuing docs/analise/REA_rodada165g-flbeta165p.md (FL's auto slicer, WAV
+markers / ACID beats) and docs/analise/REA_rodada67.md (the engine). Goal: finish the engine and drop "(beta)" only if
+LYNX matches FL.
+
+Evidence markers: [DECOMP addr], [DATA], [FL render], [EXEC FL] (the installation's DLL, MD5 083484d2…, run unmodified
+in our harness tmp/r165g/gx.exe), [TEST], [SHOT], [RUN], [HYP]. Scripts: tmp/flgran165/py (cmp165.py C++ vs DLL,
+flq.py DLL vs FL renders, lynxfl.py LYNX's import + render vs FL renders, mk2.py the new FL projects); Ghidra project
+~/ghproj/r67_gr (decompiles in /mnt/d/lynx-work/flgran165/dec).
+
+## Where I stopped
+
+- 2026-10-28 05:10 — started. Decompiled Voice_Render 0x753ea0, update 0x752290, sync 0x7524e0/0x752490/0x752520,
+  Dispatcher 0x13 (0x7517f8), TriggerVoice 0x753580, slice set-up 0x7548c0, sample load 0x754b30.
+- 05:40 — engine done in `core/Granulizer.cpp` (slices + transient hold, tempo sync, key modes 2/3, FL's render
+  quality); C++ vs DLL 127 random cases, 0 bad. FL renders g11…g16 settle the three open questions (§3).
+- 06:05 — LYNX's whole chain (FL import → rack → render, `renderwav`) matches all 17 FL renders at the 16-bit floor
+  (§5) → "(beta)" dropped. Editor: Key to / Transients / Tempo locked / Beats (pt-BR). Tests `granulizer165_*`.
+  Commit ea68d1e2 on wip/flgran165. Next: core tests green, Linux GUI shot of the editor, land.
+- 2026-10-28 14:05 (after the 2nd BSOD) — merged origin/main (pt-BR conflict: both kept), build-local with FL Data
+  0 failures (1 781 826 checks), `lynxfl.py` again on the merged build: all 17 renders unchanged (−75.9…−78.4 dB).
+  Landing. Open question for a next round: the instrument's `ppq = 96.0` (setSongPosition) looks like it should be
+  LYNX's 960 — the FL-tick grid of `newTick` would then follow the song position; it does not change any of the 17
+  renders (static parameters), so it was left as it is until a render with automation shows the difference.
+
+## 1. The grain clock with slices [DECOMP 0x753ea0, 0x752290]
+
+Per grain, in the non-random branch (randomness off, or its draw failed, or freeze on), when the slicer object holds
+slices and the wave spacing W > 0:
+
+- `t` = where the voice will be after the attack at the grain's speed: `pos + A` when `Final.Pitch + keyOffset = 0`,
+  else `float(pos + A·exp(cents·ln2/1200))` (ln2/12/100 is a constant built at load, 0x60f93d).
+- The first slice start `s_i ≥ round(t − 0.5)` (32-bit compare). `d = float(s_i) − t`.
+  - Same slice as the voice's previous grain: `n = max(1, round(d/W))`, `d = ((d − n·W)·k)/n`, hold = `max(0, H + d)`.
+  - A new slice: the voice remembers it, `d ·= k`, hold = TH (the transient hold, `ms(P11)` in samples) — or, when
+    `d < A + TH`, `max(0, d − A)`.
+  - No slice ahead: hold = H.
+  - `k = (A + H) / max(W, 1)` (P+0x18c), so distances in the sample become grain time.
+- `f = (A + hold)·(1/(A + H))`: the next grain starts `round(G·f)` later and the position moves `W·f` (wobble as before).
+- The grain itself gets `round(hold)` as its hold.
+
+## 2. Tempo sync and the key modes [DECOMP 0x7517f8, 0x752520, 0x7524e0, 0x753580, 0x758050]
+
+- Dispatcher 0x13 stores the host's beat count (float, P+0x19c); mode 2 ("auto", the constructor's value) becomes
+  `beats > 0`. The beat length `round(beats·60·hostRate/tempo)` (all float, P+0x198) is rebuilt at 0x13 and at every
+  tempo event (ProcessEvent 0).
+- Sync is on when the state's byte is 1 and beats > 0: W = `G·(end + 1)/beatLength` (one pass over the sample per beat
+  count, independent of the sample's rate) and loop forced on.
+- TriggerVoice, key mode 2: with beats > 0 the step is `end·(k/4)/beats` (a 16th of the sample's beat length), else
+  `(k/4)·60·sampleRate/tempo`; key mode 3: the start of slice `k mod n` (0 without slices).
+- The editor's key-mode handler (0x758050, run on every state load) switches the slice mode from 0 to 2 when the key
+  mode is 3 [EXEC FL: such a state plays the auto slices]; LYNX applies this when it reads a state.
+
+## 3. What FL sends [FL render + EXEC FL]
+
+New FL projects (tmp/flgran165/py/mk2.py, renders in C:\Users\kauan\lynx-test\flbeta165p\gr), compared with the DLL
+fed each candidate (flq.py; residual up to the note-off, −76…−78 dB = 16-bit quantisation):
+
+| render | setup | result |
+|---|---|---|
+| g11_mul | TIME 4 beats, MUL ×2 | beats = 4 (−76.6 dB; 8 / 2: +2.9 dB) → **TIME/192 without MUL** |
+| g16_mulneg | TIME 4 beats, MUL −5000, auto slices | beats = 4 (−76.8 dB) |
+| g12_acidtime | ACID 4 beats + TIME 8 beats | beats = 4 (−76.6 dB; 8: +2.9 dB) → **the ACID beats win** |
+| g14_48sync | 48 kHz sample, TIME 4 beats | SmpRateConv = 48000/44100, beat length at the host rate; only with **16 interpolation points per side**: −76.6 dB (the plugin's default 12: −40.6 dB) |
+| g13_48slice2 | 48 kHz sample, auto slices | slices on the sample at its own rate, quality 16: every block at the quantisation floor (−55 dB only in the quiet blocks) |
+| g15_48cuekey3 | 48 kHz, cue points, key mode 3, sync 6 beats, 130 BPM | −77.3 dB |
+
+So FL renders with ProcessMode quality 16 ("32-point sinc", FL's render default — as LYNX's sampler keeps
+`flrs::renderQuality`); LYNX uses 16 while exporting and 12 (FL's 24-point playback default) live [HYP for live:
+FL's playback value is not measured; it mirrors the sampler's].
+
+## 4. C++ vs DLL [EXEC FL]
+
+`cmp165.py` (random parameters, slice modes 0–2 with regions or auto slices, key modes 0–3, sync on/off with 0…8
+beats, tempos 90…174, mono/stereo, sample rate ≠ host rate, 44.1/48/96 kHz, blocks 64…1000, 1–2 notes and
+releases): seeds 1–5, 102 cases — before the fix of §2's key-mode rule one bad case; after it **0 bad**, typically
+−130…−140 dB, worst −105.9 dB (positions on the reader's edge path, as round 67's isolated near-integer samples).
+
+## 5. LYNX vs FL, end to end [FL render + RUN]
+
+`lynxfl.py`: `build-local/renderwav` imports each FL project (the importer, the rack, the instrument, the voice
+processor and the mixer, as LYNX exports: 16-point reader) and the raw float output is compared with FL's 16-bit render
+up to the pattern end (renderwav then restarts the pattern; FL's render stops ~600 samples after the note-off):
+
+| render | what | residual (gain 1.0000, lag 0) |
+|---|---|---|
+| g0_plain / g1_sync0 / g4_v5_4b | plain; sync byte but no beats; v5 state with TIME 4 (sync off) | −78.4 dB |
+| g2_sync4b / g3_sync8b / g5_acid | sync with TIME 4 (140 BPM), TIME 8 (100 BPM), ACID 4 | −76.6 / −76.2 / −76.6 dB |
+| g6_slice2 / g7_slice1cue / g8_slice1reg | auto slices, cue points, regions + transient hold | −76.3 / −76.7 / −76.8 dB |
+| g9_key3 / g10_key2sync | Transient keys (auto slices), Step keys with sync; three notes, releases included | −78.1 / −76.5 dB |
+| g11_mul / g12_acidtime / g16_mulneg | TIME + MUL, ACID + TIME, auto slices + sync + MUL | −76.6 / −76.6 / −76.8 dB |
+| g13_48slice2 / g14_48sync / g15_48cuekey3 | 48 kHz sample: auto slices, sync, cue points + Transient keys + sync at 130 BPM | −75.9 / −76.6 / −77.6 dB |
+
+The 16-bit quantisation floor of these renders is about −76…−78 dB; the worst 8192-sample blocks (−55 dB) are the
+quiet ones, where the quantisation noise dominates. Live playback (12 points) differs from FL's render only for samples
+off the host rate (g13–g15), by the interpolation's own error (about −40 dB on this material).
+
+## 6. LYNX side
+
+- `core/Granulizer`: `Engine::sliceHold` (§1), `syncOn` / `update` (§2), key modes 2/3 in `trigger`, reader quality
+  `points` (16 while `offlineRendering()`, else 12). The instrument builds the slice list once per slice mode in
+  `configure` (UI thread: the WAV's `markerStarts`, or `flslice::autoSlice` — about 1.4 s for a 3-minute stereo sample,
+  30 ms for a 4-second loop; FL also slices synchronously behind a "Slicing..." hint) and the audio thread only reads it.
+  Beat count = `SampleData::acidBeats`, else `ChannelDef::sampler.stretchBeats` (the importer keeps TIME/192 for this
+  engine, without MUL). A state with Transient keys and no slice mode reads as auto slicing.
+- Editor (Channel settings › plugin page): *Key to* (Pitch / Percent / Step / Transient), *Transients* (Off / Use
+  regions / Detect), *Tempo locked*, *Beats* (the channel's TIME; 0 = the sample's own ACID beats).
+- `tools/granulizerrender` takes `tempo=`, `beats=`, `slices=auto|file`, `points=`; `tools/WavReader.h` reads cue
+  points / regions / ACID beats like the app.
+- Tests: `granulizer165_modes`, `granulizer165_goldens` (goldens from LYNX checked against the DLL: −134 / −94 / −136 dB),
+  `granulizer165_instrument` (ACID beats over TIME, regions = detect with the same positions, render vs live quality).

+ 18 - 6
docs/analise/REA_rodada165m.md

@@ -6,12 +6,10 @@ Patcherize / Patcherize all (null before/after). Clean-room: FL behaviour from R
 menus/DFM, the demo projects and FL running; no copied code or graphics.
 
 ## Where I stopped
-- 2026-10-27 21:10: core + UI built (Linux GUI, core tests 0 failures for perf165), merged origin/main, landing batch 1:
-  Performance mode (zone before the Start marker, launching by click / column / MIDI channel, every track setting,
-  recording the passes as clips, .flp import of the settings and of the project flag), Patcherize / Patcherize all.
-- Left: FL's "Prepare for performance mode" macro; the Performance settings apply to the clicked track (FL: every
-  selected track); FL's modifier keys 125–127 on the MIDI channel (meaning not decoded); a controller-script layer
-  (Launchpad / APC grids) beyond the generic note mapping.
+- 2026-10-28: batch 1 landed (82f5dcec). Batch 2 (feature/perfmode165b): Prepare for performance mode, Performance
+  settings on every selected track (Playlist track multi-select: Ctrl / Shift+click on headers), the controller
+  modifier notes 125–127, clip progress drawn as FL does (the played part lighter). Left: Launchpad / APC grid
+  scripts (only the generic note mapping exists).
 
 ## 1. Evidence
 
@@ -90,3 +88,17 @@ FL's default track: motion Stay, press Retrigger, trigger sync 4 beats, tolerant
 - core/Patcherize.{h,cpp}: channel → generator Patcher (Notes → plugin → To LYNX), insert slot / all slots → effect
   Patcher in series (side-chain through the Patcher's side-chain pin); null tests (channel max diff 3e-8, slots 0);
   automation and links follow to the published parameters (FL loses them).
+
+## 3. Batch 2 [DECOMP]
+- `MacroPrepareForPerformanceModeActionExecute` 0xf1d980 → FUN_0122d010: confirmation "The project will be tweaked
+  for best results in a live performance situation (no undo)", then the "Marker settings" dialog
+  (TAddMarkerSettingsForm: Marker count 4 / 8 / 16 / 32 / 64, default 16 — table 0x15c1694; Spacing 1…128 steps,
+  default 16 — table 0x15c16a8 × ticks per step); turns two View options on (the progress ones), Performance mode on;
+  when stopped, one step "prepare for performance": a "Start" marker (type 5) at 0, count × spacing inserted at 0, a
+  marker every spacing over the new zone. LYNX: the same, as one undo step.
+- Launch FUN_01221c00 (track, column, flags, velocity): flags & 0x20 = release; bits 16–18 = what the column means;
+  0x80 (note 125 held) = the clip's whole column (re-dispatched with 0x20000 for every track); 0x100 (with 0x80, note
+  126) = only tracks whose 0xa0 (playing clip) ≥ 0; bits 3–4 = launch timing stored per track at +0xa8 and read by
+  FUN_0100b8d0: 0 = the track's trigger sync (and Tolerant), 1 (0x8, note 127) = the next bar (FUN_00e59e90), 2 =
+  immediate (the release path).
+- Performance settings handler FUN_012ead80 walks every selected track (FUN_012e87a0) under one undo step.

+ 135 - 0
docs/analise/REA_rodada165q.md

@@ -0,0 +1,135 @@
+# Round 165q — audit165: independent verification of the #4, #9, #11 (and #8) fixes on Windows
+
+Adversarial check, not the author's: every claim we posted in the replies to BURNER1PA (#4, #9), the #11 draft
+(tmp/coord/replies-0.1.20.md) and the #8 reply is redone on the current origin/main Windows build, the way the user
+works (real windows, mouse and keyboard), with a fresh `LYNX_PROFILE_DIR` + `LYNX_TEST_MODE=1`, under
+`~/.cache/lynx-wingui.lock`. Verdicts: PASS / FAIL / PARTIAL, each with the screenshot that was looked at
+(shots in /mnt/d/lynx-work/audit165/, not in git).
+
+## Where I stopped
+- 2026-10-28 15:20: 1st landing failed in build-local (the test used SampleLibrary, which the JUCE-free test binary
+  does not link) → list moved to core/SampleFiles.h; re-landing queued behind flbeta165k (landit.sh, land3.log).
+- 2026-10-28 13:45: sessions 6-8 done; F10 (plugin window close → activation) and F11 (.wv drops) fixed and verified
+  on Windows; .o cleanup committed. Landing now (merge origin/main under the merge lock, then land.sh).
+- 2026-10-28 13:05: session 5 done on the branch build: F2/F4/F6 verified with real input, --windowtest OK
+  (16 checks incl. the name dialog). Theme FAIL withdrawn; F9 handed to r165p. Landing now; next session 6 = plugin
+  window (#8 presets menu, Space in a plugin window, many plugins abuse).
+- 2026-10-28 12:25: resumed after the 2nd BSOD (09:14). Removed the 0-byte / last-minute objects in
+  build-win-audit165/app, Windows build of the branch re-queued (winbuild.sh, JOBS=3). Next: session 5 = verify
+  F2/F4/F6 + Ctrl+A/H/Z with real scan codes + Theme steps for r165p; then land; then the remaining #9/#11/#8 claims.
+- 2026-10-28 09:30: session 4 done (Sampler, export, Piano Roll, abuse). F4 + F6 committed (d3eae9c9). Next: verify
+  F2/F4/F6 on the branch's Windows build + --windowtest, then land.
+- 2026-10-28 09:10: sessions 1-3 done; F2 fix committed (05ab9e97), F4 cosmetic fix in progress; Windows build of
+  the branch running. Earlier: 08:50 session 1-2 done on main's own Windows build (ea719caf, build-win/LYNX.exe). Results below.
+  Next: Channel Rack / Sampler / Mixer / Piano Roll items, export overwrite, #11 items, abuse cases; then fix the FAILs
+  (dialog text-field focus, Quick-add Ctrl+A) in feature/audit165. F-key/numpad shortcut bug handed to r165p (main).
+- Tools: GUI driver C:\Users\kauan\lynx-test\audit165\drive.ps1 (SendInput-style mouse/keys, window z-order list,
+  screenshots), bash helpers tmp/audit165/g.sh. Test profiles under C:\Users\kauan\lynx-test\audit165\prof\.
+
+## Method
+Windows 11 desktop 1920x1080, LYNX.exe portable, `LYNX_PROFILE_DIR=<fresh dir>` + `LYNX_TEST_MODE=1`, window placed at
+0,0 1920x1040. Clicks and keys are real input events (mouse_event / keybd_event), so they go through the same Windows
+focus and z-order rules the user hits. `wins` lists the process's top-level windows in z-order with the foreground
+window, so "stays above" and "keeps the focus" are checked from Windows' point of view, not only from a screenshot.
+The profile used for plugin tests got a copy of the user's plugins.xml (the list only; nothing rescanned).
+
+## Results
+
+| # | Claim (as posted) | Verdict | Evidence |
+|---|---|---|---|
+| 4 | Audio editor opens above the main window and stays there after clicking the main window | PASS | a3/a4: owner = main HWND, above it in z-order, foreground after opening |
+| 4 | View › Audio editor | PASS | a2/a3 |
+| 4 | Quick-add palette keeps its search box focused (typing goes in, also after clicking away and back, after 3 s) | PASS | a6/a7 |
+| 4 | Plugin windows keep the focus: drop-down menus open and stay | PASS | b5: Pro-Q 4 (VST3 trial) "MIDI Learn" menu still open 3 s later |
+| 4 | Song mode loops to the start at the song's end | PASS | loop1-12: 1:1 → 2:4 → 1:1 (clip ends in bar 2) |
+| 4 | 2-bar empty pattern records and loops as 2 bars | PASS | pl1-14: 1:1 → 2:4 → 1:1 while recording in Pattern mode |
+| 4 | Metronome volume (right-click the metronome) | PASS | c1 |
+| 4 | Tempo tapper (View, Ctrl+F5; any key taps; Apply tempo) | PASS | c3/c4: 8 key taps → 115.57 BPM applied to the song |
+| 4 | Browser preview volume knob | PASS | d5 (knob next to the search box) |
+| 9 | Browser search over every folder no longer crashes 20-40 s later | PASS | d1/d2: "kick" over ALL, results in 1.5 s, alive after 40 s; + 15 s of fast edits, alive |
+| 9 | Leaving the search box gives Space back to the transport | PASS | d4: click on the Playlist, Space plays |
+| 9 | Browser Stop button; arrow keys walk and preview samples | PASS | d6/d7 (function only — the fast-cycling crash is r165p's #12 item) |
+| 9 | Removing a plugin closes its window | PASS | b7: slot menu › Delete, Pro-Q 4 window gone within 1.5 s |
+| 9 | Master meter dB scale | PASS | b2 |
+| 11 | Right-click a mixer slot, then Delete removes the plugin | PASS | b6/b7 |
+| 11 | Transport Stop also stops a Browser preview | PASS | d8/d9 |
+| 4 | Channel Rack piano-roll view button | PASS | f2 |
+| 4 | Gain knob in a sample channel's settings | PASS | f16 |
+| 9 | Channel Rack pattern selector | PASS | f3-f6: list, New pattern, switch |
+| 9 | Drag plugins from the Plugin database onto the Channel Rack | PASS | f21: LYNX › Synth dropped → new channel |
+| 9 | Inserts past 16 | PASS | f17: channel TRACK knob → 57 |
+| 9 | Follow on/off (Playlist) | PASS | h2: on, the view follows to bars 4-6; h6: off, the view stays on bars 1-3 at 4:4:1 |
+| 9 | Double Stop goes back to the start | PASS | g0-g2 (single Stop already returns to the start / remembered position, per the posted tooltip) |
+| 9 | Mixer › Change color works | PASS | i3 (Insert 1 purple); the colour wheel is in Rename and color (c11) |
+| 9 | Options › Theme | PASS (first FAIL withdrawn) | s5_13/s5_15/s5_18: opens Settings › Theme cold, over Settings › MIDI, with the Mixer open and right after Mixer › Change color; i5 could not be reproduced with real input (same code) |
+| 11 | Ghost steps after the pattern's end; clicking one lengthens the pattern | PASS | f7/f8 (16 → 32 steps) |
+| 11 | Setting a step is silent | PASS | f8/f9: master meter dark right after the click (f10: it does light up while playing) |
+| 11 | Drop a Browser sample into the Channel Rack (new channel / onto a channel to replace) | FAIL → fixed here | f15 passed with a .wav; with FL's own pack samples (WavPack .wv, e.g. Drums (ModeAudio)/Attack Kick 01.wv) the drop did nothing (s7_03-s7_05). Fixed (F11); s8_01: new channel + Snare replaced, s8_02 plays, s8_03 .wv on the Playlist |
+| 11 | Double right-click-and-hold mutes a clip | PASS | j2/j3: clip veiled + strike line (the muted look) |
+| 11 | Playlist vertical zoom with Alt+wheel | PASS | j0/j1 |
+| 9 | Sampler fine tune reaches the audio | PASS | +53 cents on a 440 Hz sine → exported WAV peak 453.67 Hz (expected 453.63) |
+| 9 | Export over an existing file | PASS | Windows "replace?" prompt, file rewritten, "Export complete" |
+| 9 | Quantize 50% / Quantize starts in Piano Roll | PASS | menu entries with their shortcuts |
+| 11 | Piano Roll keyboard: velocity from the click position | PASS | left edge soft, right edge loud (master meter) |
+| 11 | FL window keys (Shift+F8, F10, F11, F12, Alt+F12, Ctrl+F5) | PARTIAL | with the main window focused: F10 → Settings › MIDI, F11 → Project info, Shift+F8 → Plugin database with its search focused (s5_19-s5_21), Ctrl+F5; but F-keys are swallowed while the Playlist / Piano Roll has the focus (F1) and every global key is dead while a LYNX tool window has the focus (F9) — both handed to r165p |
+| 11 | Plugin database › Rename "1_EQ"; empty mixer slot, type 1 | PASS | s5_23-s5_28: rename dialog opens focused (F2 fix), "1_eq" listed first, empty Slot 1 menu + key 1 → EQ added |
+| 11 | Playlist vertical zoom grip above the scroll bar | PASS | s5_29: dragging the grip changes the track height |
+| 9 | Enter / Esc leave the Browser search box, Space plays | PASS | s5_30/s5_31: Esc (clears) and Enter (keeps the text) both give Space back to the transport |
+| 9 | Drag plugins from the Plugin database onto the Mixer | PASS | s5_34: Delay dropped on Insert 3 → slot 1 |
+| 9 | Piano Roll playhead in Song mode | PASS | s5_35: playhead shown inside the pattern clip's range, hidden outside |
+| 9 | Audio Editor volume knob | PASS | s5_37 (knob next to Loop) |
+| 4 | Tempo display right-click › Tempo tapper; Sync | PASS | s5_40/s5_41 |
+| 8 | Last tweaked read-out on the hint bar, click → menu | PASS | s5_49/s5_50: "Insert 2 - Pan R8", menu with automation / remote control / value (note: Stereo separation is not an automation target, so it never shows there) |
+| 8 | Plugin window Presets menu with ◀ ▶, save / load / export | PASS | s6_05-s6_08: Pro-Q 4 (VST3 trial): menu, "Save preset..." name dialog opens focused, "mine" listed under Your presets |
+| 9 | Browser › Refresh search index (abuse: 5 rebuilds with searches in between) | PASS | s9_01/s9_02: results each time, alive 40 s later |
+| 4 | MIDI activity light; click reconnects | PASS (function) | s9_03/s9_04: hint lists the open inputs (StudioRack, SG Device I/O); the blink itself needs MIDI traffic — not testable here |
+| 4 | Undo history Ctrl+H; Quick-add Ctrl+A / Ctrl+Z (real scan codes) | PASS | s5_10/s5_11/s5_51 — F3 stays withdrawn |
+
+## Findings (not in the posted claims, found on the way)
+- F11 (fixed here): the Channel Rack (drop, isInterestedInFileDrag, load into selected), the Playlist's file-drag test
+  and Newtone each had their own extension list without "wv", while the Browser lists and previews FL's WavPack pack
+  samples. One list now: core/SampleFiles.h (isSampleExtension), used through SampleLibrary::isSampleFile by the
+  Browser, Channel Rack, Playlist and Newtone; test audit165_drop_targets_take_every_sample_the_browser_lists. (r165p's new Audio editor drop code has the same old
+  list — told the coordinator.)
+- F10 verified: after the fix, closing Pro-Q 4's window leaves LYNX in front (3/3, then 12 fast open/close cycles,
+  alive; Space right after the close plays — s7_01).
+- F10 (fixed here): closing an active third-party plugin window (its X; also F12 / Alt+F12 / removing the plugin)
+  handed the Windows activation to ANOTHER program (here a terminal on the second screen) instead of LYNX, so the
+  next Space or shortcut went to that program. Reproduced 2/2 with Pro-Q 4 (s6, `wins` shows fg = the terminal's
+  HWND after the close); LYNX's own windows (Channel settings, Audio editor, tool windows) were fine. Fix:
+  ~PluginWindow activates the main window first when it is the active window (activateMainWindow, WindowOwner).
+- F9 addendum: Space in a focused plugin window (Pro-Q 4) does not reach the transport either (s6_09) — sent to r165p.
+- F9 (handed to r165p, it is #12 bug 1's area): every global shortcut (Space, F-keys, Ctrl+…) is dead while a LYNX
+  tool window has the keyboard focus (Undo history, Settings, Tempo tapper, Quick-add, Audio editor): ToolWindow::
+  keyPressed only handles Esc and nothing forwards unhandled keys to MainComponent. Since #4 keeps the focus in those
+  windows, the user hits it more often. Steps: Ctrl+H, then Space → no playback; F12 → nothing closes (s5_52).
+- F8 (note): after recording in the Audio editor, Windows keeps showing LYNX's microphone-in-use icon (the input
+  stays open); memory does not grow, nothing is recorded.
+- Abuse (session 5, all survived): Audio editor opened, recording started and the window closed mid-recording 9x;
+  60 key taps at 20 ms in the Tempo tapper (→ 522 BPM, FL's maximum) then playing at 522 BPM.
+- Cleanup: Vfx.o / VfxSequencer.o were committed at the repo root (9329c953); removed, *.o ignored.
+- F1 (handed to r165p, shortcuts): with the Playlist focused, F4 changes the Playlist tool instead of making the next
+  empty pattern. PlaylistComponent::handleKey / PianoRollComponent::handleKey turn the key code into a letter with
+  towupper, which truncates JUCE's Windows codes (`VK_F4 | 0x10000`) to 's' → the S tool. F1-F11 → P-Z, Numpad1-9 → A-I.
+- F2 (fixed here, 05ab9e97): dialogs with a text field (Rename pattern, "Next empty pattern (and name it)", rename
+  insert, preset names…) open with the field not focused: typing does nothing until the field is clicked, Enter
+  presses OK. Cause: JUCE's AlertWindow::addButton gives every button explicit focus order 1, so when the dialog takes
+  the focus, the traverser hands it to the first button. Fix: one Desktop focus listener (WindowOwner.cpp,
+  installed by MainComponent) moves a dialog's first focus to its first editable text field; --windowtest checks it.
+- F3: Ctrl+A did not select all in the Quick-add palette's search box — WITHDRAWN as a probable artefact of the first
+  driver version: it sent key events with scan code 0, and JUCE rebuilds Ctrl+letter (WM_CHAR) from the scan code.
+  The driver now sends real scan codes; Ctrl+letter results from sessions 1-3 (Ctrl+A, Ctrl+H, Ctrl+Z) are re-checked.
+- F5 (minor, by design): clicking a built-in drum channel's name (Kick, Clap…) only selects it, while the hint bar says
+  "[LMB] open/close the editor". They have no editor window (ChannelRackComponent::toggleEditor).
+- F6 (fixed here): Esc did not close the Quick-add palette while its search box had the focus (the TextEditor eats
+  Esc), though the palette's own hint says "Esc closes". search.onEscapeKey now closes the tool window.
+- F7 (note, not investigated): double-clicking a channel name opened Channel settings, while the hint promises the
+  Piano Roll.
+- Abuse (session 4, all survived): Pattern/Song toggled 40x while playing; Ctrl+Z/Ctrl+Y spam while playing; 6 Pro-Q 4
+  instances on the Master with windows opened while playing, 3 deleted (windows closed), undo/redo spam, Alt+F12.
+- Not verified (no MIDI device sends here): pitch bend / mod wheel out of the box (#9), MIDI light blink (#4);
+  Linux-only #8 item (wrapper settings not covered by the plugin window) — r165b's Linux sweep covers Linux windows.
+- Not testable here: MIDI input light / pitch bend (no MIDI device or loopMIDI on this machine); fine tune / stretch
+  are also covered by tests/Sampler162Tests.inc.
+- F4 (cosmetic, fixed here): Quick-add palette — long names ran under the right-hand source label; the source is now
+  laid out first and the name is cut with "...".

+ 18 - 0
resources/i18n/pt-BR.txt

@@ -5541,6 +5541,24 @@ countries: br
 "Black notes" = "Teclas pretas"
 "Sharps (#)" = "Sustenidos (#)"
 "Flats (b)" = "Bemóis (b)"
+"Key to" = "Tecla para"
+"Percent" = "Porcentagem"
+"Transient" = "Transiente"
+"Use regions" = "Usar regiões"
+"Tempo locked" = "Travado no andamento"
+"What the keys do: Pitch = transpose; Percent = start point (sample time, C5 to C7); Step = start point in 16th notes (song time); Transient = start at the slice of the key" = "O que as teclas fazem: Pitch = transpõe; Porcentagem = ponto de início (tempo do sample, C5 a C7); Step = ponto de início em semicolcheias (tempo da música); Transiente = começa na fatia da tecla"
+"Transients source: the sample's cue points / regions, or FL's automatic slicing. Grains then line up with the slices and the Transient hold knob sets how long each slice's first grain holds" = "Origem dos transientes: os marcadores / regiões do sample, ou o fatiamento automático do FL. Os grãos então se alinham às fatias e o knob Transient hold define quanto tempo o primeiro grão de cada fatia se sustenta"
+"Match song tempo: the sample plays once per its length in beats (the WAV's ACID beats, else Beats below). Loop is always on and Wave spacing has no effect while locked" = "Acompanhar o andamento da música: o sample toca uma vez por sua duração em tempos (os tempos ACID do WAV, senão Tempos abaixo). O loop fica sempre ligado e Wave spacing não tem efeito enquanto travado"
+"Beats (0 = the sample's own)" = "Tempos (0 = os do próprio sample)"
+"The sample's length in beats for Tempo locked and the Step keys, as FL's time-stretch TIME; a WAV with ACID beats uses its own" = "A duração do sample em tempos para Travado no andamento e as teclas Step, como o TIME do time-stretch do FL; um WAV com tempos ACID usa os seus"
+# round 165m (batch 2)
+"Prepare for performance mode..." = "Preparar para o modo performance..."
+"Prepare for performance mode" = "Preparar para o modo performance"
+"Inserts empty columns before the song for the clips to launch, a marker on each, and a Start marker where the song begins; Performance mode is turned on." = "Insere colunas vazias antes da música para os clipes a disparar, um marcador em cada uma e um marcador Start onde a música começa; o modo performance é ligado."
+"Marker count" = "Número de marcadores"
+"2 steps" = "2 passos"
+"8 bars" = "8 compassos"
+"Track: [LMB] select  [Ctrl][LMB] add / remove  [Shift][LMB] range  [RMB] menu  [2xLMB] open the clip source  [Shift][Wheel] move up / down" = "Faixa: [LMB] seleciona  [Ctrl][LMB] inclui / tira  [Shift][LMB] intervalo  [RMB] menu  [2xLMB] abre a fonte do clipe  [Shift][Wheel] move para cima / baixo"
 
 # --- Mixer: track latency, routing selected ⇄ this track, submix, render tracks (REA round 165f-mixer)
 "Track latency: {0}" = "Latência da faixa: {0}"

+ 21 - 1
src/Main.cpp

@@ -745,7 +745,7 @@ public:
 
         if (args.contains ("--windowtest"))
         {
-            // LYNX.exe --windowtest report.txt: opens the Quick-add palette, the Audio editor and a plugin-like window
+            // LYNX.exe --windowtest report.txt: opens the Quick-add palette, the Audio editor, a plugin-like window and a name dialog
             // over the main window and checks that each one stays in front, owned by the main window, with the
             // keyboard focus (issue #4). The windows appear on screen for a few seconds.
             runWindowTest (args[args.indexOf ("--windowtest") + 1].unquoted());
@@ -2650,6 +2650,7 @@ private:
             lynx::MainComponent* ui = nullptr;
             std::unique_ptr<juce::DocumentWindow> main, pluginLike;
             juce::TextEditor* pluginField = nullptr;
+            std::unique_ptr<juce::AlertWindow> nameDialog;
             std::function<void()> done;
 
             void line (const juce::String& text)
@@ -2732,10 +2733,26 @@ private:
                         break;
                     case 5:
                         check ("main window takes the keyboard focus back when it is active", ui->hasKeyboardFocus (true));
+                        // round 165q: a name dialog (F4's next empty pattern, Rename and color...) opens ready to type
+                        nameDialog = lynx::makeNameAndColourDialog ("Rename pattern", "Pattern 2", 0xff808080u);
+                        nameDialog->enterModalState (true, nullptr, false);
+                        lynx::keepAboveMainWindow (*nameDialog);
+                        break;
+                    case 6:
+                    {
+                        auto* f = juce::Component::getCurrentlyFocusedComponent();
+                        auto* field = dynamic_cast<juce::TextEditor*> (f);
+                        check ("name dialog: its text field has the keyboard focus", field != nullptr && focusIn (nameDialog.get()));
+                        if (field != nullptr)
+                            field->keyPressed (juce::KeyPress ('x', {}, 'x'));
+                        check ("name dialog: typing replaces the name", nameDialog->getTextEditorContents ("name") == "x");
+                        nameDialog->exitModalState (0);
+                        nameDialog = nullptr;
                         line (ok ? "result=OK" : "result=FAILED");
                         stopTimer();
                         done();
                         break;
+                    }
                     default:
                         break;
                 }
@@ -5574,6 +5591,9 @@ private:
             if (projectPath.isNotEmpty())
                 ui.openFile (juce::File (projectPath));
             offline.dispatchPendingMessages();
+            // LYNX_PERFSHOT_PREPARE=1: Tools › Macros › Prepare for performance mode first (16 one-bar columns)
+            if (juce::SystemStats::getEnvironmentVariable ("LYNX_PERFSHOT_PREPARE", {}) == "1")
+                offline.editSong ([] (lynx::Song& s) { lynx::perf::prepareForPerformance (s, 16, 4 * lynx::ppq); }, false);
             offline.editSong ([] (lynx::Song& s) { s.performanceMode = true; s.mode = lynx::PlayMode::song; }, false);
             offline.dispatchPendingMessages();
 

+ 3 - 0
src/core/FlpImport.cpp

@@ -1878,6 +1878,9 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
             def.sampler.stretchBeats = (float) (c.stretchTime / 192.0 * std::pow (2.0, c.stretchMul / 10000.0));
             def.sampler.keepPitch = c.stretchMode != 0; // only FL's "Resample" changes the pitch
             def.sampler.stretchMethod = stretchMethodForFlMode (c.stretchMode);
+            // Fruity Granulizer: FL hands the plugin TIME as its beat count, without MUL (REA_rodada165g-flgran165 §3)
+            if (def.instrument == InstrumentKind::granulizer)
+                def.sampler.stretchBeats = (float) (c.stretchTime / 192.0);
         }
 
         // FL's time-stretching panel on a sample channel or an audio clip [FL: measured, REA_rodada164e-clippitch §2]:

+ 169 - 18
src/core/Granulizer.cpp

@@ -7,6 +7,7 @@
 #include <cstring>
 #include <memory>
 
+#include "core/FlAutoSlicer.h"
 #include "core/FlVoiceProcessor.h"
 
 // Port of our round-67 reference model (r67/py/granmodel.py, REA_rodada67). The model emulates the DLL's float32
@@ -29,6 +30,9 @@ constexpr int stateSize = 4 + 48 + 12 + snapshotSize; // version 7: 428 bytes
 constexpr int maxVoices = 64;   // voice records per instance (FL: unlimited; the oldest is cut beyond this)
 constexpr int maxGrains = 48;   // grains per voice (the knobs' ranges allow about 20 at once)
 constexpr int defaultPoints = 12; // the library's default quality (0x79cda0 = 4 → 0x79c294[3]): "24-point sinc"
+// what FL's host sets with ProcessMode (Dispatcher 1, bits 8…23 → FUN_0060b020) when it renders: 16 points per side
+// ("32-point sinc") [EXEC FL: the DLL matches FL's renders of a 48 kHz sample only with 16, −76.6 dB; 12: −40.6 dB]
+constexpr int flPoints = 16;
 constexpr int maxPoints = 0x200;
 
 using flvp::bitsOf;
@@ -91,6 +95,10 @@ bool parse (const std::vector<std::uint8_t>& d, Params& out, std::vector<std::ui
         if (snapshot != nullptr && d.size() >= o + snapshotSize)
             snapshot->assign (d.begin() + (std::ptrdiff_t) o, d.begin() + (std::ptrdiff_t) (o + snapshotSize));
     }
+    // the editor's key-mode combo (0x758050, run on every state load): "slices" keys without a slice mode turn on auto
+    // slicing [DECOMP + EXEC: such a state plays the auto slices]
+    if (p.keyMode == 3 && p.sliceMode == 0)
+        p.sliceMode = 2;
     out = p;
     return true;
 }
@@ -270,12 +278,13 @@ struct Reader
     const Sample* s = nullptr;
     bool loop = false;
     std::int64_t a = 0, b = 0, la = 0, lb = 0, c0 = 0, c8 = 0, d0 = 0, d8 = 0;
-    int pts = defaultPoints, loops = 0;
+    int pts = defaultPoints, quality = defaultPoints, loops = 0;
     double pos = 0.0, speed = 1.0, wa = 0.0, wc = 0.0, cb = 0.0, cc = 0.0;
     bool copy = false;
 
-    void init (const Sample& smp, bool looped) noexcept
+    void init (const Sample& smp, bool looped, int points) noexcept
     {
+        quality = std::clamp (points, 1, maxPoints);
         s = &smp;
         loop = looped;
         const auto L = (std::int64_t) smp.n - 1;
@@ -287,8 +296,8 @@ struct Reader
         }
         else
             la = a, lb = b;
-        pts = defaultPoints, loops = 0;
-        setPoints (defaultPoints);
+        pts = quality, loops = 0;
+        setPoints (quality);
         pos = (double) a, speed = 1.0;
         cb = 3.141592653589793, cc = -2.0;
         bounds();
@@ -323,7 +332,7 @@ struct Reader
         else
             cb = 3.141592653589793 / sp, cc = std::cos (cb) * 2.0;
         auto p = (int) ((rnd (sp) + 3) & ~(std::int64_t) 3);
-        p = std::min (std::max (p, defaultPoints), maxPoints);
+        p = std::min (std::max (p, quality), maxPoints);
         if (p != pts)
         {
             setPoints (p);
@@ -471,7 +480,7 @@ struct Grain
 struct Voice
 {
     std::array<Grain, maxGrains> grains;
-    int nGrains = 0, count = 0, next = 0, elapsed = 0, key = 60;
+    int nGrains = 0, count = 0, next = 0, elapsed = 0, key = 60, slice = -1;
     float pos = 0, phase = 0, pofs = 0, ipitch = 0;
     bool done = false, looped = false, ended = false;
     float fpitch = 0, fpitchBase = 0, fvol = 1, fpan = 0;
@@ -529,12 +538,19 @@ public:
     // FUN_0060dbf0: ms → samples (double), stored as float
     float samplesMs (int ms) const noexcept { return (float) ((double) ms * (double) fs * (double) 0.001f); }
 
-    // FUN_00752290 (+ the laws of parameters 4, 5, 10)
+    // tempo sync (FUN_007524e0 → FUN_00752490): the state's sync byte is 1 and the host sent a beat count (Dispatcher
+    // 0x13: the channel's stretch time, else the sample's ACID beats, REA_rodada165g-flgran165 §2)
+    bool syncOn() const noexcept { return P.sync == 1 && beats > 0.0f && beatLen > 0; }
+
+    // FUN_00752290 (+ the laws of parameters 4, 5, 10); the beat length of FUN_00752520 first
     void update() noexcept
     {
         const auto& p = P.P;
+        const auto tempoF = (float) tempo;
+        beatLen = tempoF > 0.0f ? (int) rnd ((double) (((beats * 60.0f) * (float) fs) / tempoF)) : 0;
         A = samplesMs (msLaw (p[0]));
         H = samplesMs (msLaw (p[1]));
+        th = samplesMs (msLaw (p[11]));
         AH = A + H;
         auto gs = (AH * (float) pctLaw (p[2])) * 0.00390625f;
         if (5.0f > gs)
@@ -542,7 +558,16 @@ public:
         gsp = gs;
         loopFlag = p[8] > 0;
         ratio = smp.rate * (1.0 / (double) fs);
-        wsp = (float) ((double) (AH * (float) pctLaw (p[3])) * ratio * (double) 0.00390625f);
+        if (! syncOn())
+            wsp = (float) ((double) (AH * (float) pctLaw (p[3])) * ratio * (double) 0.00390625f);
+        else
+        {
+            // one pass over the sample per beat count: the wave spacing follows the grain spacing, the voice loops
+            wsp = (gsp * (float) ((std::int64_t) smp.le + 1)) / (float) beatLen;
+            loopFlag = true;
+        }
+        invAH = 1.0f / AH;
+        k18c = AH / (wsp <= 1.0f ? 1.0f : wsp);
         depth = (float) p[4] * 0.00390625f;
         rate5 = (float) (3.141592653589793 / (double) (0xcc - p[5]));
         start = smp.n > 0 ? (int) (((std::int64_t) p[10] * (std::int64_t) smp.le) / 0x1000) : 0;
@@ -584,12 +609,12 @@ public:
             ++slot;
         used[(std::size_t) slot] = true;
         auto& v = voices[(std::size_t) slot];
-        v.nGrains = 0, v.count = 0, v.next = 0, v.elapsed = 0, v.key = key;
+        v.nGrains = 0, v.count = 0, v.next = 0, v.elapsed = 0, v.key = key, v.slice = -1;
         v.pos = (float) start, v.phase = 0.0f, v.pofs = 0.0f, v.ipitch = initPitch;
         v.done = v.looped = v.ended = false;
         v.fpitch = v.fpitchBase = finalPitch, v.fvol = finalVol, v.fpan = finalPan;
         v.serial = ++serials;
-        if (P.keyMode >= 1) // key mapping (C5 = the start; the slice mode 3 needs slices: not modelled)
+        if (P.keyMode >= 1) // key mapping: C5 = the start, each key a step (mode 1: 1/24 of the sample, 2: a 16th, 3: a slice)
         {
             auto k = (int) rnd ((double) (v.ipitch * 0.01f)) - 60;
             v.pofs = (float) (k * -100);
@@ -598,7 +623,14 @@ public:
             if (P.keyMode == 1)
                 d = (double) (smp.le * k) / 24.0;
             else if (P.keyMode == 2)
-                d = (((double) k / 4.0) * 60.0 * smp.rate) / (double) (float) tempo; // (P+0x1a0: the tempo as a float)
+            {
+                if (beats <= 0.0f)
+                    d = (((double) k / 4.0) * 60.0 * smp.rate) / (double) (float) tempo; // (P+0x1a0: the tempo as a float)
+                else
+                    d = ((double) smp.le * ((double) k / 4.0)) / (double) beats; // the sample spans `beats` beats
+            }
+            else if (P.keyMode == 3 && nSl > 0)
+                d = (double) sl[(std::size_t) (k % nSl)];
             const auto p = rnd ((double) v.pos + d);
             v.pos = (float) (p % ((std::int64_t) smp.le + 1));
         }
@@ -623,7 +655,7 @@ public:
             return;
         auto& g = v.grains[(std::size_t) v.nGrains++];
         ++v.count;
-        g.r.init (smp, loopFlag && smp.ls >= 0);
+        g.r.init (smp, loopFlag && smp.ls >= 0, points);
         const auto p = (double) ipos;
         auto d = (double) g.r.a;
         if ((double) g.r.a <= p)
@@ -647,6 +679,41 @@ public:
             g.L = r, g.R = l;
     }
 
+    // Voice_Render's slice branch (0x75400e…0x754214): the grains line up with the slice starts. Where the voice will be
+    // after the attack (at the grain's speed), the next slice start ahead: a new slice holds its grain for the
+    // transient hold (cut so the grain ends at the slice), later grains of the same slice share out the distance left
+    // over their hold; `f14` scales the grain and wave spacing by the grain's length over A + H.
+    void sliceHold (Voice& v, float& hold, float& f14) noexcept
+    {
+        const auto cents = v.fpitch + v.pofs;
+        auto t = cents == 0.0f ? v.pos + A
+                               : (float) ((double) v.pos + (double) A * std::exp ((double) cents * (std::log (2.0) / 12.0 / 100.0)));
+        const auto at = (std::int64_t) (std::int32_t) rnd ((double) t - 0.5);
+        for (int i = 0; i < nSl; ++i)
+        {
+            if (sl[(std::size_t) i] < at)
+                continue;
+            auto d = (float) sl[(std::size_t) i] - t;
+            if (i == v.slice)
+            {
+                auto n = rnd ((double) (d / wsp));
+                const auto ni = n < 1 ? 1 : (int) n;
+                d = ((d - (float) ni * wsp) * k18c) / (float) ni;
+                hold = 0.0f < H + d ? H + d : 0.0f;
+            }
+            else
+            {
+                v.slice = i;
+                d = d * k18c;
+                hold = th;
+                if (d < A + th)
+                    hold = 0.0f < d - A ? d - A : 0.0f;
+            }
+            break;
+        }
+        f14 = (A + hold) * invAH;
+    }
+
     // FUN_00753ea0 (Voice_Render): grains into x (interleaved, cleared); true when the voice is finished
     bool voiceRender (Voice& v, float* x, int n) noexcept
     {
@@ -659,7 +726,7 @@ public:
             v.elapsed += n;
             while (v.next < v.elapsed)
             {
-                const auto f14 = 1.0f;
+                auto f14 = 1.0f, hold = H;
                 auto ip = (int) rnd ((double) v.pos);
                 if (! (p[6] < 1 || p[9] != 0 || (std::uint32_t) p[6] <= 0xffu - random (0x100)))
                 {
@@ -667,7 +734,9 @@ public:
                     while (smp.le < ip)
                         ip -= loopLen;
                 }
-                startGrain (v, ip, v.next - old, (int) rnd ((double) A), (int) rnd ((double) H));
+                else if (nSl > 0 && wsp > 0.0f)
+                    sliceHold (v, hold, f14);
+                startGrain (v, ip, v.next - old, (int) rnd ((double) A), (int) rnd ((double) hold));
                 if (v.next == 0 && v.pos == 0.0f && v.nGrains > 0)
                 {
                     auto& g = v.grains[0];
@@ -829,7 +898,12 @@ public:
     flvp::Settings S;
     std::array<std::uint8_t, snapshotSize> snap = flvp::defaultSnapshot();
     int fs = 44100, maxPoly = 0, start = 0, loopLen = 1;
-    float A = 0, H = 0, AH = 0, gsp = 5, wsp = 0, depth = 0, rate5 = 0;
+    float A = 0, H = 0, AH = 0, gsp = 5, wsp = 0, depth = 0, rate5 = 0, th = 0, invAH = 1, k18c = 1;
+    float beats = 0;  // the host's beat count (P+0x19c)
+    int beatLen = 0;  // samples of `beats` beats at the tempo (P+0x198)
+    const std::int64_t* sl = nullptr; // slice starts (the slicer object's list, ascending), owned by the caller
+    int nSl = 0;
+    int points = flPoints; // the sample reader's interpolation points per side
     double ratio = 1.0, tempo = 140.0;
     bool loopFlag = false, listed = false, tickPending = false;
     std::uint32_t seed = 0;
@@ -882,6 +956,30 @@ std::vector<std::uint8_t> granulizerNormalisedState (const std::vector<std::uint
     return out;
 }
 
+std::optional<int> granulizerMode (const std::vector<std::uint8_t>& state, int which)
+{
+    Params p;
+    if (! parseNormalised (state, p))
+        return std::nullopt;
+    switch (which)
+    {
+        case 0: return p.sliceMode;
+        case 1: return p.keyMode;
+        case 2: return p.sync == 1 ? 1 : 0;
+        default: return std::nullopt;
+    }
+}
+
+bool granulizerSetMode (std::vector<std::uint8_t>& state, int which, int value)
+{
+    Params p;
+    if (which < 0 || which > 2 || ! parseNormalised (state, p))
+        return false;
+    const int offset[] = { 52, 56, 60 }, high[] = { 2, 3, 1 };
+    putI32 (state.data() + offset[which], std::clamp (value, 0, high[which]));
+    return true;
+}
+
 int granulizerParamCount() noexcept { return paramCount; }
 
 std::pair<int, int> granulizerParamRange (int index) noexcept
@@ -917,8 +1015,19 @@ struct Setup
     std::array<std::uint8_t, snapshotSize> snap = flvp::defaultSnapshot();
     int ppq = 96;
     double tempo = 140.0;
+    float beats = 0.0f;
 };
 
+// What FL hands the plugin as the sample's beat count (Dispatcher 0x13): the WAV's ACID beats, else the channel's
+// time-stretch TIME in beats — without the MUL factor (the importer keeps TIME/192 for this engine) [FL render g11, g12,
+// g16: REA_rodada165g-flgran165 §3]
+float hostBeats (const ChannelDef& channel, const SampleData* sample) noexcept
+{
+    if (sample != nullptr && sample->acidBeats > 0.0f)
+        return sample->acidBeats;
+    return std::max (channel.sampler.stretchBeats, 0.0f);
+}
+
 class GranulizerInstrument final : public Instrument
 {
 public:
@@ -938,6 +1047,7 @@ public:
     void prepare (double sr) noexcept override
     {
         rate = sr;
+        engine.points = offlineRendering() ? flPoints : defaultPoints; // FL: 32-point sinc when it renders, 24 live
         take();
         engine.tempo = current.tempo;
         engine.init (current.P, sr, current.snap.data(), current.ppq, current.tempo);
@@ -953,16 +1063,18 @@ public:
         maxPoly.store (channel.synth.mono ? 1 : 0);
         const auto ppq = channel.modelParams.empty() ? 96 : std::clamp ((int) channel.modelParams[0], 1, 1 << 16);
         const auto tempo = bpm > 0.0 ? bpm : 140.0;
-        if (channel.pluginState == state && ppq == lastPpq && tempo == lastTempo)
+        const auto beats = hostBeats (channel, sample.get());
+        if (channel.pluginState == state && ppq == lastPpq && tempo == lastTempo && beats == lastBeats)
             return;
         Params p;
         if (! parseNormalised (channel.pluginState, p))
             return;
+        prepareSlices (p.sliceMode);
         auto s = std::make_unique<Setup>();
         s->P = p;
         std::memcpy (s->snap.data(), channel.pluginState.data() + 64, snapshotSize);
-        s->ppq = ppq, s->tempo = tempo;
-        state = channel.pluginState, lastPpq = ppq, lastTempo = tempo;
+        s->ppq = ppq, s->tempo = tempo, s->beats = beats;
+        state = channel.pluginState, lastPpq = ppq, lastTempo = tempo, lastBeats = beats;
         delete incoming.exchange (s.release());
     }
 
@@ -1050,6 +1162,33 @@ public:
     }
 
 private:
+    // The slice list of a slice mode (FUN_007548c0), built once per instrument before a Setup that uses it is published
+    // (the audio thread only reads it): 1 = the WAV's cue points / regions, 2 = FL's auto slicing
+    void prepareSlices (int mode)
+    {
+        if (sample == nullptr || sample->frames() == 0)
+            return;
+        if (mode == 1 && ! slicesReady[0])
+        {
+            slices[0] = sample->markerStarts;
+            slicesReady[0] = true;
+        }
+        else if (mode == 2 && ! slicesReady[1])
+        {
+            const auto* l = sample->leftData();
+            const auto* r = sample->rightData();
+            slices[1] = flslice::autoSlice (l, r == l ? nullptr : r, (std::int64_t) sample->frames(), sample->sampleRate);
+            slicesReady[1] = true;
+        }
+    }
+
+    void useSlices (int mode) noexcept
+    {
+        const auto* list = mode == 1 ? &slices[0] : mode == 2 ? &slices[1] : nullptr;
+        engine.sl = list != nullptr && ! list->empty() ? list->data() : nullptr;
+        engine.nSl = engine.sl != nullptr ? (int) std::min<std::size_t> (list->size(), 0x7fffffff) : 0;
+    }
+
     void renderImpl (float* left, float* right, int n) noexcept
     {
         const auto perSample = current.tempo * (double) current.ppq / (60.0 * rate);
@@ -1083,6 +1222,8 @@ private:
             current = *s;
             engine.P = current.P;
             engine.tempo = current.tempo;
+            engine.beats = current.beats;
+            useSlices (current.P.sliceMode);
             std::memcpy (engine.snap.data(), current.snap.data(), snapshotSize);
             engine.timing (current.ppq, current.tempo);
             engine.update();
@@ -1101,6 +1242,9 @@ private:
     std::vector<std::uint8_t> state;
     int lastPpq = -1;
     double lastTempo = -1.0;
+    float lastBeats = -1.0f;
+    std::array<std::vector<std::int64_t>, 2> slices; // written once each (configure), then read by the audio thread
+    std::array<bool, 2> slicesReady { false, false };
     std::array<float, blockSize> bufL {}, bufR {};
     std::array<float, maxVoices> volFactor {}, notePan {};
     double rate = 44100.0, channelVol = 1.0, channelPan = 0.0, tickPhase = 0.0, lastTicks = -1.0;
@@ -1124,6 +1268,13 @@ std::vector<float> renderReference (const std::vector<std::uint8_t>& state, cons
     auto engine = std::make_unique<Engine>();
     engine->smp = sampleOf (&sample);
     engine->tempo = opt.tempo;
+    engine->beats = opt.beats;
+    engine->points = opt.points;
+    if (P.sliceMode > 0 && ! opt.slices.empty())
+    {
+        engine->sl = opt.slices.data();
+        engine->nSl = (int) opt.slices.size();
+    }
     engine->init (P, sampleRate, state.data() + 64, opt.ppq, opt.tempo);
     engine->maxPoly = opt.maxPoly;
     engine->seed = opt.seed;

+ 19 - 5
src/core/Granulizer.h

@@ -15,11 +15,16 @@
 // key mode, sync byte, the 364-byte channel-settings snapshot); ChannelDef::samplePath is the channel's sample (FL hands
 // it to the plugin through the host's GetSampleInfo); ChannelDef::modelParams[0] (optional) is the project's PPQ.
 //
-// Not modelled (REA_rodada67 §5): the slice modes (regions from the sample, "auto slicing") and the slice key mode;
-// tempo sync (the host's beat count, Dispatcher 0x13); other interpolation qualities sent by FL's host (Dispatcher 1;
-// FL's value not confirmed); rcpps (a CPU-specific approximate reciprocal in the sinc kernel) is replaced by the exact
-// reciprocal; the sines of the kernel use the C library instead of IPP's ippsSin_64f_A50; one random seed per
-// instrument (FL: one per process).
+// Slices (REA_rodada165g-flgran165): with a transients source (the WAV's cue points / regions, or FL's auto slicing,
+// core/FlAutoSlicer) grains line up with the slice starts and the first grain of each slice holds for "transient hold";
+// tempo lock plays the sample once per its beat count (the WAV's ACID beats, else the channel's stretch TIME in beats,
+// as FL hands the plugin with Dispatcher 0x13); the keys can move the start in 16th notes or to the k-th slice. The
+// sample reader uses FL's render quality (16 points per side) while LYNX exports and the plugin's 12 live.
+//
+// Not modelled: rcpps (a CPU-specific approximate reciprocal in the sinc kernel) is replaced by the exact reciprocal;
+// the sines of the kernel use the C library instead of IPP's ippsSin_64f_A50 (both: about −130 dB, isolated samples
+// on the reader's edge path near −90 dB); one random seed per instrument (FL: one per process); the sample's own loop
+// points (the whole sample, as FL hands it).
 
 #include <cstdint>
 #include <memory>
@@ -43,6 +48,12 @@ std::vector<std::uint8_t> granulizerNormalisedState (const std::vector<std::uint
 std::optional<int> granulizerParam (const std::vector<std::uint8_t>& state, int index);
 bool granulizerSetParam (std::vector<std::uint8_t>& state, int index, int value); // clamped to the knob's range
 int granulizerParamCount() noexcept;
+
+// The editor's modes of a normalised state: 0 = transients source (slice mode: 0 off, 1 the sample's regions / cue
+// points, 2 FL's auto slicing; "Transient" keys turn 0 into 2 as FL's editor does), 1 = key to (0 pitch, 1 percent:
+// the start across the sample, 2 step: 16th notes, 3 transient: the slices), 2 = tempo locked (0/1)
+std::optional<int> granulizerMode (const std::vector<std::uint8_t>& state, int which);
+bool granulizerSetMode (std::vector<std::uint8_t>& state, int which, int value); // clamped to the mode's range
 std::pair<int, int> granulizerParamRange (int index) noexcept; // the editor knobs' ranges (EXEC)
 
 // The instrument; `sample` is the channel's sample (silent without one, as FL: TriggerVoice refuses the note)
@@ -65,6 +76,9 @@ struct RefOptions
     int ppq = 96;
     double tempo = 140.0;
     std::uint32_t seed = 0; // the DLL's RandSeed when the first note starts
+    float beats = 0.0f;     // the host's beat count (Dispatcher 0x13): tempo sync and key mode 2
+    std::vector<std::int64_t> slices; // slice starts (ascending) for slice modes 1 and 2
+    int points = 16;        // interpolation points per side (FL renders with 16; the plugin's own default is 12)
 };
 
 // Renders `notes` from a normalised `state` and `sample` like granmodel.run(). Interleaved stereo float samples

+ 264 - 19
src/core/Kepler.cpp

@@ -60,18 +60,148 @@ struct NearestMode
 };
 #endif
 
-// pow: the render's powers of two (pitch, cutoff) with exp2, the parameter laws in extended precision rounded to double.
-// The DLL's library differs from both by single ulps on some values (§6.2; exp2 and the extended pow give identical
-// renders in the tests, exp2 at a fraction of the cost)
+// pow with base 2 as the DLL's statically linked library computes it (REA_rodada165g-kepler §1): the engine calls pow
+// (double) for the oscillator increment and powf for the cutoff inside the render, where the rounding mode is "toward
+// zero"; both libraries' results then differ from exp2 by one unit in the last place on ~0.1–2 % of the inputs, which
+// self-oscillating patches amplify. The exponential is rebuilt step by step: x·ln 2 (as a head/tail pair for pow), the
+// index n = x·64/ln 2 converted in the current rounding mode, the reduced argument r = x − n·ln 2/64 (fused on CPUs
+// with FMA, the path FL takes on them), a Taylor polynomial (degree 3 for powf, 6 for pow) and the 2^(j/64) table
+// (pow: head + tail; heads truncated to 24 bits) read from the user's engine DLL. Bit-exact against the DLL's pow/powf
+// on 10⁶ random inputs in both rounding modes [EXEC].
+struct CrtExp
+{
+    std::array<double, 64> full {}, head {}, tail {};
+};
+std::atomic<const CrtExp*> crtExp { nullptr };
+
+// the polynomial steps are fused multiply-adds: hardware FMA where the CPU has it (x86: selected at run time; ARM64:
+// always), std::fma otherwise
+#define LYNX_KEPLER_CRT_POW(NAME, FMA, ATTR)                                                                               \
+    ATTR double NAME##D (const CrtExp& t, double y) noexcept                                                                \
+    {                                                                                                                    \
+        constexpr double ln2h = 0x1.62e42ep-1, ln2t = 0x1.efa39ef35793cp-25, k64 = 0x1.71547652b82fep+6,                \
+                         c64h = 0x1.62e42fp-7, c64t = -0x1.df473de6af278p-32;                                           \
+        auto top = [] (double d) noexcept {                                                                              \
+            std::uint64_t u;                                                                                             \
+            std::memcpy (&u, &d, 8);                                                                                     \
+            u &= 0xfffffffff8000000ull;                                                                                  \
+            std::memcpy (&d, &u, 8);                                                                                     \
+            return d;                                                                                                    \
+        };                                                                                                               \
+        /* log(2) as head + tail, then y·log(2) as zh + zl */                                                            \
+        const double L = ln2h + ln2t, Lh = top (L);                                                                      \
+        double l = ln2h - L;                                                                                             \
+        l = l + ln2t;                                                                                                    \
+        l = l + (L - Lh);                                                                                                \
+        const double yh = top (y), yl = y - yh;                                                                          \
+        double a = yl * l;                                                                                               \
+        a = a + yl * Lh;                                                                                                 \
+        a = a + l * yh;                                                                                                  \
+        const double hh = Lh * yh, zh = hh + a;                                                                          \
+        double zl = hh - zh;                                                                                             \
+        zl = zl + a;                                                                                                     \
+        const double kk = zh * k64;                                                                                      \
+        if (! (kk <= 65536.0 && kk >= -68800.0))                                                                         \
+            return std::exp2 (y);                                                                                        \
+        const int n = (int) std::lrint (kk);                                                                             \
+        const double dn = (double) n;                                                                                    \
+        const int j = n & 63, m = (n - j) >> 6;                                                                          \
+        double r = FMA (-dn, c64h, zh) + dn * c64t;                                                                      \
+        r = r + zl;                                                                                                      \
+        double p = FMA (0x1.6c16c16c16c17p-10, r, 0x1.1111111111111p-7);                                                \
+        p = FMA (p, r, 0x1.5555555555555p-5);                                                                            \
+        p = FMA (p, r, 0x1.5555555555555p-3);                                                                            \
+        p = FMA (p, r, 0.5);                                                                                             \
+        p = FMA (p, r, 1.0);                                                                                             \
+        const double q = p * r;                                                                                          \
+        double s5 = t.tail[(std::size_t) j] * q;                                                                         \
+        double s1 = t.head[(std::size_t) j] * q;                                                                         \
+        s5 = s5 + t.tail[(std::size_t) j];                                                                               \
+        s1 = s1 + s5;                                                                                                    \
+        s1 = s1 + t.head[(std::size_t) j];                                                                               \
+        if (m <= -1022 || m >= 1024)                                                                                     \
+            return std::ldexp (s1, m);                                                                                   \
+        const std::uint64_t sc = (std::uint64_t) (m + 0x3ff) << 52;                                                      \
+        double scale;                                                                                                    \
+        std::memcpy (&scale, &sc, 8);                                                                                    \
+        return s1 * scale;                                                                                               \
+    }                                                                                                                    \
+    ATTR float NAME##F (const CrtExp& t, float y) noexcept                                                                \
+    {                                                                                                                    \
+        const double z = (double) y * 0x1.62e42fefa39efp-1;                                                              \
+        if (! (z <= 88.72283935546875 && z > -103.2789306640625))                                                        \
+            return (float) std::exp2 ((double) y);                                                                       \
+        const int n = (int) std::lrint (z * 0x1.71547652b82fep+6);                                                       \
+        const double dn = (double) n;                                                                                    \
+        const double r = FMA (-dn, 0x1.62e42fefa39efp-7, z);                                                             \
+        double p = FMA (0x1.5555555555555p-3, r, 0.5);                                                                   \
+        p = FMA (p, r, 1.0);                                                                                             \
+        const double q = r * p;                                                                                          \
+        const double T = t.full[(std::size_t) (n & 63)];                                                                 \
+        double v = FMA (q, T, T);                                                                                        \
+        std::uint64_t u;                                                                                                 \
+        std::memcpy (&u, &v, 8);                                                                                         \
+        u += (std::uint64_t) (std::int64_t) (n >> 6) << 52;                                                              \
+        std::memcpy (&v, &u, 8);                                                                                         \
+        return (float) v;                                                                                                \
+    }
+
+LYNX_KEPLER_CRT_POW (crtPow2Sw, std::fma, )
+#if (defined(__x86_64__) || defined(_M_X64)) && (defined(__clang__) || defined(__GNUC__))
+#define LYNX_KEPLER_HW_FMA 1
+LYNX_KEPLER_CRT_POW (crtPow2Hw, __builtin_fma, __attribute__ ((target ("fma"))))
+bool detectFma() noexcept
+{
+    // CPUID.1:ECX bit 12 (FMA) and bit 27 (OSXSAVE), and the OS saving the YMM state (XCR0 bits 1, 2)
+    unsigned a = 1, b = 0, c = 0, d = 0;
+    __asm__ ("cpuid" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
+    (void) b, (void) d;
+    if ((c & (1u << 12)) == 0 || (c & (1u << 27)) == 0)
+        return false;
+    unsigned lo = 0, hi = 0;
+    __asm__ ("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
+    return (lo & 6u) == 6u;
+}
+const bool cpuHasFma = detectFma();
+#endif
+#undef LYNX_KEPLER_CRT_POW
+
+double crtPow2 (const CrtExp& t, double y) noexcept
+{
+#ifdef LYNX_KEPLER_HW_FMA
+    if (cpuHasFma)
+        return crtPow2HwD (t, y);
+#endif
+    return crtPow2SwD (t, y);
+}
+
+float crtPow2f (const CrtExp& t, float y) noexcept
+{
+#ifdef LYNX_KEPLER_HW_FMA
+    if (cpuHasFma)
+        return crtPow2HwF (t, y);
+#endif
+    return crtPow2SwF (t, y);
+}
+
+// powers of two through the library above once a DLL's tables are loaded (exp2 before that); other bases (parameter
+// laws, outside the render) in extended precision rounded to double
 double powD (double a, double b) noexcept
 {
     if (a == 2.0)
+    {
+        if (const auto* t = crtExp.load (std::memory_order_acquire))
+            return crtPow2 (*t, b);
         return std::exp2 (b);
+    }
     return (double) std::pow ((long double) a, (long double) b);
 }
 
 float powF (float a, float b) noexcept
 {
+    if (a == 2.0f)
+        if (const auto* t = crtExp.load (std::memory_order_acquire))
+            return crtPow2f (*t, b);
     return (float) powD ((double) a, (double) b);
 }
 float tanF (float x) noexcept
@@ -92,15 +222,6 @@ float sinF (float x) noexcept
     }
     return (float) r;
 }
-float cosF (float x) noexcept
-{
-    double r;
-    {
-        NearestMode m;
-        r = std::cos ((double) x);
-    }
-    return (float) r;
-}
 float lnF (float x) noexcept
 {
     double r;
@@ -118,6 +239,62 @@ float bitsF (std::uint32_t u) noexcept
     return f;
 }
 
+std::uint32_t floatBits (float f) noexcept
+{
+    std::uint32_t u;
+    std::memcpy (&u, &f, 4);
+    return u;
+}
+
+// sine and cosine as the engine's library computes them for the chorus filter design (REA_rodada165g-flbeta165k §2):
+// for |x| ≥ 2⁻¹³ a four-lane float sine run on (x, |x| + π/2) — Cody-Waite reduction by π in four float products, an
+// odd degree-9 polynomial, the parity of the quotient flipping the sign; below 2⁻¹³ sin = x, cos = 1 − x²/2. Every step
+// in float, in the current rounding mode. Bit-exact against the DLL on 5·10⁵ inputs |x| < 3.2, both rounding modes
+// [EXEC]; the correctly rounded sin/cos differ from it by one ulp on 16–27 % of the inputs (at 44.1 kHz on both).
+// Valid for |x| < 10⁴ (the library's large-argument path is not needed: the argument is 2π·7 kHz/rate).
+float engineSinLane (float x) noexcept
+{
+    const auto ax = bitsF (floatBits (x) & 0x7fffffffu);
+    const auto sign = floatBits (x) & 0x80000000u;
+    auto t = ax * bitsF (0x3ea2f983u);
+    t = t + bitsF (0x4b400000u);
+    const auto parity = floatBits (t) << 31;
+    const auto n = t - bitsF (0x4b400000u);
+    const auto a = bitsF (0x40490000u) * n, b = bitsF (0x3a7da000u) * n, c = bitsF (0x34222000u) * n, d = bitsF (0x2cb4611au) * n;
+    auto r = ax - a;
+    r = r - b;
+    r = r - c;
+    r = r - d;
+    const auto r2 = r * r;
+    r = bitsF (floatBits (r) ^ parity);
+    auto p = bitsF (0x362edef8u) * r2;
+    p = p + bitsF (0xb94fb7ffu);
+    p = p * r2;
+    p = p + bitsF (0x3c088766u);
+    p = p * r2;
+    p = p + bitsF (0xbe2aaaa6u);
+    p = r2 * p;
+    p = p * r;
+    r = r + p;
+    return bitsF (floatBits (r) ^ sign);
+}
+
+void engineSinCos (float x, float& s, float& c) noexcept
+{
+    const auto ax = bitsF (floatBits (x) & 0x7fffffffu);
+    if (! (ax >= bitsF (0x39000000u)))
+    {
+        auto q = ax * ax;
+        q = q * 0.5f;
+        s = x;
+        c = 1.0f - q;
+        return;
+    }
+    const auto y = ax + bitsF (0x3fc90fdbu);
+    s = engineSinLane (x);
+    c = engineSinLane (y);
+}
+
 // --------------------------------------------------------------------------------------------- installation data (§2)
 constexpr const char* engineSha256 = "baf37a1d8266aaafc55016de259be4b95f1a136a1fc13ba97514c72e2afc63ab";
 constexpr int lfoPoints = 2170;
@@ -238,6 +415,18 @@ std::shared_ptr<const Tables> loadTables (const std::string& path)
         return nullptr;
     t->noise.resize ((std::size_t) noisePoints);
     std::memcpy (t->noise.data(), b.data() + no, 2 * (std::size_t) noisePoints);
+    // the library's 2^(j/64) tables (§1 of REA_rodada165g-kepler): powf's rounded values, pow's 24-bit heads and tails
+    if (crtExp.load (std::memory_order_acquire) == nullptr)
+    {
+        const auto fo = offset (0xF19B0), ho = offset (0xF1BB0), to = offset (0xF1DB0);
+        if (fo + 512 > b.size() || ho + 512 > b.size() || to + 512 > b.size())
+            return nullptr;
+        static CrtExp crt;
+        std::memcpy (crt.full.data(), b.data() + fo, 512);
+        std::memcpy (crt.head.data(), b.data() + ho, 512);
+        std::memcpy (crt.tail.data(), b.data() + to, 512);
+        crtExp.store (&crt, std::memory_order_release);
+    }
     t->blit = blitRows();
     cache[path] = t;
     return t;
@@ -552,6 +741,33 @@ public:
             beatPos = beats;
     }
 
+    // FL's channel volume and pan as MIDI events (wrapper ProcessEvent 3 / 2 → engine setters, REA_rodada165g-flbeta165k
+    // §3): volume = MIDI value / 127, pan = MIDI pan / 128 + 0.5; output gains √(1 − pan)·k·(a·v³ − b·v² + c·v) and
+    // √pan·k·(…), which the render glides to by 0.05 per sample. `snap`: start at the targets (a fresh instance that
+    // FL's export warm-up has already run).
+    void setMidiLevels (float volume, float pan, bool snap) noexcept
+    {
+        midiVolume = volume;
+        midiPan = pan;
+        auto q = 0.0f;
+        if (! (midiPan < 0.0f))
+            q = std::min (midiPan, 1.0f);
+        const auto v = midiVolume;
+        const auto a = v * 6.210264205932617f;
+        auto b = v * 1.4609940052032471f;
+        auto c = v * v;
+        b = b * v;
+        const auto d = v * 1.5597299337387085f;
+        c = c * a;
+        c = c - b;
+        const auto sl = std::sqrt (1.0f - q) * 1.4144271612167358f;
+        c = c + d;
+        outTargetL = sl * c;
+        outTargetR = (std::sqrt (q) * 1.4144271612167358f) * c;
+        if (snap)
+            outGL = outTargetL, outGR = outTargetR;
+    }
+
     void noteOn (int key, int velocity) noexcept // velocity 0…127
     {
         if (! heldAdd (key, velocity))
@@ -1800,7 +2016,8 @@ private:
     void designChorusBiquad() noexcept
     {
         const auto w = 7000.0f * 6.2831854820251465f / chorus.fs;
-        const auto s = sinF (w), c = cosF (w);
+        float s, c;
+        engineSinCos (w, s, c);
         const auto al = 0.5f / 0.7070000171661377f * s;
         const auto one = 1.0f - c, half = one * 0.5f;
         const auto inv = 1.0f / (al + 1.0f);
@@ -1990,6 +2207,7 @@ private:
     // gains
     float mainL = 0.0f, mainR = 0.0f, mainSL = 0.0f, mainSR = 0.0f, mainK = 0.0f;
     float outGL = 6.309000015258789f, outGR = 6.309000015258789f, outTargetL = 6.309000015258789f, outTargetR = 6.309000015258789f;
+    float midiVolume = 1.0f, midiPan = 0.5f; // the last MIDI volume / pan events (§3 of REA_rodada165g-flbeta165k)
     // notes, hold, arpeggiator
     std::vector<std::pair<int, int>> held;
     std::vector<int> order;
@@ -2012,8 +2230,9 @@ int velocityFromInitVol (double initVol) noexcept
 // ------------------------------------------------------------------------------------------------ LYNX instrument
 //
 // Levels: FL's wrapper reads only Final.Pan (note pan + channel pan, the engine's own pan law), Final.Pitch and Final.FCut/
-// FRes; it ignores Final.Vol, and the MIDI-volume event path is not enabled for Kepler's plugin flags (§5.2). How FL then
-// applies the channel volume to this plugin is not confirmed; LYNX applies its channel volume as an output gain. Init.Vol
+// FRes; it ignores Final.Vol. FL also sends the channel volume and pan as MIDI events, which set the engine's output
+// gains (REA_rodada165g-flbeta165k §3, FL renders: the channel pan counts twice, the volume follows the engine's cubic
+// law), so LYNX's channel gains reach this instrument only as those two events — not as an output gain. Init.Vol
 // = (11^(1.28·velocity) − 1)/10 from LYNX's velocity (as for GMS, REA_rodada28 inference). The tempo is the song tempo;
 // while the transport plays, the song position (beats) drives the synced LFO1 and the arpeggiator clock.
 
@@ -2125,6 +2344,19 @@ public:
                 if (noteCents[(std::size_t) k] != sentCents[(std::size_t) k])
                     synth->setPitchExpression (k, sentCents[(std::size_t) k] = noteCents[(std::size_t) k]);
             }
+        // the channel volume and pan as FL sends them (§3 of REA_rodada165g-flbeta165k): MIDI volume = raw volume
+        // (0…12800)·128/12800 truncated, at most 127; MIDI pan = (raw pan − 6400)/100 truncated. LYNX's gains are
+        // channelGain(volume) = (11^v − 1)/10 on its cos/sin pan law, so v comes back as log(10·g + 1)/log 11.
+        {
+            const auto v = vol > 0.0 ? std::log (10.0 * vol + 1.0) / std::log (11.0) : 0.0;
+            const auto midiVolume = (int) std::min<long long> (127, std::max<long long> (0, std::llround (v * 12800.0) / 100));
+            const auto midiPan = (int) std::clamp<long long> (std::llround (pan * 6400.0) / 100, -64, 64);
+            if (midiVolume != sentVolume || midiPan != sentMidiPan)
+            {
+                synth->setMidiLevels ((float) midiVolume * 0.007874015718698502f, (float) midiPan * 0.0078125f + 0.5f, sentVolume < 0);
+                sentVolume = midiVolume, sentMidiPan = midiPan;
+            }
+        }
         synth->setTempo ((double) tempo.load());
         synth->setTransport (playing, songBeats);
         for (int done = 0; done < n;)
@@ -2133,11 +2365,10 @@ public:
             std::fill (scratchL.begin(), scratchL.begin() + m, 0.0f);
             std::fill (scratchR.begin(), scratchR.begin() + m, 0.0f);
             synth->render (scratchL.data(), scratchR.data(), m);
-            const auto g = (float) vol;
             for (int i = 0; i < m; ++i)
             {
-                left[done + i] += scratchL[(std::size_t) i] * g;
-                right[done + i] += scratchR[(std::size_t) i] * g;
+                left[done + i] += scratchL[(std::size_t) i];
+                right[done + i] += scratchR[(std::size_t) i];
             }
             done += m;
         }
@@ -2164,6 +2395,7 @@ private:
             synth.reset (s);
             sounding.fill (false);
             quiet = 0;
+            sentVolume = sentMidiPan = -1000; // a new engine: the levels are sent again (snapped)
         }
     }
 
@@ -2177,7 +2409,7 @@ private:
     std::string dll;
     double lastTicks = -1.0, songBeats = 0.0;
     bool playing = false;
-    int quiet = 0;
+    int quiet = 0, sentVolume = -1000, sentMidiPan = -1000;
     std::array<bool, 128> sounding {};
     std::array<float, 128> notePan {}, noteCents {}, sentPan {}, sentCents {};
     float nextPan = 0.0f, nextCents = 0.0f;
@@ -2212,6 +2444,17 @@ std::vector<float> renderReference (const std::vector<std::uint8_t>& state, cons
     synth->setTempo (options.tempo);
     std::vector<float> out (2 * (std::size_t) length);
     std::vector<float> l ((std::size_t) std::max (1, options.block)), r ((std::size_t) std::max (1, options.block));
+    if (options.midiVolume >= 0)
+        synth->setMidiLevels ((float) std::min (options.midiVolume, 127) * 0.007874015718698502f,
+                              (float) std::clamp (options.midiPan, -64, 64) * 0.0078125f + 0.5f, false);
+    for (int w = 0; w < options.warmup;)
+    {
+        const auto len = std::min (std::max (1, options.block), options.warmup - w);
+        std::fill (l.begin(), l.end(), 0.0f);
+        std::fill (r.begin(), r.end(), 0.0f);
+        synth->render (l.data(), r.data(), len);
+        w += len;
+    }
     // the harness (and FL's wrapper): note-ons/offs between blocks, per-note Final levels sent at the next block
     struct Pending { int key; float pan, cents; };
     std::vector<Pending> pending;
@@ -2251,6 +2494,8 @@ std::vector<float> renderReference (const std::vector<std::uint8_t>& state, cons
         pending.clear();
         std::fill (l.begin(), l.end(), 0.0f);
         std::fill (r.begin(), r.end(), 0.0f);
+        if (options.transport)
+            synth->setTransport (true, (double) n0 / sampleRate * options.tempo / 60.0);
         synth->render (l.data(), r.data(), len);
         for (int i = 0; i < len; ++i)
         {

+ 11 - 2
src/core/Kepler.h

@@ -15,9 +15,12 @@
 //
 // Host interface as FL's wrapper: note number = key, MIDI velocity from Init.Vol (41.714·ln(10·Init.Vol + 1), 0…127),
 // per-note pan / pitch expressions from FinalLevels (pan law √(1 − p), √p with p = (pan + 1)/2), the X/Y (FCut/FRes)
-// modulation routes. Not modelled / differences: the Kepler-2 (Kepler Exo) layout, DCO2, the filter types 1/2, saturation,
+// modulation routes, the channel volume / pan as FL's MIDI events (REA_rodada165g-flbeta165k §3); cut groups do not
+// cut it. FL's renders of all 277 factory presets null against LYNX's engine at the 16-bit floor once FL's export
+// warm-up (1536…2304 samples, varies between FL runs) is given. Not modelled / differences: the Kepler-2 (Kepler Exo) layout, DCO2, the filter types 1/2, saturation,
 // EQ, delay, reverb and hyper chorus (all off in every Kepler-1 state); the chorus noise/gate (off in all FL data); the
-// oversampling ×4 flag (0 in all data). The free-running oscillators/LFO pause while LYNX skips an idle channel.
+// oversampling ×4 flag (0 in all data). The free-running oscillators/LFO pause while LYNX skips an idle channel (only
+// their phase at the next note differs, as between two FL runs).
 
 #include <cstdint>
 #include <memory>
@@ -55,6 +58,12 @@ struct RefOptions
 {
     double tempo = 125.0; // the wrapper's default tempo (ProcessEvent 0 never sent)
     int block = 512;      // host block (split at every event)
+    // FL's export (REA_rodada165g-flbeta165k §3): the channel volume / pan as MIDI events sent first (midiVolume ≥ 0:
+    // 0…127, midiPan −64…64), `warmup` samples rendered before the output starts (FL's warm-up, 1536…2304 observed)
+    // and, with `transport`, the song playing from beat 0 at the first output sample
+    int midiVolume = -1, midiPan = 0;
+    int warmup = 0;
+    bool transport = false;
 };
 
 // Renders `notes` from `state` with the tables of the DLL at `dll`. Interleaved stereo (2·length); empty if unusable.

+ 2 - 2
src/core/NativeEngines.cpp

@@ -114,7 +114,7 @@ const std::vector<InstrumentEngine>& instrumentEngines()
         { InstrumentKind::toxic, "Toxic Biohazard", "Toxic Biohazard", fl, false },
         { InstrumentKind::poizone, "PoiZone", "PoiZone", fl, false },
         { InstrumentKind::sakura, "Sakura", "Sakura", fl, false },
-        { InstrumentKind::kepler, "Kepler", "Kepler", fl, true },
+        { InstrumentKind::kepler, "Kepler", "Kepler", fl, false },
         { InstrumentKind::transistorbass, "Transistor Bass", "Transistor Bass", fl, false },
         { InstrumentKind::boobass, "BooBass", "", fl, false }, // (its multisample: the user's BooBass_Eng_x64.dll)
         { InstrumentKind::simsynth, "SimSynth", "SimSynth", own, false },
@@ -125,7 +125,7 @@ const std::vector<InstrumentEngine>& instrumentEngines()
         { InstrumentKind::beepmap, "BeepMap", "BeepMap", fl, false },
         { InstrumentKind::flkeys, "FL Keys", "FL Keys", fl, false },
         { InstrumentKind::slayer, "FL Slayer", "FL Slayer", fl, false },
-        { InstrumentKind::granulizer, "Fruity Granulizer", "Fruity Granulizer", fl, true },
+        { InstrumentKind::granulizer, "Fruity Granulizer", "Fruity Granulizer", fl, false },
         { InstrumentKind::drumaxx, "Drumaxx", "Drumaxx", fl, false },
         { InstrumentKind::drumpad, "Drumpad", "Drumpad", fl, false },
         { InstrumentKind::fruitkick, "Fruit Kick", "Fruit Kick", fl, false },

+ 62 - 3
src/core/Performance.cpp

@@ -1,4 +1,5 @@
 #include "core/Performance.h"
+#include "core/NoteEdit.h"
 
 #include <algorithm>
 #include <cmath>
@@ -119,7 +120,7 @@ void Player::stopAll() noexcept
 }
 
 void Player::launch (const Song& song, const std::vector<int>& zone, TrackState& t, std::int64_t clipStart, double now,
-                     bool immediate) noexcept
+                     bool immediate, double syncOverride) noexcept
 {
     const auto index = findZoneClip (song, zone, t.track, clipStart);
     if (index < 0)
@@ -131,7 +132,7 @@ void Player::launch (const Song& song, const std::vector<int>& zone, TrackState&
     // when it starts: the next trigger sync grid point; with Queue, the end of the playing pass; Tolerant: a launch
     // within the first 1/8 of a grid step after a grid point is taken as on it (it starts now, already that far in)
     double from = std::ceil (now - 1.0e-6), grid = from;
-    const auto step = (double) syncTicks (s.triggerSync, clip.length);
+    const auto step = syncOverride > 0.0 ? syncOverride : (double) syncTicks (s.triggerSync, clip.length);
     const auto& cur = t.current;
     if (! immediate && s.queue && cur.clipStart >= 0 && cur.until == never)
     {
@@ -225,6 +226,32 @@ void Player::apply (const Song& song, const std::vector<int>& zone, const Comman
             return;
         c.clipStart = clips[(std::size_t) c.column];
     }
+    const auto barTicks = c.barSync ? (double) ppq * 4.0 * song.beatsPerBar / 4.0 : 0.0;
+    if (c.type == Command::Type::press && c.scope != Command::Scope::track)
+    {
+        // a controller's column launch: every track's zone clip that starts within the pressed clip's span
+        const auto index = findZoneClip (song, zone, c.track, c.clipStart);
+        if (index < 0)
+            return;
+        const auto& pressed = clipAt (song, index);
+        int lastTrack = -1;
+        for (const auto i : zone)
+        {
+            const auto& clip = clipAt (song, i);
+            if (clip.track == lastTrack || clip.start < pressed.start || clip.start >= pressed.start + std::max<std::int64_t> (1, pressed.length))
+                continue;
+            if (c.scope == Command::Scope::columnPlaying)
+            {
+                const auto* playing = stateOf (clip.track, false);
+                if (playing == nullptr || playing->current.clipStart < 0)
+                    continue;
+            }
+            lastTrack = clip.track;
+            if (auto* t = stateOf (clip.track, true))
+                launch (song, zone, *t, clip.start, now, false, barTicks);
+        }
+        return;
+    }
     switch (c.type)
     {
         case Command::Type::stopAll:
@@ -262,7 +289,7 @@ void Player::apply (const Song& song, const std::vector<int>& zone, const Comman
                 return;
             }
             t->held = s.press == P::holdStop || s.press == P::holdMotion;
-            launch (song, zone, *t, c.clipStart, now, false);
+            launch (song, zone, *t, c.clipStart, now, false, barTicks);
             return;
         }
         case Command::Type::release:
@@ -501,6 +528,11 @@ bool MidiMapping::note (int key, bool on, Command& out) noexcept
 {
     if (key < 0 || key > 127)
         return false;
+    if (key >= 125)
+    {
+        (key == 125 ? columnHeld : key == 126 ? playingHeld : barHeld) = on;
+        return false;
+    }
     if (key >= 120)
     {
         if (on)
@@ -519,6 +551,8 @@ bool MidiMapping::note (int key, bool on, Command& out) noexcept
     out.type = on ? Command::Type::press : Command::Type::release;
     out.track = key / 12 + trackOffset;
     out.column = key % 12 + columnOffset;
+    out.scope = playingHeld ? Command::Scope::columnPlaying : columnHeld ? Command::Scope::column : Command::Scope::track;
+    out.barSync = barHeld;
     return out.track < maxTracks;
 }
 
@@ -536,3 +570,28 @@ bool recordedClip (const Song& song, const RecordedPass& pass, Clip& out)
     return true;
 }
 } // namespace lynx::perf
+
+namespace lynx::perf
+{
+void prepareForPerformance (Song& song, int count, std::int64_t spacing)
+{
+    count = std::clamp (count, 1, 256);
+    spacing = std::max<std::int64_t> (1, spacing);
+    const auto zone = (std::int64_t) count * spacing;
+    noteedit::insertTime (song.playlist, song.markers(), 0, zone);
+    for (int k = 0; k < count; ++k)
+    {
+        Marker m;
+        m.tick = k * spacing;
+        m.name = std::to_string (k + 1);
+        song.addMarker (m);
+    }
+    Marker start;
+    start.tick = zone;
+    start.name = "Start";
+    start.action = Marker::songStart;
+    song.addMarker (start);
+    song.performanceMode = true;
+    song.mode = PlayMode::song;
+}
+} // namespace lynx::perf

+ 14 - 2
src/core/Performance.h

@@ -41,16 +41,23 @@ struct Command
     std::int64_t clipStart = 0; // identifies the clip on its track (stable across edits that don't move it)
     std::int64_t columnStart = 0, columnEnd = 0; // launchColumn: every zone clip starting in [columnStart, columnEnd)
     int column = -1; // press / release from a controller: the track's column-th zone clip (clipStart unused)
+    // a controller's modifier notes ([DECOMP] FUN_01221c00 flags 0x80 / 0x100 / 0x8)
+    enum class Scope : std::uint8_t { track, column, columnPlaying };
+    Scope scope = Scope::track; // column: every track's clip in that clip's column; columnPlaying: only tracks playing
+    bool barSync = false;       // starts on the next bar instead of the track's trigger sync
 };
 
 // FL's "MIDI channel used for playlist live mode" ([DECOMP] 0x1181be1): on that channel a note below 120 launches
 // track (note / 12 + trackOffset), column (note % 12 + columnOffset) — one octave per track, twelve clips each;
 // 120 / 121 move the track offset down / up (by 1, or 10), 122 / 123 the column offset (by 1, or 12), 124 switches
-// the big steps. False when the note is a navigation key (offsets changed, no command).
+// the big steps; 125 / 126 / 127 are held modifiers (flags 0x80, 0x180, 0x8 on the launches, FUN_01221c00): 125 = the
+// note launches its clip's whole column, 126 = the column on the tracks already playing only, 127 = the launch waits
+// for the next bar instead of the track's trigger sync. False when the note is a navigation or modifier key.
 struct MidiMapping
 {
     int trackOffset = 0, columnOffset = 0;
     bool bigSteps = false;
+    bool columnHeld = false, playingHeld = false, barHeld = false;
     bool note (int key, bool on, Command& out) noexcept;
 };
 
@@ -143,7 +150,7 @@ private:
     TrackState* stateOf (int track, bool create) noexcept;
     void apply (const Song& song, const std::vector<int>& zone, const Command& c, double now, Live* live) noexcept;
     void launch (const Song& song, const std::vector<int>& zone, TrackState& t, std::int64_t clipStart, double now,
-                 bool immediate) noexcept;
+                 bool immediate, double syncOverride = 0.0) noexcept;
     void stopTrack (const Song& song, const std::vector<int>& zone, TrackState& t, double now, bool quantized) noexcept;
     void recordPartial (const Song& song, const std::vector<int>& zone, const TrackState& t, const Play& p, double at,
                         Live* live) noexcept;
@@ -163,4 +170,9 @@ void schedulePerformance (const Song& song, const Player& player, double clock,
 
 // Recording: turns a pass into a clip copy for the arrangement (the zone clip moved to the song position).
 bool recordedClip (const Song& song, const RecordedPass& pass, Clip& out);
+
+// FL's Tools › Macros › Prepare for performance mode ([DECOMP] FUN_0122d010): makes room for a launch grid before the
+// song — `count` columns `spacing` ticks wide are inserted at the start (everything moves right), a marker at each
+// column, a "Start" marker where the song now begins, and Performance mode on (song mode).
+void prepareForPerformance (Song& song, int count, std::int64_t spacing);
 } // namespace lynx::perf

+ 3 - 1
src/core/RackRenderer.cpp

@@ -459,10 +459,12 @@ std::unique_ptr<const RackState> RackState::build (Song song,
                                    ? previous->echoes[c]
                                    : std::make_shared<channelmisc::NoteEcho>();
 
+    // (FL's Kepler keeps sounding when its cut group cuts it: FL's renders with and without "cut itself" are the same
+    // and both null against the engine fed every note to its end, REA_rodada165g-flbeta165k §3)
     for (std::size_t c = 0; c < channels.size(); ++c)
         if (channels[c].cutGroup > 0)
             for (std::size_t d = 0; d < channels.size(); ++d)
-                if (channels[d].cutBy == channels[c].cutGroup)
+                if (channels[d].cutBy == channels[c].cutGroup && channels[d].instrument != InstrumentKind::kepler)
                 {
                     state->cutTargets[c].push_back ((int) d);
                     state->hasCutGroups = true;

+ 33 - 0
src/core/SampleFiles.h

@@ -0,0 +1,33 @@
+#pragma once
+
+#include <array>
+#include <cctype>
+#include <string_view>
+
+namespace lynx
+{
+// The audio files LYNX loads as samples, by extension: wav, aif(f), flac, ogg, mp3 and FL's WavPack (.wv, FL's own
+// sample packs). Every drop target (Channel Rack, Playlist, Newtone...) and the Browser ask this through
+// SampleLibrary::isSampleFile, so they all take what the Browser lists (round 165q: the Channel Rack ignored the .wv
+// pack samples dropped from the Browser).
+inline constexpr std::array<std::string_view, 7> sampleFileExtensions { "wav", "aif", "aiff", "flac", "ogg", "mp3", "wv" };
+
+// `extension` with or without its leading dot, in any case ("WAV", ".wv").
+inline bool isSampleExtension (std::string_view extension)
+{
+    if (! extension.empty() && extension.front() == '.')
+        extension.remove_prefix (1);
+
+    for (const auto known : sampleFileExtensions)
+    {
+        if (known.size() != extension.size())
+            continue;
+        bool same = true;
+        for (std::size_t i = 0; i < known.size() && same; ++i)
+            same = std::tolower ((unsigned char) extension[i]) == known[i];
+        if (same)
+            return true;
+    }
+    return false;
+}
+} // namespace lynx

+ 6 - 0
src/engine/SampleLibrary.cpp

@@ -11,6 +11,7 @@
 #include <set>
 
 #include "core/AudioEdit.h"
+#include "core/SampleFiles.h"
 #include "core/OggVorbis.h"
 #include "core/Mp3Decoder.h"
 #include "core/TimeStretch.h"
@@ -162,6 +163,11 @@ SampleLibrary::SampleLibrary()
     formats.registerFormat (new WavPackAudioFormat(), false); // .wv files from FL packs
 }
 
+bool SampleLibrary::isSampleFile (const juce::File& file)
+{
+    return isSampleExtension (file.getFileExtension().toStdString());
+}
+
 juce::String SampleLibrary::wildcard() const
 {
     return formats.getWildcardForAllFormats();

+ 4 - 0
src/engine/SampleLibrary.h

@@ -36,6 +36,10 @@ public:
     // Filter for FileChooser ("*.wav;*.flac;...")
     juce::String wildcard() const;
 
+    // The audio files LYNX loads as samples (core/SampleFiles.h: wav, aif(f), flac, ogg, mp3 and FL's WavPack .wv).
+    // Every drop target (Channel Rack, Playlist, Audio editor...) asks this, so they all take what the Browser lists.
+    static bool isSampleFile (const juce::File& file);
+
 private:
     std::unique_ptr<juce::AudioFormatReader> createReader (const juce::File& file);
     std::shared_ptr<const SampleData> loadStreamed (const juce::File& file, juce::AudioFormatReader& reader);

+ 1 - 1
src/ui/BrowserComponent.cpp

@@ -37,7 +37,7 @@ namespace
 {
 bool isAudio (const juce::File& f)
 {
-    return f.hasFileExtension ("wav;flac;ogg;mp3;aif;aiff;wv");
+    return SampleLibrary::isSampleFile (f);
 }
 
 bool isListed (const juce::File& f)

+ 3 - 3
src/ui/ChannelRackComponent.cpp

@@ -1261,7 +1261,7 @@ bool ChannelRackComponent::loadSampleIntoSelected (const juce::File& file)
     const auto row = engine.getSelectedChannel();
     const auto& song = engine.getSong();
 
-    if (row < 0 || row >= (int) song.channels.size() || ! file.hasFileExtension ("wav;aif;aiff;flac;ogg;mp3"))
+    if (row < 0 || row >= (int) song.channels.size() || ! SampleLibrary::isSampleFile (file))
         return false;
 
     const auto kind = song.channels[(std::size_t) row].instrument;
@@ -2365,7 +2365,7 @@ void ChannelRackComponent::sliceChannel (int channel)
 bool ChannelRackComponent::isInterestedInFileDrag (const juce::StringArray& files)
 {
     for (const auto& f : files)
-        if (juce::File (f).hasFileExtension ("wav;aif;aiff;flac;ogg;mp3;sf2;sf3"))
+        if (SampleLibrary::isSampleFile (juce::File (f)) || juce::File (f).hasFileExtension ("sf2;sf3"))
             return true;
 
     return false;
@@ -2388,7 +2388,7 @@ void ChannelRackComponent::filesDropped (const juce::StringArray& files, int x,
             target = -1;
             continue;
         }
-        if (! file.hasFileExtension ("wav;aif;aiff;flac;ogg;mp3"))
+        if (! SampleLibrary::isSampleFile (file)) // (FL's WavPack pack samples too: round 165q)
             continue;
 
         assignSample (target, file);

+ 89 - 1
src/ui/ChannelSettings.cpp

@@ -945,8 +945,11 @@ public:
             for (int i = 0; i < threeOscParamCount(); ++i)
                 addThreeOsc (i);
         else if (granulizer)
+        {
             for (int i = 0; i < granulizerParamCount(); ++i)
                 addGranulizer (i);
+            setupGranulizerModes (def);
+        }
         else if (drumaxx)
         {
             addDrumaxx (0x2c1, "Master");
@@ -1018,7 +1021,7 @@ public:
             for (const auto& [index, name] : drumpadKnobs)
                 add (index, name);
         const auto rows = ((int) knobs.size() + 6) / 7; // the grid of resized()
-        setSize (720, std::max (dx10 || threeOsc ? 500 : 384, 46 + rows * 110 + 8));
+        setSize (720, std::max (dx10 || threeOsc ? 500 : 384, 46 + rows * 110 + 8 + (granulizerModes ? 64 : 0)));
 
         // a Granulizer node inside a Patcher (round 165c): no channel to drop a sample on, so its own Sample button
         if (granulizer && ref.index < 0)
@@ -1448,9 +1451,94 @@ public:
         constexpr int columns = 7, w = 96, h = 92;
         for (std::size_t i = 0; i < knobs.size(); ++i)
             knobs[i]->setBounds (12 + (int) (i % columns) * (w + 4), 46 + (int) (i / columns) * (h + 18), w, h);
+        if (granulizerModes)
+        {
+            // FL's KEY TO, TRANSIENTS and TEMPO LOCKED controls, in a row under the knobs
+            const auto rows = ((int) knobs.size() + columns - 1) / columns;
+            const auto y = 46 + rows * (h + 18) + 4;
+            granKeyToLabel.setBounds (12, y, 150, 18);
+            granKeyTo.setBounds (12, y + 20, 150, 24);
+            granTransientsLabel.setBounds (174, y, 150, 18);
+            granTransients.setBounds (174, y + 20, 150, 24);
+            granTempoLocked.setBounds (336, y + 20, 140, 24);
+            granBeatsLabel.setBounds (488, y, 200, 18);
+            granBeats.setBounds (488, y + 20, 200, 24);
+        }
     }
 
 private:
+    // Fruity Granulizer: what the keys move (Key to), where the slices come from (Transients), tempo lock and the beat
+    // count it uses (REA_rodada165g-flgran165)
+    void setupGranulizerModes (const ChannelDef& def)
+    {
+        const auto keyMode = granulizerMode (def.pluginState, 1), sliceMode = granulizerMode (def.pluginState, 0),
+                   sync = granulizerMode (def.pluginState, 2);
+        if (! keyMode || ! sliceMode || ! sync)
+            return;
+        granulizerModes = true;
+        auto label = [this] (juce::Label& l, const juce::String& text) {
+            l.setText (text, juce::dontSendNotification);
+            l.setFont (theme::font (theme::type::small));
+            addAndMakeVisible (l);
+        };
+        label (granKeyToLabel, tr ("Key to"));
+        granKeyTo.addItem (tr ("Pitch"), 1);
+        granKeyTo.addItem (tr ("Percent"), 2);
+        granKeyTo.addItem (tr ("Step"), 3);
+        granKeyTo.addItem (tr ("Transient"), 4);
+        granKeyTo.setSelectedId (std::clamp (*keyMode, 0, 3) + 1, juce::dontSendNotification);
+        granKeyTo.setTooltip (tr ("What the keys do: Pitch = transpose; Percent = start point (sample time, C5 to C7); "
+                                  "Step = start point in 16th notes (song time); Transient = start at the slice of the key"));
+        granKeyTo.onChange = [this] {
+            const auto v = granKeyTo.getSelectedId() - 1;
+            ref.edit (engine, [v] (ChannelDef& d) { granulizerSetMode (d.pluginState, 1, v); });
+            if (v == 3 && granTransients.getSelectedId() == 1) // as FL: transient keys switch slice detection on
+                granTransients.setSelectedId (3, juce::dontSendNotification);
+        };
+        addAndMakeVisible (granKeyTo);
+        label (granTransientsLabel, tr ("Transients"));
+        granTransients.addItem (tr ("Off"), 1);
+        granTransients.addItem (tr ("Use regions"), 2);
+        granTransients.addItem (tr ("Detect"), 3);
+        granTransients.setSelectedId (std::clamp (*sliceMode, 0, 2) + 1, juce::dontSendNotification);
+        granTransients.setTooltip (tr ("Transients source: the sample's cue points / regions, or FL's automatic slicing. "
+                                       "Grains then line up with the slices and the Transient hold knob sets how long each "
+                                       "slice's first grain holds"));
+        granTransients.onChange = [this] {
+            const auto v = granTransients.getSelectedId() - 1;
+            ref.edit (engine, [v] (ChannelDef& d) { granulizerSetMode (d.pluginState, 0, v); });
+        };
+        addAndMakeVisible (granTransients);
+        granTempoLocked.setButtonText (tr ("Tempo locked"));
+        granTempoLocked.setToggleState (*sync != 0, juce::dontSendNotification);
+        granTempoLocked.setTooltip (tr ("Match song tempo: the sample plays once per its length in beats (the WAV's ACID "
+                                        "beats, else Beats below). Loop is always on and Wave spacing has no effect while "
+                                        "locked"));
+        granTempoLocked.onClick = [this] {
+            const auto on = granTempoLocked.getToggleState();
+            ref.edit (engine, [on] (ChannelDef& d) { granulizerSetMode (d.pluginState, 2, on ? 1 : 0); });
+        };
+        addAndMakeVisible (granTempoLocked);
+        label (granBeatsLabel, tr ("Beats (0 = the sample's own)"));
+        granBeats.setSliderStyle (juce::Slider::LinearHorizontal);
+        granBeats.setTextBoxStyle (juce::Slider::TextBoxRight, false, 56, 20);
+        granBeats.setRange (0.0, 64.0, 0.25);
+        granBeats.setValue (def.sampler.stretchBeats, juce::dontSendNotification);
+        granBeats.setTooltip (tr ("The sample's length in beats for Tempo locked and the Step keys, as FL's time-stretch "
+                                  "TIME; a WAV with ACID beats uses its own"));
+        granBeats.onValueChange = [this] {
+            const auto v = (float) granBeats.getValue();
+            ref.edit (engine, [v] (ChannelDef& d) { d.sampler.stretchBeats = v; });
+        };
+        addAndMakeVisible (granBeats);
+    }
+
+    bool granulizerModes = false;
+    juce::ComboBox granKeyTo, granTransients;
+    juce::ToggleButton granTempoLocked;
+    juce::Slider granBeats;
+    juce::Label granKeyToLabel, granTransientsLabel, granBeatsLabel;
+
     AudioEngine& engine;
     ChannelRef ref;
     juce::Colour accent { skin::colour::crimson }; // the plugin page's accent (ui/PluginSkin.h)

+ 317 - 211
src/ui/I18nData.h

@@ -16540,216 +16540,322 @@ inline constexpr unsigned char ptBR[] = {
 34, 10, 34, 66, 108, 97, 99, 107, 32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97,
 115, 32, 112, 114, 101, 116, 97, 115, 34, 10, 34, 83, 104, 97, 114, 112, 115, 32, 40, 35, 41, 34, 32, 61,
 32, 34, 83, 117, 115, 116, 101, 110, 105, 100, 111, 115, 32, 40, 35, 41, 34, 10, 34, 70, 108, 97, 116, 115,
-32, 40, 98, 41, 34, 32, 61, 32, 34, 66, 101, 109, 195, 179, 105, 115, 32, 40, 98, 41, 34, 10, 10, 35,
-32, 45, 45, 45, 32, 77, 105, 120, 101, 114, 58, 32, 116, 114, 97, 99, 107, 32, 108, 97, 116, 101, 110, 99,
-121, 44, 32, 114, 111, 117, 116, 105, 110, 103, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 226, 135, 132, 32,
-116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 44, 32, 115, 117, 98, 109, 105, 120, 44, 32, 114, 101, 110, 100,
-101, 114, 32, 116, 114, 97, 99, 107, 115, 32, 40, 82, 69, 65, 32, 114, 111, 117, 110, 100, 32, 49, 54, 53,
-102, 45, 109, 105, 120, 101, 114, 41, 10, 34, 84, 114, 97, 99, 107, 32, 108, 97, 116, 101, 110, 99, 121, 58,
-32, 123, 48, 125, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 97, 32, 102, 97,
-105, 120, 97, 58, 32, 123, 48, 125, 34, 10, 34, 84, 114, 97, 99, 107, 115, 34, 32, 61, 32, 34, 70, 97,
-105, 120, 97, 115, 34, 10, 34, 82, 101, 110, 100, 101, 114, 32, 109, 105, 120, 101, 114, 32, 116, 114, 97, 99,
-107, 115, 32, 116, 111, 32, 97, 117, 100, 105, 111, 32, 102, 105, 108, 101, 115, 34, 32, 61, 32, 34, 82, 101,
-110, 100, 101, 114, 105, 122, 97, 114, 32, 102, 97, 105, 120, 97, 115, 32, 100, 111, 32, 109, 105, 120, 101, 114,
-32, 101, 109, 32, 97, 114, 113, 117, 105, 118, 111, 115, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 34, 10,
-34, 76, 97, 116, 101, 110, 99, 121, 32, 40, 109, 115, 41, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110,
-99, 105, 97, 32, 40, 109, 115, 41, 34, 10, 34, 76, 97, 116, 101, 110, 99, 121, 32, 40, 115, 97, 109, 112,
-108, 101, 115, 41, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 40, 97, 109, 111, 115,
-116, 114, 97, 115, 41, 34, 10, 34, 76, 97, 116, 101, 110, 99, 121, 32, 40, 98, 101, 97, 116, 115, 41, 34,
-32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 40, 116, 101, 109, 112, 111, 115, 41, 34, 10,
-34, 84, 114, 97, 99, 107, 32, 108, 97, 116, 101, 110, 99, 121, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170,
-110, 99, 105, 97, 32, 100, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 80, 111, 115, 105, 116, 105, 118, 101,
-58, 32, 116, 104, 101, 32, 111, 116, 104, 101, 114, 32, 116, 114, 97, 99, 107, 115, 32, 119, 97, 105, 116, 32,
-102, 111, 114, 32, 116, 104, 105, 115, 32, 111, 110, 101, 32, 40, 105, 116, 32, 112, 108, 97, 121, 115, 32, 101,
-97, 114, 108, 105, 101, 114, 41, 46, 32, 78, 101, 103, 97, 116, 105, 118, 101, 58, 32, 116, 104, 105, 115, 32,
-116, 114, 97, 99, 107, 32, 105, 115, 32, 100, 101, 108, 97, 121, 101, 100, 46, 34, 32, 61, 32, 34, 80, 111,
-115, 105, 116, 105, 118, 111, 58, 32, 97, 115, 32, 111, 117, 116, 114, 97, 115, 32, 102, 97, 105, 120, 97, 115,
-32, 101, 115, 112, 101, 114, 97, 109, 32, 112, 111, 114, 32, 101, 115, 116, 97, 32, 40, 101, 108, 97, 32, 116,
-111, 99, 97, 32, 97, 110, 116, 101, 115, 41, 46, 32, 78, 101, 103, 97, 116, 105, 118, 111, 58, 32, 101, 115,
-116, 97, 32, 102, 97, 105, 120, 97, 32, 195, 169, 32, 97, 116, 114, 97, 115, 97, 100, 97, 46, 34, 10, 34,
-76, 97, 116, 101, 110, 99, 121, 32, 123, 48, 125, 32, 109, 115, 32, 40, 97, 117, 116, 111, 32, 123, 49, 125,
-32, 109, 115, 44, 32, 109, 97, 110, 117, 97, 108, 32, 123, 50, 125, 32, 109, 115, 41, 34, 32, 61, 32, 34,
-76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 123, 48, 125, 32, 109, 115, 32, 40, 97, 117, 116, 111, 109, 195,
-161, 116, 105, 99, 97, 32, 123, 49, 125, 32, 109, 115, 44, 32, 109, 97, 110, 117, 97, 108, 32, 123, 50, 125,
-32, 109, 115, 41, 34, 10, 34, 84, 104, 101, 32, 100, 101, 108, 97, 121, 32, 105, 110, 116, 114, 111, 100, 117,
-99, 101, 100, 32, 98, 121, 32, 116, 104, 105, 115, 32, 109, 105, 120, 101, 114, 32, 116, 114, 97, 99, 107, 32,
-105, 115, 32, 104, 105, 103, 104, 101, 114, 32, 116, 104, 97, 110, 32, 116, 104, 101, 32, 100, 101, 108, 97, 121,
-32, 105, 110, 116, 114, 111, 100, 117, 99, 101, 100, 32, 98, 121, 32, 116, 104, 101, 32, 115, 111, 117, 114, 99,
-101, 32, 109, 105, 120, 101, 114, 32, 116, 114, 97, 99, 107, 46, 32, 83, 101, 116, 32, 97, 32, 109, 97, 107,
-101, 45, 117, 112, 32, 108, 97, 116, 101, 110, 99, 121, 32, 111, 110, 32, 116, 104, 101, 32, 115, 111, 117, 114,
-99, 101, 32, 116, 114, 97, 99, 107, 32, 105, 110, 115, 116, 101, 97, 100, 46, 34, 32, 61, 32, 34, 79, 32,
-97, 116, 114, 97, 115, 111, 32, 100, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 100, 111, 32, 109, 105,
-120, 101, 114, 32, 195, 169, 32, 109, 97, 105, 111, 114, 32, 113, 117, 101, 32, 111, 32, 100, 97, 32, 102, 97,
-105, 120, 97, 32, 100, 101, 32, 111, 114, 105, 103, 101, 109, 46, 32, 68, 101, 102, 105, 110, 97, 32, 117, 109,
-97, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 101, 32, 99, 111, 109, 112, 101, 110, 115, 97, 195,
-167, 195, 163, 111, 32, 110, 97, 32, 102, 97, 105, 120, 97, 32, 100, 101, 32, 111, 114, 105, 103, 101, 109, 46,
-34, 10, 34, 83, 101, 116, 32, 102, 114, 111, 109, 34, 32, 61, 32, 34, 68, 101, 102, 105, 110, 105, 114, 32,
-97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 101, 34, 10, 34, 67, 111, 109, 112, 101, 110, 115, 97, 116, 101,
-32, 102, 111, 114, 32, 109, 97, 115, 116, 101, 114, 32, 108, 97, 116, 101, 110, 99, 121, 34, 32, 61, 32, 34,
-67, 111, 109, 112, 101, 110, 115, 97, 114, 32, 97, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 111,
-32, 77, 97, 115, 116, 101, 114, 34, 10, 34, 66, 121, 112, 97, 115, 115, 32, 116, 114, 97, 99, 107, 32, 108,
-97, 116, 101, 110, 99, 121, 32, 99, 111, 109, 112, 101, 110, 115, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34,
-73, 103, 110, 111, 114, 97, 114, 32, 97, 32, 99, 111, 109, 112, 101, 110, 115, 97, 195, 167, 195, 163, 111, 32,
-100, 101, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34,
-65, 108, 119, 97, 121, 115, 34, 32, 61, 32, 34, 83, 101, 109, 112, 114, 101, 34, 10, 34, 87, 104, 101, 110,
-32, 114, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111, 114, 32, 110, 111, 116, 32, 112, 108, 97, 121, 105, 110,
-103, 34, 32, 61, 32, 34, 65, 111, 32, 103, 114, 97, 118, 97, 114, 32, 111, 117, 32, 112, 97, 114, 97, 100,
-111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 101, 100, 32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 116,
-104, 105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 115, 32, 115, 101, 108,
-101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120,
-97, 34, 10, 34, 82, 111, 117, 116, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 111, 32, 116, 104,
-105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 97, 115, 32, 115,
-101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97,
-105, 120, 97, 34, 10, 34, 82, 111, 117, 116, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 111, 32,
-116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 82, 111, 116, 101,
-97, 114, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 115, 195, 179, 32, 112,
-97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97,
-105, 110, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 111, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99,
-107, 34, 32, 61, 32, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 100, 97, 115, 32, 115, 101, 108, 101,
-99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97,
-34, 10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 111,
-32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 83, 105, 100,
-101, 99, 104, 97, 105, 110, 32, 100, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32,
-115, 195, 179, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 67, 114,
-101, 97, 116, 101, 32, 115, 117, 98, 109, 105, 120, 46, 46, 46, 34, 32, 61, 32, 34, 67, 114, 105, 97, 114,
-32, 115, 117, 98, 109, 105, 120, 46, 46, 46, 34, 10, 34, 67, 114, 101, 97, 116, 101, 32, 115, 117, 98, 109,
-105, 120, 34, 32, 61, 32, 34, 67, 114, 105, 97, 114, 32, 115, 117, 98, 109, 105, 120, 34, 10, 34, 84, 104,
-105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 114, 97,
-99, 107, 115, 34, 32, 61, 32, 34, 69, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 112, 97, 114, 97, 32,
-97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 82, 111, 117, 116, 101, 32,
-116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101, 100, 34, 32,
-61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 112, 97, 114,
-97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 82, 111, 117, 116,
-101, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101, 100,
-32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 101, 115, 116, 97, 32, 102, 97,
-105, 120, 97, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110,
-97, 100, 97, 115, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 116, 104, 105, 115, 32, 116, 114,
-97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101, 100, 34, 32, 61, 32, 34, 83, 105, 100, 101,
-99, 104, 97, 105, 110, 32, 100, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 112, 97, 114, 97, 32, 97,
-115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97,
-105, 110, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101,
-100, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 100, 101, 115,
-116, 97, 32, 102, 97, 105, 120, 97, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 97, 115, 32, 115, 101, 108,
-101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 83, 101, 108, 101, 99, 116, 101, 100, 32, 116, 114, 97,
-99, 107, 115, 32, 226, 135, 132, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 70,
-97, 105, 120, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 226, 135, 132, 32, 101,
-115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 82, 101, 110, 100, 101, 114, 32, 97, 114, 109, 101, 100,
-32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 119, 97, 118, 101, 32, 102, 105, 108, 101, 40, 115, 41, 46,
-46, 46, 34, 32, 61, 32, 34, 82, 101, 110, 100, 101, 114, 105, 122, 97, 114, 32, 97, 115, 32, 102, 97, 105,
-120, 97, 115, 32, 97, 114, 109, 97, 100, 97, 115, 32, 101, 109, 32, 97, 114, 113, 117, 105, 118, 111, 40, 115,
-41, 32, 87, 65, 86, 46, 46, 46, 34, 10, 34, 82, 101, 110, 100, 101, 114, 32, 115, 101, 108, 101, 99, 116,
-101, 100, 32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 119, 97, 118, 101, 32, 102, 105, 108, 101, 40, 115,
-41, 46, 46, 46, 34, 32, 61, 32, 34, 82, 101, 110, 100, 101, 114, 105, 122, 97, 114, 32, 97, 115, 32, 102,
-97, 105, 120, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 101, 109, 32, 97, 114,
-113, 117, 105, 118, 111, 40, 115, 41, 32, 87, 65, 86, 46, 46, 46, 34, 10, 34, 68, 105, 115, 107, 32, 114,
-101, 99, 111, 114, 100, 105, 110, 103, 34, 32, 61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32,
-101, 109, 32, 100, 105, 115, 99, 111, 34, 10, 34, 82, 101, 115, 101, 116, 32, 109, 97, 110, 117, 97, 108, 32,
-108, 97, 116, 101, 110, 99, 121, 32, 111, 110, 32, 97, 108, 108, 32, 116, 114, 97, 99, 107, 115, 34, 32, 61,
-32, 34, 90, 101, 114, 97, 114, 32, 97, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 109, 97, 110, 117,
-97, 108, 32, 100, 101, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 102, 97, 105, 120, 97, 115, 34, 10, 34,
-87, 97, 114, 110, 105, 110, 103, 34, 32, 61, 32, 34, 65, 118, 105, 115, 111, 34, 10, 34, 84, 104, 105, 115,
-32, 119, 105, 108, 108, 32, 114, 101, 115, 101, 116, 32, 109, 97, 110, 117, 97, 108, 32, 108, 97, 116, 101, 110,
-99, 121, 32, 118, 97, 108, 117, 101, 115, 32, 111, 110, 32, 97, 108, 108, 32, 109, 105, 120, 101, 114, 32, 116,
-114, 97, 99, 107, 115, 46, 34, 32, 61, 32, 34, 73, 115, 116, 111, 32, 118, 97, 105, 32, 122, 101, 114, 97,
-114, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 32, 100, 101, 32, 108, 97, 116, 195, 170, 110, 99, 105,
-97, 32, 109, 97, 110, 117, 97, 108, 32, 100, 101, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 102, 97, 105,
-120, 97, 115, 32, 100, 111, 32, 109, 105, 120, 101, 114, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 100,
-101, 108, 97, 121, 32, 99, 111, 109, 112, 101, 110, 115, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 67, 111,
-109, 112, 101, 110, 115, 97, 195, 167, 195, 163, 111, 32, 100, 101, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97,
-32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 34, 10, 34, 66, 97, 108, 97, 110, 99, 101, 32, 111, 102,
-32, 116, 104, 101, 32, 105, 110, 112, 117, 116, 32, 98, 101, 102, 111, 114, 101, 32, 116, 104, 101, 32, 100, 101,
-45, 101, 115, 115, 101, 114, 32, 104, 101, 97, 114, 115, 32, 105, 116, 34, 32, 61, 32, 34, 66, 97, 108, 97,
-110, 195, 167, 111, 32, 100, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 97, 110, 116, 101, 115, 32, 100, 101,
-32, 111, 32, 100, 101, 45, 101, 115, 115, 101, 114, 32, 111, 117, 118, 105, 45, 108, 97, 34, 10, 34, 66, 97,
-108, 97, 110, 99, 101, 32, 111, 102, 32, 116, 104, 101, 32, 111, 117, 116, 112, 117, 116, 34, 32, 61, 32, 34,
-66, 97, 108, 97, 110, 195, 167, 111, 32, 100, 97, 32, 115, 97, 195, 173, 100, 97, 34, 10, 10, 35, 32, 45,
-45, 45, 32, 114, 111, 117, 110, 100, 32, 49, 54, 53, 112, 32, 40, 105, 115, 115, 117, 101, 32, 35, 49, 50,
-41, 58, 32, 101, 100, 105, 116, 111, 114, 32, 116, 111, 111, 108, 32, 107, 101, 121, 115, 32, 105, 110, 32, 116,
-104, 101, 32, 107, 101, 121, 32, 109, 97, 112, 10, 34, 84, 111, 111, 108, 58, 32, 80, 101, 110, 99, 105, 108,
-34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 76, 195, 161, 112, 105, 115, 34,
-10, 34, 84, 111, 111, 108, 58, 32, 66, 114, 117, 115, 104, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109,
-101, 110, 116, 97, 58, 32, 80, 105, 110, 99, 101, 108, 34, 10, 34, 84, 111, 111, 108, 58, 32, 68, 114, 117,
-109, 32, 98, 114, 117, 115, 104, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32,
-80, 105, 110, 99, 101, 108, 32, 100, 101, 32, 98, 97, 116, 101, 114, 105, 97, 34, 10, 34, 84, 111, 111, 108,
-58, 32, 69, 114, 97, 115, 101, 114, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58,
-32, 66, 111, 114, 114, 97, 99, 104, 97, 34, 10, 34, 84, 111, 111, 108, 58, 32, 77, 117, 116, 101, 34, 32,
-61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 83, 105, 108, 101, 110, 99, 105, 97, 114,
-34, 10, 34, 84, 111, 111, 108, 58, 32, 75, 110, 105, 102, 101, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97,
-109, 101, 110, 116, 97, 58, 32, 70, 97, 99, 97, 34, 10, 34, 84, 111, 111, 108, 58, 32, 76, 97, 115, 115,
-111, 32, 40, 115, 101, 108, 101, 99, 116, 41, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116,
-97, 58, 32, 76, 97, 195, 167, 111, 32, 40, 115, 101, 108, 101, 99, 105, 111, 110, 97, 114, 41, 34, 10, 34,
-84, 111, 111, 108, 58, 32, 90, 111, 111, 109, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116,
-97, 58, 32, 90, 111, 111, 109, 34, 10, 34, 84, 111, 111, 108, 58, 32, 76, 105, 115, 116, 101, 110, 34, 32,
-61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 79, 117, 118, 105, 114, 34, 10, 34, 84,
-111, 111, 108, 58, 32, 83, 108, 105, 112, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97,
-58, 32, 68, 101, 115, 108, 105, 122, 97, 114, 32, 99, 111, 110, 116, 101, 195, 186, 100, 111, 34, 10, 34, 83,
-108, 105, 100, 101, 32, 110, 111, 116, 101, 115, 32, 111, 110, 47, 111, 102, 102, 32, 40, 110, 101, 119, 32, 110,
-111, 116, 101, 115, 41, 34, 32, 61, 32, 34, 78, 111, 116, 97, 115, 32, 115, 108, 105, 100, 101, 32, 108, 105,
-103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 32, 40, 110, 111, 116, 97, 115, 32, 110, 111, 118, 97, 115, 41,
-34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34,
-67, 97, 110, 97, 108, 32, 97, 110, 116, 101, 114, 105, 111, 114, 34, 10, 34, 78, 101, 120, 116, 32, 99, 104,
-97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 99, 97, 110, 97, 108,
-34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 99, 104, 97, 110, 110, 101, 108, 32, 119, 105, 116, 104,
-32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 32, 97, 110, 116, 101, 114, 105, 111,
-114, 32, 99, 111, 109, 32, 110, 111, 116, 97, 115, 34, 10, 34, 78, 101, 120, 116, 32, 99, 104, 97, 110, 110,
-101, 108, 32, 119, 105, 116, 104, 32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105,
-109, 111, 32, 99, 97, 110, 97, 108, 32, 99, 111, 109, 32, 110, 111, 116, 97, 115, 34, 10, 34, 123, 48, 125,
-32, 119, 97, 115, 32, 97, 108, 115, 111, 32, 123, 49, 125, 58, 32, 121, 111, 117, 114, 32, 107, 101, 121, 32,
-119, 105, 110, 115, 32, 116, 104, 101, 114, 101, 32, 110, 111, 119, 46, 34, 32, 61, 32, 34, 123, 48, 125, 32,
-116, 97, 109, 98, 195, 169, 109, 32, 101, 114, 97, 32, 123, 49, 125, 58, 32, 97, 103, 111, 114, 97, 32, 97,
-32, 115, 117, 97, 32, 116, 101, 99, 108, 97, 32, 118, 97, 108, 101, 32, 108, 195, 161, 46, 34, 10, 34, 80,
-97, 116, 116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 32, 105, 110, 32, 98, 97, 114, 115, 58, 32, 91,
-76, 77, 66, 93, 32, 100, 114, 97, 103, 32, 111, 114, 32, 91, 87, 104, 101, 101, 108, 93, 32, 99, 104, 97,
-110, 103, 101, 32, 105, 116, 32, 32, 91, 50, 120, 76, 77, 66, 93, 32, 97, 117, 116, 111, 109, 97, 116, 105,
-99, 32, 40, 102, 114, 111, 109, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 41, 32, 32, 91, 82, 77, 66,
-93, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97,
-116, 116, 101, 114, 110, 32, 101, 109, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 58, 32, 91, 76, 77, 66,
-93, 32, 97, 114, 114, 97, 115, 116, 101, 32, 111, 117, 32, 91, 87, 104, 101, 101, 108, 93, 32, 112, 97, 114,
-97, 32, 109, 117, 100, 97, 114, 32, 32, 91, 50, 120, 76, 77, 66, 93, 32, 97, 117, 116, 111, 109, 195, 161,
-116, 105, 99, 111, 32, 40, 112, 101, 108, 97, 115, 32, 110, 111, 116, 97, 115, 41, 32, 32, 91, 82, 77, 66,
-93, 32, 109, 101, 110, 117, 34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 58,
-32, 123, 48, 125, 32, 40, 97, 117, 116, 111, 109, 97, 116, 105, 99, 44, 32, 102, 114, 111, 109, 32, 116, 104,
-101, 32, 110, 111, 116, 101, 115, 41, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32,
-112, 97, 116, 116, 101, 114, 110, 58, 32, 123, 48, 125, 32, 40, 97, 117, 116, 111, 109, 195, 161, 116, 105, 99,
-111, 44, 32, 112, 101, 108, 97, 115, 32, 110, 111, 116, 97, 115, 41, 34, 10, 34, 80, 97, 116, 116, 101, 114,
-110, 32, 108, 101, 110, 103, 116, 104, 32, 40, 98, 97, 114, 115, 44, 32, 48, 32, 61, 32, 97, 117, 116, 111,
-109, 97, 116, 105, 99, 41, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97,
-116, 116, 101, 114, 110, 32, 40, 99, 111, 109, 112, 97, 115, 115, 111, 115, 44, 32, 48, 32, 61, 32, 97, 117,
-116, 111, 109, 195, 161, 116, 105, 99, 111, 41, 34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 32, 108, 101, 110,
-103, 116, 104, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97, 116, 116, 101,
-114, 110, 34, 10, 34, 70, 111, 108, 108, 111, 119, 58, 32, 97, 32, 112, 97, 116, 116, 101, 114, 110, 32, 108,
-111, 110, 103, 101, 114, 32, 116, 104, 97, 110, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82,
-97, 99, 107, 32, 112, 97, 103, 101, 115, 32, 97, 108, 111, 110, 103, 32, 119, 105, 116, 104, 32, 116, 104, 101,
-32, 112, 108, 97, 121, 105, 110, 103, 32, 115, 116, 101, 112, 59, 32, 111, 102, 102, 44, 32, 105, 116, 32, 115,
-116, 97, 121, 115, 32, 119, 104, 101, 114, 101, 32, 121, 111, 117, 32, 115, 99, 114, 111, 108, 108, 101, 100, 34,
-32, 61, 32, 34, 83, 101, 103, 117, 105, 114, 58, 32, 117, 109, 32, 112, 97, 116, 116, 101, 114, 110, 32, 109,
-97, 105, 111, 114, 32, 113, 117, 101, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32,
-112, 97, 115, 115, 97, 32, 100, 101, 32, 112, 195, 161, 103, 105, 110, 97, 32, 106, 117, 110, 116, 111, 32, 99,
-111, 109, 32, 111, 32, 115, 116, 101, 112, 32, 116, 111, 99, 97, 110, 100, 111, 59, 32, 100, 101, 115, 108, 105,
-103, 97, 100, 111, 44, 32, 102, 105, 99, 97, 32, 111, 110, 100, 101, 32, 118, 111, 99, 195, 170, 32, 114, 111,
-108, 111, 117, 34, 10, 34, 70, 111, 108, 108, 111, 119, 32, 116, 104, 101, 32, 112, 108, 97, 121, 104, 101, 97,
-100, 32, 40, 112, 97, 103, 101, 32, 97, 108, 111, 110, 103, 32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 112,
-108, 97, 121, 105, 110, 103, 32, 115, 116, 101, 112, 41, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32, 34,
-83, 101, 103, 117, 105, 114, 32, 111, 32, 99, 117, 114, 115, 111, 114, 32, 100, 101, 32, 114, 101, 112, 114, 111,
-100, 117, 195, 167, 195, 163, 111, 32, 40, 112, 97, 115, 115, 97, 114, 32, 100, 101, 32, 112, 195, 161, 103, 105,
-110, 97, 32, 99, 111, 109, 32, 111, 32, 115, 116, 101, 112, 32, 116, 111, 99, 97, 110, 100, 111, 41, 32, 108,
-105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 34, 10, 34, 70, 111, 108, 108, 111, 119, 58, 32, 116, 104,
-101, 32, 118, 105, 101, 119, 32, 112, 97, 103, 101, 115, 32, 97, 108, 111, 110, 103, 32, 119, 105, 116, 104, 32,
-116, 104, 101, 32, 112, 108, 97, 121, 98, 97, 99, 107, 32, 112, 111, 115, 105, 116, 105, 111, 110, 59, 32, 111,
-102, 102, 44, 32, 105, 116, 32, 115, 116, 97, 121, 115, 32, 119, 104, 101, 114, 101, 32, 121, 111, 117, 32, 115,
-99, 114, 111, 108, 108, 101, 100, 34, 32, 61, 32, 34, 83, 101, 103, 117, 105, 114, 58, 32, 97, 32, 118, 105,
-115, 195, 163, 111, 32, 112, 97, 115, 115, 97, 32, 100, 101, 32, 112, 195, 161, 103, 105, 110, 97, 32, 106, 117,
-110, 116, 111, 32, 99, 111, 109, 32, 97, 32, 112, 111, 115, 105, 195, 167, 195, 163, 111, 32, 100, 101, 32, 114,
-101, 112, 114, 111, 100, 117, 195, 167, 195, 163, 111, 59, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 44, 32,
-102, 105, 99, 97, 32, 111, 110, 100, 101, 32, 118, 111, 99, 195, 170, 32, 114, 111, 108, 111, 117, 34, 10, 34,
-83, 101, 110, 100, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 116, 111, 32, 97, 32,
-110, 101, 119, 32, 83, 97, 109, 112, 108, 101, 114, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34,
-69, 110, 118, 105, 97, 114, 32, 97, 32, 115, 101, 108, 101, 195, 167, 195, 163, 111, 32, 112, 97, 114, 97, 32,
-117, 109, 32, 110, 111, 118, 111, 32, 99, 97, 110, 97, 108, 32, 83, 97, 109, 112, 108, 101, 114, 34, 10, 34,
-84, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 119, 101, 110, 116, 32, 116, 111, 32, 97, 32,
-110, 101, 119, 32, 83, 97, 109, 112, 108, 101, 114, 32, 99, 104, 97, 110, 110, 101, 108, 32, 40, 123, 48, 125,
-41, 34, 32, 61, 32, 34, 65, 32, 115, 101, 108, 101, 195, 167, 195, 163, 111, 32, 102, 111, 105, 32, 112, 97,
-114, 97, 32, 117, 109, 32, 110, 111, 118, 111, 32, 99, 97, 110, 97, 108, 32, 83, 97, 109, 112, 108, 101, 114,
-32, 40, 123, 48, 125, 41, 34, 10,
+32, 40, 98, 41, 34, 32, 61, 32, 34, 66, 101, 109, 195, 179, 105, 115, 32, 40, 98, 41, 34, 10, 34, 75,
+101, 121, 32, 116, 111, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 32, 112, 97, 114, 97, 34, 10, 34, 80,
+101, 114, 99, 101, 110, 116, 34, 32, 61, 32, 34, 80, 111, 114, 99, 101, 110, 116, 97, 103, 101, 109, 34, 10,
+34, 84, 114, 97, 110, 115, 105, 101, 110, 116, 34, 32, 61, 32, 34, 84, 114, 97, 110, 115, 105, 101, 110, 116,
+101, 34, 10, 34, 85, 115, 101, 32, 114, 101, 103, 105, 111, 110, 115, 34, 32, 61, 32, 34, 85, 115, 97, 114,
+32, 114, 101, 103, 105, 195, 181, 101, 115, 34, 10, 34, 84, 101, 109, 112, 111, 32, 108, 111, 99, 107, 101, 100,
+34, 32, 61, 32, 34, 84, 114, 97, 118, 97, 100, 111, 32, 110, 111, 32, 97, 110, 100, 97, 109, 101, 110, 116,
+111, 34, 10, 34, 87, 104, 97, 116, 32, 116, 104, 101, 32, 107, 101, 121, 115, 32, 100, 111, 58, 32, 80, 105,
+116, 99, 104, 32, 61, 32, 116, 114, 97, 110, 115, 112, 111, 115, 101, 59, 32, 80, 101, 114, 99, 101, 110, 116,
+32, 61, 32, 115, 116, 97, 114, 116, 32, 112, 111, 105, 110, 116, 32, 40, 115, 97, 109, 112, 108, 101, 32, 116,
+105, 109, 101, 44, 32, 67, 53, 32, 116, 111, 32, 67, 55, 41, 59, 32, 83, 116, 101, 112, 32, 61, 32, 115,
+116, 97, 114, 116, 32, 112, 111, 105, 110, 116, 32, 105, 110, 32, 49, 54, 116, 104, 32, 110, 111, 116, 101, 115,
+32, 40, 115, 111, 110, 103, 32, 116, 105, 109, 101, 41, 59, 32, 84, 114, 97, 110, 115, 105, 101, 110, 116, 32,
+61, 32, 115, 116, 97, 114, 116, 32, 97, 116, 32, 116, 104, 101, 32, 115, 108, 105, 99, 101, 32, 111, 102, 32,
+116, 104, 101, 32, 107, 101, 121, 34, 32, 61, 32, 34, 79, 32, 113, 117, 101, 32, 97, 115, 32, 116, 101, 99,
+108, 97, 115, 32, 102, 97, 122, 101, 109, 58, 32, 80, 105, 116, 99, 104, 32, 61, 32, 116, 114, 97, 110, 115,
+112, 195, 181, 101, 59, 32, 80, 111, 114, 99, 101, 110, 116, 97, 103, 101, 109, 32, 61, 32, 112, 111, 110, 116,
+111, 32, 100, 101, 32, 105, 110, 195, 173, 99, 105, 111, 32, 40, 116, 101, 109, 112, 111, 32, 100, 111, 32, 115,
+97, 109, 112, 108, 101, 44, 32, 67, 53, 32, 97, 32, 67, 55, 41, 59, 32, 83, 116, 101, 112, 32, 61, 32,
+112, 111, 110, 116, 111, 32, 100, 101, 32, 105, 110, 195, 173, 99, 105, 111, 32, 101, 109, 32, 115, 101, 109, 105,
+99, 111, 108, 99, 104, 101, 105, 97, 115, 32, 40, 116, 101, 109, 112, 111, 32, 100, 97, 32, 109, 195, 186, 115,
+105, 99, 97, 41, 59, 32, 84, 114, 97, 110, 115, 105, 101, 110, 116, 101, 32, 61, 32, 99, 111, 109, 101, 195,
+167, 97, 32, 110, 97, 32, 102, 97, 116, 105, 97, 32, 100, 97, 32, 116, 101, 99, 108, 97, 34, 10, 34, 84,
+114, 97, 110, 115, 105, 101, 110, 116, 115, 32, 115, 111, 117, 114, 99, 101, 58, 32, 116, 104, 101, 32, 115, 97,
+109, 112, 108, 101, 39, 115, 32, 99, 117, 101, 32, 112, 111, 105, 110, 116, 115, 32, 47, 32, 114, 101, 103, 105,
+111, 110, 115, 44, 32, 111, 114, 32, 70, 76, 39, 115, 32, 97, 117, 116, 111, 109, 97, 116, 105, 99, 32, 115,
+108, 105, 99, 105, 110, 103, 46, 32, 71, 114, 97, 105, 110, 115, 32, 116, 104, 101, 110, 32, 108, 105, 110, 101,
+32, 117, 112, 32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 115, 108, 105, 99, 101, 115, 32, 97, 110, 100, 32,
+116, 104, 101, 32, 84, 114, 97, 110, 115, 105, 101, 110, 116, 32, 104, 111, 108, 100, 32, 107, 110, 111, 98, 32,
+115, 101, 116, 115, 32, 104, 111, 119, 32, 108, 111, 110, 103, 32, 101, 97, 99, 104, 32, 115, 108, 105, 99, 101,
+39, 115, 32, 102, 105, 114, 115, 116, 32, 103, 114, 97, 105, 110, 32, 104, 111, 108, 100, 115, 34, 32, 61, 32,
+34, 79, 114, 105, 103, 101, 109, 32, 100, 111, 115, 32, 116, 114, 97, 110, 115, 105, 101, 110, 116, 101, 115, 58,
+32, 111, 115, 32, 109, 97, 114, 99, 97, 100, 111, 114, 101, 115, 32, 47, 32, 114, 101, 103, 105, 195, 181, 101,
+115, 32, 100, 111, 32, 115, 97, 109, 112, 108, 101, 44, 32, 111, 117, 32, 111, 32, 102, 97, 116, 105, 97, 109,
+101, 110, 116, 111, 32, 97, 117, 116, 111, 109, 195, 161, 116, 105, 99, 111, 32, 100, 111, 32, 70, 76, 46, 32,
+79, 115, 32, 103, 114, 195, 163, 111, 115, 32, 101, 110, 116, 195, 163, 111, 32, 115, 101, 32, 97, 108, 105, 110,
+104, 97, 109, 32, 195, 160, 115, 32, 102, 97, 116, 105, 97, 115, 32, 101, 32, 111, 32, 107, 110, 111, 98, 32,
+84, 114, 97, 110, 115, 105, 101, 110, 116, 32, 104, 111, 108, 100, 32, 100, 101, 102, 105, 110, 101, 32, 113, 117,
+97, 110, 116, 111, 32, 116, 101, 109, 112, 111, 32, 111, 32, 112, 114, 105, 109, 101, 105, 114, 111, 32, 103, 114,
+195, 163, 111, 32, 100, 101, 32, 99, 97, 100, 97, 32, 102, 97, 116, 105, 97, 32, 115, 101, 32, 115, 117, 115,
+116, 101, 110, 116, 97, 34, 10, 34, 77, 97, 116, 99, 104, 32, 115, 111, 110, 103, 32, 116, 101, 109, 112, 111,
+58, 32, 116, 104, 101, 32, 115, 97, 109, 112, 108, 101, 32, 112, 108, 97, 121, 115, 32, 111, 110, 99, 101, 32,
+112, 101, 114, 32, 105, 116, 115, 32, 108, 101, 110, 103, 116, 104, 32, 105, 110, 32, 98, 101, 97, 116, 115, 32,
+40, 116, 104, 101, 32, 87, 65, 86, 39, 115, 32, 65, 67, 73, 68, 32, 98, 101, 97, 116, 115, 44, 32, 101,
+108, 115, 101, 32, 66, 101, 97, 116, 115, 32, 98, 101, 108, 111, 119, 41, 46, 32, 76, 111, 111, 112, 32, 105,
+115, 32, 97, 108, 119, 97, 121, 115, 32, 111, 110, 32, 97, 110, 100, 32, 87, 97, 118, 101, 32, 115, 112, 97,
+99, 105, 110, 103, 32, 104, 97, 115, 32, 110, 111, 32, 101, 102, 102, 101, 99, 116, 32, 119, 104, 105, 108, 101,
+32, 108, 111, 99, 107, 101, 100, 34, 32, 61, 32, 34, 65, 99, 111, 109, 112, 97, 110, 104, 97, 114, 32, 111,
+32, 97, 110, 100, 97, 109, 101, 110, 116, 111, 32, 100, 97, 32, 109, 195, 186, 115, 105, 99, 97, 58, 32, 111,
+32, 115, 97, 109, 112, 108, 101, 32, 116, 111, 99, 97, 32, 117, 109, 97, 32, 118, 101, 122, 32, 112, 111, 114,
+32, 115, 117, 97, 32, 100, 117, 114, 97, 195, 167, 195, 163, 111, 32, 101, 109, 32, 116, 101, 109, 112, 111, 115,
+32, 40, 111, 115, 32, 116, 101, 109, 112, 111, 115, 32, 65, 67, 73, 68, 32, 100, 111, 32, 87, 65, 86, 44,
+32, 115, 101, 110, 195, 163, 111, 32, 84, 101, 109, 112, 111, 115, 32, 97, 98, 97, 105, 120, 111, 41, 46, 32,
+79, 32, 108, 111, 111, 112, 32, 102, 105, 99, 97, 32, 115, 101, 109, 112, 114, 101, 32, 108, 105, 103, 97, 100,
+111, 32, 101, 32, 87, 97, 118, 101, 32, 115, 112, 97, 99, 105, 110, 103, 32, 110, 195, 163, 111, 32, 116, 101,
+109, 32, 101, 102, 101, 105, 116, 111, 32, 101, 110, 113, 117, 97, 110, 116, 111, 32, 116, 114, 97, 118, 97, 100,
+111, 34, 10, 34, 66, 101, 97, 116, 115, 32, 40, 48, 32, 61, 32, 116, 104, 101, 32, 115, 97, 109, 112, 108,
+101, 39, 115, 32, 111, 119, 110, 41, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 115, 32, 40, 48, 32, 61,
+32, 111, 115, 32, 100, 111, 32, 112, 114, 195, 179, 112, 114, 105, 111, 32, 115, 97, 109, 112, 108, 101, 41, 34,
+10, 34, 84, 104, 101, 32, 115, 97, 109, 112, 108, 101, 39, 115, 32, 108, 101, 110, 103, 116, 104, 32, 105, 110,
+32, 98, 101, 97, 116, 115, 32, 102, 111, 114, 32, 84, 101, 109, 112, 111, 32, 108, 111, 99, 107, 101, 100, 32,
+97, 110, 100, 32, 116, 104, 101, 32, 83, 116, 101, 112, 32, 107, 101, 121, 115, 44, 32, 97, 115, 32, 70, 76,
+39, 115, 32, 116, 105, 109, 101, 45, 115, 116, 114, 101, 116, 99, 104, 32, 84, 73, 77, 69, 59, 32, 97, 32,
+87, 65, 86, 32, 119, 105, 116, 104, 32, 65, 67, 73, 68, 32, 98, 101, 97, 116, 115, 32, 117, 115, 101, 115,
+32, 105, 116, 115, 32, 111, 119, 110, 34, 32, 61, 32, 34, 65, 32, 100, 117, 114, 97, 195, 167, 195, 163, 111,
+32, 100, 111, 32, 115, 97, 109, 112, 108, 101, 32, 101, 109, 32, 116, 101, 109, 112, 111, 115, 32, 112, 97, 114,
+97, 32, 84, 114, 97, 118, 97, 100, 111, 32, 110, 111, 32, 97, 110, 100, 97, 109, 101, 110, 116, 111, 32, 101,
+32, 97, 115, 32, 116, 101, 99, 108, 97, 115, 32, 83, 116, 101, 112, 44, 32, 99, 111, 109, 111, 32, 111, 32,
+84, 73, 77, 69, 32, 100, 111, 32, 116, 105, 109, 101, 45, 115, 116, 114, 101, 116, 99, 104, 32, 100, 111, 32,
+70, 76, 59, 32, 117, 109, 32, 87, 65, 86, 32, 99, 111, 109, 32, 116, 101, 109, 112, 111, 115, 32, 65, 67,
+73, 68, 32, 117, 115, 97, 32, 111, 115, 32, 115, 101, 117, 115, 34, 10, 35, 32, 114, 111, 117, 110, 100, 32,
+49, 54, 53, 109, 32, 40, 98, 97, 116, 99, 104, 32, 50, 41, 10, 34, 80, 114, 101, 112, 97, 114, 101, 32,
+102, 111, 114, 32, 112, 101, 114, 102, 111, 114, 109, 97, 110, 99, 101, 32, 109, 111, 100, 101, 46, 46, 46, 34,
+32, 61, 32, 34, 80, 114, 101, 112, 97, 114, 97, 114, 32, 112, 97, 114, 97, 32, 111, 32, 109, 111, 100, 111,
+32, 112, 101, 114, 102, 111, 114, 109, 97, 110, 99, 101, 46, 46, 46, 34, 10, 34, 80, 114, 101, 112, 97, 114,
+101, 32, 102, 111, 114, 32, 112, 101, 114, 102, 111, 114, 109, 97, 110, 99, 101, 32, 109, 111, 100, 101, 34, 32,
+61, 32, 34, 80, 114, 101, 112, 97, 114, 97, 114, 32, 112, 97, 114, 97, 32, 111, 32, 109, 111, 100, 111, 32,
+112, 101, 114, 102, 111, 114, 109, 97, 110, 99, 101, 34, 10, 34, 73, 110, 115, 101, 114, 116, 115, 32, 101, 109,
+112, 116, 121, 32, 99, 111, 108, 117, 109, 110, 115, 32, 98, 101, 102, 111, 114, 101, 32, 116, 104, 101, 32, 115,
+111, 110, 103, 32, 102, 111, 114, 32, 116, 104, 101, 32, 99, 108, 105, 112, 115, 32, 116, 111, 32, 108, 97, 117,
+110, 99, 104, 44, 32, 97, 32, 109, 97, 114, 107, 101, 114, 32, 111, 110, 32, 101, 97, 99, 104, 44, 32, 97,
+110, 100, 32, 97, 32, 83, 116, 97, 114, 116, 32, 109, 97, 114, 107, 101, 114, 32, 119, 104, 101, 114, 101, 32,
+116, 104, 101, 32, 115, 111, 110, 103, 32, 98, 101, 103, 105, 110, 115, 59, 32, 80, 101, 114, 102, 111, 114, 109,
+97, 110, 99, 101, 32, 109, 111, 100, 101, 32, 105, 115, 32, 116, 117, 114, 110, 101, 100, 32, 111, 110, 46, 34,
+32, 61, 32, 34, 73, 110, 115, 101, 114, 101, 32, 99, 111, 108, 117, 110, 97, 115, 32, 118, 97, 122, 105, 97,
+115, 32, 97, 110, 116, 101, 115, 32, 100, 97, 32, 109, 195, 186, 115, 105, 99, 97, 32, 112, 97, 114, 97, 32,
+111, 115, 32, 99, 108, 105, 112, 101, 115, 32, 97, 32, 100, 105, 115, 112, 97, 114, 97, 114, 44, 32, 117, 109,
+32, 109, 97, 114, 99, 97, 100, 111, 114, 32, 101, 109, 32, 99, 97, 100, 97, 32, 117, 109, 97, 32, 101, 32,
+117, 109, 32, 109, 97, 114, 99, 97, 100, 111, 114, 32, 83, 116, 97, 114, 116, 32, 111, 110, 100, 101, 32, 97,
+32, 109, 195, 186, 115, 105, 99, 97, 32, 99, 111, 109, 101, 195, 167, 97, 59, 32, 111, 32, 109, 111, 100, 111,
+32, 112, 101, 114, 102, 111, 114, 109, 97, 110, 99, 101, 32, 195, 169, 32, 108, 105, 103, 97, 100, 111, 46, 34,
+10, 34, 77, 97, 114, 107, 101, 114, 32, 99, 111, 117, 110, 116, 34, 32, 61, 32, 34, 78, 195, 186, 109, 101,
+114, 111, 32, 100, 101, 32, 109, 97, 114, 99, 97, 100, 111, 114, 101, 115, 34, 10, 34, 50, 32, 115, 116, 101,
+112, 115, 34, 32, 61, 32, 34, 50, 32, 112, 97, 115, 115, 111, 115, 34, 10, 34, 56, 32, 98, 97, 114, 115,
+34, 32, 61, 32, 34, 56, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 84, 114, 97, 99, 107,
+58, 32, 91, 76, 77, 66, 93, 32, 115, 101, 108, 101, 99, 116, 32, 32, 91, 67, 116, 114, 108, 93, 91, 76,
+77, 66, 93, 32, 97, 100, 100, 32, 47, 32, 114, 101, 109, 111, 118, 101, 32, 32, 91, 83, 104, 105, 102, 116,
+93, 91, 76, 77, 66, 93, 32, 114, 97, 110, 103, 101, 32, 32, 91, 82, 77, 66, 93, 32, 109, 101, 110, 117,
+32, 32, 91, 50, 120, 76, 77, 66, 93, 32, 111, 112, 101, 110, 32, 116, 104, 101, 32, 99, 108, 105, 112, 32,
+115, 111, 117, 114, 99, 101, 32, 32, 91, 83, 104, 105, 102, 116, 93, 91, 87, 104, 101, 101, 108, 93, 32, 109,
+111, 118, 101, 32, 117, 112, 32, 47, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 58,
+32, 91, 76, 77, 66, 93, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 32, 32, 91, 67, 116, 114, 108, 93,
+91, 76, 77, 66, 93, 32, 105, 110, 99, 108, 117, 105, 32, 47, 32, 116, 105, 114, 97, 32, 32, 91, 83, 104,
+105, 102, 116, 93, 91, 76, 77, 66, 93, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 32, 32, 91, 82, 77,
+66, 93, 32, 109, 101, 110, 117, 32, 32, 91, 50, 120, 76, 77, 66, 93, 32, 97, 98, 114, 101, 32, 97, 32,
+102, 111, 110, 116, 101, 32, 100, 111, 32, 99, 108, 105, 112, 101, 32, 32, 91, 83, 104, 105, 102, 116, 93, 91,
+87, 104, 101, 101, 108, 93, 32, 109, 111, 118, 101, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97, 32, 47, 32,
+98, 97, 105, 120, 111, 34, 10, 10, 35, 32, 45, 45, 45, 32, 77, 105, 120, 101, 114, 58, 32, 116, 114, 97,
+99, 107, 32, 108, 97, 116, 101, 110, 99, 121, 44, 32, 114, 111, 117, 116, 105, 110, 103, 32, 115, 101, 108, 101,
+99, 116, 101, 100, 32, 226, 135, 132, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 44, 32, 115, 117, 98,
+109, 105, 120, 44, 32, 114, 101, 110, 100, 101, 114, 32, 116, 114, 97, 99, 107, 115, 32, 40, 82, 69, 65, 32,
+114, 111, 117, 110, 100, 32, 49, 54, 53, 102, 45, 109, 105, 120, 101, 114, 41, 10, 34, 84, 114, 97, 99, 107,
+32, 108, 97, 116, 101, 110, 99, 121, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110,
+99, 105, 97, 32, 100, 97, 32, 102, 97, 105, 120, 97, 58, 32, 123, 48, 125, 34, 10, 34, 84, 114, 97, 99,
+107, 115, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 115, 34, 10, 34, 82, 101, 110, 100, 101, 114, 32, 109,
+105, 120, 101, 114, 32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 97, 117, 100, 105, 111, 32, 102, 105, 108,
+101, 115, 34, 32, 61, 32, 34, 82, 101, 110, 100, 101, 114, 105, 122, 97, 114, 32, 102, 97, 105, 120, 97, 115,
+32, 100, 111, 32, 109, 105, 120, 101, 114, 32, 101, 109, 32, 97, 114, 113, 117, 105, 118, 111, 115, 32, 100, 101,
+32, 195, 161, 117, 100, 105, 111, 34, 10, 34, 76, 97, 116, 101, 110, 99, 121, 32, 40, 109, 115, 41, 34, 32,
+61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 40, 109, 115, 41, 34, 10, 34, 76, 97, 116, 101,
+110, 99, 121, 32, 40, 115, 97, 109, 112, 108, 101, 115, 41, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110,
+99, 105, 97, 32, 40, 97, 109, 111, 115, 116, 114, 97, 115, 41, 34, 10, 34, 76, 97, 116, 101, 110, 99, 121,
+32, 40, 98, 101, 97, 116, 115, 41, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 40,
+116, 101, 109, 112, 111, 115, 41, 34, 10, 34, 84, 114, 97, 99, 107, 32, 108, 97, 116, 101, 110, 99, 121, 34,
+32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 97, 32, 102, 97, 105, 120, 97, 34, 10,
+34, 80, 111, 115, 105, 116, 105, 118, 101, 58, 32, 116, 104, 101, 32, 111, 116, 104, 101, 114, 32, 116, 114, 97,
+99, 107, 115, 32, 119, 97, 105, 116, 32, 102, 111, 114, 32, 116, 104, 105, 115, 32, 111, 110, 101, 32, 40, 105,
+116, 32, 112, 108, 97, 121, 115, 32, 101, 97, 114, 108, 105, 101, 114, 41, 46, 32, 78, 101, 103, 97, 116, 105,
+118, 101, 58, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 105, 115, 32, 100, 101, 108, 97, 121, 101,
+100, 46, 34, 32, 61, 32, 34, 80, 111, 115, 105, 116, 105, 118, 111, 58, 32, 97, 115, 32, 111, 117, 116, 114,
+97, 115, 32, 102, 97, 105, 120, 97, 115, 32, 101, 115, 112, 101, 114, 97, 109, 32, 112, 111, 114, 32, 101, 115,
+116, 97, 32, 40, 101, 108, 97, 32, 116, 111, 99, 97, 32, 97, 110, 116, 101, 115, 41, 46, 32, 78, 101, 103,
+97, 116, 105, 118, 111, 58, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 195, 169, 32, 97, 116, 114,
+97, 115, 97, 100, 97, 46, 34, 10, 34, 76, 97, 116, 101, 110, 99, 121, 32, 123, 48, 125, 32, 109, 115, 32,
+40, 97, 117, 116, 111, 32, 123, 49, 125, 32, 109, 115, 44, 32, 109, 97, 110, 117, 97, 108, 32, 123, 50, 125,
+32, 109, 115, 41, 34, 32, 61, 32, 34, 76, 97, 116, 195, 170, 110, 99, 105, 97, 32, 123, 48, 125, 32, 109,
+115, 32, 40, 97, 117, 116, 111, 109, 195, 161, 116, 105, 99, 97, 32, 123, 49, 125, 32, 109, 115, 44, 32, 109,
+97, 110, 117, 97, 108, 32, 123, 50, 125, 32, 109, 115, 41, 34, 10, 34, 84, 104, 101, 32, 100, 101, 108, 97,
+121, 32, 105, 110, 116, 114, 111, 100, 117, 99, 101, 100, 32, 98, 121, 32, 116, 104, 105, 115, 32, 109, 105, 120,
+101, 114, 32, 116, 114, 97, 99, 107, 32, 105, 115, 32, 104, 105, 103, 104, 101, 114, 32, 116, 104, 97, 110, 32,
+116, 104, 101, 32, 100, 101, 108, 97, 121, 32, 105, 110, 116, 114, 111, 100, 117, 99, 101, 100, 32, 98, 121, 32,
+116, 104, 101, 32, 115, 111, 117, 114, 99, 101, 32, 109, 105, 120, 101, 114, 32, 116, 114, 97, 99, 107, 46, 32,
+83, 101, 116, 32, 97, 32, 109, 97, 107, 101, 45, 117, 112, 32, 108, 97, 116, 101, 110, 99, 121, 32, 111, 110,
+32, 116, 104, 101, 32, 115, 111, 117, 114, 99, 101, 32, 116, 114, 97, 99, 107, 32, 105, 110, 115, 116, 101, 97,
+100, 46, 34, 32, 61, 32, 34, 79, 32, 97, 116, 114, 97, 115, 111, 32, 100, 101, 115, 116, 97, 32, 102, 97,
+105, 120, 97, 32, 100, 111, 32, 109, 105, 120, 101, 114, 32, 195, 169, 32, 109, 97, 105, 111, 114, 32, 113, 117,
+101, 32, 111, 32, 100, 97, 32, 102, 97, 105, 120, 97, 32, 100, 101, 32, 111, 114, 105, 103, 101, 109, 46, 32,
+68, 101, 102, 105, 110, 97, 32, 117, 109, 97, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 101, 32,
+99, 111, 109, 112, 101, 110, 115, 97, 195, 167, 195, 163, 111, 32, 110, 97, 32, 102, 97, 105, 120, 97, 32, 100,
+101, 32, 111, 114, 105, 103, 101, 109, 46, 34, 10, 34, 83, 101, 116, 32, 102, 114, 111, 109, 34, 32, 61, 32,
+34, 68, 101, 102, 105, 110, 105, 114, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 101, 34, 10, 34, 67,
+111, 109, 112, 101, 110, 115, 97, 116, 101, 32, 102, 111, 114, 32, 109, 97, 115, 116, 101, 114, 32, 108, 97, 116,
+101, 110, 99, 121, 34, 32, 61, 32, 34, 67, 111, 109, 112, 101, 110, 115, 97, 114, 32, 97, 32, 108, 97, 116,
+195, 170, 110, 99, 105, 97, 32, 100, 111, 32, 77, 97, 115, 116, 101, 114, 34, 10, 34, 66, 121, 112, 97, 115,
+115, 32, 116, 114, 97, 99, 107, 32, 108, 97, 116, 101, 110, 99, 121, 32, 99, 111, 109, 112, 101, 110, 115, 97,
+116, 105, 111, 110, 34, 32, 61, 32, 34, 73, 103, 110, 111, 114, 97, 114, 32, 97, 32, 99, 111, 109, 112, 101,
+110, 115, 97, 195, 167, 195, 163, 111, 32, 100, 101, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 97,
+32, 102, 97, 105, 120, 97, 34, 10, 34, 65, 108, 119, 97, 121, 115, 34, 32, 61, 32, 34, 83, 101, 109, 112,
+114, 101, 34, 10, 34, 87, 104, 101, 110, 32, 114, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111, 114, 32, 110,
+111, 116, 32, 112, 108, 97, 121, 105, 110, 103, 34, 32, 61, 32, 34, 65, 111, 32, 103, 114, 97, 118, 97, 114,
+32, 111, 117, 32, 112, 97, 114, 97, 100, 111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 101, 100, 32, 116, 114,
+97, 99, 107, 115, 32, 116, 111, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 70,
+97, 105, 120, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114, 97, 32,
+101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 82, 111, 117, 116, 101, 32, 115, 101, 108, 101, 99,
+116, 101, 100, 32, 116, 111, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 82, 111,
+116, 101, 97, 114, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114,
+97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 82, 111, 117, 116, 101, 32, 115, 101, 108,
+101, 99, 116, 101, 100, 32, 116, 111, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 111, 110, 108, 121,
+34, 32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97,
+100, 97, 115, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34,
+10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 111, 32,
+116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110,
+32, 100, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 32, 112, 97, 114, 97, 32, 101,
+115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 115, 101,
+108, 101, 99, 116, 101, 100, 32, 116, 111, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 111, 110, 108,
+121, 34, 32, 61, 32, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 100, 97, 115, 32, 115, 101, 108, 101,
+99, 105, 111, 110, 97, 100, 97, 115, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 101, 115, 116, 97, 32, 102,
+97, 105, 120, 97, 34, 10, 34, 67, 114, 101, 97, 116, 101, 32, 115, 117, 98, 109, 105, 120, 46, 46, 46, 34,
+32, 61, 32, 34, 67, 114, 105, 97, 114, 32, 115, 117, 98, 109, 105, 120, 46, 46, 46, 34, 10, 34, 67, 114,
+101, 97, 116, 101, 32, 115, 117, 98, 109, 105, 120, 34, 32, 61, 32, 34, 67, 114, 105, 97, 114, 32, 115, 117,
+98, 109, 105, 120, 34, 10, 34, 84, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108,
+101, 99, 116, 101, 100, 32, 116, 114, 97, 99, 107, 115, 34, 32, 61, 32, 34, 69, 115, 116, 97, 32, 102, 97,
+105, 120, 97, 32, 112, 97, 114, 97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115,
+34, 10, 34, 82, 111, 117, 116, 101, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115,
+101, 108, 101, 99, 116, 101, 100, 34, 32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 101, 115, 116, 97, 32,
+102, 97, 105, 120, 97, 32, 112, 97, 114, 97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100,
+97, 115, 34, 10, 34, 82, 111, 117, 116, 101, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111,
+32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 82, 111, 116, 101, 97,
+114, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 97, 115,
+32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97, 105,
+110, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116, 111, 32, 115, 101, 108, 101, 99, 116, 101, 100,
+34, 32, 61, 32, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 100, 101, 115, 116, 97, 32, 102, 97, 105,
+120, 97, 32, 112, 97, 114, 97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34,
+10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 32, 116, 104, 105, 115, 32, 116, 114, 97, 99, 107, 32, 116,
+111, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34, 83, 105, 100, 101,
+99, 104, 97, 105, 110, 32, 100, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 32, 115, 195, 179, 32, 112, 97,
+114, 97, 32, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 97, 115, 34, 10, 34, 83, 101, 108,
+101, 99, 116, 101, 100, 32, 116, 114, 97, 99, 107, 115, 32, 226, 135, 132, 32, 116, 104, 105, 115, 32, 116, 114,
+97, 99, 107, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97,
+100, 97, 115, 32, 226, 135, 132, 32, 101, 115, 116, 97, 32, 102, 97, 105, 120, 97, 34, 10, 34, 82, 101, 110,
+100, 101, 114, 32, 97, 114, 109, 101, 100, 32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 119, 97, 118, 101,
+32, 102, 105, 108, 101, 40, 115, 41, 46, 46, 46, 34, 32, 61, 32, 34, 82, 101, 110, 100, 101, 114, 105, 122,
+97, 114, 32, 97, 115, 32, 102, 97, 105, 120, 97, 115, 32, 97, 114, 109, 97, 100, 97, 115, 32, 101, 109, 32,
+97, 114, 113, 117, 105, 118, 111, 40, 115, 41, 32, 87, 65, 86, 46, 46, 46, 34, 10, 34, 82, 101, 110, 100,
+101, 114, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 116, 114, 97, 99, 107, 115, 32, 116, 111, 32, 119, 97,
+118, 101, 32, 102, 105, 108, 101, 40, 115, 41, 46, 46, 46, 34, 32, 61, 32, 34, 82, 101, 110, 100, 101, 114,
+105, 122, 97, 114, 32, 97, 115, 32, 102, 97, 105, 120, 97, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97,
+100, 97, 115, 32, 101, 109, 32, 97, 114, 113, 117, 105, 118, 111, 40, 115, 41, 32, 87, 65, 86, 46, 46, 46,
+34, 10, 34, 68, 105, 115, 107, 32, 114, 101, 99, 111, 114, 100, 105, 110, 103, 34, 32, 61, 32, 34, 71, 114,
+97, 118, 97, 195, 167, 195, 163, 111, 32, 101, 109, 32, 100, 105, 115, 99, 111, 34, 10, 34, 82, 101, 115, 101,
+116, 32, 109, 97, 110, 117, 97, 108, 32, 108, 97, 116, 101, 110, 99, 121, 32, 111, 110, 32, 97, 108, 108, 32,
+116, 114, 97, 99, 107, 115, 34, 32, 61, 32, 34, 90, 101, 114, 97, 114, 32, 97, 32, 108, 97, 116, 195, 170,
+110, 99, 105, 97, 32, 109, 97, 110, 117, 97, 108, 32, 100, 101, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32,
+102, 97, 105, 120, 97, 115, 34, 10, 34, 87, 97, 114, 110, 105, 110, 103, 34, 32, 61, 32, 34, 65, 118, 105,
+115, 111, 34, 10, 34, 84, 104, 105, 115, 32, 119, 105, 108, 108, 32, 114, 101, 115, 101, 116, 32, 109, 97, 110,
+117, 97, 108, 32, 108, 97, 116, 101, 110, 99, 121, 32, 118, 97, 108, 117, 101, 115, 32, 111, 110, 32, 97, 108,
+108, 32, 109, 105, 120, 101, 114, 32, 116, 114, 97, 99, 107, 115, 46, 34, 32, 61, 32, 34, 73, 115, 116, 111,
+32, 118, 97, 105, 32, 122, 101, 114, 97, 114, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 32, 100, 101,
+32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 109, 97, 110, 117, 97, 108, 32, 100, 101, 32, 116, 111, 100,
+97, 115, 32, 97, 115, 32, 102, 97, 105, 120, 97, 115, 32, 100, 111, 32, 109, 105, 120, 101, 114, 46, 34, 10,
+34, 80, 108, 117, 103, 105, 110, 32, 100, 101, 108, 97, 121, 32, 99, 111, 109, 112, 101, 110, 115, 97, 116, 105,
+111, 110, 34, 32, 61, 32, 34, 67, 111, 109, 112, 101, 110, 115, 97, 195, 167, 195, 163, 111, 32, 100, 101, 32,
+108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 34, 10, 34, 66,
+97, 108, 97, 110, 99, 101, 32, 111, 102, 32, 116, 104, 101, 32, 105, 110, 112, 117, 116, 32, 98, 101, 102, 111,
+114, 101, 32, 116, 104, 101, 32, 100, 101, 45, 101, 115, 115, 101, 114, 32, 104, 101, 97, 114, 115, 32, 105, 116,
+34, 32, 61, 32, 34, 66, 97, 108, 97, 110, 195, 167, 111, 32, 100, 97, 32, 101, 110, 116, 114, 97, 100, 97,
+32, 97, 110, 116, 101, 115, 32, 100, 101, 32, 111, 32, 100, 101, 45, 101, 115, 115, 101, 114, 32, 111, 117, 118,
+105, 45, 108, 97, 34, 10, 34, 66, 97, 108, 97, 110, 99, 101, 32, 111, 102, 32, 116, 104, 101, 32, 111, 117,
+116, 112, 117, 116, 34, 32, 61, 32, 34, 66, 97, 108, 97, 110, 195, 167, 111, 32, 100, 97, 32, 115, 97, 195,
+173, 100, 97, 34, 10, 10, 35, 32, 45, 45, 45, 32, 114, 111, 117, 110, 100, 32, 49, 54, 53, 112, 32, 40,
+105, 115, 115, 117, 101, 32, 35, 49, 50, 41, 58, 32, 101, 100, 105, 116, 111, 114, 32, 116, 111, 111, 108, 32,
+107, 101, 121, 115, 32, 105, 110, 32, 116, 104, 101, 32, 107, 101, 121, 32, 109, 97, 112, 10, 34, 84, 111, 111,
+108, 58, 32, 80, 101, 110, 99, 105, 108, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97,
+58, 32, 76, 195, 161, 112, 105, 115, 34, 10, 34, 84, 111, 111, 108, 58, 32, 66, 114, 117, 115, 104, 34, 32,
+61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 80, 105, 110, 99, 101, 108, 34, 10, 34,
+84, 111, 111, 108, 58, 32, 68, 114, 117, 109, 32, 98, 114, 117, 115, 104, 34, 32, 61, 32, 34, 70, 101, 114,
+114, 97, 109, 101, 110, 116, 97, 58, 32, 80, 105, 110, 99, 101, 108, 32, 100, 101, 32, 98, 97, 116, 101, 114,
+105, 97, 34, 10, 34, 84, 111, 111, 108, 58, 32, 69, 114, 97, 115, 101, 114, 34, 32, 61, 32, 34, 70, 101,
+114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 66, 111, 114, 114, 97, 99, 104, 97, 34, 10, 34, 84, 111, 111,
+108, 58, 32, 77, 117, 116, 101, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32,
+83, 105, 108, 101, 110, 99, 105, 97, 114, 34, 10, 34, 84, 111, 111, 108, 58, 32, 75, 110, 105, 102, 101, 34,
+32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 70, 97, 99, 97, 34, 10, 34, 84,
+111, 111, 108, 58, 32, 76, 97, 115, 115, 111, 32, 40, 115, 101, 108, 101, 99, 116, 41, 34, 32, 61, 32, 34,
+70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 76, 97, 195, 167, 111, 32, 40, 115, 101, 108, 101, 99,
+105, 111, 110, 97, 114, 41, 34, 10, 34, 84, 111, 111, 108, 58, 32, 90, 111, 111, 109, 34, 32, 61, 32, 34,
+70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 90, 111, 111, 109, 34, 10, 34, 84, 111, 111, 108, 58,
+32, 76, 105, 115, 116, 101, 110, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32,
+79, 117, 118, 105, 114, 34, 10, 34, 84, 111, 111, 108, 58, 32, 83, 108, 105, 112, 34, 32, 61, 32, 34, 70,
+101, 114, 114, 97, 109, 101, 110, 116, 97, 58, 32, 68, 101, 115, 108, 105, 122, 97, 114, 32, 99, 111, 110, 116,
+101, 195, 186, 100, 111, 34, 10, 34, 83, 108, 105, 100, 101, 32, 110, 111, 116, 101, 115, 32, 111, 110, 47, 111,
+102, 102, 32, 40, 110, 101, 119, 32, 110, 111, 116, 101, 115, 41, 34, 32, 61, 32, 34, 78, 111, 116, 97, 115,
+32, 115, 108, 105, 100, 101, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 32, 40, 110, 111, 116,
+97, 115, 32, 110, 111, 118, 97, 115, 41, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 99, 104, 97,
+110, 110, 101, 108, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 32, 97, 110, 116, 101, 114, 105, 111, 114, 34,
+10, 34, 78, 101, 120, 116, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120,
+105, 109, 111, 32, 99, 97, 110, 97, 108, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 99, 104, 97,
+110, 110, 101, 108, 32, 119, 105, 116, 104, 32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 67, 97, 110, 97,
+108, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 99, 111, 109, 32, 110, 111, 116, 97, 115, 34, 10, 34, 78,
+101, 120, 116, 32, 99, 104, 97, 110, 110, 101, 108, 32, 119, 105, 116, 104, 32, 110, 111, 116, 101, 115, 34, 32,
+61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 99, 97, 110, 97, 108, 32, 99, 111, 109, 32, 110, 111,
+116, 97, 115, 34, 10, 34, 123, 48, 125, 32, 119, 97, 115, 32, 97, 108, 115, 111, 32, 123, 49, 125, 58, 32,
+121, 111, 117, 114, 32, 107, 101, 121, 32, 119, 105, 110, 115, 32, 116, 104, 101, 114, 101, 32, 110, 111, 119, 46,
+34, 32, 61, 32, 34, 123, 48, 125, 32, 116, 97, 109, 98, 195, 169, 109, 32, 101, 114, 97, 32, 123, 49, 125,
+58, 32, 97, 103, 111, 114, 97, 32, 97, 32, 115, 117, 97, 32, 116, 101, 99, 108, 97, 32, 118, 97, 108, 101,
+32, 108, 195, 161, 46, 34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 32, 105,
+110, 32, 98, 97, 114, 115, 58, 32, 91, 76, 77, 66, 93, 32, 100, 114, 97, 103, 32, 111, 114, 32, 91, 87,
+104, 101, 101, 108, 93, 32, 99, 104, 97, 110, 103, 101, 32, 105, 116, 32, 32, 91, 50, 120, 76, 77, 66, 93,
+32, 97, 117, 116, 111, 109, 97, 116, 105, 99, 32, 40, 102, 114, 111, 109, 32, 116, 104, 101, 32, 110, 111, 116,
+101, 115, 41, 32, 32, 91, 82, 77, 66, 93, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 84, 97, 109, 97,
+110, 104, 111, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 101, 109, 32, 99, 111, 109, 112, 97, 115,
+115, 111, 115, 58, 32, 91, 76, 77, 66, 93, 32, 97, 114, 114, 97, 115, 116, 101, 32, 111, 117, 32, 91, 87,
+104, 101, 101, 108, 93, 32, 112, 97, 114, 97, 32, 109, 117, 100, 97, 114, 32, 32, 91, 50, 120, 76, 77, 66,
+93, 32, 97, 117, 116, 111, 109, 195, 161, 116, 105, 99, 111, 32, 40, 112, 101, 108, 97, 115, 32, 110, 111, 116,
+97, 115, 41, 32, 32, 91, 82, 77, 66, 93, 32, 109, 101, 110, 117, 34, 10, 34, 80, 97, 116, 116, 101, 114,
+110, 32, 108, 101, 110, 103, 116, 104, 58, 32, 123, 48, 125, 32, 40, 97, 117, 116, 111, 109, 97, 116, 105, 99,
+44, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 41, 34, 32, 61, 32, 34, 84, 97,
+109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 58, 32, 123, 48, 125, 32, 40, 97,
+117, 116, 111, 109, 195, 161, 116, 105, 99, 111, 44, 32, 112, 101, 108, 97, 115, 32, 110, 111, 116, 97, 115, 41,
+34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 32, 40, 98, 97, 114, 115, 44,
+32, 48, 32, 61, 32, 97, 117, 116, 111, 109, 97, 116, 105, 99, 41, 34, 32, 61, 32, 34, 84, 97, 109, 97,
+110, 104, 111, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 40, 99, 111, 109, 112, 97, 115, 115, 111,
+115, 44, 32, 48, 32, 61, 32, 97, 117, 116, 111, 109, 195, 161, 116, 105, 99, 111, 41, 34, 10, 34, 80, 97,
+116, 116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111,
+32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 70, 111, 108, 108, 111, 119, 58, 32, 97, 32,
+112, 97, 116, 116, 101, 114, 110, 32, 108, 111, 110, 103, 101, 114, 32, 116, 104, 97, 110, 32, 116, 104, 101, 32,
+67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 112, 97, 103, 101, 115, 32, 97, 108, 111, 110, 103,
+32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 112, 108, 97, 121, 105, 110, 103, 32, 115, 116, 101, 112, 59, 32,
+111, 102, 102, 44, 32, 105, 116, 32, 115, 116, 97, 121, 115, 32, 119, 104, 101, 114, 101, 32, 121, 111, 117, 32,
+115, 99, 114, 111, 108, 108, 101, 100, 34, 32, 61, 32, 34, 83, 101, 103, 117, 105, 114, 58, 32, 117, 109, 32,
+112, 97, 116, 116, 101, 114, 110, 32, 109, 97, 105, 111, 114, 32, 113, 117, 101, 32, 111, 32, 67, 104, 97, 110,
+110, 101, 108, 32, 82, 97, 99, 107, 32, 112, 97, 115, 115, 97, 32, 100, 101, 32, 112, 195, 161, 103, 105, 110,
+97, 32, 106, 117, 110, 116, 111, 32, 99, 111, 109, 32, 111, 32, 115, 116, 101, 112, 32, 116, 111, 99, 97, 110,
+100, 111, 59, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 44, 32, 102, 105, 99, 97, 32, 111, 110, 100, 101,
+32, 118, 111, 99, 195, 170, 32, 114, 111, 108, 111, 117, 34, 10, 34, 70, 111, 108, 108, 111, 119, 32, 116, 104,
+101, 32, 112, 108, 97, 121, 104, 101, 97, 100, 32, 40, 112, 97, 103, 101, 32, 97, 108, 111, 110, 103, 32, 119,
+105, 116, 104, 32, 116, 104, 101, 32, 112, 108, 97, 121, 105, 110, 103, 32, 115, 116, 101, 112, 41, 32, 111, 110,
+47, 111, 102, 102, 34, 32, 61, 32, 34, 83, 101, 103, 117, 105, 114, 32, 111, 32, 99, 117, 114, 115, 111, 114,
+32, 100, 101, 32, 114, 101, 112, 114, 111, 100, 117, 195, 167, 195, 163, 111, 32, 40, 112, 97, 115, 115, 97, 114,
+32, 100, 101, 32, 112, 195, 161, 103, 105, 110, 97, 32, 99, 111, 109, 32, 111, 32, 115, 116, 101, 112, 32, 116,
+111, 99, 97, 110, 100, 111, 41, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 34, 10, 34, 70,
+111, 108, 108, 111, 119, 58, 32, 116, 104, 101, 32, 118, 105, 101, 119, 32, 112, 97, 103, 101, 115, 32, 97, 108,
+111, 110, 103, 32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 112, 108, 97, 121, 98, 97, 99, 107, 32, 112, 111,
+115, 105, 116, 105, 111, 110, 59, 32, 111, 102, 102, 44, 32, 105, 116, 32, 115, 116, 97, 121, 115, 32, 119, 104,
+101, 114, 101, 32, 121, 111, 117, 32, 115, 99, 114, 111, 108, 108, 101, 100, 34, 32, 61, 32, 34, 83, 101, 103,
+117, 105, 114, 58, 32, 97, 32, 118, 105, 115, 195, 163, 111, 32, 112, 97, 115, 115, 97, 32, 100, 101, 32, 112,
+195, 161, 103, 105, 110, 97, 32, 106, 117, 110, 116, 111, 32, 99, 111, 109, 32, 97, 32, 112, 111, 115, 105, 195,
+167, 195, 163, 111, 32, 100, 101, 32, 114, 101, 112, 114, 111, 100, 117, 195, 167, 195, 163, 111, 59, 32, 100, 101,
+115, 108, 105, 103, 97, 100, 111, 44, 32, 102, 105, 99, 97, 32, 111, 110, 100, 101, 32, 118, 111, 99, 195, 170,
+32, 114, 111, 108, 111, 117, 34, 10, 34, 83, 101, 110, 100, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116,
+105, 111, 110, 32, 116, 111, 32, 97, 32, 110, 101, 119, 32, 83, 97, 109, 112, 108, 101, 114, 32, 99, 104, 97,
+110, 110, 101, 108, 34, 32, 61, 32, 34, 69, 110, 118, 105, 97, 114, 32, 97, 32, 115, 101, 108, 101, 195, 167,
+195, 163, 111, 32, 112, 97, 114, 97, 32, 117, 109, 32, 110, 111, 118, 111, 32, 99, 97, 110, 97, 108, 32, 83,
+97, 109, 112, 108, 101, 114, 34, 10, 34, 84, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 119,
+101, 110, 116, 32, 116, 111, 32, 97, 32, 110, 101, 119, 32, 83, 97, 109, 112, 108, 101, 114, 32, 99, 104, 97,
+110, 110, 101, 108, 32, 40, 123, 48, 125, 41, 34, 32, 61, 32, 34, 65, 32, 115, 101, 108, 101, 195, 167, 195,
+163, 111, 32, 102, 111, 105, 32, 112, 97, 114, 97, 32, 117, 109, 32, 110, 111, 118, 111, 32, 99, 97, 110, 97,
+108, 32, 83, 97, 109, 112, 108, 101, 114, 32, 40, 123, 48, 125, 41, 34, 10,
 };
 } // namespace lynx::i18n::data

+ 36 - 0
src/ui/MainComponent.cpp

@@ -4,6 +4,7 @@
 #include "ui/UiTrace.h"
 #include "core/LoadTrace.h"
 #include "ui/MainComponent.h"
+#include "core/Performance.h"
 
 #include "core/TransportEdit.h"
 #include "ui/CrashReporter.h"
@@ -518,6 +519,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     fittedChannelCount = (int) engine.getSong().channels.size();
     hintBar.setHint ({ idleHint(), {}, false, false });
     setWantsKeyboardFocus (true);
+    installDialogTextFocus(); // dialogs open with their text field focused (round 165q)
     setSize (1180, 642);
     startTimerHz (30);
     uiTraceMonitor.start ([this, last = std::make_shared<RtStats::Snapshot>()] {
@@ -564,6 +566,7 @@ MainComponent::~MainComponent()
     ui::onTweak = nullptr;
     onEditEventsInPianoRoll = nullptr;
     PluginWindows::onGesture = nullptr;
+    removeDialogTextFocus();
     engine.nameAutomation = nullptr;
     PluginWindows::closeAll(); // plugin UIs before the engine
     ParametricEqWindows::closeAll();
@@ -4469,6 +4472,7 @@ juce::PopupMenu MainComponent::getMenuForIndex (int barIndex, const juce::String
             rack.selectUnused();
         });
         menu.addItem (tr ("Switch smart disable for all plugins"), [this] { switchSmartDisableForAll(); });
+        menu.addItem (tr ("Prepare for performance mode..."), [this] { prepareForPerformance(); });
         menu.addItem (tr ("Delete unused recordings and save project..."), [this] { deleteUnusedRecordingsAndSave(); });
         menu.addItem (tr ("Collect project samples into a folder..."), [this] { collectSamples(); });
         return menu;
@@ -5015,4 +5019,36 @@ void MainComponent::FilterBox::paint (juce::Graphics& g)
     g.drawText (text, getLocalBounds().withTrimmedLeft (7).withTrimmedRight (16), juce::Justification::centredLeft, true);
     icons::draw (g, Icon::chevronDown, area.removeFromRight (16.0f).reduced (3.0f).translated (-2.0f, 0.0f), colour::textSecondary);
 }
+// FL's Tools › Macros › Prepare for performance mode ([DECOMP] FUN_0122d010, its "Marker settings" dialog: marker count
+// 4 / 8 / 16 / 32 / 64, default 16; spacing 1…128 steps, default 16 = a bar): room for a launch grid before the song,
+// a marker per column, a Start marker, Performance mode on, the zone in view. FL warns it can't be undone; in LYNX it
+// is one undo step.
+void MainComponent::prepareForPerformance()
+{
+    auto* window = new juce::AlertWindow (tr ("Prepare for performance mode"),
+                                          tr ("Inserts empty columns before the song for the clips to launch, a marker on each, and a Start "
+                                              "marker where the song begins; Performance mode is turned on."),
+                                          juce::MessageBoxIconType::NoIcon);
+    window->addComboBox ("count", { "4", "8", "16", "32", "64" }, tr ("Marker count"));
+    window->addComboBox ("spacing", { tr ("1 step"), tr ("2 steps"), tr ("1 beat"), tr ("2 beats"), tr ("1 bar"), tr ("2 bars"), tr ("4 bars"), tr ("8 bars") },
+                         tr ("Spacing"));
+    if (auto* c = window->getComboBoxComponent ("count"))
+        c->setSelectedItemIndex (2, juce::dontSendNotification);
+    if (auto* c = window->getComboBoxComponent ("spacing"))
+        c->setSelectedItemIndex (4, juce::dontSendNotification);
+    window->addButton (tr ("Accept"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+    window->addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
+    window->enterModalState (true, juce::ModalCallbackFunction::create ([this, window] (int result) {
+                                 if (result != 1)
+                                     return;
+                                 const auto count = 4 << juce::jlimit (0, 4, window->getComboBoxComponent ("count")->getSelectedItemIndex());
+                                 const auto steps = 1 << juce::jlimit (0, 7, window->getComboBoxComponent ("spacing")->getSelectedItemIndex());
+                                 engine.editSong ([count, steps] (Song& s) { perf::prepareForPerformance (s, count, (std::int64_t) steps * (ppq / 4)); });
+                                 showPanel (Panel::playlist);
+                                 playlist.runAction ("playlist.zoomPerformance");
+                             }),
+                             true);
+    keepAboveMainWindow (*window);
+}
+
 } // namespace lynx

+ 1 - 0
src/ui/MainComponent.h

@@ -225,6 +225,7 @@ private:
     void exportAudio (int format = -1); // −1: the last export's format(s); 0 WAV, 1 MP3, 2 OGG, 3 FLAC alone
     void exportMidiFile();
     void switchSmartDisableForAll();
+    void prepareForPerformance(); // Tools › Macros (round 165m)
     void refreshToolbar();
     void updateTitle();
     bool shouldReclaimKeyboardFocus(); // the main window is active but nothing in it has the keyboard focus

+ 1 - 1
src/ui/NewtoneEditor.cpp

@@ -293,7 +293,7 @@ public:
 
     bool isInterestedInFileDrag (const juce::StringArray& files) override
     {
-        return validSlot() && files.size() == 1 && juce::File (files[0]).hasFileExtension ("wav;aif;aiff;flac;ogg;mp3");
+        return validSlot() && files.size() == 1 && SampleLibrary::isSampleFile (juce::File (files[0]));
     }
 
     void filesDropped (const juce::StringArray& files, int, int) override

+ 56 - 13
src/ui/PlaylistComponent.cpp

@@ -1050,7 +1050,7 @@ void PlaylistComponent::paint (juce::Graphics& g)
             g.setColour (plate);
             g.fillRoundedRectangle (plateArea, radius::sm);
 
-            if (t == currentTrack) // the selected track (FL marks it next to the LED)
+            if (isTrackSelected (t)) // the selected tracks (FL marks them next to the LED)
             {
                 g.setColour (colour::accent);
                 g.fillRoundedRectangle (plateArea.withWidth (3.0f).reduced (0.0f, 3.0f), 1.5f);
@@ -1807,6 +1807,25 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
             });
         else if (! noteedit::isFoldedAway (engine.getSong(), track))
         {
+            // Ctrl+click adds / removes a track, Shift+click selects the tracks from the last clicked one (round 165m:
+            // FL's track menu settings, e.g. Performance settings, apply to every selected track)
+            if (e.mods.isCtrlDown())
+            {
+                if (selectedTracks.empty() && currentTrack >= 0)
+                    selectedTracks.push_back (currentTrack);
+                if (const auto it = std::find (selectedTracks.begin(), selectedTracks.end(), track); it != selectedTracks.end())
+                    selectedTracks.erase (it);
+                else
+                    selectedTracks.push_back (track);
+            }
+            else if (e.mods.isShiftDown() && currentTrack >= 0)
+            {
+                selectedTracks.clear();
+                for (int t = juce::jmin (currentTrack, track); t <= juce::jmax (currentTrack, track); ++t)
+                    selectedTracks.push_back (t);
+            }
+            else
+                selectedTracks = { track };
             currentTrack = track;
             repaint (0, headerHeight, headerWidth, getHeight() - headerHeight);
         }
@@ -2872,6 +2891,23 @@ juce::Rectangle<int> PlaylistComponent::trackArrow (int track) const
     return { led.getX() - 15, led.getY() - 1, 13, led.getHeight() + 2 };
 }
 
+bool PlaylistComponent::isTrackSelected (int track) const
+{
+    return track == currentTrack || std::find (selectedTracks.begin(), selectedTracks.end(), track) != selectedTracks.end();
+}
+
+std::vector<int> PlaylistComponent::tracksForMenu (int track) const
+{
+    // the menu's track and, when it is one of them, the other selected tracks
+    if (! isTrackSelected (track) || selectedTracks.size() < 2)
+        return { track };
+    auto out = selectedTracks;
+    if (std::find (out.begin(), out.end(), track) == out.end())
+        out.push_back (track);
+    std::sort (out.begin(), out.end());
+    return out;
+}
+
 void PlaylistComponent::editTrack (int track, std::function<void (PlaylistTrack&)> change)
 {
     if (track < 0)
@@ -2972,8 +3008,16 @@ juce::PopupMenu PlaylistComponent::buildTrackMenu (int track)
         using P = TrackPerformance;
         const auto p = info.performance;
         juce::PopupMenu perfMenu;
-        auto set = [this, track] (std::function<void (TrackPerformance&)> change) {
-            editTrack (track, [change] (PlaylistTrack& t) { change (t.performance); });
+        // FL's handler (0x1212fe0 → FUN_012ead80) sets the item on every selected track, in one undo step
+        auto set = [this, tracks = tracksForMenu (track)] (std::function<void (TrackPerformance&)> change) {
+            engine.editSong ([tracks, change] (Song& s) {
+                for (const auto t : tracks)
+                {
+                    if ((int) s.playlistTracks.size() <= t)
+                        s.playlistTracks.resize ((std::size_t) t + 1);
+                    change (s.playlistTracks[(std::size_t) t].performance);
+                }
+            });
         };
         perfMenu.addSectionHeader (tr ("Press"));
         for (auto [value, text] : { std::pair { P::Press::retrigger, TR_NOOP ("Retrigger") }, { P::Press::holdStop, TR_NOOP ("Hold & stop") },
@@ -4279,7 +4323,7 @@ ui::Hint PlaylistComponent::hintAt (juce::Point<int> p)
     {
         hint.text = h.led     ? tr ("Track: [LMB] mute / unmute  [Ctrl][LMB] or [RMB] solo")
                     : h.arrow ? tr ("Track group: [LMB] collapse / expand the grouped tracks")
-                              : tr ("Track: [LMB] select  [RMB] menu  [2xLMB] open the clip source  [Shift][Wheel] move up / down");
+                              : tr ("Track: [LMB] select  [Ctrl][LMB] add / remove  [Shift][LMB] range  [RMB] menu  [2xLMB] open the clip source  [Shift][Wheel] move up / down");
         hint.value = trackName (h.track);
         if (const auto mode = trackmodes::describe (song, h.track); ! mode.empty()) // FL's "(Instrument track)" / "(Audio track, ...)"
             hint.value += " " + (mode.rfind ("(Audio", 0) == 0 ? tr ("(Audio track, linked to mixer track {0})", { juce::String (song.playlistTracks[(std::size_t) h.track].mixerTrack) })
@@ -4406,7 +4450,7 @@ void PlaylistComponent::openClipSource (int hit, bool other)
 bool PlaylistComponent::isInterestedInFileDrag (const juce::StringArray& files)
 {
     for (const auto& f : files)
-        if (juce::File (f).hasFileExtension ("wav;aif;aiff;flac;ogg;mp3"))
+        if (SampleLibrary::isSampleFile (juce::File (f)))
             return true;
 
     return false;
@@ -4418,7 +4462,7 @@ namespace
 // file plays it instead of a new one. False when the file can't be read.
 bool addAudioClip (AudioEngine& engine, const juce::File& file, std::int64_t start, int track, bool reuse)
 {
-    if (! file.hasFileExtension ("wav;aif;aiff;flac;ogg;mp3;wv"))
+    if (! SampleLibrary::isSampleFile (file))
         return false;
 
     const auto data = engine.getSampleLibrary().load (file.getFullPathName());
@@ -4737,18 +4781,17 @@ void PlaylistComponent::paintPerformance (juce::Graphics& g, juce::Rectangle<int
             mark.addTriangle (mx, my - 4.0f, mx, my + 4.0f, mx + 6.0f, my);
             g.setColour (colour::ledOn);
             g.fillPath (mark);
-            g.setColour (colour::textPrimary.withAlpha (0.10f));
-            g.fillRoundedRectangle (r, radius::sm);
             g.setColour (colour::ledOn);
             g.drawRoundedRectangle (r.reduced (1.0f), radius::sm, 2.0f);
             if (showClipProgress)
             {
+                // as in FL, the part already played is lighter, up to a thin playhead line
                 const auto p = juce::jlimit (0.0f, 1.0f, view.progress.load (std::memory_order_relaxed));
-                const auto bar = r.reduced (3.0f, 0.0f).removeFromBottom (4.0f).translated (0.0f, -3.0f);
-                g.setColour (colour::bg0.withAlpha (0.6f));
-                g.fillRoundedRectangle (bar, 1.5f);
-                g.setColour (colour::ledOn);
-                g.fillRoundedRectangle (bar.withWidth (juce::jmax (2.0f, bar.getWidth() * p)), 1.5f);
+                const auto played = r.reduced (1.0f).withWidth (juce::jmax (0.0f, (r.getWidth() - 2.0f) * p));
+                g.setColour (colour::textPrimary.withAlpha (0.16f));
+                g.fillRect (played);
+                g.setColour (colour::ledOn.withAlpha (0.85f));
+                g.fillRect (played.withX (played.getRight() - 1.0f).withWidth (1.5f));
             }
         }
         if (pending)

+ 3 - 0
src/ui/PlaylistComponent.h

@@ -231,6 +231,9 @@ private:
     juce::Rectangle<int> trackArrow (int track) const; // a group header's fold arrow (empty for other tracks)
     void editTrack (int track, std::function<void (PlaylistTrack&)> change);
     int currentTrack = -1; // the track selected by a click on its header (FL marks it next to the LED)
+    std::vector<int> selectedTracks; // Ctrl / Shift+click on headers: more selected tracks (round 165m)
+    bool isTrackSelected (int track) const;
+    std::vector<int> tracksForMenu (int track) const;
 
     AudioEngine& engine;
     juce::ScrollBar hBar { false }, vBar { true }; // hBar is hidden: the overview strip scrolls sideways

+ 5 - 0
src/ui/PluginWindow.cpp

@@ -487,6 +487,11 @@ public:
     ~PluginWindow() override
     {
         crashguard::note (("closing the editor of " + plugin.getName()).toStdString());
+        // round 165q: closing the active plugin window (its X, F12, Alt+F12, removing the plugin) let Windows hand the
+        // activation to another program (seen: a terminal on the second screen) instead of LYNX, so Space and the
+        // shortcuts went there. The main window takes it first, while LYNX is still the foreground program.
+        if (isActiveWindow())
+            activateMainWindow();
         stopTimer();
         plugin.removeListener (this);
         // the UI must be destroyed before the plugin (which may die together with `owner`)

+ 14 - 5
src/ui/QuickAddPalette.cpp

@@ -74,16 +74,23 @@ private:
         }
 
         const auto& e = shown[(std::size_t) row];
-        g.setFont (theme::font (theme::type::body));
-        g.setColour (theme::colour::textPrimary);
-        g.drawText (e.name, 8, 0, width - 16, height, juce::Justification::centredLeft, true);
+        auto area = juce::Rectangle<int> (8, 0, width - 16, height);
 
+        // the source on the right first, then the name in what is left (cut with "..."): a long name no longer runs
+        // under the source (round 165q)
         if (e.detail.isNotEmpty())
         {
-            g.setFont (theme::font (theme::type::caption));
+            const auto caption = theme::font (theme::type::caption);
+            const auto detailWidth = juce::jmin (juce::GlyphArrangement::getStringWidthInt (juce::Font (caption), e.detail) + 2, area.getWidth() * 2 / 5);
+            g.setFont (caption);
             g.setColour (theme::colour::textSecondary);
-            g.drawText (e.detail, 8, 0, width - 16, height, juce::Justification::centredRight, true);
+            g.drawText (e.detail, area.removeFromRight (detailWidth), juce::Justification::centredRight, true);
+            area.removeFromRight (10);
         }
+
+        g.setFont (theme::font (theme::type::body));
+        g.setColour (theme::colour::textPrimary);
+        g.drawText (e.name, area, juce::Justification::centredLeft, true);
     }
 
     void listBoxItemDoubleClicked (int row, const juce::MouseEvent&) override
@@ -104,6 +111,8 @@ public:
         search.addListener (this);
         search.addKeyListener (this);
         search.setWantsKeyboardFocus (true);
+        // "Esc closes" (the hint below): the search box used to swallow Esc, so the window stayed open (round 165q)
+        search.onEscapeKey = [this] { closeToolWindowOf (*this); };
         addAndMakeVisible (search);
 
         for (auto* l : { &instrumentsTitle, &effectsTitle })

+ 83 - 0
src/ui/WindowOwner.cpp

@@ -9,6 +9,7 @@
 #include <cstdint>
 
 #include <juce_audio_processors/juce_audio_processors.h>
+#include <functional>
 #include <map>
 #include <memory>
 #include <optional>
@@ -40,6 +41,16 @@ void setMainWindowForOwnership (juce::Component* window)
     mainWindow() = window;
 }
 
+void activateMainWindow()
+{
+    auto* main = mainWindow().getComponent();
+    if (main == nullptr || ! main->isShowing())
+        return;
+    auto* top = main->getTopLevelComponent();
+    if (auto* peer = top->getPeer(); peer != nullptr && ! peer->isMinimised())
+        top->toFront (true);
+}
+
 double processCpuSeconds()
 {
    #if JUCE_WINDOWS
@@ -52,6 +63,78 @@ double processCpuSeconds()
    #endif
 }
 
+juce::TextEditor* firstTextField (juce::Component& dialog)
+{
+    juce::TextEditor* best = nullptr;
+    juce::Point<int> bestAt;
+    std::function<void (juce::Component&)> walk = [&] (juce::Component& c) {
+        for (auto* child : c.getChildren())
+        {
+            if (! child->isVisible() || ! child->isEnabled())
+                continue;
+            if (auto* editor = dynamic_cast<juce::TextEditor*> (child); editor != nullptr && ! editor->isReadOnly() && editor->getWantsKeyboardFocus())
+            {
+                const auto at = dialog.getLocalPoint (editor, juce::Point<int>());
+                if (best == nullptr || at.y < bestAt.y || (at.y == bestAt.y && at.x < bestAt.x))
+                {
+                    best = editor;
+                    bestAt = at;
+                }
+                continue;
+            }
+            walk (*child);
+        }
+    };
+    walk (dialog);
+    return best;
+}
+
+namespace
+{
+struct DialogTextFocus final : juce::FocusChangeListener
+{
+    void globalFocusChanged (juce::Component* focused) override
+    {
+        if (focused == nullptr)
+            return;
+        auto* dialog = dynamic_cast<juce::AlertWindow*> (focused->getTopLevelComponent());
+        if (dialog == nullptr || ! dialog->isShowing())
+            return;
+        auto& props = dialog->getProperties();
+        static const juce::Identifier done ("lynxTextFocused");
+        if (props.contains (done)) // only the dialog's first focus: Tab and clicks move it freely afterwards
+            return;
+        props.set (done, true);
+        if (dynamic_cast<juce::TextEditor*> (focused) != nullptr)
+            return;
+        if (auto* field = firstTextField (*dialog))
+            field->grabKeyboardFocus(); // (AlertWindow's fields select all their text when focused)
+    }
+};
+
+std::unique_ptr<DialogTextFocus>& dialogTextFocus()
+{
+    static std::unique_ptr<DialogTextFocus> listener;
+    return listener;
+}
+} // namespace
+
+void installDialogTextFocus()
+{
+    if (dialogTextFocus() != nullptr)
+        return;
+    dialogTextFocus() = std::make_unique<DialogTextFocus>();
+    juce::Desktop::getInstance().addFocusChangeListener (dialogTextFocus().get());
+}
+
+void removeDialogTextFocus()
+{
+    if (dialogTextFocus() == nullptr)
+        return;
+    juce::Desktop::getInstance().removeFocusChangeListener (dialogTextFocus().get());
+    dialogTextFocus() = nullptr;
+}
+
 juce::Image logoImage()
 {
     return juce::ImageCache::getFromMemory (logo::png256, (int) sizeof (logo::png256));

+ 14 - 0
src/ui/WindowOwner.h

@@ -21,6 +21,10 @@ void* mainWindowHandle();
 // that handles every key itself (a detached panel) sets the property "lynxOwnKeys".
 void setSecondaryWindowKeyHandler (std::function<bool (const juce::KeyPress&)> handler);
 
+// Makes the main window the active one (round 165q): a closing secondary window that is active calls it first, so
+// the activation does not go to another program.
+void activateMainWindow();
+
 // True when `window` is currently owned by the main window (Windows; elsewhere: keepAboveMainWindow was called).
 bool isOwnedByMainWindow (juce::Component& window);
 // True when `window` is above the main window in the z-order (Windows; elsewhere: isOwnedByMainWindow).
@@ -54,6 +58,16 @@ void startRenderingWatch();
 // the window's native peer uses the chosen renderer now (keepAboveMainWindow calls it)
 void applyRenderingChoice (juce::Component& window);
 
+// Dialogs with a text field (rename and color, the next empty pattern's name, preset and insert names...) open with
+// the field focused and its text selected, so typing replaces the name at once, as in FL (round 165q). JUCE's
+// AlertWindow gives its buttons an explicit focus order, so the dialog's focus went to its first button: the letters
+// typed did nothing and Enter pressed OK. Installed once for the whole app (a Desktop focus listener): the first time
+// the focus enters a dialog, it moves to the dialog's first editable text field when it landed anywhere else.
+void installDialogTextFocus();
+void removeDialogTextFocus();
+// The dialog's first editable, visible text field (top to bottom, then left to right), or nullptr.
+juce::TextEditor* firstTextField (juce::Component& dialog);
+
 // The LYNX logo (256 px, with transparency).
 juce::Image logoImage();
 

+ 13 - 0
tests/Audit165Tests.inc

@@ -0,0 +1,13 @@
+// Round 165q (audit165): independent check of the #4 / #9 / #11 / #8 fixes (docs/analise/REA_rodada165q.md)
+
+TEST (audit165_drop_targets_take_every_sample_the_browser_lists)
+{
+    // FL's own pack samples are WavPack (.wv): the Browser listed and previewed them, but the Channel Rack ignored
+    // them when dropped (it only knew wav/aif/flac/ogg/mp3). Every drop target now asks one list (core/SampleFiles.h).
+    using lynx::isSampleExtension;
+    for (const auto* ext : { "wv", ".wv", "WV", "wav", ".WAV", "aif", "aiff", "flac", "ogg", "mp3" })
+        CHECK (isSampleExtension (ext));
+    for (const auto* ext : { "", ".", "mid", ".sf2", "flp", "wave", "w", "txt", "mp" })
+        CHECK (! isSampleExtension (ext));
+    CHECK (lynx::sampleFileExtensions.size() == 7);
+}

+ 189 - 0
tests/FlGran165Tests.inc

@@ -0,0 +1,189 @@
+// Round 165g flgran165: Fruity Granulizer's slices + transient hold, tempo sync, key modes 2/3 and FL's render quality
+// (core/Granulizer, REA_rodada165g-flgran165)
+
+#include <numeric>
+
+#include "core/FlAutoSlicer.h"
+
+namespace flgran165
+{
+// our own deterministic drum-like signal (tmp/flgran165/py/goldsig.py builds the same int16 data for the DLL):
+// six square-wave hits halving every 1200 frames; right = left·3 >> 2
+lynx::SampleData drums (int ch, double rate)
+{
+    constexpr int n = 48000;
+    const int hits[] = { 0, 7000, 15500, 26000, 33000, 41000 };
+    std::vector<std::int32_t> x ((std::size_t) n, 0);
+    for (int j = 0; j < 6; ++j)
+    {
+        const int per = 14 + 6 * (j % 4), amp = 20000 - 3000 * (j % 3);
+        for (int i = hits[j]; i < n; ++i)
+        {
+            const int k = i - hits[j];
+            const int a = amp >> (k / 1200);
+            if (a == 0)
+                break;
+            const int v = (k / per) % 2 == 0 ? a : -a;
+            x[(std::size_t) i] = std::clamp (x[(std::size_t) i] + v, -32768, 32767);
+        }
+    }
+    lynx::SampleData d;
+    d.sampleRate = rate;
+    for (int i = 0; i < n; ++i)
+    {
+        d.left.push_back ((float) (std::int16_t) x[(std::size_t) i] / 32768.0f);
+        if (ch > 1)
+            d.right.push_back ((float) (std::int16_t) ((x[(std::size_t) i] * 3) >> 2) / 32768.0f);
+    }
+    return d;
+}
+
+// a version-7 state without the channel snapshot (as tmp/r165g/py/mkgr.py writes them for FL)
+std::vector<std::uint8_t> state (const std::array<int, 12>& P, int sliceMode, int keyMode, int sync)
+{
+    std::vector<std::uint8_t> b (64, 0);
+    const std::int32_t head[1] = { 7 };
+    std::memcpy (b.data(), head, 4);
+    std::memcpy (b.data() + 4, P.data(), 48);
+    std::memcpy (b.data() + 52, &sliceMode, 4);
+    std::memcpy (b.data() + 56, &keyMode, 4);
+    std::memcpy (b.data() + 60, &sync, 4);
+    return lynx::granulizerNormalisedState (b, {});
+}
+
+double energy (const std::vector<float>& y, int c)
+{
+    double e = 0.0;
+    for (std::size_t i = (std::size_t) c; i < y.size(); i += 2)
+        e += (double) y[i] * y[i];
+    return e;
+}
+
+// the instrument on a channel, one note, `n` frames (left only)
+std::vector<float> play (const lynx::ChannelDef& ch, std::shared_ptr<const lynx::SampleData> smp, int n, double rate = 44100.0)
+{
+    auto inst = lynx::makeInstrument (lynx::InstrumentKind::granulizer, smp);
+    inst->prepare (rate);
+    inst->configure (ch, 140.0);
+    std::vector<float> l ((std::size_t) n, 0.0f), r ((std::size_t) n, 0.0f);
+    inst->noteOn (62, 0.8f);
+    inst->render (l.data(), r.data(), n, 1.0f, 1.0f);
+    return l;
+}
+} // namespace flgran165
+
+TEST (granulizer165_modes)
+{
+    using namespace flgran165;
+    const std::array<int, 12> P { 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 };
+    auto s = state (P, 1, 2, 1);
+    CHECK (lynx::granulizerMode (s, 0) == 1 && lynx::granulizerMode (s, 1) == 2 && lynx::granulizerMode (s, 2) == 1
+           && ! lynx::granulizerMode (s, 3));
+    CHECK (lynx::granulizerSetMode (s, 2, 0) && lynx::granulizerMode (s, 2) == 0);
+    CHECK (lynx::granulizerSetMode (s, 0, 9) && lynx::granulizerMode (s, 0) == 2); // clamped to "detect"
+    // FL's editor: "Transient" keys turn slice detection on when the transients are off (0x758050, on every load)
+    CHECK (lynx::granulizerSetMode (s, 0, 0) && lynx::granulizerSetMode (s, 1, 3) && lynx::granulizerMode (s, 0) == 2);
+    CHECK (lynx::granulizerMode (state (P, 0, 3, 0), 0) == 2 && lynx::granulizerMode (state (P, 1, 3, 0), 0) == 1);
+    // the sync byte 2 ("auto", never saved by FL in practice) is kept as off
+    CHECK (lynx::granulizerMode (state (P, 0, 0, 2), 2) == 0);
+}
+
+TEST (granulizer165_goldens)
+{
+    // LYNX's engine against our goldens, which the installation's DLL renders within −134 / −94 / −136 dB before the
+    // first release (tmp/flgran165/py/gold165.py; the −94 dB case: the sample reader's edge path at a 48 kHz sample)
+    using namespace flgran165;
+    using N = lynx::granulizer::RefNote;
+    struct Golden { std::vector<std::uint8_t> state; int ch, fs, rate; lynx::granulizer::RefOptions opt; std::vector<N> notes;
+                    double el, er; std::tuple<int, float, float> at[6]; };
+    auto check = [] (const Golden& g) {
+        const auto smp = drums (g.ch, g.rate);
+        auto opt = g.opt;
+        if (lynx::granulizerMode (g.state, 0) == 2)
+            opt.slices = lynx::flslice::autoSlice (smp.leftData(), g.ch > 1 ? smp.rightData() : nullptr, (std::int64_t) smp.frames(), smp.sampleRate);
+        const auto y = lynx::granulizer::renderReference (g.state, smp, g.notes, (double) g.fs, 32768, opt);
+        CHECK (y.size() == 2 * 32768);
+        if (y.size() != 2 * 32768)
+            return;
+        const auto el = energy (y, 0), er = energy (y, 1);
+        CHECK (std::abs (el - g.el) <= 1e-6 * g.el && std::abs (er - g.er) <= 1e-6 * g.er);
+        for (const auto& [i, l, r] : g.at)
+            CHECK (goldenSampleClose (y[2 * (std::size_t) i], l, granulizerTolerance())
+                   && goldenSampleClose (y[2 * (std::size_t) i + 1], r, granulizerTolerance()));
+    };
+    {
+        // auto slices (slices 0, 7000, 15480, 26000, 32976, 41000) with the transient hold
+        CHECK ((lynx::flslice::autoSlice (drums (2, 44100).leftData(), drums (2, 44100).rightData(), 48000, 44100.0)
+                == std::vector<std::int64_t> { 0, 7000, 15480, 26000, 32976, 41000 }));
+        lynx::granulizer::RefOptions o;
+        o.points = 12, o.tempo = 120.0;
+        check ({ state ({ 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 }, 2, 0, 0), 2, 44100, 44100, o,
+                 { { 0, 60, 0.8, 0.0, 0.0, -1 }, { 9000, 62, 0.6, -0.3, 0.0, 20000 } }, 646.7863275739593, 309.46088519508237,
+                 { { 100, -0.3466797173023224f, -0.2600097954273224f }, { 2500, 0.086669921875f, 0.06500244140625f },
+                   { 6100, -0.08848780393600464f, -0.06636585295200348f }, { 11111, -0.14579427242279053f, -0.06419368088245392f },
+                   { 17000, -0.16434688866138458f, -0.13543438911437988f }, { 30000, -0.03256341814994812f, -0.024431241676211357f } } });
+    }
+    {
+        // regions (the WAV's markers) with "Transient" keys: C#5 and D#5 start at slices 1 and 3; mono 48 kHz sample
+        lynx::granulizer::RefOptions o;
+        o.points = 12, o.tempo = 120.0, o.slices = { 0, 7000, 26000, 41000 };
+        check ({ state ({ 150, 120, 400, 500, 0, 180, 0, 20, 1, 0, 0, 300 }, 1, 3, 0), 1, 44100, 48000, o,
+                 { { 0, 61, 1.0, 0.2, 0.0, -1 }, { 6000, 63, 0.5, 0.0, 0.0, -1 } }, 1561.4073825720589, 2339.501975751048,
+                 { { 100, -0.03832821547985077f, -0.03161964565515518f }, { 2500, 0.09727142751216888f, 0.08024617284536362f },
+                   { 6100, -0.12772196531295776f, 0.1849401742219925f }, { 11111, 0.43030425906181335f, 0.41122832894325256f },
+                   { 17000, 0.2787952423095703f, 0.22190749645233154f }, { 30000, -0.01753564178943634f, 0.03832763060927391f } } });
+    }
+    {
+        // tempo locked at 4 beats, 140 BPM, "Step" keys, auto slices, FL's render quality (16 points), 44.1 kHz sample at 48 kHz
+        lynx::granulizer::RefOptions o;
+        o.points = 16, o.tempo = 140.0, o.beats = 4.0f;
+        check ({ state ({ 180, 60, 500, 611, 0, 180, 0, 30, 0, 0, 0, 100 }, 2, 2, 1), 2, 48000, 44100, o,
+                 { { 0, 60, 0.9, 0.0, 0.0, -1 }, { 5000, 64, 0.7, 0.0, 13.0, 25000 } }, 1200.1440687254085, 436.4748503902965,
+                 { { 100, 0.49821606278419495f, 0.16563299298286438f }, { 2500, 0.11618572473526001f, -0.06435169279575348f },
+                   { 6100, -0.059035543352365494f, -0.05729549378156662f }, { 11111, -0.17978179454803467f, -0.16116628050804138f },
+                   { 17000, 0.1330646574497223f, 0.05158308893442154f }, { 30000, -0.12011360377073288f, -0.1214638277888298f } } });
+    }
+}
+
+TEST (granulizer165_instrument)
+{
+    // the channel's wiring: which beat count FL hands the plugin, where the slices come from, the render quality
+    using namespace flgran165;
+    auto make = [] (double acid, std::vector<std::int64_t> markers = {}) {
+        auto d = std::make_shared<lynx::SampleData> (drums (2, 44100.0));
+        d->acidBeats = (float) acid;
+        d->markerStarts = std::move (markers);
+        return std::shared_ptr<const lynx::SampleData> (d);
+    };
+    lynx::ChannelDef ch;
+    ch.instrument = lynx::InstrumentKind::granulizer;
+    ch.pluginState = state ({ 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 }, 0, 2, 1);
+    constexpr int n = 30000;
+    // the WAV's ACID beats win over the channel's TIME (FL render g12): ACID 4 + TIME 8 = TIME 4 alone ≠ TIME 8 alone
+    ch.sampler.stretchBeats = 8.0f;
+    const auto acid4 = play (ch, make (4.0), n), time8 = play (ch, make (0.0), n);
+    ch.sampler.stretchBeats = 4.0f;
+    const auto time4 = play (ch, make (0.0), n);
+    CHECK (acid4 == time4 && acid4 != time8);
+    // tempo lock off: the beats only move the Step keys' start (no sync); still differs from no beats at all
+    ch.sampler.stretchBeats = 0.0f;
+    const auto none = play (ch, make (0.0), n);
+    CHECK (none != time4);
+    // slices: "Use regions" with the auto slicer's positions as WAV markers = "Detect"; both differ from no slices
+    const std::vector<std::int64_t> autoSl { 0, 7000, 15480, 26000, 32976, 41000 };
+    ch.pluginState = state ({ 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 }, 2, 0, 0);
+    const auto detect = play (ch, make (0.0), n);
+    ch.pluginState = state ({ 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 }, 1, 0, 0);
+    const auto regions = play (ch, make (0.0, autoSl), n), noMarkers = play (ch, make (0.0), n);
+    ch.pluginState = state ({ 204, 50, 611, 300, 0, 180, 0, 0, 0, 0, 0, 228 }, 0, 0, 0);
+    const auto plain = play (ch, make (0.0), n);
+    CHECK (detect == regions && detect != plain && noMarkers == plain);
+    // FL renders with 16 interpolation points per side, plays live with 12: a sample off the host rate sounds slightly
+    // different while exporting
+    auto offRate = std::make_shared<lynx::SampleData> (drums (2, 48000.0));
+    const auto live = play (ch, offRate, n);
+    lynx::setOfflineRendering (true);
+    const auto exported = play (ch, offRate, n);
+    lynx::setOfflineRendering (false);
+    CHECK (live != exported && std::inner_product (live.begin(), live.end(), live.begin(), 0.0) > 1.0);
+}

+ 108 - 0
tests/Kepler165kTests.inc

@@ -0,0 +1,108 @@
+// Round 165g flbeta165k (REA_rodada165g-flbeta165k): Kepler against FL — the chorus filter designed with the engine
+// library's sine/cosine, the channel volume / pan reaching the engine as FL's MIDI events, cut groups that do not cut it.
+
+namespace
+{
+float kepler165Bits (std::uint32_t u)
+{
+    float f;
+    std::memcpy (&f, &u, 4);
+    return f;
+}
+} // namespace
+
+TEST (kepler_chorus_like_the_dll)
+{
+    // the default patch with chorus I (panel float 30 = 0.33): the chorus pre-filter's biquad is designed with the
+    // library's sin/cos (they differ from the correctly rounded ones at 44.1 kHz); bit-exact against FL's DLL [EXEC]
+    auto st = keplerTestState();
+    const float chorus1 = 0.33f;
+    std::memcpy (st.data() + 0x21 + 4 * 30, &chorus1, 4);
+    const auto dll = keplerDll();
+    if (dll.empty() || ! lynx::keplerDllUsable (dll))
+        return;
+    const std::vector<lynx::kepler::RefNote> notes { { 0, 60, 1.0, 0.0, 0.0, 20000 }, { 8000, 67, 0.6, 0.0, 0.0, 26000 }, { 16000, 55, 0.95, 0.0, 0.0, 30000 } };
+    const auto y = lynx::kepler::renderReference (st, dll, notes, 44100.0, 39690);
+    CHECK (y.size() == 2 * 39690);
+    if (y.size() != 2 * 39690)
+        return;
+    double el = 0.0, er = 0.0;
+    for (std::size_t i = 0; i < y.size(); i += 2)
+        el += (double) y[i] * y[i], er += (double) y[i + 1] * y[i + 1];
+    std::printf ("  Kepler chorus I: energy %.9f %.9f (FL's DLL 343.102284005 202.927036115)\n", el, er);
+    CHECK (std::abs (el - 343.102284005) < 1e-6 && std::abs (er - 202.927036115) < 1e-6);
+    const std::tuple<int, std::uint32_t, std::uint32_t> golden[] { { 5000, 1033982441u, 1037438445u }, { 12000, 3187804986u, 3182435783u },
+                                                                   { 25000, 1040300487u, 1016870516u }, { 35000, 980787694u, 980626269u } };
+    for (const auto& [i, l, r] : golden)
+        CHECK (y[2 * (std::size_t) i] == kepler165Bits (l) && y[2 * (std::size_t) i + 1] == kepler165Bits (r));
+}
+
+TEST (kepler_channel_levels_as_midi_events)
+{
+    // FL sends the channel volume as MIDI volume (raw·128/12800 truncated) and the channel pan as MIDI pan, and the
+    // engine turns them into its output gains √(1 − p)·k·(a·v³ − b·v² + c·v); the channel pan also stays in the note's
+    // pan expression (it counts twice, as in FL's renders). The instrument output = the reference (constructor gains
+    // 6.309) × target / 6.309.
+    const auto st = keplerTestState();
+    const auto dll = keplerDll();
+    if (dll.empty() || ! lynx::keplerDllUsable (dll))
+        return;
+    const auto cubic = [] (double v) { return (6.210264205932617 * v * v * v - 1.4609940052032471 * v * v + 1.5597299337387085 * v) * 1.4144271612167358; };
+    struct Case
+    {
+        float volume, pan;
+        int midiVolume, midiPan;
+    };
+    for (const auto& k : { Case { 0.78125f, 0.0f, 100, 0 }, Case { 9050.0f / 12800.0f, 0.0f, 90, 0 }, Case { 0.78125f, -0.5f, 100, -32 } })
+    {
+        lynx::ChannelDef c;
+        c.instrument = lynx::InstrumentKind::kepler;
+        c.pluginState = st;
+        c.samplePath = dll;
+        auto inst = lynx::makeInstrument (lynx::InstrumentKind::kepler);
+        inst->configure (c, 125.0);
+        inst->prepare (44100.0);
+        // LYNX's channel gains: channelGain(volume) on the cos/sin pan law (RackRenderer panGains)
+        const auto g = lynx::channelGain (k.volume);
+        const auto angle = (k.pan + 1.0f) * 0.25f * 3.14159265f;
+        const auto gl = g * std::cos (angle) * 1.41421356f, gr = g * std::sin (angle) * 1.41421356f;
+        inst->noteOn (60, 0.78125f);
+        std::vector<float> l (8192), r (8192);
+        inst->render (l.data(), r.data(), 8192, gl, gr);
+        // the reference: the same note (the instrument's Init.Vol, Final.Pan = the channel pan)
+        const auto initVol = (std::pow (11.0, 1.28 * (double) 0.78125f) - 1.0) / 10.0;
+        const auto y = lynx::kepler::renderReference (st, dll, { { 0, 60, initVol, (double) k.pan, 0.0, -1 } }, 44100.0, 8192, { 125.0, 8192 });
+        CHECK (y.size() == 2 * 8192);
+        if (y.size() != 2 * 8192)
+            continue;
+        const auto v = k.midiVolume / 127.0, p = k.midiPan / 128.0 + 0.5;
+        const auto tl = std::sqrt (1.0 - p) * cubic (v) / 6.309, tr = std::sqrt (p) * cubic (v) / 6.309;
+        double worst = 0.0, peak = 0.0;
+        for (int i = 0; i < 8192; ++i)
+        {
+            worst = std::max ({ worst, std::abs (l[(std::size_t) i] - y[2 * (std::size_t) i] * tl), std::abs (r[(std::size_t) i] - y[2 * (std::size_t) i + 1] * tr) });
+            peak = std::max (peak, (double) std::abs (y[2 * (std::size_t) i]));
+        }
+        std::printf ("  Kepler MIDI levels %d/%d: worst %.3g of peak %.3g\n", k.midiVolume, k.midiPan, worst, peak);
+        CHECK (peak > 0.05 && worst < 1e-5 * peak);
+    }
+}
+
+TEST (kepler_ignores_cut_groups)
+{
+    // FL's renders of a Kepler channel with "cut itself" equal the ones without (REA_rodada165g-flbeta165k §3): the
+    // schedule never chokes a Kepler channel, while a sampler channel in the same group is still cut
+    lynx::Song song;
+    song.channels.resize (2);
+    song.channels[0].instrument = lynx::InstrumentKind::kepler;
+    song.channels[1].instrument = lynx::InstrumentKind::sampler;
+    for (auto& c : song.channels)
+        c.cutGroup = c.cutBy = 1;
+    const auto state = lynx::RackState::build (song, nullptr, 44100.0);
+    CHECK (state != nullptr);
+    if (state == nullptr)
+        return;
+    CHECK (state->cutTargets.size() == 2);
+    for (const auto& t : state->cutTargets)
+        CHECK (t.size() == 1 && t[0] == 1);
+}

+ 65 - 0
tests/PerfMode165Tests.inc

@@ -535,3 +535,68 @@ TEST (perfmode165_midi_channel_launches_clips)
     CHECK (prefs::MidiPrefs::fromText (p.toText()).performanceChannel == 16);
     CHECK (prefs::MidiPrefs::fromText (prefs::MidiPrefs {}.toText()).performanceChannel == 0);
 }
+
+TEST (perfmode165_midi_modifiers_and_prepare_macro)
+{
+    using namespace lynx;
+    // [DECOMP] FUN_01221c00: 125 held → the clip's column on every track, 126 → only tracks playing, 127 → next bar
+    perf::MidiMapping m;
+    perf::Command c;
+    CHECK (! m.note (125, true, c) && m.columnHeld);
+    CHECK (m.note (1, true, c) && c.scope == perf::Command::Scope::column && ! c.barSync);
+    CHECK (! m.note (125, false, c) && ! m.columnHeld);
+    CHECK (! m.note (127, true, c));
+    CHECK (m.note (0, true, c) && c.scope == perf::Command::Scope::track && c.barSync);
+    CHECK (! m.note (127, false, c) && ! m.note (126, true, c));
+    CHECK (m.note (0, true, c) && c.scope == perf::Command::Scope::columnPlaying);
+
+    {
+        // a column launch from track 0's second clip reaches track 2's clip in the same column only
+        auto s = perfmode165::zoneSong();
+        Clip other;
+        other.pattern = 0, other.track = 2, other.start = 4 * ppq, other.length = 4 * ppq;
+        s.playlist.push_back (other);
+        Clip elsewhere = other;
+        elsewhere.track = 3, elsewhere.start = 8 * ppq;
+        s.playlist.push_back (elsewhere);
+        s.playlistTracks.resize (4);
+        perfmode165::Run r (std::move (s));
+        perf::Command col;
+        col.type = perf::Command::Type::press, col.track = 0, col.column = 1, col.scope = perf::Command::Scope::column;
+        r.live.midiCommands.push (col);
+        r.runTo (120.0);
+        CHECK (r.playing (0) == 4 * ppq && r.playing (2) == 4 * ppq && r.playing (3) == -1);
+    }
+    {
+        // the next bar instead of the 1/4 beat sync
+        auto s = perfmode165::zoneSong();
+        s.playlistTracks[0].performance.triggerSync = TrackPerformance::Sync::quarterBeat;
+        s.playlistTracks[0].performance.tolerant = false;
+        perfmode165::Run r (std::move (s));
+        r.runTo (600.0);
+        perf::Command bar;
+        bar.type = perf::Command::Type::press, bar.track = 0, bar.clipStart = 0, bar.barSync = true;
+        r.live.midiCommands.push (bar);
+        r.runTo (1200.0);
+        CHECK (r.playing (0) == -1);
+        r.runTo (4.0 * ppq + 120.0);
+        CHECK (r.playing (0) == 0);
+    }
+    {
+        // the macro: 16 one-bar columns before the song, the Start marker where it begins
+        auto s = perfmode165::zoneSong();
+        s.performanceMode = false;
+        for (auto& m : s.markers())
+            m.action = 0; // (no Start yet)
+        const auto firstClip = s.playlist[0].start;
+        perf::prepareForPerformance (s, 16, 4 * ppq);
+        CHECK (s.performanceMode && s.mode == PlayMode::song);
+        CHECK (s.performanceZoneEnd() == 64 * ppq);
+        CHECK (s.playlist[0].start == firstClip + 64 * ppq);
+        int columns = 0;
+        for (const auto& m : s.markers())
+            columns += m.tick < 64 * ppq && m.tick % (4 * ppq) == 0 && m.action == 0 ? 1 : 0;
+        CHECK (columns == 16);
+        CHECK (perf::zoneClips (s).empty()); // the song's clips moved after the Start marker
+    }
+}

+ 5 - 0
tests/tests.cpp

@@ -51,6 +51,7 @@
 #include "core/FlSynths.h"
 #include "core/Inflate.h"
 #include "core/WavPack.h"
+#include "core/SampleFiles.h"
 #include "core/FlWrapper.h"
 #include "core/FlPluginDb.h"
 #include "core/MissingFiles.h"
@@ -14351,6 +14352,7 @@ TEST (granulizer_engine)
                    && goldenSampleClose (y[2 * (std::size_t) i + 1], r, granulizerTolerance()));
     };
     lynx::granulizer::RefOptions o1, o2, o3;
+    o1.points = o2.points = o3.points = 12; // the plugin's own default quality (these goldens predate FL's render value)
     o2.block = 333, o2.seed = 777;
     o3.block = 64, o3.seed = 5;
     // the plugin's defaults, two notes (one pitched by +23 cents and released: the processor's end fade)
@@ -16236,4 +16238,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Fl165Tests.inc"
 #include "Perf165Tests.inc"
 #include "Issue12Tests.inc"
+#include "FlGran165Tests.inc"
+#include "Kepler165kTests.inc"
 #include "MixerLatency165Tests.inc"
+#include "Audit165Tests.inc"

+ 5 - 0
tools/WavReader.h

@@ -12,6 +12,7 @@
 #include <string>
 #include <vector>
 
+#include "core/AudioEdit.h"
 #include "core/Instruments.h"
 #include "core/Mp3Decoder.h"
 #include "core/OggVorbis.h"
@@ -151,6 +152,10 @@ inline std::shared_ptr<const SampleData> readWav (const std::string& path)
             sample->right[i] = read (frame + bytesPerSample);
     }
 
+    // cue points / regions and ACID beats, as the app's SampleLibrary keeps them (Fruity Granulizer's slices and sync)
+    const auto extras = audioedit::decodeWavExtras (d.data(), d.size(), (std::int64_t) frames);
+    sample->markerStarts = extras.markerStarts;
+    sample->acidBeats = extras.acidBeats;
     return sample;
 }
 } // namespace lynx::tools

+ 21 - 1
tools/granulizerrender.cpp

@@ -1,6 +1,7 @@
 // Renders a Fruity Granulizer state with LYNX's engine exactly like the round-67 EXEC harness drives the DLL
 // (verification harness, REA_rodada67 §4): granulizerrender <state.bin> <sample.raw> <channels> <format 0=int16 1=float>
-//   <sample rate> <out.f32> <length> <rate> [blk=N] [seed=N] [note=start,key,finalVol,finalPan,pitchCents,release ...]
+//   <sample rate> <out.f32> <length> <rate> [blk=N] [seed=N] [tempo=BPM] [beats=N] [slices=auto|<file of starts>]
+//   [note=start,key,finalVol,finalPan,pitchCents,release ...]
 // The state is normalised first; the raw sample is interleaved frames. Writes interleaved stereo float32.
 #include <cstdio>
 #include <cstdlib>
@@ -10,6 +11,7 @@
 #include <string>
 #include <vector>
 
+#include "core/FlAutoSlicer.h"
 #include "core/Granulizer.h"
 
 int main (int argc, char** argv)
@@ -54,6 +56,24 @@ int main (int argc, char** argv)
             opt.block = std::atoi (a.c_str() + 4);
         else if (a.rfind ("seed=", 0) == 0)
             opt.seed = (std::uint32_t) std::strtoul (a.c_str() + 5, nullptr, 10);
+        else if (a.rfind ("tempo=", 0) == 0)
+            opt.tempo = std::atof (a.c_str() + 6);
+        else if (a.rfind ("points=", 0) == 0)
+            opt.points = std::atoi (a.c_str() + 7);
+        else if (a.rfind ("beats=", 0) == 0)
+            opt.beats = (float) std::atof (a.c_str() + 6);
+        else if (a == "slices=auto")
+            opt.slices = lynx::flslice::autoSlice (smp.left.data(), ch > 1 ? smp.right.data() : nullptr, (std::int64_t) frames, smp.sampleRate);
+        else if (a.rfind ("slices=", 0) == 0)
+        {
+            if (std::FILE* sf = std::fopen (a.c_str() + 7, "r"))
+            {
+                long long v;
+                while (std::fscanf (sf, "%lld", &v) == 1)
+                    opt.slices.push_back (v);
+                std::fclose (sf);
+            }
+        }
         else if (a.rfind ("note=", 0) == 0)
         {
             lynx::granulizer::RefNote n;

+ 9 - 0
tools/keplerrender.cpp

@@ -1,5 +1,6 @@
 // Renders a Kepler state with LYNX's engine the way the REA round-46 EXEC harness drives FL's engine DLL (verification,
 // REA_rodada46 §6): keplerrender <state.bin> <engine_x64.dll> <out.f32> <length> <rate> [tempo=X] [blk=N]
+// [warm=N] [midivol=V] [midipan=P] [transport]   (FL's export: warm-up, channel levels as MIDI, song playing)
 // [note=start,key,initVol,finalPan,pitchCents,off ...]   (off = −1: held). Output: interleaved stereo float32.
 
 #include <chrono>
@@ -35,6 +36,14 @@ int main (int argc, char** argv)
             opt.tempo = std::atof (val().c_str());
         else if (a.rfind ("blk=", 0) == 0)
             opt.block = std::atoi (val().c_str());
+        else if (a.rfind ("warm=", 0) == 0)
+            opt.warmup = std::atoi (val().c_str());
+        else if (a.rfind ("midivol=", 0) == 0)
+            opt.midiVolume = std::atoi (val().c_str());
+        else if (a.rfind ("midipan=", 0) == 0)
+            opt.midiPan = std::atoi (val().c_str());
+        else if (a == "transport")
+            opt.transport = true;
         else if (a.rfind ("note=", 0) == 0)
         {
             std::stringstream ss (val());