Przeglądaj źródła

Merge remote-tracking branch 'origin/main' into feature/gms-morphine

# Conflicts:
#	CMakeLists.txt
#	README.md
#	docs/HANDOFF.md
#	docs/STATUS.md
#	resources/i18n/pt-BR.txt
#	scripts/build-local.sh
#	scripts/build-windows-zig.sh
#	src/core/FlpImport.cpp
#	src/core/Instruments.cpp
#	src/core/Song.h
#	src/engine/ProjectFile.cpp
#	src/ui/ChannelRackComponent.cpp
#	src/ui/ChannelSettings.cpp
#	src/ui/I18nData.h
#	tests/tests.cpp
Ka1-S 1 miesiąc temu
rodzic
commit
855317026f
84 zmienionych plików z 13968 dodań i 1255 usunięć
  1. 17 0
      CMakeLists.txt
  2. 1 1
      README.md
  3. 4 7
      docs/HANDOFF.md
  4. 6 1
      docs/ROADMAP.md
  5. 80 28
      docs/STATUS.md
  6. 81 50
      docs/WORKFLOW_FL.md
  7. 9 0
      docs/analise/REA_rodada37.md
  8. 213 0
      docs/analise/REA_rodada40.md
  9. 1 0
      resources/LYNX.rc
  10. BIN
      resources/LYNX_doc.ico
  11. 211 0
      resources/i18n/pt-BR.txt
  12. 4 1
      scripts/build-local.sh
  13. 7 1
      scripts/build-windows-zig.sh
  14. 86 2
      src/Main.cpp
  15. 7 0
      src/core/Effects.cpp
  16. 88 1
      src/core/FlEffects.cpp
  17. 19 0
      src/core/FlEffects.h
  18. 52 6
      src/core/FlpImport.cpp
  19. 378 129
      src/core/HarmlessFx.cpp
  20. 27 0
      src/core/HarmlessFx.h
  21. 214 0
      src/core/History.cpp
  22. 27 0
      src/core/History.h
  23. 4 0
      src/core/Instruments.cpp
  24. 67 1
      src/core/KeyMap.cpp
  25. 2 1
      src/core/KeyMap.h
  26. 100 0
      src/core/MaximusFx.cpp
  27. 45 0
      src/core/MaximusFx.h
  28. 221 0
      src/core/MixerOps.cpp
  29. 42 0
      src/core/MixerOps.h
  30. 171 0
      src/core/NoteEdit.cpp
  31. 29 0
      src/core/NoteEdit.h
  32. 410 0
      src/core/NoteTools.cpp
  33. 115 0
      src/core/NoteTools.h
  34. 3693 0
      src/core/Ogun.cpp
  35. 82 0
      src/core/Ogun.h
  36. 118 0
      src/core/PlateReverb.h
  37. 220 0
      src/core/RackOps.cpp
  38. 44 0
      src/core/RackOps.h
  39. 60 0
      src/core/Recorder.cpp
  40. 21 0
      src/core/Recorder.h
  41. 184 0
      src/core/SearchQuery.cpp
  42. 33 0
      src/core/SearchQuery.h
  43. 6 4
      src/core/Song.h
  44. 156 9
      src/core/Vocodex.cpp
  45. 21 4
      src/core/Vocodex.h
  46. 167 8
      src/engine/AudioEngine.cpp
  47. 44 1
      src/engine/AudioEngine.h
  48. 9 5
      src/engine/Metronome.cpp
  49. 4 2
      src/engine/ProjectFile.cpp
  50. 3 0
      src/engine/Transport.h
  51. 36 0
      src/platform/FileTypes.cpp
  52. 9 0
      src/platform/FileTypes.h
  53. 132 4
      src/ui/AutomationUi.cpp
  54. 395 16
      src/ui/BrowserComponent.cpp
  55. 38 1
      src/ui/BrowserComponent.h
  56. 471 12
      src/ui/ChannelRackComponent.cpp
  57. 33 1
      src/ui/ChannelRackComponent.h
  58. 35 3
      src/ui/ChannelSettings.cpp
  59. 113 0
      src/ui/HistoryPanel.cpp
  60. 14 0
      src/ui/HistoryPanel.h
  61. 1387 841
      src/ui/I18nData.h
  62. 20 0
      src/ui/Icons.cpp
  63. 3 2
      src/ui/Icons.h
  64. 331 42
      src/ui/MainComponent.cpp
  65. 29 0
      src/ui/MainComponent.h
  66. 486 14
      src/ui/MixerComponent.cpp
  67. 43 1
      src/ui/MixerComponent.h
  68. 387 0
      src/ui/NoteToolDialogs.cpp
  69. 27 0
      src/ui/NoteToolDialogs.h
  70. 223 33
      src/ui/PianoRollComponent.cpp
  71. 30 2
      src/ui/PianoRollComponent.h
  72. 434 10
      src/ui/PlaylistComponent.cpp
  73. 37 1
      src/ui/PlaylistComponent.h
  74. 265 0
      src/ui/QuickAddPalette.cpp
  75. 23 0
      src/ui/QuickAddPalette.h
  76. 90 0
      src/ui/ToolWindow.cpp
  77. 22 0
      src/ui/ToolWindow.h
  78. 57 1
      src/ui/Workspace.cpp
  79. 2 0
      src/ui/Workspace.h
  80. 544 0
      tests/WorkflowP2Tests.inc
  81. 515 8
      tests/tests.cpp
  82. 50 0
      tools/make_doc_icon.py
  83. 83 0
      tools/ogunrender.cpp
  84. 1 1
      tools/renderwav.cpp

+ 17 - 0
CMakeLists.txt

@@ -38,10 +38,12 @@ add_library(lynx_core STATIC
     src/core/Harmor.cpp
     src/core/Gms.cpp
     src/core/Morphine.cpp
+    src/core/Ogun.cpp
     src/core/HarmlessFx.cpp
     src/core/SytrusEngine.cpp
     src/core/VintagePhaser.cpp
     src/core/Vocodex.cpp
+    src/core/MaximusFx.cpp
     src/core/FlPatcher.cpp
     src/core/Inflate.cpp
     src/core/WavPack.cpp)
@@ -54,6 +56,13 @@ target_sources(lynx_core PRIVATE
     src/core/RackOps.cpp
     src/core/StartupSound.cpp)
 
+# workflow P2 (note tools, mixer operations, history labels, browser search)
+target_sources(lynx_core PRIVATE
+    src/core/NoteTools.cpp
+    src/core/MixerOps.cpp
+    src/core/History.cpp
+    src/core/SearchQuery.cpp)
+
 # WavPack decoder (BSD; read-only) for the .wv samples in the FL packs
 file(GLOB WAVPACK_SOURCES third_party/wavpack/src/*.c)
 add_library(wavpack_decoder STATIC ${WAVPACK_SOURCES})
@@ -93,6 +102,7 @@ if(LYNX_BUILD_APP)
 
     target_sources(LYNX PRIVATE
         src/Main.cpp
+        src/platform/FileTypes.cpp
         src/engine/AudioEngine.cpp
         src/engine/ChannelRackProcessor.cpp
         src/engine/Metronome.cpp
@@ -130,6 +140,13 @@ if(LYNX_BUILD_APP)
         src/ui/Dialogs.cpp
         src/ui/Splash.cpp)
 
+    # workflow P2: note tool dialogs, tool windows, undo history, quick-add palette
+    target_sources(LYNX PRIVATE
+        src/ui/NoteToolDialogs.cpp
+        src/ui/ToolWindow.cpp
+        src/ui/HistoryPanel.cpp
+        src/ui/QuickAddPalette.cpp)
+
     target_include_directories(LYNX PRIVATE third_party/asiosdk/common)
 
     target_compile_definitions(LYNX PRIVATE

+ 1 - 1
README.md

@@ -164,7 +164,7 @@ LYNX reads the `.flp` format directly and converts everything that has an equiva
 
 - **Structure:** channels, real samples (including the Ogg Vorbis WAVs and WavPack files shipped with FL), patterns, slide/porta notes, every arrangement, markers, time-signature changes, automation and controller links.
 - **Mixer:** routing, levels, sidechains, track EQ and native effects with their saved settings (Parametric EQ 2, Limiter, Compressor, Reeverb 2, Delay 3, Maximus, Gross Beat, Effector, Love Philter, Frequency Splitter, Patcher, Pitcher, Vocoder and more).
-- **Generators:** 3x Osc, FPC, DirectWave, FL Keys, Slicex, Fruity Slicer and Wave Traveller become samplers; **Sakura, Drumpad, BooBass, Fruity DrumSynth Live, GMS and Morphine run on engines rebuilt from FL's own** (checked against FL's DLLs; BooBass, DrumSynth, GMS and Morphine read their built-in sounds from *your* FL installation, never shipped with LYNX); Sytrus, Harmor, Harmless, Kepler, Ogun, MiniSynth, DX10, Toxic Biohazard, BassDrum and others run on the built-in synth, with timbres rebuilt from the curves and harmonic tables stored in the project.
+- **Generators:** 3x Osc, FPC, DirectWave, FL Keys, Slicex, Fruity Slicer and Wave Traveller become samplers; **Sakura, Drumpad, BooBass, Fruity DrumSynth Live, GMS and Morphine run on engines rebuilt from FL's own** (checked against FL's DLLs; BooBass, DrumSynth, GMS and Morphine read their built-in sounds from *your* FL installation, never shipped with LYNX); **Sytrus, Harmless, Harmor and Ogun run on their own engines rebuilt from the plugin state**; Kepler, Autogun, MiniSynth, DX10, Toxic Biohazard, BassDrum and others run on the built-in synth, with timbres rebuilt from the curves and harmonic tables stored in the project.
 - **Exact native effects:** Effector (Filter, Flanger, Phaser), Fruity Squeeze, Vintage Phaser and Pitcher reproduce FL's algorithms; how each one was decoded is documented in [`docs/analise/`](docs/analise/).
 - **Third-party plugins:** VST3/CLAP plugins inside the Fruity Wrapper are swapped for the same installed plugin, preset included.
 

+ 4 - 7
docs/HANDOFF.md

@@ -4,17 +4,14 @@
 
 ## Merged and published in this period
 - Exact FL engines: Sytrus (REA 31), Harmless + its effects rack (REA 32/36), Harmor + its effects rack (REA 34/38),
-  Vocodex (REA 35), Effector Reverb, Toxic filter envelope, Kepler LFO sync (REA 33).
+  Vocodex (REA 35), Effector Reverb, Toxic filter envelope, Kepler LFO sync (REA 33); after the migration Ogun (REA 37),
+  Maximus/Soundgoodizer (REA 40), GMS and Morphine (REA 39, bit-identical to the reference models).
 - UI: dark theme with red accent, EN/pt-BR, FL-style floating-panel desktop (Playlist background, Channel Rack pop-up,
   F5–F9), editor tools in the editors' title bars, global snap, note/clip operations, FL-style main toolbar, new icon
   set, splash screen with a synthesized start-up sound (`docs/WORKFLOW_FL.md` has the study, gap tables and layout notes).
 
-## Work in progress (pushed as `wip/*` branches — unverified, may not build)
-| Branch | What | Source of truth | State when stopped |
-|---|---|---|---|
-| `wip/ogun` | Port Ogun's exact engine (`InstrumentKind::ogun`) | `docs/analise/REA_rodada37.md`, model `rea-work/r37/py/ogmodel.py` | engine ported, was running the C++-vs-model battery |
-| `wip/maximus` | Exact Maximus + Soundgoodizer, Vocodex SG stage and internal Sytrus carrier (REA round 40 doc) | `REA_rodada8.md`, `REA_rodada35/36/38.md`, `rea-work/r38/` (harness/models of this round) | code + tests in progress; doc `REA_rodada40.md` not written yet |
-| `wip/wf-p2` | Workflow P2 items (step lanes, mixer gestures, slot drag, browser search, palette, undo history, recording options, note tools, scale…) | `docs/WORKFLOW_FL.md` P2 list | 7 commits; must `git merge main` (FL layout landed) and place buttons per the new layout |
+## Work in progress
+None: every `wip/*` branch of the migration (Ogun, Maximus, Workflow P2, GMS/Morphine) has been merged into `main`.
 
 Not started: REA round 41 (MiniSynth, DX10, Fruit Kick, BassDrum, then PoiZone/Toxic/Kepler full engines).
 

+ 6 - 1
docs/ROADMAP.md

@@ -59,6 +59,8 @@ Ordered to get something usable as early as possible without ever breaking the a
 - [x] ASIO via the Steinberg ASIO SDK's GPLv3 option (2025), compatible with LYNX's AGPL-3.0
 - [x] GPU UI: JUCE 8 draws with Direct2D on Windows
 - [x] Idle channels skipped by the renderer
+- [x] FL workflow P2 (`docs/WORKFLOW_FL.md`): step graph lanes, mixer gestures, slot drag, Browser search, quick-add
+  palette, undo history, recording options, note tools, scale snap, zoom presets, ripple editing
 
 ## Phase 6: FL fidelity (with REA)
 - [x] Volume/fader curves, swing, envelopes, time-stretch, cut groups (round 3)
@@ -78,7 +80,10 @@ Ordered to get something usable as early as possible without ever breaking the a
 - [x] Love Philter: filters, Mod X/Y, pattern envelopes and LFOs, cutoff/resonance modulation in every unit (rounds 16–20)
 - [x] Pitcher (pitch correction) and Fruity Vocoder (rounds 15, 19, 20)
 - [x] Sidechain links (round 22)
-- [x] Vocodex as the vocoder with two side inputs (round 20); internal carrier synth still missing
+- [x] Vocodex as the vocoder with two side inputs (round 20); exact engine (round 35), SG stage and internal Sytrus carrier (round 40)
+- [x] Maximus and Soundgoodizer on FL's exact Maximus engine (rounds 36, 40)
 - [x] Ogun's FFT spectral engine: initial spectrum and per-partial decay (round 24) on an evolving spectrum
+- [x] Ogun on its exact engine from the plugin state: inverse-FFT timbre, articulators, filter, EQ/chorus/delay/reverb,
+  qualities 0–4 (round 37; Autogun still on the synth approximation)
 - [x] Harmor resonance: types, mask and offset (round 25) as an SVF peak
 - [x] FLEX by preset name only (its packs are encrypted and never opened)

+ 80 - 28
docs/STATUS.md

@@ -9,19 +9,36 @@ exports the 30 demo projects shipped with FL Studio 2026.
 ### Editing
 - **Channel Rack:** step sequencer, per-channel volume/pan/mute/solo, swing (FL formula, per-channel mix),
   multiple patterns (rename, colour, length, clone, remove), cut groups, mono channels, arpeggiator,
-  PC keyboard as a piano (FL layout), MIDI input, note recording (one undo step per take).
+  PC keyboard as a piano (FL layout), MIDI input, note recording (one undo step per take). Step graph lanes
+  (Ctrl+K: velocity, pan, release, fine pitch, Mod X/Y; drag, right-drag ramp, Alt+click reset), fill every
+  2/4/8, Euclidean fill, rotate, sort channels, select unused.
+- **Recording options:** count-in (Ctrl+P), wait for the first note (Ctrl+I), overdub/replace, record quantise
+  following the global grid, a pattern clip placed in Song mode; switches next to the metronome in the main
+  toolbar and the full set in the "what to record" menu and Options → Recording.
+- **Quick-add palette (F8 / plugin-picker icon):** searchable instruments and effects (new channel or selected
+  insert). **Undo history** (Ctrl+H, Edit menu): named steps, click to jump.
 - **Piano Roll:** selection (Ctrl+drag, Shift+click, Ctrl+A), group move/resize, Ctrl+C/X/V, Ctrl+B duplicate,
   Ctrl+Q quantize, arrow keys (Shift = octave/bar), snap selector, chords and scale highlighting, per-note
-  velocity/pan/fine pitch/mute, slide (808 glide) and porta notes, `.mid` import/export.
+  velocity/pan/fine pitch/mute, slide (808 glide) and porta notes, `.mid` import/export. Note tools
+  (Arpeggiate, Strum, Flip, Randomise, Scale levels, Limit; Alt+A/S/Y/R/X/K), snap to scale (toolbar switch next
+  to the scale box, also for incoming MIDI), zoom presets (PgUp/PgDn, Shift+1..5/0), vertical zoom.
 - **Playlist:** pattern, audio and automation clips; multiple arrangements; loop region; multi-selection,
   copy/paste/duplicate, split, "make unique"; named/muted tracks; markers and time-signature changes on the
-  ruler; normalize audio clips; pattern picker.
+  ruler; normalize audio clips; pattern picker. Ripple editing (Shift+S) and ripple delete, zoom presets,
+  inline automation-point editing (axis locks, typed values, re-range), track and clip menus.
 - **Automation:** right-click any knob/fader (channel, mixer, effects, plugin parameters) → a Playlist clip with
   a point/curve editor (Alt+drag for curves); tempo automation; MIDI learn on any parameter.
 - **Mixer:** up to 127 inserts, sends with levels, "route to this track only", solo along the signal path, FL
   fader curve, gain ramps, stereo separation, phase invert, L/R swap, colours, built-in 3-band track EQ,
   10 effect slots with dry/wet, smart disable, per-edge PDC, **sidechain** (right-click a compressor slot →
-  "Sidechain from"), render insert to audio.
+  "Sidechain from"), render insert to audio. Multi-select inserts (faders/pans move together), Alt+Left/Right
+  reorder, link selected channels (Ctrl+L / Ctrl+Shift+L / Alt+L), "sidechain only" sends, per-insert record
+  arm, effect slots dragged to reorder, all-effects switch, A/B compare per slot, effect presets dropped from the
+  Browser.
+- **Browser:** search (Ctrl+F: wildcards, AND/OR/NOT), Up/Down audition, Shift+Up/Down and Enter load into the
+  selected channel, user folders.
+- **Window menus:** each window's title-bar menu carries its own items (Playlist ripple/zoom, Channel Rack graph
+  lanes/rotate/sort, Piano Roll tools/zoom/scale snap, Mixer move/link, Browser search/add folder).
 - **Project safety:** "*" in the title, "save changes?", autosave every 2 minutes and an emergency save on crash
   (`%APPDATA%\LYNX\autosave`).
 
@@ -63,11 +80,14 @@ exports the 30 demo projects shipped with FL Studio 2026.
   state — operators, FM/RM matrix, articulators, unison, portamento, filters, effects chain; FL's render settings when
   exporting, its live ones when playing); Harmor on its additive engine (REA round 34: both parts, 520-partial bank,
   module chain, articulators, and its effects rack from REA round 38; within −150 dB of the reference model on 88 of
-  the 89 demo channels it runs, 82 of 99 demo channels within −60 dB of FL's DLL with the whole rack on); GMS and
-  Morphine on their engines (REA round 39: bit-identical to the reference models on every demo channel, voice and
-  full chain, at 44.1 and 48 kHz; the models are within −60 dB of FL's DLLs on 9/9 GMS and 7/7 Morphine demo
-  channels; GMS's waves and Morphine's noise samples read from the user's FL installation); Kepler, Ogun/Autogun,
-  MiniSynth, DX10, Fruit Kick, Toxic Biohazard, PoiZone and BassDrum on the built-in synth; Sakura and Drumpad on physical models rebuilt from their
+  the 89 demo channels it runs, 82 of 99 demo channels within −60 dB of FL's DLL with the whole rack on); Ogun on its
+  inverse-FFT engine (REA round 37: the whole voice, articulators and plugin effects from the raw state; within float
+  rounding of the reference model — which is within −60 dB of FL's DLL on 20 of 20 demo channels — on all 20 demo
+  channels and 55 synthetic cases); GMS and Morphine on their engines (REA round 39: bit-identical to the reference
+  models on every demo channel, voice and full chain, at 44.1 and 48 kHz; the models are within −60 dB of FL's DLLs on
+  9/9 GMS and 7/7 Morphine demo channels; GMS's waves and Morphine's noise samples read from the user's FL
+  installation); Kepler, Autogun, MiniSynth, DX10, Fruit Kick, Toxic Biohazard, PoiZone and BassDrum on the built-in
+  synth; Sakura and Drumpad on physical models rebuilt from their
   engines (REA round 28), BooBass on its engine with the multisample read from the user's own FL installation
   (REA round 29; within −138 dB of the reference renders verified against FL's DLLs).
 - Third-party plugins in the Fruity Wrapper are matched to installed VST3/CLAP plugins (VST3 class ID, CLAP id
@@ -148,9 +168,31 @@ accordingly. Highlights of what is **confirmed and applied**:
   release / release-2 stages, drawn-curve gain tables with tensions, lookahead, saturation, band mix) loaded with
   `Harmless/Data/Compression/<n>.fst` from the user's installation. The old synth approximation remains for unreadable
   states and for the synth's "FL presets" button.
-- **Ogun:** exact initial spectrum of the timbre engine (seeded IPP-style generator, fullness/morph/pre-decay
-  weights, Forced/Impulse maps and patterns, RMS normalisation, fixed seed-3 phases) on the spectral oscillator,
-  with each partial's own decay `(t − 0.025)·B·E_dec + 0.025` (the spectrum evolves during the note); cutoff `44100·(c + c₀)` Hz, FL's Q/width, 20 s release, unison ±5(11^(P15/256) − 1) cents.
+- **Ogun:** its own instrument (`core/Ogun.cpp`, REA round 37; the channel keeps the plugin's raw state): per voice
+  up to 32 767 partials (Richness) with seeded IPP-style weights, fullness shaping, morph, Forced (B·(1 − F) + F),
+  Impulse/Decay/Release per-partial maps (sequential curve sampling, fixed patterns, 1/√h, logarithmic axis, EQ shift),
+  pre-decay, RMS normalisation, band limit and update span; per 50/25 ms frame the spectrum follows the hold, ALT DECAY
+  or release law and becomes an N-point table by an inverse real FFT (N = 2^(P52+q)); the two latest tables are read
+  with the quality's kernel (linear, 6-point 5th-order Hermite, 32-point windowed sinc), crossfaded with the unison
+  sub-voices' pan gains and phase spread (read start at the table's smallest sample), then declick, the 4-type ×
+  1–3-stage filter (2× zero-order hold below 88.2 kHz), FL's volume/pan matrix with gain ramps, silence end, same-key
+  cut and max polyphony; the 13 articulators (point curves modes 0–12, envelopes with ADSR knob scales, tempo sync,
+  velocity options and portamento, LFOs with tension/skew/pulse width, key/velocity/X/Y maps); the plugin's 3-band EQ,
+  chorus, delay (normal/inverted/ping-pong, stereo offset, tempo sync) and reverb (FL's shared plate reverb,
+  `core/PlateReverb.h`, shared with Harmless's rack), and the 2:1 polyphase decimator of qualities 2–4. Level law
+  `(3^(P0/128) − 1)/2`·Final.Vol through Ogun's own pan matrix (channel volume/pan applied once). LYNX plays the
+  state's quality and exports at quality 4, as FL does when it renders. Against the round-37 reference model (own
+  read start, same Seed-2 counter): bit-identical or within −125 dB (float rounding) on all 20 demo channels (44.1 and
+  48 kHz, every effect on, and at the export quality 4) and on 55 synthetic cases (qualities 0–4, richness, unison,
+  filter types, ALT DECAY, 1/√h, patterns, velocity options, portamento, host pan/volume/pitch/Mod X-Y, 48/96 kHz); the
+  model itself is within −60 dB of FL's DLL on 20 of 20 demo channels. The core tests check the engine against model
+  fingerprints: the 20 demo channels at the state's quality and at quality 4 (`ogun_demo_channels`) and 17 feature
+  variants of a state written from scratch (`ogun_engine`). The old spectral-oscillator conversion remains for
+  unreadable states, Autogun (another state layout), and the synth's "FL presets" button.
+  CPU: one inverse FFT of N per voice and frame (split re/im radix-2 passes, cache-blocked, AVX when available), the
+  quality-4 sinc reader vectorised with per-sub-voice tables, finished voices removed and idle channels skipped;
+  "Electric Loop – The Ogun Dream" (14 Ogun channels, 96 s) exports at FL's quality 4 in ~15–22 s (the old
+  approximation: 4.9 s), the other demos with Ogun channels within ±6 s of before.
 - **MiniSynth:** LFO periods, squared LFO depth, release, second voice in whole semitones + 7.5 cents.
 - **Toxic Biohazard:** FM 2·cell (matrix direction read from the code), filter modes (p300), cutoff `2^(9u + 5)`,
   key-track 0.09·KT oct/semitone, envelope ±9·EGAmt oct; FL's 4-pole ladder (table, resonance scale R(u), input
@@ -194,6 +236,11 @@ accordingly. Highlights of what is **confirmed and applied**:
   PSOLA path (257-sample latency), Harmonize and MIDI masks; latency reported to PDC.
 - **Fruity Vocoder:** FL's algorithm (band edges, cascaded band-passes, envelope followers, levels).
 - **Frequency Splitter:** exact Linkwitz-Riley structure for every slope (6–96 dB/oct).
+- **Maximus and Soundgoodizer:** FL's exact Maximus engine as a mixer effect (`core/MaximusFx`, REA round 40) —
+  RMS detector, saturation A/B, state versions 3–15, solo, legacy linear-phase FIR split, x87-precision smoothers;
+  Soundgoodizer runs the older engine copy of its own DLL with the preset `a…d.dat` read from the user's installation
+  at import and Amount as the band mix. Within −139 dB of Maximus_x64.dll on 96 of the 100 demo states (53
+  bit-identical) and within −126 dB of Soundgoodizer_x64.dll on every preset/amount; latency reported to PDC.
 - **Vocodex:** its own engine (`core/Vocodex.cpp`, REA round 35) built from FL's raw state, which the `.lynx`
   project keeps: band layout and the 13 per-band maps, 64-bit band-pass banks (orders 1–4, flatness, 2×
   oversampling above 11.05 kHz), PEAK/RMS followers, gate, saturation, double-precision smoother, unison, IPP-style
@@ -239,8 +286,8 @@ accordingly. Highlights of what is **confirmed and applied**:
 - 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
-  ramp at the stored value (FL's host call order not observed); Maximus features unused by the presets (RMS detector,
-  saturation B, other curve segment types, linear-phase mode) are not decoded; the editor's quality
+  ramp at the stored value (FL's host call order not observed); Maximus's Master Mid mode, its v14+ linear-phase split and curve
+  segment types other than 0/7 are not decoded (REA round 40); the editor's quality
   (0/1) is used for playback and export alike (FL renders with quality 2; LYNX's engine does not tell instruments
   when it renders offline); FL seeds its random draws from the clock, LYNX from a fixed seed (spectral-random
   phases, Noise resonance and the LFO "voice random" are deterministic and differ from any FL render by design);
@@ -248,11 +295,14 @@ accordingly. Highlights of what is **confirmed and applied**:
   answers for the release-time factor (p30) and release velocity (p46) are 1 and 0 (FL's not observed); Mod X/Y
   (Final.FCut/FRes) are 0; FL's per-channel max polyphony is not imported (LYNX's limit is its 96-record pool);
   the LFO/phaser phases follow song-position jumps but not the start of playback.
-- Ogun: the evolving spectrum is 8 snapshots per note with linear crossfades; partials binned onto one harmonic
-  share an energy-weighted decay; ALT DECAY morphs every harmonic towards its Decay EQ level (REA round 26); the
-  per-partial release (which restarts from the current level) is one overall envelope; the read-start phase offset is not reproduced; articulators
-  are at their neutral values, Seed 2 "Random" (new spectrum per note in FL) is one fixed draw, Seed 1 per key uses
-  key C5, and with richness > 9 the inharmonic partials are binned (by energy) onto harmonics of f/4.
+- Ogun (REA round 37 §1.20 and open questions): Seed 2 "Random" uses a per-instance counter starting at 0 (FL's starts
+  from its clock-seeded RTL random seed), so Random spectra are deterministic and differ from any given FL render; the
+  read start j₀ (argmin of the first table) occasionally picks a neighbouring sample vs FL (a time shift of that
+  note's table); IPP's 11-bit `exp` in the fullness shaping is evaluated exactly (up to −79 dB on the demos, −52 dB on
+  the worst synthetic case vs the DLL); global LFOs/envelopes run per voice (none in FL's data); host answers 2/6 are 0,
+  release velocity 0.5, Mod X/Y 0; parameter changes rebuild the instance (sounding notes stop); a voice pool grows on
+  demand up to 64 voices per channel (the oldest is cut beyond that); FL's per-channel max polyphony is not imported
+  (LYNX's mono setting = 1). Autogun stays on the synth approximation (its states mostly use another layout).
 - Sytrus: chaotic FM patches (two-way FM loops, strong self-feedback) cannot be sample-exact — FL builds sine tables
   with IPP's tone generator (≈1 ulp from an exact sine) and the chaos amplifies it (statistically equivalent);
   random maps use a fixed per-instance seed (FL's is clock-seeded, so they are not reproducible in FL either); the
@@ -270,13 +320,12 @@ accordingly. Highlights of what is **confirmed and applied**:
 - Pitcher: MIDI mode and Harmonize are implemented but LYNX effects receive no MIDI notes, so they behave as FL
   with nothing on the Pitcher's MIDI port (MIDI: no correction; Harmonize: dry voice / dry mix). The reported
   latency (9 / 257 samples) is the DSP's delay; FL's own PDC report is not confirmed.
-- Vocodex: the Soundgoodizer stage (SG > 0, all demo instances) is LYNX's Soundgoodizer approximation (preset A,
-  amount = SG, then the presets' −0.2 dB master limiter) on the engine's output — FL hosts its own Soundgoodizer
-  with `Data/SG.dat`, not decoded yet (on the "Vocodex demo" inputs FL's SG_x64.dll with SG.dat peaks at −0.39 dBFS
-  and sits ≈1.7 dB above the approximation, median of 100 ms windows); the
-  internal Sytrus carrier (CarIn = "---", Ookay and NewStuff) is not available, so that Vocodex passes its
-  modulator unchanged (`vocodex::makeInternalCarrier` is the hook for it); map segments with tension ≠ 0 are read
-  as straight lines (no demo uses them).
+- Vocodex: the Soundgoodizer stage (FL's engine with `Data/SG.dat`) and the internal Sytrus carrier (Ookay,
+  NewStuff) need the user's FL installation at import (otherwise the old approximation / modulator pass-through and
+  the import report says so); with the internal carrier the match is −112 dB (LYNX's Sytrus on that preset), the
+  others −136…−145 dB; map segments with tension ≠ 0 are read as straight lines (no demo uses them).
+- Maximus: 4 of the 100 demo states use the v15 linear-phase band split (Frequency Splitter's engine) or Master Mid
+  mode is set — those keep the approximation (REA round 40 §8).
 - FLEX: its packs are encrypted; LYNX never opens them (the channel gets a synth patch by preset name).
 
 ## `.flp` format findings (besides `docs/ANALISE_FL_STUDIO.md`)
@@ -319,5 +368,8 @@ Confirmed empirically on the demo projects:
 - Mouse/keyboard interactions are checked by code review and off-screen snapshots only.
 
 ## Open items
-- Ogun's per-partial release and ALT DECAY, Vocodex's internal carrier synth (needs LYNX's exact Sytrus) and its
-  Soundgoodizer stage (SG_x64.dll not decoded), Harmor's image synthesis, arpeggio envelopes and Noise resonance.
+- Autogun's engine (state layout differs from Ogun's; DLL not run), Maximus's Master Mid mode and linear-phase
+  split, Harmor's image synthesis, arpeggio envelopes and Noise resonance.
+- Workflow P2 leftovers (`docs/WORKFLOW_FL.md`): per-segment automation curve shapes, clip colour/name and track
+  colour/height (need model fields), F2/F3 search stepping, instrument drops on mixer inserts, the automation
+  record filter, and the remaining note tools (chop, quantise, articulate, flam, period slicing, LFO).

+ 81 - 50
docs/WORKFLOW_FL.md

@@ -2,7 +2,7 @@
 
 Last updated: 2026-10-14. Status: study / design input. No code was changed while it was written; the gap matrix
 and the P1 list were later updated as items landed (P1-2, 3, 9, 10, 11, 12, 13 on `feature/wf-editors`; P1-1, 4, 5, 6, 7,
-8, 14, 15 on `feature/wf-shell`).
+8, 14, 15 on `feature/wf-shell`; the P2 items and the P1 leftovers on `feature/wf-p2`, see the P2 status notes).
 
 LYNX interprets FL Studio's *workflow*: the way a producer moves between the Channel Rack, Piano Roll,
 Playlist and Mixer. It keeps its own look, names and code. This document has four parts:
@@ -300,7 +300,7 @@ Each interaction has an ID, which section 3 uses for the gap matrix.
 | A3 | Tension handle per segment (Ctrl fine, right-click resets); curve types per segment (single, double, hold, stairs, pulse, wave, smooth …) | [DOC][ac] |
 | A4 | Ctrl+drag selects points; dragging the last point stretches the clip; step mode draws freehand; slide mode keeps later points' spacing | [DOC][ac] |
 | A5 | LFO overlay on the envelope (speed, tension, skew, pulse width, level; multiply vs add) | [DOC][ac] |
-| A6 | Clip settings: min/max re-range, playback speed | [DOC][ac] |
+| A6 | Partial | Right-click on the curve: **scale the values into a range**, flip upside down, all segments straight. No playback speed |
 | A7 | Initial value stored at creation; "init song with this position" | [DOC][ac] |
 | A8 | Make unique on an automation clip; tempo automation from the tempo display (60–180 BPM default) | [DOC][ac] [DOC][tb] |
 
@@ -377,19 +377,19 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 
 | ID | LYNX | Where / note |
 |---|---|---|
-| G1 | **Done** (shell) | F5 Playlist, F6 Channel Rack, F7 Piano Roll, F9 Mixer, F8 and Alt+F8 Browser **toggle and focus** floating panels (`ui/Workspace.*`, `core/Workspace.cpp` `Layout::toggle`). F8 shows the Browser until the quick-add palette (P2) exists. Keys checked on [DOC][sc] |
+| G1 | **Done** | F5 Playlist, F6 Channel Rack, F7 Piano Roll, F9 Mixer, Alt+F8 Browser **toggle and focus** floating panels (`ui/Workspace.*`, `core/Workspace.cpp` `Layout::toggle`). **F8 opens the quick-add palette** (`ui/QuickAddPalette.*`, P2). Keys checked on [DOC][sc] |
 | G2 | No | No F12 family; Esc only deselects inside the editors |
-| G3 | **Done** (shell) | Workspace desktop: panels move by their title strip, resize by their edges, overlap, maximise (button or double-click on the title) and **detach** into a native window and back. Snapping to other panels and the edges (`workspace::snap`); Alt while dragging turns it off, as on [DOC][iface]. Plugin, settings and automation windows stay native windows |
+| G3 | **Done** (shell + P2) | Workspace desktop: panels move by their title strip, resize by their edges, overlap, maximise (button or double-click on the title) and **detach** into a native window and back. Snapping to other panels and the edges (`workspace::snap`); Alt while dragging turns it off, as on [DOC][iface]. **Detached windows snap too** (to the screen, the main window and each other; `SnapConstrainer` in `ui/Workspace.cpp`). Plugin, settings and automation windows stay native windows |
 | G4 | **Done** | View → Reset layout, Save layout as…, Load layout (`%APPDATA%\LYNX\layouts\*.txt`), Bring back off-screen panels. The current layout is saved in the user settings (`workspace.txt`), not the project |
 | G5 | **Done** | Enter maximises/restores the Playlist (key map `panel.maximisePlaylist`) |
 | G6 | **Done** (except remember-seek) | Space and the Play button: play, or stop and go back to where playback started; Ctrl+Space pauses; Stop returns to the start; **double-click Stop = all notes off** (`AudioEngine::panic`, a channel −1 choke in `RackRenderer`). Right-click Stop ("remember seek time") not done. Keys checked on [DOC][sc] and [DOC][tb] |
 | G7 | **Done** | L toggles; right-click Pattern shows the Channel Rack, right-click Song shows the Playlist ([DOC][tb]; that page is itself inconsistent, LYNX follows the per-button reading) |
 | G8 | **Done** (LYNX variant) | Tempo display (`MainComponent::TempoDisplay`): drag the whole number (1 BPM per 4 px) or the decimals (0.01 BPM/px), Ctrl finer, wheel, double-click types, Alt/middle-click resets. Right-click: type value, **tap tempo** (call-out pad, from the 2nd tap, `controls::TapTempo`), **half / double** (permanent, not FL's temporary half speed), reset, automation clip, MIDI link. No nudge |
-| G9 | Yes | Global grid combo in the main toolbar (`ui/EditorTools.h` `GlobalGridBox`, `EditorGlobals`); each editor's grid combo starts on "Follow global grid". Backspace in the Piano Roll / Playlist toggles it with "No snap". Alt bypass: Yes. Not yet used for record quantise |
+| G9 | Yes | Global grid combo in the main toolbar (`ui/EditorTools.h` `GlobalGridBox`, `EditorGlobals`); each editor's grid combo starts on "Follow global grid". Backspace in the Piano Roll / Playlist toggles it with "No snap". Alt bypass: Yes. **Record quantise follows it** (fixed fractions and bars; none/screen/nearest record as played; Options → Recording turns it off) |
 | G10 | Yes | Right-click the global grid → "Default note length" (or "Last clicked note", the default) |
-| G11 | **Done** (most) | Numpad +/− next/previous, F4 next empty pattern (then the naming dialog), F2 rename + colour dialog (F2 inside it = random palette colour), Ctrl+Shift+Ins insert before the current one, "Split by channel" in the pattern menu and the new **Patterns** menu (`core/RackOps.cpp`). Keys checked on [DOC][pat-menu] and [DOC][sc]. Not done: numpad 1–9 direct pick, Alt+C pattern clone key (Alt+C clones channels in the rack; pattern clone stays in the menu), Del, move up/down |
+| G11 | **Done** | Numpad +/− next/previous, **numpad 1–9 select patterns 1–9**, F4 next empty pattern (then the naming dialog), F2 rename + colour dialog (F2 inside it = random palette colour), Ctrl+Shift+Ins insert before the current one, **Alt+C clone** (the rack keeps Alt+C for channels while it has focus), **Shift+Ctrl+Up/Down move**, "Split by channel" in the pattern menu and the **Patterns** menu (`core/RackOps.cpp`). Keys checked on [DOC][pat-menu] and [DOC][sc]. Del is not bound (it deletes notes/clips in the editors); Delete pattern stays in the menu |
 | G12 | **Done** | Hint strip in the status bar: describes the control under the mouse (`ui::HintSource`, hint property or tooltip), shows its live value while it is dragged, and marks "can be automated" and "has a right-click menu" with LYNX icons. MIDI learn prompt kept |
-| G13 | Partial | Snapshot undo with 100 steps, one step per mouse gesture (`engine/AudioEngine.cpp:555-611`); Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z. No history list |
+| G13 | **Done** (LYNX variant) | Snapshot undo with 100 steps, one step per mouse gesture; Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z. **Undo history panel** (Ctrl+H, Edit menu; `ui/HistoryPanel.*`): steps named after what changed (`core/History.h` compares the snapshots), newest at the bottom, a click jumps there (`AudioEngine::jumpToHistory`). No undo-level or knob-tweak settings |
 | G14 | Partial | Ctrl+N new, Ctrl+O, Ctrl+S, Ctrl+Shift+S, Ctrl+R export, recent-files menu (`MainComponent.cpp:250-358, 833-957`). No save-new-version |
 | G15 | Partial | 4 built-in templates in "New from template" (`core/Templates.cpp:57`); no user templates |
 | G16 | **Done** | Ctrl+T and a toolbar toggle (off by default, so the editors' letter tools work; the manual does not state a default); saved in the user settings and passed to `EditorGlobals::typingPiano`. Every binding lives in `core/KeyMap` (remappable via `%APPDATA%\LYNX\keys.json`, Options → Edit keyboard shortcuts). While the piano is on its keys win; other plain printable keys only work for actions marked `whilePiano` (L); chords, F-keys and Space/Enter/arrows always work |
@@ -414,15 +414,15 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 | C1 | Yes | Left toggles and paints by drag, right erases (`ChannelRackComponent.cpp:315-328, 391-412`) |
 | C2 | Yes (own) | Drag-paint/erase is a LYNX design choice (FL: not documented) |
 | C3 | No | — |
-| C4 | No | No graph editor and no per-step velocity/pitch in the rack |
+| C4 | **Done** (LYNX lanes) | Graph lane under the selected channel (Ctrl+K, channel menu → Steps): velocity, pan, release, fine pitch, Mod X, Mod Y; drag sets, right-drag draws a ramp, Alt+click resets; it writes the same note fields as the Piano Roll (`core/NoteTools.h` levels). No "note" or "shift" lanes, no Ctrl scaling |
 | C5 | **Done** | Click opens/closes the channel's editor (plugin window or settings), closing the previous one unless Alt is held or Options → Keep channel editors open is on; Ctrl+click auditions; Shift+wheel on the name/selector moves the channel; double-click opens the Piano Roll. Built-in drums and audio clips have no editor (the click only selects). Checked on [DOC][cr] |
-| C6 | Partial | Menu has piano roll, instrument replace, rename **and colour dialog** (F2-style random colour), colour, clear notes, arpeggiator, sampler slicing, **clone, insert channel here, move up/down, send to free inserts, delete selected**, and "Channel settings…" for the model channels. Missing: fill every N, rotate, advanced/Euclidean fill, copy/paste note data (P2) |
-| C7 | **Done** (LYNX gestures) | Selector column: click selects, Ctrl+click or right-click toggles, Shift+click range, double-click all; Up/Down, Shift+Up/Down; **Alt+Up/Down moves**. The selection drives live MIDI (up to 16 extra channels) and the PC keyboard. No sort or select-unused |
+| C6 | **Done** (most) | Menu has piano roll, instrument replace, rename **and colour dialog**, colour, clear notes, arpeggiator, sampler slicing, clone, insert channel here, move up/down, send to free inserts, delete selected, "Channel settings…", and **Steps → fill every 2/4/8, Euclidean fill… (pulses / length / rotation with a ring preview), rotate left/right, graph lanes**. Missing: copy/paste note data, burn MIDI |
+| C7 | **Done** (LYNX gestures) | Selector column: click selects, Ctrl+click or right-click toggles, Shift+click range, double-click all; Up/Down, Shift+Up/Down; **Alt+Up/Down moves**. The selection drives live MIDI (up to 16 extra channels) and the PC keyboard. **Sort channels by name / colour / insert / type and Select unused channels** in the channel menu (`channelSortOrder`, `unusedChannels`) |
 | C8 | Partial | Left mute; right-click or Ctrl+click solo (`:267-283`). No lock |
 | C9 | **Done** | 1..0 mute, Ctrl+1..0 solo channels 1–10 while the rack has focus and the typing piano is off |
 | C10 | **Done** (most) | Ctrl+L (and menus) send the selection to free inserts, naming and colouring each insert after its channel (`sendChannelsToFreeInserts`). Route box follows the control contract. No Alt+M toggle |
 | C11 | No | No step-data clipboard in the rack |
-| C12 | No | — |
+| C12 | Partial | Ctrl+Shift+Left/Right in the rack **rotates the selected channels' steps** by one step (wrapping in the pattern); the Piano Roll's Ctrl+Shift+arrows rotate within the bar |
 | C13 | No | — |
 | C14 | Partial | Global swing knob in the toolbar (`MainComponent.cpp:121-128`); per-channel swing mix exists in the model and is imported, but there is no UI for it |
 | C15 | Partial | Length via the pattern menu (Automatic, 1–32 bars); the grid follows the length (`ChannelRackComponent.cpp:89-99`). No corner drag |
@@ -449,8 +449,8 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 | R11 | Partial | Follow global / none / Screen grid (zoom-dependent) / Nearest note (edges of notes and visible ghosts) / step and beat fractions / bar. No Line-vs-Cell distinction, no markers |
 | R12 | Partial | Ghost notes of the pattern's other channels, toggle button and Alt+V; double right-click a ghost switches to its channel. No hollow ghosts from overlapping Playlist clips (needs "opened from clip" context), no editable ghosts |
 | R13 | Yes | Channel selector in the roll's toolbar (● = has notes in this pattern); wheel steps through channels with notes, Ctrl+wheel through all; G/K previous/next channel and H/J previous/next with notes (typing piano off) |
-| R14 | Partial | Scale highlight combo (12 roots × 8 scales, `:57-71`), shading only; no snap-to-scale |
-| R15 | Partial | Chord stamp combo of 11 shapes (`:47-55`); no "only one" or inversion modes |
+| R14 | **Done** | Scale highlight combo (12 roots × 8 scales, list in `core/NoteTools`); **… menu → Snap notes to the scale**: drawn, painted and moved notes and the chord stamp land on the scale, and so do incoming MIDI and PC-keyboard notes (`AudioEngine::setInputScale`); "Move the notes onto the scale" fixes existing notes |
+| R15 | Partial | Chord stamp combo of 11 shapes; follows scale snap. No "only one" or inversion modes |
 | R16 | No | — |
 | R17 | Partial | Slide toggle in the toolbar; Ctrl+P toggles porta on the selection |
 | R18 | Partial | Ctrl+X/C/V (paste in place, not at the view's left), Ctrl+B, Del, arrows: Up/Down ±1 (Shift = octave), Left/Right by grid (Shift = bar), Ctrl+Shift+Left/Right rotate within the bar. Different key mapping from FL for transposition |
@@ -458,8 +458,8 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 | R20 | No | — |
 | R21 | Partial | Ctrl+M toggles mute on the selection; no note grouping |
 | R22 | Yes | One undo step each, on the selection or all notes (`core/NoteEdit.cpp`): Ctrl+U chop to grid, Ctrl+G join touching notes, Ctrl+L legato, Shift+D shrink to grid, Shift+Q quantise starts, Ctrl+Q (and Ctrl+Alt+Q) quantise starts and lengths; also in the roll's … menu |
-| R23 | No | None of the tool dialogs (the arpeggiator exists as a *live channel effect*, not a note tool) |
-| R24 | Partial | Wheel / Shift+wheel scroll, Ctrl+wheel horizontal zoom (`:981-997`). No vertical zoom, presets, middle-drag pan |
+| R23 | Partial (first set) | **Arpeggiate (Alt+A), Strum (Alt+S), Flip (Alt+Y), Randomise (Alt+R), Scale levels (Alt+X), Limit (Alt+K)** in `ui/NoteToolDialogs.*` (maths in `core/NoteTools.cpp`, unit-tested): live preview on the pattern, Accept = one undo step, Cancel/close restores. Not done: chop, quantise, articulate, flam, period slicing, LFO, melody/chord generators (dialogs) |
+| R24 | **Done** (most) | Wheel / Shift+wheel scroll, Ctrl+wheel horizontal zoom, **Ctrl+Alt+wheel vertical zoom, PageUp/PageDown, Shift+1/2/3 (1, 4, 16 bars), Shift+4 all, Shift+5 selection, Shift+0 centre on the playhead, middle-drag pans**. No middle-drag zoom on the keyboard |
 | R25 | Yes | Keyboard click auditions; clicking/moving a note also auditions (a LYNX choice, R26) |
 | R27 | No | Markers exist only on the Playlist ruler |
 | R28 | Yes | MIDI menu import/export (`:1163-1209`) |
@@ -469,23 +469,23 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 
 | ID | LYNX | Where / note |
 |---|---|---|
-| P1 | Yes | Tool strip with Pencil, Brush, Eraser, Mute (clip-level `Clip::muted`), Knife, Lasso, Zoom, Listen (plays from the click while held), Slip (`ui/PlaylistComponent.cpp`); keys P/B/D/T/C/E/Z/Y/S while the typing piano is off. No ripple tool |
-| P2 | Partial | Right-click deletes in every tool (right-drag many, hold on empty = Knife), Ctrl selects, Shift copies, Alt no snap. Right-click on the name strip still opens the clip menu. No double-right-click mute, no middle-drag pan |
+| P1 | Yes | Tool strip with Pencil, Brush, Eraser, Mute, Knife, Lasso, Zoom, Listen, Slip; keys P/B/D/T/C/E/Z/Y/S while the typing piano is off. **Ripple is a mode** (Shift+S, ruler menu), not a tool: resizing a clip's end moves the later clips on its track, Delete closes the gaps |
+| P2 | **Done** | Right-click deletes in every tool (right-drag many, hold on empty = Knife), **double right-click mutes the clip** (the first click's delete is undone), **middle-drag pans**, Ctrl selects, Shift copies, Alt no snap. Right-click on the name strip still opens the clip menu |
 | P3 | Partial | Picker panel selects the source; click on empty space places it (`:844-882, 1604-1739`). No source menu, no hover preview |
 | P4 | Partial | Picker lists patterns / audio / automation (`:1604-1739`); no right-click actions |
-| P5 | Partial | Fade handles fixed (`mouseDown` checks `fadeHandleAt` before move/resize). Left-edge trim moves start and offset together (content stays); Shift on an edge trims too (instead of copying); Slip tool or Alt+Shift+drag inside a clip slips the content. No ripple edit, no stretch |
+| P5 | Partial | Fade handles fixed. Left-edge trim moves start and offset together; Shift on an edge trims; Slip tool or Alt+Shift+drag slips the content. **Ripple resize** (ripple mode). No stretch |
 | P6 | Partial | Drag, group move, Shift+drag copy, Ctrl+box. No Shift+arrow moves |
 | P7 | No | — |
-| P8 | Partial | Split, make unique, select all of this pattern, open in rack, delete (`:1115-1277`). Missing: per-clip mute, colour, rename, chop |
+| P8 | Partial | Split, **mute/unmute, chop to grid**, make unique, select all of this pattern, open in rack, **open in Piano Roll**, delete. Missing: per-clip colour and name (no model field yet) |
 | P9 | Partial | Clip volume, normalise, remove fades. No clip automation, crossfades, reverse |
-| P10 | Partial | Double-click a pattern clip switches to the **Channel Rack** tab; automation clips open their editor (`:1436-1450`). No "edit in" preference |
-| P11 | Partial | LED mute, right-click rename (`:718-731`). Missing: menu, colour, height, solo, insert/delete/move, group |
-| P12 | Partial | Track mute only |
-| P13 | Partial | Click/drag on the ruler seeks; Ctrl+drag makes the time selection (= the loop), which selects the clips it touches; double-click or Ctrl+click clears it. No Shift+drag move/copy of the selection, no "outside the selection" tint on clips |
+| P10 | **Done** | Double-click a pattern clip opens the **Piano Roll when the pattern has piano-roll notes, else the Channel Rack** (`hasPianoRollNotes`); Options → "Double-click on a pattern clip opens" sets it; **Alt+double-click opens the other one**; automation clips open their editor |
+| P11 | Partial | LED mutes; **right-click menu: rename, mute, solo, insert above/below, move up/down, delete** (`noteedit::insertTrack/removeTrack/swapTracks/soloTrack`). Missing: colour, height, grouping |
+| P12 | Partial | Track mute; solo through the track menu (mutes the others) |
+| P13 | **Done** | Click/drag on the ruler seeks; Ctrl+drag makes the time selection (= the loop), which selects the clips it touches; double-click or Ctrl+click clears it. **Shift+drag inside it moves the selection with its contents, Ctrl+Shift+drag copies** (clips are cut at its edges; `noteedit::moveTimeRange`). No "outside the selection" tint |
 | P14 | Partial | Ctrl+Ins inserts and Ctrl+Del removes the time selection's length across all tracks (clips cut at the edges, markers move) (`core/NoteEdit.cpp` `insertTime`/`deleteTime`). No slice-and-insert, no Insert-key slice |
 | P15 | Yes | Ctrl+B with a time selection repeats it after itself (selected clips starting inside it, or all that do) and moves the selection on; without one, duplicates by the span rounded to bars |
 | P16 | Partial | Ruler menu: add/rename/remove marker, time-signature change, remove loop (`:1049-1089`). No marker actions, no jumps |
-| P17 | Partial | Ctrl+wheel zoom; no presets, no vertical zoom, no zoom to selection |
+| P17 | **Done** (most) | Ctrl+wheel zoom, **PageUp/PageDown, Shift+1/2/3, Shift+4 all, Shift+5 selection (or the time selection), Shift+0 centre**, also in the ruler menu. No vertical zoom |
 | P18 | No | — |
 | P19 | No | — |
 | P20 | Yes | Arrangement combo: new, clone, rename, remove (`:54-135`); no merge |
@@ -499,8 +499,8 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 | ID | LYNX | Where / note |
 |---|---|---|
 | A1 | Partial | Right-click any knob → clip + editor. With a time selection the clip spans it; otherwise the whole song. Goes on a new bottom track (not "highest empty track in view") |
-| A2 | Partial | Separate editor window: click adds, drag moves, right-click deletes (`AutomationUi.cpp:36-348`). No axis locks, no type-in |
-| A3 | Partial | Alt+drag on a segment sets tension; no curve-type menu |
+| A2 | **Done** (most) | Editor window: click adds, drag moves, **Shift / Ctrl pressed after the click lock time / value**, **right-click point menu: type value, copy/paste value, straight segment, delete**; Shift+right-click adds a point on the curve. **Inline in the Playlist** (Pencil/Brush): drag a point, click on the curve to add one, right-click a point deletes it |
+| A3 | Partial | Alt+drag on a segment sets tension; "straight segment" in the point menu. No curve-type menu (needs a per-segment shape in the model) |
 | A4–A6 | No | — |
 | A7 | No | — |
 | A8 | Partial | Make unique and tempo automation exist |
@@ -509,16 +509,16 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 
 | ID | LYNX | Where / note |
 |---|---|---|
-| M1 | Partial | Single selection by clicking a strip (`ui/MixerComponent.cpp:351-358`) |
-| M2 | No | — |
-| M3 | Partial | Send arrow buttons on other strips when one is selected; drag right after enabling sets the level (`:264-286, 335-349, 420-426`). Sidechain is configured on the compressor slot ("Sidechain from"), not on the route |
-| M4 | Partial | "Send only to this track", "Send only to Master again" (`:564-641`) |
-| M5 | Partial | "Route channel X here" (for one channel) in the strip menu; no shortcut, no selection |
-| M6 | Partial | Mute LED; an "S" button toggles solo (not exclusive); solo along the path exists (STATUS.md). No right-click solo |
+| M1 | **Done** | Click selects; **Ctrl+click / Shift+click on a strip's header add / select a range**; selected faders and pans move together (offsets kept) |
+| M2 | **Done** | **Alt+Left/Right and Shift+wheel move the selected inserts**; channels, sends, sidechains and automations follow (`mixerops::moveTracks`). Strip menu: move left/right |
+| M3 | **Done** | Send arrow on other strips when one is selected; drag after enabling sets the level; **right-click the arrow: send here / send only here / sidechain only** (a level-0 send, the compressors and vocoders there listen to the source; `mixerops::sidechainTo`) |
+| M4 | **Done** (most) | Strip menu: **route the selected inserts here / only here**, send only to this track, send only to Master again. No submix |
+| M5 | **Done** | **Ctrl+L links the selected channels to the selected insert, Ctrl+Shift+L to consecutive inserts from it, Alt+L selects the channels linked to it** (Mixer focused; also in the strip menu). Keys checked on [DOC][sc] |
+| M6 | **Done** | Mute LED: left-click mutes, **right-click or Ctrl+click solos exclusively** (again: unsolo); the "S" button still toggles; solo along the path. No Ctrl+right-click unmute-all |
 | M7 | Partial | Rename in the menu; colour only shown if imported (`:150-154`) |
-| M8 | Partial | 10 slots, click empty → add menu, bypass LED, dry/wet, menu with replace / presets / sidechain / move up/down / delete (`:999-1288`). No wheel/drag reorder, no A/B |
-| M9 | No | — |
-| M10 | No | Audio arm is global (Rec "v" menu), not per insert |
+| M8 | **Done** (most) | 10 slots, click empty → add menu, bypass LED, dry/wet, menu with replace / presets / sidechain / move / delete; **drag a slot or wheel over its name to reorder it** (`mixerops::moveEffectSlot`); **A/B compare** (store as B, swap with B) in the slot menu; effect presets dropped from the Browser load into a slot |
+| M9 | **Done** | "FX" switch in the effects panel header: click turns all effects of the insert on/off, **right-click opens or closes their plugin windows** |
+| M10 | **Done** (LYNX variant) | **Record-arm dot on every insert**: arming turns audio recording on and the take plays through the armed insert (`AudioEngine::setInsertArmed`); not saved with the project. No per-insert input selector |
 | M11 | No | — |
 | M12 | Partial | Track EQ callout with 9 sliders (`:475-562`) |
 | M13 | No | — |
@@ -530,14 +530,14 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 | ID | LYNX | Where / note |
 |---|---|---|
 | B1 | Partial | Selecting an audio file previews it (`ui/BrowserComponent.cpp:136-142`) |
-| B2 | No | — |
-| B3 | Partial | Double-click makes a *new* channel (`:144-193`) |
-| B4 | Partial | Rack and Playlist accept drops (`ChannelRackComponent.cpp:688-713`, `PlaylistComponent.cpp:1461-1504`); dropping onto a rack row replaces that channel's sample. No mixer targets |
-| B6 | No | — |
+| B2 | **Done** | Browser focused: Up/Down step and preview; **Shift+Up/Down step and load each file into the selected channel** (sampler or built-in drum); also through the search results |
+| B3 | **Done** | **Enter loads the selected file into the selected channel** (or opens it like a double-click when the channel can't take it); double-click still makes a new channel |
+| B4 | Partial | Rack and Playlist accept drops (tree and search results); dropping onto a rack row replaces that channel's sample; **effect presets (.fst) drop on the effects panel**. No instrument-on-insert drop |
+| B6 | **Done** | **Search box (Ctrl+F)** under the folder list: searches the current folder and below in the background (up to 500 results), words AND-ed, OR, NOT / -word, "exact phrase", * and ? wildcards (`core/SearchQuery`); Esc clears. No F2/F3 stepping |
 | B7 | Partial | Root-folder combo (`BrowserComponent.cpp:80-91`); no tabs, user folders, tags or favourites |
 | B8 | No | — |
-| B9 | No | Plugins are added through nested menus |
-| B10 | Partial | Fixed left panel |
+| B9 | **Done** | **Quick-add palette (F8)**: instruments (built-in and scanned plugins) and effects side by side, filtered as you type, Enter/double-click adds an instrument as a new channel or an effect into the selected insert; opened from the Mixer it starts on the effects |
+| B10 | Partial | Fixed left panel (detachable as a workspace panel); **user folders through "Add folder…" in the folder list** (kept in `browser-folders.txt`). No back/forward |
 
 **Plugin windows**
 
@@ -552,10 +552,10 @@ gesture or reduced scope · **No** = absent (searched, not found). Locations are
 
 | ID | LYNX | Where / note |
 |---|---|---|
-| X1 | Partial | Rec button + "v" menu (notes always, audio arm) (`MainComponent.cpp:72-90`) |
-| X2 | Partial | Metronome; no count-in, wait-for-input, overdub/replace choice or loop record |
-| X3 | Partial | Notes go into the current pattern, one undo step per take (`engine/AudioEngine.cpp:487-543`); no Song-mode clip placement |
-| X4 | No | No input quantise |
+| X1 | Partial | Rec button + "v" menu (notes always, audio arm, **Recording options**); R toggles recording. No automation filter |
+| X2 | **Done** | Metronome (Ctrl+M), **count-in of 1/2/4 bars (Ctrl+P toggles one bar)**, **wait for the first note (Ctrl+I)**, **overdub vs replace**. Keys checked on [DOC][sc]. No loop-record option |
+| X3 | **Done** | Notes go into the current pattern, one undo step per take; **in Song mode the take places a pattern clip where recording started** if none plays there |
+| X4 | **Done** | Recorded notes are quantised to the global grid (option on by default) |
 | X5 | No | — |
 | X6 | Partial | Input → 24-bit WAV → new audio channel + clip on a new track (`AudioEngine.cpp:286-405`); not tested by a human (STATUS.md) |
 | X7, X8, X9 | No | — |
@@ -569,9 +569,10 @@ may keep it. All key bindings should live in one remappable table (see P1-14).
 #### P1: the core feel of the workflow
 
 Status: items 1, 4, 5, 6, 7, 8, 14 and 15 were built on `feature/wf-shell`; items 2, 3, 9–13 on `feature/wf-editors` (merged into
-`feature/wf-shell`). Remaining gaps inside the shell items: panel snapping does not apply to detached windows; F8 shows the
-Browser until the quick-add palette exists; no right-click on Stop (remember seek time), tempo nudge or temporary
-half speed; no numpad 1–9 pattern pick or pattern move up/down; no channel zip/unzip, sort or select-unused.
+`feature/wf-shell`). Remaining gaps inside the shell items: no right-click on Stop (remember seek time), tempo nudge or
+temporary half speed; no channel zip/unzip. Closed on `feature/wf-p2`: detached windows snap, F8 opens the quick-add
+palette, numpad 1–9 picks patterns, patterns move up/down (Shift+Ctrl+Up/Down) and clone (Alt+C), channels sort and
+select-unused, ripple editing and Shift+drag time-selection move/copy.
 
 1. **Workspace desktop (G1, G3, G4, G5, G17).** Replace the tab bar with a *workspace*: Playlist, Channel
    Rack, Piano Roll, Mixer and Browser become movable, resizable, overlapping panels inside the main window.
@@ -667,48 +668,76 @@ half speed; no numpad 1–9 pattern pick or pattern move up/down; no channel zip
 
 #### P2: deepens the workflow
 
+Status (`feature/wf-p2`, merged with the FL-style layout of section 5): every item below landed except where its
+note says otherwise. Each window's own P2 items are also in the menu at the left of its title bar
+(`MainComponent::addPanelMenuItems`). Testable logic is in
+`core/NoteTools`, `core/MixerOps`, `core/History`, `core/SearchQuery`, `core/RackOps`, `core/NoteEdit` and
+`core/Recorder` (tests in `tests/WorkflowP2Tests.inc`); new keys are in `core/KeyMap`. Deferred: per-segment curve
+shapes for automation (needs a model field), clip colour/name (model fields), track colour/height/groups, F2/F3
+search stepping, instrument drops on mixer inserts, record filters for automation, and the remaining tool dialogs
+(chop, quantise, articulate, flam, period slicing, LFO).
+
 - **Step graph lanes (C4).** A collapsible lane under the rack row for per-step velocity, pan and fine pitch.
   Drag sets a value, right-drag draws a ramp, Alt+click resets. It writes the same note fields the Piano Roll uses.
+  - **Status:** Done (Ctrl+K; velocity, pan, release, fine pitch, Mod X/Y).
 - **Step fill and rotate (C6, C20).** Channel menu → *Fill every 2/4/8*, *Euclidean fill…* (pulses / length /
   rotation, with a preview), *Rotate left/right*.
+  - **Status:** Done (channel menu → Steps; rotate also on Ctrl+Shift+Left/Right in the rack).
 - **Mixer selection and routing gestures (M1, M2, M3, M4, M5, M6).**
   - Multi-select inserts; selected faders move together; Alt+Left/Right reorder.
   - Right-click the send button → "Sidechain only" (a level-0 route that LYNX's compressor already treats as a
     sidechain).
   - Menu: *Route selected here / here only*, *Link selected channels here* (Ctrl+L in the Mixer).
   - Mute = left-click, solo = right-click or Ctrl+click on the same LED, matching the rack.
+  - **Status:** Done (Ctrl/Shift+click on headers; Ctrl+L / Ctrl+Shift+L / Alt+L; right-click a send arrow for
+    "sidechain only").
 - **Effect slot handling (M8, M9).** Drag a slot to reorder it, or wheel over it; a per-insert "all effects
   on/off" switch; right-click that switch to open or close all effect windows; an A/B compare buffer per slot.
+  - **Status:** Done (the A/B buffer lives for the session).
 - **Browser search and audition-swap (B2, B3, B6, B10).**
   - Ctrl+F opens a filter box (wildcards, AND/NOT).
   - Up/Down auditions the files in turn. Shift+Up/Down swaps each one into the selected sampler channel; Enter
     loads it there.
   - Drop targets on mixer inserts and slots (effects, plugin presets).
   - User folders.
+  - **Status:** Done, except instrument drops on inserts (effect presets drop on the effects panel). Plain Up/Down
+    preview, Shift+Up/Down load into the selected channel (checked on [DOC][br]).
 - **Quick-add palette (B9).** A searchable plugin list (F8 in LYNX) with instruments and effects. Double-click
   adds it to a new channel or to the selected insert, depending on which panel is focused.
+  - **Status:** Done (F8 and the toolbar's plugin-picker icon; the Browser moved to Alt+F8).
 - **History panel (G13).** A list of undo steps with names (the action labels already passed to `editSong`).
   Clicking a step jumps there. Keep conventional undo (Ctrl+Z back, Ctrl+Y/Ctrl+Shift+Z forward). FL's
   toggle-style undo is deliberately *not* copied.
+  - **Status:** Done (Ctrl+H, Edit → Undo history).
 - **Recording set (X1, X2, X3, X4, X9).**
   - A record menu with filters (notes, audio, automation).
   - Count-in bars, "start on first note" (wait-for-input), *Overdub vs Replace*.
   - Input quantise follows the global grid.
   - In Song mode a take places a pattern clip at the start point.
+  - **Status:** Done except the automation filter: count-in (Ctrl+P), wait for input (Ctrl+I), overdub/replace,
+    quantise and song clips in Options → Recording and the toolbar's "what to record" menu; count-in and
+    wait-for-input also have switches next to the metronome; R toggles recording.
 - **Automation clip editing (A2, A3, A4, A6).** Edit inline in the Playlist as well as in the window. Axis locks
   (Shift/Ctrl), right-click a point to type a value, a curve-shape menu per segment (single, double, hold,
   stairs, pulse, wave, smooth), min/max re-range.
+  - **Status:** Done except the curve-shape menu (only "straight segment" for now).
 - **Note tool dialogs, first set (R23).** *Strum*, *Arpeggiate (offline)*, *Flip*, *Randomise*, *Scale
   velocities*, *Fit to range*. Each is a small modal dialog with a live preview, Apply/Revert, and one undo step.
+  - **Status:** Done as Arpeggiate, Strum, Flip, Randomise, Scale levels and Limit (non-modal windows, Accept /
+    Reset / Cancel; keys Alt+A/S/Y/R/X/K checked on [DOC][sc]).
 - **Clip menu completion (P8, P9, P11, P12).**
   - Clips: mute, colour, rename, chop to grid.
   - Tracks: colour, height, solo, insert/delete/move, and a track header menu.
   - Double-click a pattern clip opens the Piano Roll when the pattern has piano-roll notes, else the rack. A
     preference sets this.
+  - **Status:** Done except clip colour/rename and track colour/height (no model fields yet).
 - **Scale snap (R14).** "Snap to scale" when drawing or moving notes, and for incoming MIDI.
+  - **Status:** Done (switch next to the Piano Roll's scale box, also in its window menu and … menu).
 - **Zoom presets (R24, P17).** PgUp/PgDn, zoom to selection, show all, vertical zoom (Ctrl+Alt+wheel), and
   middle-drag pan.
+  - **Status:** Done in both editors (vertical zoom in the Piano Roll only).
 - **Per-insert record arm (M10).**
+  - **Status:** Done (record dot on each insert).
 
 #### P3: later or optional
 
@@ -788,9 +817,11 @@ colours, icons and fonts stay LYNX's own (dark theme, red accent, `ui/Icons.cpp`
 **LYNX** (`ui/MainComponent.cpp`, `resized()`): one band, two rows high, panels left to right:
 1. the menu, with the **hint bar under it** (the bottom status strip is gone);
 2. the transport: a two-line Pattern/Song switch, play, stop, record, tempo and the song position;
-3. the recording options: metronome, typing keyboard as piano, and "what to record";
+3. the recording options: metronome, count-in and wait-for-input over "what to record" and the typing keyboard
+   as piano;
 4. global snap, with the pattern selector under it;
-5. shortcuts: the windows (Playlist, Channel Rack, Piano Roll, Mixer, Browser, plugin picker), with the file
+5. shortcuts: the windows (Playlist, Channel Rack, Piano Roll, Mixer, Browser, plugin picker = the quick-add
+   palette, F8), with the file
    actions under them (new, open, save, export, undo, redo);
 6. the output scope with the CPU load under it, on the right.
 

+ 9 - 0
docs/analise/REA_rodada37.md

@@ -618,6 +618,15 @@ overrides used only by the verification.)
    only after the C++ port matches `ogmodel.py` on the 20 demo channels (states as saved, 44.1 and 48 kHz) to about
    −60 dB with the model's own j₀ and Seed-2 counter fed in.
 
+**Port status (LYNX, `core/Ogun.cpp`, `InstrumentKind::ogun`).** Done: the C++ engine against `ogmodel.py` with the
+same events (`tools/ogunrender` drives it like `Plugin.run`) is bit-identical or within −125 dB (float rounding) on
+the 20 demo channels as saved (every effect on; at the state's quality and at quality 4; 44.1 and 48 kHz) and on the
+55 synthetic cases of `bat_synth.py` plus quality 2/3, chorus-only and 96 kHz variants; worst −125.0 dB (Padsaw at
+quality 4). The core tests keep this as model fingerprints (energy per side + samples): `ogun_demo_channels` (40 demo
+renders) and `ogun_engine` (17 feature variants of a state written from scratch, plus sample goldens at its quality 0
+and at quality 4). The FLP import plays every readable Ogun state (23/23 in the corpus) on it; Autogun stays on the
+spectral-oscillator conversion.
+
 ---
 
 ## Evidence index

+ 213 - 0
docs/analise/REA_rodada40.md

@@ -0,0 +1,213 @@
+# Behavioural analysis of FL Studio 2026: round 40 (REA) — Maximus, Soundgoodizer, Vocodex's SG stage and internal carrier
+
+> **Nature of this document.** Continuation of `REA_rodada8.md` §1–2 (Maximus / Soundgoodizer state format),
+> `REA_rodada36.md` §2 (the Maximus engine as hosted by `Shared/SG_x64.dll`, only what Harmless's presets use),
+> `REA_rodada38.md` §6 (the RMS detector) and `REA_rodada35.md` §7–8 (Vocodex's Soundgoodizer stage and internal Sytrus
+> carrier, both left undecoded). *Clean-room* reverse engineering, behavioural only. No Image-Line (nor Intel IPP) code
+> or pseudocode was copied: what is here are data layouts, formulas and behaviours described in our own words.
+> Addresses (`FUN_xxxxxxxx`), offsets and globals serve only to trace the evidence. No FLEX pack was opened; no
+> Image-Line preset or audio data was copied into the repository (Soundgoodizer's `a…d.dat`, Vocodex's `SG.dat` and the
+> Vocodex synth presets are read at import time from the user's own installation).
+>
+> **Rule for this round: no speculation.** Every value comes from decompilation (**[DECOMP]**), from the data
+> (**[DATA]**) or from running the installation's own DLLs, unmodified (**[EXEC]**). Inferences are marked as such.
+
+| Marker | Meaning |
+|---|---|
+| **[DECOMP]** | read in the decompiled/disassembled code |
+| **[DATA]** | checked in `.flp`/`.fst`/installation files, or a value read from a DLL's data section |
+| **[EXEC]** | result obtained by running the installation's own DLL (without modifying it) |
+
+- **Date:** 2026-10-14. Scratch directory (paths below are relative to it): `/home/kauan/.claude/jobs/f8789b49/tmp/`
+  (the work of this round lives under `r38/mx/`).
+- **Targets:**
+
+  | File | SHA-256 | Role |
+  |---|---|---|
+  | `Plugins/Fruity/Effects/Maximus/Maximus_x64.dll` | `acc7affbe4d070ce8b71c13de79f267dd1b257f4207a61a733388a6aec1abdc1` | the mixer Maximus |
+  | `Shared/SG_x64.dll` | `ad567e65e2aac8314d23f2322f4d17e1b5529a09f64c43d596189582f006f6ac` (= rounds 35/36/38) | the shared engine build (Harmless/Harmor rack, Vocodex's SG stage) |
+  | `Plugins/Fruity/Effects/Soundgoodizer/Soundgoodizer_x64.dll` | `fe3f0c135b1fda9ec3dd933d28300c9d98fd7ba7020c00ca8c6b271465692ac2` | Soundgoodizer: its own, older copy of the engine |
+  | `Plugins/Fruity/Effects/Soundgoodizer/Data/Presets/a…d.dat` | `75dd159f…7efb`, `615e9600…9809`, `b86a8043…2605`, `36fb4bcc…3335` | the four presets A–D (Maximus states, version 4, 1333 bytes) |
+  | `Plugins/Fruity/Effects/Vocodex/Data/SG.dat` | `f67dd6a1472bdca169208b9ee8dc7a77d6315faac3e59809f83244b55d89ee53` (= round 35) | Vocodex's Soundgoodizer state (Maximus state, version 7, 1342 bytes) |
+  | `Plugins/Fruity/Effects/Vocodex/Synthesizer/Sytrus_x64.dll` | `46ea9f910dcc315b0bb8dd3b67dfc8562ff427fc4d291cc5c5c2de07e6f922eb` (= round 35) | Vocodex's internal carrier synth (EXEC only) |
+
+- **EXEC harness:** `r38/mx/run/mx.c` → `mx_<n>.exe` (zig cc, x86_64-windows-gnu), round 35's Vocodex harness extended
+  so it hosts any of the four DLLs above: it answers the plugin's data-file requests (dispatcher `0x47` → method 6,
+  requests `0x3fb` relative to `Plugins\Fruity\Effects\` and `0x3fc` relative to the plugin folder), the plugin folder
+  (`0x1d`), and — new in this round — **the host's file enumeration (method 2, request `0x3fb`)**, so that Vocodex's
+  tone list is filled and its internal Sytrus is created (round 35 could not get past an empty list). Same safety
+  measures as before (unmodified DLLs, `SetErrorMode`, fault handler, `TerminateProcess`, `timeout`).
+- **Drivers (our own code):** `r38/mx/py/mx.py` (runs the harness; test signals `music`, `saw`, `burst`, `loud`,
+  `quiet`; error measure), `survey.py` (extracts every Maximus / Soundgoodizer mixer state from the demo projects into
+  `r38/mx/data/demo/`, 100 Maximus + 95 Soundgoodizer slots), `t_same.py` (Maximus_x64.dll vs SG_x64.dll on the same
+  states), `t_lynx.py` (LYNX's engine vs Maximus_x64.dll), `t_sgz2.py` (LYNX vs Soundgoodizer_x64.dll, 4 presets × 4
+  amounts), `sgzc.py` (a byte-identical copy of Soundgoodizer_x64.dll in a folder of our own, with our own states as
+  its preset files), `t_vcxsg.py` (Vocodex's SG stage ≡ SG_x64.dll with SG.dat), `t_vcx.py` (LYNX's Vocodex effect vs
+  Vocodex_x64.dll); C++ drivers `r38/mx/cpp/mxcmp.cpp` (LYNX's engine on a float file), `vcxcmp.cpp` (LYNX's Vocodex
+  with the installation data appended as at import), `bench.cpp` (cost), `teststates.cpp` (the states of
+  `tests/tests.cpp`).
+
+Error measure everywhere: `20·log₁₀(‖LYNX − DLL‖ / ‖DLL‖)` over both channels, 44.1 kHz, blocks of 512 unless stated;
+"−∞" = bit-identical.
+
+---
+
+## 1. Which build runs which plugin **[DATA + EXEC]**
+
+- **Maximus (mixer)** saves its full state (plugin record `0xD5`); in the demo projects the versions are 10 (33
+  slots), 14 (9) and 15 (58). Maximus_x64.dll and the shared `SG_x64.dll` loaded with the same state give the same
+  output (`t_same.py`), so LYNX treats them as one build ("shared").
+- **Soundgoodizer** saves only 12 bytes: version (3), preset index 0…3 (A…D) and Amount 0…1000. At load it reads
+  `Data\Presets\<a…d>.dat` — a Maximus state, version 4 — and sends Amount as **parameter 5** (band mix, round 36
+  §2.1) **[DECOMP + EXEC]**. Demo usage: A 74, B 10, C 9, D 2 slots. Its engine is an **older copy** of the Maximus
+  code compiled into `Soundgoodizer_x64.dll`; §3 lists where it differs.
+- **Vocodex's SG stage** is `SG_x64.dll` (shared build) loaded with `Vocodex\Data\SG.dat`, its parameter 5 = Vocodex's
+  SG knob (§4).
+
+---
+
+## 2. Shared engine: what this round added to round 36
+
+Round 36 §2.9 left out everything Harmless's four presets do not use. The demo projects use more of it.
+
+### 2.1 RMS detector (band parameter 12 ≠ 0) **[DECOMP + EXEC]**
+
+Instead of the peak window: per sample `L² + R²`, summed over the last W samples (same W as the peak window) in an
+extended-precision running sum that is carried between blocks as a double; the sum is scaled by `1/(2W)`, clamped
+below at 0 and square-rooted (IPP threshold + sqrt, float). The release/attack stages that follow are unchanged.
+
+### 2.2 Saturation mode B (band parameter 11 > 0) **[DECOMP + EXEC]**
+
+With ceiling `c = L7(p12)` and threshold `t = (1 − thr/1000)·c` (float), range `r = c − t` (a tiny positive value
+when r ≤ 0): samples with `|x| ≤ t` pass; above it `|y| = t + r·(1 − e^{(t − |x|)/r})`, sign of x kept (computed in
+extended precision, rounded to float). The output approaches c smoothly. Mode A (thr < 0) is round 36 §2.6.
+
+### 2.3 Older state layouts (versions 3…6) **[DECOMP]**
+
+The loader copies a fixed block of the state raw into the plugin object; its length depends on the version: 0x1FA
+bytes for v ≥ 7, 0x1F9 (v6), 0x1F5 (v5), 0x1F1 (v4), 0x1EE (v3). Fields the shorter block does not reach keep the
+plugin's reset value (0) — for v4 this includes the oversampling word at 0x1F4. The envelope curves follow the block
+as in round 36. Versions below 3 (a piecewise layout) occur in no preset or demo state and are rejected.
+
+### 2.4 Numeric details that matter at −140 dB **[DECOMP of the x87 code + EXEC]**
+
+- **Filter states between blocks:** the end-of-block clean-up of the biquad / all-pass states only zeroes values
+  below 2⁻²⁴; the states stay in double (round 36 had them rounded to float — the decompiler shows a conversion the
+  instructions do not make).
+- **Control smoothers** (release, attack and release-2 one-poles): the state lives in x87 extended precision for the
+  whole block, the coefficients are doubles, only the output samples are rounded to float; between blocks the state
+  is kept as a double (0 below 2⁻²⁴). LYNX uses `long double` (80-bit on every x86-64 target it is built for).
+
+### 2.5 Menu options stored in the state's UI block **[DECOMP + EXEC]**
+
+- **Solo** (byte 0x1EF) with the editor's selected band (int 0x1E0): when solo is on and a band other than the master
+  is selected, every other band 0…2 is muted (effective mode ≥ 2) and the master runs at least as "compression off"
+  (effective mode ≥ 1).
+- **Linear-phase filters (legacy mode)** (byte 0x1FD): the IIR crossover is replaced by three FIR filters run on the
+  (low-cut, oversampled) input, one per band:
+  - FIR length `N = round(0.004·band rate) | 1` (at least 5); each split's own windowed-sinc length
+    `L = round(K·27 500·(slope + 1)/f) | 1` (at least 5, at most N; K = oversampling factor, f = split frequency).
+  - Kernel: ideal low-pass sinc at the normalised frequency, times a 4-term Blackman–Harris window; a high-pass is the
+    spectral inversion of the low-pass; the mid band is (low-pass at f_low + high-pass at f_high) inverted, i.e. a
+    band-pass; when one outer band is off its split is dropped (mid = low-pass at f_high or high-pass at f_low). Each
+    kernel is centred in the N-tap buffer and converted to float. The low and high bands use polarity +1 in this mode.
+  - The FIRs add `(N − 1)/2` samples of delay, included in the reported latency.
+- **Master Mid mode** (byte 0x1FC) and the v ≥ 14 **linear-phase band split** (flags bit 0, which hands the split to
+  Frequency Splitter's `engine_x64.dll`) are **not decoded**; LYNX rejects such states (§6).
+- **v ≥ 14 curve-scale flag** (bit 6): round 36 §2.1; now exercised by the demo states.
+
+### 2.6 High band as the first band on **[DECOMP + EXEC]**
+
+The band outputs are accumulated into a sum buffer; the first band that is on *is* the sum buffer. When the low and
+mid bands are both off, the high band is the first, and the final add of "band + sum" then **doubles** it. This is the
+plugin's behaviour (EXEC: LYNX matches the DLL on such states only with the doubling) and LYNX reproduces it.
+
+### 2.7 Latency **[DECOMP]**
+
+Reported to the host: `max(L₀…₂)/K + L₃`; with the legacy FIRs `(max(L₀…₂) + (N − 1)/2)/K + L₃`. LYNX reports the same to its PDC.
+
+---
+
+## 3. Soundgoodizer_x64.dll's older build **[DECOMP + EXEC]**
+
+Same structure as §2 with these differences:
+
+1. **Loader:** it stops after the fixed block — states newer than version 13 (v14+ options) are not read by this
+   build. The shipped presets are v4.
+2. **Gain table end:** while building the drawn-curve table the saturated output is compared with the double 0.975
+   (not the float), the stored end value is the last output before saturation, and the peak used for saturation A's
+   top is divided by the float 0.975.
+3. **Saturation A table:** 16-bit — each value is `round(v·32767)` clamped to ±32767 and read back × ceiling/32768.
+4. **Crossover:** the low band has no phase-matching all-pass at the high split (only `sL + 1` low-pass stages).
+5. **Legacy FIR mode:** the high split's length constant is 110 000 instead of 27 500.
+
+Everything else (detectors, stages, oversampling, band mix, master) is shared.
+
+---
+
+## 4. Vocodex's Soundgoodizer stage **[DECOMP + EXEC]**
+
+- The stage is the shared engine loaded with `Vocodex\Data\SG.dat`, parameter 5 = the SG knob (0 skips the stage), run
+  in place on Vocodex's output by the sub-plugin's Eff_Render. `t_vcxsg.py`: Vocodex_x64.dll with SG as stored is
+  **bit-identical** to (Vocodex with SG = 0) → SG_x64.dll with SG.dat and parameter 5 = SG, on two demo instances
+  (SG = 226 and 546). With SG_x64.dll's default state instead of SG.dat the difference is +3.7…+4.2 dB, so the data file
+  is required.
+- The latency of the stage adds to Vocodex's own.
+
+---
+
+## 5. Vocodex's internal carrier **[DECOMP + EXEC]**
+
+- With the harness answering the file enumeration, Vocodex lists the 25 presets of
+  `Synthesizer\Data\Presets\*.fst` and creates its own Sytrus. The carrier is that Sytrus with the tone's preset (a
+  standard FL preset stream for plugin `"Sytrus"`), one voice per latched key: Init/Final pan 0, volume 0.5,
+  `Final.Pitch = 100·key − 6000` cents (i.e. the key itself), cut/res 0; the host answers the voice's velocity query
+  with 0.78125 and its release velocity with 1.0. The keys stay held for the whole render.
+- LYNX runs this on its own exact Sytrus engine (round 31) with the preset read from the user's installation at
+  import. Ookay / NewStuff (tone "PWM", keys 51, 63, 66, 73) now vocode against the synth instead of passing the
+  modulator through.
+
+---
+
+## 6. What LYNX does with it
+
+- **`EffectKind::maximus`** (`core/MaximusFx`): a mixer effect whose slot state is a small container of our own
+  (`"LXMX"`, version, build, band mix, then the Maximus state bytes). A **Maximus** slot keeps FL's own saved state;
+  a **Soundgoodizer** slot keeps the preset file read from the user's installation at import plus Amount as the band
+  mix, and runs on the Soundgoodizer build. Host blocks longer than 512 frames are split into the engine's calls.
+- **Fallbacks:** states the engine does not support (§2.5: Master Mid mode, the v14+ linear-phase split, oversampling
+  above ×2), or a Soundgoodizer whose preset file cannot be read, keep the previous approximation; the import report
+  lists them.
+- **Vocodex:** at import the SG.dat bytes and the carrier's Sytrus state are appended to FL's raw Vocodex state (a
+  tagged trailer; FL's bytes are untouched), so a saved `.lynx` project needs no installation to play.
+
+---
+
+## 7. Verification **[EXEC]**
+
+| Check | Cases | Result |
+|---|---|---|
+| Maximus, every demo state (`t_lynx.py`, music signal) | 100 states | 96 within −139.4 dB (53 bit-identical, median −∞); 4 rejected (all four use the v15 linear-phase split, §2.5) |
+| Legacy FIR mode (demo states with byte 0x1FD set) | 2 states × music / noise bursts | −137.3…−139.1 dB |
+| Soundgoodizer (`t_sgz2.py`), music, 44.1 kHz / 512 | presets A–D × Amount 0, 128, 600, 1000 | −128.1…−∞ dB (A −128…−137, B −133…−146, C −143…−∞, D −146…−∞) |
+| Soundgoodizer, noise bursts, 48 kHz / blocks of 300 | the same 16 cases | −125.9…−∞ dB |
+| Vocodex's SG stage ≡ SG_x64.dll + SG.dat (`t_vcxsg.py`) | 2 demo instances | bit-identical |
+| LYNX's Vocodex effect vs Vocodex_x64.dll (`t_vcx.py`) | all 10 demo instances, SG stage on | −136.0…−144.9 dB; the two internal-carrier instances (Ookay, NewStuff) −111.8 dB |
+| Unit tests (`tests/tests.cpp` `maximus_engine`) | own states vs SG_x64.dll / a Soundgoodizer DLL copy: RMS, saturation B, low cut, solo, legacy FIR, v4 layout on the Soundgoodizer build; containers | goldens within 2·10⁻⁶ |
+
+The −111.8 dB of the internal-carrier instances is the error of LYNX's Sytrus engine on that preset, not of Vocodex
+or the SG stage (the external-carrier instances sit at −136 dB and below).
+
+**Cost** (one core, 44.1 kHz, 20 s of noise, `bench.cpp`): a demo Maximus state 1.3 % of real time, the same with the
+legacy FIRs 3.4 %, Soundgoodizer preset A 1.9 %.
+
+---
+
+## 8. Open items
+
+- Master Mid mode (UI byte 0x1FC) and the v14+ linear-phase band split through `engine_x64.dll` (4 of the 100 demo
+  Maximus states) — not decoded, approximated.
+- Oversampling orders above ×2 (no preset or demo state uses them).
+- Envelope segment types other than 0 and 7 in the drawn curve (none in the demo states).
+- The 512-frame split of long host blocks follows FL's usual block size; FL's own behaviour with longer blocks was not
+  observed.

+ 1 - 0
resources/LYNX.rc

@@ -1,3 +1,4 @@
 #include <winuser.h>
 CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "LYNX.manifest"
 1 ICON "LYNX.ico"
+2 ICON "LYNX_doc.ico"

BIN
resources/LYNX_doc.ico


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

@@ -442,6 +442,7 @@ countries: br
 "Harmor — FL's additive engine (effects rack off; image synthesis not decoded)" = "Harmor — motor aditivo do FL (rack de efeitos desligado; síntese de imagem não decodificada)"
 "GMS — FL's engine (waves read from your FL installation)" = "GMS — motor do FL (ondas lidas da sua instalação do FL)"
 "Morphine — FL's additive engine (new settings restart the voices)" = "Morphine — motor aditivo do FL (novos ajustes reiniciam as vozes)"
+"Ogun — FL's engine with its effects (Seed 2 Random is a fixed draw per channel)" = "Ogun — motor do FL com seus efeitos (Seed 2 Random é um sorteio fixo por canal)"
 "BooBass — FL's engine, its sound read from your FL installation (knobs: 3-band EQ)" = "BooBass — motor do FL, som lido da sua instalação do FL (knobs: EQ de 3 bandas)"
 "Sakura — physical strings (FL's engine; new parameters apply to the next note)" = "Sakura — cordas físicas (motor do FL; novos parâmetros valem a partir da próxima nota)"
 "Drumpad — physical drum (FL's engine; new parameters apply to the next hit)" = "Drumpad — tambor físico (motor do FL; novos parâmetros valem a partir do próximo hit)"
@@ -705,6 +706,209 @@ countries: br
 "Drag to move (Alt: no snapping), double-click to maximize" = "Arraste para mover (Alt: sem encaixe), duplo clique maximiza"
 "F5 Playlist   F6 Channel Rack   F7 Piano Roll   F8 Browser   F9 Mixer" = "F5 Playlist   F6 Channel Rack   F7 Piano Roll   F8 Browser   F9 Mixer"
 
+# --- Workflow P2: history, key map, note tools, mixer, browser, recording
+"Add pattern" = "Adicionar pattern"
+"Add notes: {0}" = "Adicionar notas: {0}"
+"Delete notes: {0}" = "Apagar notas: {0}"
+"Edit notes: {0}" = "Editar notas: {0}"
+"Rename pattern: {0}" = "Renomear pattern: {0}"
+"Pattern length: {0}" = "Duração do pattern: {0}"
+"Add channel" = "Adicionar canal"
+"Move channels" = "Mover canais"
+"Mute: {0}" = "Mudo: {0}"
+"Channel level: {0}" = "Nível do canal: {0}"
+"Channel: {0}" = "Canal: {0}"
+"Add insert" = "Adicionar insert"
+"Remove insert" = "Remover insert"
+"Move inserts" = "Mover inserts"
+"Routing: {0}" = "Roteamento: {0}"
+"Mixer level: {0}" = "Nível do mixer: {0}"
+"Mixer: {0}" = "Mixer: {0}"
+"Add clips" = "Adicionar clipes"
+"Delete clips" = "Apagar clipes"
+"Edit clips" = "Editar clipes"
+"Time selection" = "Seleção de tempo"
+"Markers" = "Marcadores"
+"Arrangements" = "Arranjos"
+"Playlist tracks" = "Faixas da Playlist"
+"Select pattern" = "Selecionar pattern"
+"Quick-add palette: instruments and effects" = "Paleta de inserção rápida: instrumentos e efeitos"
+"Clone the current pattern" = "Clonar o pattern atual"
+"Move the current pattern up" = "Mover o pattern atual para cima"
+"Move the current pattern down" = "Mover o pattern atual para baixo"
+"Recording on/off" = "Gravação liga/desliga"
+"Metronome on/off" = "Metrônomo liga/desliga"
+"Count-in before recording on/off" = "Contagem antes de gravar liga/desliga"
+"Recording waits for the first note on/off" = "Gravação espera a primeira nota liga/desliga"
+"Undo history" = "Histórico de desfazer"
+"Search the Browser" = "Buscar no Browser"
+"Step graph lanes on/off" = "Faixas de gráfico dos steps liga/desliga"
+"Rotate the selected channels' steps left" = "Girar os steps dos canais selecionados para a esquerda"
+"Rotate the selected channels' steps right" = "Girar os steps dos canais selecionados para a direita"
+"Arpeggiate..." = "Arpejar..."
+"Strum..." = "Dedilhar (strum)..."
+"Flip..." = "Espelhar..."
+"Randomise..." = "Aleatorizar..."
+"Scale levels..." = "Escalar níveis..."
+"Limit to a range..." = "Limitar a uma faixa..."
+"Zoom in" = "Aproximar"
+"Zoom out" = "Afastar"
+"Zoom: one bar" = "Zoom: um compasso"
+"Zoom: four bars" = "Zoom: quatro compassos"
+"Zoom: sixteen bars" = "Zoom: dezesseis compassos"
+"Zoom to show everything" = "Zoom para mostrar tudo"
+"Zoom to the selection" = "Zoom na seleção"
+"Centre the view on the playhead" = "Centralizar a vista no cursor de reprodução"
+"Delete the selected clips and close the gaps" = "Apagar os clipes selecionados e fechar os vãos"
+"Ripple editing on/off" = "Edição ripple liga/desliga"
+"Move the selected inserts left" = "Mover os inserts selecionados para a esquerda"
+"Move the selected inserts right" = "Mover os inserts selecionados para a direita"
+"Link the selected channels to the selected insert" = "Ligar os canais selecionados ao insert selecionado"
+"Link the selected channels to inserts starting from the selected one" = "Ligar os canais selecionados a inserts a partir do selecionado"
+"Select the channels linked to the selected insert" = "Selecionar os canais ligados ao insert selecionado"
+"Select pattern {0}" = "Selecionar pattern {0}"
+"Previous file (preview)" = "Arquivo anterior (pré-escuta)"
+"Next file (preview)" = "Próximo arquivo (pré-escuta)"
+"Previous file into the selected channel" = "Arquivo anterior no canal selecionado"
+"Next file into the selected channel" = "Próximo arquivo no canal selecionado"
+"Load the file into the selected channel" = "Carregar o arquivo no canal selecionado"
+"Click: new point · drag: move (then Shift: time locked, Ctrl: value locked) · right-click: point menu · Alt+drag: curve · Ctrl+wheel: zoom" = "Clique: novo ponto · arrastar: mover (depois Shift: trava o tempo, Ctrl: trava o valor) · botão direito: menu do ponto · Alt+arrastar: curva · Ctrl+roda: zoom"
+"Copy value" = "Copiar valor"
+"Paste value" = "Colar valor"
+"Straight segment (reset the curve)" = "Segmento reto (zera a curva)"
+"Delete point" = "Apagar ponto"
+"Point value" = "Valor do ponto"
+"BPM" = "BPM"
+"Percent (0 to 100)" = "Porcentagem (0 a 100)"
+"Scale the values into a range..." = "Escalar os valores para uma faixa..."
+"Flip the values upside down" = "Inverter os valores de cabeça para baixo"
+"All segments straight" = "Todos os segmentos retos"
+"Scale the values into a range" = "Escalar os valores para uma faixa"
+"The lowest point goes to the minimum and the highest to the maximum (percent)." = "O ponto mais baixo vai ao mínimo e o mais alto ao máximo (porcentagem)."
+"Minimum" = "Mínimo"
+"Maximum" = "Máximo"
+"Search (Ctrl+F): kick -loop, snare OR clap, hat*.wav" = "Buscar (Ctrl+F): kick -loop, snare OR clap, hat*.wav"
+"Add folder..." = "Adicionar pasta..."
+"Add a folder to the Browser" = "Adicionar uma pasta ao Browser"
+"Nothing found for \"{0}\"." = "Nada encontrado para \"{0}\"."
+"Searching {0}..." = "Buscando em {0}..."
+"Showing the first {0} results." = "Mostrando os primeiros {0} resultados."
+"Drag: set  ·  Right-drag: ramp  ·  Alt+click: reset" = "Arrastar: define  ·  Arrastar com o direito: rampa  ·  Alt+clique: restaura"
+"Select unused channels" = "Selecionar canais sem uso"
+"Every channel is used by a pattern or a Playlist clip." = "Todos os canais são usados por um pattern ou por um clipe da Playlist."
+"Pulses" = "Pulsos"
+"Length (steps)" = "Duração (steps)"
+"Rotation" = "Rotação"
+"Euclidean fill: {0}" = "Preenchimento euclidiano: {0}"
+"Accept" = "Aceitar"
+"Euclidean fill" = "Preenchimento euclidiano"
+"Graph lane: choose what the bars edit (Ctrl+K hides the lane)" = "Faixa de gráfico: escolha o que as barras editam (Ctrl+K esconde a faixa)"
+"Graph lane: drag sets the steps, right-drag draws a ramp, Alt+click resets" = "Faixa de gráfico: arrastar define os steps, arrastar com o direito desenha uma rampa, Alt+clique restaura"
+"Fill every 2 steps" = "Preencher a cada 2 steps"
+"Fill every 4 steps" = "Preencher a cada 4 steps"
+"Fill every 8 steps" = "Preencher a cada 8 steps"
+"Euclidean fill..." = "Preenchimento euclidiano..."
+"Rotate left" = "Girar para a esquerda"
+"Rotate right" = "Girar para a direita"
+"Graph lanes (velocity, pan, pitch...)" = "Faixas de gráfico (velocity, pan, afinação...)"
+"Steps" = "Steps"
+"By name" = "Por nome"
+"By color" = "Por cor"
+"By mixer insert" = "Por insert do mixer"
+"By type" = "Por tipo"
+"Sort channels" = "Ordenar canais"
+"Click a step to go back (or forward) to it. Newest at the bottom." = "Clique num passo para voltar (ou avançar) até ele. O mais recente fica embaixo."
+"Recording" = "Gravação"
+"Quick-add palette" = "Paleta de inserção rápida"
+"The selected insert has no free effect slot." = "O insert selecionado não tem slot de efeito livre."
+"Count-in" = "Contagem"
+"Wait for the first note to start" = "Esperar a primeira nota para começar"
+"Overdub: add to the pattern" = "Overdub: soma ao pattern"
+"Replace: a recorded channel's old notes are cleared" = "Substituir: as notas antigas de um canal gravado são apagadas"
+"Quantise recorded notes to the global grid" = "Quantizar as notas gravadas na grade global"
+"Song mode: place a pattern clip where recording starts" = "Modo Song: colocar um clipe do pattern onde a gravação começa"
+"Undo history..." = "Histórico de desfazer..."
+"Quick-add palette..." = "Paleta de inserção rápida..."
+"Remove this send" = "Remover este envio"
+"Send here" = "Enviar para cá"
+"Send only here" = "Enviar só para cá"
+"Sidechain only (no audio): the compressors here listen to it" = "Só sidechain (sem áudio): os compressores daqui escutam este insert"
+"Sidechain" = "Sidechain"
+"The link was made; add a compressor to this insert to use it." = "A ligação foi feita; adicione um compressor a este insert para usá-la."
+"Click: mute.  Right-click or Ctrl+click: solo" = "Clique: mudo.  Botão direito ou Ctrl+clique: solo"
+"Record arm: audio takes from the input play through this insert" = "Armar gravação: as tomadas de áudio da entrada tocam por este insert"
+"Send from the selected insert to this one (drag after enabling: level; right-click: sidechain, only here)" = "Envio do insert selecionado para este (arraste depois de ligar: nível; botão direito: sidechain, só para cá)"
+"Click selects the insert (Ctrl: add, Shift: range), right-click opens its menu; Alt+Left/Right moves the selection" = "Clique seleciona o insert (Ctrl: adiciona, Shift: intervalo), botão direito abre o menu; Alt+Esquerda/Direita move a seleção"
+"Link the selected channels here" = "Ligar os canais selecionados aqui"
+"Link the selected channels starting here" = "Ligar os canais selecionados a partir daqui"
+"Select the channels linked here" = "Selecionar os canais ligados aqui"
+"Route the selected inserts here" = "Rotear os inserts selecionados para cá"
+"Route the selected inserts only here" = "Rotear os inserts selecionados só para cá"
+"Move left" = "Mover para a esquerda"
+"Move right" = "Mover para a direita"
+"All effects of this insert on/off; right-click opens or closes their plugin windows" = "Todos os efeitos deste insert liga/desliga; botão direito abre ou fecha as janelas dos plugins"
+"Effect slot: click edits, the LED bypasses, drag or wheel reorders, right-click: replace, move, delete" = "Slot de efeito: clique edita, o LED desativa, arrastar ou a roda reordena, botão direito: substituir, mover, apagar"
+"{0} notes. Changes are heard and seen right away; Accept keeps them as one undo step." = "{0} notas. As mudanças são ouvidas e vistas na hora; Aceitar as mantém como um passo de desfazer."
+"steps" = "steps"
+"Spread" = "Espalhamento"
+"Curve" = "Curva"
+"Velocity per note" = "Velocity por nota"
+"Direction" = "Direção"
+"Low to high" = "Do grave ao agudo"
+"High to low" = "Do agudo ao grave"
+"Alternate" = "Alternar"
+"Keep the ends" = "Manter os finais"
+"Down and up" = "Desce e sobe"
+"Octaves" = "Oitavas"
+"Flip in time" = "Espelhar no tempo"
+"Flip in pitch" = "Espelhar na altura"
+"Timing" = "Tempo"
+"Both directions" = "Nos dois sentidos"
+"Scale at the start" = "Escala no início"
+"Scale at the end" = "Escala no fim"
+"Offset" = "Deslocamento"
+"Lowest note" = "Nota mais grave"
+"Highest note" = "Nota mais aguda"
+"Lowest velocity" = "Menor velocity"
+"Highest velocity" = "Maior velocity"
+"Reset" = "Restaurar"
+"New variation" = "Nova variação"
+"Strum" = "Dedilhar (strum)"
+"Arpeggiate" = "Arpejar"
+"Flip" = "Espelhar"
+"Randomise" = "Aleatorizar"
+"Scale levels" = "Escalar níveis"
+"Limit" = "Limitar"
+"Tools" = "Ferramentas"
+"Taller keys" = "Teclas mais altas"
+"Shorter keys" = "Teclas mais baixas"
+"Snap notes to the scale" = "Encaixar notas na escala"
+"Move the notes onto the scale" = "Mover as notas para a escala"
+"Ripple" = "Ripple"
+"Ripple editing (resizing and deleting move the later clips)" = "Edição ripple (redimensionar e apagar movem os clipes seguintes)"
+"Type to filter (e.g. reverb, synth OR bass, -delay)" = "Digite para filtrar (ex.: reverb, synth OR bass, -delay)"
+"Instruments: new channel" = "Instrumentos: novo canal"
+"Effects: into the selected insert" = "Efeitos: no insert selecionado"
+"Enter adds the highlighted item, Up/Down move, Tab switches lists, Esc closes" = "Enter adiciona o item destacado, Cima/Baixo movem, Tab troca de lista, Esc fecha"
+"built-in" = "nativo"
+"Piano Roll when it has piano-roll notes, else Channel Rack" = "Piano Roll quando tem notas de Piano Roll, senão Channel Rack"
+"Channel Rack" = "Channel Rack"
+"Double-click on a pattern clip opens" = "Duplo clique num clipe de pattern abre"
+"Unmute" = "Tirar do mudo"
+"Solo (mute the other tracks)" = "Solo (silencia as outras faixas)"
+"Insert a track above" = "Inserir uma faixa acima"
+"Insert a track below" = "Inserir uma faixa abaixo"
+"Delete the track and its clips" = "Apagar a faixa e seus clipes"
+"Open in Piano Roll" = "Abrir no Piano Roll"
+"LYNX can't build an effect from this preset." = "O LYNX não consegue montar um efeito a partir deste preset."
+"Store the current settings as B" = "Guardar os ajustes atuais como B"
+"Swap with B" = "Trocar com B"
+"Forget B" = "Esquecer B"
+"A/B compare (B stored)" = "Comparar A/B (B guardado)"
+"A/B compare" = "Comparar A/B"
+"Recording: waiting for the first note (Space cancels)" = "Gravação: esperando a primeira nota (Espaço cancela)"
+"Recording: count-in..." = "Gravação: contagem..."
+
 # --- Start-up: splash screen and sound
 "Starting the audio engine..." = "Iniciando o motor de áudio..."
 "Loading the workspace..." = "Carregando a área de trabalho..."
@@ -722,3 +926,10 @@ countries: br
 "Detached (own window)" = "Destacada (janela própria)"
 "Maximized" = "Maximizada"
 "Close" = "Fechar"
+
+# --- Workflow P2 in the main toolbar
+"Count-in before recording: {0} bar(s)" = "Contagem antes de gravar: {0} compasso(s)"
+"Count-in before recording: off" = "Contagem antes de gravar: desligada"
+"Recording waits for the first note: on" = "Gravação espera a primeira nota: ligada"
+"Recording waits for the first note: off" = "Gravação espera a primeira nota: desligada"
+"Snap notes to the scale: new and moved notes, and incoming MIDI, land on the chosen scale" = "Encaixar as notas na escala: notas novas e movidas, e o MIDI que chega, caem na escala escolhida"

+ 4 - 1
scripts/build-local.sh

@@ -13,11 +13,13 @@ if [[ -z "${CXX:-}" ]]; then
 fi
 
 FLAGS="-std=c++20 -O2 -g -Wall -Wextra -Wpedantic -Isrc -Ithird_party/wavpack/include"
-CORE="src/flp/Flp.cpp src/core/Song.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Vocodex.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp src/core/FlpImport.cpp src/core/Effects.cpp"
+CORE="src/flp/Flp.cpp src/core/Song.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Vocodex.cpp src/core/MaximusFx.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/Ogun.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp src/core/FlpImport.cpp src/core/Effects.cpp"
 
 mkdir -p build-local build-local/wavpack
 # workflow shell (key map, workspace layout, rack operations)
 CORE="$CORE src/core/KeyMap.cpp src/core/Workspace.cpp src/core/RackOps.cpp"
+# workflow P2 (note tools, mixer operations, history labels, browser search)
+CORE="$CORE src/core/NoteTools.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp"
 # start-up sound (procedural)
 CORE="$CORE src/core/StartupSound.cpp"
 # WavPack decoder (C)
@@ -43,5 +45,6 @@ $CXX $FLAGS $CORE $WAVPACK tools/vocodexrender.cpp -o build-local/vocodexrender
 $CXX $FLAGS src/core/Harmor.cpp src/core/HarmlessFx.cpp tools/harmorrender.cpp -o build-local/harmorrender 2> >(grep -v 'glibc version' >&2)
 $CXX $FLAGS src/core/Gms.cpp tools/gmsrender.cpp -o build-local/gmsrender 2> >(grep -v 'glibc version' >&2)
 $CXX $FLAGS src/core/Morphine.cpp tools/morphinerender.cpp -o build-local/morphinerender 2> >(grep -v 'glibc version' >&2)
+$CXX $FLAGS $CORE $WAVPACK tools/ogunrender.cpp -o build-local/ogunrender 2> >(grep -v 'glibc version' >&2)
 
 ./build-local/lynx_tests "$@"

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

@@ -75,11 +75,17 @@ APP_SOURCES=(src/Main.cpp
              src/engine/SampleLibrary.cpp src/engine/WavPackFormat.cpp src/engine/ProjectFile.cpp src/engine/PluginHost.cpp src/engine/PluginSandbox.cpp src/engine/Exporter.cpp src/engine/StreamPrefetcher.cpp src/engine/ClapFormat.cpp src/engine/MidiFileIo.cpp src/engine/PreviewPlayer.cpp
              src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp src/ui/Theme.cpp src/ui/Icons.cpp src/ui/I18n.cpp src/ui/EditorTools.cpp
              src/core/Song.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp
-             src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Vocodex.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
+             src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Vocodex.cpp src/core/MaximusFx.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/Ogun.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
              src/platform/MingwFixes.cpp)
 
 # workflow shell: core (key map, workspace layout, rack operations) and UI (workspace desktop, control contract)
 APP_SOURCES+=(src/core/KeyMap.cpp src/core/Workspace.cpp src/core/RackOps.cpp src/ui/Workspace.cpp src/ui/ValueControl.cpp src/ui/Dialogs.cpp)
+# Windows file association (.lynx) and its icon
+APP_SOURCES+=(src/platform/FileTypes.cpp)
+# workflow P2: core (note tools, mixer operations, history labels, browser search)
+APP_SOURCES+=(src/core/NoteTools.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp)
+# workflow P2: UI (note tool dialogs, tool windows, undo history, quick-add palette)
+APP_SOURCES+=(src/ui/NoteToolDialogs.cpp src/ui/ToolWindow.cpp src/ui/HistoryPanel.cpp src/ui/QuickAddPalette.cpp)
 # start-up: splash screen and its procedurally synthesised sound
 APP_SOURCES+=(src/core/StartupSound.cpp src/ui/Splash.cpp)
 

+ 86 - 2
src/Main.cpp

@@ -11,6 +11,7 @@
 #include "engine/ProjectFile.h"
 #include "engine/SampleLibrary.h"
 #include "engine/Text.h"
+#include "platform/FileTypes.h"
 #include "ui/AutomationUi.h"
 #include "ui/ChannelSettings.h"
 #include "ui/Dialogs.h"
@@ -18,6 +19,8 @@
 #include "ui/ExportDialog.h"
 #include "ui/I18n.h"
 #include "ui/MainComponent.h"
+#include "ui/HistoryPanel.h"
+#include "ui/NoteToolDialogs.h"
 #include "ui/ParametricEqEditor.h"
 #include "ui/Splash.h"
 #include "ui/Theme.h"
@@ -302,6 +305,7 @@ public:
 
         juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
         startupOptions = lynx::StartupOptions::load();
+        lynx::registerFileTypes();
         // Double-clicking a .lynx/.flp opens LYNX with the file as an argument.
         if (args.size() > 0 && juce::File::isAbsolutePath (args[0].unquoted()))
             fileToOpen = juce::File (args[0].unquoted());
@@ -1261,6 +1265,21 @@ private:
             saveIconSheet (prefix + "-icons-150.png", 1.5f);
             saveWindow (lynx::MainComponent::makeHelpContent(), "-help.png");
             saveMenus (ui, prefix + "-menus.png");
+            {
+                // the windows' own menus (title bars) and the toolbar's recording menu
+                juce::StringArray names;
+                std::vector<juce::PopupMenu> menus;
+                for (auto [panel, name] : { std::pair { lynx::workspace::Panel::playlist, "Playlist" }, { lynx::workspace::Panel::channelRack, "Channel Rack" },
+                                            { lynx::workspace::Panel::pianoRoll, "Piano Roll" }, { lynx::workspace::Panel::mixer, "Mixer" },
+                                            { lynx::workspace::Panel::browser, "Browser" } })
+                {
+                    names.add (name);
+                    menus.push_back (ui.getPanelMenuForSnapshot (panel));
+                }
+                names.add ("Recording");
+                menus.push_back (ui.getRecordMenuForSnapshot());
+                saveMenus (names, menus, prefix + "-panel-menus.png");
+            }
 
             auto saveAlert = [&] (std::unique_ptr<juce::AlertWindow> alert, const juce::String& name) {
                 alert->setOpaque (true);
@@ -1332,6 +1351,62 @@ private:
                 saveWindow (std::move (inspector), "-noteinspector.png");
             if (auto inspector = ui.getPianoRollForSnapshot().makeNoteInspectorForSnapshot (true))
                 saveWindow (std::move (inspector), "-noteinspector-one.png");
+
+            // workflow P2: note tool dialogs (they preview on the pattern; each one puts the notes back when destroyed)
+            {
+                auto& roll = ui.getPianoRollForSnapshot();
+                const std::pair<lynx::NoteTool, const char*> tools[] = { { lynx::NoteTool::strum, "-tool-strum.png" },
+                                                                         { lynx::NoteTool::arpeggiate, "-tool-arpeggiate.png" },
+                                                                         { lynx::NoteTool::flip, "-tool-flip.png" },
+                                                                         { lynx::NoteTool::randomise, "-tool-randomise.png" },
+                                                                         { lynx::NoteTool::scaleLevels, "-tool-scalelevels.png" },
+                                                                         { lynx::NoteTool::limit, "-tool-limit.png" } };
+                for (const auto& [tool, name] : tools)
+                    saveWindow (lynx::makeNoteToolPanel (offline, tool, roll.noteIndicesForSnapshot(), roll.gridForSnapshot()), name);
+            }
+
+            // the Channel Rack with the step graph lane (velocity), and the Euclidean fill window
+            ui.selectTabForSnapshot (0);
+            ui.getRackForSnapshot().setGraphLevelForSnapshot (0);
+            offline.dispatchPendingMessages();
+            saveSnapshot (ui, prefix + "-rack-graph.png");
+            ui.getRackForSnapshot().setGraphLevelForSnapshot (1);
+            saveSnapshot (ui, prefix + "-rack-graph-pan.png");
+            ui.getRackForSnapshot().toggleGraphLanes();
+            saveWindow (ui.getRackForSnapshot().makeEuclideanPanel (0), "-euclidean.png");
+
+            // the Mixer with three inserts selected and one armed for recording
+            ui.selectTabForSnapshot (3);
+            if (offline.getSong().mixer.size() > 4)
+            {
+                ui.getMixerForSnapshot().getStripsForSnapshot().setSelection ({ 1, 2, 3 }, 2);
+                offline.setInsertArmed (3, true);
+                offline.dispatchPendingMessages();
+                saveSnapshot (ui, prefix + "-mixer-multi.png");
+                offline.setInsertArmed (3, false);
+                ui.getMixerForSnapshot().getStripsForSnapshot().setSelection ({}, 0);
+            }
+
+            // the Playlist with ripple editing on
+            ui.selectTabForSnapshot (2);
+            ui.getPlaylistForSnapshot().setRipple (true);
+            saveSnapshot (ui, prefix + "-playlist-ripple.png");
+            ui.getPlaylistForSnapshot().setRipple (false);
+
+            // quick-add palette, and the Browser searching
+            saveWindow (ui.makeQuickAddForSnapshot(), "-quickadd.png");
+            ui.showDesktopForSnapshot (false);
+            ui.getBrowserForSnapshot().setSearchForSnapshot ("kick");
+            offline.dispatchPendingMessages();
+            saveSnapshot (ui, prefix + "-browser-search.png");
+            ui.getBrowserForSnapshot().setSearchForSnapshot ({});
+
+            // the undo history after a few edits
+            offline.editSong ([] (lynx::Song& s) { s.bpm += 1.0; });
+            offline.editSong ([] (lynx::Song& s) { if (! s.channels.empty()) s.channels[0].muted = ! s.channels[0].muted; });
+            offline.editSong ([] (lynx::Song& s) { if (! s.patterns.empty()) s.patterns[(std::size_t) s.currentPattern].notes.push_back ({}); });
+            offline.undo();
+            saveWindow (lynx::makeHistoryPanel (offline), "-history.png");
         }
         juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
         quit();
@@ -1340,8 +1415,17 @@ private:
     // the menu bar's menus side by side, drawn with the LookAndFeel as they appear when opened
     static void saveMenus (lynx::MainComponent& ui, const juce::String& path)
     {
-        auto& lf = juce::LookAndFeel::getDefaultLookAndFeel();
         const auto names = ui.getMenuNamesForSnapshot();
+        std::vector<juce::PopupMenu> source;
+        for (int m = 0; m < names.size(); ++m)
+            source.push_back (ui.getMenuForSnapshot (m));
+        saveMenus (names, source, path);
+    }
+
+    // menus side by side, each under its name
+    static void saveMenus (const juce::StringArray& names, const std::vector<juce::PopupMenu>& source, const juce::String& path)
+    {
+        auto& lf = juce::LookAndFeel::getDefaultLookAndFeel();
         struct Laid
         {
             juce::PopupMenu menu;
@@ -1353,7 +1437,7 @@ private:
 
         for (int m = 0; m < names.size(); ++m)
         {
-            Laid laid { ui.getMenuForSnapshot (m) };
+            Laid laid { source[(std::size_t) m] };
             int width = 160, height = 2 * border;
 
             for (juce::PopupMenu::MenuItemIterator it (laid.menu); it.next();)

+ 7 - 0
src/core/Effects.cpp

@@ -4,6 +4,7 @@
 #include "core/PitcherDsp.h"
 #include "core/VintagePhaser.h"
 #include "core/Vocodex.h"
+#include "core/MaximusFx.h"
 
 #include "core/Biquad.h"
 
@@ -2131,6 +2132,7 @@ const EffectInfo& effectInfo (EffectKind kind)
                                                        { "Release", 90.0f / 990.0f }, { "Hold", 0.0f }, { "Modulator", 0.0f },
                                                        { "Carrier", 0.0f }, { "Wet", 0.8f }, { "Side inputs", 0.0f } } };
     static const EffectInfo vocodexInfo { "Vocodex", {} }; // everything comes from FL's raw state (EffectSlot::state)
+    static const EffectInfo maximusInfo { "Maximus", {} }; // the engine's state travels in EffectSlot::state (core/MaximusFx.h)
     // raw FL values / max (the names are FL's controls, REA_rodada29 §2.1)
     static const EffectInfo squeezeInfo { "Squeeze", { { "Volume", 127.0f / 160.0f }, { "Mix", 0.5f }, { "Steps", 1.0f / 32768.0f },
                                                        { "Filter", 0.0f }, { "Filter type", 0.0f }, { "Resonance", 0.5f },
@@ -2225,6 +2227,7 @@ const EffectInfo& effectInfo (EffectKind kind)
         case EffectKind::squeeze: return squeezeInfo;
         case EffectKind::vintagePhaser: return vintagePhaserInfo;
         case EffectKind::vocodex: return vocodexInfo;
+        case EffectKind::maximus: return maximusInfo;
     }
     return eq;
 }
@@ -2494,6 +2497,7 @@ std::string formatEffectParam (EffectKind kind, int param, float v, double bpm)
         case EffectKind::plugin:
         case EffectKind::parallel:
         case EffectKind::vocodex:
+        case EffectKind::maximus:
             break;
     }
 
@@ -2523,6 +2527,8 @@ std::unique_ptr<Effect> makeEffect (const EffectSlot& slot)
         return makeParallelEffect (slot);
     if (slot.kind == EffectKind::vocodex)
         return vocodex::make (slot.state);
+    if (slot.kind == EffectKind::maximus)
+        return maximusfx::make (slot.state);
     return makeEffect (slot.kind);
 }
 
@@ -2554,6 +2560,7 @@ std::unique_ptr<Effect> makeEffect (EffectKind kind)
         case EffectKind::squeeze: return std::make_unique<Squeeze>();
         case EffectKind::vintagePhaser: return makeVintagePhaser();
         case EffectKind::vocodex: return vocodex::make ({}); // without a state: passes the signal; use makeEffect (slot)
+        case EffectKind::maximus: return maximusfx::make ({}); // without a state: passes the signal; use makeEffect (slot)
         case EffectKind::pitchCorrect: return std::make_unique<PitchCorrect>();
         case EffectKind::plugin: break; // created by the app (RackState::Factories)
     }

+ 88 - 1
src/core/FlEffects.cpp

@@ -1,6 +1,8 @@
 #include "core/FlEffects.h"
 #include "core/VintagePhaser.h"
 #include "core/Vocodex.h"
+#include "core/MaximusFx.h"
+#include "core/SytrusEngine.h"
 #include "core/FlSynths.h"
 
 #include <algorithm>
@@ -814,6 +816,38 @@ std::vector<EffectSlot> soundgoodizerApproximation (int preset, int amount)
     return chain;
 }
 
+std::optional<VocodexConversion> vocodexEffect (const std::vector<std::uint8_t>& d, const FlDataReader& data)
+{
+    auto out = vocodexEffect (d);
+    if (! out || ! data)
+        return out;
+    const auto state = vocodex::parseState (d);
+    vocodex::InstallData files;
+    const std::string folder = "Plugins\\Fruity\\Effects\\Vocodex\\";
+    if (state->params[vocodex::sg] > 0)
+    {
+        files.sgDat = data (folder + "Data\\SG.dat");
+        if (hlfx::makeMaximusPreset (files.sgDat) == nullptr)
+            files.sgDat.clear();
+    }
+    if (state->internalCarrier() && ! state->tone.empty())
+    {
+        // FUN_008506a0: Synthesizer\Data\Presets\<tone>.FST (the files ship as .fst)
+        auto fst = data (folder + "Synthesizer\\Data\\Presets\\" + state->tone + ".fst");
+        if (fst.empty())
+            fst = data (folder + "Synthesizer\\Data\\Presets\\" + state->tone + ".FST");
+        if (auto st = hlfx::maximusStateFromFst (fst); st && sytrus::stateUsable (*st))
+            files.carrierState = std::move (*st);
+    }
+    out->slot.state = vocodex::appendInstallData (d, files);
+    out->notes.clear();
+    if (state->internalCarrier() && vocodex::makeInternalCarrier (*state, files.carrierState) == nullptr)
+        out->notes.push_back ("Vocodex: internal carrier synth not available (modulator only)");
+    if (state->params[vocodex::sg] > 0 && files.sgDat.empty())
+        out->notes.push_back ("Vocodex: Soundgoodizer stage approximated (SG.dat not found)");
+    return out;
+}
+
 std::optional<VocodexConversion> vocodexEffect (const std::vector<std::uint8_t>& d)
 {
     // the exact engine keeps FL's raw state (REA_rodada35); ModIn/CarIn index the track's inputs list
@@ -828,7 +862,7 @@ std::optional<VocodexConversion> vocodexEffect (const std::vector<std::uint8_t>&
     if (state->internalCarrier() && vocodex::makeInternalCarrier (*state) == nullptr)
         out.notes.push_back ("Vocodex: internal carrier synth not available (modulator only)");
     if (state->params[vocodex::sg] > 0)
-        out.notes.push_back ("Vocodex: Soundgoodizer stage approximated");
+        out.notes.push_back ("Vocodex: Soundgoodizer stage approximated (SG.dat not found)");
     return out;
 }
 
@@ -840,8 +874,61 @@ std::optional<EffectSlot> fruityLimiterCompressor (const std::vector<std::uint8_
     return slot;
 }
 
+std::optional<EffectSlot> maximusExact (const std::vector<std::uint8_t>& state)
+{
+    maximusfx::Blob blob;
+    blob.state = state;
+    if (maximusfx::presetOf (blob) == nullptr)
+        return std::nullopt;
+    auto slot = makeEffectSlot (EffectKind::maximus);
+    slot.state = maximusfx::pack (blob);
+    return slot;
+}
+
+std::optional<EffectSlot> soundgoodizerExact (const std::vector<std::uint8_t>& state, const std::vector<std::uint8_t>& presetFile)
+{
+    // FUN_00836ac0 (Soundgoodizer_x64.dll): the preset file is loaded through the plugin's own Maximus copy, then
+    // parameter 5 (band mix) is set to Amount (REA_rodada40 §3.1)
+    const auto sg = maximusfx::parseSoundgoodizer (state);
+    if (! sg)
+        return std::nullopt;
+    maximusfx::Blob blob;
+    blob.build = hlfx::MaximusBuild::soundgoodizer;
+    blob.mix = sg->amount;
+    blob.state = presetFile;
+    if (maximusfx::presetOf (blob) == nullptr)
+        return std::nullopt;
+    auto slot = makeEffectSlot (EffectKind::maximus);
+    slot.state = maximusfx::pack (blob);
+    return slot;
+}
+
+std::string soundgoodizerPresetPath (const std::vector<std::uint8_t>& state)
+{
+    const auto sg = maximusfx::parseSoundgoodizer (state);
+    if (! sg)
+        return {};
+    return std::string ("Plugins\\Fruity\\Effects\\Soundgoodizer\\Data\\Presets\\") + maximusfx::soundgoodizerPresetFile (sg->preset);
+}
+
+std::optional<EffectSlot> effectFromFl (const std::string& pluginName, const std::vector<std::uint8_t>& state, double bpm,
+                                        const FlDataReader& data)
+{
+    if (pluginName == "Vocodex" && data)
+        if (auto v = vocodexEffect (state, data))
+            return v->slot;
+    if (pluginName == "Soundgoodizer" && data)
+        if (const auto path = soundgoodizerPresetPath (state); ! path.empty())
+            if (auto exact = soundgoodizerExact (state, data (path)))
+                return exact;
+    return effectFromFl (pluginName, state, bpm);
+}
+
 std::optional<EffectSlot> effectFromFl (const std::string& pluginName, const std::vector<std::uint8_t>& state, double bpm)
 {
+    if (pluginName == "Maximus") // FL's own engine from the saved state (REA_rodada36/38); the approximation otherwise
+        if (auto exact = maximusExact (state))
+            return exact;
     if (pluginName == "Effector")
         return effector (state, bpm);
     if (pluginName == "Fruity Vocoder")

+ 19 - 0
src/core/FlEffects.h

@@ -19,6 +19,22 @@ namespace lynx
 // `bpm` converts tempo-synced times (e.g. Reeverb 2 predelay) to milliseconds.
 std::optional<EffectSlot> effectFromFl (const std::string& pluginName, const std::vector<std::uint8_t>& state, double bpm = 120.0);
 
+// A file of the user's FL installation by its path relative to %FLStudioFactoryData% (e.g.
+// "Plugins\\Fruity\\Effects\\Soundgoodizer\\Data\\Presets\\a.dat"); empty = not available
+using FlDataReader = std::function<std::vector<std::uint8_t> (const std::string& relativePath)>;
+// The same, with access to the installation's data files: Soundgoodizer becomes the exact engine with its preset
+// file (REA_rodada40 §3); without them (or with an unreadable file) the approximation is used.
+std::optional<EffectSlot> effectFromFl (const std::string& pluginName, const std::vector<std::uint8_t>& state, double bpm,
+                                        const FlDataReader& data);
+
+// FL's Maximus as the exact engine (EffectKind::maximus) when its state is supported (REA_rodada36/38); nullopt =
+// a feature that is not decoded (the caller keeps the approximation)
+std::optional<EffectSlot> maximusExact (const std::vector<std::uint8_t>& state);
+// Soundgoodizer as the exact engine from its state and the preset file it names (a…d.dat, read by the caller)
+std::optional<EffectSlot> soundgoodizerExact (const std::vector<std::uint8_t>& state, const std::vector<std::uint8_t>& presetFile);
+// The installation path (relative to %FLStudioFactoryData%) of the preset file a Soundgoodizer state loads
+std::string soundgoodizerPresetPath (const std::vector<std::uint8_t>& state);
+
 // FL effect preset (.fst from Plugin presets\Effects): the built-in effect with the preset's settings.
 std::optional<EffectSlot> effectFromFlPreset (const std::vector<std::uint8_t>& fileBytes, double bpm = 120.0);
 
@@ -77,6 +93,9 @@ struct VocodexConversion
     std::vector<std::string> notes;
 };
 std::optional<VocodexConversion> vocodexEffect (const std::vector<std::uint8_t>& state);
+// The same, with the installation's data files appended to the slot (SG.dat for the SG stage, the internal carrier's
+// Sytrus preset; REA_rodada40 §4–5)
+std::optional<VocodexConversion> vocodexEffect (const std::vector<std::uint8_t>& state, const FlDataReader& data);
 // LYNX's Soundgoodizer approximation (REA_rodada8; preset 0…3 = A…D, amount 0…1000): the compressor followed by
 // the presets' −0.2 dB master limiter
 std::vector<EffectSlot> soundgoodizerApproximation (int preset, int amount);

+ 52 - 6
src/core/FlpImport.cpp

@@ -4,6 +4,7 @@
 #include "core/Harmless.h"
 #include "core/Morphine.h"
 #include "core/Harmor.h"
+#include "core/Ogun.h"
 #include "core/HarmlessFx.h"
 #include "core/SytrusEngine.h"
 #include "core/PhysicalModels.h"
@@ -431,6 +432,14 @@ std::optional<SynthSettings> synthFromFlPreset (const std::vector<std::uint8_t>&
             if (synthFromHarmor (project.channels.front().pluginState, synth, gain))
                 return synth;
         }
+        if (! song.channels.empty() && song.channels.front().instrument == InstrumentKind::ogun)
+        {
+            // ... and of an Ogun / Autogun patch (the spectral-oscillator conversion)
+            SynthSettings synth;
+            float gain = 1.0f;
+            if (synthFromOgun (project.channels.front().pluginState, synth, gain))
+                return synth;
+        }
         if (song.channels.empty() || song.channels.front().instrument != InstrumentKind::synth)
             return std::nullopt;
 
@@ -921,8 +930,19 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                 else if (synthFromGms (c.pluginState, song.bpm, fromPlugin, pluginGain))
                     adopt();
             }
-            else if ((name == "ogun" || name == "autogun") && synthFromOgun (c.pluginState, fromPlugin, pluginGain))
-                adopt();
+            else if (name == "ogun" || name == "autogun")
+            {
+                // FL's inverse-FFT engine from the raw state (REA_rodada37); Autogun (its own state variant and DLL, not
+                // verified in round 37) and states the engine can't read keep the spectral-oscillator conversion
+                if (name == "ogun" && ogunStateUsable (c.pluginState))
+                {
+                    def.instrument = InstrumentKind::ogun;
+                    def.pluginState = c.pluginState;
+                    adoptedFromPlugin = true;
+                }
+                else if (synthFromOgun (c.pluginState, fromPlugin, pluginGain))
+                    adopt();
+            }
             else if (name == "sakura")
             {
                 // the physical string model (REA_rodada28 §1); the old saw + triangle stays as a fallback
@@ -1078,7 +1098,8 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                      || def.instrument == InstrumentKind::boobass || def.instrument == InstrumentKind::drumsynth
                      || def.instrument == InstrumentKind::harmless || def.instrument == InstrumentKind::sytrus
                      || def.instrument == InstrumentKind::harmor || def.instrument == InstrumentKind::gms
-                     || def.instrument == InstrumentKind::morphine)
+                     || def.instrument == InstrumentKind::morphine
+                     || def.instrument == InstrumentKind::ogun)
                 ++r.converted[c.pluginName]; // FL's own engine rebuilt from the plugin state
             else if ((plugin == "harmless" && def.instrument != InstrumentKind::harmless) || (plugin == "harmor" && def.instrument != InstrumentKind::harmor && adoptedFromPlugin) || plugin == "minisynth" || plugin == "fruity dx10" || plugin == "dx10" || plugin == "fruit kick"
                      || ((plugin == "sytrus" || plugin == "gms" || plugin == "ogun" || plugin == "autogun" || plugin == "sakura" || plugin == "kepler" || plugin == "boobass" || plugin == "drumpad" || plugin == "poizone" || plugin == "bassdrum"
@@ -1167,6 +1188,24 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
     };
     std::map<std::pair<int, int>, decltype (LovePhilterConversion::paramMap)> lovePhilterMaps; // Love Philter automation
 
+    // data files of the user's FL installation that some effects load at run time (Soundgoodizer's presets,
+    // REA_rodada40); nothing of them is stored in LYNX itself, only in the imported project
+    const FlDataReader flData = [&options] (const std::string& relative) -> std::vector<std::uint8_t> {
+        const auto path = resolveFlPath ("%FLStudioFactoryData%\\" + relative, options.roots);
+        if (path.empty() || ! options.readFile || (options.fileExists && ! options.fileExists (path)))
+            return {};
+        return options.readFile (path);
+    };
+    // exact engines that fell back to their approximation (for the report)
+    auto noteFallback = [&options] (const std::string& plugin, const EffectSlot& fx) {
+        if (options.report == nullptr || fx.kind == EffectKind::maximus)
+            return;
+        if (plugin == "Maximus")
+            ++options.report->droppedEffects["Maximus (option not decoded: approximated)"];
+        else if (plugin == "Soundgoodizer")
+            ++options.report->droppedEffects["Soundgoodizer (preset file not found: approximated)"];
+    };
+
     for (const auto& insert : project.mixer)
     {
         if (insert.index < 0 || insert.index >= tracks)
@@ -1237,8 +1276,11 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                                     if (! head.note.empty() && options.report != nullptr)
                                         ++options.report->droppedEffects[head.note];
                                 }
-                                else if (auto fx = effectFromFl (node.plugin, node.state, song.bpm); fx && fx->kind != EffectKind::plugin)
+                                else if (auto fx = effectFromFl (node.plugin, node.state, song.bpm, flData); fx && fx->kind != EffectKind::plugin)
+                                {
+                                    noteFallback (node.plugin, *fx);
                                     chain.push_back (std::move (*fx));
+                                }
                                 else if (options.report != nullptr)
                                     ++options.report->droppedEffects[node.plugin + " (in Patcher)"];
                                 break;
@@ -1318,7 +1360,11 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                     made->plugin.foreign = std::move (foreign);
                 }
                 else
-                    made = effectFromFl (slot.plugin, slot.state, song.bpm); // native effect with the saved settings (REA_rodada7)
+                {
+                    made = effectFromFl (slot.plugin, slot.state, song.bpm, flData); // native effect with the saved settings (REA_rodada7)
+                    if (made)
+                        noteFallback (slot.plugin, *made);
+                }
 
                 if (! made)
                 {
@@ -1357,7 +1403,7 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
                 else if (slot.plugin == "Vocodex")
                 {
                     // ModIn/CarIn index the same inputs list as the sidechains (REA_rodada22 §1)
-                    if (const auto v = vocodexEffect (slot.state))
+                    if (const auto v = vocodexEffect (slot.state, flData))
                     {
                         fx.sidechain = sidechainSource (insert.index, v->modIn);
                         fx.sidechain2 = sidechainSource (insert.index, v->carIn);

+ 378 - 129
src/core/HarmlessFx.cpp

@@ -1,4 +1,5 @@
 #include "core/HarmlessFx.h"
+#include "core/PlateReverb.h"
 
 #include <algorithm>
 #include <cmath>
@@ -23,11 +24,10 @@ const double ln001 = std::log (0.01);
 
 inline float f32 (double x) noexcept { return (float) x; }
 inline double rint (double x) noexcept { return std::nearbyint (x); } // round half to even (cvtsd2si)
-inline float flush (double v) noexcept
-{
-    const auto f = (float) v;
-    return std::fabs (f) < flushLevel ? 0.0f : f;
-}
+// FUN_00627cc0 (x87): a double state below 2^-24 in magnitude becomes 0; the others are kept as they are (the
+// decompiler shows a float conversion that the instructions do not do: fldl / fcmovb / fstpl, REA_rodada40 §2.4)
+inline double flushState (double v) noexcept { return std::fabs (v) < (double) flushLevel ? 0.0 : v; }
+
 
 // (11^x − 1)/10, exactly 1 at x = 1 (ln 11 as the float of the plugin's run-time global)
 float g11 (float x) noexcept
@@ -192,13 +192,21 @@ struct MaximusPreset
         double end = 0.0, peak = 1.0;
         std::vector<float> sat;   // soft-saturation table (mode A), 65 538 entries; empty = none
         float satOut = 0.0f, satIn = 0.0f;
+        int satB = 0;             // 1: saturation mode B (REA_rodada40 §2.2) with threshold satT and range satR
+        float satT = 0.0f, satR = 1.0f, satK = 1.0f;
+        int mode = 3;             // effective mode (solo applied, FUN_008417e0)
+        bool rms = false;         // envelope mode RMS (REA_rodada40 §2.1)
         float pre = 1.0f, post = 1.0f, g20 = 1.0f;
         std::array<float, 4> matrix { 1.0f, 1.0f, 0.0f, 0.0f };
     };
     std::array<Band, 4> band {};
     bool valid = false;
+    bool legacyFir = false; // "Linear-phase filters (legacy mode)": windowed-sinc FIR band split (FUN_0083c200)
+    MaximusBuild build = MaximusBuild::shared;
 };
 
+
+
 namespace
 {
 std::vector<Point> readCurve (const std::vector<std::uint8_t>& d, std::size_t& pos, bool& ok)
@@ -248,8 +256,41 @@ std::vector<Point> readCurve (const std::vector<std::uint8_t>& d, std::size_t& p
 }
 
 // FUN_00845b50
-void buildGainTable (Curve& curve, float scale, MaximusPreset::Band& b)
+void buildGainTable (Curve& curve, float scale, MaximusPreset::Band& b, bool soundgoodizer)
 {
+    if (soundgoodizer)
+    {
+        // Soundgoodizer_x64.dll's older build (FUN_0083b050, REA_rodada40 §3.2): the saturated output snaps to the
+        // double 0.975 (not the float), the stored end value is the last output before the snap and the peak is
+        // divided by the float 0.975
+        curve.start();
+        b.gain.assign (32770, 0.0f);
+        const auto dv9 = 0.5 / std::log (3.0), dv10 = std::log (3.0) * 2.0, half = 0.48750001192092896;
+        double prev = 0.0, out = 0.0, mx = 0.0, last = 0.0;
+        int lastOk = 0;
+        for (int i = 0; i < 32769; ++i)
+        {
+            const auto lv = (double) std::max (i, 1);
+            const auto c = std::log (lv * 0.0001220703125 * 2.0 + 1.0) * dv9;
+            const auto y = curve.step (c - prev);
+            prev = c;
+            out = (std::exp (y * dv10) - 1.0) * half;
+            auto idx = i;
+            auto keep = out;
+            if (std::fabs (out - 0.975) < 5.960464477539063e-08)
+                out = 0.975, idx = lastOk, keep = last;
+            mx = std::max (mx, out);
+            b.gain[(std::size_t) i] = f32 (out / (lv * 0.0001220703125));
+            lastOk = idx;
+            last = keep;
+        }
+        b.gain[(std::size_t) lastOk + 1] = b.gain[(std::size_t) lastOk];
+        b.gain.resize ((std::size_t) lastOk + 2);
+        b.size = lastOk;
+        b.end = last;
+        b.peak = mx / 0.9750000238418579;
+        return;
+    }
     curve.start();
     b.gain.assign (32770, 0.0f);
     const auto dv9 = 0.5 / std::log (3.0), dv10 = std::log (3.0) * 2.0, dv14 = (double) scale * 0.5;
@@ -277,7 +318,7 @@ void buildGainTable (Curve& curve, float scale, MaximusPreset::Band& b)
 }
 
 // FUN_00841380, mode A (threshold < 0)
-void buildSaturation (int thr, float ceil, double top, MaximusPreset::Band& b)
+void buildSaturation (int thr, float ceil, double top, MaximusPreset::Band& b, bool soundgoodizer)
 {
     const auto p = (double) f32 ((float) (20.0f - f32 ((float) std::log ((double) f32 (f32 (thr * -0.1) + 1.0f)) / std::log (101.0)) * 19.0f));
     const auto ip = 1.0 / p;
@@ -289,12 +330,19 @@ void buildSaturation (int thr, float ceil, double top, MaximusPreset::Band& b)
     for (int i = 0; i <= 65536; ++i)
     {
         auto v = std::pow (std::atan (std::pow (i * d, p)), ip) * norm;
+        if (soundgoodizer)
+        {
+            // FUN_00837d90: a 16-bit table, round(v·32767) clamped to ±32767, read back ×ceiling/32768
+            const auto q = std::clamp (std::nearbyint (v * 32767.0), -32767.0, 32767.0);
+            b.sat[(std::size_t) i] = (float) q;
+            continue;
+        }
         if (v < 5.960464477539063e-08)
             v = 0.0;
         b.sat[(std::size_t) i] = (float) v;
     }
     b.sat[65537] = b.sat[65536];
-    b.satOut = ceil;
+    b.satOut = soundgoodizer ? f32 ((double) ceil * 3.0517578125e-05) : ceil;
     b.satIn = f32 (1.0 / top);
 }
 } // namespace
@@ -340,23 +388,47 @@ std::optional<std::vector<std::uint8_t>> maximusStateFromFst (const std::vector<
 
 std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::uint8_t>& d)
 {
+    return makeMaximusPreset (d, MaximusBuild::shared);
+}
+
+std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::uint8_t>& d, MaximusBuild build)
+{
+    const auto sgz = build == MaximusBuild::soundgoodizer;
+    if (sgz && (std::uint32_t) i32At (d, 0) > 13)
+        return nullptr; // that build's loader stops after the fixed block (no v14+ options)
     if (d.size() < 0x1fe + 12)
         return nullptr;
     auto m = std::make_shared<MaximusPreset>();
+    m->build = build;
     const auto header = (std::uint32_t) i32At (d, 0);
     const auto version = header > 0xFFFFu ? (int) (header >> 16) : (int) header;
-    if (version < 7)
-        return nullptr; // older layouts are not used by Harmless's presets
+    if (version < 3)
+        return nullptr; // the pre-v3 piecewise layout is not used by any preset or demo state
+    // fixed block read raw into the object (FUN_0083ef50): 0x1FA bytes for v ≥ 7, 0x1F9 (v6), 0x1F5 (v5), 0x1F1 (v4),
+    // 0x1EE (v3); the bytes the block does not reach keep the plugin's reset values (0)
+    const std::size_t block = version >= 7 ? 0x1fa : version == 6 ? 0x1f9 : version == 5 ? 0x1f5 : version == 4 ? 0x1f1 : 0x1ee;
+    if (d.size() < 4 + block)
+        return nullptr;
+    auto byteAt = [&] (std::size_t at) { return at < 4 + block ? (int) d[at] : 0; };
     for (int i = 0; i < 59; ++i)
         m->p[(std::size_t) i] = i32At (d, 4 + 4 * (std::size_t) i);
-    m->oversampling = i32At (d, 0x1f4);
+    m->oversampling = byteAt (0x1f4) | (byteAt (0x1f5) << 8) | (byteAt (0x1f6) << 16) | (byteAt (0x1f7) << 24);
     if (m->oversampling < 0 || m->oversampling > 1)
-        return nullptr; // only ×1 and ×2 are used by Harmless's presets
-    std::size_t pos = 0x1fe;
+        return nullptr; // only ×1 and ×2 are used by the presets and the demo projects
+    // menu options read with the block: "Master Mid mode" (+0x324) is not decoded for rendering; the legacy
+    // linear-phase FIR crossover (+0x325) and solo (+0x317) of the editor's band (+0x308) are (REA_rodada40 §2.5)
+    if (byteAt (0x1fc) != 0)
+        return nullptr;
+    m->legacyFir = byteAt (0x1fd) != 0;
+    const auto solo = byteAt (0x1ef) != 0;
+    const auto soloBand = i32At (d, 0x1e0);
+    std::size_t pos = 4 + block;
     if (version >= 14)
     {
         if ((d[pos + 8] & 0x40) != 0)
             m->scale = 1.0f;
+        if ((d[pos + 8] & 0x01) != 0)
+            return nullptr; // linear-phase band split through Frequency Splitter's engine_x64.dll: not decoded
         pos += 9 + 20;
     }
     if (version >= 15)
@@ -388,16 +460,31 @@ std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::u
         Curve curve (env[(std::size_t) (2 * b)]);
         if (! curve.supported())
             return nullptr;
-        buildGainTable (curve, m->scale, B);
+        buildGainTable (curve, m->scale, B, sgz);
         B.g20 = (B.pre * B.post) * B.gain[0];
+        // effective mode (FUN_008417e0): with solo on and another band selected, the master is at least
+        // "compression off" and the other bands are muted
+        B.mode = mode;
+        if (solo && soloBand != 3 && b != soloBand)
+            B.mode = std::max (B.mode, b == 3 ? 1 : 2);
+        B.rms = q (19) != 0;
         const auto thr = q (11);
-        if (thr > 0)
-            return nullptr; // saturation mode B: not decoded (not used by Harmless's or Harmor's presets)
         if (thr < 0)
         {
             const auto top0 = (q (19) == 0 && mode < 1) ? B.peak : 4.0;
             const auto ceil = l7 (q (12));
-            buildSaturation (thr, ceil, std::max (top0 * (double) B.post, (double) ceil), B);
+            buildSaturation (thr, ceil, std::max (top0 * (double) B.post, (double) ceil), B, sgz);
+        }
+        else if (thr > 0)
+        {
+            // mode B (FUN_00841380 → FUN_00629fd0): threshold t = (1 − thr/1000)·ceiling, range = ceiling − t
+            const auto ceil = l7 (q (12));
+            B.satB = 1;
+            B.satT = f32 ((double) (1.0f - (float) thr * 0.001f) * (double) ceil);
+            B.satR = ceil - B.satT;
+            if (B.satR <= 0.0f)
+                B.satR = 1.5258789e-05f;
+            B.satK = 1.0f / B.satR;
         }
     }
     m->valid = true;
@@ -407,7 +494,7 @@ std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::u
 namespace
 {
 // FUN_00624580 (types 1 low-pass, 4 high-pass, 5 all-pass) + FUN_00624e90 (stereo direct form I in double, the
-// states rounded to float at the end of every block)
+// states flushed below 2^-24 at the end of every block, kept in double)
 struct Biquad
 {
     int type = 1;
@@ -445,7 +532,8 @@ struct Biquad
             lx2 = lx1, lx1 = xl, ly2 = ly1, ly1 = yl;
             rx2 = rx1, rx1 = xr, ry2 = ry1, ry1 = yr;
         }
-        s = { flush (lx1), flush (lx2), flush (ly1), flush (ly2), flush (rx1), flush (rx2), flush (ry1), flush (ry2) };
+        s = { flushState (lx1), flushState (lx2), flushState (ly1), flushState (ly2),
+              flushState (rx1), flushState (rx2), flushState (ry1), flushState (ry2) };
     }
 };
 
@@ -477,7 +565,7 @@ struct Halfband
     {
         for (int c = 0; c < 2; ++c)
             for (int k : { 0, 1, 2, 6, 7, 8 })
-                s[(std::size_t) (12 * c + k)] = flush (s[(std::size_t) (12 * c + k)]);
+                s[(std::size_t) (12 * c + k)] = flushState (s[(std::size_t) (12 * c + k)]);
     }
 
     void up (const float* inL, const float* inR, float* outL, float* outR, int n) noexcept
@@ -517,25 +605,39 @@ struct Halfband
     }
 };
 
-// FUN_00605410: one-pole on a control signal, c0 while the input is ≥ the state, c1 otherwise
+// FUN_00605410 (x87): one-pole on a control signal, c0 while the input is ≥ the state, c1 otherwise. The state stays
+// on the x87 stack (64-bit mantissa) through the block, the coefficients are doubles and only the output samples are
+// rounded to float; between blocks the state is kept as a double, 0 below 2^-24 (REA_rodada40 §2.4). long double is
+// the 80-bit x87 format on the x86-64 GCC/Clang/MinGW targets LYNX is built for.
 struct Smoother
 {
-    float c0 = 0.0f, c1 = 0.0f, s = 0.0f;
+    double c0 = 0.0, c1 = 0.0, s = 0.0;
 
     void run (float* x, int n) noexcept
     {
-        auto st = s;
+        long double st = s;
         if (c0 == c1)
+        {
+            const long double c = c0;
             for (int i = 0; i < n; ++i)
-                st = (st - x[i]) * c0 + x[i], x[i] = st;
+            {
+                const long double v = x[i];
+                st = (st - v) * c + v;
+                x[i] = (float) st;
+            }
+        }
         else
+        {
+            const long double k0 = c0, k1 = c1;
             for (int i = 0; i < n; ++i)
             {
-                const auto c = st <= x[i] ? c0 : c1;
-                st = x[i] + c * (st - x[i]);
-                x[i] = st;
+                const long double v = x[i];
+                const auto c = v >= st ? k0 : k1;
+                st = (st - v) * c + v;
+                x[i] = (float) st;
             }
-        s = std::fabs (st) > flushLevel ? st : 0.0f;
+        }
+        s = std::fabs ((double) st) > (double) flushLevel ? (double) st : 0.0;
     }
 };
 
@@ -610,9 +712,9 @@ struct PeakWindow
     }
 };
 
-// the RMS detector (envelope mode 1; SG class at 0x780020, process FUN_00780b90 + FUN_00780ab0/FUN_00780a60,
-// REA_rodada38 §R): L² + R² summed over the last W samples (a float running sum kept as a double between blocks),
-// scaled by 1/(2W) (the sum kept in x87 extended precision), clamped below at 0 (ippsThreshold_LT) and square-rooted (ippsSqrt)
+// the RMS detector (envelope mode 1; SG class at 0x780020, process FUN_00780b90 with the window kernel FUN_00780a60;
+// REA_rodada38, REA_rodada40 §2.1): L² + R² summed over the last W samples in an x87 running sum (kept as a double
+// between blocks), scaled by 1/(2W), clamped below at 0 (ippsThreshold_LT_32f_I) and square-rooted (ippsSqrt_32f_I)
 struct RmsWindow
 {
     int W = 1, idx = 0;
@@ -656,6 +758,17 @@ struct RmsWindow
     }
 };
 
+// saturation mode B (FUN_0062a090, x87): above the threshold t, |y| = t + range·(1 − e^((t − |x|)/range)), sign kept
+inline float saturateB (float x, float t, float range, float k) noexcept
+{
+    const auto a = std::fabs (x);
+    if (! (a > t))
+        return x;
+    const auto e = std::exp ((long double) ((long double) t - (long double) a) * (long double) k);
+    const auto y = (float) ((1.0L - e) * (long double) range + (long double) t);
+    return std::signbit (x) ? -y : y;
+}
+
 // FUN_0077f350: L-frame delay (swap ring)
 struct FrameDelay
 {
@@ -692,6 +805,131 @@ struct FrameDelay
 };
 } // namespace
 
+namespace
+{
+// the legacy linear-phase band split (REA_rodada40 §2.5): FUN_0083c0d0 (windowed sinc), FUN_0062ac70 type 0 (4-term
+// Blackman-Harris), FUN_0083c070 (spectral inversion), FUN_0083c200 (placement in the N-tap buffer), taps converted to
+// float and run by ippsFIR_32f per channel (FUN_0083bce0)
+std::vector<double> sincLowpass (int L, double fc)
+{
+    std::vector<double> h ((std::size_t) L);
+    const auto w = fc * 6.283185307179586;
+    for (int i = 0; i < L; ++i)
+    {
+        if (i == (L - 1) / 2)
+            h[(std::size_t) i] = fc * 2.0;
+        else
+        {
+            const auto d = (double) ((float) i - (float) (L - 1) * 0.5f);
+            h[(std::size_t) i] = std::sin (w * d) / (d * 3.141592653589793);
+        }
+    }
+    const auto a = 6.283185307179586 / (double) (L - 1);
+    for (int i = 0; i < L; ++i)
+    {
+        const auto c1 = std::cos (a * (double) i), c2 = std::cos (a * 2.0 * (double) i), c3 = std::cos (a * 3.0 * (double) i);
+        h[(std::size_t) i] *= ((0.35875 - c1 * 0.48829) + c2 * 0.14128) - c3 * 0.01168;
+    }
+    return h;
+}
+
+void invert (std::vector<double>& h)
+{
+    for (auto& v : h)
+        v *= -1.0;
+    h[(h.size() - 1) / 2] += 1.0;
+}
+
+// kind 0 low-pass (f1, L1), 3 high-pass (f1, L1), 1 band-pass (f1, L1 / f2, L2); placed in the middle of N taps
+std::vector<float> legacyTaps (int N, int kind, double f1, int L1, double f2, int L2)
+{
+    std::vector<double> buf ((std::size_t) N, 0.0);
+    f1 = std::min (f1, 0.5), f2 = std::min (f2, 0.5);
+    L1 |= 1, L2 |= 1;
+    auto place = [&] (std::vector<double>& to, const std::vector<double>& h) {
+        const auto at = (N - (int) h.size()) / 2;
+        for (std::size_t i = 0; i < h.size(); ++i)
+            to[(std::size_t) at + i] = h[i];
+    };
+    if (kind == 0)
+        place (buf, sincLowpass (L1, f1));
+    else if (kind == 3)
+    {
+        auto h = sincLowpass (L1, f1);
+        invert (h);
+        place (buf, h);
+    }
+    else
+    {
+        std::vector<double> hi ((std::size_t) N, 0.0);
+        place (buf, sincLowpass (L1, f1));
+        auto h = sincLowpass (L2, f2);
+        invert (h);
+        place (hi, h);
+        for (int i = 0; i < N; ++i)
+            buf[(std::size_t) i] += hi[(std::size_t) i];
+        if (kind == 1)
+            invert (buf);
+    }
+    std::vector<float> taps ((std::size_t) N);
+    for (int i = 0; i < N; ++i)
+        taps[(std::size_t) i] = (float) buf[(std::size_t) i];
+    return taps;
+}
+
+struct Fir
+{
+    std::vector<float> taps, rev;           // rev: the taps in time order of the history (oldest first)
+    std::array<std::vector<float>, 2> hist; // the last N − 1 inputs, then the block
+
+    void reset() noexcept
+    {
+        for (auto& h : hist)
+            std::fill (h.begin(), h.end(), 0.0f);
+    }
+
+    void prepare (std::vector<float> t, int maxFrames)
+    {
+        taps = std::move (t);
+        rev.assign (taps.rbegin(), taps.rend());
+        for (auto& h : hist)
+            h.assign (taps.size() - 1 + (std::size_t) maxFrames, 0.0f);
+    }
+
+    void process (const float* inL, const float* inR, float* outL, float* outR, int n) noexcept
+    {
+        const auto N = (int) taps.size();
+        const float* in[2] { inL, inR };
+        float* out[2] { outL, outR };
+        for (int c = 0; c < 2; ++c)
+        {
+            auto& h = hist[(std::size_t) c];
+            std::copy (in[c], in[c] + n, h.begin() + (N - 1));
+            // double accumulation in four interleaved partial sums (IPP's own summation order is not known; the
+            // difference stays far below the float output's rounding)
+            const float* rt = rev.data();
+            for (int i = 0; i < n; ++i)
+            {
+                const float* x = h.data() + i;
+                double a0 = 0.0, a1 = 0.0, a2 = 0.0, a3 = 0.0;
+                int k = 0;
+                for (; k + 4 <= N; k += 4)
+                {
+                    a0 += (double) rt[k] * (double) x[k];
+                    a1 += (double) rt[k + 1] * (double) x[k + 1];
+                    a2 += (double) rt[k + 2] * (double) x[k + 2];
+                    a3 += (double) rt[k + 3] * (double) x[k + 3];
+                }
+                for (; k < N; ++k)
+                    a0 += (double) rt[k] * (double) x[k];
+                out[c][i] = (float) ((a0 + a1) + (a2 + a3));
+            }
+            std::copy (h.begin() + n, h.begin() + n + (N - 1), h.begin());
+        }
+    }
+};
+} // namespace
+
 class Maximus
 {
 public:
@@ -708,7 +946,7 @@ public:
         mixOn = mix != 1.0f;
         std::array<int, 4> mode {};
         for (int b = 0; b < 4; ++b)
-            mode[(std::size_t) b] = p[(std::size_t) (7 + 13 * b)];
+            mode[(std::size_t) b] = P.band[(std::size_t) b].mode;
         const auto anyComp = mode[0] < 1 || mode[1] < 1 || mode[2] < 1;
         int latency = 0;
         for (int b = 0; b < 4; ++b)
@@ -730,20 +968,22 @@ public:
             const auto rel2N = q (14) == 0 ? attN : (tms (q (14)) * 2.0 * 0.001 * fs * k * 2.0) / std::sqrt ((double) na);
             const auto sus = (int) rint (tms (q (18)) * 2.0 * 0.001 * fs);
             B.det.setLength (std::max (std::max (L, 1), sus * k));
-            B.rms = q (19) != 0;
+            B.rms = P.band[(std::size_t) b].rms;
             if (B.rms)
                 B.rmsDet.setLength (std::max (std::max (L, 1), sus * k));
-            B.att.assign ((std::size_t) na, Smoother { f32 (coefFor (rel2N)), f32 (coefFor (attN)), 0.0f });
+            B.att.assign ((std::size_t) na, Smoother { coefFor (rel2N), coefFor (attN), 0.0 });
             const auto R = tms (q (16)) * 2.0 * 0.001 * fs * k;
             B.rel.clear();
             if (R > 0.0)
             {
                 const auto nr = std::max (1, q (17));
-                B.rel.assign ((std::size_t) nr, Smoother { 0.0f, f32 (coefFor ((R * 2.0) / std::sqrt ((double) nr))), 0.0f });
+                B.rel.assign ((std::size_t) nr, Smoother { 0.0, coefFor ((R * 2.0) / std::sqrt ((double) nr)), 0.0 });
             }
             B.delay.setLength (L);
         }
+        const auto latencyBands = latency;
         latency = latency / K + band[3].L;
+        reportedLatency = latency;
         tailLength = latency + (int) rint (fs * 1.5);
 
         // crossover (FUN_00844e10)
@@ -771,9 +1011,12 @@ public:
         };
         for (auto& s : stages)
             s.clear();
-        const auto n0 = sL + (sH > 0 ? 1 : 0) + 1;
+        // the low band's all-pass at the high crossover (phase match with a 24 dB high split) is absent from the
+        // older build in Soundgoodizer_x64.dll (FUN_0083a4a0: sL + 1 low-pass stages only)
+        const auto allPass = sH > 0 && P.build == MaximusBuild::shared;
+        const auto n0 = sL + (allPass ? 1 : 0) + 1;
         for (int i = 0; i < n0; ++i)
-            stages[0].push_back (i == n0 - 1 && sH > 0 ? stage (5, fH, 0) : stage (1, fL, sL));
+            stages[0].push_back (i == n0 - 1 && allPass ? stage (5, fH, 0) : stage (1, fL, sL));
         for (int i = 0; i <= sL; ++i)
             stages[1].push_back (stage (4, fL, sL));
         for (int i = 0; i <= sH; ++i)
@@ -781,6 +1024,35 @@ public:
         for (int i = 0; i <= sH; ++i)
             stages[2].push_back (stage (4, fH, sH));
         inPlaceStages = std::min (sL + 1, (int) stages[1].size() - 1);
+        firOn = P.legacyFir;
+        if (firOn)
+        {
+            // FUN_00840bb0: N = round(0.004·band rate) | 1 (≥ 5); FUN_00844e10: per split round(K·c·(slope + 1)/f) | 1
+            // (≥ 5, ≤ N) with c = 27 500 (the high split of Soundgoodizer_x64.dll's build: 110 000)
+            auto N = (int) rint (rateB * 0.004) | 1;
+            N = std::max (N, 5);
+            auto len = [&] (double c, int slope, float f) {
+                const auto v = (double) K * c * (double) (slope + 1) / (double) f;
+                auto L = (int) rint (v);
+                L = (L | 1) < 6 ? 5 : (L | 1);
+                return std::min (L, N);
+            };
+            const auto Ll = len (27500.0, sL, fL);
+            const auto Lh = len (P.build == MaximusBuild::soundgoodizer ? 110000.0 : 27500.0, sH, fH);
+            const auto nl = (double) (float) (fL / (float) rateB), nh = (double) (float) (fH / (float) rateB);
+            fir[0].prepare (legacyTaps (N, 0, nl, Ll, 0.0, 0), maxFrames);
+            if (sL < 0)
+                fir[1].prepare (sH >= 0 ? legacyTaps (N, 0, nh, Lh, 0.0, 0) : std::vector<float> ((std::size_t) N, 0.0f), maxFrames);
+            else if (sH < 0)
+                fir[1].prepare (legacyTaps (N, 3, nl, Ll, 0.0, 0), maxFrames);
+            else
+                fir[1].prepare (legacyTaps (N, 1, nl, Ll, nh, Lh), maxFrames);
+            fir[2].prepare (legacyTaps (N, 3, nh, Lh, 0.0, 0), maxFrames);
+            band[0].g18 = band[2].g18 = 1.0f;
+            firLatency = (N - 1) / 2;
+            reportedLatency = (latencyBands + firLatency) / K + band[3].L;
+            tailLength = reportedLatency + (int) rint (fs * 1.5);
+        }
 
         // low cut: four high-pass stages at 0.8·f (FUN_00840b40, FUN_0083a5c0)
         lowCut.clear();
@@ -818,6 +1090,8 @@ public:
                 q.reset();
         for (auto& q : lowCut)
             q.reset();
+        for (auto& f : fir)
+            f.reset();
         for (auto& h : up)
             h.reset();
         for (auto& h : down)
@@ -871,6 +1145,8 @@ public:
             float* yr = br.data();
             if (st.empty())
                 std::copy (XL, XL + nb, yl), std::copy (XR, XR + nb, yr);
+            else if (firOn) // the legacy linear-phase split: every band from the input (FUN_0083bce0)
+                fir[(std::size_t) b].process (XL, XR, yl, yr, nb);
             else if (b == 1 && b != first)
             {
                 const float* sl = XL;
@@ -899,7 +1175,15 @@ public:
             processBand (b, yl, yr, nb);
             if (B.mode < 2)
             {
-                if (! haveSum)
+                if (! haveSum && b == 2)
+                {
+                    // the high band is the first one on: its buffer is the sum buffer, and the final add (ippsAdd_32f
+                    // of the band and the sum) doubles it (FUN_00843a40)
+                    for (int i = 0; i < nb; ++i)
+                        sl[(std::size_t) i] = yl[i] + yl[i], sr[(std::size_t) i] = yr[i] + yr[i];
+                    haveSum = true;
+                }
+                else if (! haveSum)
                     std::copy (yl, yl + nb, sl.data()), std::copy (yr, yr + nb, sr.data()), haveSum = true;
                 else
                     for (int i = 0; i < nb; ++i)
@@ -1008,6 +1292,9 @@ private:
             for (int i = 0; i < n; ++i)
                 xl[i] = sat (xl[i]), xr[i] = sat (xr[i]);
         }
+        else if (S.satB != 0 && B.mode < 2)
+            for (int i = 0; i < n; ++i)
+                xl[i] = saturateB (xl[i], S.satT, S.satR, S.satK), xr[i] = saturateB (xr[i], S.satT, S.satR, S.satK);
         if (b == 3)
         {
             if (B.mode == 2)
@@ -1031,9 +1318,16 @@ private:
         }
     }
 
+public:
+    // FUN_00840a00: the latency the plugin reports to the host (PDC), max(L0…2)/K + L3
+    int latency() const noexcept { return reportedLatency; }
+
+private:
     std::shared_ptr<const MaximusPreset> pr;
     double fs = 44100.0;
-    int K = 1, first = 0, inPlaceStages = 0, tailLength = 0, counter = 0;
+    int K = 1, first = 0, inPlaceStages = 0, tailLength = 0, counter = 0, reportedLatency = 0, firLatency = 0;
+    bool firOn = false;
+    std::array<Fir, 3> fir {};
     float mix = 1.0f;
     bool mixOn = false;
     std::array<BandState, 4> band {};
@@ -1249,22 +1543,10 @@ struct Rack::Delay
 
 // the shared Reverb_x64.dll (REA_rodada31 §7.5) with the library wrapper's fields: lowcut Hz (0 off), highcut and
 // damping in hundreds of Hz (0 off), predelay samples, room, diffusion, decay in samples, colour
-struct ReverbUnit
+struct ReverbUnit : PlateReverb
 {
-    std::array<std::vector<float>, 12> buf;
-    std::array<int, 12> L {}, P {};
-    std::array<int, 7> tl {}, tr {};
-    std::vector<float> pre;
-    int pp = 0;
-    float cHc = 1, cLc = 0, cDamp = 1, cIn = 0, c1 = 0, c2 = 0, g = 0, c48 = 0, c44 = 0;
-    float s10 = 0, s14 = 0, s18 = 0, s3c = 0, s40 = 0, s4c = 0, s50 = 0, s54 = 0, s58 = 0;
-
     ReverbUnit (float lowcut, float highcut, int preS, int room, int diffusion, float decaySamples, float damping, int colourIndex, double fs)
     {
-        static constexpr int lines[12] { 142, 107, 379, 277, 672, 4453, 1800, 3720, 908, 4217, 2656, 3163 };
-        static constexpr int tapsL[7] { 266, 2974, 1913, 2496, 1690, 187, 1566 };
-        static constexpr int tapsR[7] { 353, 3627, 1728, 3173, 1811, 335, 621 };
-        static constexpr double colour[5] { 0.2, 0.6, 1.0, 1.5, 3.0 };
         const auto rate = (long long) fs;
         const auto decay = (double) decaySamples;
         const auto f17 = (double) f32 (1.0 / (double) rate), half = (double) f32 ((double) rate * 0.5);
@@ -1284,10 +1566,7 @@ struct ReverbUnit
         auto muldiv = [] (long long a, long long b, long long c) { return (int) ((a * b) / c); };
         const auto sc = muldiv (rate, room + 15, 115);
         for (int i = 0; i < 12; ++i)
-        {
             L[(std::size_t) i] = std::max (1, muldiv (lines[i], sc, 20000));
-            buf[(std::size_t) i].assign ((std::size_t) L[(std::size_t) i], 0.0f);
-        }
         for (int i = 0; i < 7; ++i)
             tl[(std::size_t) i] = muldiv (tapsL[i], sc, 20000), tr[(std::size_t) i] = muldiv (tapsR[i], sc, 20000);
         const auto dv = (double) f32 (diffusion * 0.01), f13 = (double) f32 (f17 * 0.5);
@@ -1298,85 +1577,13 @@ struct ReverbUnit
         }
         const auto ssum = (double) (L[5] + L[7] + L[9] + L[11]);
         g = f32 (std::pow (std::exp (std::log (0.001) * ssum / decay), 0.25));
-        auto r2 = (double) f32 ((double) f32 (std::pow (std::exp (std::log (0.001) * ssum / (double) f32 (decay * colour[std::clamp (colourIndex, 0, 4)])), 0.25)) / (double) g);
+        auto r2 = (double) f32 ((double) f32 (std::pow (std::exp (std::log (0.001) * ssum / (double) f32 (decay * colourFactor[std::clamp (colourIndex, 0, 4)])), 0.25)) / (double) g);
         c48 = f32 ((r2 - 1.0) * 0.5);
         if (r2 > 1.0)
             r2 = 1.0;
         const auto t = (double) f32 (std::tan (500.0 * pi * f17));
         c44 = f32 ((t - r2) / (t + r2));
-        pre.assign ((std::size_t) std::max (1, preS), 0.0f);
-    }
-
-    float ap (int i, float v, float c) noexcept
-    {
-        auto& p = P[(std::size_t) i];
-        auto& b = buf[(std::size_t) i];
-        const auto w = b[(std::size_t) p] - c * v;
-        b[(std::size_t) p] = c * w + v;
-        p = p > 0 ? p - 1 : L[(std::size_t) i] - 1;
-        return w;
-    }
-
-    float dl (int i, float v) noexcept
-    {
-        auto& p = P[(std::size_t) i];
-        auto& b = buf[(std::size_t) i];
-        const auto r = b[(std::size_t) p];
-        b[(std::size_t) p] = v;
-        p = p > 0 ? p - 1 : L[(std::size_t) i] - 1;
-        return r;
-    }
-
-    float tap (int i, int off) const noexcept
-    {
-        const auto k = off + P[(std::size_t) i];
-        return buf[(std::size_t) i][(std::size_t) (k >= L[(std::size_t) i] ? k - L[(std::size_t) i] : k)];
-    }
-
-    void process (const float* x, float* outL, float* outR, int n) noexcept
-    {
-        const auto t1 = 1.0f - g;
-        const auto w74 = t1 * 0.6f + g, w6c = t1 * 0.25f + g, w78 = t1 * 0.7f + g, w68 = t1 * 0.2f + g, w70 = t1 * 0.5f + g;
-        for (int i = 0; i < n; ++i)
-        {
-            auto a = ((x[i] + 1.0e-30f) - s10) * cHc + s10;
-            s10 = a;
-            const auto h = (a - s14) * cLc + s18;
-            s18 = a, s14 = h;
-            if (cLc != 0.0f)
-                a = (a - h) * 0.5f + 1.0e-30f;
-            for (int k = 0; k < 4; ++k)
-                a = ap (k, a, cIn);
-            const auto z = pre[(std::size_t) pp];
-            pre[(std::size_t) pp] = a;
-            pp = pp > 0 ? pp - 1 : (int) pre.size() - 1;
-            // half 1
-            auto u = buf[11][(std::size_t) P[11]] * g;
-            auto f = (u - s50) * c44 + s4c;
-            s4c = u, s50 = f;
-            auto v = (((f + u) * c48 + u + z) - s3c) * cDamp + s3c;
-            s3c = v;
-            auto w = ap (4, v, c1);
-            auto r = dl (5, w) * g;
-            auto w2 = ap (6, r, c2);
-            buf[7][(std::size_t) P[7]] = w2;
-            P[7] = P[7] > 0 ? P[7] - 1 : L[7] - 1;
-            // half 2
-            u = buf[7][(std::size_t) P[7]] * g;
-            f = (u - s58) * c44 + s54;
-            s54 = u, s58 = f;
-            v = (((f + u) * c48 + u + z) - s40) * cDamp + s40;
-            s40 = v;
-            w = ap (8, v, c1);
-            r = dl (9, w) * g;
-            w2 = ap (10, r, c2);
-            buf[11][(std::size_t) P[11]] = w2;
-            P[11] = P[11] > 0 ? P[11] - 1 : L[11] - 1;
-            outL[i] = (((tap (9, tl[0]) - w6c * tap (9, tl[1])) - w78 * tap (10, tl[2])) - w68 * tap (11, tl[3]))
-                      + w74 * tap (5, tl[4]) + tap (6, tl[5]) + w70 * tap (7, tl[6]);
-            outR[i] = ((((w6c * tap (5, tr[1]) + tap (5, tr[0])) - w78 * tap (6, tr[2])) - w68 * tap (7, tr[3]))
-                       - w74 * tap (9, tr[4])) + tap (10, tr[5]) + w70 * tap (11, tr[6]);
-        }
+        allocate (std::max (1, preS));
     }
 };
 
@@ -2173,3 +2380,45 @@ void HarmorRack::process (float* left, float* right, const float* fxL, const flo
 void HarmorRack::advance (int n) noexcept { d->advance (n); }
 bool HarmorRack::quiet() const noexcept { return ! d->on || d->quietFor >= d->quietNeeded; }
 } // namespace lynx::hlfx
+
+namespace lynx::hlfx
+{
+// =================================================================================================================
+// The engine on its own (mixer Maximus, Soundgoodizer, Vocodex's SG stage; REA_rodada40)
+// =================================================================================================================
+
+MaximusProcessor::MaximusProcessor() = default;
+MaximusProcessor::~MaximusProcessor() = default;
+
+void MaximusProcessor::prepare (std::shared_ptr<const MaximusPreset> preset, double sampleRate, int mixParameter)
+{
+    if (preset == nullptr)
+    {
+        engine.reset();
+        return;
+    }
+    engine = std::make_unique<Maximus>();
+    engine->prepare (std::move (preset), sampleRate, mixParameter);
+}
+
+void MaximusProcessor::process (float* left, float* right, int n) noexcept
+{
+    if (engine == nullptr)
+        return;
+    for (int done = 0; done < n; done += Rack::maxBlock)
+    {
+        const auto len = std::min (Rack::maxBlock, n - done);
+        engine->process (left + done, right + done, len);
+    }
+}
+
+void MaximusProcessor::reset() noexcept
+{
+    if (engine != nullptr)
+        engine->reset();
+}
+
+int MaximusProcessor::latencySamples() const noexcept { return engine != nullptr ? engine->latency() : 0; }
+
+int maximusMixParameter (const MaximusPreset& preset) noexcept { return preset.p[5]; }
+} // namespace lynx::hlfx

+ 27 - 0
src/core/HarmlessFx.h

@@ -26,8 +26,35 @@ std::optional<std::vector<std::uint8_t>> maximusStateFromFst (const std::vector<
 struct MaximusPreset;
 std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::uint8_t>& state);
 
+// Which build of the engine runs the state: Shared/SG_x64.dll (= Maximus_x64.dll, bit-identical on the demo states)
+// or the older copy inside Soundgoodizer_x64.dll (16-bit saturation tables, another curve end; REA_rodada40 §3)
+enum class MaximusBuild { shared, soundgoodizer };
+std::shared_ptr<const MaximusPreset> makeMaximusPreset (const std::vector<std::uint8_t>& state, MaximusBuild build);
+
 class Maximus;
 
+// The Maximus engine on its own, as FL's mixer Maximus, Soundgoodizer and Vocodex's SG stage run it (Eff_Render on
+// the host's blocks; blocks longer than 512 frames are split). mixParameter: parameter 5 (band mix, 0…1000).
+class MaximusProcessor
+{
+public:
+    MaximusProcessor();
+    ~MaximusProcessor();
+    MaximusProcessor (const MaximusProcessor&) = delete;
+    MaximusProcessor& operator= (const MaximusProcessor&) = delete;
+
+    void prepare (std::shared_ptr<const MaximusPreset> preset, double sampleRate, int mixParameter);
+    void process (float* left, float* right, int n) noexcept;
+    void reset() noexcept;
+    int latencySamples() const noexcept; // reported to the host (FL compensates it)
+
+private:
+    std::unique_ptr<Maximus> engine;
+};
+
+// parameter 5 (band mix) stored in the state
+int maximusMixParameter (const MaximusPreset& preset) noexcept;
+
 // The whole rack of one Harmless instance (state lives here; the presets are shared)
 class Rack
 {

+ 214 - 0
src/core/History.cpp

@@ -0,0 +1,214 @@
+#include "core/History.h"
+
+#include <algorithm>
+
+namespace lynx
+{
+namespace
+{
+bool sameNote (const Note& a, const Note& b) noexcept
+{
+    return a.start == b.start && a.length == b.length && a.channel == b.channel && a.key == b.key && a.velocity == b.velocity
+           && a.pan == b.pan && a.finePitch == b.finePitch && a.muted == b.muted && a.slide == b.slide && a.porta == b.porta
+           && a.release == b.release && a.modX == b.modX && a.modY == b.modY;
+}
+
+bool sameNotes (const std::vector<Note>& a, const std::vector<Note>& b) noexcept
+{
+    return a.size() == b.size() && std::equal (a.begin(), a.end(), b.begin(), sameNote);
+}
+
+bool sameChannelLevels (const ChannelDef& a, const ChannelDef& b) noexcept
+{
+    return a.volume == b.volume && a.pan == b.pan;
+}
+
+bool sameChannel (const ChannelDef& a, const ChannelDef& b) noexcept
+{
+    return a.name == b.name && a.instrument == b.instrument && sameChannelLevels (a, b) && a.muted == b.muted && a.samplePath == b.samplePath
+           && a.zones == b.zones && a.mixerTrack == b.mixerTrack && a.plugin == b.plugin && a.controllerState == b.controllerState
+           && a.modelParams == b.modelParams && a.pluginState == b.pluginState && a.sampler == b.sampler && a.synth == b.synth
+           && a.swingMix == b.swingMix && a.arp == b.arp && a.cutGroup == b.cutGroup && a.cutBy == b.cutBy && a.colour == b.colour;
+}
+
+bool sameSlot (const EffectSlot& a, const EffectSlot& b) noexcept
+{
+    return a.kind == b.kind && a.enabled == b.enabled && a.params == b.params && a.mix == b.mix && a.plugin == b.plugin
+           && a.sidechain == b.sidechain && a.sidechain2 == b.sidechain2 && a.branches.size() == b.branches.size() && a.state == b.state;
+}
+
+bool sameEffects (const MixerTrack& a, const MixerTrack& b) noexcept
+{
+    return a.effects.size() == b.effects.size() && std::equal (a.effects.begin(), a.effects.end(), b.effects.begin(), sameSlot);
+}
+
+bool sameRouting (const MixerTrack& a, const MixerTrack& b) noexcept
+{
+    return a.sends == b.sends && a.toMaster == b.toMaster;
+}
+
+bool sameTrack (const MixerTrack& a, const MixerTrack& b) noexcept
+{
+    return a.name == b.name && a.volume == b.volume && a.pan == b.pan && a.muted == b.muted && a.solo == b.solo && sameEffects (a, b)
+           && sameRouting (a, b) && a.stereo == b.stereo && a.colour == b.colour && a.invertPhase == b.invertPhase
+           && a.swapChannels == b.swapChannels && a.eq == b.eq;
+}
+
+bool sameClip (const Clip& a, const Clip& b) noexcept
+{
+    return a.pattern == b.pattern && a.track == b.track && a.start == b.start && a.length == b.length && a.offset == b.offset
+           && a.kind == b.kind && a.channel == b.channel && a.automation == b.automation && a.fadeIn == b.fadeIn && a.fadeOut == b.fadeOut
+           && a.gain == b.gain && a.muted == b.muted;
+}
+
+bool sameClips (const std::vector<Clip>& a, const std::vector<Clip>& b) noexcept
+{
+    return a.size() == b.size() && std::equal (a.begin(), a.end(), b.begin(), sameClip);
+}
+
+bool samePoints (const Automation& a, const Automation& b) noexcept
+{
+    if (a.points.size() != b.points.size() || a.name != b.name || ! (a.target == b.target))
+        return false;
+
+    for (std::size_t i = 0; i < a.points.size(); ++i)
+        if (a.points[i].tick != b.points[i].tick || a.points[i].value != b.points[i].value || a.points[i].tension != b.points[i].tension)
+            return false;
+
+    return true;
+}
+
+ChangeLabel label (const char* text, std::string arg = {})
+{
+    return { text, std::move (arg) };
+}
+} // namespace
+
+ChangeLabel describeChange (const Song& before, const Song& after)
+{
+    // patterns and notes
+    if (before.patterns.size() != after.patterns.size())
+        return label (after.patterns.size() > before.patterns.size() ? TR_NOOP ("Add pattern") : TR_NOOP ("Delete pattern"));
+
+    for (std::size_t p = 0; p < after.patterns.size(); ++p)
+    {
+        const auto& a = before.patterns[p];
+        const auto& b = after.patterns[p];
+
+        if (! sameNotes (a.notes, b.notes))
+        {
+            if (b.notes.size() > a.notes.size())
+                return label (TR_NOOP ("Add notes: {0}"), b.name);
+            if (b.notes.size() < a.notes.size())
+                return label (TR_NOOP ("Delete notes: {0}"), b.name);
+            return label (TR_NOOP ("Edit notes: {0}"), b.name);
+        }
+
+        if (a.name != b.name || a.colour != b.colour)
+            return label (TR_NOOP ("Rename pattern: {0}"), b.name);
+        if (a.lengthTicks != b.lengthTicks)
+            return label (TR_NOOP ("Pattern length: {0}"), b.name);
+    }
+
+    // channels
+    if (before.channels.size() != after.channels.size())
+        return label (after.channels.size() > before.channels.size() ? TR_NOOP ("Add channel") : TR_NOOP ("Delete channel"));
+
+    for (std::size_t c = 0; c < after.channels.size(); ++c)
+    {
+        const auto& a = before.channels[c];
+        const auto& b = after.channels[c];
+
+        if (sameChannel (a, b))
+            continue;
+
+        if (a.name != b.name && std::any_of (before.channels.begin(), before.channels.end(), [&b] (const ChannelDef& o) { return o.name == b.name; }))
+            return label (TR_NOOP ("Move channels"));
+
+        auto onlyMute = a;
+        onlyMute.muted = b.muted;
+        if (sameChannel (onlyMute, b))
+            return label (TR_NOOP ("Mute: {0}"), b.name);
+
+        auto onlyLevels = a;
+        onlyLevels.volume = b.volume;
+        onlyLevels.pan = b.pan;
+        if (sameChannel (onlyLevels, b))
+            return label (TR_NOOP ("Channel level: {0}"), b.name);
+
+        return label (TR_NOOP ("Channel: {0}"), b.name);
+    }
+
+    // mixer
+    if (before.mixer.size() != after.mixer.size())
+        return label (after.mixer.size() > before.mixer.size() ? TR_NOOP ("Add insert") : TR_NOOP ("Remove insert"));
+
+    for (std::size_t t = 0; t < after.mixer.size(); ++t)
+    {
+        const auto& a = before.mixer[t];
+        const auto& b = after.mixer[t];
+
+        if (sameTrack (a, b))
+            continue;
+
+        if (a.name != b.name && std::any_of (before.mixer.begin(), before.mixer.end(), [&b] (const MixerTrack& o) { return o.name == b.name; }))
+            return label (TR_NOOP ("Move inserts"));
+        if (! sameEffects (a, b))
+            return label (TR_NOOP ("Effects: {0}"), b.name);
+        if (! sameRouting (a, b))
+            return label (TR_NOOP ("Routing: {0}"), b.name);
+        if (a.volume != b.volume || a.pan != b.pan)
+            return label (TR_NOOP ("Mixer level: {0}"), b.name);
+        return label (TR_NOOP ("Mixer: {0}"), b.name);
+    }
+
+    // playlist
+    if (! sameClips (before.playlist, after.playlist))
+    {
+        if (after.playlist.size() > before.playlist.size())
+            return label (TR_NOOP ("Add clips"));
+        if (after.playlist.size() < before.playlist.size())
+            return label (TR_NOOP ("Delete clips"));
+        return label (TR_NOOP ("Edit clips"));
+    }
+
+    if (before.automations.size() != after.automations.size()
+        || ! std::equal (before.automations.begin(), before.automations.end(), after.automations.begin(), samePoints))
+        return label (TR_NOOP ("Automation"));
+
+    if (before.bpm != after.bpm)
+        return label (TR_NOOP ("Tempo"));
+    if (before.swing != after.swing)
+        return label (TR_NOOP ("Swing"));
+    if (before.loopStart != after.loopStart || before.loopEnd != after.loopEnd)
+        return label (TR_NOOP ("Time selection"));
+    if (before.markers() != after.markers())
+        return label (TR_NOOP ("Markers"));
+    if (before.arrangements.size() != after.arrangements.size() || before.currentArrangement != after.currentArrangement)
+        return label (TR_NOOP ("Arrangements"));
+    if (before.playlistTracks.size() != after.playlistTracks.size())
+        return label (TR_NOOP ("Playlist tracks"));
+
+    for (std::size_t i = 0; i < after.playlistTracks.size(); ++i)
+        if (before.playlistTracks[i].name != after.playlistTracks[i].name || before.playlistTracks[i].muted != after.playlistTracks[i].muted)
+            return label (TR_NOOP ("Playlist tracks"));
+
+    if (before.mode != after.mode)
+        return label (TR_NOOP ("Pattern / song mode"));
+    if (before.currentPattern != after.currentPattern)
+        return label (TR_NOOP ("Select pattern"));
+
+    return label (TR_NOOP ("Edit"));
+}
+
+std::string describeChangeText (const Song& before, const Song& after)
+{
+    const auto l = describeChange (before, after);
+    std::string text = l.text;
+
+    if (const auto at = text.find ("{0}"); at != std::string::npos)
+        text.replace (at, 3, l.arg);
+
+    return text;
+}
+} // namespace lynx

+ 27 - 0
src/core/History.h

@@ -0,0 +1,27 @@
+#pragma once
+
+// Names for undo steps (docs/WORKFLOW_FL.md P2: history panel). The undo stack keeps whole Song
+// snapshots; this compares two of them and says what changed, in a few words the UI translates.
+
+#include <string>
+
+#include "core/Song.h"
+
+#ifndef TR_NOOP
+ #define TR_NOOP(text) text
+#endif
+
+namespace lynx
+{
+struct ChangeLabel
+{
+    const char* text = "Edit"; // English, may contain {0}; translated by the UI
+    std::string arg;           // what {0} stands for (a pattern, channel or insert name)
+};
+
+// What turned `before` into `after` (the first difference found, from the most specific).
+ChangeLabel describeChange (const Song& before, const Song& after);
+
+// Same, already formatted in English ("Notes: Pattern 1"); used by the tests and logs.
+std::string describeChangeText (const Song& before, const Song& after);
+} // namespace lynx

+ 4 - 0
src/core/Instruments.cpp

@@ -6,6 +6,7 @@
 #include "core/Morphine.h"
 #include "core/SytrusEngine.h"
 #include "core/Harmor.h"
+#include "core/Ogun.h"
 #include "core/PhysicalModels.h"
 
 #include <algorithm>
@@ -202,6 +203,7 @@ private:
             case InstrumentKind::harmor:
             case InstrumentKind::gms:
             case InstrumentKind::morphine:
+            case InstrumentKind::ogun:
                 break;
         }
 
@@ -2008,6 +2010,8 @@ std::unique_ptr<Instrument> makeInstrument (InstrumentKind kind, std::shared_ptr
 
     if (kind == InstrumentKind::morphine)
         return makeMorphineInstrument();
+    if (kind == InstrumentKind::ogun)
+        return makeOgunInstrument();
 
     return std::make_unique<DrumInstrument> (kind);
 }

+ 67 - 1
src/core/KeyMap.cpp

@@ -18,6 +18,8 @@ const KeyName keyNames[] = {
     { del, "Delete" },         { insert, "Insert" },   { up, "Up" },           { down, "Down" },         { left, "Left" },
     { right, "Right" },        { pageUp, "PageUp" },   { pageDown, "PageDown" }, { home, "Home" },       { end, "End" },
     { numpadPlus, "Numpad +" }, { numpadMinus, "Numpad -" },
+    { numpad0, "Numpad 0" }, { numpad1, "Numpad 1" }, { numpad2, "Numpad 2" }, { numpad3, "Numpad 3" }, { numpad4, "Numpad 4" },
+    { numpad5, "Numpad 5" }, { numpad6, "Numpad 6" }, { numpad7, "Numpad 7" }, { numpad8, "Numpad 8" }, { numpad9, "Numpad 9" },
 };
 
 std::string lower (std::string s)
@@ -52,7 +54,8 @@ std::vector<Action> makeActions()
         { "panel.playlist", TR_NOOP ("Show, focus or hide the Playlist"), Context::global, { chord (f5) } },
         { "panel.channelRack", TR_NOOP ("Show, focus or hide the Channel Rack"), Context::global, { chord (f6) } },
         { "panel.pianoRoll", TR_NOOP ("Show, focus or hide the Piano Roll"), Context::global, { chord (f7) } },
-        { "panel.browser", TR_NOOP ("Show, focus or hide the Browser"), Context::global, { chord (f8), chord (f8, alt) } },
+        { "panel.browser", TR_NOOP ("Show, focus or hide the Browser"), Context::global, { chord (f8, alt) } },
+        { "panel.quickAdd", TR_NOOP ("Quick-add palette: instruments and effects"), Context::global, { chord (f8) } },
         { "panel.mixer", TR_NOOP ("Show, focus or hide the Mixer"), Context::global, { chord (f9) } },
         { "panel.maximisePlaylist", TR_NOOP ("Maximize or restore the Playlist"), Context::global, { chord (enter) } },
 
@@ -62,6 +65,15 @@ std::vector<Action> makeActions()
         { "pattern.nextEmpty", TR_NOOP ("Next empty pattern (and name it)"), Context::global, { chord (f4) } },
         { "pattern.rename", TR_NOOP ("Rename and color the pattern"), Context::global, { chord (f2) } },
         { "pattern.insert", TR_NOOP ("Insert an empty pattern before the current one"), Context::global, { chord (insert, ctrl | shift) } },
+        { "pattern.clone", TR_NOOP ("Clone the current pattern"), Context::global, { chord ('C', alt) } },
+        { "pattern.moveUp", TR_NOOP ("Move the current pattern up"), Context::global, { chord (up, ctrl | shift) } },
+        { "pattern.moveDown", TR_NOOP ("Move the current pattern down"), Context::global, { chord (down, ctrl | shift) } },
+
+        // recording
+        { "transport.record", TR_NOOP ("Recording on/off"), Context::global, { chord ('R') } },
+        { "transport.metronome", TR_NOOP ("Metronome on/off"), Context::global, { chord ('M', ctrl) } },
+        { "record.countIn", TR_NOOP ("Count-in before recording on/off"), Context::global, { chord ('P', ctrl) } },
+        { "record.waitForInput", TR_NOOP ("Recording waits for the first note on/off"), Context::global, { chord ('I', ctrl) } },
 
         // files and history
         { "file.new", TR_NOOP ("New project"), Context::global, { chord ('N', ctrl) } },
@@ -71,7 +83,9 @@ std::vector<Action> makeActions()
         { "file.export", TR_NOOP ("Export audio"), Context::global, { chord ('R', ctrl) } },
         { "edit.undo", TR_NOOP ("Undo"), Context::global, { chord ('Z', ctrl) } },
         { "edit.redo", TR_NOOP ("Redo"), Context::global, { chord ('Y', ctrl), chord ('Z', ctrl | shift) } },
+        { "edit.history", TR_NOOP ("Undo history"), Context::global, { chord ('H', ctrl) } },
         { "help.shortcuts", TR_NOOP ("Shortcut sheet"), Context::global, { chord (f1) } },
+        { "browser.search", TR_NOOP ("Search the Browser"), Context::global, { chord ('F', ctrl) } },
 
         // Channel Rack (focused)
         { "rack.selectPrevious", TR_NOOP ("Select the channel above"), Context::channelRack, { chord (up) } },
@@ -84,8 +98,60 @@ std::vector<Action> makeActions()
         { "rack.clone", TR_NOOP ("Clone the selected channels"), Context::channelRack, { chord ('C', alt) } },
         { "rack.deleteSelected", TR_NOOP ("Delete the selected channels"), Context::channelRack, { chord (del, alt) } },
         { "rack.sendToInserts", TR_NOOP ("Send the selected channels to free mixer inserts"), Context::channelRack, { chord ('L', ctrl) } },
+        { "rack.graphEditor", TR_NOOP ("Step graph lanes on/off"), Context::channelRack, { chord ('K', ctrl) } },
+        { "rack.rotateLeft", TR_NOOP ("Rotate the selected channels' steps left"), Context::channelRack, { chord (left, ctrl | shift) } },
+        { "rack.rotateRight", TR_NOOP ("Rotate the selected channels' steps right"), Context::channelRack, { chord (right, ctrl | shift) } },
+
+        // Piano Roll (focused): tool dialogs and zoom
+        { "pianoRoll.arpeggiate", TR_NOOP ("Arpeggiate..."), Context::pianoRoll, { chord ('A', alt) } },
+        { "pianoRoll.strum", TR_NOOP ("Strum..."), Context::pianoRoll, { chord ('S', alt) } },
+        { "pianoRoll.flip", TR_NOOP ("Flip..."), Context::pianoRoll, { chord ('Y', alt) } },
+        { "pianoRoll.randomise", TR_NOOP ("Randomise..."), Context::pianoRoll, { chord ('R', alt) } },
+        { "pianoRoll.scaleLevels", TR_NOOP ("Scale levels..."), Context::pianoRoll, { chord ('X', alt) } },
+        { "pianoRoll.limit", TR_NOOP ("Limit to a range..."), Context::pianoRoll, { chord ('K', alt) } },
+        { "pianoRoll.zoomIn", TR_NOOP ("Zoom in"), Context::pianoRoll, { chord (pageUp) } },
+        { "pianoRoll.zoomOut", TR_NOOP ("Zoom out"), Context::pianoRoll, { chord (pageDown) } },
+        { "pianoRoll.zoom1", TR_NOOP ("Zoom: one bar"), Context::pianoRoll, { chord ('1', shift) }, true },
+        { "pianoRoll.zoom2", TR_NOOP ("Zoom: four bars"), Context::pianoRoll, { chord ('2', shift) }, true },
+        { "pianoRoll.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::pianoRoll, { chord ('3', shift) }, true },
+        { "pianoRoll.zoomAll", TR_NOOP ("Zoom to show everything"), Context::pianoRoll, { chord ('4', shift) }, true },
+        { "pianoRoll.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::pianoRoll, { chord ('5', shift) }, true },
+        { "pianoRoll.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::pianoRoll, { chord ('0', shift) }, true },
+
+        // Playlist (focused)
+        { "playlist.zoomIn", TR_NOOP ("Zoom in"), Context::playlist, { chord (pageUp) } },
+        { "playlist.zoomOut", TR_NOOP ("Zoom out"), Context::playlist, { chord (pageDown) } },
+        { "playlist.zoom1", TR_NOOP ("Zoom: one bar"), Context::playlist, { chord ('1', shift) }, true },
+        { "playlist.zoom2", TR_NOOP ("Zoom: four bars"), Context::playlist, { chord ('2', shift) }, true },
+        { "playlist.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::playlist, { chord ('3', shift) }, true },
+        { "playlist.zoomAll", TR_NOOP ("Zoom to show everything"), Context::playlist, { chord ('4', shift) }, true },
+        { "playlist.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::playlist, { chord ('5', shift) }, true },
+        { "playlist.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::playlist, { chord ('0', shift) }, true },
+        { "playlist.rippleDelete", TR_NOOP ("Delete the selected clips and close the gaps"), Context::playlist, { chord (del, shift) } },
+        { "playlist.ripple", TR_NOOP ("Ripple editing on/off"), Context::playlist, { chord ('S', shift) } },
+
+        // Browser (focused)
+        { "browser.previous", TR_NOOP ("Previous file (preview)"), Context::browser, { chord (up) } },
+        { "browser.next", TR_NOOP ("Next file (preview)"), Context::browser, { chord (down) } },
+        { "browser.swapPrevious", TR_NOOP ("Previous file into the selected channel"), Context::browser, { chord (up, shift) } },
+        { "browser.swapNext", TR_NOOP ("Next file into the selected channel"), Context::browser, { chord (down, shift) } },
+        { "browser.load", TR_NOOP ("Load the file into the selected channel"), Context::browser, { chord (enter) } },
+
+        // Mixer (focused)
+        { "mixer.moveLeft", TR_NOOP ("Move the selected inserts left"), Context::mixer, { chord (left, alt) } },
+        { "mixer.moveRight", TR_NOOP ("Move the selected inserts right"), Context::mixer, { chord (right, alt) } },
+        { "mixer.linkChannels", TR_NOOP ("Link the selected channels to the selected insert"), Context::mixer, { chord ('L', ctrl) } },
+        { "mixer.linkChannelsFrom", TR_NOOP ("Link the selected channels to inserts starting from the selected one"), Context::mixer, { chord ('L', ctrl | shift) } },
+        { "mixer.selectLinkedChannels", TR_NOOP ("Select the channels linked to the selected insert"), Context::mixer, { chord ('L', alt) } },
     };
 
+    // numeric keypad 1-9: select patterns 1-9
+    static const char* patternIds[] = { "pattern.select1", "pattern.select2", "pattern.select3", "pattern.select4", "pattern.select5",
+                                        "pattern.select6", "pattern.select7", "pattern.select8", "pattern.select9" };
+
+    for (int i = 0; i < 9; ++i)
+        list.push_back ({ patternIds[i], TR_NOOP ("Select pattern {0}"), Context::global, { chord (numpad1 + i) } });
+
     // number keys: mute (plain) / solo (Ctrl) channels 1-10 while the rack has focus
     static const char* muteIds[] = { "rack.mute1", "rack.mute2", "rack.mute3", "rack.mute4", "rack.mute5",
                                      "rack.mute6", "rack.mute7", "rack.mute8", "rack.mute9", "rack.mute10" };

+ 2 - 1
src/core/KeyMap.h

@@ -27,7 +27,8 @@ enum Key : int
     f1 = 0x10001, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
     up = 0x10020, down, left, right, pageUp, pageDown, home, end,
     enter = 0x10030, escape, tab, backspace, del, insert,
-    numpadPlus = 0x10040, numpadMinus
+    numpadPlus = 0x10040, numpadMinus,
+    numpad0 = 0x10050, numpad1, numpad2, numpad3, numpad4, numpad5, numpad6, numpad7, numpad8, numpad9
 };
 
 enum Modifier : std::uint8_t

+ 100 - 0
src/core/MaximusFx.cpp

@@ -0,0 +1,100 @@
+#include "core/MaximusFx.h"
+
+#include <cstring>
+
+namespace lynx::maximusfx
+{
+namespace
+{
+constexpr std::uint8_t magic[4] { 'L', 'X', 'M', 'X' };
+constexpr std::size_t headerSize = 4 + 1 + 1 + 4;
+} // namespace
+
+std::vector<std::uint8_t> pack (const Blob& blob)
+{
+    std::vector<std::uint8_t> out (magic, magic + 4);
+    out.push_back (1);
+    out.push_back (blob.build == hlfx::MaximusBuild::soundgoodizer ? 1 : 0);
+    const auto mix = (std::int32_t) blob.mix;
+    std::uint8_t m[4];
+    std::memcpy (m, &mix, 4);
+    out.insert (out.end(), m, m + 4);
+    out.insert (out.end(), blob.state.begin(), blob.state.end());
+    return out;
+}
+
+std::optional<Blob> unpack (const std::vector<std::uint8_t>& bytes)
+{
+    if (bytes.size() < headerSize || std::memcmp (bytes.data(), magic, 4) != 0 || bytes[4] != 1 || bytes[5] > 1)
+        return std::nullopt;
+    Blob b;
+    b.build = bytes[5] == 1 ? hlfx::MaximusBuild::soundgoodizer : hlfx::MaximusBuild::shared;
+    std::int32_t mix = 0;
+    std::memcpy (&mix, bytes.data() + 6, 4);
+    b.mix = mix;
+    b.state.assign (bytes.begin() + (std::ptrdiff_t) headerSize, bytes.end());
+    return b;
+}
+
+std::shared_ptr<const hlfx::MaximusPreset> presetOf (const Blob& blob)
+{
+    return hlfx::makeMaximusPreset (blob.state, blob.build);
+}
+
+std::optional<SoundgoodizerState> parseSoundgoodizer (const std::vector<std::uint8_t>& state)
+{
+    // FUN_00836960: u32 version (> 0), then the preset index and the amount, read raw into the plugin
+    if (state.size() < 12)
+        return std::nullopt;
+    std::int32_t v[3];
+    std::memcpy (v, state.data(), sizeof (v));
+    if (v[0] < 1 || v[1] < 0 || v[1] > 3)
+        return std::nullopt;
+    return SoundgoodizerState { v[1], v[2] };
+}
+
+const char* soundgoodizerPresetFile (int preset)
+{
+    static const char* names[4] { "a.dat", "b.dat", "c.dat", "d.dat" };
+    return names[preset < 0 || preset > 3 ? 0 : preset];
+}
+
+namespace
+{
+class MaximusEffect final : public Effect
+{
+public:
+    explicit MaximusEffect (const std::vector<std::uint8_t>& slotState)
+    {
+        if (const auto blob = unpack (slotState))
+            if ((preset = presetOf (*blob)) != nullptr)
+                mix = blob->mix >= 0 ? blob->mix : hlfx::maximusMixParameter (*preset);
+    }
+
+    void prepare (double sampleRate) noexcept override
+    {
+        if (preset != nullptr)
+            engine.prepare (preset, sampleRate, mix); // allocates; called off the audio thread by the host
+    }
+
+    void reset() noexcept override { engine.reset(); }
+
+    void process (float* left, float* right, int n, const EffectParams&, double) noexcept override
+    {
+        engine.process (left, right, n);
+    }
+
+    int latencySamples() const noexcept override { return engine.latencySamples(); }
+
+private:
+    std::shared_ptr<const hlfx::MaximusPreset> preset;
+    int mix = 1000;
+    hlfx::MaximusProcessor engine;
+};
+} // namespace
+
+std::unique_ptr<Effect> make (const std::vector<std::uint8_t>& slotState)
+{
+    return std::make_unique<MaximusEffect> (slotState);
+}
+} // namespace lynx::maximusfx

+ 45 - 0
src/core/MaximusFx.h

@@ -0,0 +1,45 @@
+#pragma once
+
+// FL Studio's Maximus and Soundgoodizer as LYNX mixer effects, on the exact engine of core/HarmlessFx (rebuilt in
+// docs/analise/REA_rodada36.md and REA_rodada40.md; clean-room). The effect slot carries everything in
+// EffectSlot::state as LYNX's own small container:
+//
+//   "LXMX", u8 container version (1), u8 build (0 = Maximus / Shared SG_x64.dll, 1 = Soundgoodizer_x64.dll's copy),
+//   i32 band-mix parameter (−1 = the state's own parameter 5), then the Maximus state bytes.
+//
+// A Maximus slot holds FL's own saved state; a Soundgoodizer slot holds the preset file a…d.dat read at import from
+// the user's FL installation (never from this repository) and its Amount as the band mix.
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <vector>
+
+#include "core/Effects.h"
+#include "core/HarmlessFx.h"
+
+namespace lynx::maximusfx
+{
+struct Blob
+{
+    hlfx::MaximusBuild build = hlfx::MaximusBuild::shared;
+    int mix = -1; // parameter 5; −1 = the state's own value
+    std::vector<std::uint8_t> state;
+};
+
+std::vector<std::uint8_t> pack (const Blob& blob);
+std::optional<Blob> unpack (const std::vector<std::uint8_t>& bytes);
+
+// The engine's preset for a container (nullptr when the state is not supported: see makeMaximusPreset)
+std::shared_ptr<const hlfx::MaximusPreset> presetOf (const Blob& blob);
+
+// Soundgoodizer's state (0xD5, 12 bytes): version, preset 0…3 (A…D → Data\Presets\a…d.dat), amount 0…1000
+struct SoundgoodizerState
+{
+    int preset = 0, amount = 600;
+};
+std::optional<SoundgoodizerState> parseSoundgoodizer (const std::vector<std::uint8_t>& state);
+const char* soundgoodizerPresetFile (int preset); // "a.dat" … "d.dat"
+
+std::unique_ptr<Effect> make (const std::vector<std::uint8_t>& slotState);
+} // namespace lynx::maximusfx

+ 221 - 0
src/core/MixerOps.cpp

@@ -0,0 +1,221 @@
+#include "core/MixerOps.h"
+
+#include <algorithm>
+#include <numeric>
+
+namespace lynx::mixerops
+{
+namespace
+{
+bool isInsert (const Song& song, int t) noexcept
+{
+    return t > 0 && t < (int) song.mixer.size();
+}
+
+template <typename Fn>
+void forEachSlot (std::vector<EffectSlot>& slots, Fn&& fn)
+{
+    for (auto& slot : slots)
+    {
+        fn (slot);
+        for (auto& branch : slot.branches)
+            forEachSlot (branch.chain, fn);
+    }
+}
+
+bool isTrackTarget (AutomationTargetKind k) noexcept
+{
+    return k == AutomationTargetKind::mixerVolume || k == AutomationTargetKind::mixerPan || k == AutomationTargetKind::effectParam
+           || k == AutomationTargetKind::effectMix;
+}
+} // namespace
+
+void swapTracks (Song& song, int a, int b)
+{
+    if (a == b || ! isInsert (song, a) || ! isInsert (song, b))
+        return;
+
+    auto map = [a, b] (int t) { return t == a ? b : t == b ? a : t; };
+    std::swap (song.mixer[(std::size_t) a], song.mixer[(std::size_t) b]);
+
+    for (auto& c : song.channels)
+        c.mixerTrack = map (c.mixerTrack);
+
+    for (auto& track : song.mixer)
+    {
+        for (auto& send : track.sends)
+            send.target = map (send.target);
+
+        forEachSlot (track.effects, [&map] (EffectSlot& slot) {
+            if (slot.sidechain > 0)
+                slot.sidechain = map (slot.sidechain);
+            if (slot.sidechain2 > 0)
+                slot.sidechain2 = map (slot.sidechain2);
+        });
+    }
+
+    song.forEachTarget ([&map] (AutomationTarget& t) {
+        if (isTrackTarget (t.kind))
+            t.index = map (t.index);
+    });
+
+    for (auto& automation : song.automations)
+        if (automation.source.track > 0)
+            automation.source.track = map (automation.source.track);
+}
+
+bool moveTracks (Song& song, std::vector<int>& selection, int delta)
+{
+    const auto count = (int) song.mixer.size();
+    std::sort (selection.begin(), selection.end());
+    selection.erase (std::unique (selection.begin(), selection.end()), selection.end());
+    selection.erase (std::remove_if (selection.begin(), selection.end(), [count] (int t) { return t <= 0 || t >= count; }), selection.end());
+
+    if (selection.empty() || delta == 0 || (delta < 0 && selection.front() == 1) || (delta > 0 && selection.back() == count - 1))
+        return false;
+
+    if (delta < 0)
+    {
+        for (auto& t : selection) // left to right: each swaps with its left neighbour
+        {
+            swapTracks (song, t, t - 1);
+            --t;
+        }
+    }
+    else
+    {
+        for (auto it = selection.rbegin(); it != selection.rend(); ++it)
+        {
+            swapTracks (song, *it, *it + 1);
+            ++*it;
+        }
+    }
+
+    return true;
+}
+
+std::vector<int> linkChannels (Song& song, const std::vector<int>& channels, int track, bool startingHere)
+{
+    std::vector<int> result;
+
+    if (song.mixer.empty())
+        song.mixer = Song::defaultMixer (0);
+
+    track = std::clamp (track, 0, (int) song.mixer.size() - 1);
+    auto next = track;
+
+    for (auto channel : channels)
+    {
+        if (channel < 0 || channel >= (int) song.channels.size())
+        {
+            result.push_back (0);
+            continue;
+        }
+
+        while (next >= (int) song.mixer.size() && (int) song.mixer.size() < maxMixerTracks)
+        {
+            auto& added = song.mixer.emplace_back();
+            added.name = "Insert " + std::to_string (song.mixer.size() - 1);
+        }
+
+        const auto target = std::min (next, (int) song.mixer.size() - 1);
+        song.channels[(std::size_t) channel].mixerTrack = target;
+        result.push_back (target);
+
+        if (startingHere && track > 0)
+            ++next;
+    }
+
+    return result;
+}
+
+std::vector<int> channelsOn (const Song& song, int track)
+{
+    std::vector<int> out;
+
+    for (int c = 0; c < (int) song.channels.size(); ++c)
+        if (song.channels[(std::size_t) c].mixerTrack == track)
+            out.push_back (c);
+
+    return out;
+}
+
+int routeTo (Song& song, const std::vector<int>& sources, int to, bool only)
+{
+    int routed = 0;
+
+    for (auto from : sources)
+    {
+        if (! isInsert (song, from) || from == to || (to != 0 && ! song.canRoute (from, to) && ! song.routes (from, to)))
+            continue;
+
+        if (only)
+        {
+            auto& track = song.mixer[(std::size_t) from];
+            track.sends.erase (std::remove_if (track.sends.begin(), track.sends.end(), [to] (const MixerSend& s) { return s.target != to; }),
+                               track.sends.end());
+            track.toMaster = to == 0;
+        }
+
+        song.setRoute (from, to, true);
+        ++routed;
+    }
+
+    return routed;
+}
+
+int sidechainTo (Song& song, int from, int to)
+{
+    if (! isInsert (song, from) || ! isInsert (song, to) || from == to)
+        return 0;
+
+    if (! song.routes (from, to))
+    {
+        if (! song.canRoute (from, to))
+            return 0;
+        song.setRoute (from, to, true, 0.0f);
+    }
+
+    int linked = 0;
+    for (auto& fx : song.mixer[(std::size_t) to].effects)
+        if ((fx.kind == EffectKind::compressor || fx.kind == EffectKind::vocoder) && (fx.sidechain < 0 || fx.sidechain == from))
+        {
+            fx.sidechain = from;
+            ++linked;
+        }
+
+    return linked;
+}
+
+bool moveEffectSlot (Song& song, int track, int from, int to)
+{
+    if (track < 0 || track >= (int) song.mixer.size())
+        return false;
+
+    const auto count = (int) song.mixer[(std::size_t) track].effects.size();
+
+    if (from < 0 || from >= count || to < 0 || to >= count || from == to)
+        return false;
+
+    for (auto s = from; s != to; s += to > from ? 1 : -1)
+        song.swapEffectSlots (track, s, s + (to > from ? 1 : -1));
+
+    return true;
+}
+
+void setAllEffectsEnabled (Song& song, int track, bool enabled)
+{
+    if (track >= 0 && track < (int) song.mixer.size())
+        for (auto& fx : song.mixer[(std::size_t) track].effects)
+            fx.enabled = enabled;
+}
+
+bool anyEffectEnabled (const Song& song, int track) noexcept
+{
+    if (track < 0 || track >= (int) song.mixer.size())
+        return false;
+
+    const auto& fx = song.mixer[(std::size_t) track].effects;
+    return std::any_of (fx.begin(), fx.end(), [] (const EffectSlot& s) { return s.enabled; });
+}
+} // namespace lynx::mixerops

+ 42 - 0
src/core/MixerOps.h

@@ -0,0 +1,42 @@
+#pragma once
+
+// Mixer workflow operations (docs/WORKFLOW_FL.md P2: insert multi-selection and reordering, routing and
+// sidechain gestures, linking channels, effect slot reordering). Pure functions over the Song model:
+// no JUCE, unit-tested in tests/WorkflowP2Tests.inc.
+
+#include <vector>
+
+#include "core/Song.h"
+
+namespace lynx::mixerops
+{
+// Swaps inserts a and b (both >= 1): everything that refers to them by number follows (channel routing,
+// sends, sidechain inputs, automation and MIDI targets, controller sources).
+void swapTracks (Song& song, int a, int b);
+
+// Moves the selected inserts left (delta < 0) or right by one place as a block; the Master never moves.
+// `selection` is updated. Returns false when nothing moved.
+bool moveTracks (Song& song, std::vector<int>& selection, int delta);
+
+// Routes `channels` to insert `track` (all of them), or, with `startingHere`, to consecutive inserts from
+// `track` on (adding inserts as needed, up to maxMixerTracks). Returns the insert of each channel.
+std::vector<int> linkChannels (Song& song, const std::vector<int>& channels, int track, bool startingHere);
+
+// Channels whose output goes to `track`.
+std::vector<int> channelsOn (const Song& song, int track);
+
+// Sends each source insert to `to` (0 = Master). `only`: the source stops sending anywhere else. Sources
+// that would make a cycle are skipped. Returns how many were routed.
+int routeTo (Song& song, const std::vector<int>& sources, int to, bool only);
+
+// Sidechain link: a level-0 send from `from` to `to` (so `from` is processed first) and every compressor
+// or vocoder on `to` without a side input listens to `from`. Returns how many effects now listen.
+int sidechainTo (Song& song, int from, int to);
+
+// Moves effect slot `from` to position `to` of the same insert (the others shift); automations follow.
+bool moveEffectSlot (Song& song, int track, int from, int to);
+
+// All effects of the insert on or off (the "effects" switch).
+void setAllEffectsEnabled (Song& song, int track, bool enabled);
+bool anyEffectEnabled (const Song& song, int track) noexcept;
+} // namespace lynx::mixerops

+ 171 - 0
src/core/NoteEdit.cpp

@@ -528,4 +528,175 @@ std::vector<int> repeatTime (std::vector<Clip>& clips, std::int64_t from, std::i
 
     return added;
 }
+
+void rippleDelete (std::vector<Clip>& clips, std::vector<int> indices)
+{
+    std::sort (indices.begin(), indices.end());
+    indices.erase (std::unique (indices.begin(), indices.end()), indices.end());
+    indices.erase (std::remove_if (indices.begin(), indices.end(), [&clips] (int i) { return i < 0 || i >= (int) clips.size(); }), indices.end());
+
+    // gaps per track, latest first, so each shift sees the positions the later ones left
+    std::vector<Clip> removed;
+    for (auto it = indices.rbegin(); it != indices.rend(); ++it)
+    {
+        removed.push_back (clips[(std::size_t) *it]);
+        clips.erase (clips.begin() + *it);
+    }
+
+    std::sort (removed.begin(), removed.end(), [] (const Clip& a, const Clip& b) { return a.start > b.start; });
+
+    for (const auto& gap : removed)
+        for (auto& c : clips)
+            if (c.track == gap.track && c.start >= gap.end())
+                c.start -= gap.length;
+}
+
+void rippleResize (std::vector<Clip>& clips, int index, std::int64_t newLength)
+{
+    if (index < 0 || index >= (int) clips.size())
+        return;
+
+    auto& clip = clips[(std::size_t) index];
+    newLength = std::max<std::int64_t> (1, newLength);
+    const auto oldEnd = clip.end();
+    const auto delta = newLength - clip.length;
+    clip.length = newLength;
+    clampFades (clip);
+
+    for (int i = 0; i < (int) clips.size(); ++i)
+        if (i != index && clips[(std::size_t) i].track == clips[(std::size_t) index].track && clips[(std::size_t) i].start >= oldEnd)
+            clips[(std::size_t) i].start = std::max<std::int64_t> (0, clips[(std::size_t) i].start + delta);
+}
+
+std::vector<int> moveTimeRange (std::vector<Clip>& clips, std::int64_t from, std::int64_t to, std::int64_t delta, bool copy)
+{
+    if (to <= from)
+        return {};
+
+    delta = std::max (delta, -from); // nothing before 0
+
+    // cut at the edges so only the inside moves
+    for (const auto edge : { from, to })
+        for (std::size_t i = 0, n = clips.size(); i < n; ++i)
+            if (clips[i].start < edge && clips[i].end() > edge)
+            {
+                auto rest = splitClip (clips[i], edge);
+                clampFades (clips[i]);
+                clampFades (rest);
+                clips.push_back (rest);
+            }
+
+    std::vector<int> moved;
+
+    for (int i = 0, n = (int) clips.size(); i < n; ++i)
+    {
+        const auto& c = clips[(std::size_t) i];
+
+        if (c.start < from || c.end() > to)
+            continue;
+
+        if (copy)
+        {
+            auto duplicate = c;
+            duplicate.start += delta;
+            moved.push_back ((int) clips.size());
+            clips.push_back (duplicate);
+        }
+        else
+        {
+            clips[(std::size_t) i].start += delta;
+            moved.push_back (i);
+        }
+    }
+
+    return moved;
+}
+
+std::vector<int> chopClip (std::vector<Clip>& clips, int index, std::int64_t grid)
+{
+    if (index < 0 || index >= (int) clips.size() || grid <= 0)
+        return {};
+
+    std::vector<int> pieces { index };
+    auto current = index;
+
+    for (auto cut = (clips[(std::size_t) index].start / grid + 1) * grid; cut < clips[(std::size_t) current].end(); cut += grid)
+    {
+        auto rest = splitClip (clips[(std::size_t) current], cut);
+        clampFades (clips[(std::size_t) current]);
+        clampFades (rest);
+        clips.push_back (rest);
+        current = (int) clips.size() - 1;
+        pieces.push_back (current);
+    }
+
+    return pieces;
+}
+
+namespace
+{
+std::vector<PlaylistTrack>& headers (Song& song, int atLeast)
+{
+    if ((int) song.playlistTracks.size() < atLeast)
+        song.playlistTracks.resize ((std::size_t) atLeast);
+    return song.playlistTracks;
+}
+} // namespace
+
+void insertTrack (Song& song, int track)
+{
+    track = std::max (0, track);
+    song.forEachClipList ([track] (std::vector<Clip>& clips) {
+        for (auto& c : clips)
+            if (c.track >= track)
+                ++c.track;
+    });
+
+    auto& h = headers (song, track);
+    h.insert (h.begin() + track, PlaylistTrack {});
+}
+
+void removeTrack (Song& song, int track)
+{
+    if (track < 0)
+        return;
+
+    song.forEachClipList ([track] (std::vector<Clip>& clips) {
+        clips.erase (std::remove_if (clips.begin(), clips.end(), [track] (const Clip& c) { return c.track == track; }), clips.end());
+        for (auto& c : clips)
+            if (c.track > track)
+                --c.track;
+    });
+
+    if (track < (int) song.playlistTracks.size())
+        song.playlistTracks.erase (song.playlistTracks.begin() + track);
+}
+
+void swapTracks (Song& song, int a, int b)
+{
+    if (a < 0 || b < 0 || a == b)
+        return;
+
+    song.forEachClipList ([a, b] (std::vector<Clip>& clips) {
+        for (auto& c : clips)
+            c.track = c.track == a ? b : c.track == b ? a : c.track;
+    });
+
+    auto& h = headers (song, std::max (a, b) + 1);
+    std::swap (h[(std::size_t) a], h[(std::size_t) b]);
+}
+
+void soloTrack (Song& song, int track, int trackCount)
+{
+    trackCount = std::max (trackCount, track + 1);
+    auto& h = headers (song, trackCount);
+    bool alone = ! h[(std::size_t) track].muted;
+
+    for (int t = 0; t < trackCount && alone; ++t)
+        if (t != track && ! h[(std::size_t) t].muted)
+            alone = false;
+
+    for (int t = 0; t < (int) h.size(); ++t)
+        h[(std::size_t) t].muted = alone ? false : t != track;
+}
 } // namespace lynx::noteedit

+ 29 - 0
src/core/NoteEdit.h

@@ -134,4 +134,33 @@ std::vector<int> clipsInTime (const std::vector<Clip>& clips, std::int64_t from,
 // Repeats the time selection [from, to) right after itself: copies of `sources` (or, if empty, of the
 // clips that start inside it) shifted by its length. Returns the new indices.
 std::vector<int> repeatTime (std::vector<Clip>& clips, std::int64_t from, std::int64_t to, std::vector<int> sources);
+
+// --- ripple editing and time-selection moves (docs/WORKFLOW_FL.md P2) -------------------------
+
+// Ripple delete: removes the clips and closes each gap: on the same track, the clips after a removed
+// clip move left by its length.
+void rippleDelete (std::vector<Clip>& clips, std::vector<int> indices);
+
+// Ripple resize: clip `index` gets `newLength` (at least 1) and every later clip on its track moves by the
+// change, so nothing after it overlaps or opens a gap.
+void rippleResize (std::vector<Clip>& clips, int index, std::int64_t newLength);
+
+// Moves (or copies) what lies inside the time selection [from, to) by `delta` ticks: clips crossing its
+// edges are cut there first, so only the part inside moves. Returns the indices of the moved clips (or
+// of the copies). The start never goes below 0.
+std::vector<int> moveTimeRange (std::vector<Clip>& clips, std::int64_t from, std::int64_t to, std::int64_t delta, bool copy);
+
+// --- Playlist tracks and clips (docs/WORKFLOW_FL.md P2: clip and track menus) ------------------
+
+// Cuts clip `index` at every multiple of `grid` (song time) inside it. Returns the indices of all pieces.
+std::vector<int> chopClip (std::vector<Clip>& clips, int index, std::int64_t grid);
+
+// Inserts an empty track at `track` (the clips there and below move down); every arrangement follows.
+void insertTrack (Song& song, int track);
+// Removes track `track` and its clips (the tracks below move up), in every arrangement.
+void removeTrack (Song& song, int track);
+// Swaps two tracks (their clips and headers), in every arrangement.
+void swapTracks (Song& song, int a, int b);
+// Solo: `track` plays alone (every other track muted); on the only unmuted track it unmutes all.
+void soloTrack (Song& song, int track, int trackCount);
 } // namespace lynx::noteedit

+ 410 - 0
src/core/NoteTools.cpp

@@ -0,0 +1,410 @@
+#include "core/NoteTools.h"
+
+#include <algorithm>
+#include <cmath>
+#include <map>
+#include <tuple>
+
+namespace lynx::notetools
+{
+namespace
+{
+bool valid (const Pattern& p, int i)
+{
+    return i >= 0 && i < (int) p.notes.size();
+}
+
+std::vector<int> validSorted (const Pattern& p, std::vector<int> indices)
+{
+    indices.erase (std::remove_if (indices.begin(), indices.end(), [&p] (int i) { return ! valid (p, i); }), indices.end());
+    std::sort (indices.begin(), indices.end());
+    indices.erase (std::unique (indices.begin(), indices.end()), indices.end());
+    return indices;
+}
+
+// small deterministic generator (the same seed gives the same result on every compiler)
+struct Random
+{
+    std::uint32_t state;
+    explicit Random (std::uint32_t seed) : state (seed * 2654435761u + 0x6d2b79f5u) {}
+
+    float next() noexcept // 0..1
+    {
+        state ^= state << 13;
+        state ^= state >> 17;
+        state ^= state << 5;
+        return (float) (state >> 8) / (float) (1u << 24);
+    }
+
+    float bipolar (bool both) noexcept { return both ? next() * 2.0f - 1.0f : -next(); }
+};
+} // namespace
+
+// --- levels -----------------------------------------------------------------------------------
+
+const char* levelName (Level level)
+{
+    switch (level)
+    {
+        case Level::velocity: return TR_NOOP ("Velocity");
+        case Level::pan: return TR_NOOP ("Pan");
+        case Level::release: return TR_NOOP ("Release");
+        case Level::finePitch: return TR_NOOP ("Fine pitch");
+        case Level::modX: return TR_NOOP ("Mod X");
+        case Level::modY: return TR_NOOP ("Mod Y");
+    }
+    return "";
+}
+
+float levelValue (const Note& n, Level level) noexcept
+{
+    switch (level)
+    {
+        case Level::velocity: return n.velocity;
+        case Level::pan: return (n.pan + 1.0f) * 0.5f;
+        case Level::release: return n.release;
+        case Level::finePitch: return (n.finePitch + 120.0f) / 240.0f;
+        case Level::modX: return n.modX;
+        case Level::modY: return n.modY;
+    }
+    return 0.0f;
+}
+
+void setLevelValue (Note& n, Level level, float v) noexcept
+{
+    v = std::clamp (v, 0.0f, 1.0f);
+
+    switch (level)
+    {
+        case Level::velocity: n.velocity = v; break;
+        case Level::pan: n.pan = v * 2.0f - 1.0f; break;
+        case Level::release: n.release = v; break;
+        case Level::finePitch: n.finePitch = v * 240.0f - 120.0f; break;
+        case Level::modX: n.modX = v; break;
+        case Level::modY: n.modY = v; break;
+    }
+}
+
+float levelDefault (Level level) noexcept
+{
+    return levelValue (Note {}, level);
+}
+
+bool levelIsBipolar (Level level) noexcept
+{
+    return level == Level::pan || level == Level::finePitch;
+}
+
+// --- scales -----------------------------------------------------------------------------------
+
+const std::vector<ScaleInfo>& scales()
+{
+    static const std::vector<ScaleInfo> list {
+        { TR_NOOP ("No scale"), {} },
+        { TR_NOOP ("Major"), { 0, 2, 4, 5, 7, 9, 11 } },
+        { TR_NOOP ("Natural minor"), { 0, 2, 3, 5, 7, 8, 10 } },
+        { TR_NOOP ("Harmonic minor"), { 0, 2, 3, 5, 7, 8, 11 } },
+        { TR_NOOP ("Major pentatonic"), { 0, 2, 4, 7, 9 } },
+        { TR_NOOP ("Minor pentatonic"), { 0, 3, 5, 7, 10 } },
+        { "Blues", { 0, 3, 5, 6, 7, 10 } },
+        { TR_NOOP ("Dorian"), { 0, 2, 3, 5, 7, 9, 10 } },
+        { TR_NOOP ("Phrygian"), { 0, 1, 3, 5, 7, 8, 10 } },
+    };
+    return list;
+}
+
+bool inScale (int key, int root, int scale) noexcept
+{
+    if (scale <= 0 || scale >= (int) scales().size())
+        return true;
+
+    const auto& intervals = scales()[(std::size_t) scale].intervals;
+    const auto degree = ((key - root) % 12 + 12) % 12;
+    return std::find (intervals.begin(), intervals.end(), degree) != intervals.end();
+}
+
+int snapToScale (int key, int root, int scale) noexcept
+{
+    key = std::clamp (key, 0, 127);
+
+    if (scale <= 0 || scale >= (int) scales().size())
+        return key;
+
+    for (int d = 0; d < 12; ++d)
+    {
+        if (key - d >= 0 && inScale (key - d, root, scale))
+            return key - d;
+        if (key + d <= 127 && inScale (key + d, root, scale))
+            return key + d;
+    }
+
+    return key;
+}
+
+void snapNotesToScale (Pattern& pattern, const std::vector<int>& indices, int root, int scale)
+{
+    for (auto i : validSorted (pattern, indices))
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+        n.key = snapToScale (n.key, root, scale);
+    }
+}
+
+// --- chords -----------------------------------------------------------------------------------
+
+std::vector<std::vector<int>> chordsOf (const Pattern& pattern, const std::vector<int>& indices)
+{
+    std::map<std::tuple<std::int64_t, int>, std::vector<int>> groups; // (start, channel)
+
+    for (auto i : validSorted (pattern, indices))
+    {
+        const auto& n = pattern.notes[(std::size_t) i];
+        groups[{ n.start, n.channel }].push_back (i);
+    }
+
+    std::vector<std::vector<int>> out;
+
+    for (auto& [key, group] : groups)
+    {
+        std::stable_sort (group.begin(), group.end(), [&pattern] (int a, int b) {
+            return pattern.notes[(std::size_t) a].key < pattern.notes[(std::size_t) b].key;
+        });
+        out.push_back (std::move (group));
+    }
+
+    return out;
+}
+
+// --- strum ------------------------------------------------------------------------------------
+
+void strum (Pattern& pattern, const std::vector<int>& indices, const StrumOptions& o)
+{
+    const auto chords = chordsOf (pattern, indices);
+    int chordNumber = 0;
+    const auto exponent = std::pow (2.0, (double) std::clamp (o.curve, -1.0f, 1.0f) * 2.0);
+
+    for (const auto& chord : chords)
+    {
+        if (chord.size() < 2)
+            continue;
+
+        auto downward = o.downward;
+        if (o.alternate && (chordNumber % 2) == 1)
+            downward = ! downward;
+        ++chordNumber;
+
+        const auto count = (int) chord.size();
+        const auto total = (double) o.spread * (count - 1);
+
+        for (int k = 0; k < count; ++k)
+        {
+            auto& n = pattern.notes[(std::size_t) chord[(std::size_t) (downward ? count - 1 - k : k)]];
+            const auto x = (double) k / (double) (count - 1);
+            const auto offset = std::max<std::int64_t> (0, (std::int64_t) std::llround (total * std::pow (x, exponent)));
+            const auto end = n.start + n.length;
+            n.start += offset;
+
+            if (o.keepEnds)
+                n.length = std::max<std::int64_t> (std::min<std::int64_t> (n.length, 10), end - n.start);
+
+            n.velocity = std::clamp (n.velocity + o.velocityStep * (float) k, 0.0f, 1.0f);
+        }
+    }
+}
+
+// --- arpeggiate -------------------------------------------------------------------------------
+
+std::vector<int> arpeggiate (Pattern& pattern, const std::vector<int>& indices, const ArpeggiateOptions& o)
+{
+    const auto step = std::max<std::int64_t> (1, o.step);
+    const auto octaves = std::clamp (o.octaves, 1, 4);
+    const auto noteLength = std::max<std::int64_t> (1, (std::int64_t) std::llround ((double) step * std::clamp (o.gate, 0.05f, 1.0f)));
+    std::vector<int> doomed;
+    std::vector<Note> created;
+
+    for (const auto& chord : chordsOf (pattern, indices))
+    {
+        if (chord.size() < 2 && octaves == 1)
+            continue;
+
+        std::vector<Note> base;
+        std::int64_t span = 0;
+
+        for (auto i : chord)
+        {
+            base.push_back (pattern.notes[(std::size_t) i]);
+            span = std::max (span, pattern.notes[(std::size_t) i].length);
+            doomed.push_back (i);
+        }
+
+        // the ascending run over the octaves
+        std::vector<Note> run;
+        for (int oct = 0; oct < octaves; ++oct)
+            for (auto n : base)
+                if (n.key + 12 * oct <= 127)
+                {
+                    n.key += 12 * oct;
+                    run.push_back (n);
+                }
+
+        std::vector<Note> sequence;
+        auto down = run;
+        std::reverse (down.begin(), down.end());
+
+        switch (o.direction)
+        {
+            case ArpeggiateOptions::down: sequence = down; break;
+            case ArpeggiateOptions::upDown:
+                sequence = run;
+                if (down.size() > 2)
+                    sequence.insert (sequence.end(), down.begin() + 1, down.end() - 1);
+                break;
+            case ArpeggiateOptions::downUp:
+                sequence = down;
+                if (run.size() > 2)
+                    sequence.insert (sequence.end(), run.begin() + 1, run.end() - 1);
+                break;
+            default: sequence = run; break;
+        }
+
+        if (sequence.empty())
+            continue;
+
+        const auto start = base.front().start;
+
+        for (std::int64_t t = 0, k = 0; t < span; t += step, ++k)
+        {
+            auto n = sequence[(std::size_t) (k % (std::int64_t) sequence.size())];
+            n.start = start + t;
+            n.length = std::min (noteLength, span - t);
+            created.push_back (n);
+        }
+    }
+
+    std::sort (doomed.begin(), doomed.end());
+    for (auto it = doomed.rbegin(); it != doomed.rend(); ++it)
+        pattern.notes.erase (pattern.notes.begin() + *it);
+
+    std::vector<int> added;
+    for (const auto& n : created)
+    {
+        added.push_back ((int) pattern.notes.size());
+        pattern.notes.push_back (n);
+    }
+
+    return added;
+}
+
+// --- flip -------------------------------------------------------------------------------------
+
+void flip (Pattern& pattern, const std::vector<int>& indices, bool horizontal, bool vertical)
+{
+    const auto targets = validSorted (pattern, indices);
+
+    if (targets.empty())
+        return;
+
+    std::int64_t from = INT64_MAX, to = INT64_MIN;
+    int low = 127, high = 0;
+
+    for (auto i : targets)
+    {
+        const auto& n = pattern.notes[(std::size_t) i];
+        from = std::min (from, n.start);
+        to = std::max (to, n.start + n.length);
+        low = std::min (low, n.key);
+        high = std::max (high, n.key);
+    }
+
+    for (auto i : targets)
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+
+        if (horizontal)
+            n.start = from + (to - (n.start + n.length));
+        if (vertical)
+            n.key = std::clamp (low + high - n.key, 0, 127);
+    }
+}
+
+// --- randomise --------------------------------------------------------------------------------
+
+void randomise (Pattern& pattern, const std::vector<int>& indices, const RandomiseOptions& o)
+{
+    Random random (o.seed);
+
+    for (auto i : validSorted (pattern, indices))
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+        // every note draws the same number of values, so changing one amount doesn't reshuffle the others
+        const auto rv = random.bipolar (o.bipolar), rp = random.bipolar (true), rf = random.bipolar (true);
+        const auto rx = random.bipolar (true), ry = random.bipolar (true), rt = random.bipolar (o.bipolar);
+        const auto rl = random.bipolar (true);
+
+        n.velocity = std::clamp (n.velocity + o.velocity * rv, 0.0f, 1.0f);
+        n.pan = std::clamp (n.pan + 2.0f * o.pan * rp, -1.0f, 1.0f);
+        n.finePitch = std::clamp (n.finePitch + 120.0f * o.finePitch * rf, -120.0f, 120.0f);
+        n.modX = std::clamp (n.modX + o.modX * rx, 0.0f, 1.0f);
+        n.modY = std::clamp (n.modY + o.modY * ry, 0.0f, 1.0f);
+
+        if (o.timing > 0)
+            n.start = std::max<std::int64_t> (0, n.start + (std::int64_t) std::llround ((double) o.timing * (o.bipolar ? rt : -rt)));
+
+        if (o.length > 0.0f)
+            n.length = std::max<std::int64_t> (1, (std::int64_t) std::llround ((double) n.length * (1.0 + (double) o.length * rl)));
+    }
+}
+
+// --- scale levels -----------------------------------------------------------------------------
+
+void scaleLevels (Pattern& pattern, const std::vector<int>& indices, Level level, float scaleStart, float scaleEnd, float offset)
+{
+    const auto targets = validSorted (pattern, indices);
+
+    if (targets.empty())
+        return;
+
+    std::int64_t first = INT64_MAX, last = INT64_MIN;
+    for (auto i : targets)
+    {
+        first = std::min (first, pattern.notes[(std::size_t) i].start);
+        last = std::max (last, pattern.notes[(std::size_t) i].start);
+    }
+
+    const auto centre = levelIsBipolar (level) ? 0.5f : 0.0f;
+
+    for (auto i : targets)
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+        const auto t = last > first ? (float) (n.start - first) / (float) (last - first) : 0.0f;
+        const auto scale = scaleStart + (scaleEnd - scaleStart) * t;
+        setLevelValue (n, level, centre + (levelValue (n, level) - centre) * scale + offset);
+    }
+}
+
+// --- limit ------------------------------------------------------------------------------------
+
+void limit (Pattern& pattern, const std::vector<int>& indices, const LimitOptions& o)
+{
+    const auto low = std::clamp (std::min (o.lowKey, o.highKey), 0, 127);
+    const auto high = std::clamp (std::max (o.lowKey, o.highKey), 0, 127);
+    const auto minV = std::clamp (std::min (o.minVelocity, o.maxVelocity), 0.0f, 1.0f);
+    const auto maxV = std::clamp (std::max (o.minVelocity, o.maxVelocity), 0.0f, 1.0f);
+
+    for (auto i : validSorted (pattern, indices))
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+
+        if (high - low >= 11) // an octave fits: keep the pitch class
+        {
+            while (n.key < low)
+                n.key += 12;
+            while (n.key > high)
+                n.key -= 12;
+        }
+
+        n.key = std::clamp (n.key, low, high);
+        n.velocity = std::clamp (n.velocity, minV, maxV);
+    }
+}
+} // namespace lynx::notetools

+ 115 - 0
src/core/NoteTools.h

@@ -0,0 +1,115 @@
+#pragma once
+
+// Piano Roll note tools (docs/WORKFLOW_FL.md P2: strum, arpeggiate, flip, randomise, scale levels, limit,
+// scale snap) and the per-note "levels" shared by the Piano Roll lane and the step sequencer graph lanes.
+// LYNX's own designs of the behaviours the manual describes; pure functions over Pattern, no JUCE.
+
+#include <cstdint>
+#include <vector>
+
+#include "core/Song.h"
+
+#ifndef TR_NOOP
+ #define TR_NOOP(text) text
+#endif
+
+namespace lynx::notetools
+{
+// --- per-note levels, normalised to 0..1 ------------------------------------------------------
+enum class Level
+{
+    velocity,  // 0..1
+    pan,       // -1..1 -> 0..1
+    release,   // 0..1
+    finePitch, // -120..120 cents -> 0..1
+    modX,      // 0..1
+    modY       // 0..1
+};
+
+constexpr int levelCount = 6;
+const char* levelName (Level level); // English, for tr()
+float levelValue (const Note& note, Level level) noexcept;
+void setLevelValue (Note& note, Level level, float normalised) noexcept;
+float levelDefault (Level level) noexcept; // normalised value of a fresh note
+bool levelIsBipolar (Level level) noexcept; // drawn from the centre line (pan, fine pitch)
+
+// --- scales -----------------------------------------------------------------------------------
+struct ScaleInfo
+{
+    const char* name; // English, for tr()
+    std::vector<int> intervals;
+};
+
+const std::vector<ScaleInfo>& scales(); // [0] = no scale
+bool inScale (int key, int root, int scale) noexcept;
+// The in-scale key nearest to `key` (a tie goes down); `key` itself without a scale. Stays in 0..127.
+int snapToScale (int key, int root, int scale) noexcept;
+// Moves every note to the nearest in-scale key.
+void snapNotesToScale (Pattern& pattern, const std::vector<int>& indices, int root, int scale);
+
+// --- chords -----------------------------------------------------------------------------------
+// Groups the notes into chords: same channel and same start. Each group is sorted by key (low first);
+// the groups are in start order.
+std::vector<std::vector<int>> chordsOf (const Pattern& pattern, const std::vector<int>& indices);
+
+// --- strum ------------------------------------------------------------------------------------
+struct StrumOptions
+{
+    std::int64_t spread = 40;   // ticks from one chord note to the next
+    float curve = 0.0f;         // -1..1: < 0 the strum speeds up, > 0 it slows down
+    float velocityStep = 0.0f;  // added to each successive note's velocity (-0.25..0.25)
+    bool downward = false;      // high note first
+    bool alternate = false;     // every other chord strums the other way
+    bool keepEnds = true;       // notes keep their end (they get shorter); otherwise they keep their length
+};
+
+void strum (Pattern& pattern, const std::vector<int>& indices, const StrumOptions& options);
+
+// --- arpeggiate (offline) ---------------------------------------------------------------------
+struct ArpeggiateOptions
+{
+    enum Direction { up, down, upDown, downUp };
+    std::int64_t step = ticksPerStep; // time between arpeggio notes
+    float gate = 0.8f;                // fraction of the step each note sounds (0.05..1)
+    int direction = up;
+    int octaves = 1;                  // 1..4
+};
+
+// Replaces each chord (and, with more than one octave, each single note) by a run of notes over its length.
+// Returns the indices of the new notes (not re-sorted).
+std::vector<int> arpeggiate (Pattern& pattern, const std::vector<int>& indices, const ArpeggiateOptions& options);
+
+// --- flip -------------------------------------------------------------------------------------
+// Horizontal: mirrors the notes in time inside their span. Vertical: mirrors the keys around the middle
+// of their range.
+void flip (Pattern& pattern, const std::vector<int>& indices, bool horizontal, bool vertical);
+
+// --- randomise --------------------------------------------------------------------------------
+struct RandomiseOptions
+{
+    float velocity = 0.25f;   // maximum change (0..1 of the full range)
+    float pan = 0.0f;
+    float finePitch = 0.0f;   // fraction of ±120 cents
+    float modX = 0.0f, modY = 0.0f;
+    std::int64_t timing = 0;  // maximum start shift in ticks (never before 0)
+    float length = 0.0f;      // maximum relative length change (0..1)
+    bool bipolar = true;      // changes go both ways; otherwise only down (velocity) / only later (timing)
+    std::uint32_t seed = 1;
+};
+
+void randomise (Pattern& pattern, const std::vector<int>& indices, const RandomiseOptions& options);
+
+// --- scale levels -----------------------------------------------------------------------------
+// Each value becomes value * scale + offset (pan and fine pitch around their centre), where `scale` ramps
+// from `scaleStart` (first note) to `scaleEnd` (last note) through time: a fade in or out.
+void scaleLevels (Pattern& pattern, const std::vector<int>& indices, Level level, float scaleStart, float scaleEnd, float offset);
+
+// --- limit ------------------------------------------------------------------------------------
+struct LimitOptions
+{
+    int lowKey = 36, highKey = 84;   // notes outside move by octaves into the range (or are clamped if it is narrower)
+    float minVelocity = 0.0f, maxVelocity = 1.0f;
+};
+
+void limit (Pattern& pattern, const std::vector<int>& indices, const LimitOptions& options);
+} // namespace lynx::notetools

+ 3693 - 0
src/core/Ogun.cpp

@@ -0,0 +1,3693 @@
+// FL Studio's Ogun: the inverse-FFT timbre engine of docs/analise/REA_rodada37.md, ported 1:1 from our own round-37
+// reference model (r37/py/ogmodel.py, ogcurve.py, ogpatch.py, ogfx_chorus.py, ogfx_delay.py, ogfx_reverb.py,
+// ogos.py, ogos_fast.py). Clean-room: written from the behavioural description; no Image-Line code. Every float32
+// rounding of the model is kept (the model was checked against the DLL), so most expressions below spell out their
+// float/double steps. Section references (§) are to REA_rodada37.
+
+#include "core/Ogun.h"
+
+#include <algorithm>
+#include <array>
+#include <atomic>
+#include <cmath>
+#include <cstring>
+#include <mutex>
+
+#include "core/Inflate.h"
+#include "core/PlateReverb.h"
+
+#if defined(__clang__)
+#pragma clang fp contract(off)
+#endif
+
+namespace lynx
+{
+namespace
+{
+constexpr double kPi = 3.141592653589793;
+constexpr double LN2 = 0.6931471805599453;
+constexpr double tiny24 = 5.960464477539063e-08; // 2^-24
+inline double f32 (double x) noexcept { return (double) (float) x; }
+inline long long rnd (double x) noexcept { return (long long) std::nearbyint (x); } // Delphi/Python round: half to even
+inline int sgn (double x) noexcept { return x > 0.0 ? 1 : (x < 0.0 ? -1 : 0); }
+
+// ---------------------------------------------------------------------------------------------------------------
+// numpy's pairwise summation (float accumulators for float32 data), used where the model sums with np.sum
+template <typename T, typename S>
+T pairwiseSum (const S* a, std::size_t n) noexcept
+{
+    if (n < 8)
+    {
+        T res = (T) 0;
+        for (std::size_t i = 0; i < n; ++i)
+            res += (T) a[i];
+        return res;
+    }
+    if (n <= 128)
+    {
+        T r[8];
+        for (int j = 0; j < 8; ++j)
+            r[j] = (T) a[j];
+        std::size_t i = 8;
+        for (; i < n - (n % 8); i += 8)
+            for (int j = 0; j < 8; ++j)
+                r[j] += (T) a[i + (std::size_t) j];
+        T res = ((r[0] + r[1]) + (r[2] + r[3])) + ((r[4] + r[5]) + (r[6] + r[7]));
+        for (; i < n; ++i)
+            res += (T) a[i];
+        return res;
+    }
+    auto n2 = n / 2;
+    n2 -= n2 % 8;
+    return pairwiseSum<T> (a, n2) + pairwiseSum<T> (a + n2, n - n2);
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// state (§1.3; our ogpatch.py)
+
+struct Point
+{
+    double dx = 0.0, y = 0.0, T = 0.0;
+    int mode = 0;
+};
+
+struct CurveData
+{
+    int type = 0, ver = 0;
+    std::vector<Point> pts;
+    int flags = 0, enabled = 0, decay = -1, loop = -1, sus = -1;
+    int cfg = 0;
+    double centre = 0.0;
+};
+
+constexpr int cfgEnv = 0x2d, cfgLfo = 0x27, cfgMap = 0x20;
+constexpr int artMode[13] { 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1 };
+constexpr double artCentre[13] { 0.0, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5 };
+
+struct ArtData
+{
+    double base = 0.0, envamt = 0.0, lfoamt = 0.0;
+    CurveData env, lfo, key, vel, X, Y;
+    std::array<int, 4> adsr {}, lfoKnobs {};
+    int lfoExtra = 0;
+    int mode = 0;
+};
+
+struct StateData
+{
+    int version = 0;
+    std::vector<std::uint8_t> body;
+    std::array<std::int32_t, 64> P {};
+    std::array<std::uint8_t, 3> b358 {};
+    std::array<int, 3> eqtype {};
+    std::array<ArtData, 13> arts;
+    std::array<CurveData, 4> maps; // 13 forced, 14 impulse, 15 decay, 16 release
+    std::uint8_t byte (int plugOffset) const noexcept { return body[(std::size_t) (plugOffset - 0x12c)]; }
+};
+
+struct Reader
+{
+    const std::uint8_t* b;
+    std::size_t n, i = 0;
+    bool ok = true;
+
+    bool need (std::size_t k) noexcept
+    {
+        if (! ok || i + k > n)
+            ok = false;
+        return ok;
+    }
+    std::int32_t i32() noexcept
+    {
+        if (! need (4))
+            return 0;
+        std::int32_t v;
+        std::memcpy (&v, b + i, 4);
+        i += 4;
+        return v;
+    }
+    float f32v() noexcept
+    {
+        if (! need (4))
+            return 0.0f;
+        float v;
+        std::memcpy (&v, b + i, 4);
+        i += 4;
+        return v;
+    }
+    double f64v() noexcept
+    {
+        if (! need (8))
+            return 0.0;
+        double v;
+        std::memcpy (&v, b + i, 8);
+        i += 8;
+        return v;
+    }
+    void skip (std::size_t k) noexcept
+    {
+        if (need (k))
+            i += k;
+    }
+    std::uint8_t u8() noexcept
+    {
+        if (! need (1))
+            return 0;
+        return b[i++];
+    }
+};
+
+bool readCurve (Reader& r, CurveData& c, int cfg, double centre)
+{
+    c.cfg = cfg;
+    c.centre = centre;
+    c.type = r.i32();
+    c.ver = r.i32();
+    const auto n = r.i32();
+    if (! r.ok || n < 0 || n > 100000)
+        return false;
+    c.pts.resize ((std::size_t) n);
+    for (auto& p : c.pts)
+    {
+        if (c.ver >= 2)
+        {
+            p.dx = r.f64v();
+            p.y = (double) (float) r.f64v();
+        }
+        else
+        {
+            p.dx = (double) r.f32v();
+            p.y = (double) r.f32v();
+        }
+        p.T = (double) r.f32v();
+        if (c.ver >= 1)
+        {
+            p.mode = r.u8();
+            r.skip (3); // arpeggio byte (cleared) + 2
+        }
+        else
+            p.mode = 0;
+    }
+    c.flags = r.i32();
+    c.enabled = r.i32();
+    c.decay = r.i32();
+    c.loop = r.i32();
+    c.sus = r.i32();
+    if (! (cfg & 4))
+        c.decay = c.loop = c.sus = -1;
+    if (! (cfg & 8))
+        c.decay = -1;
+    return r.ok;
+}
+
+std::optional<StateData> parseState (const std::vector<std::uint8_t>& blob)
+{
+    if (blob.size() < 8)
+        return std::nullopt;
+    std::uint32_t vw = 0;
+    std::memcpy (&vw, blob.data(), 4);
+    StateData S;
+    S.version = (int) (vw > 0xffff ? vw >> 16 : vw);
+    if (S.version < 14)
+        return std::nullopt;
+    auto body = inflateZlib (blob.data() + 4, blob.size() - 4, false, 16u << 20);
+    if (! body || body->size() < 0x100 + 3 + 12)
+        return std::nullopt;
+    S.body = std::move (*body);
+    std::memcpy (S.P.data(), S.body.data(), 256);
+    Reader r { S.body.data(), S.body.size(), 0x100 };
+    for (auto& b : S.b358)
+        b = r.u8();
+    for (auto& t : S.eqtype)
+        t = r.i32();
+    if (S.version < 18)
+    {
+        const auto n = r.i32();
+        if (n < 0)
+            return std::nullopt;
+        r.skip ((std::size_t) n);
+    }
+    else
+    {
+        std::size_t v = 0;
+        int shift = 0;
+        while (r.ok)
+        {
+            const auto c = r.u8();
+            v |= (std::size_t) (c & 0x7f) << shift;
+            shift += 7;
+            if (! (c & 0x80) || shift > 28)
+                break;
+        }
+        r.skip (2 * v);
+    }
+    for (int k = 0; k < 13; ++k)
+    {
+        auto& a = S.arts[(std::size_t) k];
+        const auto c = artCentre[k];
+        r.i32(); // version
+        a.base = r.f32v();
+        a.envamt = r.f32v();
+        a.lfoamt = r.f32v();
+        if (! readCurve (r, a.env, cfgEnv, c))
+            return std::nullopt;
+        for (auto& v : a.adsr)
+            v = r.i32();
+        if (! readCurve (r, a.lfo, cfgLfo, 0.5))
+            return std::nullopt;
+        for (auto& v : a.lfoKnobs)
+            v = r.i32();
+        a.lfoExtra = a.lfo.ver >= 3 ? r.i32() : 0;
+        if (! readCurve (r, a.key, cfgMap, c) || ! readCurve (r, a.vel, cfgMap, c) || ! readCurve (r, a.X, cfgMap, c)
+            || ! readCurve (r, a.Y, cfgMap, c))
+            return std::nullopt;
+        a.mode = artMode[k];
+    }
+    for (auto& m : S.maps)
+        if (! readCurve (r, m, cfgMap, 0.0))
+            return std::nullopt;
+    if (! r.ok)
+        return std::nullopt;
+    return S;
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// point curves (§1.4; our ogcurve.py)
+
+struct Curve
+{
+    double centre = 0.0;
+    int flags = 0, enabled = 0, decay = -1, loop = -1, sus = -1, cfg = 0, rel = -1;
+    std::vector<double> dx, y, T, w;
+    std::vector<int> mode, sign;
+    std::vector<std::array<double, 3>> k;
+    double lo = 0.0, hi = 1.0;
+
+    Curve() = default;
+    Curve (const CurveData& cd, double length = -1.0) { build (cd, length); }
+
+    void build (const CurveData& cd, double length)
+    {
+        centre = cd.centre;
+        flags = cd.flags, enabled = cd.enabled;
+        decay = cd.decay, loop = cd.loop, sus = cd.sus;
+        cfg = cd.cfg;
+        auto pts = cd.pts;
+        if (length >= 0.0)
+        {
+            if (pts.empty())
+                pts.push_back (Point {});
+            else if (pts[0].dx > 0.0)
+            {
+                Point p0;
+                p0.y = pts[0].y;
+                pts.insert (pts.begin(), p0);
+                for (auto* a : { &decay, &loop, &sus })
+                    if (*a >= 0)
+                        ++*a;
+            }
+            double tot = 0.0;
+            for (const auto& p : pts)
+                tot += p.dx;
+            if (tot > 0.0)
+            {
+                for (auto& p : pts)
+                    p.dx = p.dx * (length / tot);
+            }
+            else
+                pts.back().dx = pts.size() > 1 ? length : 0.0;
+        }
+        if (pts.empty())
+            pts.push_back (Point {}); // (an empty envelope; never in FL's data)
+        const auto n = pts.size();
+        dx.resize (n), y.resize (n), T.resize (n), mode.resize (n);
+        for (std::size_t i = 0; i < n; ++i)
+        {
+            dx[i] = pts[i].dx;
+            y[i] = f32 (pts[i].y);
+            T[i] = f32 (pts[i].T);
+            mode[i] = pts[i].mode;
+        }
+        coeffs();
+    }
+
+    void coeffs()
+    {
+        const int n = (int) dx.size();
+        for (auto& d : dx)
+            if (d < 0.0)
+                d = 0.0;
+        sign.assign ((std::size_t) n, 0);
+        k.assign ((std::size_t) n, { 0.0, 0.0, 0.0 });
+        const auto LN1M = std::log (1000001.0);
+        for (int i = 1; i < n; ++i)
+        {
+            const auto Ti = T[(std::size_t) i];
+            const auto m = mode[(std::size_t) i];
+            int s = Ti == 0.0 ? 0 : (Ti < 0.0 ? -1 : 1);
+            long long N = 0;
+            if (m >= 3 && m <= 6)
+            {
+                const auto v = f32 (1.0 - std::fabs (Ti) * 0.6);
+                N = rnd (f32 (std::exp (v * LN1M) - 1.0) * 0.001);
+                if (m == 3 && Ti >= 0.0)
+                    N += 1;
+            }
+            double k14 = 0.0, k18 = 0.0, k1c = 0.0;
+            if (m == 6)
+            {
+                k14 = f32 ((double) N + 0.5);
+                k18 = f32 (2.0 * kPi);
+                if (N == 0 && s > 0)
+                    s = 2;
+            }
+            else if (m < 2)
+            {
+                auto q = f32 (std::exp (f32 (std::fabs (Ti)) * LN1M) - 1.0);
+                q = Ti >= 0.0 ? q : -q;
+                k14 = q;
+                if (q != 0.0)
+                {
+                    k18 = f32 (1.0 / std::fabs (q));
+                    k1c = f32 (std::log (std::fabs (q) + 1.0));
+                }
+            }
+            else if (m == 3)
+            {
+                const double sg = Ti < 0.0 ? -1.0 : 1.0;
+                k1c = f32 (sg * 0.5);
+                k14 = f32 ((double) (N + 1));
+                k18 = f32 (1.0 / f32 (k14 - sg));
+            }
+            else if (m == 4)
+            {
+                k14 = f32 ((double) (N + 1));
+                k18 = f32 (1.0 / k14);
+            }
+            else if (m == 5)
+            {
+                const double sg = Ti < 0.0 ? -1.0 : 1.0;
+                k1c = f32 (sg * 0.5);
+                k14 = f32 ((double) ((N + 1) * 2));
+                k18 = f32 (2.0 * kPi);
+            }
+            else if (m == 7 || m == 8)
+                k14 = Ti;
+            else if (m == 9)
+                k14 = f32 (std::fabs (Ti));
+            else if (m == 10)
+            {
+                const auto X6 = std::max (dx[(std::size_t) i], tiny24);
+                const auto yi = y[(std::size_t) i];
+                const int j = i - 1;
+                const auto y9 = y[(std::size_t) j];
+                auto X8 = y9;
+                double X7 = 1.0;
+                if (mode[(std::size_t) j] == 10)
+                {
+                    X7 = dx[(std::size_t) j] / X6;
+                    if (j - 1 >= 0)
+                        X8 = y[(std::size_t) (j - 1)];
+                }
+                const int kk = i + 1;
+                double in1, d19;
+                if (kk > n - 1 || mode[(std::size_t) kk] != 10)
+                    in1 = yi, d19 = 1.0;
+                else
+                    d19 = dx[(std::size_t) kk] / X6, in1 = y[(std::size_t) kk];
+                const auto d = yi - y9;
+                if (std::fabs (d) >= tiny24)
+                {
+                    X8 = (X8 - y9) / d;
+                    const auto d24 = std::max (X7, tiny24);
+                    d19 = std::max (d19, tiny24);
+                    const auto d26 = ((in1 - y9) / d - 1.0) / d19;
+                    const auto d21 = (-X8) / d24;
+                    double a = 0.0;
+                    if (f32 (f32 (d26) * 1.0) > 0.0)
+                    {
+                        const auto f25 = f32 (f32 (d19) * 2.0 + 1.0), f18 = f32 (f32 (d19) + 2.0);
+                        a = f32 (f32 (f32 (f32 (d26) * 1.0) * f32 (f25 + f18)) / f32 (f32 (f25 * f32 (d26)) + f32 (f18 * 1.0)));
+                    }
+                    double b = 0.0;
+                    if (f32 (1.0 * f32 (d21)) > 0.0)
+                    {
+                        const auto f18 = f32 (2.0 + f32 (d24)), f25 = f32 (1.0 + f32 (d24) * 2.0);
+                        b = f32 (f32 (f32 (1.0 * f32 (d21)) * f32 (f18 + f25)) / f32 (f32 (f18 * 1.0) + f32 (f25 * f32 (d21))));
+                    }
+                    k14 = a, k18 = b, k1c = f32 (1.0 - std::fabs (Ti));
+                }
+                else
+                    s = 2;
+            }
+            else if (m == 11 || m == 12)
+            {
+                const auto d = std::max (std::fabs (Ti) * 0.9, 1.52587890625e-05);
+                const auto u = 1.0 - d;
+                k14 = f32 (1.0 - u * u * u);
+                k18 = f32 ((1.0 - k14) / k14);
+                k1c = k18;
+                if (s > 0)
+                {
+                    k18 = -k18;
+                    k1c = f32 (k18 - 1.0);
+                }
+                if (m == 12)
+                {
+                    k18 = f32 (k18 * 0.5);
+                    k1c = f32 (k1c * 0.5);
+                }
+            }
+            if (m >= 0 && m < 16 && ((0x1b83 >> m) & 1) && Ti == 0.0)
+                s = 2;
+            sign[(std::size_t) i] = s;
+            k[(std::size_t) i] = { k14, k18, k1c };
+        }
+        // per-point weights of the sustain-level offset
+        const int i15 = std::max (decay, 0);
+        const int l80 = sus >= 0 ? sus : n - 1;
+        const int l7c = loop >= 0 ? loop : l80;
+        double L98 = 0.0, L90 = 0.0, L88 = 0.0;
+        for (int i = 0; i < n; ++i)
+        {
+            if (i <= i15)
+                L98 += dx[(std::size_t) i];
+            else if (i <= l7c)
+                L90 += dx[(std::size_t) i];
+            if (i > l80)
+                L88 += dx[(std::size_t) i];
+        }
+        w.assign ((std::size_t) n, 0.0);
+        double d = L98;
+        for (int i = 0; i < n; ++i)
+        {
+            const auto di = dx[(std::size_t) i];
+            if (i > i15)
+            {
+                w[(std::size_t) i] = 1.0;
+                if (i > l80)
+                {
+                    d -= di;
+                    w[(std::size_t) i] = ! (cfg & 0x80) ? f32 (d / std::max (L88, 1.52587890625e-05)) : 1.0;
+                }
+                else
+                {
+                    if (i <= l7c)
+                        w[(std::size_t) i] = f32 ((d + di) / std::max (L90, 1.52587890625e-05));
+                    d += di;
+                    if (i == l80)
+                        d = L88;
+                }
+            }
+            else if (i == i15)
+                d = 0.0;
+            else
+            {
+                d -= di;
+                w[(std::size_t) i] = f32 (d / std::max (L98, 1.52587890625e-05));
+            }
+        }
+        rel = sus >= 0 ? sus : (loop >= 0 ? n - 1 : -1);
+    }
+
+    int size() const noexcept { return (int) dx.size(); }
+
+    double val (int i, double mod = 0.0, bool clamp = true) const noexcept
+    {
+        if (i < 0 || i >= size())
+            return 0.0;
+        auto v = y[(std::size_t) i];
+        if (mod != 0.0)
+        {
+            v = v + f32 (w[(std::size_t) i] * mod);
+            if (clamp)
+                v = std::min (std::max (v, lo), hi);
+        }
+        return v - centre;
+    }
+
+    static double half01 (double x, double k14, double k18, double k1c) noexcept
+    {
+        if (k14 == 0.0)
+            return x;
+        if (k14 > 0.0)
+            return 1.0 - (std::exp ((1.0 - x) * k1c) - 1.0) * k18;
+        return (std::exp (x * k1c) - 1.0) * k18;
+    }
+
+    double shape (int i, double t) const noexcept
+    {
+        const auto m = mode[(std::size_t) i];
+        const auto s = sign[(std::size_t) i];
+        const auto [k14, k18, k1c] = k[(std::size_t) i];
+        if (s == 2)
+            return t;
+        switch (m)
+        {
+            case 7:
+            {
+                const auto u = s > 0 ? 1.0 - t : t;
+                const auto u3 = u * u * u;
+                return t - (u3 * u3 - u) * k14;
+            }
+            case 0: return half01 (t, k14, k18, k1c);
+            case 1:
+                if (t < 0.5)
+                    return half01 (t * 2.0, k14, k18, k1c) * 0.5;
+                return 1.0 - half01 ((1.0 - t) * 2.0, k14, k18, k1c) * 0.5;
+            case 2: return 0.0;
+            case 3: return (double) ((float) rnd (t * k14 - k1c) * (float) k18);
+            case 5: return (double) (rnd (t * k14 - k1c) & 1);
+            case 6:
+            {
+                if (s < 0)
+                    return (std::sin ((t * k14 + 0.75) * k18) + 1.0) * 0.5;
+                const auto v = t * k14 - 0.5;
+                const auto r = (double) rnd (v - 0.5);
+                return std::fabs ((v - r) * 2.0 - 1.0);
+            }
+            case 4:
+            {
+                const auto v = t * k14 - 0.5;
+                const auto r = (double) rnd (v - 0.5);
+                auto d = (v - r) * 2.0 - 1.0;
+                if (s < 0)
+                {
+                    const auto a = 1.0 - std::fabs (d);
+                    d = (1.0 - a * a * a) * (d >= 0.0 ? 1.0 : -1.0);
+                }
+                else
+                    d = d * d * d;
+                return (r + d * 0.5 + 1.0) * k18;
+            }
+            case 8:
+            {
+                if (t < 0.5)
+                {
+                    const auto x = t * 2.0, u = s > 0 ? 1.0 - x : x, u3 = u * u * u;
+                    return (x - (u3 * u3 - u) * k14) * 0.5;
+                }
+                const auto x = (1.0 - t) * 2.0, u = s > 0 ? 1.0 - x : x, u3 = u * u * u;
+                return 1.0 - (x - (u3 * u3 - u) * k14) * 0.5;
+            }
+            case 9:
+            {
+                const auto g = s < 1 ? (1.0 - std::cos (t * 1.5707963705062866)) : std::sin (t * 1.5707963705062866);
+                return t - (t - g) * k14;
+            }
+            case 10:
+            {
+                const auto t2 = t * t, t1 = t - 1.0;
+                return t + (((t2 * 3.0 - t2 * 2.0 * t) + t2 * t1 * k14 + t * t1 * t1 * k18) - t) * k1c;
+            }
+            case 11:
+                if (s < 1)
+                    return k18 / (1.0 - k14 * t) - k1c;
+                return k18 / (1.0 - k14 * (1.0 - t)) - k1c;
+            case 12:
+            {
+                if (t < 0.5)
+                {
+                    if (s < 1)
+                        return k18 / (1.0 - k14 * t * 2.0) - k1c;
+                    return k18 / (1.0 - k14 * (1.0 - t * 2.0)) - k1c;
+                }
+                const auto d = (1.0 - t) * 2.0;
+                if (s < 1)
+                    return (1.0 - k18 / (1.0 - k14 * d)) + k1c;
+                return (1.0 - k18 / (1.0 - k14 * (1.0 - d))) + k1c;
+            }
+            default: return 0.0;
+        }
+    }
+
+    // sequential stepping state used by the free evaluation, table rendering and per-partial sampling
+    struct Seq
+    {
+        int idx = 0;
+        double r = 0.0, t = 0.0, ys = 0.0, dl = 0.0;
+    };
+
+    Seq seqStart (double rate) const noexcept
+    {
+        Seq q;
+        if (dx[0] == 0.0)
+            q.r = 1.0, q.t = 1.0;
+        else
+            q.r = rate / dx[0], q.t = 0.0;
+        q.ys = val (0);
+        return q;
+    }
+
+    void seqStep (Seq& q, double x) const noexcept
+    {
+        const int n = size();
+        q.t = q.t + x * q.r;
+        while (q.t >= 1.0)
+        {
+            const auto old = q.idx;
+            q.t = q.r == 0.0 ? x : (q.t - 1.0) / q.r;
+            q.ys = val (q.idx);
+            if (q.idx < n - 1)
+                ++q.idx;
+            q.dl = val (q.idx) - q.ys;
+            if (old == q.idx)
+                q.t = 0.0, q.r = 0.0;
+            else
+            {
+                const auto d = dx[(std::size_t) q.idx];
+                if (d <= 0.0)
+                    q.r = 1.0, q.t = q.t + 1.0;
+                else
+                    q.r = 1.0 / d, q.t = q.t * q.r;
+            }
+        }
+    }
+
+    double valueAt (double x, double rate = 1.0) const noexcept
+    {
+        auto q = seqStart (rate);
+        seqStep (q, x);
+        if (q.idx < 0 || q.idx >= size())
+            return 0.0;
+        return q.ys + shape (q.idx, q.t) * q.dl;
+    }
+
+    std::vector<double> render (int N, double step) const
+    {
+        std::vector<double> out ((std::size_t) N);
+        auto q = seqStart (1.0);
+        out[0] = q.ys;
+        for (int j = 1; j < N; ++j)
+        {
+            seqStep (q, step);
+            out[(std::size_t) j] = q.ys + shape (q.idx, q.t) * q.dl;
+        }
+        return out;
+    }
+
+    // per-partial maps: stepping to increasing positions (ogmodel._seq_eval)
+    void seqEval (const double* xs, int n, double* out) const noexcept
+    {
+        auto q = seqStart (1.0);
+        double prev = 0.0;
+        for (int j = 0; j < n; ++j)
+        {
+            const auto stp = xs[j] - prev;
+            prev = xs[j];
+            seqStep (q, stp);
+            out[j] = q.ys + (q.dl != 0.0 ? shape (q.idx, q.t) * q.dl : 0.0);
+        }
+    }
+
+    bool isConstant() const noexcept
+    {
+        for (const auto v : y)
+            if (v != y[0])
+                return false;
+        return true;
+    }
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// envelope / LFO time engine (§1.5)
+
+struct EnvRun
+{
+    const Curve* c = nullptr;
+    double rate0 = 0.0;
+    double kn[4] {};
+    int stage = 9, sub = 9, idx = 0;
+    double ys = 0.0, dl = 0.0, out = 0.0, t = 0.0, r = 0.0, mod = 0.0, relv = 0.0;
+    bool loopzero = false;
+
+    void init (const Curve& curve, double rateTime, double rateTempo, const std::array<int, 4>& knobs) noexcept
+    {
+        c = &curve;
+        rate0 = (curve.flags & 1) ? rateTempo : rateTime;
+        for (int i = 0; i < 4; ++i)
+            kn[i] = f32 (knobs[(std::size_t) i] / 128.0);
+        if (! curve.enabled)
+        {
+            stage = 9, sub = 9, ys = dl = out = 0.0, idx = 0, t = r = mod = relv = 0.0;
+            loopzero = false;
+            return;
+        }
+        idx = 0, mod = 0.0;
+        stage = curve.decay < 0 ? 3 : 1;
+        if (curve.dx[0] == 0.0)
+            r = 1.0, t = 1.0;
+        else
+            r = rate0 / curve.dx[0], t = 0.0;
+        sub = stage;
+        dl = 0.0;
+        relv = curve.sus >= 0 ? kn[2] : 0.0;
+        loopzero = false;
+        if (curve.rel >= 0 && curve.loop >= 0)
+        {
+            double a = 0.0, b = 0.0;
+            for (int i = 0; i <= curve.rel; ++i)
+                a += curve.dx[(std::size_t) i];
+            for (int i = 0; i <= curve.loop; ++i)
+                b += curve.dx[(std::size_t) i];
+            loopzero = ! (a - b > 0.0);
+        }
+        ys = curve.val (0, f32 (mod));
+        out = ys;
+    }
+
+    void setMod (double v) noexcept
+    {
+        mod = stage < 2 ? f32 (v) : relv;
+        out = c->val (0, f32 (mod));
+    }
+
+    double step (double x) noexcept
+    {
+        const auto& C = *c;
+        const int n = C.size();
+        if (stage == 9 && ! C.enabled)
+            return out;
+        if (! (0 <= idx && idx <= n - 1))
+            return out;
+        t += x * r;
+        while (t >= 1.0)
+        {
+            t = r == 0.0 ? x : (t - 1.0) / r;
+            ys = C.val (idx, f32 (mod));
+            bool end = false;
+            if (idx < C.rel || C.rel < 0 || stage > 5)
+            {
+                if (C.decay >= 0 && C.decay <= idx && sub < 3)
+                {
+                    stage = std::max (stage, 3);
+                    sub = 3;
+                    mod = relv;
+                }
+                if (idx < n - 1)
+                    ++idx;
+                else
+                {
+                    stage = 9;
+                    end = true;
+                }
+            }
+            else if (C.loop < 0)
+                end = true;
+            else
+            {
+                sub = 4;
+                idx = C.loop + 1;
+                end = loopzero;
+            }
+            dl = C.val (idx, f32 (mod)) - ys;
+            if (! end)
+            {
+                const int i2 = (stage >= 6 && C.sus >= 0) ? 1 : 0;
+                const auto sc = kn[(stage > 2 ? 1 : 0) + 2 * i2];
+                const auto d = C.dx[(std::size_t) idx] * sc;
+                if (d <= 0.0)
+                    r = 1.0, t += 1.0;
+                else
+                {
+                    r = rate0 / d;
+                    t *= r;
+                }
+            }
+            else
+                t = 0.0, r = 0.0;
+        }
+        if (dl == 0.0)
+            out = ys;
+        else
+            out = ys + C.shape (idx, t) * dl;
+        return out;
+    }
+
+    void release() noexcept
+    {
+        const auto& C = *c;
+        if (! C.enabled || stage >= 6)
+            return;
+        if (C.sus >= 0)
+        {
+            idx = C.sus;
+            const auto v = C.val (idx, f32 (mod), false);
+            mod = mod + (out - v);
+            t = 1.0;
+            sub = 6;
+        }
+        stage = 6;
+        if (r == 0.0)
+            t = 1.0;
+    }
+};
+
+struct LfoRun : EnvRun
+{
+    double wT = 0.0, w0 = 0.0, w1 = 0.0, w3 = 0.0, w4 = 0.0;
+    std::uint32_t w5 = 0, w6 = 0, w7 = 0, ph = 0;
+    double inc = 0.0, lout = 0.0;
+    bool flag = false;
+
+    void initLfo (const Curve& curve, double rateTime, double rateTempo, const std::array<int, 4>& knobs, int extra) noexcept
+    {
+        EnvRun::init (curve, rateTime, rateTempo, { 128, 128, 0, 128 });
+        kn[0] = 1.0, kn[1] = 1.0, kn[2] = 0.0, kn[3] = 1.0;
+        relv = 0.0;
+        const auto speed = knobs[0], tens = knobs[1], skew = knobs[2], pw = knobs[3];
+        // (global LFOs, header flag 2, run as per-voice ones: not modelled, REA_rodada37 open questions)
+        const auto av = std::abs (tens);
+        auto T = f32 (f32 (std::exp (f32 (av * f32 (1.0 / 128.0)) * std::log (21.0)) - 1.0) * 0.05);
+        T = f32 (std::exp (T * std::log (9.999999843067494e+17)) - 1.0);
+        T = T * (tens == 0 ? 0.0 : (tens > 0 ? 1.0 : -1.0));
+        wT = f32 (T);
+        if (wT != 0.0)
+        {
+            w3 = f32 (1.0 / std::fabs (wT));
+            w4 = f32 (std::log (std::fabs (wT) + 1.0));
+        }
+        const auto s = f32 (skew * 0.00390625), p = f32 (pw * f32 (1.0 / 128.0));
+        flag = (curve.flags & 4) != 0;
+        if (p > 0.0)
+        {
+            const float a = (float) (1.0 - p);
+            const float b = a * 4294967296.0f;
+            const float cc = b - 1.0f;
+            w7 = (std::uint32_t) (std::uint64_t) rnd ((double) cc);
+        }
+        else
+            w7 = 0xffffffffu;
+        auto d = (f32 ((1.0 - p) / 2.0) - s * (1.0 - std::fabs (p))) * 4294967296.0;
+        if (d > (double) w7 - 1.0)
+            d = (double) w7 - 1.0;
+        else if (d < 1.0)
+            d = 1.0;
+        w5 = (std::uint32_t) (std::uint64_t) rnd (d);
+        if (p < 0.0)
+        {
+            const auto v = (std::uint32_t) (std::int64_t) rnd (d + f32 (p * 4294967296.0));
+            w6 = v != 0 ? v : 1u;
+        }
+        else
+            w6 = w5;
+        w0 = f32 (2.0 / (double) w6);
+        const auto span = (std::uint32_t) (w7 - w5);
+        w1 = span != 0 ? f32 (2.0 / (double) span) : 0.0;
+        auto in = (std::exp (f32 (speed * 1.52587890625e-05) * std::log (10001.0)) - 1.0) * 6871947.6736 * rate0;
+        in = std::min (in, 805306368.0);
+        inc = (double) rnd (in);
+        if (curve.flags & 8)
+            inc = 0.0;
+        ph = (std::uint32_t) ((std::int64_t) w5 + (std::int64_t) ((w7 - w5) >> 1) + 1 + (std::int64_t) extra);
+        lout = 0.0;
+    }
+
+    double shapeT (double a) const noexcept
+    {
+        if (wT == 0.0)
+            return a;
+        if (wT > 0.0)
+            return 1.0 - (std::exp ((1.0 - a) * w4) - 1.0) * w3;
+        return (std::exp (a * w4) - 1.0) * w3;
+    }
+
+    double wave (std::uint32_t p) const noexcept
+    {
+        double v;
+        if (p > w7)
+            return 1.0;
+        if (p < w6)
+            v = f32 (1.0 - (double) (float) p * w0);
+        else if (p < w5)
+            return -1.0;
+        else
+            v = f32 ((double) (float) (std::uint32_t) (p - w5) * w1 - 1.0);
+        if (! flag)
+        {
+            const auto r = shapeT (std::fabs (v));
+            return f32 (std::copysign (f32 (r), v));
+        }
+        const auto u = f32 ((v + 1.0) * 0.5);
+        return f32 (shapeT (u) * 2.0 - 1.0);
+    }
+
+    double lstep (double x) noexcept
+    {
+        auto xp = x;
+        if (idx == 0 && stage < 9 && t < 1.0)
+        {
+            const auto d = r != 0.0 ? x + (t - 1.0) / r : x;
+            xp = d > 0.0 ? d : 0.0;
+        }
+        step (x);
+        if (idx != 0 || stage > 8 || t >= 1.0)
+        {
+            ph = (std::uint32_t) ((std::uint64_t) ph + (std::uint64_t) (std::int64_t) rnd (xp * inc));
+            lout = out * wave (ph);
+        }
+        return lout;
+    }
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// IPP-style uniform generator and the seed mix (round 24 §1.3/§1.4)
+
+void rand32f (float* out, int n, float lo, float hi, std::uint32_t seed) noexcept
+{
+    constexpr std::uint32_t A = 69069u, C = 0x3c6ef373u;
+    const auto sc = (double) (hi - lo) * 2.3283064365386963e-10;
+    const auto of = (double) (lo + hi) * 0.5;
+    std::uint32_t e0 = (seed * A + C) * A + C, e1 = seed * A + C, e2 = seed;
+    std::uint32_t L = 0x436cbae9u;
+    std::int32_t borrow = -1;
+    for (int k = 0; k < n; ++k)
+    {
+        auto v = (std::int32_t) (e1 - e0 + (std::uint32_t) borrow);
+        borrow = v < 0 ? -1 : 0;
+        if (v < 0)
+            v = (std::int32_t) ((std::uint32_t) v - 18u);
+        e0 = e1, e1 = e2, e2 = (std::uint32_t) v;
+        L = L * A + C;
+        out[k] = (float) ((double) (std::int32_t) ((std::uint32_t) v + L) * sc + of);
+    }
+}
+
+long long mix32 (long long a0, std::uint32_t k1) noexcept
+{
+    const auto a = (std::uint32_t) a0;
+    std::uint32_t u6 = ((0u - a - k1)) ^ (a << 8);
+    std::uint32_t u7 = (0x1eefu - a - u6) ^ (u6 >> 13);
+    std::uint32_t u5 = (a - u6 - u7) ^ (u7 >> 12);
+    u6 = (u6 - u7 - u5) ^ (u5 << 16);
+    u7 = (u7 - u5 - u6) ^ (u6 >> 5);
+    u5 = (u5 - u6 - u7) ^ (u7 >> 3);
+    u6 = (u6 - u7 - u5) ^ (u5 << 10);
+    u6 = (u7 - u5 - u6) ^ (u6 >> 15);
+    return std::llabs ((long long) (std::int32_t) u6);
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// inverse real FFT (unscaled, double): x[n] = Σ_k X_k e^{2πikn/N} for a Hermitian spectrum with bins 1…M
+
+// sin and cos of |x| ≲ 4 in double (quadrant reduction + Taylor polynomials on |r| ≤ π/4; within a few ulps of libm)
+inline void sinCos (double x, double& s, double& c) noexcept
+{
+    const auto q = std::nearbyint (x * 0.6366197723675814);
+    const auto r = (x - q * 1.5707963267341256) - q * 6.077100506506192e-11;
+    const auto r2 = r * r;
+    const auto sr = r + r * r2 * (-1.0 / 6 + r2 * (1.0 / 120 + r2 * (-1.0 / 5040 + r2 * (1.0 / 362880 + r2 * (-1.0 / 39916800
+                    + r2 * (1.0 / 6227020800.0 + r2 * (-1.0 / 1307674368000.0)))))));
+    const auto cr = 1.0 + r2 * (-0.5 + r2 * (1.0 / 24 + r2 * (-1.0 / 720 + r2 * (1.0 / 40320 + r2 * (-1.0 / 3628800
+                    + r2 * (1.0 / 479001600.0 + r2 * (-1.0 / 87178291200.0 + r2 * (1.0 / 20922789888000.0))))))));
+    switch (((int) q) & 3)
+    {
+        case 0: s = sr, c = cr; break;
+        case 1: s = cr, c = -sr; break;
+        case 2: s = -sr, c = -cr; break;
+        default: s = -cr, c = sr; break;
+    }
+}
+
+#if defined(__x86_64__) || defined(_M_X64)
+#define OGUN_X86 1
+#define OGUN_INLINE inline __attribute__ ((always_inline))
+bool ogunCpuHasAvx() noexcept
+{
+    unsigned a = 1, b = 0, c = 0, d = 0;
+    __asm__ __volatile__ ("cpuid" : "+a"(a), "=b"(b), "=c"(c), "=d"(d) : "c"(0));
+    if ((c & (1u << 27)) == 0 || (c & (1u << 28)) == 0) // OSXSAVE, AVX
+        return false;
+    unsigned lo = 0, hi = 0;
+    __asm__ __volatile__ ("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
+    return (lo & 6u) == 6u;
+}
+#else
+#define OGUN_INLINE inline
+#endif
+
+// The 32-point windowed-sinc reader of quality 4 (ogos_fast.sinc_read_fast) for one chunk, both tables at once:
+// tap ix + k (k = −31…32) weighted by ½·sin(b(f − k))/(π(f − k))·(0.36 + w + 0.64w²), w = cos(a(f − k)); the sines of
+// the shifted arguments come from sin/cos(bf), sin/cos(af) and the per-k tables (angle addition).
+struct SincTables
+{
+    double b = -1.0;
+    double cb[64], sb[64], cA[64], sA[64], kk[64];
+};
+
+OGUN_INLINE void sincChunkBody (const SincTables& T, const float* tn, const float* to, double pos0, double step, int m, int N,
+                                float* vn, float* vo) noexcept
+{
+    constexpr double a = kPi / 32.0;
+    alignas (32) double wgt[64];
+    for (int i = 0; i < m; ++i)
+    {
+        const auto pos = pos0 + step * i;
+        const auto ip = (long long) pos;
+        const auto f = std::max (pos - (double) ip, 1e-25);
+        const auto ix = (std::size_t) ((ip & (N - 1)) + 32);
+        double sbf, cbf, saf, caf;
+        sinCos (T.b * f, sbf, cbf);
+        sinCos (a * f, saf, caf);
+        for (int t = 0; t < 64; ++t)
+        {
+            const auto d = f - T.kk[t];
+            const auto sn = sbf * T.cb[t] - cbf * T.sb[t];
+            const auto w = caf * T.cA[t] + saf * T.sA[t];
+            wgt[t] = (sn / (kPi * d)) * (0.36 + w + 0.64 * w * w);
+        }
+        const float* pn = tn + ix - 31;
+        const float* po = to + ix - 31;
+        double an[4] {}, ao[4] {};
+        for (int t = 0; t < 64; t += 4)
+            for (int l = 0; l < 4; ++l)
+            {
+                an[l] += (double) pn[t + l] * wgt[t + l];
+                ao[l] += (double) po[t + l] * wgt[t + l];
+            }
+        vn[i] = (float) (0.5 * ((an[0] + an[1]) + (an[2] + an[3])));
+        vo[i] = (float) (0.5 * ((ao[0] + ao[1]) + (ao[2] + ao[3])));
+    }
+}
+
+void sincChunkPlain (const SincTables& T, const float* tn, const float* to, double pos0, double step, int m, int N, float* vn, float* vo) noexcept
+{
+    sincChunkBody (T, tn, to, pos0, step, m, N, vn, vo);
+}
+
+#ifdef OGUN_X86
+__attribute__ ((target ("avx"))) void sincChunkAvx (const SincTables& T, const float* tn, const float* to, double pos0, double step, int m,
+                                                   int N, float* vn, float* vo) noexcept
+{
+    sincChunkBody (T, tn, to, pos0, step, m, N, vn, vo);
+}
+#endif
+
+void sincChunk (const SincTables& T, const float* tn, const float* to, double pos0, double step, int m, int N, float* vn, float* vo) noexcept
+{
+#ifdef OGUN_X86
+    static const bool avx = ogunCpuHasAvx();
+    if (avx)
+    {
+        sincChunkAvx (T, tn, to, pos0, step, m, N, vn, vo);
+        return;
+    }
+#endif
+    sincChunkPlain (T, tn, to, pos0, step, m, N, vn, vo);
+}
+
+// radix-2 passes (decimation in time, sign +) on split re/im arrays, lengths 8…Nh: block by block up to `block`
+// points (cache-resident), then the remaining lengths over the whole array; twiddles per length contiguous
+OGUN_INLINE void fftPassesBody (double* zr, double* zi, const double* twr, const double* twi, int Nh, int block) noexcept
+{
+    auto pass = [&] (int from, int to, int L) {
+        const int h = L / 2;
+        const double* wr = twr + (h - 4);
+        const double* wi = twi + (h - 4);
+        for (int i = from; i < to; i += L)
+        {
+            double* ar = zr + i;
+            double* ai = zi + i;
+            double* br = ar + h;
+            double* bi = ai + h;
+            for (int j = 0; j < h; ++j)
+            {
+                const auto c = wr[j], s = wi[j];
+                const auto tr = br[j] * c - bi[j] * s, ti = br[j] * s + bi[j] * c;
+                const auto ur = ar[j], ui = ai[j];
+                ar[j] = ur + tr, ai[j] = ui + ti;
+                br[j] = ur - tr, bi[j] = ui - ti;
+            }
+        }
+    };
+    const int bl = std::min (block, Nh);
+    for (int start = 0; start < Nh; start += bl)
+        for (int L = 8; L <= bl; L <<= 1)
+            pass (start, start + bl, L);
+    for (int L = bl * 2; L <= Nh; L <<= 1)
+        pass (0, Nh, L);
+}
+
+void fftPassesPlain (double* zr, double* zi, const double* twr, const double* twi, int Nh, int block) noexcept
+{
+    fftPassesBody (zr, zi, twr, twi, Nh, block);
+}
+
+#ifdef OGUN_X86
+__attribute__ ((target ("avx"))) void fftPassesAvx (double* zr, double* zi, const double* twr, const double* twi, int Nh, int block) noexcept
+{
+    fftPassesBody (zr, zi, twr, twi, Nh, block);
+}
+#endif
+
+void fftPasses (double* zr, double* zi, const double* twr, const double* twi, int Nh, int block) noexcept
+{
+#ifdef OGUN_X86
+    static const bool avx = ogunCpuHasAvx();
+    if (avx)
+    {
+        fftPassesAvx (zr, zi, twr, twi, Nh, block);
+        return;
+    }
+#endif
+    fftPassesPlain (zr, zi, twr, twi, Nh, block);
+}
+
+struct Fft
+{
+    int N = 0, Nh = 0;
+    std::vector<int> rev;
+    std::vector<double> twr, twi; // per stage (length L ≥ 8): e^{2πij/L}, j < L/2, at index L/2 − 4
+    std::vector<double> hr, hi;   // e^{2πik/N}, k < Nh
+    static constexpr int block = 4096;
+
+    void init (int n)
+    {
+        N = n, Nh = n / 2;
+        int logNh = 0;
+        while ((1 << logNh) < Nh)
+            ++logNh;
+        rev.assign ((std::size_t) Nh, 0);
+        for (int i = 0; i < Nh; ++i)
+        {
+            int r = 0;
+            for (int b = 0; b < logNh; ++b)
+                if (i & (1 << b))
+                    r |= 1 << (logNh - 1 - b);
+            rev[(std::size_t) i] = r;
+        }
+        twr.assign ((std::size_t) std::max (0, Nh - 4), 0.0);
+        twi.assign (twr.size(), 0.0);
+        for (int L = 8; L <= Nh; L <<= 1)
+            for (int j = 0; j < L / 2; ++j)
+            {
+                const auto a = 2.0 * kPi * j / L;
+                twr[(std::size_t) (L / 2 - 4 + j)] = std::cos (a);
+                twi[(std::size_t) (L / 2 - 4 + j)] = std::sin (a);
+            }
+        hr.resize ((std::size_t) Nh), hi.resize ((std::size_t) Nh);
+        for (int k = 0; k < Nh; ++k)
+        {
+            const auto a = 2.0 * kPi * k / N;
+            hr[(std::size_t) k] = std::cos (a), hi[(std::size_t) k] = std::sin (a);
+        }
+    }
+
+    // e: spectrum bins 1…M (re/im float32 values); out: N float samples; z: scratch (2·Nh doubles)
+    void inverse (const float* eRe, const float* eIm, int M, float* out, double* z) const noexcept
+    {
+        double* zr = z;
+        double* zi = z + Nh;
+        // Z[k] = A + i·B, A = X[k] + conj(X[Nh−k]), B = (X[k] − conj(X[Nh−k]))·e^{2πik/N}, written bit-reversed
+        std::fill (z, z + 2 * (std::size_t) Nh, 0.0);
+        auto put = [&] (int k) {
+            double ar = 0, ai = 0, br = 0, bi = 0;
+            if (k >= 1 && k <= M)
+                ar = eRe[k - 1], ai = eIm[k - 1];
+            const int kb = Nh - k;
+            if (kb >= 1 && kb <= M)
+                br = eRe[kb - 1], bi = eIm[kb - 1];
+            const auto Ar = ar + br, Ai = ai - bi;
+            const auto Dr = ar - br, Di = ai + bi;
+            const auto Br = Dr * hr[(std::size_t) k] - Di * hi[(std::size_t) k];
+            const auto Bi = Dr * hi[(std::size_t) k] + Di * hr[(std::size_t) k];
+            const auto j = (std::size_t) rev[(std::size_t) k];
+            zr[j] = Ar - Bi;
+            zi[j] = Ai + Br;
+        };
+        const int lo = std::min (M, Nh - 1);
+        for (int k = 0; k <= lo; ++k)
+            put (k);
+        for (int k = std::max (lo + 1, Nh - M); k < Nh; ++k)
+            put (k);
+        // lengths 2 and 4 together
+        if (Nh >= 4)
+            for (int i = 0; i < Nh; i += 4)
+            {
+                double* r = zr + i;
+                double* m = zi + i;
+                const auto b0r = r[0] + r[1], b0i = m[0] + m[1], b1r = r[0] - r[1], b1i = m[0] - m[1];
+                const auto b2r = r[2] + r[3], b2i = m[2] + m[3], b3r = r[2] - r[3], b3i = m[2] - m[3];
+                r[0] = b0r + b2r, m[0] = b0i + b2i, r[2] = b0r - b2r, m[2] = b0i - b2i;
+                r[1] = b1r - b3i, m[1] = b1i + b3r, r[3] = b1r + b3i, m[3] = b1i - b3r; // ± i·b3
+            }
+        else if (Nh == 2)
+        {
+            const auto r = zr[0], i = zi[0];
+            zr[0] = r + zr[1], zi[0] = i + zi[1], zr[1] = r - zr[1], zi[1] = i - zi[1];
+        }
+        if (Nh >= 8)
+            fftPasses (zr, zi, twr.data(), twi.data(), Nh, block);
+        for (int m = 0; m < Nh; ++m)
+        {
+            out[2 * m] = (float) zr[m];
+            out[2 * m + 1] = (float) zi[m];
+        }
+    }
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// biquad designer (normalised by a0) and the library's stereo biquad
+
+struct Coef
+{
+    double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0;
+};
+
+Coef design (int dtype, double A, double p3, double sn, double cs) noexcept
+{
+    Coef c;
+    if (dtype == 6)
+    {
+        const auto d2 = (A - 1.0) * cs, q = p3 * sn;
+        const auto n = 1.0 / (A + 1.0 + d2 + q);
+        c.a1 = n * ((A - 1.0) + (A + 1.0) * cs) * -2.0;
+        c.a2 = n * ((A + 1.0 + d2) - q);
+        c.b1 = n * A * 2.0 * ((A - 1.0) - (A + 1.0) * cs);
+        c.b0 = n * A * (((A + 1.0) - d2) + q);
+        c.b2 = n * A * (((A + 1.0) - d2) - q);
+    }
+    else if (dtype == 7)
+    {
+        const auto n = 1.0 / (p3 / A + 1.0);
+        c.a1 = n * cs * -2.0;
+        c.a2 = n * (1.0 - p3 / A);
+        c.b1 = c.a1;
+        c.b0 = n * (p3 * A + 1.0);
+        c.b2 = n * (1.0 - p3 * A);
+    }
+    else if (dtype == 8)
+    {
+        const auto d2 = (A - 1.0) * cs, q = p3 * sn;
+        const auto n = 1.0 / (((A + 1.0) - d2) + q);
+        c.a1 = n * ((A - 1.0) - (A + 1.0) * cs) * 2.0;
+        c.a2 = n * (((A + 1.0) - d2) - q);
+        c.b1 = n * A * -2.0 * ((A - 1.0) + (A + 1.0) * cs);
+        c.b0 = n * A * (A + 1.0 + d2 + q);
+        c.b2 = n * A * ((A + 1.0 + d2) - q);
+    }
+    return c;
+}
+
+// direct form 1 in double per sample, float32 output (in place); afterwards the 8 state values are rounded to float32
+// and values below 2^-24 zeroed. st: x1[2], x2[2], y1[2], y2[2]
+void biquadRun (const Coef& k, double* st, float* L, float* R, int n) noexcept
+{
+    for (int ch = 0; ch < 2; ++ch)
+    {
+        float* x = ch == 0 ? L : R;
+        auto x1 = st[ch], x2 = st[2 + ch], y1 = st[4 + ch], y2 = st[6 + ch];
+        for (int i = 0; i < n; ++i)
+        {
+            const auto xv = (double) x[i];
+            const auto yv = xv * k.b0 + (((x1 * k.b1 - y2 * k.a2) + x2 * k.b2) - y1 * k.a1);
+            x[i] = (float) yv;
+            x2 = x1, x1 = xv, y2 = y1, y1 = yv;
+        }
+        st[ch] = x1, st[2 + ch] = x2, st[4 + ch] = y1, st[6 + ch] = y2;
+    }
+    for (int i = 0; i < 8; ++i)
+    {
+        const auto v = f32 (st[i]);
+        st[i] = std::fabs (v) < tiny24 ? 0.0 : v;
+    }
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// the patch: everything that depends on the state and the rate (immutable, shared by an engine's voices)
+
+constexpr double uniD[9] { 0.877, 1.069, 0.929, 1.181, 1.031, 1.129, 0.887, 1.117, 0.977 };
+
+// chorus jitter table (DATA 0x8e2b7c, round 37 §1.16)
+constexpr std::uint32_t chorusJitterBits[20] {
+    0x3f778d50, 0x3f84fdf4, 0x3f82b021, 0x3dcf7660, 0x3f7a1cac, 0x3f843958, 0x3f7f3b64, 0x3f789375, 0x3f87ced9, 0x3f726e98,
+    0x3f83f7cf, 0x3dcea4a9, 0x3f881062, 0x3f73f7cf, 0x3f7db22d, 0x3f8645a2, 0x3f7ba5e3, 0x3f86872b, 0x3f826e98, 0x3f88d4fe };
+
+struct ChorusTap
+{
+    int ch = 0;
+    float gL = 0, gR = 0;
+    double centre = 0, s8 = 0, s9 = 0, s10 = 0;
+    std::uint32_t inc = 0, ph0 = 0;
+};
+
+struct Art
+{
+    double base = 0, envamt = 0, lfoamt = 0;
+    int mode = 0;
+    Curve env, lfo, key, vel;
+    std::array<int, 4> adsr {}, lfoKnobs {};
+    int lfoExtra = 0;
+    std::vector<float> xtab, ytab; // 513 points
+};
+
+struct Patch
+{
+    StateData S;
+    std::array<std::int32_t, 64> P {};
+    std::array<std::uint8_t, 0x28> fl {}; // bytes +0x200…+0x227
+    int quality = 0, interp = 1, qt = 0, osf = 1, rich = 0, N = 0, M = 0, hop = 0, B = 0, Lmap = 0;
+    double hopMs = 50, fsHost = 44100, fs = 44100, r588 = 1, xysmooth = 0, tempo = 140, envRate = 0, envRateTempo = 0;
+    bool oversampleFilter = true;
+    double rateLimit = 0, declickLen = 0, master = 1;
+    int masterCents = 0;
+    double pre = 0, dec = -1, rel = 0, full = 0, morph = 0, fcut = 0, fres = 0;
+    long long seed1 = -1, seed2 = -1;
+    int ftype = 0, forder = 0, fflat = 0;
+    bool alt = false, norm = false, isqrt = false, logx = false;
+    std::array<Art, 13> arts;
+    bool hasForced = false;
+    std::vector<float> mForced, mImp, mDec, mRel; // forced stored as 1 − F (length M); others ≥ M
+    int first = 0, last = 0;
+    double gnorm = 1.0;
+    std::vector<float> phRe, phIm;
+    Fft fft;
+    double speedK = 0; // f32(33488.07421875·2^q)
+    // EQ
+    struct Band
+    {
+        bool on = false;
+        Coef c;
+    };
+    std::array<Band, 3> eq;
+    // chorus
+    bool chorusOn = false;
+    float chorusDry = 1;
+    std::vector<ChorusTap> taps;
+    int chorusD = 0, chorusRing = 0;
+    // delay
+    bool delayOn = false;
+    int delaySize = 0, delayLen = 1, delayOffL = 0, delayOffR = 0, delayMode = 0;
+    double delayFb = 0, delayWet = 0;
+    // reverb
+    bool reverbOn = false;
+    PlateReverb reverbProto; // coefficients and line lengths (lines empty; the engine allocates its own)
+    int reverbPre = 1;
+    float reverbWet = 0;
+    int tailLen = 0;
+    int maxBlock = 512;
+    std::vector<std::string> fallbacks;
+
+    std::uint8_t flag (int off) const noexcept { return fl[(std::size_t) (off - 0x200)]; }
+};
+
+std::shared_ptr<Patch> buildPatch (const StateData& S, double fsHost, int quality, double tempo, int maxBlock)
+{
+    auto pp = std::make_shared<Patch>();
+    auto& p = *pp;
+    p.S = S;
+    p.P = S.P;
+    const auto& P = p.P;
+    for (int o = 0x200; o < 0x228; ++o)
+        p.fl[(std::size_t) (o - 0x200)] = S.byte (o);
+    p.fsHost = fsHost;
+    p.maxBlock = maxBlock;
+    const int q = std::clamp (quality >= 0 ? quality : P[54], 0, 4);
+    p.quality = q;
+    static constexpr int tab[5][5] { { 1, 0, 50, 96, 0 }, { 2, 0, 50, 96, 0 }, { 2, 1, 50, 48, 1 }, { 2, 2, 25, 24, 1 }, { 6, 2, 25, 8, 1 } };
+    p.interp = tab[q][0];
+    p.qt = tab[q][1];
+    p.hopMs = tab[q][2];
+    const int ctl = tab[q][3];
+    p.osf = tab[q][4] ? 2 : 1;
+    const auto fs = fsHost * p.osf;
+    p.fs = fs;
+    p.rich = std::clamp ((int) P[52], 2, 16);
+    if (p.rich != P[52])
+        p.fallbacks.push_back ("richness out of range");
+    if (p.rich < 10 && fs < 88200.0 && p.qt < 1)
+        p.qt = 1;
+    p.N = 1 << (p.rich + p.qt);
+    p.M = (1 << (p.rich - 1)) - 1;
+    p.hop = (int) rnd (p.hopMs * 0.001 * fs);
+    const auto r588 = ctl * fs / 44100.0;
+    p.B = std::max (4, (int) rnd (r588 / 4.0) * 4);
+    p.r588 = (p.B * (double) ctl) / (r588 * 96.0);
+    p.xysmooth = f32 (std::exp (std::log (0.01) * p.r588 / 96.0));
+    p.tempo = tempo;
+    const auto d3 = (p.r588 * 96.0) / 44100.0;
+    p.envRate = d3 * 2.0;
+    p.envRateTempo = d3 * tempo / 60.0;
+    p.oversampleFilter = fs < 88200.0;
+    p.rateLimit = f32 (0.001 * 44100.0 / fs);
+    const auto r20 = 44100.0 / fs;
+    p.declickLen = f32 (96.0 / (r20 * r20));
+    const auto x = f32 (P[0] * 0.0078125);
+    p.master = x == 1.0 ? 1.0 : f32 ((std::exp (x * f32 (std::log (3.0))) - 1.0) * 0.5);
+    p.masterCents = P[1] * 100 + P[2];
+    p.pre = f32 (P[5] * f32 (0.001));
+    p.dec = P[6] == 10000 ? -1.0 : f32 (P[6] * 0.0001);
+    p.rel = f32 (P[7] * 0.0001);
+    p.full = f32 (P[8] * f32 (0.001));
+    p.morph = f32 (P[9] * f32 (0.001));
+    p.seed1 = P[10] - 1 < 0 ? -1 : mix32 ((long long) P[10] - 0x20cf, 0x1cfc);
+    p.seed2 = P[11] - 1 < 0 ? -1 : mix32 ((long long) P[11] - 0x20cf, 0x1cfc);
+    p.fcut = f32 (P[17] * 0.00390625);
+    p.fres = f32 (P[18] * 0.00390625);
+    p.ftype = P[49], p.forder = P[50], p.fflat = P[51];
+    if (p.forder > 0 && (p.ftype < 0 || p.ftype > 3))
+    {
+        p.fallbacks.push_back ("unknown filter type (filter off)");
+        p.forder = 0;
+    }
+    p.forder = std::min (p.forder, 8);
+    p.alt = p.flag (0x224) != 0;
+    p.norm = p.flag (0x225) != 0;
+    p.isqrt = p.flag (0x226) != 0;
+    p.logx = p.flag (0x213) != 0;
+    // articulators
+    for (int k = 0; k < 13; ++k)
+    {
+        const auto& a = S.arts[(std::size_t) k];
+        auto& A = p.arts[(std::size_t) k];
+        A.base = a.base, A.envamt = a.envamt, A.lfoamt = a.lfoamt, A.mode = a.mode;
+        A.env.build (a.env, -1.0);
+        A.lfo.build (a.lfo, -1.0);
+        A.key.build (a.key, 1.0);
+        A.vel.build (a.vel, 1.0);
+        A.adsr = a.adsr, A.lfoKnobs = a.lfoKnobs, A.lfoExtra = a.lfoExtra;
+        for (int t = 0; t < 2; ++t)
+        {
+            const Curve c (t == 0 ? a.X : a.Y, 1.0);
+            const auto v = c.render (513, f32 (1.0 / 512.0));
+            auto& dst = t == 0 ? A.xtab : A.ytab;
+            dst.resize (513);
+            for (int i = 0; i < 513; ++i)
+                dst[(std::size_t) i] = (float) v[(std::size_t) i];
+        }
+        if (k < 5 && a.lfo.enabled && (a.lfo.flags & 2))
+            p.fallbacks.push_back ("global LFO (runs per voice)");
+    }
+    // per-partial maps (FUN_0086e6c0, FUN_00842960)
+    const int M = p.M;
+    const int L = std::min (M + M / 2, 0x8000);
+    p.Lmap = L;
+    std::vector<double> xs ((std::size_t) L);
+    for (int i = 0; i < L; ++i)
+        xs[(std::size_t) i] = (p.logx ? std::log2 (i + 1.0) / 15.0 : i / 32767.0) + 5.960464477539063e-08;
+    std::vector<double> tmp ((std::size_t) L);
+    const float fill[4] { 0.0f, 0.0f, 1.0f, 1.0f };
+    const double ln3 = std::log (3.0);
+    for (int k = 13; k <= 16; ++k)
+    {
+        const Curve c (S.maps[(std::size_t) (k - 13)], 1.0);
+        auto& dst = k == 13 ? p.mForced : k == 14 ? p.mImp : k == 15 ? p.mDec : p.mRel;
+        if (k == 13 && c.isConstant() && c.y[0] == 0.0)
+        {
+            p.hasForced = false;
+            continue;
+        }
+        if (k == 13)
+            p.hasForced = true;
+        const int n = k == 13 ? M : L;
+        c.seqEval (xs.data(), n, tmp.data());
+        std::vector<float> v ((std::size_t) n);
+        for (int i = 0; i < n; ++i)
+            v[(std::size_t) i] = std::clamp ((float) tmp[(std::size_t) i], 0.0f, 1.0f);
+        if (k != 13)
+            for (auto& e : v)
+                e = e * 2.0f == 1.0f ? 1.0f : (float) ((std::exp ((double) (e * 2.0f * (float) ln3)) - 1.0) * 0.5);
+        if (p.isqrt && k <= 14 + (p.alt ? 1 : 0))
+            for (int i = 0; i < n; ++i)
+                v[(std::size_t) i] = v[(std::size_t) i] * (float) (1.0 / std::sqrt ((double) (i + 1)));
+        const auto pat = P[58 + (k - 13)];
+        if (pat > 0)
+            for (int i = 0; i < n; ++i)
+                if (pat < 5 ? (i % (pat + 1) == pat) : (pat - 2 != 0 && i % (pat - 2) > 0))
+                    v[(std::size_t) i] = fill[k - 13];
+        int ln = n;
+        while (ln > M && v[(std::size_t) (ln - 1)] == v[(std::size_t) (ln - 2)])
+            --ln;
+        v.resize ((std::size_t) ln);
+        if (k == 13)
+            for (auto& e : v)
+                e = 1.0f - e;
+        dst = std::move (v);
+    }
+    // update span
+    {
+        const auto& Ei = p.mImp;
+        const auto& Ed = p.mDec;
+        int fi = -1, la = -1;
+        for (int i = 0; i < M; ++i)
+        {
+            const bool nz = p.alt ? std::fabs ((double) Ei[(std::size_t) i] - (double) Ed[(std::size_t) i]) > tiny24
+                                  : (double) Ei[(std::size_t) i] > tiny24;
+            if (nz)
+            {
+                if (fi < 0)
+                    fi = i;
+                la = i;
+            }
+        }
+        p.first = fi >= 0 ? fi : M;
+        p.last = la >= 0 ? la + 1 : M;
+        p.gnorm = 1.0;
+        if (p.norm)
+        {
+            auto rmsOf = [&] (const std::vector<float>& v) {
+                std::vector<float> sq (v.size());
+                for (std::size_t i = 0; i < v.size(); ++i)
+                    sq[i] = v[i] * v[i];
+                const auto s = sq.empty() ? 0.0f : sq[0] + pairwiseSum<float> (sq.data() + 1, sq.size() - 1);
+                return std::sqrt ((double) s / M);
+            };
+            auto r = rmsOf (Ei);
+            if (p.alt)
+                r = std::max (r, rmsOf (Ed));
+            if (r > tiny24)
+                p.gnorm = f32 (0.5 / r);
+        }
+    }
+    // phases (seed 3)
+    {
+        std::vector<float> th ((std::size_t) M);
+        rand32f (th.data(), M, 0.0f, 6.2831855f, 3);
+        const auto s = 1.0 / std::sqrt ((double) M);
+        p.phRe.resize ((std::size_t) M), p.phIm.resize ((std::size_t) M);
+        for (int i = 0; i < M; ++i)
+        {
+            auto re = (float) (s * std::cos ((double) th[(std::size_t) i]));
+            auto im = (float) (s * std::sin ((double) th[(std::size_t) i]));
+            p.phRe[(std::size_t) i] = std::fabs (re) < (float) tiny24 ? 0.0f : re;
+            p.phIm[(std::size_t) i] = std::fabs (im) < (float) tiny24 ? 0.0f : im;
+        }
+    }
+    p.fft.init (p.N);
+    p.speedK = f32 (f32 (33488.07421875) * (double) (1 << p.qt));
+    // EQ (FUN_0086a670, FUN_00625290)
+    for (int k = 0; k < 3; ++k)
+    {
+        const auto level = f32 (P[40 + k] * f32 (0.01));
+        auto fq = f32 (f32 (std::exp (f32 (P[43 + k] * 1.52587890625e-05) * std::log (101.0)) - 1.0) * 159.9 + 10.0);
+        const auto width = f32 (P[46 + k] * 1.52587890625e-05);
+        const int dtype = S.eqtype[(std::size_t) k] + 6;
+        const auto nyq = f32 (fs * 0.4999);
+        if (fq > nyq)
+            fq = nyq;
+        const auto w = fq * (2.0 * kPi / fs);
+        const auto sn = std::sin (w), cs = std::cos (w);
+        double A, p3;
+        if (dtype == 7)
+        {
+            A = std::exp (level * 0.025 * std::log (10.0));
+            const auto f1 = f32 (std::exp (width * std::log (1001.0)) - 1.0);
+            p3 = sn / ((f1 * 0.0999 + 0.1) * 2.0);
+        }
+        else
+        {
+            A = std::exp (level * 0.025 * std::log (10.0));
+            p3 = std::sqrt ((A * A + 1.0) / (width * 1.9 + 0.1) - (A - 1.0) * (A - 1.0));
+        }
+        auto& b = p.eq[(std::size_t) k];
+        b.on = level != 0.0 && dtype >= 6 && dtype <= 8;
+        if (level != 0.0 && ! b.on)
+            p.fallbacks.push_back ("unknown EQ band type (band off)");
+        if (b.on)
+            b.c = design (dtype, A, p3, sn, cs);
+    }
+    p.tailLen = (int) ((long long) fs * 100 / 44100);
+    // chorus (FUN_0086a2d0, FUN_00840690; our ogfx_chorus.py)
+    if (P[19] >= 1)
+    {
+        p.chorusOn = true;
+        const int order = std::max ((int) P[19], 1);
+        const auto depth = f32 (P[20] * 0.0009765625), speed = f32 (P[21] * 0.0009765625);
+        const auto delay = (double) ((float) P[22] * 0.0078125f);
+        const auto spread = (double) ((float) P[23] * 0.0078125f);
+        const auto cross = (double) ((float) P[24] * 0.0078125f);
+        const auto m = (double) ((float) std::abs ((int) P[25]) * 0.0078125f);
+        const double LN11 = std::log (11.0), LN101 = std::log (101.0), LN1001 = std::log (1001.0), LN5 = std::log (5.0);
+        p.chorusDry = (float) (1.0f - (float) (std::exp (m * LN5) - 1.0) * 0.25f);
+        const int sg = P[25] == 0 ? 0 : (P[25] > 0 ? 1 : -1);
+        const auto wet = (float) ((float) sg * (1.0f - (float) (std::exp ((double) (float) (1.0f - (float) m) * LN5) - 1.0) * 0.25f));
+        auto warp = [&] (double v, double scale) { return (float) ((float) (std::exp ((double) (float) v * LN11) - 1.0) * (float) ((float) scale / 10.0f)); };
+        const auto A = warp (depth, 1092.5);
+        const auto r = f32 (std::exp ((double) (float) (1.0f - (float) speed) * LN101) - 1.0);
+        const auto K = (2147483648.0 / (r * 75000.0 + 50000.0)) * 500.0;
+        const auto Bd = warp (delay, 4410.0);
+        const auto sp = (float) ((float) (std::exp (spread * LN1001) - 1.0) / 1000.0f);
+        const auto fsr = (float) (44100.0 / (double) (int) fs);
+        auto xmix = [&] (double a, double b) { return a * (double) sp + b * (double) (1.0f - sp); };
+        const int cnt = 2 * order;
+        float maxd = 0.0f, gsum = 0.0f;
+        for (int i = 0; i < cnt; ++i)
+        {
+            float t;
+            int ch;
+            std::uint32_t ph0;
+            if (i < order)
+                t = (float) i, ch = 0, ph0 = 0;
+            else
+                t = (float) (cnt - i - 1), ch = 1, ph0 = 0x80000000u;
+            const float w = 1.0f - t / (float) order;
+            float jt;
+            std::memcpy (&jt, &chorusJitterBits[i % 20], 4);
+            const auto jj = f32 (xmix ((double) (jt * jt), 1.0));
+            float gL = 1.0f, gR = (float) cross * w;
+            if (ch)
+                std::swap (gL, gR);
+            gsum = (float) ((double) gsum + std::fabs ((double) gL) + std::fabs ((double) gR));
+            auto base = A * w + 10.0f;
+            const auto k0 = K / (double) (A + 10.0f);
+            const auto k1 = K * jj / (double) base;
+            const auto kk = xmix (k1, k0);
+            const auto dmod = (float) xmix ((double) ((Bd * w) * (float) jj), (double) Bd);
+            const auto off = (long long) rnd ((double) ((w * sp) * 2147483648.0f / 256.0f));
+            ph0 = (std::uint32_t) (ph0 + (std::uint32_t) ((std::uint64_t) off << 8));
+            const auto inc = (std::uint32_t) (std::int64_t) rnd (kk * (double) fsr);
+            base = base / fsr;
+            auto qd = dmod / fsr;
+            if (! (qd > 8.0f))
+                qd = 8.0f;
+            const float centre = base + qd;
+            const float v = centre + base;
+            if (! (maxd > v))
+                maxd = v;
+            const auto sq = std::sqrt ((double) (base * 4.0f));
+            ChorusTap tp;
+            tp.ch = ch, tp.gL = gL, tp.gR = gR, tp.centre = (double) centre, tp.inc = inc, tp.ph0 = ph0;
+            tp.s8 = f32 (sq / 2147483648.0), tp.s9 = f32 (sq), tp.s10 = f32 (sq / 2.0);
+            p.taps.push_back (tp);
+        }
+        auto g = (float) (1.0f - (float) (std::exp ((double) (float) (1.0f - 1.0f / gsum) * LN1001) - 1.0) / 1000.0f);
+        g = g * wet;
+        for (auto& tp : p.taps)
+            tp.gL = tp.gL * g, tp.gR = tp.gR * g;
+        p.chorusD = (int) rnd ((double) maxd) + 8;
+        p.chorusRing = maxBlock * p.osf + p.chorusD;
+        p.tailLen += p.chorusRing;
+    }
+    // delay (FUN_00869dd0; our ogfx_delay.py)
+    if (S.b358[1])
+    {
+        p.delayOn = true;
+        const int ifs = (int) fs;
+        const auto a = f32 (std::abs ((int) P[28]) * 0.001953125);
+        const auto factor = f32 (f32 (std::exp (a * std::log (1001.0)) - 1.0) * 50.0);
+        const int off = (int) rnd ((double) ((float) factor * (float) ifs / 100000.0f));
+        double d;
+        if (S.b358[0] != 0)
+            d = ((double) P[27] * ifs) * 0.3125 / f32 (tempo);
+        else
+            d = ((double) P[27] * ifs) / 384.0;
+        p.delayLen = std::max (1, (int) rnd (d));
+        p.delaySize = maxBlock * p.osf + off + p.delayLen;
+        p.delayOffL = P[28] > 0 ? 0 : off;
+        p.delayOffR = P[28] > 0 ? off : 0;
+        p.delayFb = f32 (P[26] * 0.0078125);
+        const auto v = f32 (P[29] * 0.0078125);
+        const auto av = f32 (std::fabs (v));
+        double g;
+        if (av == 1.0)
+            g = 1.0;
+        else
+            g = f32 ((std::exp ((double) ((float) av * 2.39789534f)) - 1.0) * f32 (0.1));
+        p.delayWet = f32 (g * (v == 0.0 ? 0.0 : (v < 0.0 ? -1.0 : 1.0)));
+        p.delayMode = P[30];
+    }
+    // reverb (FUN_0086a0a0, FUN_0083f840; DSP in core/PlateReverb.h)
+    if (P[53] & 0xff)
+    {
+        p.reverbOn = true;
+        const int ifs = (int) fs;
+        double pd;
+        if (p.flag (0x201))
+            pd = ((double) P[33] * ifs) * 0.3125 / f32 (tempo);
+        else
+            pd = ((double) P[33] * ifs) / 384.0;
+        p.reverbPre = std::max (1, (int) rnd (pd));
+        const auto decay = f32 (((double) P[36] * ifs) / 10.0);
+        const auto lowcut = P[31] == 0x13 ? 0.0 : (double) P[31];
+        const auto highcut = P[32] == 0xdd ? 0.0 : (double) P[32];
+        const auto damp = P[37] == 0xdd ? 0.0 : (double) P[37];
+        const int room = P[34], diff = P[35], colour = P[38];
+        p.reverbWet = (float) P[39] * 0.00390625f;
+        auto& R = p.reverbProto;
+        const auto inv = f32 (1.0 / ifs);
+        auto onepole = [&] (double f) {
+            if (f == 0.0)
+                return 1.0f;
+            const auto h = f32 (ifs * 0.5);
+            if (! (h > f))
+                f = h;
+            const auto w = f * 628.3185307179587 * inv;
+            const auto b = f32 (2.0 - std::cos (w));
+            const auto bb = f32 (b * b);
+            return (float) (1.0 - (b - std::sqrt (bb - 1.0)));
+        };
+        if (lowcut == 0.0)
+            R.cLc = 0.0f;
+        else
+        {
+            auto f = lowcut;
+            const auto h = f32 (ifs * 0.5);
+            if (! (h > f))
+                f = h;
+            const auto t = f32 (std::tan (f * kPi * inv));
+            R.cLc = (float) ((t - 1.0) / (t + 1.0));
+        }
+        R.cHc = onepole (highcut);
+        auto muldiv = [] (long long a, long long b, long long c) {
+            const auto pr = a * b;
+            const auto qq = std::llabs (pr) / std::llabs (c);
+            return (pr >= 0) == (c > 0) ? qq : -qq;
+        };
+        const auto Rr = muldiv (ifs, room + 15, 0x73);
+        for (int i = 0; i < 12; ++i)
+            R.L[(std::size_t) i] = (int) std::max (1LL, muldiv (PlateReverb::lines[i], Rr, 20000));
+        for (int i = 0; i < 7; ++i)
+            R.tl[(std::size_t) i] = (int) muldiv (PlateReverb::tapsL[i], Rr, 20000), R.tr[(std::size_t) i] = (int) muldiv (PlateReverb::tapsR[i], Rr, 20000);
+        const auto fd = f32 (diff * 0.01), hh = f32 (inv * 0.5);
+        const double LN_1E3 = std::log (0.001);
+        if (fd == 0.0)
+            R.cIn = R.c1 = R.c2 = 0.0f;
+        else
+        {
+            auto gg = [&] (int a, int b, double kf) {
+                const auto xx = (double) ((float) (a + b) * (float) hh);
+                return (float) std::exp (LN_1E3 * xx / (fd * kf));
+            };
+            R.cIn = gg (R.L[0], R.L[1], 0.07);
+            R.c1 = gg (R.L[4], R.L[8], 0.35);
+            R.c2 = gg (R.L[6], R.L[10], 0.51);
+        }
+        const auto Ssum = (double) (float) (R.L[5] + R.L[7] + R.L[9] + R.L[11]);
+        R.g = (float) std::exp (0.25 * (LN_1E3 * Ssum / decay));
+        R.cDamp = onepole (damp);
+        const auto kc = colour >= 0 && colour <= 4 ? PlateReverb::colourFactor[colour] : 1.0;
+        const auto d2 = f32 (std::exp (0.25 * (LN_1E3 * Ssum / f32 (decay * (double) (float) kc))));
+        auto rr = f32 (d2 / (double) R.g);
+        R.c48 = (float) ((rr - 1.0) * 0.5);
+        if (rr > 1.0)
+            rr = 1.0;
+        const auto t = (float) std::tan (500.0 * kPi * inv);
+        R.c44 = (float) ((float) (t - (float) rr) / (float) (t + (float) rr));
+    }
+    return pp;
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// voice
+
+struct Sub
+{
+    double pos = 0, ratio = 1, L = 0, R = 0, det = 0;
+    float g[4] {}, d[4] {};
+};
+
+// cumulative float32 gain ramp for one chunk (values g, g+d, g+2d...)
+inline void accRamp (float& g, float d, int m, float* out) noexcept
+{
+    if (d == 0.0f)
+    {
+        for (int i = 0; i < m; ++i)
+            out[i] = g;
+        return;
+    }
+    auto x = g;
+    for (int i = 0; i < m; ++i)
+    {
+        out[i] = x;
+        x = x + d;
+    }
+    g = x;
+}
+
+inline double hermite6 (double ym2, double ym1, double y0, double y1, double y2, double y3, double x) noexcept
+{
+    const auto c0 = y0;
+    const auto c1 = 1.0 / 12 * (ym2 - y2) + 2.0 / 3 * (y1 - ym1);
+    const auto c2 = 13.0 / 12 * ym1 - 25.0 / 12 * y0 + 3.0 / 2 * y1 - 11.0 / 24 * y2 + 1.0 / 12 * y3 - 1.0 / 8 * ym2;
+    const auto c3 = 5.0 / 12 * y0 - 7.0 / 12 * y1 + 7.0 / 24 * y2 - 1.0 / 24 * (ym2 + ym1 + y3);
+    const auto c4 = 1.0 / 8 * ym2 - 7.0 / 12 * ym1 + 13.0 / 12 * y0 - y1 + 11.0 / 24 * y2 - 1.0 / 12 * y3;
+    const auto c5 = 1.0 / 24 * (y3 - ym2) + 5.0 / 24 * (ym1 - y2) + 5.0 / 12 * (y1 - y0);
+    return ((((c5 * x + c4) * x + c3) * x + c2) * x + c1) * x + c0;
+}
+
+class Engine;
+
+struct Voice
+{
+    // buffers sized for the patch (allocated once per pool slot)
+    std::vector<float> tA, tB;            // two tables (N + 64 guard samples)
+    float* tNew = nullptr;
+    float* tOld = nullptr;
+    std::vector<float> eRe, eIm, tgRe, tgIm, fac, Bw;
+    std::vector<float> xL, xR, fL, fR;   // chunk buffers (control block), filter at 2×
+    std::vector<SincTables> sinc;        // quality 4: per sub-voice reader tables
+
+    // identity / host
+    bool used = false, dead = false;
+    long long id = 0;
+    int lynxKey = -1;
+    bool lynxReleased = false;
+    double notePan = 0;
+    double fvol = 1, fpan = 0, fcutH = 0, fresH = 0, FP = 0, relvel = 0, note = 0, vel = 0;
+    int keyi = 0, state = 1, cnt = 0;
+    bool firstChunk = true;
+    double xy[2] {};
+    int ixy[2] {};
+    double stat[13] {}, out[13] {};
+    EnvRun envs[5];
+    LfoRun lfos[5];
+    bool lfoOn[5] {}, en[5] {};
+    double cents0 = 0, cents = 0, upitch = 0, S = 0;
+    int envmin = 9;
+    float gt[4] {}, gc[4] {}, gs[4] {}, gd[4] {};
+    std::vector<std::array<double, 8>> fst;
+    int declick = -1;
+    float dcG = 0, dcD = 0, dcL = 0, dcR = 0;
+    bool timRelOnEnv = false, timReleased = false;
+
+    // timbre (§1.7)
+    double tpre = 0, decSamples = 0, p = 0, tmorph = 0, speed = 0, c = 1;
+    long long seed1 = -1, seed2 = -1;
+    bool alt = false, started = false;
+    int shift = 0, rot = 0, nsub = 1;
+    std::array<Sub, 9> subs;
+    long long cntTotal = 0, frameEnd = 0, inFrame = 0;
+    long long silence = 0;
+    double thr = 0;
+    int tstate = 0, band = 0, tfirst = 0, tlast = 0;
+};
+
+class Engine
+{
+public:
+    static constexpr int maxHostBlock = 512;
+    static constexpr int maxVoices = 64;
+
+    explicit Engine (std::shared_ptr<const Patch> patch)
+        : pt (std::move (patch))
+    {
+        const auto& p = *pt;
+        nb = maxHostBlock * p.osf;
+        bufL.assign ((std::size_t) nb, 0.0f), bufR.assign ((std::size_t) nb, 0.0f);
+        tmpL.assign ((std::size_t) nb, 0.0f), tmpR.assign ((std::size_t) nb, 0.0f);
+        mono.assign ((std::size_t) nb, 0.0f);
+        zr.assign (2 * (std::size_t) p.fft.Nh, 0.0);
+        sU.assign ((std::size_t) p.M, 0.0f), sV.assign ((std::size_t) p.M, 0.0f), sD.assign ((std::size_t) p.M, 0.0f);
+        rampBuf.assign (8 * (std::size_t) p.B, 0.0f);
+        if (p.interp == 6)
+            sincN.assign ((std::size_t) p.B, 0.0f), sincO.assign ((std::size_t) p.B, 0.0f);
+        for (auto& e : eqSt)
+            e.fill (0.0);
+        if (p.chorusOn)
+        {
+            chorusPh.resize (p.taps.size());
+            for (std::size_t i = 0; i < p.taps.size(); ++i)
+                chorusPh[i] = p.taps[i].ph0;
+            int sz = 1;
+            while (sz < nb + p.chorusD + 16)
+                sz <<= 1;
+            ringL.assign ((std::size_t) sz, 0.0f), ringR.assign ((std::size_t) sz, 0.0f);
+            ringMask = sz - 1;
+        }
+        if (p.delayOn)
+        {
+            dline.assign (2 * (std::size_t) p.delaySize, 0.0f);
+            dr = 0, dw = p.delayLen;
+            fbCur = p.delayFb;
+        }
+        if (p.reverbOn)
+        {
+            reverb = p.reverbProto;
+            reverb.allocate (p.reverbPre);
+        }
+        decSt.fill (0.0);
+        quietNeeded = (long long) (2.0 * p.fsHost) + (p.chorusOn ? p.chorusRing : 0) + (p.delayOn ? 4LL * p.delaySize : 0)
+                      + (p.reverbOn ? (long long) p.reverbPre + reverb.L[5] + reverb.L[9] : 0);
+        quietFor = quietNeeded;
+        pool.reserve (maxVoices);
+        order.reserve (maxVoices);
+        grow (std::min (4, maxVoices));
+    }
+
+    const Patch& patch() const noexcept { return *pt; }
+
+    // host values
+    int counter = 0;
+    int maxpoly = 0;
+    bool hostKills = true;
+    double hostEv2 = 0;
+
+    // (key, velocity, Final.Vol, Final.Pan, Final.Pitch offset cents, FCut, FRes, release velocity) → voice id
+    long long noteOn (int key, double vel, double fvol, double fpan, double pofs, double fcut = 0, double fres = 0,
+                      double relvel = 0, int j0shift = 0, int lynxKey = -1, double notePan = 0) noexcept
+    {
+        const auto& p = *pt;
+        if (0 < maxpoly && maxpoly <= nlisted)
+        {
+            Voice* lastAct = nullptr;
+            int act = 0;
+            for (auto* u : order)
+                if (u->state < 9)
+                    ++act, lastAct = u;
+            if (act >= maxpoly && lastAct != nullptr)
+                kill (*lastAct);
+        }
+        if (p.flag (0x209) && nlisted > 0)
+        {
+            const float fp = (float) (100.0 * key - 6000.0 + pofs);
+            const auto kk = (int) rnd (std::max ((double) (fp * 0.01f + 60.0f), 0.0));
+            for (auto* u : order)
+                if (u->keyi == kk && u->state < 9)
+                    kill (*u);
+        }
+        Voice* v = freeVoice();
+        if (v == nullptr)
+            return -1;
+        startVoice (*v, key, vel, fvol, fpan, pofs, fcut, fres, relvel);
+        v->id = ++serial;
+        v->lynxKey = lynxKey;
+        v->lynxReleased = false;
+        v->notePan = notePan;
+        v->used = true;
+        order.push_back (v);
+        ++nlisted;
+        if (j0shift != 0)
+            j0Map.push_back ({ v, j0shift });
+        return v->id;
+    }
+
+    void release (long long id) noexcept
+    {
+        for (auto* v : order)
+            if (v->id == id)
+                voiceRelease (*v);
+    }
+
+    // LYNX: releases the oldest held note of a key
+    void releaseKey (int key) noexcept
+    {
+        for (auto* v : order)
+            if (v->lynxKey == key && ! v->lynxReleased)
+            {
+                v->lynxReleased = true;
+                voiceRelease (*v);
+                return;
+            }
+    }
+
+    void killAll() noexcept
+    {
+        for (auto* v : order)
+            kill (*v);
+    }
+
+    void setLevels (double fvol, double fpan) noexcept
+    {
+        for (auto* v : order)
+            v->fvol = fvol, v->fpan = v->notePan + fpan;
+    }
+
+    int voices() const noexcept { return (int) order.size(); }
+    bool quiet() const noexcept { return order.empty() && quietFor >= quietNeeded; }
+
+    // one host block (n ≤ maxHostBlock): adds to out
+    void render (float* outL, float* outR, int n) noexcept
+    {
+        const auto& p = *pt;
+        const int m = n * p.osf;
+        std::fill (bufL.begin(), bufL.begin() + m, 0.0f);
+        std::fill (bufR.begin(), bufR.begin() + m, 0.0f);
+        if (nlisted < 1)
+        {
+            if (tail > 0)
+                tail -= m;
+        }
+        else
+            tail = p.tailLen;
+        for (std::size_t i = 0; i < order.size();)
+        {
+            auto* v = order[i];
+            renderVoice (*v, bufL.data(), bufR.data(), m);
+            if (v->dead)
+            {
+                order.erase (order.begin() + (std::ptrdiff_t) i);
+                v->used = false;
+                for (auto& j : j0Map)
+                    if (j.first == v)
+                        j.first = nullptr;
+                if (hostKills)
+                    --nlisted;
+            }
+            else
+                ++i;
+        }
+        for (int k = 0; k < 3; ++k)
+            if (p.eq[(std::size_t) k].on)
+                biquadRun (p.eq[(std::size_t) k].c, eqSt[(std::size_t) k].data(), bufL.data(), bufR.data(), m);
+        if (p.chorusOn)
+            chorus (m, tail > 0);
+        if (p.delayOn)
+            delay (m, tail > 0);
+        if (p.reverbOn)
+        {
+            for (int i = 0; i < m; ++i)
+                mono[(std::size_t) i] = bufL[(std::size_t) i] + bufR[(std::size_t) i];
+            reverb.process (mono.data(), tmpL.data(), tmpR.data(), m);
+            for (int i = 0; i < m; ++i)
+            {
+                bufL[(std::size_t) i] = bufL[(std::size_t) i] + tmpL[(std::size_t) i] * p.reverbWet;
+                bufR[(std::size_t) i] = bufR[(std::size_t) i] + tmpR[(std::size_t) i] * p.reverbWet;
+            }
+        }
+        if (p.osf > 1)
+            decimate (m);
+        float peak = 0.0f;
+        for (int i = 0; i < n; ++i)
+        {
+            outL[i] += bufL[(std::size_t) i];
+            outR[i] += bufR[(std::size_t) i];
+            peak = std::max (peak, std::max (std::fabs (bufL[(std::size_t) i]), std::fabs (bufR[(std::size_t) i])));
+        }
+        if (! order.empty() || peak > 1.0e-7f)
+            quietFor = 0;
+        else
+            quietFor += n;
+    }
+
+    // nothing sounds: only the chorus phases (and the effect tail counter) advance, as in Gen_Render without voices
+    void skip (int n) noexcept
+    {
+        const auto& p = *pt;
+        const int m = n * p.osf;
+        if (tail > 0)
+            tail -= m;
+        if (p.chorusOn)
+            for (std::size_t i = 0; i < chorusPh.size(); ++i)
+                chorusPh[i] = chorusPh[i] + p.taps[i].inc * (std::uint32_t) m;
+        if (p.delayOn)
+        {
+            dr = (int) ((dr + (long long) m) % p.delaySize);
+            dw = (int) ((dw + (long long) m) % p.delaySize);
+        }
+    }
+
+private:
+    std::shared_ptr<const Patch> pt;
+    std::vector<std::unique_ptr<Voice>> pool;
+    std::vector<Voice*> order; // listed voices in note-on order
+    std::vector<std::pair<Voice*, int>> j0Map;
+    long long serial = 0;
+    int nlisted = 0, tail = 0, nb = 0;
+    std::vector<float> bufL, bufR, tmpL, tmpR, mono;
+    std::vector<double> zr;
+    std::vector<float> sU, sV, sD, rampBuf;
+    std::array<std::array<double, 8>, 3> eqSt {};
+    // chorus
+    std::vector<std::uint32_t> chorusPh;
+    std::vector<float> ringL, ringR;
+    int ringMask = 0, ringPos = 0;
+    // delay
+    std::vector<float> dline;
+    int dr = 0, dw = 0;
+    double fbCur = 0;
+    // reverb
+    PlateReverb reverb;
+    // decimator: per channel 12 doubles
+    std::array<double, 24> decSt {};
+    long long quietFor = 0, quietNeeded = 0;
+
+    void grow (int count)
+    {
+        const auto& p = *pt;
+        for (int i = 0; i < count && (int) pool.size() < maxVoices; ++i)
+        {
+            auto v = std::make_unique<Voice>();
+            v->tA.assign ((std::size_t) p.N + 64, 0.0f);
+            v->tB.assign ((std::size_t) p.N + 64, 0.0f);
+            v->eRe.assign ((std::size_t) p.M, 0.0f), v->eIm.assign ((std::size_t) p.M, 0.0f);
+            if (p.alt)
+                v->tgRe.assign ((std::size_t) p.M, 0.0f), v->tgIm.assign ((std::size_t) p.M, 0.0f);
+            v->fac.assign ((std::size_t) p.M, 0.0f), v->Bw.assign ((std::size_t) p.M, 0.0f);
+            v->xL.assign ((std::size_t) p.B, 0.0f), v->xR.assign ((std::size_t) p.B, 0.0f);
+            v->fL.assign (2 * (std::size_t) p.B, 0.0f), v->fR.assign (2 * (std::size_t) p.B, 0.0f);
+            v->fst.assign ((std::size_t) std::max (0, p.forder), std::array<double, 8> {});
+            if (p.interp == 6)
+                v->sinc.assign (9, SincTables {});
+            pool.push_back (std::move (v));
+        }
+    }
+
+    Voice* freeVoice() noexcept
+    {
+        for (auto& v : pool)
+            if (! v->used)
+                return v.get();
+        if ((int) pool.size() < maxVoices)
+        {
+            grow (std::min (8, maxVoices - (int) pool.size())); // (allocates: only when the polyphony reaches a new high)
+            for (auto& v : pool)
+                if (! v->used)
+                    return v.get();
+        }
+        // pool full: the oldest voice is cut at once
+        if (order.empty())
+            return nullptr;
+        auto* v = order.front();
+        order.erase (order.begin());
+        if (hostKills)
+            --nlisted;
+        v->used = false;
+        return v;
+    }
+
+    // ---- articulators ----
+    double artStatic (int k, double key, double vel) const noexcept
+    {
+        const auto& a = pt->arts[(std::size_t) k];
+        const auto kv = a.key.valueAt (key * (1.0 / 120.0));
+        const auto vv = a.vel.valueAt (vel);
+        double s;
+        if (a.mode == 0)
+            s = kv * vv;
+        else if (a.mode == 1)
+            s = kv + vv;
+        else
+            s = kv * vv * 2.0;
+        return f32 (s);
+    }
+
+    double xyApply (int k, double v, int ix, int iy) const noexcept
+    {
+        const auto& a = pt->arts[(std::size_t) k];
+        for (int t = 0; t < 2; ++t)
+        {
+            const auto tv = (double) (t == 0 ? a.xtab : a.ytab)[(std::size_t) (t == 0 ? ix : iy)];
+            if (a.mode == 0)
+                v = v * tv;
+            else if (a.mode == 1)
+                v = v + tv;
+            else
+                v = v * tv * 2.0;
+        }
+        return v;
+    }
+
+    static int ixOf (double v, double h) noexcept { return (int) std::clamp (rnd (f32 (v + h * 256.0)), 0LL, 512LL); }
+
+    // ---- voice start (TriggerVoice; ogmodel.Voice.__init__) ----
+    void startVoice (Voice& v, int key, double vel, double fvol, double fpan, double pofs, double fcut, double fres, double relvel) noexcept
+    {
+        const auto& p = *pt;
+        const auto& P = p.P;
+        v.dead = false;
+        v.fvol = fvol, v.fpan = fpan, v.fcutH = fcut, v.fresH = fres;
+        v.FP = f32 (100.0 * key - 6000.0 + pofs);
+        v.relvel = relvel;
+        const auto note = std::max (f32 (v.FP * f32 (0.01) + 60.0), 0.0);
+        v.note = note;
+        v.keyi = (int) rnd (note);
+        v.vel = vel;
+        v.state = 1;
+        v.cnt = -p.B;
+        v.firstChunk = true;
+        v.xy[0] = (double) P[3], v.xy[1] = (double) P[4];
+        v.ixy[0] = ixOf (v.xy[0], fcut), v.ixy[1] = ixOf (v.xy[1], fres);
+        for (int k = 0; k < 13; ++k)
+            v.stat[k] = 0.0, v.out[k] = 0.0;
+        const bool porta = ((p.flag (0x210) != 0) != (hostEv2 == 14.0)) && hasLastPitch;
+        for (int k = 0; k < 13; ++k)
+        {
+            if (k == 8)
+                continue;
+            const auto& a = p.arts[(std::size_t) k];
+            auto s = artStatic (k, note, vel);
+            if (k < 5)
+            {
+                if (k == 3)
+                {
+                    s = s * 4.0;
+                    if (p.flag (0x20b) == 0)
+                        s = s - v.FP * (1.0 / 1200.0);
+                    v.cents0 = f32 ((v.FP + (double) p.masterCents) + s * 1200.0);
+                }
+                v.stat[k] = s;
+                auto& env = v.envs[k];
+                env.init (a.env, p.envRate, p.envRateTempo, a.adsr);
+                v.lfoOn[k] = a.lfo.enabled != 0;
+                if (v.lfoOn[k])
+                    v.lfos[k].initLfo (a.lfo, p.envRate, p.envRateTempo, a.lfoKnobs, a.lfoExtra);
+                v.en[k] = a.env.enabled != 0 || v.lfoOn[k];
+                auto val = a.base;
+                if (a.env.enabled && porta && k == 3)
+                {
+                    auto d = f32 (lastPitch - v.cents0);
+                    const int m12 = p.flag (0x212);
+                    if (m12)
+                    {
+                        if (m12 < 2)
+                        {
+                            const auto sg = (double) sgn (d);
+                            while (std::fabs (d) > 1250.0)
+                                d = f32 (d - sg * 1200.0);
+                        }
+                        else
+                        {
+                            const auto lim = (double) ((6 - m12) * 100);
+                            const auto sg = (double) sgn (d);
+                            d = f32 (sg * std::min (std::fabs (d), lim));
+                        }
+                    }
+                    if (d != 0.0)
+                    {
+                        env.setMod (f32 (d * (1.0 / 1200.0)));
+                        if (p.flag (0x211))
+                            env.kn[0] = f32 (env.kn[0] * (std::fabs (d) * (1.0 / 1200.0)));
+                        env.relv = env.c->sus >= 0 ? env.kn[2] : 0.0;
+                        env.setMod (env.mod);
+                    }
+                }
+                else if (a.env.enabled)
+                {
+                    const int vo = p.flag (0x20d);
+                    if (vo)
+                    {
+                        if (vo & 1)
+                        {
+                            env.kn[0] = f32 (env.kn[0] * f32 (2.0 - vel * 2.0));
+                            env.relv = env.c->sus >= 0 ? env.kn[2] : 0.0;
+                            env.setMod (env.mod);
+                        }
+                        if ((vo & 2) && env.c->decay >= 0)
+                        {
+                            double cum = 0.0;
+                            for (int i = 0; i <= env.c->decay; ++i)
+                                cum += env.c->dx[(std::size_t) i];
+                            env.step (cum * env.kn[0] * vel / env.rate0);
+                        }
+                    }
+                    val = val + env.out * a.envamt;
+                }
+                if (v.lfoOn[k])
+                {
+                    if (a.mode == 1)
+                        val = val + v.lfos[k].lout * a.lfoamt;
+                    else
+                        val = val * (v.lfos[k].lout * a.lfoamt * 2.0 + 1.0);
+                }
+                if (! v.en[k])
+                    v.out[k] = s;
+                else if (a.mode == 0)
+                    v.out[k] = val * s;
+                else if (a.mode == 1)
+                    v.out[k] = val + s;
+                else
+                    v.out[k] = val * s * 2.0;
+            }
+            else
+                v.stat[k] = xyApply (k, s, v.ixy[0], v.ixy[1]);
+        }
+        // timbre start parameters
+        const auto* st = v.stat;
+        double dec = -1.0;
+        if (p.dec >= 0.0)
+            dec = f32 (f32 (f32 (f32 (std::exp (p.dec * std::log (21.0)) - 1.0) * 997.5 * f32 (st[7])) + 50.0) * 0.001 * p.fs);
+        const auto full = std::min (std::max (f32 (p.full + st[9] * 2.0), -1.0), 1.0);
+        auto s1 = p.seed1;
+        if (p.flag (0x20c))
+            s1 = mix32 ((long long) P[10] + rnd (note) - 0x1f88, 0x1e42);
+        long long s2;
+        if (p.seed2 < 0)
+            s2 = mix32 ((long long) counter - 0x200e, 0x1dbc), ++counter;
+        else
+            s2 = p.seed2;
+        const auto morph = f32 (p.morph * st[10]);
+        const auto ratio = std::exp (v.cents0 * (1.0 / 1200.0) * LN2);
+        const auto eqs = std::min (std::max (f32 (st[12]), -0.5), 0.5);
+        const int n = std::clamp ((int) P[12], 1, 9);
+        // Timbre.__init__
+        v.tpre = p.pre * st[6];
+        v.decSamples = dec;
+        const auto mag = f32 ((std::exp (std::fabs (full) * std::log (10000001.0)) - 1.0) * 0.01);
+        v.p = f32 (mag * -(double) sgn (full));
+        v.seed1 = s1, v.seed2 = s2, v.tmorph = morph;
+        v.alt = p.alt;
+        v.shift = (int) rnd (eqs * p.M);
+        {
+            const auto r = rnd (f32 (st[11]) * p.M + (double) ((long long) p.M << 8));
+            v.rot = (int) (((r % p.M) + p.M) % p.M);
+        }
+        v.speed = p.speedK / p.fs * ratio;
+        v.nsub = n;
+        for (auto& sb : v.subs)
+            sb = Sub {};
+        v.started = false;
+        v.cntTotal = 0, v.frameEnd = p.hop, v.inFrame = 0;
+        v.silence = rnd (p.fs * 0.1);
+        v.thr = f32 (std::exp (std::log (10.0) / 20.0 * -80.0));
+        v.tstate = 0;
+        v.c = 1.0;
+        v.cents = v.cents0;
+        // unison
+        v.upitch = f32 (P[15] * v.out[4]);
+        const auto S = f32 (f32 (std::exp (f32 (v.upitch * 0.00390625) * std::log (11.0)) - 1.0) * 5.0);
+        const auto d23 = 1.0 - f32 (P[16] * 0.0078125) * st[5];
+        const auto sp = std::exp (f32 (d23) * std::log (101.0));
+        const auto base = (double) (1.0f - (float) ((float) (sp - 1.0) * 0.01f));
+        const auto spread = f32 (std::pow (base, (double) p.rich));
+        const auto vv = f32 (P[14] * 0.0078125);
+        const auto g3 = n < 3 ? 1.0 : f32 (1.0 / std::sqrt ((double) n));
+        for (int k = 0; k < n; ++k)
+        {
+            auto& sb = v.subs[(std::size_t) k];
+            double L, R, ph, fr;
+            if (n == 1)
+            {
+                sb.det = 0.0;
+                L = R = f32 (0.3);
+                ph = 0.0, fr = 1.0;
+            }
+            else
+            {
+                const float fk = (float) k, fn = (float) n;
+                ph = (double) (((fk / fn) - (((float) (n - 1) / fn) * 0.5f)) * (float) spread);
+                const auto u = f32 (f32 ((double) k / (n - 1)) * 2.0 - 1.0);
+                auto au = std::fabs (u);
+                const auto gain = n == 2 ? 0.3 : f32 (f32 (g3 * vv + g3 * 2.0 * (1.0 - au) * (1.0 - vv)) * 0.3);
+                const auto pan = f32 (u * 0.0078125 * P[13]);
+                const auto ang = (1.0 + pan) * 0.7853981633974483;
+                L = f32 (std::cos (ang) * gain);
+                R = f32 (std::sin (ang) * gain);
+                if (k & 1)
+                    au = -au;
+                if ((n & 1) && n < 2 * k)
+                    au = -au;
+                sb.det = f32 (au * uniD[k]);
+                fr = f32 (std::exp (f32 (sb.det * f32 (S * f32 (LN2 / 1200.0)))));
+            }
+            sb.ratio = fr, sb.pos = ph, sb.L = L, sb.R = R;
+        }
+        v.S = S;
+        for (int i = 0; i < 4; ++i)
+            v.gt[i] = v.gc[i] = v.gs[i] = v.gd[i] = 0.0f;
+        for (auto& f : v.fst)
+            f.fill (0.0);
+        v.declick = -1;
+        if (p.flag (0x20e))
+        {
+            v.declick = (int) rnd (p.declickLen);
+            v.dcG = 0.0f;
+            v.dcD = (float) (1.0 / std::max (1, v.declick));
+            v.dcL = v.dcR = 0.0f;
+        }
+        v.timRelOnEnv = false;
+        if (p.flag (0x20f))
+        {
+            const auto& e = p.arts[0].env;
+            v.timRelOnEnv = e.enabled && e.decay >= 0;
+        }
+        v.timReleased = false;
+        lastPitch = v.cents0;
+        hasLastPitch = true;
+        v.tNew = v.tA.data(), v.tOld = v.tB.data();
+    }
+
+    void kill (Voice& v) noexcept
+    {
+        if (v.state < 9)
+            v.state = 9;
+        for (int k = 0; k < 5; ++k)
+        {
+            v.envs[k].stage = 9, v.envs[k].sub = 9;
+            if (v.lfoOn[k])
+                v.lfos[k].stage = 9, v.lfos[k].sub = 9;
+        }
+    }
+
+    void voiceRelease (Voice& v) noexcept
+    {
+        if (v.state < 5)
+            v.state = 5;
+        if (! v.timRelOnEnv)
+            timRelease (v, v.relvel);
+        for (int k = 0; k < 5; ++k)
+        {
+            v.envs[k].release();
+            if (v.lfoOn[k])
+                v.lfos[k].release();
+        }
+    }
+
+    void timRelease (Voice& v, double rv) noexcept
+    {
+        if (v.timReleased)
+            return;
+        v.timReleased = true;
+        const auto& p = *pt;
+        rv = std::min (std::max (rv, 0.0), 1.0);
+        auto a8 = artStatic (8, v.note, rv);
+        a8 = xyApply (8, a8, v.ixy[0], v.ixy[1]);
+        const auto t = f32 (f32 (f32 (std::exp (p.rel * std::log (21.0)) - 1.0) * 997.5 * a8 + 50.0) * 0.001 * p.fs);
+        timbreRelease (v, t);
+    }
+
+    // ---- per control block (ogmodel.Voice.control) ----
+    static void volpan (double pan, double vol, float* g) noexcept
+    {
+        if (pan == 0.0)
+        {
+            g[0] = g[1] = (float) vol, g[2] = g[3] = 0.0f;
+            return;
+        }
+        if (vol == 0.0)
+        {
+            g[0] = g[1] = g[2] = g[3] = 0.0f;
+            return;
+        }
+        const auto ang = (1.0 + pan) * 0.7853981633974483;
+        const auto vs = f32 (vol * f32 (std::sqrt (2.0)));
+        const float L = (float) (std::cos (ang) * vs), R = (float) (std::sin (ang) * vs);
+        const float fv = (float) vol;
+        float f3, f2;
+        if (pan <= 0.0)
+            f3 = 1.0f - R / fv, f2 = 0.0f;
+        else
+            f3 = 0.0f, f2 = 1.0f - L / fv;
+        g[2] = L * f3 * 0.5f;
+        g[0] = L * (1.0f - f3 * 0.5f);
+        g[3] = R * f2 * 0.5f;
+        g[1] = R * (1.0f - f2 * 0.5f);
+    }
+
+    void ramp (float cur, float tgt, int n, float& start, float& d, float& newc) const noexcept
+    {
+        start = cur;
+        auto dd = tgt - start;
+        if (dd == 0.0f)
+        {
+            d = 0.0f, newc = cur;
+            return;
+        }
+        newc = tgt;
+        dd = dd / (float) n;
+        const auto lim = (float) pt->rateLimit;
+        if (std::fabs (dd) > lim)
+        {
+            dd = std::copysign (lim, dd);
+            newc = start + dd * (float) n;
+            if (std::fabs ((double) newc) < tiny24)
+            {
+                newc = 0.0f;
+                dd = -start / (float) n;
+            }
+        }
+        d = dd;
+    }
+
+    void control (Voice& v) noexcept
+    {
+        const auto& p = *pt;
+        double x;
+        if (v.cnt < 0)
+            v.cnt = -v.cnt, x = 0.0;
+        else
+            v.cnt = p.B, x = 1.0;
+        v.envmin = 9;
+        for (int i = 0; i < 2; ++i)
+        {
+            const auto Pv = (double) p.P[(std::size_t) (3 + i)];
+            if (p.flag (0x208) == 0)
+                v.xy[i] = Pv;
+            else
+                v.xy[i] = f32 (Pv + f32 (v.xy[i] - Pv) * p.xysmooth);
+        }
+        v.ixy[0] = ixOf (v.xy[0], v.fcutH), v.ixy[1] = ixOf (v.xy[1], v.fresH);
+        for (int k = 0; k < 5; ++k)
+        {
+            const auto& a = p.arts[(std::size_t) k];
+            auto val = xyApply (k, v.stat[k], v.ixy[0], v.ixy[1]);
+            if (v.en[k])
+            {
+                auto& env = v.envs[k];
+                if (a.env.enabled)
+                {
+                    const auto eo = env.step (x);
+                    if (a.mode == 1)
+                        val = val + eo * a.envamt;
+                    else
+                        val = val * eo * a.envamt;
+                }
+                int lst = 9;
+                if (v.lfoOn[k])
+                {
+                    const auto lo = v.lfos[k].lstep (x);
+                    if (a.mode == 1)
+                        val = val + lo * a.lfoamt;
+                    else
+                        val = val * (lo * a.lfoamt * 2.0 + 1.0);
+                    lst = v.lfos[k].stage;
+                }
+                v.envmin = std::min ({ v.envmin, env.stage, lst });
+            }
+            v.out[k] = val;
+        }
+        const auto vb = f32 (v.fvol * p.master);
+        const auto pan = std::min (std::max (v.fpan, -1.0), 1.0);
+        if (v.state < 9)
+            volpan (pan, f32 (vb * v.out[0]), v.gt);
+        else
+            v.gt[0] = v.gt[1] = v.gt[2] = v.gt[3] = 0.0f;
+        if (v.firstChunk)
+            for (int i = 0; i < 4; ++i)
+                v.gc[i] = v.gt[i];
+        for (int i = 0; i < 4; ++i)
+        {
+            float s, d, c;
+            ramp (v.gc[i], v.gt[i], v.cnt, s, d, c);
+            v.gs[i] = s, v.gd[i] = d, v.gc[i] = c;
+        }
+        if (v.timRelOnEnv && v.envs[0].stage > 2)
+            timRelease (v, 0.5);
+    }
+
+    // ---- filter (§1.10) ----
+    Coef filterCoeffs (const Voice& v) const noexcept
+    {
+        const auto& p = *pt;
+        const auto u = p.fcut + v.out[1];
+        auto r = p.fres + v.out[2];
+        if (p.fflat)
+            r = r * (u + 1.0) * 0.5;
+        const int typ = p.ftype, order = p.forder;
+        auto s = f32 (44100.0 / p.fs);
+        if (p.oversampleFilter)
+            s = f32 (s * 0.5);
+        const auto ws = s * (2.0 * kPi);
+        auto pw = [] (double base, double xx) { return f32 (std::exp (f32 (xx) * std::log (base))); };
+        double sn, cs, alpha;
+        if (typ == 0 || typ == 3)
+        {
+            double c = 0.0;
+            if (u > 0.0)
+            {
+                if (typ == 0)
+                    c = f32 (pw (1501.0, u) - 1.0) * 0.0006646666442975402;
+                else
+                    c = std::min (f32 (pw (1501.0, u) - 1.0) * 0.00039993334212340415, 0.6001);
+            }
+            double Q;
+            if (r <= 0.0)
+                Q = 0.1;
+            else if (r >= 1.0)
+                Q = 50.0;
+            else
+                Q = f32 (pw (2001.0, r) - 1.0) * 0.024950001388788223 + 0.1;
+            if (order > 1)
+                Q = f32 (std::exp (f32 (1.0 / order) * std::log (f32 (Q))));
+            const auto kq = 0.5 / Q;
+            auto w = (c + (typ == 0 ? 0.003 : 0.0001)) * ws;
+            w = std::min (std::max (w, 0.0), 2.849517146113191);
+            sn = std::sin (w), cs = std::cos (w);
+            alpha = sn * kq;
+        }
+        else
+        {
+            double c = 0.0;
+            if (u > 0.0)
+                c = std::min (f32 (pw (1501.0, u) - 1.0) * 0.00039993334212340415, 1.0001);
+            double bw;
+            if (r <= 0.0)
+                bw = 0.01;
+            else if (r >= 1.0)
+                bw = 12.0;
+            else
+                bw = f32 (pw (101.0, r) - 1.0) * 0.11989999562501907 + 0.01;
+            auto f38 = (double) order;
+            if (typ == 2)
+                f38 = f32 (1.0 / f38);
+            f38 = f32 (f38 * (LN2 / 2.0));
+            auto w = (c + 0.0001) * ws;
+            w = std::min (std::max (w, 0.0), 2.849517146113191);
+            sn = std::sin (w), cs = std::cos (w);
+            alpha = sn * std::sinh ((bw * f38 * w) / sn);
+        }
+        const auto n = 1.0 / (alpha + 1.0);
+        Coef k;
+        k.a1 = n * cs * -2.0;
+        k.a2 = n * (1.0 - alpha);
+        if (typ == 0)
+            k.b1 = n * (1.0 - cs), k.b0 = k.b1 * 0.5, k.b2 = k.b0;
+        else if (typ == 1)
+            k.b1 = 0.0, k.b0 = n * alpha, k.b2 = n * -alpha;
+        else if (typ == 2)
+            k.b1 = k.a1, k.b0 = n, k.b2 = n;
+        else
+            k.b1 = n * -(cs + 1.0), k.b0 = -k.b1 * 0.5, k.b2 = k.b0;
+        return k;
+    }
+
+    void filter (Voice& v, float* L, float* R, int m) noexcept
+    {
+        const auto& p = *pt;
+        const auto k = filterCoeffs (v);
+        float* xl = L;
+        float* xr = R;
+        int len = m;
+        if (p.oversampleFilter)
+        {
+            for (int i = 0; i < m; ++i)
+            {
+                v.fL[(std::size_t) (2 * i)] = v.fL[(std::size_t) (2 * i + 1)] = L[i];
+                v.fR[(std::size_t) (2 * i)] = v.fR[(std::size_t) (2 * i + 1)] = R[i];
+            }
+            xl = v.fL.data(), xr = v.fR.data(), len = 2 * m;
+        }
+        for (auto& st : v.fst)
+            biquadRun (k, st.data(), xl, xr, len);
+        if (p.oversampleFilter)
+            for (int i = 0; i < m; ++i)
+            {
+                L[i] = xl[2 * i] * 0.5f + xl[2 * i + 1] * 0.5f;
+                R[i] = xr[2 * i] * 0.5f + xr[2 * i + 1] * 0.5f;
+            }
+    }
+
+    // ---- voice render (ogmodel.Voice.render) ----
+    void renderVoice (Voice& v, float* bl, float* br, int n) noexcept
+    {
+        const auto& p = *pt;
+        int o = 0;
+        float* gsL[4] { rampBuf.data(), rampBuf.data() + p.B, rampBuf.data() + 2 * p.B, rampBuf.data() + 3 * p.B };
+        while (o < n)
+        {
+            if (v.cnt < 1)
+                control (v);
+            const auto c = f32 ((v.FP + (double) p.masterCents) + v.out[3] * 1200.0);
+            if (c != v.cents)
+            {
+                v.cents = c;
+                v.speed = p.speedK / p.fs * std::exp (c * (1.0 / 1200.0) * LN2);
+            }
+            const auto up = f32 (p.P[15] * v.out[4]);
+            if (up != v.upitch)
+            {
+                v.upitch = up;
+                const auto S = f32 (f32 (std::exp (f32 (up * 0.00390625) * std::log (11.0)) - 1.0) * 5.0);
+                for (int k = 0; k < v.nsub; ++k)
+                {
+                    auto& sb = v.subs[(std::size_t) k];
+                    sb.ratio = f32 (std::exp (f32 (sb.det * f32 (S * f32 (LN2 / 1200.0)))));
+                }
+            }
+            const int m = std::min (v.cnt, n - o);
+            float* xL = v.xL.data();
+            float* xR = v.xR.data();
+            timbreRender (v, xL, xR, m);
+            if (v.silence < 1 && v.state < 9)
+                v.state = 9;
+            if (v.declick > 0)
+            {
+                v.declick -= m;
+                const int k = v.declick >= 0 ? m : m + v.declick;
+                auto g = v.dcG, L = v.dcL, R = v.dcR;
+                for (int i = 0; i < k; ++i)
+                {
+                    L = L + g * (xL[i] - L);
+                    xL[i] = L;
+                    R = R + g * (xR[i] - R);
+                    xR[i] = R;
+                    g = g + v.dcD;
+                }
+                v.dcL = L, v.dcR = R;
+                v.dcG = v.dcG + v.dcD * (float) k;
+            }
+            if (p.forder > 0)
+                filter (v, xL, xR, m);
+            for (int i = 0; i < 4; ++i)
+            {
+                auto g = v.gs[i];
+                accRamp (g, v.gd[i], m, gsL[i]);
+            }
+            for (int i = 0; i < m; ++i)
+            {
+                const float Lv = xL[i] * gsL[0][i] + xR[i] * gsL[2][i];
+                const float Rv = xR[i] * gsL[1][i] + xL[i] * gsL[3][i];
+                bl[o + i] = bl[o + i] + Lv;
+                br[o + i] = br[o + i] + Rv;
+            }
+            for (int i = 0; i < 4; ++i)
+                v.gs[i] = v.gs[i] + v.gd[i] * (float) m;
+            v.firstChunk = false;
+            v.cnt -= m;
+            o += m;
+        }
+        if (v.state >= 9 || v.envmin >= 9)
+            if (v.state < 10 && v.gs[0] == 0.0f && v.gs[1] == 0.0f && v.gs[2] == 0.0f && v.gs[3] == 0.0f && v.gd[0] == 0.0f
+                && v.gd[1] == 0.0f && v.gd[2] == 0.0f && v.gd[3] == 0.0f)
+                v.state = 10;
+        if (v.state >= 10)
+            v.dead = true;
+    }
+
+    // ---- timbre (ogmodel.Timbre) ----
+    void shaped (const Voice& v, long long seed, float* out) noexcept
+    {
+        const auto& p = *pt;
+        const int M = p.M;
+        rand32f (sU.data(), M, 0.0f, 1.0f, (std::uint32_t) seed);
+        const float* u = sU.data();
+        if (v.rot > 0)
+        {
+            for (int i = 0; i < M; ++i)
+                sV[(std::size_t) i] = u[(i - v.rot + M) % M];
+            u = sV.data();
+        }
+        const auto pp = v.p;
+        if (pp == 0.0)
+        {
+            std::memmove (out, u, sizeof (float) * (std::size_t) M);
+            return;
+        }
+        if (pp <= 0.0)
+        {
+            const float q = (float) (1.0 - pp);
+            const float lq = (float) std::log ((double) q);
+            for (int i = 0; i < M; ++i)
+            {
+                const float w = (1.0f - u[i]) * lq;
+                out[i] = q - (float) std::exp ((double) w);
+            }
+            return;
+        }
+        const float lp = (float) std::log ((double) (float) (pp + 1.0));
+        for (int i = 0; i < M; ++i)
+        {
+            const float w = u[i] * lp;
+            out[i] = (float) std::exp ((double) w) + -1.0f;
+        }
+    }
+
+    void setup (Voice& v, int mode, double argPre, double argTime) noexcept
+    {
+        const auto& p = *pt;
+        const int M = p.M, hop = p.hop;
+        const auto T0 = (p.fs * 0.025) / hop;
+        const auto Tm = argTime / hop - T0;
+        const auto T = Tm > 0.0 ? Tm : 0.0;
+        v.tstate = argTime < 0.0 ? 1 : 0;
+        if (v.alt && v.tstate == 0)
+            v.c = T > 0.0 ? 1.0 - std::exp (std::log (0.01) / T) : 1.0;
+        const float ln001 = (float) std::log (0.01);
+        if (mode == 0)
+        {
+            const auto Pp = std::max (argPre, 0.001);
+            const auto invP = 1.0 / Pp;
+            const auto lp = v.p == 0.0 ? 1.0 : f32 (1.0 / std::fabs (v.p));
+            const auto m = v.tmorph;
+            float* B = v.Bw.data();
+            bool haveB = false;
+            if (m != 0.0)
+            {
+                shaped (v, v.seed2, B);
+                const float sc = (float) (m * lp);
+                for (int i = 0; i < M; ++i)
+                    B[i] = B[i] * sc;
+                haveB = true;
+            }
+            if (m < 1.0)
+            {
+                if (v.seed1 < 0)
+                {
+                    const float a = (float) (1.0 - m);
+                    if (! haveB)
+                        std::fill (B, B + M, a);
+                    else
+                        for (int i = 0; i < M; ++i)
+                            B[i] = B[i] + a;
+                }
+                else
+                {
+                    shaped (v, v.seed1, sD.data());
+                    const float sc = (float) ((1.0 - m) * lp);
+                    for (int i = 0; i < M; ++i)
+                    {
+                        const float t = sD[(std::size_t) i] * sc;
+                        B[i] = haveB ? B[i] + t : t;
+                    }
+                }
+                haveB = true;
+            }
+            if (! (v.tmorph == 0.0 && v.seed1 < 0))
+                for (int i = 0; i < M; ++i)
+                    B[i] = std::max (B[i], 0.0f);
+            if (p.hasForced)
+                for (int i = 0; i < M; ++i)
+                {
+                    const auto Fm = p.mForced[(std::size_t) i];
+                    B[i] = (B[i] * Fm + 1.0f) - Fm;
+                }
+            // D (in sD), hold factors
+            const float fInvP = (float) invP;
+            float* D = sD.data();
+            for (int i = 0; i < M; ++i)
+            {
+                const float x4 = B[i] * fInvP + 0.001f;
+                D[i] = (float) std::exp ((double) (ln001 / x4));
+            }
+            if (! v.alt && v.tstate == 0)
+            {
+                const float fT = (float) T, fT0 = (float) T0;
+                const int L = (int) p.mDec.size();
+                for (int i = 0; i < M; ++i)
+                {
+                    const float Ed = p.mDec[(std::size_t) std::clamp (i - v.shift, 0, L - 1)];
+                    const float xx = (B[i] * Ed) * fT + fT0;
+                    v.fac[(std::size_t) i] = (float) std::exp ((double) (ln001 / xx));
+                }
+            }
+            else
+                std::fill (v.fac.begin(), v.fac.end(), 1.0f);
+            {
+                // rms over M in double (np.sum of float32 squares with a float64 accumulator)
+                for (int i = 0; i < M; ++i)
+                    sU[(std::size_t) i] = D[i] * D[i];
+                const auto sum = sU.empty() ? 0.0 : (double) sU[0] + pairwiseSum<double> (sU.data() + 1, (std::size_t) M - 1);
+                const auto rms = f32 (std::sqrt (sum / M));
+                if (rms > 0.0)
+                {
+                    const float g = (float) (p.gnorm / rms);
+                    for (int i = 0; i < M; ++i)
+                        D[i] = D[i] * g;
+                }
+            }
+            auto band = (long long) ((M * (double) (1 << p.qt) * 0.907029478) / v.speed);
+            band = std::min (std::max (band, 0LL), (long long) M);
+            v.band = (int) band;
+            int first, last;
+            if (v.shift == 0)
+                first = std::clamp (p.first, 0, M), last = std::min (v.band, p.last);
+            else
+                first = 0, last = v.band;
+            v.tfirst = first, v.tlast = last;
+            const int f0 = v.alt ? 0 : first, ec = v.alt ? v.band : last;
+            std::fill (v.eRe.begin(), v.eRe.end(), 0.0f);
+            std::fill (v.eIm.begin(), v.eIm.end(), 0.0f);
+            const int Li = (int) p.mImp.size();
+            for (int i = f0; i < std::max (f0, ec); ++i)
+            {
+                const float amp = D[i] * p.mImp[(std::size_t) std::clamp (i - v.shift, 0, Li - 1)];
+                v.eRe[(std::size_t) i] = p.phRe[(std::size_t) i] * amp;
+                v.eIm[(std::size_t) i] = p.phIm[(std::size_t) i] * amp;
+            }
+            if (v.alt)
+            {
+                std::fill (v.tgRe.begin(), v.tgRe.end(), 0.0f);
+                std::fill (v.tgIm.begin(), v.tgIm.end(), 0.0f);
+                const int Ld = (int) p.mDec.size();
+                for (int i = first; i < std::max (first, last); ++i)
+                {
+                    const float yv = D[i] * p.mDec[(std::size_t) std::clamp (i - v.shift, 0, Ld - 1)];
+                    v.tgRe[(std::size_t) i] = p.phRe[(std::size_t) i] * yv;
+                    v.tgIm[(std::size_t) i] = p.phIm[(std::size_t) i] * yv;
+                }
+            }
+            for (int i = first; i < last; ++i)
+            {
+                if (std::fabs (v.eRe[(std::size_t) i]) < (float) tiny24)
+                    v.eRe[(std::size_t) i] = 0.0f;
+                if (std::fabs (v.eIm[(std::size_t) i]) < (float) tiny24)
+                    v.eIm[(std::size_t) i] = 0.0f;
+            }
+            for (auto& f : v.fac)
+                if (std::fabs (f) < (float) tiny24)
+                    f = 0.0f;
+        }
+        else
+        {
+            const float fT = (float) T, fT0 = (float) T0;
+            const int L = (int) p.mRel.size();
+            for (int i = 0; i < M; ++i)
+            {
+                const float Er = p.mRel[(std::size_t) std::clamp (i - v.shift, 0, L - 1)];
+                const float xx = (v.Bw[(std::size_t) i] * Er) * fT + fT0;
+                auto f = (float) std::exp ((double) (ln001 / xx));
+                v.fac[(std::size_t) i] = std::fabs (f) < (float) tiny24 ? 0.0f : f;
+            }
+            if (v.alt)
+            {
+                v.alt = false;
+                v.tfirst = 0, v.tlast = v.band;
+            }
+        }
+    }
+
+    void advance (Voice& v) noexcept
+    {
+        if (v.tstate != 0)
+            return;
+        const int a = v.tfirst, b = v.tlast;
+        if (b <= a)
+            return;
+        if (! v.alt)
+            for (int i = a; i < b; ++i)
+            {
+                v.eRe[(std::size_t) i] = v.eRe[(std::size_t) i] * v.fac[(std::size_t) i];
+                v.eIm[(std::size_t) i] = v.eIm[(std::size_t) i] * v.fac[(std::size_t) i];
+            }
+        else
+        {
+            const float c = (float) v.c;
+            for (int i = a; i < b; ++i)
+            {
+                const float dr = (v.tgRe[(std::size_t) i] - v.eRe[(std::size_t) i]) * c;
+                const float di = (v.tgIm[(std::size_t) i] - v.eIm[(std::size_t) i]) * c;
+                v.eRe[(std::size_t) i] = v.eRe[(std::size_t) i] + dr;
+                v.eIm[(std::size_t) i] = v.eIm[(std::size_t) i] + di;
+            }
+        }
+    }
+
+    void ifftInto (Voice& v, float* dst) noexcept
+    {
+        const auto& p = *pt;
+        p.fft.inverse (v.eRe.data(), v.eIm.data(), p.M, dst, zr.data());
+        std::memcpy (dst + p.N, dst, 64 * sizeof (float));
+    }
+
+    // FUN_00843300: new table from the current spectrum, then advance the spectrum
+    void frame (Voice& v) noexcept
+    {
+        if (v.tstate < 0)
+            return;
+        std::swap (v.tNew, v.tOld);
+        ifftInto (v, v.tNew);
+        advance (v);
+    }
+
+    void timbreStart (Voice& v) noexcept
+    {
+        const auto& p = *pt;
+        v.started = true;
+        setup (v, 0, v.tpre, v.decSamples);
+        frame (v);
+        frame (v);
+        // j0 = first index of the smallest squared sample (float32)
+        int j0 = 0;
+        float best = v.tNew[0] * v.tNew[0];
+        for (int i = 1; i < p.N; ++i)
+        {
+            const float sq = v.tNew[i] * v.tNew[i];
+            if (sq < best)
+                best = sq, j0 = i;
+        }
+        for (auto& j : j0Map)
+            if (j.first == &v)
+            {
+                j0 = (int) (((long long) j0 + j.second) % p.N + p.N) % p.N;
+                j.first = nullptr;
+            }
+        for (int k = 0; k < v.nsub; ++k)
+            v.subs[(std::size_t) k].pos = v.subs[(std::size_t) k].pos * p.N + (double) (j0 + (2 * p.N - 32));
+        resetGains (v);
+        if (v.tstate > 0)
+            v.tstate = -1;
+    }
+
+    void resetGains (Voice& v) const noexcept
+    {
+        const auto h = (float) (1.0 / pt->hop);
+        for (int k = 0; k < v.nsub; ++k)
+        {
+            auto& s = v.subs[(std::size_t) k];
+            s.g[0] = 0.0f, s.g[1] = 0.0f, s.g[2] = (float) s.L, s.g[3] = (float) s.R;
+            s.d[0] = (float) s.L * h, s.d[1] = (float) s.R * h;
+            s.d[2] = -s.d[0], s.d[3] = -s.d[1];
+        }
+    }
+
+    void timbreRelease (Voice& v, double relSamples) noexcept
+    {
+        const auto& p = *pt;
+        if (! v.started)
+            timbreStart (v);
+        setup (v, 1, 0.0, relSamples);
+        v.tstate = 0;
+        if (v.cntTotal != 0)
+        {
+            const float fr = (float) v.inFrame / (float) p.hop;
+            const float fo = 1.0f - fr;
+            for (int i = 0; i < p.N; ++i)
+                v.tNew[i] = v.tNew[i] * fr + v.tOld[i] * fo;
+            std::memcpy (v.tNew + p.N, v.tNew, 64 * sizeof (float));
+            frame (v);
+            v.frameEnd = v.cntTotal + p.hop;
+            v.inFrame = 0;
+            resetGains (v);
+        }
+    }
+
+    void timbreRender (Voice& v, float* outL, float* outR, int n) noexcept
+    {
+        const auto& p = *pt;
+        const int N = p.N;
+        int o = 0;
+        float* gv[4] { rampBuf.data() + 4 * p.B, rampBuf.data() + 5 * p.B, rampBuf.data() + 6 * p.B, rampBuf.data() + 7 * p.B };
+        while (o < n)
+        {
+            const int m = (int) std::min ((long long) (n - o), v.frameEnd - v.cntTotal);
+            v.inFrame += m;
+            if (! v.started)
+                timbreStart (v);
+            const float* tn = v.tNew;
+            const float* to = v.tOld;
+            for (int j = 0; j < v.nsub; ++j)
+            {
+                auto& s = v.subs[(std::size_t) j];
+                const auto step = v.speed * s.ratio;
+                const auto pos0 = s.pos;
+                s.pos = s.pos + step * m;
+                for (int i = 0; i < 4; ++i)
+                    accRamp (s.g[i], s.d[i], m, gv[i]);
+                float* dL = outL + o;
+                float* dR = outR + o;
+                if (p.interp == 1)
+                {
+                    for (int i = 0; i < m; ++i)
+                    {
+                        const auto pos = pos0 + step * i;
+                        const auto ip = (long long) pos;
+                        const float fr = (float) (pos - (double) ip);
+                        const auto ix = (std::size_t) ((ip & (N - 1)) + 32);
+                        const float a0 = tn[ix], a1 = tn[ix + 1], b0 = to[ix], b1 = to[ix + 1];
+                        const float vn = (a1 - a0) * fr + a0, vo = (b1 - b0) * fr + b0;
+                        const float L = vn * gv[0][i] + vo * gv[2][i];
+                        const float R = vn * gv[1][i] + vo * gv[3][i];
+                        if (j == 0)
+                            dL[i] = L, dR[i] = R;
+                        else
+                            dL[i] = dL[i] + L, dR[i] = dR[i] + R;
+                    }
+                }
+                else if (p.interp == 6)
+                {
+                    sincRead (v.sinc[(std::size_t) j], tn, to, pos0, step, m, N, gv, dL, dR, j == 0);
+                }
+                else
+                {
+                    for (int i = 0; i < m; ++i)
+                    {
+                        const auto pos = pos0 + step * i;
+                        const auto ip = (long long) pos;
+                        const auto xf = (double) (float) (pos - (double) ip);
+                        const auto ix = (std::size_t) ((ip & (N - 1)) + 32);
+                        const float vn = (float) hermite6 (tn[ix - 2], tn[ix - 1], tn[ix], tn[ix + 1], tn[ix + 2], tn[ix + 3], xf);
+                        const float vo = (float) hermite6 (to[ix - 2], to[ix - 1], to[ix], to[ix + 1], to[ix + 2], to[ix + 3], xf);
+                        const float L = vn * gv[0][i] + vo * gv[2][i];
+                        const float R = vn * gv[1][i] + vo * gv[3][i];
+                        if (j == 0)
+                            dL[i] = L, dR[i] = R;
+                        else
+                            dL[i] = dL[i] + L, dR[i] = dR[i] + R;
+                    }
+                }
+            }
+            o += m;
+            v.cntTotal += m;
+            if (v.cntTotal >= v.frameEnd)
+            {
+                frame (v);
+                v.frameEnd += p.hop;
+                v.inFrame = 0;
+                resetGains (v);
+            }
+        }
+        bool silent = true;
+        for (int i = 0; i < n && silent; ++i)
+            silent = std::fabs ((double) outL[i]) <= v.thr && std::fabs ((double) outR[i]) <= v.thr;
+        if (silent)
+            v.silence -= n;
+        else
+            v.silence = rnd (p.fs * 0.1);
+    }
+
+    std::vector<float> sincN, sincO;
+
+    void sincRead (SincTables& sk, const float* tn, const float* to, double pos0, double step, int m, int N, float* const* gv,
+                   float* dL, float* dR, bool firstSub) noexcept
+    {
+        constexpr int points = 32;
+        const auto s = std::fabs (step);
+        const auto b = kPi * (s > 1.0 ? 1.0 / s : 1.0);
+        if (b != sk.b)
+        {
+            // cos/sin(b·k) by rotation from k = 0 (error ≲ 10⁻¹⁵, far below the float output)
+            double c1 = 1.0, s1 = 0.0;
+            if (b != kPi)
+                sinCos (b, s1, c1);
+            double cp = 1.0, sp = 0.0, cm = 1.0, sm = 0.0;
+            sk.cb[31] = 1.0, sk.sb[31] = 0.0;
+            for (int k = 1; k <= points; ++k)
+            {
+                const auto ncp = cp * c1 - sp * s1, nsp = sp * c1 + cp * s1;
+                cp = ncp, sp = nsp;
+                sk.cb[31 + k] = cp, sk.sb[31 + k] = sp;
+                if (k < points)
+                {
+                    const auto ncm = cm * c1 + sm * s1, nsm = sm * c1 - cm * s1;
+                    cm = ncm, sm = nsm;
+                    sk.cb[31 - k] = cm, sk.sb[31 - k] = sm;
+                }
+            }
+            for (int k = -points + 1; k <= points; ++k)
+            {
+                const int t = k + points - 1;
+                if (sk.b < 0.0)
+                {
+                    sk.kk[t] = (double) k;
+                    sk.cA[t] = std::cos (kPi / points * k), sk.sA[t] = std::sin (kPi / points * k);
+                }
+                if (b == kPi)
+                    sk.cb[t] = (k & 1) ? -1.0 : 1.0, sk.sb[t] = 0.0;
+            }
+            sk.b = b;
+        }
+        float* vn = sincN.data();
+        float* vo = sincO.data();
+        sincChunk (sk, tn, to, pos0, step, m, N, vn, vo);
+        for (int i = 0; i < m; ++i)
+        {
+            const float L = vn[i] * gv[0][i] + vo[i] * gv[2][i];
+            const float R = vn[i] * gv[1][i] + vo[i] * gv[3][i];
+            if (firstSub)
+                dL[i] = L, dR[i] = R;
+            else
+                dL[i] = dL[i] + L, dR[i] = dR[i] + R;
+        }
+    }
+
+    // ---- chorus (§1.16; our ogfx_chorus.py) ----
+    static float trunc32 (double x) noexcept
+    {
+        auto f = (float) x;
+        if (std::fabs ((double) f) > std::fabs (x))
+            f = std::nextafter (f, 0.0f);
+        return f;
+    }
+
+    void chorus (int n, bool active) noexcept
+    {
+        const auto& p = *pt;
+        if (! active)
+        {
+            for (std::size_t i = 0; i < chorusPh.size(); ++i)
+                chorusPh[i] = chorusPh[i] + p.taps[i].inc * (std::uint32_t) n;
+            return;
+        }
+        const int base = ringPos;
+        for (int i = 0; i < n; ++i)
+        {
+            ringL[(std::size_t) ((base + i) & ringMask)] = bufL[(std::size_t) i];
+            ringR[(std::size_t) ((base + i) & ringMask)] = bufR[(std::size_t) i];
+        }
+        ringPos = (ringPos + n) & ringMask;
+        for (int i = 0; i < n; ++i)
+        {
+            float aL = 0.0f, aR = 0.0f;
+            for (std::size_t t = 0; t < p.taps.size(); ++t)
+            {
+                const auto& tp = p.taps[t];
+                const auto ph = (std::uint32_t) (chorusPh[t] + tp.inc * (std::uint32_t) i);
+                const auto phs = (double) (std::int32_t) ph;
+                const auto x = std::fabs (phs * tp.s8) - tp.s10;
+                const auto d = (tp.s9 - std::fabs (x)) * x + tp.centre;
+                const auto k = (long long) d;
+                const auto fr = d - (double) k;
+                const auto& src = tp.ch == 0 ? ringL : ringR;
+                const auto x0 = (double) src[(std::size_t) ((base + i - k) & ringMask)];
+                const auto x1 = (double) src[(std::size_t) ((base + i - k - 1) & ringMask)];
+                const auto val = x0 + (x1 - x0) * fr;
+                if (t == 0)
+                    aL = trunc32 (val * (double) tp.gL), aR = trunc32 (val * (double) tp.gR);
+                else
+                    aL = trunc32 (val * (double) tp.gL + (double) aL), aR = trunc32 (val * (double) tp.gR + (double) aR);
+            }
+            tmpL[(std::size_t) i] = aL, tmpR[(std::size_t) i] = aR;
+        }
+        for (std::size_t t = 0; t < chorusPh.size(); ++t)
+            chorusPh[t] = chorusPh[t] + p.taps[t].inc * (std::uint32_t) n;
+        for (int i = 0; i < n; ++i)
+        {
+            auto l = bufL[(std::size_t) i], r = bufR[(std::size_t) i];
+            if (p.chorusDry != 1.0f)
+                l = l * p.chorusDry, r = r * p.chorusDry;
+            bufL[(std::size_t) i] = l + tmpL[(std::size_t) i];
+            bufR[(std::size_t) i] = r + tmpR[(std::size_t) i];
+        }
+    }
+
+    // ---- delay (§1.17; our ogfx_delay.py) ----
+    void delay (int n, bool active) noexcept
+    {
+        const auto& p = *pt;
+        const int S = p.delaySize;
+        auto line = [&] (int i, int ch) -> float& { return dline[2 * (std::size_t) i + (std::size_t) ch]; };
+        if (active)
+            for (int i = 0; i < n; ++i)
+            {
+                auto& a = line ((dw + p.delayOffL + i) % S, 0);
+                a = a + bufL[(std::size_t) i];
+                auto& b = line ((dw + p.delayOffR + i) % S, 1);
+                b = b + bufR[(std::size_t) i];
+            }
+        // feedback ramp (FUN_0062b400)
+        const auto g0 = fbCur;
+        double inc = 0.0;
+        {
+            const auto d = f32 (p.delayFb - g0);
+            if (d != 0.0)
+            {
+                fbCur = p.delayFb;
+                inc = f32 (d / (double) (float) n);
+                const auto lim = p.rateLimit;
+                if (std::fabs (inc) > lim)
+                {
+                    inc = std::copysign (lim, inc);
+                    const auto cur = f32 (g0 + f32 (inc * (double) (float) n));
+                    fbCur = cur;
+                    if (std::fabs (cur) < tiny24)
+                    {
+                        fbCur = 0.0;
+                        inc = f32 (-g0 / (double) (float) n);
+                    }
+                }
+            }
+        }
+        for (int i = 0; i < n; ++i)
+        {
+            const auto g = g0 + inc * i;
+            auto& rl = line (dr, 0);
+            auto& rr = line (dr, 1);
+            const auto L = (double) rl, R = (double) rr;
+            rl = 0.0f, rr = 0.0f;
+            double oL, oR, fLv, fRv;
+            if (p.delayMode == 0)
+                oL = L, oR = R, fLv = L, fRv = R;
+            else if (p.delayMode == 1)
+                oL = R, oR = L, fLv = L, fRv = R;
+            else
+                oL = R, oR = L, fLv = R, fRv = L;
+            tmpL[(std::size_t) i] = (float) oL, tmpR[(std::size_t) i] = (float) oR;
+            auto& wl = line (dw, 0);
+            auto& wr = line (dw, 1);
+            auto vl = (float) (fLv * g + (double) wl);
+            auto vr = (float) (fRv * g + (double) wr);
+            wl = std::fabs ((double) vl) < tiny24 ? 0.0f : vl;
+            wr = std::fabs ((double) vr) < tiny24 ? 0.0f : vr;
+            dr = dr + 1 == S ? 0 : dr + 1;
+            dw = dw + 1 == S ? 0 : dw + 1;
+        }
+        const auto wet = (float) p.delayWet;
+        for (int i = 0; i < n; ++i)
+        {
+            if (wet == 1.0f)
+                bufL[(std::size_t) i] = bufL[(std::size_t) i] + tmpL[(std::size_t) i], bufR[(std::size_t) i] = bufR[(std::size_t) i] + tmpR[(std::size_t) i];
+            else
+                bufL[(std::size_t) i] = bufL[(std::size_t) i] + tmpL[(std::size_t) i] * wet,
+                bufR[(std::size_t) i] = bufR[(std::size_t) i] + tmpR[(std::size_t) i] * wet;
+        }
+    }
+
+    // ---- 2:1 decimator of qualities 2–4 (§1.19; our ogos.Decimator, order 1) ----
+    static bool quietWord (std::uint32_t w) noexcept { return (std::uint32_t) (w << 1) <= (std::uint32_t) (0x358637bdu * 2u); }
+
+    void decimate (int m) noexcept
+    {
+        bool quiet = true;
+        for (int i = 0; i < m && quiet; ++i)
+        {
+            std::uint32_t a, b;
+            std::memcpy (&a, &bufL[(std::size_t) i], 4);
+            std::memcpy (&b, &bufR[(std::size_t) i], 4);
+            quiet = quietWord (a) && quietWord (b);
+        }
+        // state slots 0…5 (allpass outputs) of both channels, tested as 32-bit words
+        for (int s = 0; s < 6 && quiet; ++s)
+            for (int ch = 0; ch < 2 && quiet; ++ch)
+            {
+                std::uint32_t w[2];
+                std::memcpy (w, &decSt[(std::size_t) (s * 2 + ch)], 8);
+                quiet = quietWord (w[0]) && quietWord (w[1]);
+            }
+        const int h = m / 2;
+        if (quiet)
+            return; // the first half of the block is passed on as it is
+        static constexpr double A0 = 0.1473771136010466, A1 = 0.48246854276970014, A2 = 0.8830050257693731;
+        static constexpr double B0 = 0.039151597734460045, B1 = 0.3026468483284934, B2 = 0.6746159185469639;
+        for (int ch = 0; ch < 2; ++ch)
+        {
+            float* x = ch == 0 ? bufL.data() : bufR.data();
+            double S[12];
+            for (int k = 0; k < 12; ++k)
+                S[k] = decSt[(std::size_t) (k * 2 + ch)];
+            for (int i = 0; i < h; ++i)
+            {
+                const auto e = (double) x[2 * i], od = (double) x[2 * i + 1];
+                auto t = S[6] + (e - S[0]) * A0;
+                S[6] = e, S[0] = t;
+                t = S[9] + (od - S[3]) * B0;
+                S[9] = od, S[3] = t;
+                t = S[7] + (S[0] - S[1]) * A1;
+                S[7] = S[0], S[1] = t;
+                t = S[10] + (S[3] - S[4]) * B1;
+                S[10] = S[3], S[4] = t;
+                t = S[8] + (S[1] - S[2]) * A2;
+                S[8] = S[1], S[2] = t;
+                t = S[11] + (S[4] - S[5]) * B2;
+                S[11] = S[4], S[5] = t;
+                x[i] = (float) ((S[5] + S[2]) * 0.5);
+            }
+            for (int k = 0; k < 6; ++k)
+                if (std::fabs (S[k]) < tiny24)
+                    S[k] = 0.0;
+            for (int k = 0; k < 12; ++k)
+                decSt[(std::size_t) (k * 2 + ch)] = S[k];
+        }
+    }
+
+    double lastPitch = 0.0;
+    bool hasLastPitch = false;
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// LYNX front-end
+//
+// Levels (§1.12/§1.13, REA_rodada28 §4.1): FL hands Ogun Final.Vol = the channel volume and Final.Pan = note pan +
+// channel pan, and Ogun applies Final.Vol × master × volume articulator through its own pan matrix (no host
+// ComputeLRVol). LYNX's channel gains are gl = √2·V·cos((1 + p)π/4), gr = √2·V·sin(…), so V = √((gl² + gr²)/2) and p
+// are recovered exactly and Ogun's law is applied once. Final.Pitch = 100·(key − 60) + channel pitch + note cents;
+// velocity = LYNX velocity (FL velocity / 128); release velocity 0.5; Mod X/Y (Final.FCut/FRes) 0.
+// Seed 2 "Random": the per-note counter starts at 0 for every instance (FL: from the RTL random seed).
+
+class OgunInstrument final : public Instrument
+{
+public:
+    ~OgunInstrument() override
+    {
+        delete incoming.exchange (nullptr);
+        delete retired.exchange (nullptr);
+    }
+
+    void prepare (double sr) noexcept override
+    {
+        take();
+        rate.store (sr);
+        const bool render = offlineRendering();
+        {
+            const std::lock_guard<std::mutex> lock (buildMutex);
+            if (! loadedState.empty() && (sr != loadedRate || render != loadedMode))
+                rebuild (sr, render);
+        }
+        take();
+    }
+
+    void configure (const ChannelDef& channel, double bpm) noexcept override
+    {
+        delete retired.exchange (nullptr);
+        const auto b = bpm > 0.0 ? bpm : 120.0;
+        channelCents.store (channel.sampler.pitch * 100.0f);
+        mono.store (channel.synth.mono);
+        const bool render = offlineRendering();
+        const std::lock_guard<std::mutex> lock (buildMutex);
+        if (channel.pluginState == loadedState && loadedRate == rate.load() && loadedMode == render && b == loadedBpm)
+            return;
+        if (channel.pluginState != loadedState)
+        {
+            loadedState = channel.pluginState;
+            try
+            {
+                parsed = parseState (loadedState);
+            }
+            catch (...)
+            {
+                parsed.reset();
+            }
+        }
+        loadedBpm = b;
+        rebuild (rate.load(), render);
+    }
+
+    void setNextNoteExpression (float pan, float cents, bool) noexcept override
+    {
+        nextPan = pan;
+        nextCents = cents;
+    }
+
+    void noteOn (int key, float velocity) noexcept override
+    {
+        take();
+        if (engine == nullptr)
+            return;
+        engine->maxpoly = mono.load() ? 1 : 0;
+        const auto pofs = (double) channelCents.load() + (double) nextCents;
+        engine->noteOn (key, std::clamp ((double) velocity, 0.0, 1.0), channelVol, (double) nextPan + channelPan, pofs, 0.0, 0.0,
+                        0.5, 0, key, (double) nextPan);
+        nextPan = 0.0f, nextCents = 0.0f;
+    }
+
+    void noteOff (int key) noexcept override
+    {
+        take();
+        if (engine != nullptr)
+            engine->releaseKey (key);
+    }
+
+    void allNotesOff() noexcept override
+    {
+        take();
+        if (engine != nullptr)
+            engine->killAll();
+    }
+
+    bool idle() const noexcept override { return engine == nullptr || engine->quiet(); }
+
+    void render (float* left, float* right, int n, float gl, float gr) noexcept override
+    {
+        take();
+        if (engine == nullptr)
+            return;
+        const auto vol = std::sqrt (((double) gl * gl + (double) gr * gr) * 0.5);
+        auto pan = vol > 0.0 ? std::atan2 ((double) gr, (double) gl) * (4.0 / kPi) - 1.0 : 0.0;
+        if (std::fabs (pan) < 1e-9)
+            pan = 0.0; // (equal gains: exactly centre, as FL's Final.Pan)
+        if (vol != channelVol || pan != channelPan)
+        {
+            channelVol = vol, channelPan = pan;
+            engine->setLevels (vol, pan);
+        }
+        for (int done = 0; done < n; done += Engine::maxHostBlock)
+        {
+            const auto m = std::min (Engine::maxHostBlock, n - done);
+            if (engine->quiet())
+                engine->skip (m); // nothing sounds: only the plugin-wide phases run
+            else
+                engine->render (left + done, right + done, m);
+        }
+    }
+
+private:
+    void rebuild (double sr, bool render) noexcept
+    {
+        loadedRate = sr;
+        loadedMode = render;
+        if (! parsed)
+        {
+            delete incoming.exchange (nullptr);
+            clearEngine.store (true);
+            return;
+        }
+        try
+        {
+            auto patch = buildPatch (*parsed, sr, render ? 4 : -1, loadedBpm, Engine::maxHostBlock);
+            auto e = std::make_unique<Engine> (std::move (patch));
+            delete incoming.exchange (e.release());
+        }
+        catch (...)
+        {
+        }
+    }
+
+    void take() noexcept
+    {
+        if (clearEngine.exchange (false))
+        {
+            delete retired.exchange (engine.release());
+        }
+        if (auto* e = incoming.exchange (nullptr))
+        {
+            delete retired.exchange (engine.release());
+            engine.reset (e);
+            engine->setLevels (channelVol, channelPan);
+        }
+    }
+
+    std::unique_ptr<Engine> engine;
+    std::atomic<Engine*> incoming { nullptr }, retired { nullptr };
+    std::atomic<bool> clearEngine { false };
+    std::mutex buildMutex; // configure (UI thread) and prepare build engines; the audio thread only takes them
+    std::atomic<double> rate { 44100.0 };
+    std::atomic<float> channelCents { 0.0f };
+    std::atomic<bool> mono { false };
+    std::vector<std::uint8_t> loadedState;
+    std::optional<StateData> parsed;
+    double loadedRate = 0.0, loadedBpm = 120.0;
+    bool loadedMode = false;
+    double channelVol = 1.0, channelPan = 0.0;
+    float nextPan = 0.0f, nextCents = 0.0f;
+};
+
+// zlib stream with stored (uncompressed) blocks
+std::vector<std::uint8_t> zlibStored (const std::vector<std::uint8_t>& data)
+{
+    std::vector<std::uint8_t> out { 0x78, 0x01 };
+    std::size_t i = 0;
+    do
+    {
+        const auto len = std::min<std::size_t> (65535, data.size() - i);
+        const bool last = i + len >= data.size();
+        out.push_back (last ? 1 : 0);
+        out.push_back ((std::uint8_t) (len & 0xff));
+        out.push_back ((std::uint8_t) (len >> 8));
+        out.push_back ((std::uint8_t) (~len & 0xff));
+        out.push_back ((std::uint8_t) ((~len >> 8) & 0xff));
+        out.insert (out.end(), data.begin() + (std::ptrdiff_t) i, data.begin() + (std::ptrdiff_t) (i + len));
+        i += len;
+    } while (i < data.size());
+    std::uint32_t a = 1, b = 0;
+    for (const auto c : data)
+    {
+        a = (a + c) % 65521u;
+        b = (b + a) % 65521u;
+    }
+    const auto ad = (b << 16) | a;
+    for (int s = 24; s >= 0; s -= 8)
+        out.push_back ((std::uint8_t) (ad >> s));
+    return out;
+}
+} // namespace
+
+bool ogunStateUsable (const std::vector<std::uint8_t>& state)
+{
+    try
+    {
+        return parseState (state).has_value();
+    }
+    catch (...)
+    {
+        return false;
+    }
+}
+
+std::optional<int> ogunParam (const std::vector<std::uint8_t>& state, int index)
+{
+    if (index < 0 || index >= 64 || state.size() < 8)
+        return std::nullopt;
+    const auto body = inflateZlib (state.data() + 4, state.size() - 4, false, 16u << 20);
+    if (! body || body->size() < 256)
+        return std::nullopt;
+    std::int32_t v;
+    std::memcpy (&v, body->data() + 4 * index, 4);
+    return v;
+}
+
+bool ogunSetParam (std::vector<std::uint8_t>& state, int index, int value)
+{
+    if (index < 0 || index >= 64 || state.size() < 8)
+        return false;
+    auto body = inflateZlib (state.data() + 4, state.size() - 4, false, 16u << 20);
+    if (! body || body->size() < 256)
+        return false;
+    const std::int32_t v = value;
+    std::memcpy (body->data() + 4 * index, &v, 4);
+    const auto z = zlibStored (*body);
+    state.resize (4);
+    state.insert (state.end(), z.begin(), z.end());
+    return true;
+}
+
+std::vector<std::string> ogunFallbacks (const std::vector<std::uint8_t>& state)
+{
+    const auto S = parseState (state);
+    if (! S)
+        return { "state not usable" };
+    auto f = buildPatch (*S, 44100.0, -1, 140.0, 512)->fallbacks;
+    if (S->P[11] < 1 && S->P[9] != 0)
+        f.push_back ("Seed 2 random (fixed per-instance counter)");
+    return f;
+}
+
+std::unique_ptr<Instrument> makeOgunInstrument() { return std::make_unique<OgunInstrument>(); }
+
+namespace ogun
+{
+std::vector<float> renderReference (const std::vector<std::uint8_t>& state, const std::vector<RefNote>& notes, double sampleRate,
+                                    int length, const RefOptions& opt)
+{
+    const auto S = parseState (state);
+    if (! S || length <= 0)
+        return {};
+    const auto patch = buildPatch (*S, sampleRate, opt.quality, opt.tempo, 512);
+    auto engine = std::make_unique<Engine> (patch);
+    engine->counter = opt.counter;
+    engine->maxpoly = opt.maxPolyphony;
+    engine->hostKills = opt.hostKills;
+    std::vector<int> evs;
+    for (const auto& nt : notes)
+    {
+        evs.push_back (nt.start);
+        if (nt.release >= 0)
+            evs.push_back (nt.release);
+    }
+    std::vector<long long> handle (notes.size(), -1);
+    std::vector<float> out (2 * (std::size_t) length, 0.0f), l ((std::size_t) Engine::maxHostBlock), r (l.size());
+    const int block = std::max (1, std::min (opt.block, Engine::maxHostBlock));
+    int n0 = 0;
+    while (n0 < length)
+    {
+        auto ln = std::min (block, length - n0);
+        for (auto e : evs)
+            if (n0 < e && e < n0 + ln)
+                ln = e - n0;
+        // events at this sample in input order (ogmodel sorts by sample, stable)
+        struct Ev
+        {
+            int idx;
+            bool on;
+        };
+        std::vector<std::pair<int, Ev>> list;
+        for (std::size_t i = 0; i < notes.size(); ++i)
+        {
+            if (notes[i].start == n0)
+                list.push_back ({ (int) list.size(), { (int) i, true } });
+            if (notes[i].release == n0)
+                list.push_back ({ (int) list.size(), { (int) i, false } });
+        }
+        for (const auto& [o, e] : list)
+        {
+            const auto& nt = notes[(std::size_t) e.idx];
+            if (e.on)
+            {
+                const int sh = (std::size_t) e.idx < opt.j0Shift.size() ? opt.j0Shift[(std::size_t) e.idx] : 0;
+                handle[(std::size_t) e.idx] = engine->noteOn (nt.key, nt.velocity, nt.finalVol, nt.finalPan, nt.pitchOffset, nt.fcut,
+                                                              nt.fres, nt.releaseVelocity, sh);
+            }
+            else if (handle[(std::size_t) e.idx] >= 0)
+                engine->release (handle[(std::size_t) e.idx]);
+        }
+        std::fill (l.begin(), l.end(), 0.0f);
+        std::fill (r.begin(), r.end(), 0.0f);
+        engine->render (l.data(), r.data(), ln);
+        for (int j = 0; j < ln; ++j)
+        {
+            out[2 * (std::size_t) (n0 + j)] = l[(std::size_t) j];
+            out[2 * (std::size_t) (n0 + j) + 1] = r[(std::size_t) j];
+        }
+        n0 += ln;
+    }
+    return out;
+}
+} // namespace ogun
+} // namespace lynx

+ 82 - 0
src/core/Ogun.h

@@ -0,0 +1,82 @@
+#pragma once
+
+// FL Studio's Ogun rebuilt as the inverse-FFT timbre engine decoded in docs/analise/REA_rodada37.md (clean-room; a 1:1
+// port of our own round-37 reference model r37/py/ogmodel.py, which was checked against renders of the installation's
+// DLL: 20 of 20 demo channels within −60 dB, median −123 dB). Per voice: up to 32 767 partials (Richness) whose
+// complex spectrum (seeded uniform weights, fullness shaping, morph, Forced/Impulse/Decay/Release per-partial maps
+// with fixed patterns, 1/√h, logarithmic axis and EQ shift, pre-decay, RMS normalisation, band limit) evolves per
+// 50/25 ms frame by the hold / ALT DECAY / release laws and is turned into an N-point table by an inverse real FFT;
+// the two latest tables are read with the quality's kernel (linear, 6-point Hermite, 32-point windowed sinc) and
+// crossfaded with the unison sub-voices' pan gains; then declick, the 4-type × 1–3-stage filter (2× zero-order-hold
+// oversampled below 88.2 kHz), the volume/pan matrix with gain ramps, and the 13 articulators (point-curve envelopes,
+// LFOs, key/velocity/X/Y maps, velocity options, portamento); the plugin-level 3-band EQ, chorus, delay and reverb
+// (FL's shared plate reverb, core/PlateReverb.h); qualities 2–4 run at twice the rate with the 2:1 polyphase
+// decimator. The channel keeps the plugin's raw saved state (record 0xD5, as FL wrote it) in ChannelDef::pluginState.
+//
+// Level: Ogun applies Final.Vol × (3^(P0/128) − 1)/2 × the volume articulator and its own pan matrix (FL's host does
+// not apply the channel volume/pan to it, REA_rodada28): LYNX's channel gains are turned back into Final.Vol/Pan and
+// applied once, inside the engine.
+//
+// Rendering: FL forces quality 4 when it renders to a file (dispatcher process-mode flag); LYNX does the same while
+// it exports (offlineRendering()); live playback uses the state's quality (P54).
+//
+// Differences from FL by design / not modelled (REA_rodada37 §1.20 and open questions):
+// - Seed 2 "Random": FL's per-note counter starts from its RTL random seed (clock); LYNX's starts at a fixed value per
+//   instance (0), so Random spectra are deterministic and differ from any given FL render.
+// - Read start j₀ (argmin of the first table) is ill-conditioned: an occasional time shift of a note's table vs FL.
+// - IPP's 11-bit exp in the fullness shaping is evaluated exactly (FL's last bits differ; −52 dB worst synthetic case).
+// - Global LFOs/envelopes (curve header flag 2) run as per-voice ones; host answers 2/6 are 0, release velocity is
+//   0.5 (FL's default note-off velocity), Final.FCut/FRes (Mod X/Y) are 0; parameter changes rebuild the instance.
+// - Voices: a pool grown on demand up to 64 voices per instance (the oldest is cut beyond that).
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <string>
+#include <vector>
+
+#include "core/Instruments.h"
+
+namespace lynx
+{
+// true when the exact engine can play this Ogun state (version ≥ 14, every articulator and curve parsed). (Autogun's
+// states mostly use another layout; the importer keeps them on the synth approximation.)
+bool ogunStateUsable (const std::vector<std::uint8_t>& state);
+
+// Raw integer parameter P[index] (0…63) of a state, or nullopt
+std::optional<int> ogunParam (const std::vector<std::uint8_t>& state, int index);
+// Writes P[index] (the state is re-wrapped as zlib with stored blocks); false if the state can't be read
+bool ogunSetParam (std::vector<std::uint8_t>& state, int index, int value);
+
+// what this state uses that is not modelled exactly (empty: nothing), for reports
+std::vector<std::string> ogunFallbacks (const std::vector<std::uint8_t>& state);
+
+std::unique_ptr<Instrument> makeOgunInstrument();
+
+namespace ogun
+{
+// One note for the reference renderer (drives the engine like ogmodel.Plugin.run).
+struct RefNote
+{
+    int start = 0, key = 60;
+    double velocity = 1.0, finalVol = 1.0, finalPan = 0.0, pitchOffset = 0.0, fcut = 0.0, fres = 0.0, releaseVelocity = 0.0;
+    int release = -1; // sample of the note-off (−1: held)
+};
+
+struct RefOptions
+{
+    int quality = -1;          // −1: the state's P54
+    double tempo = 140.0;      // ProcessEvent 0 (140 when never sent)
+    int block = 512;           // host block (split at every event)
+    int counter = 0;           // Seed-2 "Random" counter at the first note
+    int maxPolyphony = 0;      // ProcessEvent 1 (0 = unlimited)
+    bool hostKills = false;    // false: like the EXEC harness / model default (finished voices stay listed)
+    std::vector<int> j0Shift;  // per note (in note order): read-start shift (verification only; 0 = own choice)
+};
+
+// Renders `notes` from `state` like ogmodel.Plugin(...).run(length, events). Returns interleaved stereo float samples
+// (2·length), empty if the state is unusable.
+std::vector<float> renderReference (const std::vector<std::uint8_t>& state, const std::vector<RefNote>& notes, double sampleRate,
+                                    int length, const RefOptions& options = {});
+} // namespace ogun
+} // namespace lynx

+ 118 - 0
src/core/PlateReverb.h

@@ -0,0 +1,118 @@
+#pragma once
+
+// The plate-type reverb engine of FL Studio's shared `Shared/Reverb_x64.dll` (clean-room; behaviour described in
+// docs/analise/REA_rodada31.md §7.5, REA_rodada36 §1 and REA_rodada37 §1.18): mono input, +10⁻³⁰ anti-denormal,
+// one-pole high cut, first-order all-pass low cut, four input diffusers, predelay line, a two-half "figure-eight" tank
+// (feedback line × decay, colour shelf, + predelay output, damping one-pole, all-pass, delay × decay, all-pass,
+// delay) and 7 output taps per channel, all in float32. The plugins that host it (the Harmless and Harmor racks,
+// Ogun) compute the coefficients themselves (each with its own parameter laws) and fill the fields below; the
+// per-sample routine is the shared one. (Sytrus keeps its own double-precision copy in SytrusEngine.cpp.)
+
+#include <array>
+#include <vector>
+
+namespace lynx
+{
+struct PlateReverb
+{
+    static constexpr int lines[12] { 142, 107, 379, 277, 672, 4453, 1800, 3720, 908, 4217, 2656, 3163 };
+    static constexpr int tapsL[7] { 266, 2974, 1913, 2496, 1690, 187, 1566 };
+    static constexpr int tapsR[7] { 353, 3627, 1728, 3173, 1811, 335, 621 };
+    static constexpr double colourFactor[5] { 0.2, 0.6, 1.0, 1.5, 3.0 };
+
+    std::array<std::vector<float>, 12> buf;
+    std::array<int, 12> L {}, P {};
+    std::array<int, 7> tl {}, tr {};
+    std::vector<float> pre;
+    int pp = 0;
+    // coefficients: high cut, low cut (0 = off), damping, input diffusers, tank all-passes, decay, colour shelf
+    float cHc = 1, cLc = 0, cDamp = 1, cIn = 0, c1 = 0, c2 = 0, g = 0, c48 = 0, c44 = 0;
+    float s10 = 0, s14 = 0, s18 = 0, s3c = 0, s40 = 0, s4c = 0, s50 = 0, s54 = 0, s58 = 0;
+
+    // after L / pre lengths are set: zeroed lines
+    void allocate (int predelay)
+    {
+        for (std::size_t i = 0; i < 12; ++i)
+        {
+            buf[i].assign ((std::size_t) L[i], 0.0f);
+            P[i] = 0;
+        }
+        pre.assign ((std::size_t) (predelay < 1 ? 1 : predelay), 0.0f);
+        pp = 0;
+        s10 = s14 = s18 = s3c = s40 = s4c = s50 = s54 = s58 = 0.0f;
+    }
+
+    float ap (int i, float v, float c) noexcept
+    {
+        auto& p = P[(std::size_t) i];
+        auto& b = buf[(std::size_t) i];
+        const auto w = b[(std::size_t) p] - c * v;
+        b[(std::size_t) p] = c * w + v;
+        p = p > 0 ? p - 1 : L[(std::size_t) i] - 1;
+        return w;
+    }
+
+    float dl (int i, float v) noexcept
+    {
+        auto& p = P[(std::size_t) i];
+        auto& b = buf[(std::size_t) i];
+        const auto r = b[(std::size_t) p];
+        b[(std::size_t) p] = v;
+        p = p > 0 ? p - 1 : L[(std::size_t) i] - 1;
+        return r;
+    }
+
+    float tap (int i, int off) const noexcept
+    {
+        const auto k = off + P[(std::size_t) i];
+        return buf[(std::size_t) i][(std::size_t) (k >= L[(std::size_t) i] ? k - L[(std::size_t) i] : k)];
+    }
+
+    // x: mono input (n samples); writes the wet stereo output (not scaled)
+    void process (const float* x, float* outL, float* outR, int n) noexcept
+    {
+        const auto t1 = 1.0f - g;
+        const auto w74 = t1 * 0.6f + g, w6c = t1 * 0.25f + g, w78 = t1 * 0.7f + g, w68 = t1 * 0.2f + g, w70 = t1 * 0.5f + g;
+        for (int i = 0; i < n; ++i)
+        {
+            auto a = ((x[i] + 1.0e-30f) - s10) * cHc + s10;
+            s10 = a;
+            const auto h = (a - s14) * cLc + s18;
+            s18 = a, s14 = h;
+            if (cLc != 0.0f)
+                a = (a - h) * 0.5f + 1.0e-30f;
+            for (int k = 0; k < 4; ++k)
+                a = ap (k, a, cIn);
+            const auto z = pre[(std::size_t) pp];
+            pre[(std::size_t) pp] = a;
+            pp = pp > 0 ? pp - 1 : (int) pre.size() - 1;
+            // half 1
+            auto u = buf[11][(std::size_t) P[11]] * g;
+            auto f = (u - s50) * c44 + s4c;
+            s4c = u, s50 = f;
+            auto v = (((f + u) * c48 + u + z) - s3c) * cDamp + s3c;
+            s3c = v;
+            auto w = ap (4, v, c1);
+            auto r = dl (5, w) * g;
+            auto w2 = ap (6, r, c2);
+            buf[7][(std::size_t) P[7]] = w2;
+            P[7] = P[7] > 0 ? P[7] - 1 : L[7] - 1;
+            // half 2
+            u = buf[7][(std::size_t) P[7]] * g;
+            f = (u - s58) * c44 + s54;
+            s54 = u, s58 = f;
+            v = (((f + u) * c48 + u + z) - s40) * cDamp + s40;
+            s40 = v;
+            w = ap (8, v, c1);
+            r = dl (9, w) * g;
+            w2 = ap (10, r, c2);
+            buf[11][(std::size_t) P[11]] = w2;
+            P[11] = P[11] > 0 ? P[11] - 1 : L[11] - 1;
+            outL[i] = (((tap (9, tl[0]) - w6c * tap (9, tl[1])) - w78 * tap (10, tl[2])) - w68 * tap (11, tl[3]))
+                      + w74 * tap (5, tl[4]) + tap (6, tl[5]) + w70 * tap (7, tl[6]);
+            outR[i] = ((((w6c * tap (5, tr[1]) + tap (5, tr[0])) - w78 * tap (6, tr[2])) - w68 * tap (7, tr[3]))
+                       - w74 * tap (9, tr[4])) + tap (10, tr[5]) + w70 * tap (11, tr[6]);
+        }
+    }
+};
+} // namespace lynx

+ 220 - 0
src/core/RackOps.cpp

@@ -1,6 +1,9 @@
 #include "core/RackOps.h"
 
 #include <algorithm>
+#include <cctype>
+#include <cmath>
+#include <functional>
 #include <numeric>
 
 namespace lynx
@@ -156,6 +159,223 @@ int splitPatternByChannel (Song& song, int index)
     return (int) created.size();
 }
 
+namespace
+{
+std::string nextCopyName (const std::string& base, const std::function<bool (const std::string&)>& taken)
+{
+    for (int n = 2;; ++n)
+    {
+        const auto name = base + " #" + std::to_string (n);
+        if (! taken (name))
+            return name;
+    }
+}
+} // namespace
+
+int clonePattern (Song& song, int index)
+{
+    if (index < 0 || index >= (int) song.patterns.size())
+        return -1;
+
+    auto copy = song.patterns[(std::size_t) index];
+    copy.name = nextCopyName (copy.name, [&song] (const std::string& name) {
+        return std::any_of (song.patterns.begin(), song.patterns.end(), [&] (const Pattern& p) { return p.name == name; });
+    });
+    shiftPatternClips (song, index + 1, 1);
+    song.patterns.insert (song.patterns.begin() + index + 1, std::move (copy));
+    song.currentPattern = index + 1;
+    return index + 1;
+}
+
+bool movePattern (Song& song, int index, int delta)
+{
+    const auto other = index + (delta < 0 ? -1 : 1);
+
+    if (delta == 0 || index < 0 || index >= (int) song.patterns.size() || other < 0 || other >= (int) song.patterns.size())
+        return false;
+
+    std::swap (song.patterns[(std::size_t) index], song.patterns[(std::size_t) other]);
+    song.forEachClipList ([index, other] (std::vector<Clip>& clips) {
+        for (auto& c : clips)
+            if (c.kind == ClipKind::pattern)
+                c.pattern = c.pattern == index ? other : c.pattern == other ? index : c.pattern;
+    });
+
+    if (song.currentPattern == index)
+        song.currentPattern = other;
+    else if (song.currentPattern == other)
+        song.currentPattern = index;
+
+    return true;
+}
+
+// --- step sequencer ----------------------------------------------------------------------------
+
+int patternSteps (const Song& song, const Pattern& pattern) noexcept
+{
+    return std::clamp ((int) (pattern.effectiveLength (song.beatsPerBar) / ticksPerStep), 16, 512);
+}
+
+std::vector<bool> euclideanRhythm (int pulses, int steps, int rotation)
+{
+    if (steps <= 0)
+        return {};
+
+    pulses = std::clamp (pulses, 0, steps);
+    std::vector<bool> out ((std::size_t) steps, false);
+
+    // step i is an onset when the running count floor(i * pulses / steps) goes up there: the onsets
+    // are spread as evenly as integers allow, and the first step is always one
+    for (int i = 0; i < steps; ++i)
+        out[(std::size_t) i] = pulses > 0 && (i * pulses) % steps < pulses;
+
+    rotation = ((rotation % steps) + steps) % steps;
+    std::rotate (out.rbegin(), out.rbegin() + rotation, out.rend());
+    return out;
+}
+
+void fillEverySteps (Pattern& pattern, int channel, int every, int steps, int offset)
+{
+    every = std::max (1, every);
+
+    for (int s = std::max (0, offset); s < steps; s += every)
+        if (! pattern.hasStep (channel, s))
+            pattern.toggleStep (channel, s);
+}
+
+void setStepRhythm (Pattern& pattern, int channel, const std::vector<bool>& rhythm, int steps)
+{
+    const auto end = (std::int64_t) steps * ticksPerStep;
+    auto& notes = pattern.notes;
+    notes.erase (std::remove_if (notes.begin(), notes.end(),
+                                 [&] (const Note& n) { return n.channel == channel && n.start < end && n.start % ticksPerStep == 0; }),
+                 notes.end());
+
+    if (! rhythm.empty())
+        for (int s = 0; s < steps; ++s)
+            if (rhythm[(std::size_t) s % rhythm.size()])
+            {
+                Note n;
+                n.start = (std::int64_t) s * ticksPerStep;
+                n.channel = channel;
+                notes.push_back (n);
+            }
+
+    pattern.sortNotes();
+}
+
+void rotateSteps (Pattern& pattern, int channel, int delta, int steps)
+{
+    if (steps <= 0)
+        return;
+
+    const auto length = (std::int64_t) steps * ticksPerStep;
+    const auto shift = (std::int64_t) delta * ticksPerStep;
+
+    for (auto& n : pattern.notes)
+        if (n.channel == channel && n.start < length)
+            n.start = ((n.start + shift) % length + length) % length;
+
+    pattern.sortNotes();
+}
+
+bool hasPianoRollNotes (const Pattern& pattern) noexcept
+{
+    return std::any_of (pattern.notes.begin(), pattern.notes.end(), [] (const Note& n) {
+        return n.start % ticksPerStep != 0 || n.key != 60 || n.length > ticksPerStep;
+    });
+}
+
+std::vector<int> notesInStep (const Pattern& pattern, int channel, int step)
+{
+    const auto from = (std::int64_t) step * ticksPerStep;
+    std::vector<int> out;
+
+    for (int i = 0; i < (int) pattern.notes.size(); ++i)
+    {
+        const auto& n = pattern.notes[(std::size_t) i];
+        if (n.channel == channel && n.start >= from && n.start < from + ticksPerStep)
+            out.push_back (i);
+    }
+
+    return out;
+}
+
+// --- channel organisation ----------------------------------------------------------------------
+
+std::vector<int> channelSortOrder (const Song& song, ChannelSort by)
+{
+    std::vector<int> order (song.channels.size());
+    std::iota (order.begin(), order.end(), 0);
+
+    auto lower = [] (std::string s) {
+        for (auto& c : s)
+            c = (char) std::tolower ((unsigned char) c);
+        return s;
+    };
+
+    // colour order: by hue, uncoloured channels last
+    auto hue = [] (std::uint32_t argb) {
+        if (argb == 0)
+            return 1000.0;
+        const auto r = ((argb >> 16) & 0xff) / 255.0, g = ((argb >> 8) & 0xff) / 255.0, b = (argb & 0xff) / 255.0;
+        const auto mx = std::max ({ r, g, b }), mn = std::min ({ r, g, b }), d = mx - mn;
+        if (d <= 1e-9)
+            return 400.0 + mx; // greys after the colours
+        double h = mx == r ? std::fmod ((g - b) / d, 6.0) : mx == g ? (b - r) / d + 2.0 : (r - g) / d + 4.0;
+        h = h < 0.0 ? h * 60.0 + 360.0 : h * 60.0;
+        return h >= 345.0 ? h - 360.0 : h; // reds just below 360 sort with the other reds, first
+    };
+
+    const auto& c = song.channels;
+    std::stable_sort (order.begin(), order.end(), [&] (int a, int b) {
+        const auto& x = c[(std::size_t) a];
+        const auto& y = c[(std::size_t) b];
+        switch (by)
+        {
+            case ChannelSort::name: return lower (x.name) < lower (y.name);
+            case ChannelSort::colour: return hue (x.colour) < hue (y.colour);
+            case ChannelSort::insert: return (x.mixerTrack <= 0 ? 1 << 20 : x.mixerTrack) < (y.mixerTrack <= 0 ? 1 << 20 : y.mixerTrack);
+            case ChannelSort::type: return (int) x.instrument < (int) y.instrument;
+        }
+        return false;
+    });
+
+    return order;
+}
+
+std::vector<int> unusedChannels (const Song& song)
+{
+    std::vector<char> used (song.channels.size(), 0);
+    auto mark = [&used] (int channel) {
+        if (channel >= 0 && channel < (int) used.size())
+            used[(std::size_t) channel] = 1;
+    };
+
+    for (const auto& p : song.patterns)
+        for (const auto& n : p.notes)
+            mark (n.channel);
+
+    auto markClips = [&mark] (const std::vector<Clip>& clips) {
+        for (const auto& clip : clips)
+            if (clip.kind == ClipKind::audio)
+                mark (clip.channel);
+    };
+    markClips (song.playlist);
+    for (const auto& a : song.arrangements)
+        markClips (a.clips);
+
+    for (const auto& a : song.automations)
+        mark (a.source.channel);
+
+    std::vector<int> out;
+    for (int i = 0; i < (int) used.size(); ++i)
+        if (! used[(std::size_t) i])
+            out.push_back (i);
+
+    return out;
+}
+
 // --- channel selection -------------------------------------------------------------------------
 
 bool ChannelSelection::contains (int row) const noexcept

+ 44 - 0
src/core/RackOps.h

@@ -45,6 +45,50 @@ int splitPatternByChannel (Song& song, int index);
 // Default name for a new pattern: "Pattern N" with the lowest N not in use.
 std::string newPatternName (const Song& song);
 
+// Copies pattern `index` (notes, length, colour) right after it, named "<name> #2" (or the next free
+// number), and selects it. Playlist clips keep pointing at the same patterns. Returns the new index.
+int clonePattern (Song& song, int index);
+
+// Swaps pattern `index` with its neighbour above (delta < 0) or below; clips and the current pattern
+// follow. Returns false at the ends.
+bool movePattern (Song& song, int index, int delta);
+
+// --- step sequencer (docs/WORKFLOW_FL.md P2: fill, Euclidean fill, rotate, graph lanes) --------------
+
+// Steps the pattern shows in the rack (its length in sixteenths, at least 16).
+int patternSteps (const Song& song, const Pattern& pattern) noexcept;
+
+// An Euclidean rhythm: `pulses` onsets spread as evenly as possible over `steps`, starting on the first
+// step, then rotated right by `rotation` steps. pulses is clamped to 0..steps.
+std::vector<bool> euclideanRhythm (int pulses, int steps, int rotation = 0);
+
+// Turns on every `every`-th step of `channel` (from `offset`) over `steps` steps; existing notes stay.
+void fillEverySteps (Pattern& pattern, int channel, int every, int steps, int offset = 0);
+
+// Replaces the channel's step notes (notes starting exactly on a step) inside the first `steps` steps by
+// `rhythm`, repeated to fill them. Notes that are off the step grid are left alone.
+void setStepRhythm (Pattern& pattern, int channel, const std::vector<bool>& rhythm, int steps);
+
+// Moves every note of `channel` by `delta` steps, wrapping inside the first `steps` steps.
+void rotateSteps (Pattern& pattern, int channel, int delta, int steps);
+
+// True when the pattern has notes the step sequencer can't show as steps (off the step grid, another key
+// or a held length): the Playlist then opens it in the Piano Roll.
+bool hasPianoRollNotes (const Pattern& pattern) noexcept;
+
+// Indices of the channel's notes that start inside step `step` (the cell the rack draws).
+std::vector<int> notesInStep (const Pattern& pattern, int channel, int step);
+
+// --- channel organisation ----------------------------------------------------------------------
+
+enum class ChannelSort { name, colour, insert, type };
+
+// The order (newOrder for permuteChannels) that sorts the channels; stable, so equal keys keep their order.
+std::vector<int> channelSortOrder (const Song& song, ChannelSort by);
+
+// Channels no pattern plays and no Playlist clip uses (and that no automation reads as a live source).
+std::vector<int> unusedChannels (const Song& song);
+
 // --- channel selection -------------------------------------------------------------------------
 
 // Multi-selection of Channel Rack rows: always sorted, unique and inside [0, count).

+ 60 - 0
src/core/Recorder.cpp

@@ -22,6 +22,66 @@ std::int64_t patternPositionForTick (const Song& song, double tick, std::int64_t
     return position % std::max<std::int64_t> (1, loopLength);
 }
 
+void commitTake (Pattern& pattern, std::vector<Note> notes, RecordMode mode, std::int64_t grid, std::vector<int>& clearedChannels)
+{
+    if (mode == RecordMode::replace)
+        for (const auto& n : notes)
+            if (std::find (clearedChannels.begin(), clearedChannels.end(), n.channel) == clearedChannels.end())
+            {
+                clearedChannels.push_back (n.channel);
+                auto& existing = pattern.notes;
+                existing.erase (std::remove_if (existing.begin(), existing.end(), [&n] (const Note& o) { return o.channel == n.channel; }),
+                                existing.end());
+            }
+
+    if (grid > 1)
+        for (auto& n : notes)
+            n.start = std::max<std::int64_t> (0, (n.start + grid / 2) / grid * grid);
+
+    pattern.notes.insert (pattern.notes.end(), notes.begin(), notes.end());
+    pattern.sortNotes();
+}
+
+bool placePatternClipAt (Song& song, int pattern, std::int64_t tick)
+{
+    if (pattern < 0 || pattern >= (int) song.patterns.size())
+        return false;
+
+    tick = std::max<std::int64_t> (0, tick);
+
+    for (const auto& c : song.playlist)
+        if (c.kind == ClipKind::pattern && c.pattern == pattern && tick >= c.start && tick < c.end())
+            return false;
+
+    const auto bar = song.barAt (tick);
+    Clip clip;
+    clip.kind = ClipKind::pattern;
+    clip.pattern = pattern;
+    clip.start = bar.tick;
+    clip.length = song.patterns[(std::size_t) pattern].effectiveLength (song.beatsPerBar);
+
+    for (int track = 0;; ++track)
+    {
+        const auto busy = std::any_of (song.playlist.begin(), song.playlist.end(), [&] (const Clip& c) {
+            return c.track == track && c.start < clip.end() && c.end() > clip.start;
+        });
+
+        if (! busy)
+        {
+            clip.track = track;
+            break;
+        }
+    }
+
+    song.playlist.push_back (clip);
+    return true;
+}
+
+std::int64_t countInLength (const Song& song, int bars, std::int64_t tick)
+{
+    return std::max (0, bars) * std::max<std::int64_t> (1, song.barAt (std::max<std::int64_t> (0, tick)).length);
+}
+
 void NoteRecorder::begin (std::int64_t loopLength)
 {
     active = true;

+ 21 - 0
src/core/Recorder.h

@@ -3,6 +3,7 @@
 // Recording of notes played live (MIDI or PC keyboard) into the current pattern.
 // Runs on the UI thread; events arrive with the absolute transport position.
 
+#include <cstdint>
 #include <map>
 #include <vector>
 
@@ -24,6 +25,26 @@ struct RecordedEvent
 // playing there (or, without a clip, as if it were the pattern loop).
 std::int64_t patternPositionForTick (const Song& song, double tick, std::int64_t loopLength);
 
+// --- recording options (docs/WORKFLOW_FL.md P2: recording set) ---------------------------------
+
+enum class RecordMode : std::uint8_t
+{
+    overdub, // recorded notes are added to what the pattern has
+    replace  // a channel's first recorded note of a take clears that channel's notes in the pattern
+};
+
+// Commits finished notes of a take into `pattern`: starts quantised to the nearest multiple of `grid`
+// (grid <= 1: as played; lengths kept). In replace mode, `clearedChannels` remembers the channels already
+// cleared during this take, so later notes of the same take stay.
+void commitTake (Pattern& pattern, std::vector<Note> notes, RecordMode mode, std::int64_t grid, std::vector<int>& clearedChannels);
+
+// Song mode: makes sure a clip of `pattern` plays at `tick`. If none does, one is placed at the start of
+// that bar, on the first track that is free there. Returns true when a clip was added.
+bool placePatternClipAt (Song& song, int pattern, std::int64_t tick);
+
+// Length of a count-in of `bars` bars at the song position `tick` (bars follow the time signature there).
+std::int64_t countInLength (const Song& song, int bars, std::int64_t tick = 0);
+
 class NoteRecorder
 {
 public:

+ 184 - 0
src/core/SearchQuery.cpp

@@ -0,0 +1,184 @@
+#include "core/SearchQuery.h"
+
+#include <cctype>
+
+namespace lynx::search
+{
+namespace
+{
+std::string lower (std::string s)
+{
+    for (auto& c : s)
+        c = (char) std::tolower ((unsigned char) c);
+    return s;
+}
+
+// splits into tokens; a quoted phrase is one token (kept with a leading '"' marker)
+std::vector<std::string> tokens (const std::string& q)
+{
+    std::vector<std::string> out;
+    std::string current;
+    bool quoted = false;
+
+    auto flush = [&] {
+        if (! current.empty())
+            out.push_back (current);
+        current.clear();
+    };
+
+    for (std::size_t i = 0; i < q.size(); ++i)
+    {
+        const auto c = q[i];
+
+        if (c == '"')
+        {
+            if (quoted)
+            {
+                out.push_back ("\"" + current);
+                current.clear();
+                quoted = false;
+            }
+            else
+            {
+                flush();
+                quoted = true;
+            }
+            continue;
+        }
+
+        if (! quoted && std::isspace ((unsigned char) c))
+        {
+            flush();
+            continue;
+        }
+
+        current += c;
+    }
+
+    if (quoted)
+        out.push_back ("\"" + current);
+    else
+        flush();
+
+    return out;
+}
+} // namespace
+
+bool wildcardMatch (const std::string& pattern, const std::string& text)
+{
+    const auto p = lower (pattern), t = lower (text);
+    std::size_t pi = 0, ti = 0, star = std::string::npos, mark = 0;
+
+    while (ti < t.size())
+    {
+        if (pi < p.size() && (p[pi] == '?' || p[pi] == t[ti]))
+        {
+            ++pi;
+            ++ti;
+        }
+        else if (pi < p.size() && p[pi] == '*')
+        {
+            star = pi++;
+            mark = ti;
+        }
+        else if (star != std::string::npos)
+        {
+            pi = star + 1;
+            ti = ++mark;
+        }
+        else
+            return false;
+    }
+
+    while (pi < p.size() && p[pi] == '*')
+        ++pi;
+
+    return pi == p.size();
+}
+
+Query parse (const std::string& query)
+{
+    Query out (1);
+    bool negateNext = false;
+
+    for (const auto& token : tokens (query))
+    {
+        const auto phrase = ! token.empty() && token[0] == '"';
+
+        if (! phrase && token == "OR")
+        {
+            if (! out.back().empty())
+                out.emplace_back();
+            continue;
+        }
+
+        if (! phrase && token == "AND")
+            continue;
+
+        if (! phrase && token == "NOT")
+        {
+            negateNext = true;
+            continue;
+        }
+
+        Term term;
+        term.negated = negateNext;
+        negateNext = false;
+        auto text = phrase ? token.substr (1) : token;
+
+        if (! phrase && text.size() > 1 && text[0] == '-')
+        {
+            term.negated = true;
+            text = text.substr (1);
+        }
+
+        if (text.empty())
+            continue;
+
+        term.text = lower (text);
+        term.wildcard = ! phrase && text.find_first_of ("*?") != std::string::npos;
+        out.back().push_back (term);
+    }
+
+    if (out.back().empty() && out.size() > 1)
+        out.pop_back();
+
+    return out;
+}
+
+bool matches (const Query& query, const std::string& name)
+{
+    const auto lowered = lower (name);
+    bool anyGroup = false;
+
+    for (const auto& group : query)
+    {
+        if (group.empty())
+            continue;
+
+        anyGroup = true;
+        bool all = true;
+
+        for (const auto& term : group)
+        {
+            const auto hit = term.wildcard ? wildcardMatch (term.text, lowered) : lowered.find (term.text) != std::string::npos;
+
+            if (hit == term.negated)
+            {
+                all = false;
+                break;
+            }
+        }
+
+        if (all)
+            return true;
+    }
+
+    return ! anyGroup;
+}
+
+bool matches (const std::string& query, const std::string& name)
+{
+    return matches (parse (query), name);
+}
+} // namespace lynx::search

+ 33 - 0
src/core/SearchQuery.h

@@ -0,0 +1,33 @@
+#pragma once
+
+// Browser search queries (docs/WORKFLOW_FL.md P2: browser search). Case-insensitive (ASCII) matching of
+// file names against a small query language:
+//   kick snare        both words (AND; "AND" may also be written)
+//   kick OR snare     either side of OR (OR binds looser than AND)
+//   NOT loop / -loop  excludes names containing the word
+//   "808 kick"        the exact phrase
+//   kick*.wav, h?t    wildcards: * any run of characters, ? any one character (the whole name must match)
+// An empty query matches everything.
+
+#include <string>
+#include <vector>
+
+namespace lynx::search
+{
+struct Term
+{
+    std::string text;      // lower-case
+    bool negated = false;
+    bool wildcard = false; // contains * or ?: matched against the whole name
+};
+
+// Groups of AND-ed terms, OR-ed together.
+using Query = std::vector<std::vector<Term>>;
+
+Query parse (const std::string& query);
+bool matches (const Query& query, const std::string& name);
+bool matches (const std::string& query, const std::string& name);
+
+// Wildcard match of the whole text (* and ?), case-insensitive.
+bool wildcardMatch (const std::string& pattern, const std::string& text);
+} // namespace lynx::search

+ 6 - 4
src/core/Song.h

@@ -44,7 +44,8 @@ enum class InstrumentKind : std::uint8_t
     sytrus,     // FL's Sytrus engine (REA_rodada31): the plugin's raw saved state in ChannelDef::pluginState
     harmor,     // FL's Harmor additive engine (REA_rodada34): the plugin's raw saved state in ChannelDef::pluginState
     gms,        // FL's GMS engine (REA_rodada39 §1): raw saved state in pluginState, wave folder in samplePath
-    morphine    // FL's Morphine engine (REA_rodada39 §2): raw saved state in pluginState, noise sample in samplePath
+    morphine,   // FL's Morphine engine (REA_rodada39 §2): raw saved state in pluginState, noise sample in samplePath
+    ogun        // FL's Ogun inverse-FFT engine (REA_rodada37): the plugin's raw saved state in ChannelDef::pluginState
 };
 
 // External plugin: format identifier (the app knows how to find the file) + saved state.
@@ -248,7 +249,7 @@ struct ChannelDef
     PluginRef plugin;       // used when instrument == plugin
     std::vector<std::uint8_t> controllerState; // instrument == controller: FL Envelope Controller state
     std::vector<float> modelParams; // instrument == sakura / drumpad / boobass / drumsynth / harmless: FL's raw state parameters
-    std::vector<std::uint8_t> pluginState; // instrument == sytrus / harmor: the FL plugin's saved state (record 0xD5), as FL wrote it
+    std::vector<std::uint8_t> pluginState; // instrument == sytrus / harmor / ogun: the FL plugin's saved state (record 0xD5), as FL wrote it
     SamplerSettings sampler; // used when instrument == sampler
     SynthSettings synth;     // used when instrument == synth
     float swingMix = 1.0f;   // how much of the global swing applies to this channel (0..1), as in FL
@@ -285,7 +286,8 @@ enum class EffectKind : std::uint8_t
     pitchCorrect, // pitch correction (FL's Pitcher): detects the pitch and pulls it to the nearest allowed note
     squeeze,      // FL's Fruity Squeeze, exact (REA_rodada29 §2): quantiser, periodic gate, filter; raw values / max
     vintagePhaser, // FL's Vintage Phaser (REA_rodada29 §3, core/VintagePhaser.h): 36 normalised engine values
-    vocodex       // FL's Vocodex (REA_rodada35, core/Vocodex.h): built from FL's raw state (EffectSlot::state)
+    vocodex,      // FL's Vocodex (REA_rodada35, core/Vocodex.h): built from FL's raw state (EffectSlot::state)
+    maximus       // FL's Maximus / Soundgoodizer engine (REA_rodada36/38, core/MaximusFx.h): built from EffectSlot::state
 };
 
 constexpr int maxEffectParams = 48; // the 7-band parametric EQ and the Pitcher use most of them
@@ -321,7 +323,7 @@ struct EffectSlot
     int sidechain2 = -1;  // second side input (vocoder carrier); −1 = none
     std::vector<EffectBranch> branches;           // used when kind == parallel
     std::vector<EffectLink> links;                // used when kind == parallel
-    std::vector<std::uint8_t> state;              // FL's raw plugin state, for exact effects built from it (vocodex)
+    std::vector<std::uint8_t> state;              // FL's raw plugin state, for exact effects built from it (vocodex, maximus)
 };
 
 // Send from one track to another (post-fader), like FL's routing between inserts.

+ 156 - 9
src/core/Vocodex.cpp

@@ -6,6 +6,8 @@
 #include <cstring>
 
 #include "core/FlEffects.h"
+#include "core/Instruments.h"
+#include "core/SytrusEngine.h"
 
 // The engine's rounding is part of its behaviour (the reference matches FL's DLL to the last bits): no fused
 // multiply-add contraction, whatever the target CPU.
@@ -1575,10 +1577,138 @@ void Engine::process (const float* own, const float* mod, const float* car, floa
 int Engine::latencySamples() const noexcept { return impl->draft ? fifoFrames : 0; }
 int Engine::maxBlock() const noexcept { return impl->maxBlock; }
 
+// --- install data (LYNX's trailer after FL's state) ------------------------------------------------------------------
+namespace
+{
+constexpr char dataTag[8] { 'L', 'X', 'V', 'X', 'D', 'A', 'T', 'A' };
+
+void putU32 (std::vector<std::uint8_t>& v, std::uint32_t x)
+{
+    for (int k = 0; k < 4; ++k)
+        v.push_back ((std::uint8_t) (x >> (8 * k)));
+}
+
+std::uint32_t getU32 (const std::uint8_t* p)
+{
+    return (std::uint32_t) p[0] | ((std::uint32_t) p[1] << 8) | ((std::uint32_t) p[2] << 16) | ((std::uint32_t) p[3] << 24);
+}
+} // namespace
+
+std::vector<std::uint8_t> appendInstallData (std::vector<std::uint8_t> flState, const InstallData& data)
+{
+    std::vector<std::uint8_t> body;
+    auto record = [&body] (std::uint32_t tag, const std::vector<std::uint8_t>& bytes) {
+        if (bytes.empty())
+            return;
+        putU32 (body, tag);
+        putU32 (body, (std::uint32_t) bytes.size());
+        body.insert (body.end(), bytes.begin(), bytes.end());
+    };
+    record (1, data.sgDat);
+    record (2, data.carrierState);
+    if (body.empty())
+        return flState;
+    flState.insert (flState.end(), body.begin(), body.end());
+    putU32 (flState, (std::uint32_t) body.size());
+    flState.insert (flState.end(), dataTag, dataTag + 8);
+    return flState;
+}
+
+std::pair<std::vector<std::uint8_t>, InstallData> splitInstallData (const std::vector<std::uint8_t>& slotState)
+{
+    InstallData data;
+    const auto n = slotState.size();
+    if (n < 12 || std::memcmp (slotState.data() + n - 8, dataTag, 8) != 0)
+        return { slotState, data };
+    const auto len = (std::size_t) getU32 (slotState.data() + n - 12);
+    if (len > n - 12)
+        return { slotState, data };
+    const auto begin = n - 12 - len;
+    for (auto at = begin; at + 8 <= n - 12;)
+    {
+        const auto tag = getU32 (slotState.data() + at);
+        const auto size = (std::size_t) getU32 (slotState.data() + at + 4);
+        at += 8;
+        if (size > n - 12 - at)
+            break;
+        std::vector<std::uint8_t> bytes (slotState.begin() + (std::ptrdiff_t) at, slotState.begin() + (std::ptrdiff_t) (at + size));
+        if (tag == 1)
+            data.sgDat = std::move (bytes);
+        else if (tag == 2)
+            data.carrierState = std::move (bytes);
+        at += size;
+    }
+    return { std::vector<std::uint8_t> (slotState.begin(), slotState.begin() + (std::ptrdiff_t) begin), data };
+}
+
 // --- internal carrier --------------------------------------------------------------------------------------------------
+namespace
+{
+// REA_rodada35 §8 + REA_rodada40 §5: Vocodex hosts its own Sytrus build and triggers one voice per latched key with
+// Init/Final levels pan 0, volume 0.5, Final.Pitch = 100·key − 6000 cents (= the key itself) and FCut/FRes 0; its host
+// answers the voice events 3 (velocity) 0.78125 and 5 (release) 1.0, colour 0 (FUN_0084c1c0). The keys stay held.
+class SytrusCarrier final : public Carrier
+{
+public:
+    SytrusCarrier (std::shared_ptr<const sytrus::Patch> p, std::vector<int> keys) : patch (std::move (p)), notes (std::move (keys)) {}
+
+    void prepare (double sampleRate) override
+    {
+        engine.prepare (sampleRate, offlineRendering(), block);
+        engine.setPatch (patch);
+        std::int64_t id = 0;
+        for (const auto key : notes)
+        {
+            sytrus::NoteParams note;
+            note.key = (float) key;
+            note.cents = 0.0f;
+            note.velocity = 0.78125f;
+            note.releaseVelocity = 1.0f;
+            note.pan = 0.0f;
+            note.id = ++id;
+            engine.noteOn (note);
+        }
+        left.assign ((std::size_t) block, 0.0f);
+        right.assign ((std::size_t) block, 0.0f);
+    }
+
+    void render (float* out, int n) noexcept override
+    {
+        for (int done = 0; done < n; done += block)
+        {
+            const auto len = std::min (block, n - done);
+            std::fill (left.begin(), left.begin() + len, 0.0f);
+            std::fill (right.begin(), right.begin() + len, 0.0f);
+            engine.render (left.data(), right.data(), len, 0.5f, 0.0f);
+            for (int k = 0; k < len; ++k)
+                out[2 * (done + k)] = left[(std::size_t) k], out[2 * (done + k) + 1] = right[(std::size_t) k];
+        }
+    }
+
+    void setTempo (double bpm) noexcept { engine.setTempo (bpm); }
+
+private:
+    static constexpr int block = 512;
+    std::shared_ptr<const sytrus::Patch> patch;
+    std::vector<int> notes;
+    sytrus::Engine engine;
+    std::vector<float> left, right;
+};
+} // namespace
+
 std::unique_ptr<Carrier> makeInternalCarrier (const State&)
 {
-    return nullptr; // no LYNX instrument plays the internal Sytrus carrier yet
+    return nullptr; // the Sytrus preset comes from the user's installation: see the overload below
+}
+
+std::unique_ptr<Carrier> makeInternalCarrier (const State& state, const std::vector<std::uint8_t>& sytrusState)
+{
+    if (sytrusState.empty() || state.notes.empty())
+        return nullptr;
+    auto patch = sytrus::parsePatch (sytrusState);
+    if (patch == nullptr)
+        return nullptr;
+    return std::make_unique<SytrusCarrier> (std::move (patch), state.notes);
 }
 
 // --- the effect --------------------------------------------------------------------------------------------------------
@@ -1589,16 +1719,23 @@ class VocodexEffect final : public Effect
 public:
     static constexpr int chunk = 2048;
 
-    explicit VocodexEffect (const std::vector<std::uint8_t>& raw)
-        : state (parseState (raw))
+    explicit VocodexEffect (const std::vector<std::uint8_t>& slotState)
     {
+        auto [raw, data] = splitInstallData (slotState);
+        state = parseState (raw);
         if (state && state->internalCarrier())
-            carrier = makeInternalCarrier (*state);
+            carrier = makeInternalCarrier (*state, data.carrierState);
         if (state && state->params[sg] > 0)
         {
-            sgSlots = soundgoodizerApproximation (0, state->params[sg]);
-            for (const auto& slot : sgSlots)
-                sgEffects.push_back (makeEffect (slot.kind));
+            // FL's SG stage: the shared Maximus build with Vocodex/Data/SG.dat and parameter 5 = SG (REA_rodada40 §4)
+            if (! data.sgDat.empty())
+                sgPreset = hlfx::makeMaximusPreset (data.sgDat);
+            if (sgPreset == nullptr)
+            {
+                sgSlots = soundgoodizerApproximation (0, state->params[sg]);
+                for (const auto& slot : sgSlots)
+                    sgEffects.push_back (makeEffect (slot.kind));
+            }
         }
         for (auto* v : { &ownBuf, &modBuf, &carBuf, &outBuf, &zeros })
             v->assign (2 * chunk, 0.0f);
@@ -1610,6 +1747,8 @@ public:
             engine.prepare (*state, sr, chunk, state->draft());
         if (carrier != nullptr)
             carrier->prepare (sr);
+        if (sgPreset != nullptr)
+            sgEngine.prepare (sgPreset, sr, state->params[sg]);
         for (auto& e : sgEffects)
             e->prepare (sr);
     }
@@ -1618,6 +1757,7 @@ public:
     {
         if (runsEngine())
             engine.flush();
+        sgEngine.reset();
         for (auto& e : sgEffects)
             e->reset();
     }
@@ -1626,9 +1766,9 @@ public:
     {
         if (! runsEngine())
             return 0;
-        auto latency = engine.latencySamples();
+        auto latency = engine.latencySamples() + sgEngine.latencySamples();
         for (const auto& e : sgEffects)
-            latency += e->latencySamples(); // the Soundgoodizer's limiter look-ahead
+            latency += e->latencySamples(); // the Soundgoodizer approximation's limiter look-ahead
         return latency;
     }
 
@@ -1650,6 +1790,8 @@ public:
         useSide = { false, false };
         if (! state)
             return;
+        if (auto* s = dynamic_cast<SytrusCarrier*> (carrier.get()))
+            s->setTempo (bpm);
 
         for (int done = 0; done < n; done += chunk)
         {
@@ -1706,8 +1848,11 @@ public:
                 L[k] = outBuf[(std::size_t) (2 * k)], R[k] = outBuf[(std::size_t) (2 * k + 1)];
         }
         if (runsEngine())
+        {
+            sgEngine.process (l, r, n); // FL's Eff_Render of the hosted SG.dll, in place on the output
             for (std::size_t i = 0; i < sgEffects.size(); ++i)
                 sgEffects[i]->process (l, r, n, sgSlots[i].params, bpm);
+        }
     }
 
 private:
@@ -1716,6 +1861,8 @@ private:
     std::optional<State> state;
     Engine engine;
     std::unique_ptr<Carrier> carrier;
+    std::shared_ptr<const hlfx::MaximusPreset> sgPreset;
+    hlfx::MaximusProcessor sgEngine;
     std::vector<EffectSlot> sgSlots;
     std::vector<std::unique_ptr<Effect>> sgEffects;
     std::vector<float> ownBuf, modBuf, carBuf, outBuf, zeros;

+ 21 - 4
src/core/Vocodex.h

@@ -5,8 +5,11 @@
 // state (EffectSlot::state) and builds the whole engine from it: band layout and per-band maps, 64-bit band-pass
 // filter banks with 2× / octave-level multirate, PEAK/RMS followers, gate, saturation, smoother, unison, carrier
 // noise, consonant/carrier contour, pass-through and the gain ramps. Draft re-blocks into 16-frame chunks (16 samples
-// of latency, reported to PDC). The Soundgoodizer stage (SG > 0) is LYNX's Soundgoodizer approximation
-// (compressor + the presets' −0.2 dB master limiter, whose look-ahead adds to the latency).
+// of latency, reported to PDC). The Soundgoodizer stage (SG > 0) is FL's Maximus engine (core/HarmlessFx) loaded with
+// the installation's Vocodex/Data/SG.dat, band mix = SG (REA_rodada40 §4); the internal carrier is LYNX's Sytrus engine
+// playing the installation's Synthesizer preset. Both files are read at import from the user's FL installation and
+// travel with the slot (InstallData); without them the stage falls back to the Soundgoodizer approximation and the
+// internal carrier is unavailable.
 
 #include <array>
 #include <cstdint>
@@ -16,6 +19,7 @@
 #include <vector>
 
 #include "core/Effects.h"
+#include "core/HarmlessFx.h"
 
 namespace lynx::vocodex
 {
@@ -85,9 +89,22 @@ public:
     virtual void render (float* out, int n) noexcept = 0;
 };
 
-// The internal carrier synth (a Sytrus with the preset `<tone>.fst` and the state's notes held at volume 0.5,
-// REA_rodada35 §8). LYNX has no instrument for it yet: returns nullptr, and the effect then passes the modulator.
+// The internal carrier synth (a Sytrus with the preset `<tone>.fst` and the state's notes held, REA_rodada35 §8 and
+// REA_rodada40 §5): without the preset's Sytrus state it cannot be built (nullptr; the effect then passes the
+// modulator).
 std::unique_ptr<Carrier> makeInternalCarrier (const State& state);
+std::unique_ptr<Carrier> makeInternalCarrier (const State& state, const std::vector<std::uint8_t>& sytrusState);
+
+// Data files of the user's FL installation that Vocodex loads at run time, appended by LYNX after FL's state in
+// EffectSlot::state (our own trailer: records, then their byte count and the tag "LXVXDATA")
+struct InstallData
+{
+    std::vector<std::uint8_t> sgDat;        // Plugins/Fruity/Effects/Vocodex/Data/SG.dat (a Maximus state)
+    std::vector<std::uint8_t> carrierState; // the Sytrus state of Synthesizer/Data/Presets/<tone>.fst
+};
+std::vector<std::uint8_t> appendInstallData (std::vector<std::uint8_t> flState, const InstallData& data);
+// FL's state alone and the appended data (empty when there is none)
+std::pair<std::vector<std::uint8_t>, InstallData> splitInstallData (const std::vector<std::uint8_t>& slotState);
 
 std::unique_ptr<Effect> make (const std::vector<std::uint8_t>& state);
 } // namespace lynx::vocodex

+ 167 - 8
src/engine/AudioEngine.cpp

@@ -10,6 +10,7 @@
 #include "core/SoftClip.h"
 #include "engine/ChannelRackProcessor.h"
 #include "engine/Metronome.h"
+#include "core/NoteTools.h"
 #include "engine/PreviewPlayer.h"
 #include "flp/Flp.h"
 
@@ -237,7 +238,78 @@ float AudioEngine::renderOffline (const RenderOptions& options)
 }
 
 void AudioEngine::play() noexcept { transport.playing.store (true); }
-void AudioEngine::stop() noexcept { transport.playing.store (false); }
+
+void AudioEngine::stop() noexcept
+{
+    waitingForInput.store (false);
+    transport.countIn.store (0.0);
+    transport.playing.store (false);
+}
+
+void AudioEngine::setRecordOptions (const RecordOptions& options)
+{
+    recordOptions = options;
+    recordOptions.countInBars = juce::jlimit (0, 4, options.countInBars);
+    sendChangeMessage();
+}
+
+void AudioEngine::startPlayback()
+{
+    if (! transport.recording.load())
+    {
+        play();
+        return;
+    }
+
+    if (recordOptions.waitForInput)
+    {
+        waitingForInput.store (true);
+        sendChangeMessage();
+        return;
+    }
+
+    if (recordOptions.countInBars > 0)
+    {
+        const auto at = (std::int64_t) transport.positionTicks.load();
+        transport.countIn.store ((double) countInLength (song, recordOptions.countInBars, at));
+        sendChangeMessage();
+        return;
+    }
+
+    play();
+}
+
+void AudioEngine::startOnInput() noexcept
+{
+    if (waitingForInput.exchange (false))
+        transport.playing.store (true);
+}
+
+void AudioEngine::setInsertArmed (int track, bool armed)
+{
+    const auto it = std::find (armedInserts.begin(), armedInserts.end(), track);
+    const auto wasArmed = it != armedInserts.end();
+
+    if (armed == wasArmed || track <= 0)
+        return;
+
+    if (armed)
+        armedInserts.push_back (track);
+    else
+        armedInserts.erase (it);
+
+    if (armed && ! audioArmed)
+        setAudioRecordingArmed (true);
+    else if (! armed && armedInserts.empty() && audioArmed)
+        setAudioRecordingArmed (false);
+
+    sendChangeMessage();
+}
+
+bool AudioEngine::isInsertArmed (int track) const noexcept
+{
+    return std::find (armedInserts.begin(), armedInserts.end(), track) != armedInserts.end();
+}
 void AudioEngine::rewind() noexcept { transport.rewindRequested.store (true); }
 void AudioEngine::seek (double ticks) noexcept { transport.seekRequest.store (juce::jmax (0.0, ticks)); }
 
@@ -259,6 +331,18 @@ void AudioEngine::previewFile (const juce::File& file)
         preview->play (file.existsAsFile() ? samples.load (file.getFullPathName()) : nullptr);
 }
 
+void AudioEngine::setInputScale (int scale, int root) noexcept
+{
+    inputScaleRoot.store (root);
+    inputScale.store (scale);
+}
+
+int AudioEngine::snapInputKey (int key) const noexcept
+{
+    const auto scale = inputScale.load();
+    return scale > 0 ? notetools::snapToScale (key, inputScaleRoot.load(), scale) : key;
+}
+
 void AudioEngine::previewSample (std::shared_ptr<const SampleData> sample)
 {
     if (preview != nullptr)
@@ -267,6 +351,13 @@ void AudioEngine::previewSample (std::shared_ptr<const SampleData> sample)
 
 void AudioEngine::sendLiveNote (int channel, int key, float velocity, bool on, bool record)
 {
+    if (record) // played notes (the PC keyboard) follow the scale snap; previews don't
+    {
+        key = snapInputKey (key);
+        if (on)
+            startOnInput();
+    }
+
     NoteEvent e;
     e.type = on ? NoteEvent::Type::on : NoteEvent::Type::off;
     e.channel = channel;
@@ -399,13 +490,14 @@ void AudioEngine::finishAudioTake()
 
     const auto path = takeFile.getFullPathName().toStdString();
     const auto name = takeFile.getFileNameWithoutExtension().toStdString();
+    const auto armedTrack = armedInserts.empty() ? 0 : armedInserts.front(); // the take plays through the armed insert
 
     editSong ([=] (Song& s) {
         ChannelDef c;
         c.name = name;
         c.instrument = InstrumentKind::audioClip;
         c.samplePath = path;
-        c.mixerTrack = s.nextFreeInsert();
+        c.mixerTrack = armedTrack > 0 && armedTrack < (int) s.mixer.size() ? armedTrack : s.nextFreeInsert();
         s.channels.push_back (c);
 
         int track = 0;
@@ -436,9 +528,13 @@ void AudioEngine::handleIncomingMidiMessage (juce::MidiInput*, const juce::MidiM
         return;
 
     const auto on = m.isNoteOn();
+
+    if (on)
+        startOnInput();
+
     NoteEvent e;
     e.type = on ? NoteEvent::Type::on : NoteEvent::Type::off;
-    e.key = m.getNoteNumber();
+    e.key = snapInputKey (m.getNoteNumber());
     e.velocity = on ? m.getFloatVelocity() : 0.0f;
     const auto extra = juce::jlimit (0, maxLiveChannels, extraLiveCount.load());
 
@@ -525,6 +621,8 @@ void AudioEngine::updateRecording()
         const auto& pattern = song.patterns[(std::size_t) song.currentPattern];
         recorder.begin (pattern.effectiveLength (song.beatsPerBar));
         takeHasUndoStep = false;
+        takeClearedChannels.clear();
+        takeStartPosition = lastPlayingTick;
     };
 
     if (active)
@@ -556,11 +654,15 @@ void AudioEngine::updateRecording()
     if (notes.empty())
         return;
 
-    // the whole take is a single undo step
-    editSong ([&notes] (Song& s) {
-        auto& p = s.patterns[(std::size_t) s.currentPattern];
-        p.notes.insert (p.notes.end(), notes.begin(), notes.end());
-        p.sortNotes();
+    // the whole take is a single undo step: overdub or replace, quantised to the record grid; in song mode a
+    // clip of the pattern is placed where recording started if none plays there
+    const auto options = recordOptions;
+    const auto placeClipAt = (std::int64_t) takeStartPosition;
+    editSong ([&] (Song& s) {
+        commitTake (s.patterns[(std::size_t) s.currentPattern], notes, options.mode, options.quantise, takeClearedChannels);
+
+        if (options.placeSongClip && s.mode == PlayMode::song && ! takeHasUndoStep)
+            placePatternClipAt (s, s.currentPattern, placeClipAt);
     }, ! takeHasUndoStep);
     takeHasUndoStep = true;
 }
@@ -637,6 +739,53 @@ void AudioEngine::redo()
     publishSong();
 }
 
+namespace
+{
+const Song& historyState (const std::deque<Song>& undo, const Song& current, const std::deque<Song>& redo, int index)
+{
+    if (index < (int) undo.size())
+        return undo[(std::size_t) index];
+    if (index == (int) undo.size())
+        return current;
+    return redo[redo.size() - 1 - (std::size_t) (index - (int) undo.size() - 1)];
+}
+} // namespace
+
+ChangeLabel AudioEngine::getHistoryLabel (int index) const
+{
+    if (index <= 0 || index >= getHistorySize())
+        return { TR_NOOP ("Start"), {} };
+
+    return describeChange (historyState (undoStack, song, redoStack, index - 1), historyState (undoStack, song, redoStack, index));
+}
+
+void AudioEngine::jumpToHistory (int index)
+{
+    index = juce::jlimit (0, getHistorySize() - 1, index);
+
+    if (index == getHistoryPosition())
+        return;
+
+    // move through the stacks, then publish once
+    while (getHistoryPosition() > index && ! undoStack.empty())
+    {
+        redoStack.push_back (std::move (song));
+        song = std::move (undoStack.back());
+        undoStack.pop_back();
+    }
+
+    while (getHistoryPosition() < index && ! redoStack.empty())
+    {
+        undoStack.push_back (std::move (song));
+        song = std::move (redoStack.back());
+        redoStack.pop_back();
+    }
+
+    modified = true;
+    lastUndoPress = {};
+    publishSong();
+}
+
 void AudioEngine::setSelectedChannel (int channel)
 {
     channel = juce::jlimit (0, juce::jmax (0, (int) song.channels.size() - 1), channel);
@@ -938,6 +1087,16 @@ void AudioEngine::audioDeviceIOCallbackWithContext (const float* const* inputCha
     numInputChannels = juce::jmin (numInputChannels, (int) inputs.size());
     numOutputChannels = juce::jmin (numOutputChannels, (int) outputs.size());
 
+    // count-in: the metronome counts the pre-roll down, then playback starts
+    if (const auto countIn = transport.countIn.load (std::memory_order_relaxed); countIn > 0.0 && ! transport.playing.load (std::memory_order_relaxed))
+    {
+        const auto left = countIn - numSamples * transport.ticksPerSample();
+        transport.countIn.store (juce::jmax (0.0, left), std::memory_order_relaxed);
+
+        if (left <= 0.0)
+            transport.playing.store (true, std::memory_order_relaxed);
+    }
+
     for (int done = 0; done < numSamples;)
     {
         auto n = numSamples - done;

+ 44 - 1
src/engine/AudioEngine.h

@@ -10,6 +10,7 @@
 #include "core/WorkerPool.h"
 #include "core/RackRenderer.h"
 #include "core/FlpImport.h"
+#include "core/History.h"
 #include "core/SnapshotExchange.h"
 #include "core/Song.h"
 #include "engine/PluginHost.h"
@@ -56,7 +57,30 @@ public:
     void capturePluginStates();
 
     void play() noexcept;
-    void stop() noexcept;
+    void stop() noexcept; // also cancels a count-in or a wait for the first note
+
+    // Recording options (docs/WORKFLOW_FL.md P2: recording set). UI thread.
+    struct RecordOptions
+    {
+        int countInBars = 0;            // 0 = off
+        bool waitForInput = false;      // playback starts at the first played note
+        RecordMode mode = RecordMode::overdub;
+        std::int64_t quantise = 0;      // record quantise in ticks (<= 1: as played); follows the global grid
+        bool placeSongClip = true;      // song mode: a take puts a clip of the pattern where recording started
+    };
+    const RecordOptions& getRecordOptions() const noexcept { return recordOptions; }
+    void setRecordOptions (const RecordOptions& options);
+
+    // Play pressed: with recording on, honours wait-for-input and the count-in; otherwise play().
+    void startPlayback();
+    bool isWaitingForInput() const noexcept { return waitingForInput.load(); }
+    bool isCountingIn() const noexcept { return transport.countIn.load() > 0.0; }
+
+    // Per-insert record arm: an armed insert receives the audio takes (arming one turns audio recording on;
+    // disarming the last one turns it off). Not saved with the project.
+    void setInsertArmed (int track, bool armed);
+    bool isInsertArmed (int track) const noexcept;
+    const std::vector<int>& getArmedInserts() const noexcept { return armedInserts; }
     void rewind() noexcept;
     void seek (double ticks) noexcept;
 
@@ -69,6 +93,11 @@ public:
     // `record` = goes into the recording if recording is on (Piano Roll preview doesn't).
     void sendLiveNote (int channel, int key, float velocity, bool on, bool record = false);
 
+    // Scale snap for played notes (MIDI input and the PC keyboard): scale index into notetools::scales()
+    // (0 = off) and its root (0..11). Any thread.
+    void setInputScale (int scale, int root) noexcept;
+    int snapInputKey (int key) const noexcept;
+
     // All notes off on every channel (double-click on Stop). UI thread.
     void panic();
 
@@ -108,6 +137,13 @@ public:
     void undo();
     void redo();
 
+    // Undo history as a list of states, oldest first: the undo steps, the current state, then the redo
+    // steps. Each entry is named after what changed from the previous one (core/History.h).
+    int getHistorySize() const noexcept { return (int) (undoStack.size() + 1 + redoStack.size()); }
+    int getHistoryPosition() const noexcept { return (int) undoStack.size(); }
+    ChangeLabel getHistoryLabel (int index) const; // index 0 = the oldest state kept
+    void jumpToHistory (int index);
+
     // Channel selected in the Channel Rack (target of the Piano Roll and keyboard). UI thread.
     int getSelectedChannel() const noexcept { return selectedChannel; }
     void setSelectedChannel (int channel); // selects only this channel
@@ -204,7 +240,14 @@ private:
     std::vector<RecordedEvent> uiRecorded;           // PC keyboard -> recording
     NoteRecorder recorder;
     bool takeHasUndoStep = false;
+    RecordOptions recordOptions;
+    std::vector<int> takeClearedChannels; // replace mode: channels already cleared in this take
+    double takeStartPosition = 0.0;
+    std::atomic<bool> waitingForInput { false };
+    void startOnInput() noexcept; // MIDI or UI thread: the first note while waiting starts playback
+    std::vector<int> armedInserts;
     double lastPlayingTick = 0.0;
+    std::atomic<int> inputScale { 0 }, inputScaleRoot { 0 };
     std::atomic<int> liveChannel { 0 };              // selected channel, read by the MIDI thread
     static constexpr int maxLiveChannels = 16;       // other selected channels that also get MIDI input
     std::array<std::atomic<int>, maxLiveChannels> extraLiveChannels {};

+ 9 - 5
src/engine/Metronome.cpp

@@ -27,7 +27,10 @@ void Metronome::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer
 {
     buffer.clear();
 
-    if (! transport.playing.load (std::memory_order_relaxed) || ! transport.metronome.load (std::memory_order_relaxed))
+    const auto countIn = transport.countIn.load (std::memory_order_relaxed);
+    const auto counting = countIn > 0.0 && ! transport.playing.load (std::memory_order_relaxed);
+
+    if (! counting && (! transport.playing.load (std::memory_order_relaxed) || ! transport.metronome.load (std::memory_order_relaxed)))
     {
         lastBeat = -1;
         clickSamplesLeft = 0;
@@ -62,8 +65,8 @@ void Metronome::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer
     }
 
     auto isDownbeat = [&] (std::int64_t beat) {
-        if (! songMode || signatureCount == 0)
-            return beat % beatsPerBar == 0;
+        if (beat < 0 || ! songMode || signatureCount == 0)
+            return ((beat % beatsPerBar) + beatsPerBar) % beatsPerBar == 0;
 
         const auto tick = beat * ppq;
         auto index = 0;
@@ -74,13 +77,14 @@ void Metronome::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer
         const auto [start, length] = signatures[(std::size_t) index];
         return (tick - start) % juce::jmax<std::int64_t> (1, length) == 0;
     };
-    const auto startTick = transport.positionTicks.load (std::memory_order_relaxed);
+    // during the count-in the clicks run on a position before the start (whole bars, so the beats line up)
+    const auto startTick = transport.positionTicks.load (std::memory_order_relaxed) - (counting ? countIn : 0.0);
     const auto tps = transport.ticksPerSample();
     const auto clickLength = (int) (clickLengthSeconds * currentSampleRate);
 
     for (int i = 0; i < buffer.getNumSamples(); ++i)
     {
-        const auto beat = (std::int64_t) ((startTick + i * tps) / ppq);
+        const auto beat = (std::int64_t) std::floor ((startTick + i * tps) / ppq);
 
         if (beat != lastBeat)
         {

+ 4 - 2
src/engine/ProjectFile.cpp

@@ -86,6 +86,7 @@ const char* instrumentId (InstrumentKind k)
         case InstrumentKind::harmor: return "harmor";
         case InstrumentKind::gms: return "gms";
         case InstrumentKind::morphine: return "morphine";
+        case InstrumentKind::ogun: return "ogun";
     }
     return "synth";
 }
@@ -96,7 +97,7 @@ InstrumentKind instrumentFromId (const juce::String& id)
                     InstrumentKind::synth, InstrumentKind::sampler, InstrumentKind::audioClip,
                     InstrumentKind::plugin, InstrumentKind::controller, InstrumentKind::sakura, InstrumentKind::drumpad, InstrumentKind::boobass,
                     InstrumentKind::drumsynth, InstrumentKind::harmless, InstrumentKind::sytrus, InstrumentKind::harmor,
-                    InstrumentKind::gms, InstrumentKind::morphine })
+                    InstrumentKind::gms, InstrumentKind::morphine, InstrumentKind::ogun })
         if (id == instrumentId (k))
             return k;
 
@@ -135,6 +136,7 @@ const char* effectId (EffectKind k)
         case EffectKind::squeeze: return "squeeze";
         case EffectKind::vintagePhaser: return "vintagePhaser";
         case EffectKind::vocodex: return "vocodex";
+        case EffectKind::maximus: return "maximus";
     }
     return "eq";
 }
@@ -276,7 +278,7 @@ std::optional<EffectSlot> effectFromVar (const juce::var& e)
 std::optional<EffectKind> effectFromId (const juce::String& id)
 {
     for (auto k : { EffectKind::eq, EffectKind::compressor, EffectKind::delay, EffectKind::reverb, EffectKind::plugin,
-                    EffectKind::limiter, EffectKind::filter, EffectKind::distortion, EffectKind::chorus, EffectKind::parametricEq, EffectKind::utility, EffectKind::volumeGate, EffectKind::peakController, EffectKind::pitchShift, EffectKind::freqShift, EffectKind::parallel, EffectKind::lofi, EffectKind::effector, EffectKind::crossover, EffectKind::rhythmGain, EffectKind::autoPan, EffectKind::vocoder, EffectKind::pitchCorrect, EffectKind::squeeze, EffectKind::vintagePhaser, EffectKind::vocodex })
+                    EffectKind::limiter, EffectKind::filter, EffectKind::distortion, EffectKind::chorus, EffectKind::parametricEq, EffectKind::utility, EffectKind::volumeGate, EffectKind::peakController, EffectKind::pitchShift, EffectKind::freqShift, EffectKind::parallel, EffectKind::lofi, EffectKind::effector, EffectKind::crossover, EffectKind::rhythmGain, EffectKind::autoPan, EffectKind::vocoder, EffectKind::pitchCorrect, EffectKind::squeeze, EffectKind::vintagePhaser, EffectKind::vocodex, EffectKind::maximus })
         if (id == effectId (k))
             return k;
 

+ 3 - 0
src/engine/Transport.h

@@ -28,6 +28,9 @@ struct Transport
     std::atomic<std::uint32_t> signatureVersion { 0 };
     std::atomic<double> sampleRate { 44100.0 };
     std::atomic<double> positionTicks { 0.0 };
+    // Count-in before recording: ticks of pre-roll left. While > 0 playback has not started (`playing` is
+    // false), the metronome clicks the count and the audio thread counts it down, then starts playing.
+    std::atomic<double> countIn { 0.0 };
     std::atomic<bool> rewindRequested { false };
     std::atomic<double> seekRequest { -1.0 }; // < 0 = none; the audio thread applies it on the next block
 

+ 36 - 0
src/platform/FileTypes.cpp

@@ -0,0 +1,36 @@
+#include "platform/FileTypes.h"
+
+#include <juce_core/juce_core.h>
+
+#if JUCE_WINDOWS
+ #include <windows.h>
+ #include <shlobj.h>
+#endif
+
+namespace lynx
+{
+void registerFileTypes()
+{
+   #if JUCE_WINDOWS
+    using juce::WindowsRegistry;
+    const auto exe = juce::File::getSpecialLocation (juce::File::currentExecutableFile).getFullPathName();
+    const juce::String classes = "HKEY_CURRENT_USER\\Software\\Classes\\";
+    const juce::String progId = "LYNX.Project";
+    const auto command = "\"" + exe + "\" \"%1\"";
+    const auto icon = "\"" + exe + "\",-2"; // resource id 2 in resources/LYNX.rc: the project-file icon
+
+    if (WindowsRegistry::getValue (classes + ".lynx\\") == progId
+        && WindowsRegistry::getValue (classes + progId + "\\shell\\open\\command\\") == command
+        && WindowsRegistry::getValue (classes + progId + "\\DefaultIcon\\") == icon)
+        return;
+
+    WindowsRegistry::setValue (classes + ".lynx\\", progId);
+    WindowsRegistry::setValue (classes + ".lynx\\Content Type", juce::String ("application/x-lynx-project"));
+    WindowsRegistry::setValue (classes + progId + "\\", juce::String ("LYNX Project"));
+    WindowsRegistry::setValue (classes + progId + "\\DefaultIcon\\", icon);
+    WindowsRegistry::setValue (classes + progId + "\\shell\\open\\command\\", command);
+    // Explorer caches icons per type: tell it the association changed
+    SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr);
+   #endif
+}
+} // namespace lynx

+ 9 - 0
src/platform/FileTypes.h

@@ -0,0 +1,9 @@
+#pragma once
+
+namespace lynx
+{
+// Registers .lynx project files with Windows for the current user (no admin rights): double-click opens them in this
+// LYNX.exe and Explorer shows LYNX's project icon. Rewrites the entries only when they point somewhere else, so a
+// moved or updated exe takes the association over. Does nothing on other platforms.
+void registerFileTypes();
+} // namespace lynx

+ 132 - 4
src/ui/AutomationUi.cpp

@@ -140,7 +140,7 @@ public:
 
         g.setColour (colour::textSecondary);
         g.setFont (font (type::caption));
-        g.drawText (tr ("Click: new point · drag: move · right-click: delete · Alt+drag: curve · Ctrl+wheel: zoom"),
+        g.drawText (tr ("Click: new point · drag: move (then Shift: time locked, Ctrl: value locked) · right-click: point menu · Alt+drag: curve · Ctrl+wheel: zoom"),
                     area.getX(), getHeight() - 18, area.getWidth(), 16, juce::Justification::centredLeft);
 
         if (hoverPoint >= 0 && hoverPoint < (int) points.size())
@@ -175,10 +175,26 @@ public:
 
         const auto hit = pointAt (e.position);
 
+        downMods = e.mods;
+
         if (e.mods.isPopupMenu())
         {
-            if (hit >= 0 && a->points.size() > 1)
-                edit ([hit] (Automation& x) { x.points.erase (x.points.begin() + hit); });
+            if (e.mods.isShiftDown() && hit < 0) // a point on the curve, keeping its level
+            {
+                AutomationPoint p;
+                p.tick = snap (xToTick (e.x), true);
+                p.value = a->valueAt ((double) p.tick);
+                edit ([p] (Automation& x) {
+                    x.points.push_back (p);
+                    std::stable_sort (x.points.begin(), x.points.end(), [] (auto& l, auto& r) { return l.tick < r.tick; });
+                });
+                return;
+            }
+
+            if (hit >= 0)
+                showPointMenu (hit);
+            else
+                showCurveMenu();
             return;
         }
 
@@ -239,7 +255,13 @@ public:
         const auto lo = dragPoint > 0 ? points[(std::size_t) dragPoint - 1].tick : 0;
         const auto hi = dragPoint + 1 < (int) points.size() ? points[(std::size_t) dragPoint + 1].tick : std::numeric_limits<std::int64_t>::max();
         tick = juce::jlimit (lo, hi, tick);
-        const auto value = yToValue (e.y);
+        auto value = yToValue (e.y);
+
+        // locks: Shift pressed after the click keeps the time, Ctrl keeps the value
+        if (e.mods.isShiftDown() && ! downMods.isShiftDown())
+            tick = points[(std::size_t) dragPoint].tick;
+        if (e.mods.isCtrlDown() && ! downMods.isCtrlDown())
+            value = points[(std::size_t) dragPoint].value;
 
         edit ([i = dragPoint, tick, value] (Automation& x) {
             x.points[(std::size_t) i].tick = tick;
@@ -268,6 +290,112 @@ public:
     }
 
 private:
+    juce::ModifierKeys downMods;
+    static inline float copiedValue = -1.0f;
+
+    juce::String valueText (float v) const
+    {
+        const auto* a = current();
+        return a != nullptr && a->target.kind == AutomationTargetKind::tempo ? juce::String (tempoFromValue (v), 2) + " BPM"
+                                                                             : juce::String (v * 100.0f, 1) + "%";
+    }
+
+    void showPointMenu (int point)
+    {
+        const auto* a = current();
+        const auto value = a->points[(std::size_t) point].value;
+        juce::PopupMenu menu;
+        menu.addSectionHeader (valueText (value));
+        menu.addItem (tr ("Type value..."), [this, point] { typeValue (point); });
+        menu.addItem (tr ("Copy value"), [value] { copiedValue = value; });
+        menu.addItem (tr ("Paste value"), copiedValue >= 0.0f, false, [this, point] {
+            edit ([point, v = copiedValue] (Automation& x) {
+                if (point < (int) x.points.size())
+                    x.points[(std::size_t) point].value = v;
+            });
+        });
+        menu.addItem (tr ("Straight segment (reset the curve)"), [this, point] {
+            edit ([point] (Automation& x) {
+                if (point < (int) x.points.size())
+                    x.points[(std::size_t) point].tension = 0.0f;
+            });
+        });
+        menu.addSeparator();
+        menu.addItem (tr ("Delete point"), a->points.size() > 1, false, [this, point] {
+            edit ([point] (Automation& x) {
+                if (point < (int) x.points.size() && x.points.size() > 1)
+                    x.points.erase (x.points.begin() + point);
+            });
+        });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void typeValue (int point)
+    {
+        const auto* a = current();
+        const auto tempo = a->target.kind == AutomationTargetKind::tempo;
+        const auto value = a->points[(std::size_t) point].value;
+        auto* window = new juce::AlertWindow (tr ("Point value"), tempo ? tr ("BPM") : tr ("Percent (0 to 100)"), juce::MessageBoxIconType::NoIcon);
+        window->addTextEditor ("value", tempo ? juce::String (tempoFromValue (value), 2) : juce::String (value * 100.0f, 1));
+        window->addButton (tr ("OK"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+        window->addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
+        window->enterModalState (true, juce::ModalCallbackFunction::create ([this, point, tempo, window] (int result) {
+                                     if (result != 1)
+                                         return;
+                                     const auto typed = window->getTextEditorContents ("value").retainCharacters ("0123456789.,-").replaceCharacter (',', '.').getDoubleValue();
+                                     const auto v = juce::jlimit (0.0f, 1.0f, tempo ? valueFromTempo (typed) : (float) typed / 100.0f);
+                                     edit ([point, v] (Automation& x) {
+                                         if (point < (int) x.points.size())
+                                             x.points[(std::size_t) point].value = v;
+                                     });
+                                 }),
+                                 true);
+    }
+
+    void showCurveMenu()
+    {
+        juce::PopupMenu menu;
+        menu.addItem (tr ("Scale the values into a range..."), [this] { rerange(); });
+        menu.addItem (tr ("Flip the values upside down"), [this] {
+            edit ([] (Automation& x) {
+                for (auto& p : x.points)
+                    p.value = 1.0f - p.value;
+            });
+        });
+        menu.addItem (tr ("All segments straight"), [this] {
+            edit ([] (Automation& x) {
+                for (auto& p : x.points)
+                    p.tension = 0.0f;
+            });
+        });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void rerange()
+    {
+        auto* window = new juce::AlertWindow (tr ("Scale the values into a range"), tr ("The lowest point goes to the minimum and the highest to the maximum (percent)."),
+                                              juce::MessageBoxIconType::NoIcon);
+        window->addTextEditor ("min", "0", tr ("Minimum"));
+        window->addTextEditor ("max", "100", tr ("Maximum"));
+        window->addButton (tr ("OK"), 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 lo = juce::jlimit (0.0f, 1.0f, window->getTextEditorContents ("min").getFloatValue() / 100.0f);
+                                     const auto hi = juce::jlimit (0.0f, 1.0f, window->getTextEditorContents ("max").getFloatValue() / 100.0f);
+                                     edit ([lo, hi] (Automation& x) {
+                                         if (x.points.empty())
+                                             return;
+                                         auto [mn, mx] = std::minmax_element (x.points.begin(), x.points.end(), [] (auto& a, auto& b) { return a.value < b.value; });
+                                         const auto from = mn->value, span = mx->value - mn->value;
+                                         for (auto& p : x.points)
+                                             p.value = span > 1e-6f ? lo + (p.value - from) / span * (hi - lo) : lo;
+                                     });
+                                 }),
+                                 true);
+    }
+
     const Automation* current() const
     {
         const auto& song = engine.getSong();

+ 395 - 16
src/ui/BrowserComponent.cpp

@@ -1,6 +1,8 @@
 #include "ui/BrowserComponent.h"
 
 #include "core/FlpImport.h"
+#include "core/SearchQuery.h"
+#include "engine/PluginHost.h"
 #include "engine/Text.h"
 #include "ui/I18n.h"
 #include "ui/Theme.h"
@@ -13,11 +15,208 @@ bool isAudio (const juce::File& f)
 {
     return f.hasFileExtension ("wav;flac;ogg;mp3;aif;aiff;wv");
 }
+
+bool isListed (const juce::File& f)
+{
+    return f.hasFileExtension ("wav;flac;ogg;mp3;aif;aiff;mid;midi;lynx;flp;fst");
+}
+
+constexpr int maxResults = 500;
+
+juce::Array<juce::File> searchFiles (const juce::File& root, const juce::String& query, bool& truncated, const std::function<bool()>& shouldStop)
+{
+    const auto parsed = search::parse (query.toStdString());
+    juce::Array<juce::File> found;
+    truncated = false;
+
+    for (const auto& entry : juce::RangedDirectoryIterator (root, true, "*", juce::File::findFiles))
+    {
+        if (shouldStop())
+            break;
+
+        const auto file = entry.getFile();
+
+        if (! isListed (file) || ! search::matches (parsed, file.getFileName().toStdString()))
+            continue;
+
+        found.add (file);
+
+        if (found.size() >= maxResults)
+        {
+            truncated = true;
+            break;
+        }
+    }
+
+    return found;
+}
 } // namespace
 
+// --- search: a background walk of the current folder ------------------------------------------------
+
+class BrowserComponent::SearchJob final : public juce::Thread
+{
+public:
+    SearchJob (juce::File r, juce::String q, std::function<void (juce::Array<juce::File>, bool)> d)
+        : juce::Thread ("LYNX browser search"), root (std::move (r)), query (std::move (q)), done (std::move (d))
+    {
+    }
+
+    ~SearchJob() override { stopThread (3000); }
+
+    void run() override
+    {
+        bool truncated = false;
+        const auto found = searchFiles (root, query, truncated, [this] { return threadShouldExit(); });
+
+        if (threadShouldExit())
+            return;
+
+        juce::MessageManager::callAsync ([done = done, found, truncated] { done (found, truncated); });
+    }
+
+private:
+    juce::File root;
+    juce::String query;
+    std::function<void (juce::Array<juce::File>, bool)> done;
+};
+
+class BrowserComponent::Results final : public juce::ListBox,
+                                        private juce::ListBoxModel
+{
+public:
+    explicit Results (BrowserComponent& b) : browser (b)
+    {
+        setModel (this);
+        setRowHeight (22);
+        setColour (juce::ListBox::backgroundColourId, theme::colour::bg2);
+        setOutlineThickness (0);
+        setWantsKeyboardFocus (false);
+        setMouseClickGrabsKeyboardFocus (false);
+    }
+
+    juce::Array<juce::File> files;
+    juce::File root;
+    juce::String status;
+
+    juce::File selected() const
+    {
+        const auto row = getSelectedRow();
+        return juce::isPositiveAndBelow (row, files.size()) ? files[row] : juce::File();
+    }
+
+    int getNumRows() override { return files.size(); }
+
+    void paintListBoxItem (int row, juce::Graphics& g, int width, int height, bool isSelected) override
+    {
+        if (! juce::isPositiveAndBelow (row, files.size()))
+            return;
+
+        if (isSelected)
+        {
+            g.setColour (theme::colour::accentMuted);
+            g.fillRect (0, 0, width, height);
+        }
+
+        const auto& f = files[row];
+        g.setFont (theme::font (theme::type::body));
+        g.setColour (theme::colour::textPrimary);
+        g.drawText (f.getFileName(), 6, 0, width - 12, height, juce::Justification::centredLeft, true);
+        g.setFont (theme::font (theme::type::caption));
+        g.setColour (theme::colour::textDisabled);
+        g.drawText (f.getParentDirectory().getRelativePathFrom (root), 6, 0, width - 12, height, juce::Justification::centredRight, true);
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        juce::ListBox::paint (g);
+
+        if (files.isEmpty())
+        {
+            g.setColour (theme::colour::textDisabled);
+            g.setFont (theme::font (theme::type::small));
+            g.drawFittedText (status, getLocalBounds().reduced (10), juce::Justification::centredTop, 3);
+        }
+    }
+
+    void selectedRowsChanged (int row) override
+    {
+        if (juce::isPositiveAndBelow (row, files.size()) && isAudio (files[row]))
+            browser.engine.previewFile (files[row]);
+    }
+
+    void listBoxItemDoubleClicked (int row, const juce::MouseEvent&) override
+    {
+        if (juce::isPositiveAndBelow (row, files.size()))
+            browser.openFile (files[row]);
+    }
+
+    juce::var getDragSourceDescription (const juce::SparseSet<int>& rows) override
+    {
+        if (rows.isEmpty() || ! juce::isPositiveAndBelow (rows[0], files.size()))
+            return {};
+        return juce::String (dragDescription) + "|" + files[rows[0]].getFullPathName();
+    }
+
+private:
+    BrowserComponent& browser;
+};
+
 BrowserComponent::BrowserComponent (AudioEngine& e)
     : engine (e)
 {
+    rebuildRoots();
+
+    rootBox.onChange = [this] {
+        const auto id = rootBox.getSelectedId();
+        if (id == addFolderId)
+        {
+            rootBox.setSelectedId (currentRoot + 1, juce::dontSendNotification);
+            addUserFolder();
+            return;
+        }
+        setRoot (id - 1);
+        if (searchBox.getText().isNotEmpty())
+            runSearch();
+    };
+    rootBox.setWantsKeyboardFocus (false);
+    rootBox.setMouseClickGrabsKeyboardFocus (false);
+    addAndMakeVisible (rootBox);
+
+    searchBox.setTextToShowWhenEmpty (tr ("Search (Ctrl+F): kick -loop, snare OR clap, hat*.wav"), theme::colour::textDisabled);
+    searchBox.addListener (this);
+    searchBox.setEscapeAndReturnKeysConsumed (true);
+    addAndMakeVisible (searchBox);
+
+    results = std::make_unique<Results> (*this);
+    addChildComponent (*results);
+
+    tree.setItemHeight (20);
+    tree.setDragAndDropDescription (dragDescription);
+    tree.addListener (this);
+    tree.setColour (juce::TreeView::backgroundColourId, theme::colour::bg2);
+    tree.setWantsKeyboardFocus (false);
+    addAndMakeVisible (tree);
+
+    thread.startThread (juce::Thread::Priority::low);
+
+    if (! roots.isEmpty())
+    {
+        rootBox.setSelectedId (1, juce::dontSendNotification);
+        setRoot (0);
+    }
+}
+
+juce::File BrowserComponent::userFoldersFile()
+{
+    return PluginHost::settingsFolder().getChildFile ("browser-folders.txt");
+}
+
+void BrowserComponent::rebuildRoots()
+{
+    roots.clear();
+    rootBox.clear (juce::dontSendNotification);
+
     // FL folders (if installed) and user folders
     const auto programs = juce::File::getSpecialLocation (juce::File::globalApplicationsDirectory);
     juce::File fl;
@@ -45,29 +244,40 @@ BrowserComponent::BrowserComponent (AudioEngine& e)
     add (tr ("Desktop"), juce::File::getSpecialLocation (juce::File::userDesktopDirectory));
     add (tr ("Downloads"), juce::File::getSpecialLocation (juce::File::userHomeDirectory).getChildFile ("Downloads"));
 
-    rootBox.onChange = [this] { setRoot (rootBox.getSelectedId() - 1); };
-    rootBox.setWantsKeyboardFocus (false);
-    rootBox.setMouseClickGrabsKeyboardFocus (false);
-    addAndMakeVisible (rootBox);
+    for (const auto& line : juce::StringArray::fromLines (userFoldersFile().loadFileAsString()))
+        if (line.trim().isNotEmpty())
+            add (juce::File (line.trim()).getFileName(), juce::File (line.trim()));
 
-    tree.setItemHeight (20);
-    tree.setDragAndDropDescription (dragDescription);
-    tree.addListener (this);
-    tree.setColour (juce::TreeView::backgroundColourId, theme::colour::bg2);
-    tree.setWantsKeyboardFocus (false);
-    addAndMakeVisible (tree);
+    rootBox.addSeparator();
+    rootBox.addItem (tr ("Add folder..."), addFolderId);
+}
 
-    thread.startThread (juce::Thread::Priority::low);
+void BrowserComponent::addUserFolder()
+{
+    chooser = std::make_unique<juce::FileChooser> (tr ("Add a folder to the Browser"), juce::File::getSpecialLocation (juce::File::userMusicDirectory));
+    chooser->launchAsync (juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectDirectories, [this] (const juce::FileChooser& fc) {
+        const auto folder = fc.getResult();
+        if (! folder.isDirectory())
+            return;
 
-    if (! roots.isEmpty())
-    {
-        rootBox.setSelectedId (1, juce::dontSendNotification);
-        setRoot (0);
-    }
+        auto lines = juce::StringArray::fromLines (userFoldersFile().loadFileAsString());
+        lines.removeEmptyStrings();
+        lines.addIfNotAlreadyThere (folder.getFullPathName());
+        userFoldersFile().replaceWithText (lines.joinIntoString ("\n"));
+        rebuildRoots();
+
+        for (int i = 0; i < roots.size(); ++i)
+            if (roots[i] == folder)
+            {
+                rootBox.setSelectedId (i + 1, juce::dontSendNotification);
+                setRoot (i);
+            }
+    });
 }
 
 BrowserComponent::~BrowserComponent()
 {
+    job.reset();
     tree.removeListener (this);
     engine.previewFile ({});
     thread.stopThread (2000);
@@ -76,7 +286,10 @@ BrowserComponent::~BrowserComponent()
 void BrowserComponent::setRoot (int index)
 {
     if (juce::isPositiveAndBelow (index, roots.size()))
+    {
+        currentRoot = index;
         list.setDirectory (roots[index], true, true);
+    }
 }
 
 void BrowserComponent::waitForListing (int timeoutMs)
@@ -98,7 +311,10 @@ void BrowserComponent::resized()
     auto area = getLocalBounds().reduced (4);
     rootBox.setBounds (area.removeFromTop (26));
     area.removeFromTop (4);
+    searchBox.setBounds (area.removeFromTop (24));
+    area.removeFromTop (4);
     tree.setBounds (area);
+    results->setBounds (area);
 }
 
 void BrowserComponent::paint (juce::Graphics& g)
@@ -115,6 +331,169 @@ void BrowserComponent::selectionChanged()
 }
 
 void BrowserComponent::fileDoubleClicked (const juce::File& file)
+{
+    openFile (file);
+}
+
+// --- search ------------------------------------------------------------------------------------------
+
+void BrowserComponent::focusSearch()
+{
+    searchBox.grabKeyboardFocus();
+    searchBox.selectAll();
+}
+
+void BrowserComponent::setSearchForSnapshot (const juce::String& text)
+{
+    // synchronous: the snapshot is drawn before any message is dispatched
+    searchBox.setText (text, juce::dontSendNotification);
+    job.reset();
+    results->setVisible (text.isNotEmpty());
+    tree.setVisible (text.isEmpty());
+
+    if (text.isEmpty() || ! juce::isPositiveAndBelow (currentRoot, roots.size()))
+        return;
+
+    bool truncated = false;
+    results->root = roots[currentRoot];
+    results->files = searchFiles (roots[currentRoot], text, truncated, [] { return false; });
+    results->status = results->files.isEmpty() ? tr ("Nothing found for \"{0}\".", { text }) : juce::String();
+    results->updateContent();
+    results->selectRow (results->files.isEmpty() ? -1 : 0, true, true);
+}
+
+void BrowserComponent::textEditorTextChanged (juce::TextEditor&)
+{
+    startTimer (250); // search once typing pauses
+}
+
+void BrowserComponent::textEditorEscapeKeyPressed (juce::TextEditor&)
+{
+    searchBox.clear();
+    runSearch();
+}
+
+void BrowserComponent::textEditorReturnKeyPressed (juce::TextEditor&)
+{
+    stopTimer();
+    runSearch();
+}
+
+void BrowserComponent::timerCallback()
+{
+    stopTimer();
+    runSearch();
+}
+
+void BrowserComponent::runSearch()
+{
+    job.reset();
+    const auto query = searchBox.getText().trim();
+    results->setVisible (query.isNotEmpty());
+    tree.setVisible (query.isEmpty());
+
+    if (query.isEmpty() || ! juce::isPositiveAndBelow (currentRoot, roots.size()))
+        return;
+
+    results->files.clear();
+    results->root = roots[currentRoot];
+    results->status = tr ("Searching {0}...", { roots[currentRoot].getFullPathName() });
+    results->updateContent();
+    results->repaint();
+
+    job = std::make_unique<SearchJob> (roots[currentRoot], query, [safe = juce::Component::SafePointer<BrowserComponent> (this), query] (juce::Array<juce::File> found, bool truncated) {
+        if (safe == nullptr || safe->searchBox.getText().trim() != query)
+            return;
+
+        auto& r = *safe->results;
+        r.files = found;
+        r.status = found.isEmpty() ? tr ("Nothing found for \"{0}\".", { query }) : juce::String();
+        r.updateContent();
+        r.selectRow (-1);
+        r.repaint();
+
+        if (truncated)
+            r.status = tr ("Showing the first {0} results.", { juce::String (maxResults) });
+    });
+    job->startThread (juce::Thread::Priority::low);
+}
+
+// --- keys --------------------------------------------------------------------------------------------
+
+juce::File BrowserComponent::getSelectedFile() const
+{
+    return results->isVisible() ? results->selected() : tree.getSelectedFile();
+}
+
+void BrowserComponent::step (int delta, bool load)
+{
+    juce::File file;
+
+    if (results->isVisible())
+    {
+        const auto count = results->files.size();
+        if (count == 0)
+            return;
+        const auto row = juce::jlimit (0, count - 1, results->getSelectedRow() < 0 ? 0 : results->getSelectedRow() + delta);
+        results->selectRow (row);
+        results->scrollToEnsureRowIsOnscreen (row);
+        file = results->selected();
+    }
+    else
+    {
+        // walk the visible rows of the tree, skipping folders
+        auto* selected = tree.getSelectedItem (0);
+        auto row = selected != nullptr ? selected->getRowNumberInTree() : -1;
+
+        for (int guard = 0; guard < tree.getNumRowsInTree(); ++guard)
+        {
+            row += delta;
+            auto* item = tree.getItemOnRow (row);
+            if (item == nullptr)
+                return;
+            item->setSelected (true, true);
+            tree.scrollToKeepItemVisible (item);
+            file = tree.getSelectedFile();
+            if (! file.isDirectory())
+                break;
+        }
+    }
+
+    if (load && file.existsAsFile() && onLoadIntoChannel)
+        onLoadIntoChannel (file);
+}
+
+void BrowserComponent::loadSelected()
+{
+    const auto file = getSelectedFile();
+
+    if (! file.existsAsFile())
+        return;
+
+    if (! onLoadIntoChannel || ! onLoadIntoChannel (file))
+        openFile (file);
+}
+
+bool BrowserComponent::isBrowserDrag (const juce::DragAndDropTarget::SourceDetails& details)
+{
+    const auto text = details.description.toString();
+    return text == dragDescription || text.startsWith (juce::String (dragDescription) + "|");
+}
+
+juce::File BrowserComponent::draggedFile (const juce::DragAndDropTarget::SourceDetails& details)
+{
+    const auto text = details.description.toString();
+
+    if (text.startsWith (juce::String (dragDescription) + "|"))
+        return juce::File (text.fromFirstOccurrenceOf ("|", false, false));
+
+    if (auto* tree = dynamic_cast<juce::FileTreeComponent*> (details.sourceComponent.get()))
+        return tree->getSelectedFile();
+
+    return {};
+}
+
+void BrowserComponent::openFile (const juce::File& file)
 {
     if (isAudio (file))
     {

+ 38 - 1
src/ui/BrowserComponent.h

@@ -10,14 +10,34 @@ namespace lynx
 //  - click an audio file: preview; double-click: new sampler channel with it
 //  - drag onto the Channel Rack or the Playlist (like dragging from Explorer)
 //  - double-click a .lynx/.flp/.mid: opens it (onOpenProject)
+//  - search box (Ctrl+F): searches the current folder and below (core/SearchQuery syntax); Esc clears
+//  - keys while the Browser has focus: Up/Down step and preview, Shift+Up/Down step and load each file
+//    into the selected channel, Enter loads the selected file into the selected channel
+//  - the folder list has "Add folder..." for user folders (kept in the user settings)
 class BrowserComponent final : public juce::Component,
-                               private juce::FileBrowserListener
+                               private juce::FileBrowserListener,
+                               private juce::TextEditor::Listener,
+                               private juce::Timer
 {
 public:
     explicit BrowserComponent (AudioEngine& engine);
     ~BrowserComponent() override;
 
     std::function<void (const juce::File&)> onOpenProject;
+    // Enter / Shift+Up/Down: put this file into the selected channel; returns false if it can't take it.
+    std::function<bool (const juce::File&)> onLoadIntoChannel;
+
+    void focusSearch();
+    void addUserFolder(); // asks for a folder and adds it to the folder list
+    void setSearchForSnapshot (const juce::String& text);
+    // Up/Down (load = false) or Shift+Up/Down (load = true); Enter = loadSelected()
+    void step (int delta, bool load);
+    void loadSelected();
+    juce::File getSelectedFile() const;
+
+    // Drags from the Browser (tree or search results): is it one, and which file it carries.
+    static bool isBrowserDrag (const juce::DragAndDropTarget::SourceDetails& details);
+    static juce::File draggedFile (const juce::DragAndDropTarget::SourceDetails& details);
 
     void resized() override;
 
@@ -26,6 +46,7 @@ public:
     void paint (juce::Graphics& g) override;
 
     static constexpr const char* dragDescription = "lynx-arquivo";
+    static constexpr int addFolderId = 1000;
 
 private:
     void selectionChanged() override;
@@ -33,6 +54,22 @@ private:
     void fileDoubleClicked (const juce::File& file) override;
     void browserRootChanged (const juce::File&) override {}
     void setRoot (int index);
+    void textEditorTextChanged (juce::TextEditor&) override;
+    void textEditorEscapeKeyPressed (juce::TextEditor&) override;
+    void textEditorReturnKeyPressed (juce::TextEditor&) override;
+    void timerCallback() override;
+    void runSearch();
+    void rebuildRoots();
+    static juce::File userFoldersFile();
+    void openFile (const juce::File& file); // what a double-click does
+
+    class Results;
+    std::unique_ptr<Results> results;
+    class SearchJob;
+    std::unique_ptr<SearchJob> job;
+    juce::TextEditor searchBox;
+    std::unique_ptr<juce::FileChooser> chooser;
+    int currentRoot = 0;
 
     AudioEngine& engine;
     juce::ComboBox rootBox;

+ 471 - 12
src/ui/ChannelRackComponent.cpp

@@ -1,6 +1,8 @@
 #include "ui/ChannelRackComponent.h"
 
 #include "ui/AutomationUi.h"
+#include "core/NoteTools.h"
+#include "ui/ToolWindow.h"
 #include "core/Slicer.h"
 #include "ui/ChannelSettings.h"
 
@@ -39,6 +41,7 @@ juce::String instrumentName (InstrumentKind k)
         case InstrumentKind::harmor: return "Harmor";
         case InstrumentKind::gms: return "GMS";
         case InstrumentKind::morphine: return "Morphine";
+        case InstrumentKind::ogun: return "Ogun";
     }
     return "?";
 }
@@ -107,27 +110,65 @@ int ChannelRackComponent::numSteps() const
 void ChannelRackComponent::updateSize()
 {
     const auto rows = (int) engine.getSong().channels.size() + 1; // +1 = "add channel" row
-    setSize (gridLeft() + numSteps() * stepWidth + 8, rows * rowHeight + 8);
+    setSize (gridLeft() + numSteps() * stepWidth + 8, rows * rowHeight + 8 + (graphRow() >= 0 ? laneHeight : 0));
+}
+
+int ChannelRackComponent::graphRow() const
+{
+    const auto count = (int) engine.getSong().channels.size();
+    return graphLanes && count > 0 ? juce::jlimit (0, count - 1, engine.getSelectedChannel()) : -1;
+}
+
+int ChannelRackComponent::rowY (int row) const
+{
+    const auto lane = graphRow();
+    return 4 + row * rowHeight + (lane >= 0 && row > lane ? laneHeight : 0);
+}
+
+int ChannelRackComponent::rowAtY (int y) const
+{
+    if (y < 4)
+        return -1;
+
+    if (const auto lane = graphRow(); lane >= 0)
+    {
+        const auto laneTop = rowY (lane) + rowHeight;
+        if (y >= laneTop && y < laneTop + laneHeight)
+            return lane;
+        if (y >= laneTop + laneHeight)
+            y -= laneHeight;
+    }
+
+    return (y - 4) / rowHeight;
+}
+
+juce::Rectangle<int> ChannelRackComponent::laneBounds() const
+{
+    const auto lane = graphRow();
+    return lane < 0 ? juce::Rectangle<int>() : juce::Rectangle<int> (0, rowY (lane) + rowHeight, getWidth(), laneHeight);
 }
 
 juce::Rectangle<int> ChannelRackComponent::rowBounds (int row) const
 {
-    return { 0, 4 + row * rowHeight, getWidth(), rowHeight };
+    return { 0, rowY (row), getWidth(), rowHeight };
 }
 
 juce::Rectangle<int> ChannelRackComponent::stepBounds (int row, int step) const
 {
-    return { gridLeft() + step * stepWidth + 1, 4 + row * rowHeight + 4, stepWidth - 3, rowHeight - 8 };
+    return { gridLeft() + step * stepWidth + 1, rowY (row) + 4, stepWidth - 3, rowHeight - 8 };
 }
 
 ChannelRackComponent::Area ChannelRackComponent::areaAt (int x, int y, int& row) const
 {
     const auto channels = (int) engine.getSong().channels.size();
-    row = (y - 4) / rowHeight;
+    row = rowAtY (y);
 
-    if (y < 4 || row > channels)
+    if (row < 0 || row > channels)
         return Area::none;
 
+    if (laneBounds().contains (x, y))
+        return x < gridLeft() ? Area::laneLevels : Area::lane;
+
     if (row == channels)
         return x < gridLeft() ? Area::addRow : Area::none;
 
@@ -180,7 +221,7 @@ void ChannelRackComponent::paint (juce::Graphics& g)
 
     for (int row = 0; row < (int) song.channels.size(); ++row)
     {
-        const auto y = 4 + row * rowHeight;
+        const auto y = rowY (row);
 
         if (y > clip.getBottom() || y + rowHeight < clip.getY())
             continue;
@@ -261,7 +302,8 @@ void ChannelRackComponent::paint (juce::Graphics& g)
         }
     }
 
-    const auto addY = 4 + (int) song.channels.size() * rowHeight;
+    paintLane (g);
+    const auto addY = rowY ((int) song.channels.size());
     {
         const auto addArea = juce::Rectangle<float> ((float) nameLeft(), (float) addY + 3, (float) nameWidth, (float) rowHeight - 6);
         const float dash[] = { 3.0f, 3.0f };
@@ -548,6 +590,361 @@ void ChannelRackComponent::toggleEditor (int channel, bool keepOthers)
     openEditorRow = channel;
 }
 
+// --- step graph lanes (docs/WORKFLOW_FL.md P2, C4) --------------------------------------------------
+
+juce::Rectangle<int> ChannelRackComponent::levelButtonBounds (int level) const
+{
+    const auto lane = laneBounds();
+    const auto width = (gridLeft() - 24) / 3;
+    return { 12 + (level % 3) * width, lane.getY() + 8 + (level / 3) * 24, width - 4, 20 };
+}
+
+void ChannelRackComponent::paintLane (juce::Graphics& g)
+{
+    using namespace theme::colour;
+    const auto lane = laneBounds();
+
+    if (lane.isEmpty() || ! g.getClipBounds().intersects (lane))
+        return;
+
+    const auto& song = engine.getSong();
+    const auto& pattern = song.patterns[(std::size_t) song.currentPattern];
+    const auto channel = graphRow();
+    const auto level = (notetools::Level) graphLevel;
+
+    g.setColour (bg0);
+    g.fillRect (lane);
+    g.setColour (border);
+    g.drawHorizontalLine (lane.getY(), 0.0f, (float) getWidth());
+    g.drawHorizontalLine (lane.getBottom() - 1, 0.0f, (float) getWidth());
+
+    for (int l = 0; l < notetools::levelCount; ++l)
+    {
+        const auto r = levelButtonBounds (l).toFloat();
+        g.setColour (l == graphLevel ? accent : bg4);
+        g.fillRoundedRectangle (r, theme::radius::sm);
+        g.setColour (l == graphLevel ? onAccent : textSecondary);
+        g.setFont (theme::font (theme::type::caption, l == graphLevel));
+        g.drawFittedText (tr (notetools::levelName ((notetools::Level) l)), r.toNearestInt(), juce::Justification::centred, 1, 0.8f);
+    }
+
+    g.setColour (textDisabled);
+    g.setFont (theme::font (theme::type::caption));
+    g.drawFittedText (tr ("Drag: set  ·  Right-drag: ramp  ·  Alt+click: reset"),
+                      juce::Rectangle<int> (12, lane.getBottom() - 20, gridLeft() - 24, 16), juce::Justification::centredLeft, 1, 0.8f);
+
+    const auto top = (float) lane.getY() + 6.0f, bottom = (float) lane.getBottom() - 6.0f;
+    const auto bipolar = notetools::levelIsBipolar (level);
+    const auto base = bipolar ? (top + bottom) * 0.5f : bottom;
+
+    for (int step = 0; step < numSteps(); ++step)
+    {
+        const auto x = (float) (gridLeft() + step * stepWidth + 1);
+        const auto w = (float) stepWidth - 3.0f;
+
+        if (step % 4 == 0 && step > 0)
+        {
+            g.setColour (step % 16 == 0 ? gridBar : gridBeat);
+            g.drawVerticalLine ((int) x - 2, top, bottom);
+        }
+
+        const auto notes = notesInStep (pattern, channel, step);
+
+        if (notes.empty())
+        {
+            g.setColour (theme::stepOff (step));
+            g.fillRect (x + w * 0.5f - 1.0f, base - 1.0f, 2.0f, 2.0f);
+            continue;
+        }
+
+        const auto v = notetools::levelValue (pattern.notes[(std::size_t) notes.front()], level);
+        const auto y = bottom - v * (bottom - top);
+        g.setColour ((level == notetools::Level::velocity ? accent : info).withAlpha (0.85f));
+        g.fillRect (juce::Rectangle<float> (x + 2.0f, juce::jmin (y, base), w - 4.0f, juce::jmax (2.0f, std::abs (base - y))));
+        g.setColour (textPrimary);
+        g.fillRect (x + 1.0f, y - 1.0f, w - 2.0f, 2.0f);
+    }
+
+    if (bipolar)
+    {
+        g.setColour (gridBar);
+        g.drawHorizontalLine ((int) base, (float) gridLeft(), (float) getWidth());
+    }
+}
+
+float ChannelRackComponent::laneValueAt (int y) const
+{
+    const auto lane = laneBounds();
+    const auto top = (float) lane.getY() + 6.0f, bottom = (float) lane.getBottom() - 6.0f;
+    return juce::jlimit (0.0f, 1.0f, (bottom - (float) y) / juce::jmax (1.0f, bottom - top));
+}
+
+void ChannelRackComponent::setLaneValue (int step, float value)
+{
+    const auto channel = graphRow();
+    const auto level = (notetools::Level) graphLevel;
+    engine.editSong ([channel, step, value, level] (Song& s) {
+        auto& p = s.patterns[(std::size_t) s.currentPattern];
+        for (auto i : notesInStep (p, channel, step))
+            notetools::setLevelValue (p.notes[(std::size_t) i], level, value);
+    });
+}
+
+void ChannelRackComponent::applyLane (const juce::MouseEvent& e)
+{
+    const auto steps = numSteps();
+    const auto step = juce::jlimit (0, steps - 1, (e.x - gridLeft()) / stepWidth);
+    const auto value = laneValueAt (e.y);
+
+    if (e.mods.isRightButtonDown()) // a straight ramp from the press to here
+    {
+        const auto from = juce::jmin (laneDownStep, step), to = juce::jmax (laneDownStep, step);
+        const auto channel = graphRow();
+        const auto level = (notetools::Level) graphLevel;
+        const auto v0 = laneDownStep <= step ? laneDownValue : value, v1 = laneDownStep <= step ? value : laneDownValue;
+        engine.editSong ([=] (Song& s) {
+            auto& p = s.patterns[(std::size_t) s.currentPattern];
+            for (int st = from; st <= to; ++st)
+            {
+                const auto t = to > from ? (float) (st - from) / (float) (to - from) : 0.0f;
+                for (auto i : notesInStep (p, channel, st))
+                    notetools::setLevelValue (p.notes[(std::size_t) i], level, v0 + (v1 - v0) * t);
+            }
+        });
+        return;
+    }
+
+    setLaneValue (step, value);
+}
+
+void ChannelRackComponent::toggleGraphLanes()
+{
+    graphLanes = ! graphLanes;
+    updateSize();
+    repaint();
+}
+
+// --- fills, rotation and organisation ------------------------------------------------------------
+
+void ChannelRackComponent::rotateSelected (int steps)
+{
+    const auto rows = engine.getSelectedChannels();
+    engine.editSong ([rows, steps] (Song& s) {
+        auto& p = s.patterns[(std::size_t) s.currentPattern];
+        const auto length = patternSteps (s, p);
+        for (auto r : rows)
+            rotateSteps (p, r, steps, length);
+    });
+}
+
+void ChannelRackComponent::fillSelected (int every)
+{
+    const auto rows = engine.getSelectedChannels();
+    engine.editSong ([rows, every] (Song& s) {
+        auto& p = s.patterns[(std::size_t) s.currentPattern];
+        const auto length = patternSteps (s, p);
+        for (auto r : rows)
+            if (r < (int) s.channels.size() && s.channels[(std::size_t) r].instrument != InstrumentKind::audioClip)
+                fillEverySteps (p, r, every, length);
+    });
+}
+
+void ChannelRackComponent::sortChannels (ChannelSort by)
+{
+    engine.editSong ([by] (Song& s) { permuteChannels (s, channelSortOrder (s, by)); });
+    openEditorRow = -1;
+    selectRows ({ 0 }, 0);
+}
+
+void ChannelRackComponent::selectUnused()
+{
+    const auto unused = unusedChannels (engine.getSong());
+
+    if (unused.empty())
+    {
+        juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Select unused channels"),
+                                                tr ("Every channel is used by a pattern or a Playlist clip."));
+        return;
+    }
+
+    selectRows (unused, unused.front());
+}
+
+int ChannelRackComponent::addChannel (ChannelDef c, bool openEditor)
+{
+    int index = 0;
+    engine.editSong ([&] (Song& s) {
+        c.mixerTrack = s.nextFreeInsert();
+        s.channels.push_back (c);
+        index = (int) s.channels.size() - 1;
+    });
+    selectionAnchor = index;
+    selectRows ({ index }, index);
+
+    if (openEditor && c.instrument == InstrumentKind::plugin)
+    {
+        openPluginWindow (index);
+        openEditorRow = index;
+    }
+
+    return index;
+}
+
+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"))
+        return false;
+
+    const auto kind = song.channels[(std::size_t) row].instrument;
+
+    // only channels that play a sample (or the built-in drums, which become samplers) take a file
+    if (kind != InstrumentKind::sampler && kind != InstrumentKind::kick && kind != InstrumentKind::snare && kind != InstrumentKind::hat
+        && kind != InstrumentKind::clap)
+        return false;
+
+    assignSample (row, file);
+    return true;
+}
+
+namespace
+{
+// Euclidean fill: pulses spread evenly over a length, rotated; previewed live on the pattern.
+class EuclideanPanel final : public juce::Component
+{
+public:
+    EuclideanPanel (AudioEngine& e, int c) : engine (e), channel (c)
+    {
+        const auto& song = engine.getSong();
+        patternIndex = song.currentPattern;
+        originals = song.patterns[(std::size_t) patternIndex].notes;
+        steps = patternSteps (song, song.patterns[(std::size_t) patternIndex]);
+
+        auto setup = [this] (juce::Slider& s, juce::Label& l, const juce::String& name, double lo, double hi, double v) {
+            l.setText (name, juce::dontSendNotification);
+            addAndMakeVisible (l);
+            s.setSliderStyle (juce::Slider::LinearHorizontal);
+            s.setTextBoxStyle (juce::Slider::TextBoxRight, false, 50, 20);
+            s.setRange (lo, hi, 1.0);
+            s.setValue (v, juce::dontSendNotification);
+            s.onValueChange = [this] { preview(); };
+            addAndMakeVisible (s);
+        };
+        setup (pulses, pulsesLabel, tr ("Pulses"), 0, 32, 5);
+        setup (length, lengthLabel, tr ("Length (steps)"), 1, 32, 16);
+        setup (rotation, rotationLabel, tr ("Rotation"), -16, 16, 0);
+        title.setText (tr ("Euclidean fill: {0}", { juce::String::fromUTF8 (song.channels[(std::size_t) channel].name.c_str()) }), juce::dontSendNotification);
+        title.setFont (theme::font (theme::type::title, true));
+        addAndMakeVisible (title);
+
+        for (auto* b : { &accept, &cancel })
+            addAndMakeVisible (b);
+        accept.setColour (juce::TextButton::buttonColourId, theme::colour::accent);
+        accept.onClick = [this] {
+            restore();
+            const auto rhythm = current();
+            engine.editSong ([this, rhythm] (Song& s) { setStepRhythm (s.patterns[(std::size_t) patternIndex], channel, rhythm, steps); });
+            done = true;
+            closeToolWindowOf (*this);
+        };
+        cancel.onClick = [this] { closeToolWindowOf (*this); };
+        setSize (380, 330);
+        preview();
+    }
+
+    ~EuclideanPanel() override
+    {
+        if (! done)
+            restore();
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        g.fillAll (theme::colour::bg2);
+        // the rhythm as a ring of steps, the first step at the top
+        const auto rhythm = current();
+        const auto ring = juce::Rectangle<float> (0, 150, (float) getWidth(), 120).withSizeKeepingCentre (110, 110);
+        const auto n = (int) rhythm.size();
+
+        for (int i = 0; i < n; ++i)
+        {
+            const auto angle = juce::MathConstants<float>::twoPi * (float) i / (float) n;
+            const auto centre = ring.getCentre() + juce::Point<float> (std::sin (angle), -std::cos (angle)) * 50.0f;
+            const auto dot = juce::Rectangle<float> (12, 12).withCentre (centre);
+            g.setColour (rhythm[(std::size_t) i] ? theme::colour::stepOn : theme::colour::stepOff);
+            g.fillEllipse (dot);
+            if (i == 0)
+            {
+                g.setColour (theme::colour::textPrimary);
+                g.drawEllipse (dot.expanded (2.0f), 1.0f);
+            }
+        }
+    }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (12, 10);
+        title.setBounds (area.removeFromTop (24));
+        area.removeFromTop (6);
+        for (auto [s, l] : { std::pair { &pulses, &pulsesLabel }, std::pair { &length, &lengthLabel }, std::pair { &rotation, &rotationLabel } })
+        {
+            auto row = area.removeFromTop (30);
+            l->setBounds (row.removeFromLeft (120));
+            s->setBounds (row);
+        }
+        auto buttons = area.removeFromBottom (28);
+        accept.setBounds (buttons.removeFromRight (100));
+        buttons.removeFromRight (8);
+        cancel.setBounds (buttons.removeFromRight (90));
+    }
+
+private:
+    std::vector<bool> current() const
+    {
+        return euclideanRhythm ((int) pulses.getValue(), (int) length.getValue(), (int) rotation.getValue());
+    }
+
+    void restore()
+    {
+        if (patternIndex < (int) engine.getSong().patterns.size())
+            engine.editSong ([this] (Song& s) { s.patterns[(std::size_t) patternIndex].notes = originals; }, false);
+    }
+
+    void preview()
+    {
+        const auto rhythm = current();
+        if (patternIndex < (int) engine.getSong().patterns.size())
+            engine.editSong ([this, rhythm] (Song& s) {
+                auto& p = s.patterns[(std::size_t) patternIndex];
+                p.notes = originals;
+                setStepRhythm (p, channel, rhythm, steps);
+            }, false);
+        repaint();
+    }
+
+    AudioEngine& engine;
+    int channel, patternIndex = 0, steps = 16;
+    std::vector<Note> originals;
+    bool done = false;
+    juce::Label title, pulsesLabel, lengthLabel, rotationLabel;
+    juce::Slider pulses, length, rotation;
+    juce::TextButton accept { tr ("Accept") }, cancel { tr ("Cancel") };
+};
+} // namespace
+
+std::unique_ptr<juce::Component> ChannelRackComponent::makeEuclideanPanel (int channel)
+{
+    return std::make_unique<EuclideanPanel> (engine, juce::jlimit (0, juce::jmax (0, (int) engine.getSong().channels.size() - 1), channel));
+}
+
+void ChannelRackComponent::showEuclideanFill (int channel)
+{
+    if (channel >= 0 && channel < (int) engine.getSong().channels.size())
+        openToolWindow (makeEuclideanPanel (channel), tr ("Euclidean fill"), "euclidean");
+}
+
 // --- mouse -------------------------------------------------------------------------------------
 
 void ChannelRackComponent::mouseDown (const juce::MouseEvent& e)
@@ -565,6 +962,31 @@ void ChannelRackComponent::mouseDown (const juce::MouseEvent& e)
             showAddChannelMenu();
             return;
 
+        case Area::laneLevels:
+            for (int l = 0; l < notetools::levelCount; ++l)
+                if (levelButtonBounds (l).contains (e.getPosition()))
+                {
+                    graphLevel = l;
+                    repaint();
+                }
+            return;
+
+        case Area::lane:
+        {
+            const auto step = juce::jlimit (0, numSteps() - 1, (e.x - gridLeft()) / stepWidth);
+
+            if (e.mods.isAltDown() || e.mods.isMiddleButtonDown())
+            {
+                setLaneValue (step, notetools::levelDefault ((notetools::Level) graphLevel));
+                return;
+            }
+
+            laneDownStep = step;
+            laneDownValue = laneValueAt (e.y);
+            applyLane (e);
+            return;
+        }
+
         case Area::mute:
             if (e.mods.isPopupMenu() || e.mods.isCtrlDown())
                 solo (row);
@@ -673,6 +1095,12 @@ void ChannelRackComponent::mouseDrag (const juce::MouseEvent& e)
         return;
     }
 
+    if (laneDownStep >= 0)
+    {
+        applyLane (e);
+        return;
+    }
+
     if (paintMode != PaintMode::none)
         applyPaint (e);
 }
@@ -684,6 +1112,7 @@ void ChannelRackComponent::mouseUp (const juce::MouseEvent&)
 
     auditionRow = -1;
     paintMode = PaintMode::none;
+    laneDownStep = -1;
 
     if (knobDrag != Area::none)
         repaint();
@@ -768,6 +1197,12 @@ ui::Hint ChannelRackComponent::hintAt (juce::Point<int> p)
         case Area::addRow:
             h.text = tr ("Add a channel (or drop audio files on the rack)");
             break;
+        case Area::laneLevels:
+            h.text = tr ("Graph lane: choose what the bars edit (Ctrl+K hides the lane)");
+            break;
+        case Area::lane:
+            h.text = name + " - " + tr ("Graph lane: drag sets the steps, right-drag draws a ramp, Alt+click resets");
+            break;
         default:
             break;
     }
@@ -778,9 +1213,12 @@ ui::Hint ChannelRackComponent::hintAt (juce::Point<int> p)
 void ChannelRackComponent::applyPaint (const juce::MouseEvent& e)
 {
     const auto& song = engine.getSong();
-    const auto row = (e.y - 4) / rowHeight;
+    const auto row = rowAtY (e.y);
     const auto step = (e.x - gridLeft()) / stepWidth;
 
+    if (laneBounds().contains (e.getPosition()))
+        return;
+
     if (row < 0 || row >= (int) song.channels.size() || step < 0 || step >= numSteps() || e.x < gridLeft()
         || song.channels[(std::size_t) row].instrument == InstrumentKind::audioClip)
         return;
@@ -915,6 +1353,19 @@ void ChannelRackComponent::showChannelMenu (int channel)
 
         menu.addSubMenu (tr ("Color"), colours);
     }
+    {
+        juce::PopupMenu steps;
+        steps.addItem (tr ("Fill every 2 steps"), [this] { fillSelected (2); });
+        steps.addItem (tr ("Fill every 4 steps"), [this] { fillSelected (4); });
+        steps.addItem (tr ("Fill every 8 steps"), [this] { fillSelected (8); });
+        steps.addItem (tr ("Euclidean fill..."), [this, channel] { showEuclideanFill (channel); });
+        steps.addSeparator();
+        steps.addItem (tr ("Rotate left") + "\tCtrl+Shift+Left", [this] { rotateSelected (-1); });
+        steps.addItem (tr ("Rotate right") + "\tCtrl+Shift+Right", [this] { rotateSelected (1); });
+        steps.addSeparator();
+        steps.addItem (tr ("Graph lanes (velocity, pan, pitch...)") + "\tCtrl+K", true, graphLanes, [this] { toggleGraphLanes(); });
+        menu.addSubMenu (tr ("Steps"), steps);
+    }
     menu.addItem (tr ("Clear notes in this pattern"), [this, channel] {
         engine.editSong ([channel] (Song& s) {
             auto& notes = s.patterns[(std::size_t) s.currentPattern].notes;
@@ -936,6 +1387,15 @@ void ChannelRackComponent::showChannelMenu (int channel)
     menu.addItem (tr ("Move up") + "\tAlt+Up", engine.getSelectedChannels().front() > 0, false, [this] { moveSelected (-1); });
     menu.addItem (tr ("Move down") + "\tAlt+Down", engine.getSelectedChannels().back() < count - 1, false, [this] { moveSelected (1); });
     menu.addItem (tr ("Send to free mixer inserts") + "\tCtrl+L", [this] { sendSelectedToInserts(); });
+    {
+        juce::PopupMenu sort;
+        sort.addItem (tr ("By name"), [this] { sortChannels (ChannelSort::name); });
+        sort.addItem (tr ("By color"), [this] { sortChannels (ChannelSort::colour); });
+        sort.addItem (tr ("By mixer insert"), [this] { sortChannels (ChannelSort::insert); });
+        sort.addItem (tr ("By type"), [this] { sortChannels (ChannelSort::type); });
+        menu.addSubMenu (tr ("Sort channels"), sort);
+    }
+    menu.addItem (tr ("Select unused channels"), [this] { selectUnused(); });
     menu.addSeparator();
 
     if (selected > 1)
@@ -1161,13 +1621,12 @@ void ChannelRackComponent::timerCallback()
 
 bool ChannelRackComponent::isInterestedInDragSource (const SourceDetails& details)
 {
-    return details.description.toString() == BrowserComponent::dragDescription;
+    return BrowserComponent::isBrowserDrag (details);
 }
 
 void ChannelRackComponent::itemDropped (const SourceDetails& details)
 {
-    if (auto* tree = dynamic_cast<juce::FileTreeComponent*> (details.sourceComponent.get()))
-        if (tree->getSelectedFile().existsAsFile())
-            filesDropped ({ tree->getSelectedFile().getFullPathName() }, details.localPosition.x, details.localPosition.y);
+    if (const auto file = BrowserComponent::draggedFile (details); file.existsAsFile())
+        filesDropped ({ file.getFullPathName() }, details.localPosition.x, details.localPosition.y);
 }
 } // namespace lynx

+ 33 - 1
src/ui/ChannelRackComponent.h

@@ -62,6 +62,24 @@ public:
     void toggleMute (int channel);
     void solo (int channel);
 
+    // Workflow P2: step graph lanes, fills, rotation and organisation
+    void toggleGraphLanes();
+    bool areGraphLanesShown() const noexcept { return graphLanes; }
+    void setGraphLevelForSnapshot (int level) { graphLevel = level; graphLanes = true; updateSize(); repaint(); }
+    void rotateSelected (int steps);
+    void fillSelected (int every);
+    void showEuclideanFill (int channel);
+    std::unique_ptr<juce::Component> makeEuclideanPanel (int channel); // the window's content (also for --snapshot)
+    void sortChannels (ChannelSort by);
+    void selectUnused();
+
+    // Adds a channel at the end (routed to a free insert), selects it and, for plugins, opens its window.
+    int addChannel (ChannelDef channel, bool openEditor);
+
+    // Loads `file` into the selected sampler channel (Browser: Enter, Shift+Up/Down). Returns false when
+    // the selected channel cannot take a sample.
+    bool loadSampleIntoSelected (const juce::File& file);
+
     // Opens or closes the channel's editor (plugin window or settings window; built-in drums and audio
     // clips have none). `keepOthers`: don't close the previously opened editor.
     void toggleEditor (int channel, bool keepOthers);
@@ -80,7 +98,7 @@ public:
     static constexpr int stepWidth = 22;
 
 private:
-    enum class Area { none, mute, pan, volume, route, name, select, grid, addRow };
+    enum class Area { none, mute, pan, volume, route, name, select, grid, addRow, laneLevels, lane };
 
     void changeListenerCallback (juce::ChangeBroadcaster*) override;
     void timerCallback() override;
@@ -91,6 +109,20 @@ private:
     int selectLeft() const noexcept { return nameLeft() + nameWidth + 4; }
     int gridLeft() const noexcept { return selectLeft() + selectWidth + 8; }
     juce::Rectangle<int> rowBounds (int row) const;
+    int rowY (int row) const;       // top of a row (rows below the graph lane shift down)
+    int rowAtY (int y) const;       // row under y (the lane counts as its channel's row)
+    int graphRow() const;           // the row the lane belongs to (the primary selection), -1 when hidden
+    juce::Rectangle<int> laneBounds() const;
+    juce::Rectangle<int> levelButtonBounds (int level) const;
+    void paintLane (juce::Graphics& g);
+    void setLaneValue (int step, float value);
+    void applyLane (const juce::MouseEvent& e);
+    float laneValueAt (int y) const;
+    bool graphLanes = false;
+    int graphLevel = 0; // notetools::Level
+    int laneDownStep = -1;
+    float laneDownValue = 0.0f;
+    static constexpr int laneHeight = 72;
     juce::Rectangle<int> stepBounds (int row, int step) const;
     bool cellHasNote (int channel, int step) const;
     void applyPaint (const juce::MouseEvent& e);

+ 35 - 3
src/ui/ChannelSettings.cpp

@@ -10,6 +10,7 @@
 #include "core/Harmor.h"
 #include "core/Gms.h"
 #include "core/Morphine.h"
+#include "core/Ogun.h"
 #include "core/SynthPresets.h"
 #include "engine/Text.h"
 #include "ui/I18n.h"
@@ -477,6 +478,7 @@ public:
         harmor = def.instrument == InstrumentKind::harmor;
         gms = def.instrument == InstrumentKind::gms;
         morphine = def.instrument == InstrumentKind::morphine;
+        ogun = def.instrument == InstrumentKind::ogun;
         // DrumSynth Live: the patch on the key selected in FL's editor (raw FL values)
         if (drumsynth)
         {
@@ -589,12 +591,38 @@ public:
             addAndMakeVisible (*knob);
             knobs.push_back (std::move (knob));
         };
+        // Ogun: raw FL integers P0…P63 inside the saved (zlib) state (REA_rodada37 §1.3)
+        static const Ranged ogunKnobs[] = {
+            { 0, "Master vol", 0, 256 }, { 5, "Pre-decay", 0, 1000 }, { 6, "Decay", 0, 10000 }, { 7, "Release", 0, 10000 },
+            { 8, "Fullness", -1000, 1000 }, { 9, "Morph", 0, 1000 }, { 10, "Seed 1", 0, 1000 }, { 11, "Seed 2", 0, 1000 },
+            { 52, "Richness", 6, 16 }, { 12, "Unison", 1, 9 }, { 15, "Uni pitch", 0, 256 }, { 17, "Cutoff", 0, 256 },
+            { 18, "Resonance", 0, 256 }, { 3, "Mod X", 0, 512 }, { 4, "Mod Y", 0, 512 }, { 54, "Quality", 0, 4 } };
+        auto addOgun = [&] (const Ranged& k) {
+            const auto value = ogunParam (def.pluginState, k.index);
+            if (! value)
+                return;
+            auto knob = std::make_unique<juce::Slider> (juce::Slider::RotaryHorizontalVerticalDrag, juce::Slider::TextBoxBelow);
+            knob->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 70, 16);
+            knob->setRange (k.low, k.high, 1.0);
+            knob->setValue (*value, juce::dontSendNotification);
+            knob->setName (k.name);
+            knob->onValueChange = [this, index = k.index, s = knob.get()] {
+                engine.editSong ([c = channel, index, v = (int) s->getValue()] (Song& song) {
+                    ogunSetParam (song.channels[(std::size_t) c].pluginState, index, v);
+                });
+            };
+            addAndMakeVisible (*knob);
+            knobs.push_back (std::move (knob));
+        };
         if (gms)
             for (const auto& k : gmsKnobs)
                 addFloat (k);
         else if (morphine)
             for (const auto& k : morphineKnobs)
                 addFloat (k);
+        else if (ogun)
+            for (const auto& k : ogunKnobs)
+                addOgun (k);
         else if (harmor)
             for (const auto& k : harmorKnobs)
                 addHarmor (k);
@@ -628,6 +656,7 @@ public:
                     : harmor ? tr ("Harmor — FL's additive engine (effects rack off; image synthesis not decoded)")
                     : gms ? tr ("GMS — FL's engine (waves read from your FL installation)")
                     : morphine ? tr ("Morphine — FL's additive engine (new settings restart the voices)")
+                    : ogun ? tr ("Ogun — FL's engine with its effects (Seed 2 Random is a fixed draw per channel)")
                     : boobass ? tr ("BooBass — FL's engine, its sound read from your FL installation (knobs: 3-band EQ)")
                     : sakura ? tr ("Sakura — physical strings (FL's engine; new parameters apply to the next note)")
                              : tr ("Drumpad — physical drum (FL's engine; new parameters apply to the next hit)"),
@@ -647,7 +676,7 @@ public:
 private:
     AudioEngine& engine;
     int channel;
-    bool sakura = true, boobass = false, drumsynth = false, harmless = false, harmor = false, gms = false, morphine = false, wavesFound = false;
+    bool sakura = true, boobass = false, drumsynth = false, harmless = false, harmor = false, gms = false, morphine = false, ogun = false, wavesFound = false;
     int editorKey = 60;
     std::vector<std::unique_ptr<juce::Slider>> knobs;
 };
@@ -1278,7 +1307,8 @@ public:
         else if (const auto kind = engine.getSong().channels[(std::size_t) channel].instrument;
                  kind == InstrumentKind::sakura || kind == InstrumentKind::drumpad || kind == InstrumentKind::boobass
                  || kind == InstrumentKind::drumsynth || kind == InstrumentKind::harmless || kind == InstrumentKind::harmor
-                 || kind == InstrumentKind::gms || kind == InstrumentKind::morphine)
+                 || kind == InstrumentKind::gms || kind == InstrumentKind::morphine
+                 || kind == InstrumentKind::ogun)
             setContentOwned (new ModelPanel (engine, channel), true);
         else
             setContentOwned (new SettingsPanel (engine, channel), true);
@@ -1358,6 +1388,7 @@ bool hasChannelSettings (InstrumentKind kind) noexcept
         case InstrumentKind::harmor:
         case InstrumentKind::gms:
         case InstrumentKind::morphine:
+        case InstrumentKind::ogun:
             return true;
         default:
             return false;
@@ -1390,7 +1421,8 @@ std::unique_ptr<juce::Component> makeChannelSettingsPanel (AudioEngine& engine,
     if (const auto kind = engine.getSong().channels[(std::size_t) channel].instrument;
         kind == InstrumentKind::sakura || kind == InstrumentKind::drumpad || kind == InstrumentKind::boobass
                  || kind == InstrumentKind::drumsynth || kind == InstrumentKind::harmless || kind == InstrumentKind::harmor
-                 || kind == InstrumentKind::gms || kind == InstrumentKind::morphine)
+                 || kind == InstrumentKind::gms || kind == InstrumentKind::morphine
+                 || kind == InstrumentKind::ogun)
         return std::make_unique<ModelPanel> (engine, channel);
 
     return std::make_unique<SettingsPanel> (engine, channel);

+ 113 - 0
src/ui/HistoryPanel.cpp

@@ -0,0 +1,113 @@
+#include "ui/HistoryPanel.h"
+
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+
+namespace lynx
+{
+namespace
+{
+class HistoryPanel final : public juce::Component,
+                           private juce::ListBoxModel,
+                           private juce::ChangeListener
+{
+public:
+    explicit HistoryPanel (AudioEngine& e) : engine (e)
+    {
+        title.setText (tr ("Undo history"), juce::dontSendNotification);
+        title.setFont (theme::font (theme::type::title, true));
+        addAndMakeVisible (title);
+        note.setText (tr ("Click a step to go back (or forward) to it. Newest at the bottom."), juce::dontSendNotification);
+        note.setFont (theme::font (theme::type::small));
+        note.setColour (juce::Label::textColourId, theme::colour::textSecondary);
+        addAndMakeVisible (note);
+
+        list.setModel (this);
+        list.setRowHeight (24);
+        list.setColour (juce::ListBox::backgroundColourId, theme::colour::bg1);
+        list.setOutlineThickness (0);
+        addAndMakeVisible (list);
+        engine.addChangeListener (this);
+        refresh();
+        setSize (340, 420);
+    }
+
+    ~HistoryPanel() override { engine.removeChangeListener (this); }
+
+    void paint (juce::Graphics& g) override { g.fillAll (theme::colour::bg2); }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (10);
+        title.setBounds (area.removeFromTop (24));
+        note.setBounds (area.removeFromTop (22));
+        area.removeFromTop (4);
+        list.setBounds (area);
+    }
+
+private:
+    void refresh()
+    {
+        labels.clear();
+        for (int i = 0; i < engine.getHistorySize(); ++i)
+        {
+            const auto l = engine.getHistoryLabel (i);
+            labels.add (tr (l.text, { juce::String::fromUTF8 (l.arg.c_str()) }));
+        }
+
+        position = engine.getHistoryPosition();
+        list.updateContent();
+        list.scrollToEnsureRowIsOnscreen (position);
+        list.repaint();
+    }
+
+    void changeListenerCallback (juce::ChangeBroadcaster*) override
+    {
+        if (engine.getHistorySize() != labels.size() || engine.getHistoryPosition() != position)
+            refresh();
+        else if (labels.size() > 0) // the newest step may have been extended by a drag
+        {
+            const auto l = engine.getHistoryLabel (labels.size() - 1);
+            labels.set (labels.size() - 1, tr (l.text, { juce::String::fromUTF8 (l.arg.c_str()) }));
+            list.repaintRow (labels.size() - 1);
+        }
+    }
+
+    int getNumRows() override { return labels.size(); }
+
+    void paintListBoxItem (int row, juce::Graphics& g, int width, int height, bool) override
+    {
+        const auto current = row == position;
+        const auto future = row > position;
+
+        if (current)
+        {
+            g.setColour (theme::colour::accentMuted);
+            g.fillRect (0, 0, width, height);
+            g.setColour (theme::colour::accent);
+            g.fillRect (0, 2, 3, height - 4);
+        }
+
+        g.setFont (theme::font (theme::type::caption));
+        g.setColour (theme::colour::textDisabled);
+        g.drawText (juce::String (row), 8, 0, 28, height, juce::Justification::centredRight);
+        g.setFont (theme::font (theme::type::body, current));
+        g.setColour (future ? theme::colour::textDisabled : theme::colour::textPrimary);
+        g.drawText (labels[row], 44, 0, width - 50, height, juce::Justification::centredLeft, true);
+    }
+
+    void listBoxItemClicked (int row, const juce::MouseEvent&) override { engine.jumpToHistory (row); }
+
+    AudioEngine& engine;
+    juce::Label title, note;
+    juce::ListBox list;
+    juce::StringArray labels;
+    int position = 0;
+};
+} // namespace
+
+std::unique_ptr<juce::Component> makeHistoryPanel (AudioEngine& engine)
+{
+    return std::make_unique<HistoryPanel> (engine);
+}
+} // namespace lynx

+ 14 - 0
src/ui/HistoryPanel.h

@@ -0,0 +1,14 @@
+#pragma once
+
+#include <memory>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+// Undo history (docs/WORKFLOW_FL.md P2, G13): the undo steps by name, oldest first, the current state
+// marked; clicking an entry jumps there (later entries stay as redo steps until the next edit).
+std::unique_ptr<juce::Component> makeHistoryPanel (AudioEngine& engine);
+} // namespace lynx

+ 1387 - 841
src/ui/I18nData.h

@@ -996,850 +996,1396 @@ inline constexpr unsigned char ptBR[] = {
 115, 116, 97, 114, 116, 32, 116, 104, 101, 32, 118, 111, 105, 99, 101, 115, 41, 34, 32, 61, 32, 34, 77, 111,
 114, 112, 104, 105, 110, 101, 32, 226, 128, 148, 32, 109, 111, 116, 111, 114, 32, 97, 100, 105, 116, 105, 118, 111,
 32, 100, 111, 32, 70, 76, 32, 40, 110, 111, 118, 111, 115, 32, 97, 106, 117, 115, 116, 101, 115, 32, 114, 101,
-105, 110, 105, 99, 105, 97, 109, 32, 97, 115, 32, 118, 111, 122, 101, 115, 41, 34, 10, 34, 66, 111, 111, 66,
-97, 115, 115, 32, 226, 128, 148, 32, 70, 76, 39, 115, 32, 101, 110, 103, 105, 110, 101, 44, 32, 105, 116, 115,
-32, 115, 111, 117, 110, 100, 32, 114, 101, 97, 100, 32, 102, 114, 111, 109, 32, 121, 111, 117, 114, 32, 70, 76,
-32, 105, 110, 115, 116, 97, 108, 108, 97, 116, 105, 111, 110, 32, 40, 107, 110, 111, 98, 115, 58, 32, 51, 45,
-98, 97, 110, 100, 32, 69, 81, 41, 34, 32, 61, 32, 34, 66, 111, 111, 66, 97, 115, 115, 32, 226, 128, 148,
-32, 109, 111, 116, 111, 114, 32, 100, 111, 32, 70, 76, 44, 32, 115, 111, 109, 32, 108, 105, 100, 111, 32, 100,
-97, 32, 115, 117, 97, 32, 105, 110, 115, 116, 97, 108, 97, 195, 167, 195, 163, 111, 32, 100, 111, 32, 70, 76,
-32, 40, 107, 110, 111, 98, 115, 58, 32, 69, 81, 32, 100, 101, 32, 51, 32, 98, 97, 110, 100, 97, 115, 41,
-34, 10, 34, 83, 97, 107, 117, 114, 97, 32, 226, 128, 148, 32, 112, 104, 121, 115, 105, 99, 97, 108, 32, 115,
-116, 114, 105, 110, 103, 115, 32, 40, 70, 76, 39, 115, 32, 101, 110, 103, 105, 110, 101, 59, 32, 110, 101, 119,
-32, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32, 97, 112, 112, 108, 121, 32, 116, 111, 32, 116, 104, 101,
-32, 110, 101, 120, 116, 32, 110, 111, 116, 101, 41, 34, 32, 61, 32, 34, 83, 97, 107, 117, 114, 97, 32, 226,
-128, 148, 32, 99, 111, 114, 100, 97, 115, 32, 102, 195, 173, 115, 105, 99, 97, 115, 32, 40, 109, 111, 116, 111,
-114, 32, 100, 111, 32, 70, 76, 59, 32, 110, 111, 118, 111, 115, 32, 112, 97, 114, 195, 162, 109, 101, 116, 114,
-111, 115, 32, 118, 97, 108, 101, 109, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 97, 32, 112, 114, 195,
-179, 120, 105, 109, 97, 32, 110, 111, 116, 97, 41, 34, 10, 34, 68, 114, 117, 109, 112, 97, 100, 32, 226, 128,
-148, 32, 112, 104, 121, 115, 105, 99, 97, 108, 32, 100, 114, 117, 109, 32, 40, 70, 76, 39, 115, 32, 101, 110,
-103, 105, 110, 101, 59, 32, 110, 101, 119, 32, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32, 97, 112, 112,
-108, 121, 32, 116, 111, 32, 116, 104, 101, 32, 110, 101, 120, 116, 32, 104, 105, 116, 41, 34, 32, 61, 32, 34,
-68, 114, 117, 109, 112, 97, 100, 32, 226, 128, 148, 32, 116, 97, 109, 98, 111, 114, 32, 102, 195, 173, 115, 105,
-99, 111, 32, 40, 109, 111, 116, 111, 114, 32, 100, 111, 32, 70, 76, 59, 32, 110, 111, 118, 111, 115, 32, 112,
-97, 114, 195, 162, 109, 101, 116, 114, 111, 115, 32, 118, 97, 108, 101, 109, 32, 97, 32, 112, 97, 114, 116, 105,
-114, 32, 100, 111, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 104, 105, 116, 41, 34, 10, 34, 80, 105, 116,
-99, 104, 34, 32, 61, 32, 34, 80, 105, 116, 99, 104, 34, 10, 34, 83, 116, 114, 101, 116, 99, 104, 34, 32,
-61, 32, 34, 83, 116, 114, 101, 116, 99, 104, 34, 10, 34, 83, 116, 97, 114, 116, 34, 32, 61, 32, 34, 73,
-110, 195, 173, 99, 105, 111, 34, 10, 34, 69, 110, 100, 34, 32, 61, 32, 34, 70, 105, 109, 34, 10, 34, 67,
-117, 116, 111, 102, 102, 34, 32, 61, 32, 34, 67, 117, 116, 111, 102, 102, 34, 10, 34, 82, 101, 115, 111, 110,
-97, 110, 99, 101, 34, 32, 61, 32, 34, 82, 101, 115, 115, 111, 110, 195, 162, 110, 99, 105, 97, 34, 10, 34,
-67, 104, 97, 110, 110, 101, 108, 32, 102, 105, 108, 116, 101, 114, 32, 99, 117, 116, 111, 102, 102, 32, 40, 108,
-111, 119, 45, 112, 97, 115, 115, 32, 97, 116, 32, 109, 97, 120, 105, 109, 117, 109, 32, 119, 105, 116, 104, 32,
-110, 111, 32, 114, 101, 115, 111, 110, 97, 110, 99, 101, 32, 61, 32, 111, 102, 102, 41, 34, 32, 61, 32, 34,
-67, 117, 116, 111, 102, 102, 32, 100, 111, 32, 102, 105, 108, 116, 114, 111, 32, 100, 111, 32, 99, 97, 110, 97,
-108, 32, 40, 112, 97, 115, 115, 97, 45, 98, 97, 105, 120, 97, 32, 110, 111, 32, 109, 195, 161, 120, 105, 109,
-111, 32, 115, 101, 109, 32, 114, 101, 115, 115, 111, 110, 195, 162, 110, 99, 105, 97, 32, 61, 32, 100, 101, 115,
-108, 105, 103, 97, 100, 111, 41, 34, 10, 34, 76, 111, 119, 45, 112, 97, 115, 115, 34, 32, 61, 32, 34, 80,
-97, 115, 115, 97, 45, 98, 97, 105, 120, 97, 34, 10, 34, 72, 105, 103, 104, 45, 112, 97, 115, 115, 34, 32,
-61, 32, 34, 80, 97, 115, 115, 97, 45, 97, 108, 116, 97, 34, 10, 34, 77, 111, 100, 117, 108, 97, 116, 105,
-111, 110, 32, 40, 101, 110, 118, 101, 108, 111, 112, 101, 115, 32, 97, 110, 100, 32, 76, 70, 79, 115, 41, 46,
-46, 46, 34, 32, 61, 32, 34, 77, 111, 100, 117, 108, 97, 195, 167, 195, 163, 111, 32, 40, 101, 110, 118, 101,
-108, 111, 112, 101, 115, 32, 101, 32, 76, 70, 79, 115, 41, 46, 46, 46, 34, 10, 34, 87, 104, 101, 114, 101,
-32, 116, 104, 101, 32, 115, 97, 109, 112, 108, 101, 32, 115, 116, 97, 114, 116, 115, 32, 112, 108, 97, 121, 105,
-110, 103, 32, 40, 102, 114, 97, 99, 116, 105, 111, 110, 32, 111, 102, 32, 116, 104, 101, 32, 102, 105, 108, 101,
-41, 34, 32, 61, 32, 34, 79, 110, 100, 101, 32, 111, 32, 115, 97, 109, 112, 108, 101, 32, 99, 111, 109, 101,
-195, 167, 97, 32, 97, 32, 116, 111, 99, 97, 114, 32, 40, 102, 114, 97, 195, 167, 195, 163, 111, 32, 100, 111,
-32, 97, 114, 113, 117, 105, 118, 111, 41, 34, 10, 34, 48, 32, 61, 32, 111, 102, 102, 46, 32, 79, 116, 104,
-101, 114, 119, 105, 115, 101, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 115, 97, 109, 112, 108, 101, 32,
-108, 97, 115, 116, 115, 32, 116, 104, 105, 115, 32, 109, 97, 110, 121, 32, 98, 101, 97, 116, 115, 32, 97, 110,
-100, 32, 102, 111, 108, 108, 111, 119, 115, 32, 116, 104, 101, 32, 66, 80, 77, 32, 40, 98, 121, 32, 114, 101,
-115, 97, 109, 112, 108, 105, 110, 103, 44, 32, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32, 82, 101, 115, 97,
-109, 112, 108, 101, 32, 109, 111, 100, 101, 41, 34, 32, 61, 32, 34, 48, 32, 61, 32, 100, 101, 115, 108, 105,
-103, 97, 100, 111, 46, 32, 67, 97, 115, 111, 32, 99, 111, 110, 116, 114, 195, 161, 114, 105, 111, 44, 32, 111,
-32, 115, 97, 109, 112, 108, 101, 32, 105, 110, 116, 101, 105, 114, 111, 32, 100, 117, 114, 97, 32, 101, 115, 115,
-97, 32, 113, 117, 97, 110, 116, 105, 100, 97, 100, 101, 32, 100, 101, 32, 98, 101, 97, 116, 115, 32, 101, 32,
-115, 101, 103, 117, 101, 32, 111, 32, 66, 80, 77, 32, 40, 112, 111, 114, 32, 114, 101, 97, 109, 111, 115, 116,
-114, 97, 103, 101, 109, 44, 32, 99, 111, 109, 111, 32, 111, 32, 109, 111, 100, 111, 32, 82, 101, 115, 97, 109,
-112, 108, 101, 32, 100, 111, 32, 70, 76, 41, 34, 10, 34, 48, 32, 61, 32, 116, 104, 101, 32, 119, 104, 111,
-108, 101, 32, 115, 97, 109, 112, 108, 101, 32, 112, 108, 97, 121, 115, 32, 40, 111, 110, 101, 45, 115, 104, 111,
-116, 41, 44, 32, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32, 115, 116, 101, 112, 115, 34, 32, 61, 32, 34,
-48, 32, 61, 32, 111, 32, 115, 97, 109, 112, 108, 101, 32, 116, 111, 99, 97, 32, 105, 110, 116, 101, 105, 114,
-111, 32, 40, 111, 110, 101, 45, 115, 104, 111, 116, 41, 44, 32, 99, 111, 109, 111, 32, 110, 111, 115, 32, 115,
-116, 101, 112, 115, 32, 100, 111, 32, 70, 76, 34, 10, 34, 83, 116, 114, 101, 116, 99, 104, 32, 107, 101, 101,
-112, 105, 110, 103, 32, 112, 105, 116, 99, 104, 34, 32, 61, 32, 34, 83, 116, 114, 101, 116, 99, 104, 32, 109,
-97, 110, 116, 101, 110, 100, 111, 32, 111, 32, 112, 105, 116, 99, 104, 34, 10, 34, 87, 105, 116, 104, 32, 92,
-34, 83, 116, 114, 101, 116, 99, 104, 92, 34, 58, 32, 99, 104, 97, 110, 103, 101, 115, 32, 116, 104, 101, 32,
-108, 101, 110, 103, 116, 104, 32, 119, 105, 116, 104, 111, 117, 116, 32, 99, 104, 97, 110, 103, 105, 110, 103, 32,
-116, 104, 101, 32, 112, 105, 116, 99, 104, 32, 40, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32, 83, 116, 114,
-101, 116, 99, 104, 32, 109, 111, 100, 101, 115, 41, 34, 32, 61, 32, 34, 67, 111, 109, 32, 92, 34, 83, 116,
-114, 101, 116, 99, 104, 92, 34, 58, 32, 109, 117, 100, 97, 32, 97, 32, 100, 117, 114, 97, 195, 167, 195, 163,
-111, 32, 115, 101, 109, 32, 109, 117, 100, 97, 114, 32, 111, 32, 112, 105, 116, 99, 104, 32, 40, 99, 111, 109,
-111, 32, 111, 115, 32, 109, 111, 100, 111, 115, 32, 83, 116, 114, 101, 116, 99, 104, 32, 100, 111, 32, 70, 76,
-41, 34, 10, 34, 82, 101, 118, 101, 114, 115, 101, 34, 32, 61, 32, 34, 82, 101, 118, 101, 114, 115, 111, 34,
-10, 34, 67, 117, 116, 32, 105, 116, 115, 101, 108, 102, 34, 32, 61, 32, 34, 67, 111, 114, 116, 97, 32, 97,
-32, 115, 105, 32, 109, 101, 115, 109, 111, 34, 10, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58, 32,
-116, 104, 101, 32, 110, 111, 116, 101, 32, 115, 116, 97, 114, 116, 115, 32, 102, 114, 111, 109, 32, 116, 104, 101,
-32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 110, 111, 116, 101, 39, 115, 32, 112, 105, 116, 99, 104, 32, 40,
-119, 105, 116, 104, 32, 67, 117, 116, 32, 105, 116, 115, 101, 108, 102, 44, 32, 116, 104, 101, 32, 56, 48, 56,
-32, 103, 108, 105, 100, 101, 41, 34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58, 32,
-97, 32, 110, 111, 116, 97, 32, 99, 111, 109, 101, 195, 167, 97, 32, 110, 111, 32, 112, 105, 116, 99, 104, 32,
-100, 97, 32, 110, 111, 116, 97, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 99, 111, 109, 32, 67, 111,
-114, 116, 97, 32, 97, 32, 115, 105, 32, 109, 101, 115, 109, 111, 44, 32, 111, 32, 103, 108, 105, 100, 101, 32,
-100, 111, 32, 56, 48, 56, 41, 34, 10, 34, 65, 32, 110, 101, 119, 32, 110, 111, 116, 101, 32, 99, 117, 116,
-115, 32, 116, 104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 111, 110, 101, 32, 40, 103, 111, 111, 100,
-32, 102, 111, 114, 32, 104, 105, 45, 104, 97, 116, 115, 32, 97, 110, 100, 32, 56, 48, 56, 115, 41, 34, 32,
-61, 32, 34, 85, 109, 97, 32, 110, 111, 116, 97, 32, 110, 111, 118, 97, 32, 99, 111, 114, 116, 97, 32, 97,
-32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 98, 111, 109, 32, 112, 97, 114, 97, 32, 104, 105, 45, 104,
-97, 116, 115, 32, 101, 32, 56, 48, 56, 115, 41, 34, 10, 34, 83, 97, 109, 112, 108, 101, 114, 32, 115, 101,
-116, 116, 105, 110, 103, 115, 32, 45, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 111, 110, 102, 105, 103, 117,
-114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 115, 97, 109, 112, 108, 101, 114, 32, 45, 32, 123, 48,
-125, 34, 10, 34, 32, 40, 109, 117, 108, 116, 105, 45, 115, 97, 109, 112, 108, 101, 58, 32, 123, 48, 125, 32,
-122, 111, 110, 101, 115, 41, 34, 32, 61, 32, 34, 32, 40, 109, 117, 108, 116, 105, 45, 115, 97, 109, 112, 108,
-101, 58, 32, 123, 48, 125, 32, 122, 111, 110, 97, 115, 41, 34, 10, 34, 79, 115, 99, 32, 123, 48, 125, 34,
-32, 61, 32, 34, 79, 115, 99, 32, 123, 48, 125, 34, 10, 34, 83, 97, 119, 34, 32, 61, 32, 34, 68, 101,
-110, 116, 101, 32, 100, 101, 32, 115, 101, 114, 114, 97, 34, 10, 34, 83, 113, 117, 97, 114, 101, 34, 32, 61,
-32, 34, 81, 117, 97, 100, 114, 97, 100, 97, 34, 10, 34, 78, 111, 105, 115, 101, 34, 32, 61, 32, 34, 82,
-117, 195, 173, 100, 111, 34, 10, 34, 72, 97, 114, 109, 111, 110, 105, 99, 115, 34, 32, 61, 32, 34, 72, 97,
-114, 109, 195, 180, 110, 105, 99, 111, 115, 34, 10, 34, 70, 77, 58, 32, 111, 115, 99, 32, 51, 32, 40, 119,
-104, 105, 99, 104, 32, 115, 116, 111, 112, 115, 32, 115, 111, 117, 110, 100, 105, 110, 103, 41, 32, 109, 111, 100,
-117, 108, 97, 116, 101, 115, 32, 116, 104, 101, 32, 112, 104, 97, 115, 101, 32, 111, 102, 32, 111, 115, 99, 32,
-49, 32, 97, 110, 100, 32, 50, 59, 32, 48, 32, 61, 32, 111, 102, 102, 34, 32, 61, 32, 34, 70, 77, 58,
-32, 111, 32, 111, 115, 99, 32, 51, 32, 40, 113, 117, 101, 32, 112, 97, 114, 97, 32, 100, 101, 32, 115, 111,
-97, 114, 41, 32, 109, 111, 100, 117, 108, 97, 32, 97, 32, 102, 97, 115, 101, 32, 100, 111, 115, 32, 111, 115,
-99, 32, 49, 32, 101, 32, 50, 59, 32, 48, 32, 61, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 34, 10,
-34, 84, 105, 109, 101, 32, 102, 111, 114, 32, 116, 104, 101, 32, 70, 77, 32, 105, 110, 100, 101, 120, 32, 116,
-111, 32, 100, 101, 99, 97, 121, 32, 40, 48, 32, 61, 32, 99, 111, 110, 115, 116, 97, 110, 116, 41, 59, 32,
-116, 104, 101, 32, 98, 114, 105, 103, 104, 116, 110, 101, 115, 115, 32, 102, 97, 100, 101, 115, 32, 108, 105, 107,
-101, 32, 97, 110, 32, 101, 108, 101, 99, 116, 114, 105, 99, 32, 112, 105, 97, 110, 111, 34, 32, 61, 32, 34,
-84, 101, 109, 112, 111, 32, 112, 97, 114, 97, 32, 111, 32, 195, 173, 110, 100, 105, 99, 101, 32, 100, 101, 32,
-70, 77, 32, 100, 101, 99, 97, 105, 114, 32, 40, 48, 32, 61, 32, 99, 111, 110, 115, 116, 97, 110, 116, 101,
-41, 59, 32, 111, 32, 98, 114, 105, 108, 104, 111, 32, 115, 111, 109, 101, 32, 99, 111, 109, 111, 32, 110, 117,
-109, 32, 112, 105, 97, 110, 111, 32, 101, 108, 195, 169, 116, 114, 105, 99, 111, 34, 10, 34, 67, 117, 116, 111,
-102, 102, 32, 102, 111, 108, 108, 111, 119, 115, 32, 116, 104, 101, 32, 110, 111, 116, 101, 58, 32, 99, 117, 116,
-111, 102, 102, 32, 111, 99, 116, 97, 118, 101, 115, 32, 112, 101, 114, 32, 110, 111, 116, 101, 32, 111, 99, 116,
-97, 118, 101, 44, 32, 114, 101, 108, 97, 116, 105, 118, 101, 32, 116, 111, 32, 67, 51, 32, 40, 49, 51, 48,
-46, 56, 32, 72, 122, 41, 34, 32, 61, 32, 34, 79, 32, 99, 117, 116, 111, 102, 102, 32, 115, 101, 103, 117,
-101, 32, 97, 32, 110, 111, 116, 97, 58, 32, 111, 105, 116, 97, 118, 97, 115, 32, 100, 101, 32, 99, 117, 116,
-111, 102, 102, 32, 112, 111, 114, 32, 111, 105, 116, 97, 118, 97, 32, 100, 97, 32, 110, 111, 116, 97, 44, 32,
-101, 109, 32, 114, 101, 108, 97, 195, 167, 195, 163, 111, 32, 97, 111, 32, 67, 51, 32, 40, 49, 51, 48, 44,
-56, 32, 72, 122, 41, 34, 10, 34, 75, 105, 99, 107, 32, 112, 105, 116, 99, 104, 32, 115, 119, 101, 101, 112,
-58, 32, 116, 104, 101, 32, 110, 111, 116, 101, 32, 115, 116, 97, 114, 116, 115, 32, 40, 49, 32, 43, 32, 118,
-97, 108, 117, 101, 41, 32, 116, 105, 109, 101, 115, 32, 104, 105, 103, 104, 101, 114, 32, 97, 110, 100, 32, 102,
-97, 108, 108, 115, 34, 32, 61, 32, 34, 83, 119, 101, 101, 112, 32, 100, 101, 32, 112, 105, 116, 99, 104, 32,
-100, 111, 32, 107, 105, 99, 107, 58, 32, 97, 32, 110, 111, 116, 97, 32, 99, 111, 109, 101, 195, 167, 97, 32,
-40, 49, 32, 43, 32, 118, 97, 108, 111, 114, 41, 32, 118, 101, 122, 101, 115, 32, 109, 97, 105, 115, 32, 97,
-103, 117, 100, 97, 32, 101, 32, 100, 101, 115, 99, 101, 34, 10, 34, 83, 119, 101, 101, 112, 32, 116, 105, 109,
-101, 32, 99, 111, 110, 115, 116, 97, 110, 116, 34, 32, 61, 32, 34, 67, 111, 110, 115, 116, 97, 110, 116, 101,
-32, 100, 101, 32, 116, 101, 109, 112, 111, 32, 100, 111, 32, 115, 119, 101, 101, 112, 34, 10, 34, 51, 45, 98,
-97, 110, 100, 32, 116, 111, 110, 101, 32, 97, 102, 116, 101, 114, 32, 116, 104, 101, 32, 102, 105, 108, 116, 101,
-114, 32, 40, 108, 111, 119, 32, 60, 32, 49, 55, 56, 32, 72, 122, 32, 60, 32, 109, 105, 100, 32, 60, 32,
-49, 46, 49, 56, 32, 107, 72, 122, 32, 60, 32, 104, 105, 103, 104, 41, 59, 32, 49, 32, 61, 32, 117, 110,
-99, 104, 97, 110, 103, 101, 100, 34, 32, 61, 32, 34, 84, 105, 109, 98, 114, 101, 32, 100, 101, 32, 51, 32,
-98, 97, 110, 100, 97, 115, 32, 100, 101, 112, 111, 105, 115, 32, 100, 111, 32, 102, 105, 108, 116, 114, 111, 32,
-40, 103, 114, 97, 118, 101, 115, 32, 60, 32, 49, 55, 56, 32, 72, 122, 32, 60, 32, 109, 195, 169, 100, 105,
-111, 115, 32, 60, 32, 49, 44, 49, 56, 32, 107, 72, 122, 32, 60, 32, 97, 103, 117, 100, 111, 115, 41, 59,
-32, 49, 32, 61, 32, 115, 101, 109, 32, 97, 108, 116, 101, 114, 97, 195, 167, 195, 163, 111, 34, 10, 34, 82,
-105, 110, 103, 34, 32, 61, 32, 34, 82, 105, 110, 103, 34, 10, 34, 87, 105, 116, 104, 32, 65, 77, 32, 111,
-110, 58, 32, 114, 105, 110, 103, 32, 109, 111, 100, 117, 108, 97, 116, 105, 111, 110, 44, 32, 40, 111, 115, 99,
-32, 49, 32, 43, 32, 50, 41, 32, 195, 151, 32, 40, 49, 32, 226, 136, 146, 32, 108, 101, 118, 101, 108, 32,
-43, 32, 111, 115, 99, 32, 51, 41, 44, 32, 108, 105, 107, 101, 32, 83, 121, 116, 114, 117, 115, 39, 115, 32,
-82, 77, 34, 32, 61, 32, 34, 67, 111, 109, 32, 65, 77, 32, 108, 105, 103, 97, 100, 111, 58, 32, 109, 111,
-100, 117, 108, 97, 195, 167, 195, 163, 111, 32, 101, 109, 32, 97, 110, 101, 108, 44, 32, 40, 111, 115, 99, 32,
-49, 32, 43, 32, 50, 41, 32, 195, 151, 32, 40, 49, 32, 226, 136, 146, 32, 110, 195, 173, 118, 101, 108, 32,
-43, 32, 111, 115, 99, 32, 51, 41, 44, 32, 99, 111, 109, 111, 32, 111, 32, 82, 77, 32, 100, 111, 32, 83,
-121, 116, 114, 117, 115, 34, 10, 34, 83, 101, 109, 105, 116, 111, 110, 101, 34, 32, 61, 32, 34, 83, 101, 109,
-105, 116, 111, 109, 34, 10, 34, 70, 105, 110, 101, 34, 32, 61, 32, 34, 70, 105, 110, 111, 34, 10, 34, 76,
-101, 118, 101, 108, 34, 32, 61, 32, 34, 78, 195, 173, 118, 101, 108, 34, 10, 34, 80, 111, 114, 116, 97, 32,
-116, 105, 109, 101, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 32, 112, 111, 114, 116, 97, 34, 10, 34, 70,
-77, 34, 32, 61, 32, 34, 70, 77, 34, 10, 34, 70, 77, 32, 100, 101, 99, 97, 121, 34, 32, 61, 32, 34,
-68, 101, 99, 97, 121, 32, 70, 77, 34, 10, 34, 75, 101, 121, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34,
-75, 101, 121, 116, 114, 97, 99, 107, 34, 10, 34, 83, 119, 101, 101, 112, 34, 32, 61, 32, 34, 83, 119, 101,
-101, 112, 34, 10, 34, 83, 119, 101, 101, 112, 32, 116, 105, 109, 101, 34, 32, 61, 32, 34, 84, 101, 109, 112,
-111, 32, 115, 119, 101, 101, 112, 34, 10, 34, 80, 114, 101, 115, 101, 116, 115, 46, 46, 46, 34, 32, 61, 32,
-34, 80, 114, 101, 115, 101, 116, 115, 46, 46, 46, 34, 10, 34, 70, 76, 32, 112, 114, 101, 115, 101, 116, 115,
-46, 46, 46, 34, 32, 61, 32, 34, 80, 114, 101, 115, 101, 116, 115, 32, 100, 111, 32, 70, 76, 46, 46, 46,
-34, 10, 34, 84, 104, 101, 32, 51, 120, 32, 79, 115, 99, 32, 99, 104, 97, 110, 110, 101, 108, 32, 112, 114,
-101, 115, 101, 116, 115, 32, 116, 104, 97, 116, 32, 115, 104, 105, 112, 32, 119, 105, 116, 104, 32, 70, 76, 32,
-83, 116, 117, 100, 105, 111, 32, 40, 80, 97, 116, 99, 104, 101, 115, 92, 92, 67, 104, 97, 110, 110, 101, 108,
-32, 112, 114, 101, 115, 101, 116, 115, 92, 92, 51, 120, 32, 79, 115, 99, 41, 34, 32, 61, 32, 34, 79, 115,
-32, 112, 114, 101, 115, 101, 116, 115, 32, 100, 101, 32, 99, 97, 110, 97, 108, 32, 100, 111, 32, 51, 120, 32,
-79, 115, 99, 32, 113, 117, 101, 32, 118, 195, 170, 109, 32, 99, 111, 109, 32, 111, 32, 70, 76, 32, 83, 116,
-117, 100, 105, 111, 32, 40, 80, 97, 116, 99, 104, 101, 115, 92, 92, 67, 104, 97, 110, 110, 101, 108, 32, 112,
-114, 101, 115, 101, 116, 115, 92, 92, 51, 120, 32, 79, 115, 99, 41, 34, 10, 34, 70, 105, 108, 116, 101, 114,
-32, 116, 121, 112, 101, 34, 32, 61, 32, 34, 84, 105, 112, 111, 32, 100, 101, 32, 102, 105, 108, 116, 114, 111,
-34, 10, 34, 79, 115, 99, 32, 51, 32, 109, 111, 100, 117, 108, 97, 116, 101, 115, 32, 116, 104, 101, 32, 97,
-109, 112, 108, 105, 116, 117, 100, 101, 32, 111, 102, 32, 111, 115, 99, 32, 49, 32, 97, 110, 100, 32, 50, 32,
-40, 108, 105, 107, 101, 32, 51, 120, 32, 79, 115, 99, 39, 115, 32, 65, 77, 41, 59, 32, 105, 116, 115, 32,
-108, 101, 118, 101, 108, 32, 105, 115, 32, 116, 104, 101, 32, 100, 101, 112, 116, 104, 34, 32, 61, 32, 34, 79,
-32, 111, 115, 99, 32, 51, 32, 109, 111, 100, 117, 108, 97, 32, 97, 32, 97, 109, 112, 108, 105, 116, 117, 100,
-101, 32, 100, 111, 115, 32, 111, 115, 99, 32, 49, 32, 101, 32, 50, 32, 40, 99, 111, 109, 111, 32, 111, 32,
-65, 77, 32, 100, 111, 32, 51, 120, 32, 79, 115, 99, 41, 59, 32, 111, 32, 110, 195, 173, 118, 101, 108, 32,
-100, 101, 108, 101, 32, 195, 169, 32, 97, 32, 112, 114, 111, 102, 117, 110, 100, 105, 100, 97, 100, 101, 34, 10,
-34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 32, 116, 105, 109, 101, 44, 32, 105, 110, 32, 98, 101, 97,
-116, 115, 32, 40, 97, 112, 112, 108, 105, 101, 115, 32, 116, 111, 32, 116, 104, 101, 32, 80, 111, 114, 116, 97,
-32, 98, 117, 116, 116, 111, 110, 32, 97, 110, 100, 32, 116, 111, 32, 110, 111, 116, 101, 115, 32, 109, 97, 114,
-107, 101, 100, 32, 112, 111, 114, 116, 97, 41, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 32, 100, 101, 32,
-112, 111, 114, 116, 97, 109, 101, 110, 116, 111, 44, 32, 101, 109, 32, 98, 101, 97, 116, 115, 32, 40, 118, 97,
-108, 101, 32, 112, 97, 114, 97, 32, 111, 32, 98, 111, 116, 195, 163, 111, 32, 80, 111, 114, 116, 97, 32, 101,
-32, 112, 97, 114, 97, 32, 110, 111, 116, 97, 115, 32, 109, 97, 114, 99, 97, 100, 97, 115, 32, 99, 111, 109,
-32, 112, 111, 114, 116, 97, 41, 34, 10, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58, 32, 116, 104,
-101, 32, 110, 101, 119, 32, 110, 111, 116, 101, 32, 103, 108, 105, 100, 101, 115, 32, 102, 114, 111, 109, 32, 116,
-104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 111, 110, 101, 32, 40, 110, 111, 116, 101, 115, 32, 109,
-97, 114, 107, 101, 100, 32, 112, 111, 114, 116, 97, 32, 105, 110, 118, 101, 114, 116, 32, 116, 104, 105, 115, 41,
-34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58, 32, 97, 32, 110, 111, 116, 97, 32,
-110, 111, 118, 97, 32, 100, 101, 115, 108, 105, 122, 97, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 97,
-32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 110, 111, 116, 97, 115, 32, 109, 97, 114, 99, 97, 100, 97,
-115, 32, 99, 111, 109, 32, 112, 111, 114, 116, 97, 32, 105, 110, 118, 101, 114, 116, 101, 109, 32, 105, 115, 115,
-111, 41, 34, 10, 34, 83, 105, 110, 103, 108, 101, 32, 118, 111, 105, 99, 101, 58, 32, 116, 104, 101, 32, 110,
-101, 119, 32, 110, 111, 116, 101, 32, 116, 97, 107, 101, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 111,
-110, 101, 32, 99, 117, 114, 114, 101, 110, 116, 108, 121, 32, 115, 111, 117, 110, 100, 105, 110, 103, 32, 40, 98,
-97, 115, 115, 101, 115, 32, 97, 110, 100, 32, 108, 101, 97, 100, 115, 41, 34, 32, 61, 32, 34, 86, 111, 122,
-32, 195, 186, 110, 105, 99, 97, 58, 32, 97, 32, 110, 111, 116, 97, 32, 110, 111, 118, 97, 32, 115, 117, 98,
-115, 116, 105, 116, 117, 105, 32, 97, 32, 113, 117, 101, 32, 101, 115, 116, 195, 161, 32, 115, 111, 97, 110, 100,
-111, 32, 40, 98, 97, 105, 120, 111, 115, 32, 101, 32, 108, 101, 97, 100, 115, 41, 34, 10, 34, 70, 76, 32,
-112, 114, 101, 115, 101, 116, 115, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 32, 40, 105, 110, 115, 116, 97,
-108, 108, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 111, 114, 32, 99, 104, 101, 99, 107, 32, 116, 104,
-101, 32, 68, 97, 116, 97, 92, 92, 80, 97, 116, 99, 104, 101, 115, 32, 102, 111, 108, 100, 101, 114, 41, 46,
-34, 32, 61, 32, 34, 80, 114, 101, 115, 101, 116, 115, 32, 100, 111, 32, 70, 76, 32, 110, 195, 163, 111, 32,
-101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 115, 32, 40, 105, 110, 115, 116, 97, 108, 101, 32, 111, 32, 70,
-76, 32, 83, 116, 117, 100, 105, 111, 32, 111, 117, 32, 118, 101, 114, 105, 102, 105, 113, 117, 101, 32, 97, 32,
-112, 97, 115, 116, 97, 32, 68, 97, 116, 97, 92, 92, 80, 97, 116, 99, 104, 101, 115, 41, 46, 34, 10, 34,
-84, 104, 105, 115, 32, 112, 114, 101, 115, 101, 116, 32, 105, 115, 32, 110, 111, 116, 32, 102, 111, 114, 32, 97,
-32, 115, 121, 110, 116, 104, 32, 76, 89, 78, 88, 32, 99, 111, 110, 118, 101, 114, 116, 115, 44, 32, 111, 114,
-32, 105, 116, 32, 99, 111, 117, 108, 100, 32, 110, 111, 116, 32, 98, 101, 32, 114, 101, 97, 100, 46, 34, 32,
-61, 32, 34, 69, 115, 116, 101, 32, 112, 114, 101, 115, 101, 116, 32, 110, 195, 163, 111, 32, 195, 169, 32, 100,
-101, 32, 117, 109, 32, 115, 121, 110, 116, 104, 32, 113, 117, 101, 32, 111, 32, 76, 89, 78, 88, 32, 99, 111,
-110, 118, 101, 114, 116, 101, 44, 32, 111, 117, 32, 110, 195, 163, 111, 32, 112, 195, 180, 100, 101, 32, 115, 101,
-114, 32, 108, 105, 100, 111, 46, 34, 10, 34, 83, 121, 110, 116, 104, 32, 115, 101, 116, 116, 105, 110, 103, 115,
-32, 45, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167, 195, 181,
-101, 115, 32, 100, 111, 32, 115, 121, 110, 116, 104, 32, 45, 32, 123, 48, 125, 34, 10, 34, 67, 104, 97, 110,
-110, 101, 108, 32, 115, 101, 116, 116, 105, 110, 103, 115, 34, 32, 61, 32, 34, 67, 111, 110, 102, 105, 103, 117,
-114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 99, 97, 110, 97, 108, 34, 10, 34, 69, 120, 112, 111,
-114, 116, 105, 110, 103, 32, 97, 117, 100, 105, 111, 46, 46, 46, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114,
-116, 97, 110, 100, 111, 32, 195, 161, 117, 100, 105, 111, 46, 46, 46, 34, 10, 34, 67, 111, 117, 108, 100, 32,
-110, 111, 116, 32, 114, 101, 110, 100, 101, 114, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32,
-112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 114, 101, 110, 100, 101, 114, 105, 122, 97, 114, 34, 10, 34, 69,
-120, 112, 111, 114, 116, 32, 99, 111, 109, 112, 108, 101, 116, 101, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114,
-116, 97, 195, 167, 195, 163, 111, 32, 99, 111, 110, 99, 108, 117, 195, 173, 100, 97, 34, 10, 34, 80, 101, 97,
-107, 58, 32, 123, 48, 125, 32, 100, 66, 70, 83, 34, 32, 61, 32, 34, 80, 105, 99, 111, 58, 32, 123, 48,
-125, 32, 100, 66, 70, 83, 34, 10, 34, 67, 111, 117, 108, 100, 32, 110, 111, 116, 32, 101, 120, 112, 111, 114,
-116, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108,
-32, 101, 120, 112, 111, 114, 116, 97, 114, 34, 10, 34, 69, 120, 112, 111, 114, 116, 105, 110, 103, 32, 115, 116,
-101, 109, 115, 46, 46, 46, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 110, 100, 111, 32, 115, 116,
-101, 109, 115, 46, 46, 46, 34, 10, 34, 83, 116, 101, 109, 115, 32, 101, 120, 112, 111, 114, 116, 101, 100, 34,
-32, 61, 32, 34, 83, 116, 101, 109, 115, 32, 101, 120, 112, 111, 114, 116, 97, 100, 111, 115, 34, 10, 34, 123,
-48, 125, 32, 102, 105, 108, 101, 40, 115, 41, 32, 105, 110, 32, 123, 49, 125, 34, 32, 61, 32, 34, 123, 48,
-125, 32, 97, 114, 113, 117, 105, 118, 111, 40, 115, 41, 32, 101, 109, 32, 123, 49, 125, 34, 10, 34, 87, 65,
-86, 32, 49, 54, 32, 98, 105, 116, 115, 34, 32, 61, 32, 34, 87, 65, 86, 32, 49, 54, 32, 98, 105, 116,
-115, 34, 10, 34, 87, 65, 86, 32, 50, 52, 32, 98, 105, 116, 115, 34, 32, 61, 32, 34, 87, 65, 86, 32,
-50, 52, 32, 98, 105, 116, 115, 34, 10, 34, 87, 65, 86, 32, 51, 50, 32, 98, 105, 116, 115, 32, 40, 102,
-108, 111, 97, 116, 41, 34, 32, 61, 32, 34, 87, 65, 86, 32, 51, 50, 32, 98, 105, 116, 115, 32, 40, 102,
-108, 111, 97, 116, 41, 34, 10, 34, 70, 76, 65, 67, 32, 50, 52, 32, 98, 105, 116, 115, 34, 32, 61, 32,
-34, 70, 76, 65, 67, 32, 50, 52, 32, 98, 105, 116, 115, 34, 10, 34, 70, 117, 108, 108, 32, 115, 111, 110,
-103, 32, 40, 80, 108, 97, 121, 108, 105, 115, 116, 41, 34, 32, 61, 32, 34, 77, 195, 186, 115, 105, 99, 97,
-32, 105, 110, 116, 101, 105, 114, 97, 32, 40, 80, 108, 97, 121, 108, 105, 115, 116, 41, 34, 10, 34, 67, 117,
-114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 80, 97, 116, 116, 101, 114,
-110, 32, 97, 116, 117, 97, 108, 34, 10, 34, 78, 111, 32, 116, 97, 105, 108, 34, 32, 61, 32, 34, 83, 101,
-109, 32, 99, 97, 117, 100, 97, 34, 10, 34, 84, 97, 105, 108, 32, 117, 112, 32, 116, 111, 32, 123, 48, 125,
-32, 115, 34, 32, 61, 32, 34, 67, 97, 117, 100, 97, 32, 100, 101, 32, 97, 116, 195, 169, 32, 123, 48, 125,
-32, 115, 34, 10, 34, 70, 111, 114, 109, 97, 116, 34, 32, 61, 32, 34, 70, 111, 114, 109, 97, 116, 111, 34,
-10, 34, 83, 97, 109, 112, 108, 101, 32, 114, 97, 116, 101, 34, 32, 61, 32, 34, 84, 97, 120, 97, 34, 10,
-34, 69, 120, 112, 111, 114, 116, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 114, 34, 10, 34, 84,
-97, 105, 108, 34, 32, 61, 32, 34, 67, 97, 117, 100, 97, 34, 10, 34, 79, 110, 101, 32, 102, 105, 108, 101,
-32, 112, 101, 114, 32, 109, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 32, 40, 115, 116, 101, 109, 115,
-41, 34, 32, 61, 32, 34, 85, 109, 32, 97, 114, 113, 117, 105, 118, 111, 32, 112, 111, 114, 32, 105, 110, 115,
-101, 114, 116, 32, 100, 111, 32, 109, 105, 120, 101, 114, 32, 40, 115, 116, 101, 109, 115, 41, 34, 10, 34, 69,
-120, 112, 111, 114, 116, 32, 97, 117, 100, 105, 111, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 114,
-32, 195, 161, 117, 100, 105, 111, 34, 10, 34, 69, 120, 112, 111, 114, 116, 46, 46, 46, 34, 32, 61, 32, 34,
-69, 120, 112, 111, 114, 116, 97, 114, 46, 46, 46, 34, 10, 34, 82, 101, 110, 100, 101, 114, 105, 110, 103, 32,
-105, 110, 115, 101, 114, 116, 32, 116, 111, 32, 97, 117, 100, 105, 111, 46, 46, 46, 34, 32, 61, 32, 34, 82,
-101, 110, 100, 101, 114, 105, 122, 97, 110, 100, 111, 32, 105, 110, 115, 101, 114, 116, 32, 101, 109, 32, 195, 161,
-117, 100, 105, 111, 46, 46, 46, 34, 10, 34, 83, 99, 97, 110, 110, 105, 110, 103, 32, 102, 111, 114, 32, 112,
-108, 117, 103, 105, 110, 115, 32, 40, 86, 83, 84, 51, 32, 97, 110, 100, 32, 67, 76, 65, 80, 41, 46, 46,
-46, 34, 32, 61, 32, 34, 80, 114, 111, 99, 117, 114, 97, 110, 100, 111, 32, 112, 108, 117, 103, 105, 110, 115,
-32, 40, 86, 83, 84, 51, 32, 101, 32, 67, 76, 65, 80, 41, 46, 46, 46, 34, 10, 34, 40, 110, 111, 32,
-112, 108, 117, 103, 105, 110, 115, 32, 102, 111, 117, 110, 100, 59, 32, 117, 115, 101, 32, 92, 34, 83, 99, 97,
-110, 32, 102, 111, 114, 32, 112, 108, 117, 103, 105, 110, 115, 92, 34, 41, 34, 32, 61, 32, 34, 40, 110, 101,
-110, 104, 117, 109, 32, 112, 108, 117, 103, 105, 110, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 59, 32,
-117, 115, 101, 32, 92, 34, 80, 114, 111, 99, 117, 114, 97, 114, 32, 112, 108, 117, 103, 105, 110, 115, 92, 34,
-41, 34, 10, 34, 83, 99, 97, 110, 32, 102, 111, 114, 32, 112, 108, 117, 103, 105, 110, 115, 32, 40, 86, 83,
-84, 51, 32, 97, 110, 100, 32, 67, 76, 65, 80, 41, 46, 46, 46, 34, 32, 61, 32, 34, 80, 114, 111, 99,
-117, 114, 97, 114, 32, 112, 108, 117, 103, 105, 110, 115, 32, 40, 86, 83, 84, 51, 32, 101, 32, 67, 76, 65,
-80, 41, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 80, 108, 117, 103,
-105, 110, 115, 34, 10, 34, 123, 48, 125, 32, 110, 101, 119, 32, 112, 108, 117, 103, 105, 110, 40, 115, 41, 32,
-102, 111, 117, 110, 100, 46, 34, 32, 61, 32, 34, 123, 48, 125, 32, 112, 108, 117, 103, 105, 110, 40, 115, 41,
-32, 110, 111, 118, 111, 40, 115, 41, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 40, 115, 41, 46, 34,
-10, 10, 35, 32, 45, 45, 45, 32, 74, 85, 67, 69, 39, 115, 32, 111, 119, 110, 32, 115, 116, 114, 105, 110,
-103, 115, 32, 40, 97, 117, 100, 105, 111, 32, 115, 101, 116, 116, 105, 110, 103, 115, 32, 100, 105, 97, 108, 111,
-103, 41, 10, 34, 40, 110, 111, 32, 97, 117, 100, 105, 111, 32, 105, 110, 112, 117, 116, 32, 99, 104, 97, 110,
-110, 101, 108, 115, 32, 102, 111, 117, 110, 100, 41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104, 117, 109, 32,
-99, 97, 110, 97, 108, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 100, 101, 32, 195, 161, 117, 100,
-105, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 41, 34, 10, 34, 40, 110, 111, 32, 97, 117, 100,
-105, 111, 32, 111, 117, 116, 112, 117, 116, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 102, 111, 117, 110, 100,
-41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104, 117, 109, 32, 99, 97, 110, 97, 108, 32, 100, 101, 32, 115,
-97, 195, 173, 100, 97, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97,
-100, 111, 41, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 77, 73, 68, 73, 32, 105, 110, 112, 117, 116, 115,
-58, 34, 32, 61, 32, 34, 69, 110, 116, 114, 97, 100, 97, 115, 32, 77, 73, 68, 73, 32, 97, 116, 105, 118,
-97, 115, 58, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 105, 110, 112, 117, 116, 32, 99, 104, 97, 110, 110,
-101, 108, 115, 58, 34, 32, 61, 32, 34, 67, 97, 110, 97, 105, 115, 32, 100, 101, 32, 101, 110, 116, 114, 97,
-100, 97, 32, 97, 116, 105, 118, 111, 115, 58, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 111, 117, 116, 112,
-117, 116, 32, 99, 104, 97, 110, 110, 101, 108, 115, 58, 34, 32, 61, 32, 34, 67, 97, 110, 97, 105, 115, 32,
-100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 97, 116, 105, 118, 111, 115, 58, 34, 10, 34, 65, 117, 100, 105,
-111, 32, 98, 117, 102, 102, 101, 114, 32, 115, 105, 122, 101, 58, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110,
-104, 111, 32, 100, 111, 32, 98, 117, 102, 102, 101, 114, 58, 34, 10, 34, 65, 117, 100, 105, 111, 32, 100, 101,
-118, 105, 99, 101, 32, 116, 121, 112, 101, 58, 34, 32, 61, 32, 34, 84, 105, 112, 111, 32, 100, 101, 32, 100,
-105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 58, 34, 10, 34, 66, 108, 117, 101, 116, 111, 111, 116, 104, 32,
-77, 73, 68, 73, 34, 32, 61, 32, 34, 77, 73, 68, 73, 32, 66, 108, 117, 101, 116, 111, 111, 116, 104, 34,
-10, 34, 67, 111, 110, 116, 114, 111, 108, 32, 80, 97, 110, 101, 108, 34, 32, 61, 32, 34, 80, 97, 105, 110,
-101, 108, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 101, 34, 10, 34, 68, 101, 118, 105, 99, 101, 58,
-34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 58, 34, 10, 34, 69, 114, 114, 111,
-114, 32, 119, 104, 101, 110, 32, 116, 114, 121, 105, 110, 103, 32, 116, 111, 32, 111, 112, 101, 110, 32, 97, 117,
-100, 105, 111, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 69, 114, 114, 111, 32, 97, 111, 32,
-116, 101, 110, 116, 97, 114, 32, 97, 98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105,
-118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 33, 34, 10, 34, 73, 110, 112, 117, 116, 58, 34, 32,
-61, 32, 34, 69, 110, 116, 114, 97, 100, 97, 58, 34, 10, 34, 77, 73, 68, 73, 32, 79, 117, 116, 112, 117,
-116, 58, 34, 32, 61, 32, 34, 83, 97, 195, 173, 100, 97, 32, 77, 73, 68, 73, 58, 34, 10, 34, 78, 111,
-32, 77, 73, 68, 73, 32, 105, 110, 112, 117, 116, 115, 32, 97, 118, 97, 105, 108, 97, 98, 108, 101, 34, 32,
-61, 32, 34, 78, 101, 110, 104, 117, 109, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 77, 73, 68, 73, 32,
-100, 105, 115, 112, 111, 110, 195, 173, 118, 101, 108, 34, 10, 34, 79, 112, 101, 110, 115, 32, 116, 104, 101, 32,
-100, 101, 118, 105, 99, 101, 39, 115, 32, 111, 119, 110, 32, 99, 111, 110, 116, 114, 111, 108, 32, 112, 97, 110,
-101, 108, 34, 32, 61, 32, 34, 65, 98, 114, 101, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 100, 101, 32,
-99, 111, 110, 116, 114, 111, 108, 101, 32, 100, 111, 32, 112, 114, 195, 179, 112, 114, 105, 111, 32, 100, 105, 115,
-112, 111, 115, 105, 116, 105, 118, 111, 34, 10, 34, 79, 117, 116, 112, 117, 116, 58, 34, 32, 61, 32, 34, 83,
-97, 195, 173, 100, 97, 58, 34, 10, 34, 80, 108, 97, 121, 115, 32, 97, 32, 116, 101, 115, 116, 32, 116, 111,
-110, 101, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32, 117, 109, 32, 116, 111, 109, 32, 100, 101, 32, 116, 101,
-115, 116, 101, 34, 10, 34, 82, 101, 115, 101, 116, 32, 68, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 82,
-101, 105, 110, 105, 99, 105, 97, 114, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 34, 10, 34, 82,
-101, 115, 101, 116, 115, 32, 116, 104, 101, 32, 97, 117, 100, 105, 111, 32, 105, 110, 116, 101, 114, 102, 97, 99,
-101, 32, 45, 32, 115, 111, 109, 101, 116, 105, 109, 101, 115, 32, 110, 101, 101, 100, 101, 100, 32, 97, 102, 116,
-101, 114, 32, 99, 104, 97, 110, 103, 105, 110, 103, 32, 97, 32, 100, 101, 118, 105, 99, 101, 39, 115, 32, 112,
-114, 111, 112, 101, 114, 116, 105, 101, 115, 32, 105, 110, 32, 105, 116, 115, 32, 99, 117, 115, 116, 111, 109, 32,
-99, 111, 110, 116, 114, 111, 108, 32, 112, 97, 110, 101, 108, 34, 32, 61, 32, 34, 82, 101, 105, 110, 105, 99,
-105, 97, 32, 97, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111,
-32, 45, 32, 195, 160, 115, 32, 118, 101, 122, 101, 115, 32, 110, 101, 99, 101, 115, 115, 195, 161, 114, 105, 111,
-32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 109, 117, 100, 97, 114, 32, 112, 114, 111, 112, 114, 105, 101,
-100, 97, 100, 101, 115, 32, 100, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 110, 111, 32,
-112, 97, 105, 110, 101, 108, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 101, 32, 100, 101, 108, 101, 34,
-10, 34, 83, 97, 109, 112, 108, 101, 32, 114, 97, 116, 101, 58, 34, 32, 61, 32, 34, 84, 97, 120, 97, 32,
-100, 101, 32, 97, 109, 111, 115, 116, 114, 97, 103, 101, 109, 58, 34, 10, 34, 83, 99, 97, 110, 32, 102, 111,
-114, 32, 98, 108, 117, 101, 116, 111, 111, 116, 104, 32, 77, 73, 68, 73, 32, 100, 101, 118, 105, 99, 101, 115,
-34, 32, 61, 32, 34, 80, 114, 111, 99, 117, 114, 97, 114, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118,
-111, 115, 32, 77, 73, 68, 73, 32, 66, 108, 117, 101, 116, 111, 111, 116, 104, 34, 10, 34, 83, 104, 111, 119,
-32, 97, 100, 118, 97, 110, 99, 101, 100, 32, 115, 101, 116, 116, 105, 110, 103, 115, 46, 46, 46, 34, 32, 61,
-32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 99, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167, 195, 181, 101,
-115, 32, 97, 118, 97, 110, 195, 167, 97, 100, 97, 115, 46, 46, 46, 34, 10, 34, 84, 101, 115, 116, 34, 32,
-61, 32, 34, 84, 101, 115, 116, 97, 114, 34, 10, 34, 84, 104, 101, 32, 105, 110, 112, 117, 116, 32, 97, 110,
-100, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 115, 32, 100, 111, 110, 39, 116, 32, 115,
-104, 97, 114, 101, 32, 97, 32, 99, 111, 109, 109, 111, 110, 32, 115, 97, 109, 112, 108, 101, 32, 114, 97, 116,
-101, 33, 34, 32, 61, 32, 34, 79, 115, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 115, 32, 100,
-101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 101, 32, 115, 97, 195, 173, 100, 97, 32, 110, 195, 163, 111, 32,
-116, 195, 170, 109, 32, 117, 109, 97, 32, 116, 97, 120, 97, 32, 100, 101, 32, 97, 109, 111, 115, 116, 114, 97,
-103, 101, 109, 32, 101, 109, 32, 99, 111, 109, 117, 109, 33, 34, 10, 34, 67, 111, 117, 108, 100, 110, 39, 116,
-32, 111, 112, 101, 110, 32, 116, 104, 101, 32, 105, 110, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 33, 34,
-32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 97,
-98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110,
-116, 114, 97, 100, 97, 33, 34, 10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 111, 112, 101, 110, 32, 116,
-104, 101, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 78, 195,
-163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 97, 98, 114, 105, 114, 32, 111,
-32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 33, 34,
-10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 111, 112, 101, 110, 32, 116, 104, 101, 32, 111, 117, 116, 112,
-117, 116, 32, 100, 101, 118, 105, 99, 101, 32, 40, 98, 117, 102, 102, 101, 114, 32, 115, 105, 122, 101, 32, 109,
-105, 115, 109, 97, 116, 99, 104, 41, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111,
-115, 115, 195, 173, 118, 101, 108, 32, 97, 98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116,
-105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 40, 116, 97, 109, 97, 110, 104, 111, 32, 100,
-101, 32, 98, 117, 102, 102, 101, 114, 32, 105, 110, 99, 111, 109, 112, 97, 116, 195, 173, 118, 101, 108, 41, 34,
-10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 115, 116, 97, 114, 116, 32, 116, 104, 101, 32, 105, 110, 112,
+105, 110, 105, 99, 105, 97, 109, 32, 97, 115, 32, 118, 111, 122, 101, 115, 41, 34, 10, 34, 79, 103, 117, 110,
+32, 226, 128, 148, 32, 70, 76, 39, 115, 32, 101, 110, 103, 105, 110, 101, 32, 119, 105, 116, 104, 32, 105, 116,
+115, 32, 101, 102, 102, 101, 99, 116, 115, 32, 40, 83, 101, 101, 100, 32, 50, 32, 82, 97, 110, 100, 111, 109,
+32, 105, 115, 32, 97, 32, 102, 105, 120, 101, 100, 32, 100, 114, 97, 119, 32, 112, 101, 114, 32, 99, 104, 97,
+110, 110, 101, 108, 41, 34, 32, 61, 32, 34, 79, 103, 117, 110, 32, 226, 128, 148, 32, 109, 111, 116, 111, 114,
+32, 100, 111, 32, 70, 76, 32, 99, 111, 109, 32, 115, 101, 117, 115, 32, 101, 102, 101, 105, 116, 111, 115, 32,
+40, 83, 101, 101, 100, 32, 50, 32, 82, 97, 110, 100, 111, 109, 32, 195, 169, 32, 117, 109, 32, 115, 111, 114,
+116, 101, 105, 111, 32, 102, 105, 120, 111, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 41, 34, 10, 34, 66,
+111, 111, 66, 97, 115, 115, 32, 226, 128, 148, 32, 70, 76, 39, 115, 32, 101, 110, 103, 105, 110, 101, 44, 32,
+105, 116, 115, 32, 115, 111, 117, 110, 100, 32, 114, 101, 97, 100, 32, 102, 114, 111, 109, 32, 121, 111, 117, 114,
+32, 70, 76, 32, 105, 110, 115, 116, 97, 108, 108, 97, 116, 105, 111, 110, 32, 40, 107, 110, 111, 98, 115, 58,
+32, 51, 45, 98, 97, 110, 100, 32, 69, 81, 41, 34, 32, 61, 32, 34, 66, 111, 111, 66, 97, 115, 115, 32,
+226, 128, 148, 32, 109, 111, 116, 111, 114, 32, 100, 111, 32, 70, 76, 44, 32, 115, 111, 109, 32, 108, 105, 100,
+111, 32, 100, 97, 32, 115, 117, 97, 32, 105, 110, 115, 116, 97, 108, 97, 195, 167, 195, 163, 111, 32, 100, 111,
+32, 70, 76, 32, 40, 107, 110, 111, 98, 115, 58, 32, 69, 81, 32, 100, 101, 32, 51, 32, 98, 97, 110, 100,
+97, 115, 41, 34, 10, 34, 83, 97, 107, 117, 114, 97, 32, 226, 128, 148, 32, 112, 104, 121, 115, 105, 99, 97,
+108, 32, 115, 116, 114, 105, 110, 103, 115, 32, 40, 70, 76, 39, 115, 32, 101, 110, 103, 105, 110, 101, 59, 32,
+110, 101, 119, 32, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32, 97, 112, 112, 108, 121, 32, 116, 111, 32,
+116, 104, 101, 32, 110, 101, 120, 116, 32, 110, 111, 116, 101, 41, 34, 32, 61, 32, 34, 83, 97, 107, 117, 114,
+97, 32, 226, 128, 148, 32, 99, 111, 114, 100, 97, 115, 32, 102, 195, 173, 115, 105, 99, 97, 115, 32, 40, 109,
+111, 116, 111, 114, 32, 100, 111, 32, 70, 76, 59, 32, 110, 111, 118, 111, 115, 32, 112, 97, 114, 195, 162, 109,
+101, 116, 114, 111, 115, 32, 118, 97, 108, 101, 109, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 97, 32,
+112, 114, 195, 179, 120, 105, 109, 97, 32, 110, 111, 116, 97, 41, 34, 10, 34, 68, 114, 117, 109, 112, 97, 100,
+32, 226, 128, 148, 32, 112, 104, 121, 115, 105, 99, 97, 108, 32, 100, 114, 117, 109, 32, 40, 70, 76, 39, 115,
+32, 101, 110, 103, 105, 110, 101, 59, 32, 110, 101, 119, 32, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 32,
+97, 112, 112, 108, 121, 32, 116, 111, 32, 116, 104, 101, 32, 110, 101, 120, 116, 32, 104, 105, 116, 41, 34, 32,
+61, 32, 34, 68, 114, 117, 109, 112, 97, 100, 32, 226, 128, 148, 32, 116, 97, 109, 98, 111, 114, 32, 102, 195,
+173, 115, 105, 99, 111, 32, 40, 109, 111, 116, 111, 114, 32, 100, 111, 32, 70, 76, 59, 32, 110, 111, 118, 111,
+115, 32, 112, 97, 114, 195, 162, 109, 101, 116, 114, 111, 115, 32, 118, 97, 108, 101, 109, 32, 97, 32, 112, 97,
+114, 116, 105, 114, 32, 100, 111, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 104, 105, 116, 41, 34, 10, 34,
+80, 105, 116, 99, 104, 34, 32, 61, 32, 34, 80, 105, 116, 99, 104, 34, 10, 34, 83, 116, 114, 101, 116, 99,
+104, 34, 32, 61, 32, 34, 83, 116, 114, 101, 116, 99, 104, 34, 10, 34, 83, 116, 97, 114, 116, 34, 32, 61,
+32, 34, 73, 110, 195, 173, 99, 105, 111, 34, 10, 34, 69, 110, 100, 34, 32, 61, 32, 34, 70, 105, 109, 34,
+10, 34, 67, 117, 116, 111, 102, 102, 34, 32, 61, 32, 34, 67, 117, 116, 111, 102, 102, 34, 10, 34, 82, 101,
+115, 111, 110, 97, 110, 99, 101, 34, 32, 61, 32, 34, 82, 101, 115, 115, 111, 110, 195, 162, 110, 99, 105, 97,
+34, 10, 34, 67, 104, 97, 110, 110, 101, 108, 32, 102, 105, 108, 116, 101, 114, 32, 99, 117, 116, 111, 102, 102,
+32, 40, 108, 111, 119, 45, 112, 97, 115, 115, 32, 97, 116, 32, 109, 97, 120, 105, 109, 117, 109, 32, 119, 105,
+116, 104, 32, 110, 111, 32, 114, 101, 115, 111, 110, 97, 110, 99, 101, 32, 61, 32, 111, 102, 102, 41, 34, 32,
+61, 32, 34, 67, 117, 116, 111, 102, 102, 32, 100, 111, 32, 102, 105, 108, 116, 114, 111, 32, 100, 111, 32, 99,
+97, 110, 97, 108, 32, 40, 112, 97, 115, 115, 97, 45, 98, 97, 105, 120, 97, 32, 110, 111, 32, 109, 195, 161,
+120, 105, 109, 111, 32, 115, 101, 109, 32, 114, 101, 115, 115, 111, 110, 195, 162, 110, 99, 105, 97, 32, 61, 32,
+100, 101, 115, 108, 105, 103, 97, 100, 111, 41, 34, 10, 34, 76, 111, 119, 45, 112, 97, 115, 115, 34, 32, 61,
+32, 34, 80, 97, 115, 115, 97, 45, 98, 97, 105, 120, 97, 34, 10, 34, 72, 105, 103, 104, 45, 112, 97, 115,
+115, 34, 32, 61, 32, 34, 80, 97, 115, 115, 97, 45, 97, 108, 116, 97, 34, 10, 34, 77, 111, 100, 117, 108,
+97, 116, 105, 111, 110, 32, 40, 101, 110, 118, 101, 108, 111, 112, 101, 115, 32, 97, 110, 100, 32, 76, 70, 79,
+115, 41, 46, 46, 46, 34, 32, 61, 32, 34, 77, 111, 100, 117, 108, 97, 195, 167, 195, 163, 111, 32, 40, 101,
+110, 118, 101, 108, 111, 112, 101, 115, 32, 101, 32, 76, 70, 79, 115, 41, 46, 46, 46, 34, 10, 34, 87, 104,
+101, 114, 101, 32, 116, 104, 101, 32, 115, 97, 109, 112, 108, 101, 32, 115, 116, 97, 114, 116, 115, 32, 112, 108,
+97, 121, 105, 110, 103, 32, 40, 102, 114, 97, 99, 116, 105, 111, 110, 32, 111, 102, 32, 116, 104, 101, 32, 102,
+105, 108, 101, 41, 34, 32, 61, 32, 34, 79, 110, 100, 101, 32, 111, 32, 115, 97, 109, 112, 108, 101, 32, 99,
+111, 109, 101, 195, 167, 97, 32, 97, 32, 116, 111, 99, 97, 114, 32, 40, 102, 114, 97, 195, 167, 195, 163, 111,
+32, 100, 111, 32, 97, 114, 113, 117, 105, 118, 111, 41, 34, 10, 34, 48, 32, 61, 32, 111, 102, 102, 46, 32,
+79, 116, 104, 101, 114, 119, 105, 115, 101, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 115, 97, 109, 112,
+108, 101, 32, 108, 97, 115, 116, 115, 32, 116, 104, 105, 115, 32, 109, 97, 110, 121, 32, 98, 101, 97, 116, 115,
+32, 97, 110, 100, 32, 102, 111, 108, 108, 111, 119, 115, 32, 116, 104, 101, 32, 66, 80, 77, 32, 40, 98, 121,
+32, 114, 101, 115, 97, 109, 112, 108, 105, 110, 103, 44, 32, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32, 82,
+101, 115, 97, 109, 112, 108, 101, 32, 109, 111, 100, 101, 41, 34, 32, 61, 32, 34, 48, 32, 61, 32, 100, 101,
+115, 108, 105, 103, 97, 100, 111, 46, 32, 67, 97, 115, 111, 32, 99, 111, 110, 116, 114, 195, 161, 114, 105, 111,
+44, 32, 111, 32, 115, 97, 109, 112, 108, 101, 32, 105, 110, 116, 101, 105, 114, 111, 32, 100, 117, 114, 97, 32,
+101, 115, 115, 97, 32, 113, 117, 97, 110, 116, 105, 100, 97, 100, 101, 32, 100, 101, 32, 98, 101, 97, 116, 115,
+32, 101, 32, 115, 101, 103, 117, 101, 32, 111, 32, 66, 80, 77, 32, 40, 112, 111, 114, 32, 114, 101, 97, 109,
+111, 115, 116, 114, 97, 103, 101, 109, 44, 32, 99, 111, 109, 111, 32, 111, 32, 109, 111, 100, 111, 32, 82, 101,
+115, 97, 109, 112, 108, 101, 32, 100, 111, 32, 70, 76, 41, 34, 10, 34, 48, 32, 61, 32, 116, 104, 101, 32,
+119, 104, 111, 108, 101, 32, 115, 97, 109, 112, 108, 101, 32, 112, 108, 97, 121, 115, 32, 40, 111, 110, 101, 45,
+115, 104, 111, 116, 41, 44, 32, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32, 115, 116, 101, 112, 115, 34, 32,
+61, 32, 34, 48, 32, 61, 32, 111, 32, 115, 97, 109, 112, 108, 101, 32, 116, 111, 99, 97, 32, 105, 110, 116,
+101, 105, 114, 111, 32, 40, 111, 110, 101, 45, 115, 104, 111, 116, 41, 44, 32, 99, 111, 109, 111, 32, 110, 111,
+115, 32, 115, 116, 101, 112, 115, 32, 100, 111, 32, 70, 76, 34, 10, 34, 83, 116, 114, 101, 116, 99, 104, 32,
+107, 101, 101, 112, 105, 110, 103, 32, 112, 105, 116, 99, 104, 34, 32, 61, 32, 34, 83, 116, 114, 101, 116, 99,
+104, 32, 109, 97, 110, 116, 101, 110, 100, 111, 32, 111, 32, 112, 105, 116, 99, 104, 34, 10, 34, 87, 105, 116,
+104, 32, 92, 34, 83, 116, 114, 101, 116, 99, 104, 92, 34, 58, 32, 99, 104, 97, 110, 103, 101, 115, 32, 116,
+104, 101, 32, 108, 101, 110, 103, 116, 104, 32, 119, 105, 116, 104, 111, 117, 116, 32, 99, 104, 97, 110, 103, 105,
+110, 103, 32, 116, 104, 101, 32, 112, 105, 116, 99, 104, 32, 40, 108, 105, 107, 101, 32, 70, 76, 39, 115, 32,
+83, 116, 114, 101, 116, 99, 104, 32, 109, 111, 100, 101, 115, 41, 34, 32, 61, 32, 34, 67, 111, 109, 32, 92,
+34, 83, 116, 114, 101, 116, 99, 104, 92, 34, 58, 32, 109, 117, 100, 97, 32, 97, 32, 100, 117, 114, 97, 195,
+167, 195, 163, 111, 32, 115, 101, 109, 32, 109, 117, 100, 97, 114, 32, 111, 32, 112, 105, 116, 99, 104, 32, 40,
+99, 111, 109, 111, 32, 111, 115, 32, 109, 111, 100, 111, 115, 32, 83, 116, 114, 101, 116, 99, 104, 32, 100, 111,
+32, 70, 76, 41, 34, 10, 34, 82, 101, 118, 101, 114, 115, 101, 34, 32, 61, 32, 34, 82, 101, 118, 101, 114,
+115, 111, 34, 10, 34, 67, 117, 116, 32, 105, 116, 115, 101, 108, 102, 34, 32, 61, 32, 34, 67, 111, 114, 116,
+97, 32, 97, 32, 115, 105, 32, 109, 101, 115, 109, 111, 34, 10, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116,
+111, 58, 32, 116, 104, 101, 32, 110, 111, 116, 101, 32, 115, 116, 97, 114, 116, 115, 32, 102, 114, 111, 109, 32,
+116, 104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 110, 111, 116, 101, 39, 115, 32, 112, 105, 116, 99,
+104, 32, 40, 119, 105, 116, 104, 32, 67, 117, 116, 32, 105, 116, 115, 101, 108, 102, 44, 32, 116, 104, 101, 32,
+56, 48, 56, 32, 103, 108, 105, 100, 101, 41, 34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116,
+111, 58, 32, 97, 32, 110, 111, 116, 97, 32, 99, 111, 109, 101, 195, 167, 97, 32, 110, 111, 32, 112, 105, 116,
+99, 104, 32, 100, 97, 32, 110, 111, 116, 97, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 99, 111, 109,
+32, 67, 111, 114, 116, 97, 32, 97, 32, 115, 105, 32, 109, 101, 115, 109, 111, 44, 32, 111, 32, 103, 108, 105,
+100, 101, 32, 100, 111, 32, 56, 48, 56, 41, 34, 10, 34, 65, 32, 110, 101, 119, 32, 110, 111, 116, 101, 32,
+99, 117, 116, 115, 32, 116, 104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 111, 110, 101, 32, 40, 103,
+111, 111, 100, 32, 102, 111, 114, 32, 104, 105, 45, 104, 97, 116, 115, 32, 97, 110, 100, 32, 56, 48, 56, 115,
+41, 34, 32, 61, 32, 34, 85, 109, 97, 32, 110, 111, 116, 97, 32, 110, 111, 118, 97, 32, 99, 111, 114, 116,
+97, 32, 97, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 98, 111, 109, 32, 112, 97, 114, 97, 32, 104,
+105, 45, 104, 97, 116, 115, 32, 101, 32, 56, 48, 56, 115, 41, 34, 10, 34, 83, 97, 109, 112, 108, 101, 114,
+32, 115, 101, 116, 116, 105, 110, 103, 115, 32, 45, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 111, 110, 102,
+105, 103, 117, 114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 115, 97, 109, 112, 108, 101, 114, 32, 45,
+32, 123, 48, 125, 34, 10, 34, 32, 40, 109, 117, 108, 116, 105, 45, 115, 97, 109, 112, 108, 101, 58, 32, 123,
+48, 125, 32, 122, 111, 110, 101, 115, 41, 34, 32, 61, 32, 34, 32, 40, 109, 117, 108, 116, 105, 45, 115, 97,
+109, 112, 108, 101, 58, 32, 123, 48, 125, 32, 122, 111, 110, 97, 115, 41, 34, 10, 34, 79, 115, 99, 32, 123,
+48, 125, 34, 32, 61, 32, 34, 79, 115, 99, 32, 123, 48, 125, 34, 10, 34, 83, 97, 119, 34, 32, 61, 32,
+34, 68, 101, 110, 116, 101, 32, 100, 101, 32, 115, 101, 114, 114, 97, 34, 10, 34, 83, 113, 117, 97, 114, 101,
+34, 32, 61, 32, 34, 81, 117, 97, 100, 114, 97, 100, 97, 34, 10, 34, 78, 111, 105, 115, 101, 34, 32, 61,
+32, 34, 82, 117, 195, 173, 100, 111, 34, 10, 34, 72, 97, 114, 109, 111, 110, 105, 99, 115, 34, 32, 61, 32,
+34, 72, 97, 114, 109, 195, 180, 110, 105, 99, 111, 115, 34, 10, 34, 70, 77, 58, 32, 111, 115, 99, 32, 51,
+32, 40, 119, 104, 105, 99, 104, 32, 115, 116, 111, 112, 115, 32, 115, 111, 117, 110, 100, 105, 110, 103, 41, 32,
+109, 111, 100, 117, 108, 97, 116, 101, 115, 32, 116, 104, 101, 32, 112, 104, 97, 115, 101, 32, 111, 102, 32, 111,
+115, 99, 32, 49, 32, 97, 110, 100, 32, 50, 59, 32, 48, 32, 61, 32, 111, 102, 102, 34, 32, 61, 32, 34,
+70, 77, 58, 32, 111, 32, 111, 115, 99, 32, 51, 32, 40, 113, 117, 101, 32, 112, 97, 114, 97, 32, 100, 101,
+32, 115, 111, 97, 114, 41, 32, 109, 111, 100, 117, 108, 97, 32, 97, 32, 102, 97, 115, 101, 32, 100, 111, 115,
+32, 111, 115, 99, 32, 49, 32, 101, 32, 50, 59, 32, 48, 32, 61, 32, 100, 101, 115, 108, 105, 103, 97, 100,
+111, 34, 10, 34, 84, 105, 109, 101, 32, 102, 111, 114, 32, 116, 104, 101, 32, 70, 77, 32, 105, 110, 100, 101,
+120, 32, 116, 111, 32, 100, 101, 99, 97, 121, 32, 40, 48, 32, 61, 32, 99, 111, 110, 115, 116, 97, 110, 116,
+41, 59, 32, 116, 104, 101, 32, 98, 114, 105, 103, 104, 116, 110, 101, 115, 115, 32, 102, 97, 100, 101, 115, 32,
+108, 105, 107, 101, 32, 97, 110, 32, 101, 108, 101, 99, 116, 114, 105, 99, 32, 112, 105, 97, 110, 111, 34, 32,
+61, 32, 34, 84, 101, 109, 112, 111, 32, 112, 97, 114, 97, 32, 111, 32, 195, 173, 110, 100, 105, 99, 101, 32,
+100, 101, 32, 70, 77, 32, 100, 101, 99, 97, 105, 114, 32, 40, 48, 32, 61, 32, 99, 111, 110, 115, 116, 97,
+110, 116, 101, 41, 59, 32, 111, 32, 98, 114, 105, 108, 104, 111, 32, 115, 111, 109, 101, 32, 99, 111, 109, 111,
+32, 110, 117, 109, 32, 112, 105, 97, 110, 111, 32, 101, 108, 195, 169, 116, 114, 105, 99, 111, 34, 10, 34, 67,
+117, 116, 111, 102, 102, 32, 102, 111, 108, 108, 111, 119, 115, 32, 116, 104, 101, 32, 110, 111, 116, 101, 58, 32,
+99, 117, 116, 111, 102, 102, 32, 111, 99, 116, 97, 118, 101, 115, 32, 112, 101, 114, 32, 110, 111, 116, 101, 32,
+111, 99, 116, 97, 118, 101, 44, 32, 114, 101, 108, 97, 116, 105, 118, 101, 32, 116, 111, 32, 67, 51, 32, 40,
+49, 51, 48, 46, 56, 32, 72, 122, 41, 34, 32, 61, 32, 34, 79, 32, 99, 117, 116, 111, 102, 102, 32, 115,
+101, 103, 117, 101, 32, 97, 32, 110, 111, 116, 97, 58, 32, 111, 105, 116, 97, 118, 97, 115, 32, 100, 101, 32,
+99, 117, 116, 111, 102, 102, 32, 112, 111, 114, 32, 111, 105, 116, 97, 118, 97, 32, 100, 97, 32, 110, 111, 116,
+97, 44, 32, 101, 109, 32, 114, 101, 108, 97, 195, 167, 195, 163, 111, 32, 97, 111, 32, 67, 51, 32, 40, 49,
+51, 48, 44, 56, 32, 72, 122, 41, 34, 10, 34, 75, 105, 99, 107, 32, 112, 105, 116, 99, 104, 32, 115, 119,
+101, 101, 112, 58, 32, 116, 104, 101, 32, 110, 111, 116, 101, 32, 115, 116, 97, 114, 116, 115, 32, 40, 49, 32,
+43, 32, 118, 97, 108, 117, 101, 41, 32, 116, 105, 109, 101, 115, 32, 104, 105, 103, 104, 101, 114, 32, 97, 110,
+100, 32, 102, 97, 108, 108, 115, 34, 32, 61, 32, 34, 83, 119, 101, 101, 112, 32, 100, 101, 32, 112, 105, 116,
+99, 104, 32, 100, 111, 32, 107, 105, 99, 107, 58, 32, 97, 32, 110, 111, 116, 97, 32, 99, 111, 109, 101, 195,
+167, 97, 32, 40, 49, 32, 43, 32, 118, 97, 108, 111, 114, 41, 32, 118, 101, 122, 101, 115, 32, 109, 97, 105,
+115, 32, 97, 103, 117, 100, 97, 32, 101, 32, 100, 101, 115, 99, 101, 34, 10, 34, 83, 119, 101, 101, 112, 32,
+116, 105, 109, 101, 32, 99, 111, 110, 115, 116, 97, 110, 116, 34, 32, 61, 32, 34, 67, 111, 110, 115, 116, 97,
+110, 116, 101, 32, 100, 101, 32, 116, 101, 109, 112, 111, 32, 100, 111, 32, 115, 119, 101, 101, 112, 34, 10, 34,
+51, 45, 98, 97, 110, 100, 32, 116, 111, 110, 101, 32, 97, 102, 116, 101, 114, 32, 116, 104, 101, 32, 102, 105,
+108, 116, 101, 114, 32, 40, 108, 111, 119, 32, 60, 32, 49, 55, 56, 32, 72, 122, 32, 60, 32, 109, 105, 100,
+32, 60, 32, 49, 46, 49, 56, 32, 107, 72, 122, 32, 60, 32, 104, 105, 103, 104, 41, 59, 32, 49, 32, 61,
+32, 117, 110, 99, 104, 97, 110, 103, 101, 100, 34, 32, 61, 32, 34, 84, 105, 109, 98, 114, 101, 32, 100, 101,
+32, 51, 32, 98, 97, 110, 100, 97, 115, 32, 100, 101, 112, 111, 105, 115, 32, 100, 111, 32, 102, 105, 108, 116,
+114, 111, 32, 40, 103, 114, 97, 118, 101, 115, 32, 60, 32, 49, 55, 56, 32, 72, 122, 32, 60, 32, 109, 195,
+169, 100, 105, 111, 115, 32, 60, 32, 49, 44, 49, 56, 32, 107, 72, 122, 32, 60, 32, 97, 103, 117, 100, 111,
+115, 41, 59, 32, 49, 32, 61, 32, 115, 101, 109, 32, 97, 108, 116, 101, 114, 97, 195, 167, 195, 163, 111, 34,
+10, 34, 82, 105, 110, 103, 34, 32, 61, 32, 34, 82, 105, 110, 103, 34, 10, 34, 87, 105, 116, 104, 32, 65,
+77, 32, 111, 110, 58, 32, 114, 105, 110, 103, 32, 109, 111, 100, 117, 108, 97, 116, 105, 111, 110, 44, 32, 40,
+111, 115, 99, 32, 49, 32, 43, 32, 50, 41, 32, 195, 151, 32, 40, 49, 32, 226, 136, 146, 32, 108, 101, 118,
+101, 108, 32, 43, 32, 111, 115, 99, 32, 51, 41, 44, 32, 108, 105, 107, 101, 32, 83, 121, 116, 114, 117, 115,
+39, 115, 32, 82, 77, 34, 32, 61, 32, 34, 67, 111, 109, 32, 65, 77, 32, 108, 105, 103, 97, 100, 111, 58,
+32, 109, 111, 100, 117, 108, 97, 195, 167, 195, 163, 111, 32, 101, 109, 32, 97, 110, 101, 108, 44, 32, 40, 111,
+115, 99, 32, 49, 32, 43, 32, 50, 41, 32, 195, 151, 32, 40, 49, 32, 226, 136, 146, 32, 110, 195, 173, 118,
+101, 108, 32, 43, 32, 111, 115, 99, 32, 51, 41, 44, 32, 99, 111, 109, 111, 32, 111, 32, 82, 77, 32, 100,
+111, 32, 83, 121, 116, 114, 117, 115, 34, 10, 34, 83, 101, 109, 105, 116, 111, 110, 101, 34, 32, 61, 32, 34,
+83, 101, 109, 105, 116, 111, 109, 34, 10, 34, 70, 105, 110, 101, 34, 32, 61, 32, 34, 70, 105, 110, 111, 34,
+10, 34, 76, 101, 118, 101, 108, 34, 32, 61, 32, 34, 78, 195, 173, 118, 101, 108, 34, 10, 34, 80, 111, 114,
+116, 97, 32, 116, 105, 109, 101, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 32, 112, 111, 114, 116, 97, 34,
+10, 34, 70, 77, 34, 32, 61, 32, 34, 70, 77, 34, 10, 34, 70, 77, 32, 100, 101, 99, 97, 121, 34, 32,
+61, 32, 34, 68, 101, 99, 97, 121, 32, 70, 77, 34, 10, 34, 75, 101, 121, 116, 114, 97, 99, 107, 34, 32,
+61, 32, 34, 75, 101, 121, 116, 114, 97, 99, 107, 34, 10, 34, 83, 119, 101, 101, 112, 34, 32, 61, 32, 34,
+83, 119, 101, 101, 112, 34, 10, 34, 83, 119, 101, 101, 112, 32, 116, 105, 109, 101, 34, 32, 61, 32, 34, 84,
+101, 109, 112, 111, 32, 115, 119, 101, 101, 112, 34, 10, 34, 80, 114, 101, 115, 101, 116, 115, 46, 46, 46, 34,
+32, 61, 32, 34, 80, 114, 101, 115, 101, 116, 115, 46, 46, 46, 34, 10, 34, 70, 76, 32, 112, 114, 101, 115,
+101, 116, 115, 46, 46, 46, 34, 32, 61, 32, 34, 80, 114, 101, 115, 101, 116, 115, 32, 100, 111, 32, 70, 76,
+46, 46, 46, 34, 10, 34, 84, 104, 101, 32, 51, 120, 32, 79, 115, 99, 32, 99, 104, 97, 110, 110, 101, 108,
+32, 112, 114, 101, 115, 101, 116, 115, 32, 116, 104, 97, 116, 32, 115, 104, 105, 112, 32, 119, 105, 116, 104, 32,
+70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 40, 80, 97, 116, 99, 104, 101, 115, 92, 92, 67, 104, 97, 110,
+110, 101, 108, 32, 112, 114, 101, 115, 101, 116, 115, 92, 92, 51, 120, 32, 79, 115, 99, 41, 34, 32, 61, 32,
+34, 79, 115, 32, 112, 114, 101, 115, 101, 116, 115, 32, 100, 101, 32, 99, 97, 110, 97, 108, 32, 100, 111, 32,
+51, 120, 32, 79, 115, 99, 32, 113, 117, 101, 32, 118, 195, 170, 109, 32, 99, 111, 109, 32, 111, 32, 70, 76,
+32, 83, 116, 117, 100, 105, 111, 32, 40, 80, 97, 116, 99, 104, 101, 115, 92, 92, 67, 104, 97, 110, 110, 101,
+108, 32, 112, 114, 101, 115, 101, 116, 115, 92, 92, 51, 120, 32, 79, 115, 99, 41, 34, 10, 34, 70, 105, 108,
+116, 101, 114, 32, 116, 121, 112, 101, 34, 32, 61, 32, 34, 84, 105, 112, 111, 32, 100, 101, 32, 102, 105, 108,
+116, 114, 111, 34, 10, 34, 79, 115, 99, 32, 51, 32, 109, 111, 100, 117, 108, 97, 116, 101, 115, 32, 116, 104,
+101, 32, 97, 109, 112, 108, 105, 116, 117, 100, 101, 32, 111, 102, 32, 111, 115, 99, 32, 49, 32, 97, 110, 100,
+32, 50, 32, 40, 108, 105, 107, 101, 32, 51, 120, 32, 79, 115, 99, 39, 115, 32, 65, 77, 41, 59, 32, 105,
+116, 115, 32, 108, 101, 118, 101, 108, 32, 105, 115, 32, 116, 104, 101, 32, 100, 101, 112, 116, 104, 34, 32, 61,
+32, 34, 79, 32, 111, 115, 99, 32, 51, 32, 109, 111, 100, 117, 108, 97, 32, 97, 32, 97, 109, 112, 108, 105,
+116, 117, 100, 101, 32, 100, 111, 115, 32, 111, 115, 99, 32, 49, 32, 101, 32, 50, 32, 40, 99, 111, 109, 111,
+32, 111, 32, 65, 77, 32, 100, 111, 32, 51, 120, 32, 79, 115, 99, 41, 59, 32, 111, 32, 110, 195, 173, 118,
+101, 108, 32, 100, 101, 108, 101, 32, 195, 169, 32, 97, 32, 112, 114, 111, 102, 117, 110, 100, 105, 100, 97, 100,
+101, 34, 10, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 32, 116, 105, 109, 101, 44, 32, 105, 110, 32,
+98, 101, 97, 116, 115, 32, 40, 97, 112, 112, 108, 105, 101, 115, 32, 116, 111, 32, 116, 104, 101, 32, 80, 111,
+114, 116, 97, 32, 98, 117, 116, 116, 111, 110, 32, 97, 110, 100, 32, 116, 111, 32, 110, 111, 116, 101, 115, 32,
+109, 97, 114, 107, 101, 100, 32, 112, 111, 114, 116, 97, 41, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 32,
+100, 101, 32, 112, 111, 114, 116, 97, 109, 101, 110, 116, 111, 44, 32, 101, 109, 32, 98, 101, 97, 116, 115, 32,
+40, 118, 97, 108, 101, 32, 112, 97, 114, 97, 32, 111, 32, 98, 111, 116, 195, 163, 111, 32, 80, 111, 114, 116,
+97, 32, 101, 32, 112, 97, 114, 97, 32, 110, 111, 116, 97, 115, 32, 109, 97, 114, 99, 97, 100, 97, 115, 32,
+99, 111, 109, 32, 112, 111, 114, 116, 97, 41, 34, 10, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58,
+32, 116, 104, 101, 32, 110, 101, 119, 32, 110, 111, 116, 101, 32, 103, 108, 105, 100, 101, 115, 32, 102, 114, 111,
+109, 32, 116, 104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 111, 110, 101, 32, 40, 110, 111, 116, 101,
+115, 32, 109, 97, 114, 107, 101, 100, 32, 112, 111, 114, 116, 97, 32, 105, 110, 118, 101, 114, 116, 32, 116, 104,
+105, 115, 41, 34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 109, 101, 110, 116, 111, 58, 32, 97, 32, 110, 111,
+116, 97, 32, 110, 111, 118, 97, 32, 100, 101, 115, 108, 105, 122, 97, 32, 97, 32, 112, 97, 114, 116, 105, 114,
+32, 100, 97, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 110, 111, 116, 97, 115, 32, 109, 97, 114, 99,
+97, 100, 97, 115, 32, 99, 111, 109, 32, 112, 111, 114, 116, 97, 32, 105, 110, 118, 101, 114, 116, 101, 109, 32,
+105, 115, 115, 111, 41, 34, 10, 34, 83, 105, 110, 103, 108, 101, 32, 118, 111, 105, 99, 101, 58, 32, 116, 104,
+101, 32, 110, 101, 119, 32, 110, 111, 116, 101, 32, 116, 97, 107, 101, 115, 32, 111, 118, 101, 114, 32, 116, 104,
+101, 32, 111, 110, 101, 32, 99, 117, 114, 114, 101, 110, 116, 108, 121, 32, 115, 111, 117, 110, 100, 105, 110, 103,
+32, 40, 98, 97, 115, 115, 101, 115, 32, 97, 110, 100, 32, 108, 101, 97, 100, 115, 41, 34, 32, 61, 32, 34,
+86, 111, 122, 32, 195, 186, 110, 105, 99, 97, 58, 32, 97, 32, 110, 111, 116, 97, 32, 110, 111, 118, 97, 32,
+115, 117, 98, 115, 116, 105, 116, 117, 105, 32, 97, 32, 113, 117, 101, 32, 101, 115, 116, 195, 161, 32, 115, 111,
+97, 110, 100, 111, 32, 40, 98, 97, 105, 120, 111, 115, 32, 101, 32, 108, 101, 97, 100, 115, 41, 34, 10, 34,
+70, 76, 32, 112, 114, 101, 115, 101, 116, 115, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 32, 40, 105, 110,
+115, 116, 97, 108, 108, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 111, 114, 32, 99, 104, 101, 99, 107,
+32, 116, 104, 101, 32, 68, 97, 116, 97, 92, 92, 80, 97, 116, 99, 104, 101, 115, 32, 102, 111, 108, 100, 101,
+114, 41, 46, 34, 32, 61, 32, 34, 80, 114, 101, 115, 101, 116, 115, 32, 100, 111, 32, 70, 76, 32, 110, 195,
+163, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 115, 32, 40, 105, 110, 115, 116, 97, 108, 101, 32,
+111, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 111, 117, 32, 118, 101, 114, 105, 102, 105, 113, 117, 101,
+32, 97, 32, 112, 97, 115, 116, 97, 32, 68, 97, 116, 97, 92, 92, 80, 97, 116, 99, 104, 101, 115, 41, 46,
+34, 10, 34, 84, 104, 105, 115, 32, 112, 114, 101, 115, 101, 116, 32, 105, 115, 32, 110, 111, 116, 32, 102, 111,
+114, 32, 97, 32, 115, 121, 110, 116, 104, 32, 76, 89, 78, 88, 32, 99, 111, 110, 118, 101, 114, 116, 115, 44,
+32, 111, 114, 32, 105, 116, 32, 99, 111, 117, 108, 100, 32, 110, 111, 116, 32, 98, 101, 32, 114, 101, 97, 100,
+46, 34, 32, 61, 32, 34, 69, 115, 116, 101, 32, 112, 114, 101, 115, 101, 116, 32, 110, 195, 163, 111, 32, 195,
+169, 32, 100, 101, 32, 117, 109, 32, 115, 121, 110, 116, 104, 32, 113, 117, 101, 32, 111, 32, 76, 89, 78, 88,
+32, 99, 111, 110, 118, 101, 114, 116, 101, 44, 32, 111, 117, 32, 110, 195, 163, 111, 32, 112, 195, 180, 100, 101,
+32, 115, 101, 114, 32, 108, 105, 100, 111, 46, 34, 10, 34, 83, 121, 110, 116, 104, 32, 115, 101, 116, 116, 105,
+110, 103, 115, 32, 45, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 111, 110, 102, 105, 103, 117, 114, 97, 195,
+167, 195, 181, 101, 115, 32, 100, 111, 32, 115, 121, 110, 116, 104, 32, 45, 32, 123, 48, 125, 34, 10, 34, 67,
+104, 97, 110, 110, 101, 108, 32, 115, 101, 116, 116, 105, 110, 103, 115, 34, 32, 61, 32, 34, 67, 111, 110, 102,
+105, 103, 117, 114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 99, 97, 110, 97, 108, 34, 10, 34, 69,
+120, 112, 111, 114, 116, 105, 110, 103, 32, 97, 117, 100, 105, 111, 46, 46, 46, 34, 32, 61, 32, 34, 69, 120,
+112, 111, 114, 116, 97, 110, 100, 111, 32, 195, 161, 117, 100, 105, 111, 46, 46, 46, 34, 10, 34, 67, 111, 117,
+108, 100, 32, 110, 111, 116, 32, 114, 101, 110, 100, 101, 114, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102,
+111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 114, 101, 110, 100, 101, 114, 105, 122, 97, 114, 34,
+10, 34, 69, 120, 112, 111, 114, 116, 32, 99, 111, 109, 112, 108, 101, 116, 101, 34, 32, 61, 32, 34, 69, 120,
+112, 111, 114, 116, 97, 195, 167, 195, 163, 111, 32, 99, 111, 110, 99, 108, 117, 195, 173, 100, 97, 34, 10, 34,
+80, 101, 97, 107, 58, 32, 123, 48, 125, 32, 100, 66, 70, 83, 34, 32, 61, 32, 34, 80, 105, 99, 111, 58,
+32, 123, 48, 125, 32, 100, 66, 70, 83, 34, 10, 34, 67, 111, 117, 108, 100, 32, 110, 111, 116, 32, 101, 120,
+112, 111, 114, 116, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173,
+118, 101, 108, 32, 101, 120, 112, 111, 114, 116, 97, 114, 34, 10, 34, 69, 120, 112, 111, 114, 116, 105, 110, 103,
+32, 115, 116, 101, 109, 115, 46, 46, 46, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 110, 100, 111,
+32, 115, 116, 101, 109, 115, 46, 46, 46, 34, 10, 34, 83, 116, 101, 109, 115, 32, 101, 120, 112, 111, 114, 116,
+101, 100, 34, 32, 61, 32, 34, 83, 116, 101, 109, 115, 32, 101, 120, 112, 111, 114, 116, 97, 100, 111, 115, 34,
+10, 34, 123, 48, 125, 32, 102, 105, 108, 101, 40, 115, 41, 32, 105, 110, 32, 123, 49, 125, 34, 32, 61, 32,
+34, 123, 48, 125, 32, 97, 114, 113, 117, 105, 118, 111, 40, 115, 41, 32, 101, 109, 32, 123, 49, 125, 34, 10,
+34, 87, 65, 86, 32, 49, 54, 32, 98, 105, 116, 115, 34, 32, 61, 32, 34, 87, 65, 86, 32, 49, 54, 32,
+98, 105, 116, 115, 34, 10, 34, 87, 65, 86, 32, 50, 52, 32, 98, 105, 116, 115, 34, 32, 61, 32, 34, 87,
+65, 86, 32, 50, 52, 32, 98, 105, 116, 115, 34, 10, 34, 87, 65, 86, 32, 51, 50, 32, 98, 105, 116, 115,
+32, 40, 102, 108, 111, 97, 116, 41, 34, 32, 61, 32, 34, 87, 65, 86, 32, 51, 50, 32, 98, 105, 116, 115,
+32, 40, 102, 108, 111, 97, 116, 41, 34, 10, 34, 70, 76, 65, 67, 32, 50, 52, 32, 98, 105, 116, 115, 34,
+32, 61, 32, 34, 70, 76, 65, 67, 32, 50, 52, 32, 98, 105, 116, 115, 34, 10, 34, 70, 117, 108, 108, 32,
+115, 111, 110, 103, 32, 40, 80, 108, 97, 121, 108, 105, 115, 116, 41, 34, 32, 61, 32, 34, 77, 195, 186, 115,
+105, 99, 97, 32, 105, 110, 116, 101, 105, 114, 97, 32, 40, 80, 108, 97, 121, 108, 105, 115, 116, 41, 34, 10,
+34, 67, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 80, 97, 116,
+116, 101, 114, 110, 32, 97, 116, 117, 97, 108, 34, 10, 34, 78, 111, 32, 116, 97, 105, 108, 34, 32, 61, 32,
+34, 83, 101, 109, 32, 99, 97, 117, 100, 97, 34, 10, 34, 84, 97, 105, 108, 32, 117, 112, 32, 116, 111, 32,
+123, 48, 125, 32, 115, 34, 32, 61, 32, 34, 67, 97, 117, 100, 97, 32, 100, 101, 32, 97, 116, 195, 169, 32,
+123, 48, 125, 32, 115, 34, 10, 34, 70, 111, 114, 109, 97, 116, 34, 32, 61, 32, 34, 70, 111, 114, 109, 97,
+116, 111, 34, 10, 34, 83, 97, 109, 112, 108, 101, 32, 114, 97, 116, 101, 34, 32, 61, 32, 34, 84, 97, 120,
+97, 34, 10, 34, 69, 120, 112, 111, 114, 116, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 114, 34,
+10, 34, 84, 97, 105, 108, 34, 32, 61, 32, 34, 67, 97, 117, 100, 97, 34, 10, 34, 79, 110, 101, 32, 102,
+105, 108, 101, 32, 112, 101, 114, 32, 109, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 32, 40, 115, 116,
+101, 109, 115, 41, 34, 32, 61, 32, 34, 85, 109, 32, 97, 114, 113, 117, 105, 118, 111, 32, 112, 111, 114, 32,
+105, 110, 115, 101, 114, 116, 32, 100, 111, 32, 109, 105, 120, 101, 114, 32, 40, 115, 116, 101, 109, 115, 41, 34,
+10, 34, 69, 120, 112, 111, 114, 116, 32, 97, 117, 100, 105, 111, 34, 32, 61, 32, 34, 69, 120, 112, 111, 114,
+116, 97, 114, 32, 195, 161, 117, 100, 105, 111, 34, 10, 34, 69, 120, 112, 111, 114, 116, 46, 46, 46, 34, 32,
+61, 32, 34, 69, 120, 112, 111, 114, 116, 97, 114, 46, 46, 46, 34, 10, 34, 82, 101, 110, 100, 101, 114, 105,
+110, 103, 32, 105, 110, 115, 101, 114, 116, 32, 116, 111, 32, 97, 117, 100, 105, 111, 46, 46, 46, 34, 32, 61,
+32, 34, 82, 101, 110, 100, 101, 114, 105, 122, 97, 110, 100, 111, 32, 105, 110, 115, 101, 114, 116, 32, 101, 109,
+32, 195, 161, 117, 100, 105, 111, 46, 46, 46, 34, 10, 34, 83, 99, 97, 110, 110, 105, 110, 103, 32, 102, 111,
+114, 32, 112, 108, 117, 103, 105, 110, 115, 32, 40, 86, 83, 84, 51, 32, 97, 110, 100, 32, 67, 76, 65, 80,
+41, 46, 46, 46, 34, 32, 61, 32, 34, 80, 114, 111, 99, 117, 114, 97, 110, 100, 111, 32, 112, 108, 117, 103,
+105, 110, 115, 32, 40, 86, 83, 84, 51, 32, 101, 32, 67, 76, 65, 80, 41, 46, 46, 46, 34, 10, 34, 40,
+110, 111, 32, 112, 108, 117, 103, 105, 110, 115, 32, 102, 111, 117, 110, 100, 59, 32, 117, 115, 101, 32, 92, 34,
+83, 99, 97, 110, 32, 102, 111, 114, 32, 112, 108, 117, 103, 105, 110, 115, 92, 34, 41, 34, 32, 61, 32, 34,
+40, 110, 101, 110, 104, 117, 109, 32, 112, 108, 117, 103, 105, 110, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100,
+111, 59, 32, 117, 115, 101, 32, 92, 34, 80, 114, 111, 99, 117, 114, 97, 114, 32, 112, 108, 117, 103, 105, 110,
+115, 92, 34, 41, 34, 10, 34, 83, 99, 97, 110, 32, 102, 111, 114, 32, 112, 108, 117, 103, 105, 110, 115, 32,
+40, 86, 83, 84, 51, 32, 97, 110, 100, 32, 67, 76, 65, 80, 41, 46, 46, 46, 34, 32, 61, 32, 34, 80,
+114, 111, 99, 117, 114, 97, 114, 32, 112, 108, 117, 103, 105, 110, 115, 32, 40, 86, 83, 84, 51, 32, 101, 32,
+67, 76, 65, 80, 41, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 80,
+108, 117, 103, 105, 110, 115, 34, 10, 34, 123, 48, 125, 32, 110, 101, 119, 32, 112, 108, 117, 103, 105, 110, 40,
+115, 41, 32, 102, 111, 117, 110, 100, 46, 34, 32, 61, 32, 34, 123, 48, 125, 32, 112, 108, 117, 103, 105, 110,
+40, 115, 41, 32, 110, 111, 118, 111, 40, 115, 41, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 40, 115,
+41, 46, 34, 10, 10, 35, 32, 45, 45, 45, 32, 74, 85, 67, 69, 39, 115, 32, 111, 119, 110, 32, 115, 116,
+114, 105, 110, 103, 115, 32, 40, 97, 117, 100, 105, 111, 32, 115, 101, 116, 116, 105, 110, 103, 115, 32, 100, 105,
+97, 108, 111, 103, 41, 10, 34, 40, 110, 111, 32, 97, 117, 100, 105, 111, 32, 105, 110, 112, 117, 116, 32, 99,
+104, 97, 110, 110, 101, 108, 115, 32, 102, 111, 117, 110, 100, 41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104,
+117, 109, 32, 99, 97, 110, 97, 108, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 100, 101, 32, 195,
+161, 117, 100, 105, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 41, 34, 10, 34, 40, 110, 111, 32,
+97, 117, 100, 105, 111, 32, 111, 117, 116, 112, 117, 116, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 102, 111,
+117, 110, 100, 41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104, 117, 109, 32, 99, 97, 110, 97, 108, 32, 100,
+101, 32, 115, 97, 195, 173, 100, 97, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 101, 110, 99, 111, 110,
+116, 114, 97, 100, 111, 41, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 77, 73, 68, 73, 32, 105, 110, 112,
+117, 116, 115, 58, 34, 32, 61, 32, 34, 69, 110, 116, 114, 97, 100, 97, 115, 32, 77, 73, 68, 73, 32, 97,
+116, 105, 118, 97, 115, 58, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 105, 110, 112, 117, 116, 32, 99, 104,
+97, 110, 110, 101, 108, 115, 58, 34, 32, 61, 32, 34, 67, 97, 110, 97, 105, 115, 32, 100, 101, 32, 101, 110,
+116, 114, 97, 100, 97, 32, 97, 116, 105, 118, 111, 115, 58, 34, 10, 34, 65, 99, 116, 105, 118, 101, 32, 111,
+117, 116, 112, 117, 116, 32, 99, 104, 97, 110, 110, 101, 108, 115, 58, 34, 32, 61, 32, 34, 67, 97, 110, 97,
+105, 115, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 97, 116, 105, 118, 111, 115, 58, 34, 10, 34, 65,
+117, 100, 105, 111, 32, 98, 117, 102, 102, 101, 114, 32, 115, 105, 122, 101, 58, 34, 32, 61, 32, 34, 84, 97,
+109, 97, 110, 104, 111, 32, 100, 111, 32, 98, 117, 102, 102, 101, 114, 58, 34, 10, 34, 65, 117, 100, 105, 111,
+32, 100, 101, 118, 105, 99, 101, 32, 116, 121, 112, 101, 58, 34, 32, 61, 32, 34, 84, 105, 112, 111, 32, 100,
+101, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 58, 34, 10, 34, 66, 108, 117, 101, 116, 111, 111,
+116, 104, 32, 77, 73, 68, 73, 34, 32, 61, 32, 34, 77, 73, 68, 73, 32, 66, 108, 117, 101, 116, 111, 111,
+116, 104, 34, 10, 34, 67, 111, 110, 116, 114, 111, 108, 32, 80, 97, 110, 101, 108, 34, 32, 61, 32, 34, 80,
+97, 105, 110, 101, 108, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 101, 34, 10, 34, 68, 101, 118, 105,
+99, 101, 58, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 58, 34, 10, 34, 69,
+114, 114, 111, 114, 32, 119, 104, 101, 110, 32, 116, 114, 121, 105, 110, 103, 32, 116, 111, 32, 111, 112, 101, 110,
+32, 97, 117, 100, 105, 111, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 69, 114, 114, 111, 32,
+97, 111, 32, 116, 101, 110, 116, 97, 114, 32, 97, 98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115,
+105, 116, 105, 118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 33, 34, 10, 34, 73, 110, 112, 117, 116,
+58, 34, 32, 61, 32, 34, 69, 110, 116, 114, 97, 100, 97, 58, 34, 10, 34, 77, 73, 68, 73, 32, 79, 117,
+116, 112, 117, 116, 58, 34, 32, 61, 32, 34, 83, 97, 195, 173, 100, 97, 32, 77, 73, 68, 73, 58, 34, 10,
+34, 78, 111, 32, 77, 73, 68, 73, 32, 105, 110, 112, 117, 116, 115, 32, 97, 118, 97, 105, 108, 97, 98, 108,
+101, 34, 32, 61, 32, 34, 78, 101, 110, 104, 117, 109, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 77, 73,
+68, 73, 32, 100, 105, 115, 112, 111, 110, 195, 173, 118, 101, 108, 34, 10, 34, 79, 112, 101, 110, 115, 32, 116,
+104, 101, 32, 100, 101, 118, 105, 99, 101, 39, 115, 32, 111, 119, 110, 32, 99, 111, 110, 116, 114, 111, 108, 32,
+112, 97, 110, 101, 108, 34, 32, 61, 32, 34, 65, 98, 114, 101, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32,
+100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 101, 32, 100, 111, 32, 112, 114, 195, 179, 112, 114, 105, 111, 32,
+100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 34, 10, 34, 79, 117, 116, 112, 117, 116, 58, 34, 32, 61,
+32, 34, 83, 97, 195, 173, 100, 97, 58, 34, 10, 34, 80, 108, 97, 121, 115, 32, 97, 32, 116, 101, 115, 116,
+32, 116, 111, 110, 101, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32, 117, 109, 32, 116, 111, 109, 32, 100, 101,
+32, 116, 101, 115, 116, 101, 34, 10, 34, 82, 101, 115, 101, 116, 32, 68, 101, 118, 105, 99, 101, 34, 32, 61,
+32, 34, 82, 101, 105, 110, 105, 99, 105, 97, 114, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 34,
+10, 34, 82, 101, 115, 101, 116, 115, 32, 116, 104, 101, 32, 97, 117, 100, 105, 111, 32, 105, 110, 116, 101, 114,
+102, 97, 99, 101, 32, 45, 32, 115, 111, 109, 101, 116, 105, 109, 101, 115, 32, 110, 101, 101, 100, 101, 100, 32,
+97, 102, 116, 101, 114, 32, 99, 104, 97, 110, 103, 105, 110, 103, 32, 97, 32, 100, 101, 118, 105, 99, 101, 39,
+115, 32, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 32, 105, 110, 32, 105, 116, 115, 32, 99, 117, 115, 116,
+111, 109, 32, 99, 111, 110, 116, 114, 111, 108, 32, 112, 97, 110, 101, 108, 34, 32, 61, 32, 34, 82, 101, 105,
+110, 105, 99, 105, 97, 32, 97, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 32, 100, 101, 32, 195, 161, 117,
+100, 105, 111, 32, 45, 32, 195, 160, 115, 32, 118, 101, 122, 101, 115, 32, 110, 101, 99, 101, 115, 115, 195, 161,
+114, 105, 111, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 109, 117, 100, 97, 114, 32, 112, 114, 111, 112,
+114, 105, 101, 100, 97, 100, 101, 115, 32, 100, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32,
+110, 111, 32, 112, 97, 105, 110, 101, 108, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 101, 32, 100, 101,
+108, 101, 34, 10, 34, 83, 97, 109, 112, 108, 101, 32, 114, 97, 116, 101, 58, 34, 32, 61, 32, 34, 84, 97,
+120, 97, 32, 100, 101, 32, 97, 109, 111, 115, 116, 114, 97, 103, 101, 109, 58, 34, 10, 34, 83, 99, 97, 110,
+32, 102, 111, 114, 32, 98, 108, 117, 101, 116, 111, 111, 116, 104, 32, 77, 73, 68, 73, 32, 100, 101, 118, 105,
+99, 101, 115, 34, 32, 61, 32, 34, 80, 114, 111, 99, 117, 114, 97, 114, 32, 100, 105, 115, 112, 111, 115, 105,
+116, 105, 118, 111, 115, 32, 77, 73, 68, 73, 32, 66, 108, 117, 101, 116, 111, 111, 116, 104, 34, 10, 34, 83,
+104, 111, 119, 32, 97, 100, 118, 97, 110, 99, 101, 100, 32, 115, 101, 116, 116, 105, 110, 103, 115, 46, 46, 46,
+34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 99, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167,
+195, 181, 101, 115, 32, 97, 118, 97, 110, 195, 167, 97, 100, 97, 115, 46, 46, 46, 34, 10, 34, 84, 101, 115,
+116, 34, 32, 61, 32, 34, 84, 101, 115, 116, 97, 114, 34, 10, 34, 84, 104, 101, 32, 105, 110, 112, 117, 116,
+32, 97, 110, 100, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 115, 32, 100, 111, 110, 39,
+116, 32, 115, 104, 97, 114, 101, 32, 97, 32, 99, 111, 109, 109, 111, 110, 32, 115, 97, 109, 112, 108, 101, 32,
+114, 97, 116, 101, 33, 34, 32, 61, 32, 34, 79, 115, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111,
+115, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 101, 32, 115, 97, 195, 173, 100, 97, 32, 110, 195,
+163, 111, 32, 116, 195, 170, 109, 32, 117, 109, 97, 32, 116, 97, 120, 97, 32, 100, 101, 32, 97, 109, 111, 115,
+116, 114, 97, 103, 101, 109, 32, 101, 109, 32, 99, 111, 109, 117, 109, 33, 34, 10, 34, 67, 111, 117, 108, 100,
+110, 39, 116, 32, 111, 112, 101, 110, 32, 116, 104, 101, 32, 105, 110, 112, 117, 116, 32, 100, 101, 118, 105, 99,
+101, 33, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101,
+108, 32, 97, 98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101,
+32, 101, 110, 116, 114, 97, 100, 97, 33, 34, 10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 111, 112, 101,
+110, 32, 116, 104, 101, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32,
+34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 97, 98, 114, 105,
+114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100,
+97, 33, 34, 10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 111, 112, 101, 110, 32, 116, 104, 101, 32, 111,
+117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 32, 40, 98, 117, 102, 102, 101, 114, 32, 115, 105, 122,
+101, 32, 109, 105, 115, 109, 97, 116, 99, 104, 41, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105,
+32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 97, 98, 114, 105, 114, 32, 111, 32, 100, 105, 115, 112, 111,
+115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 40, 116, 97, 109, 97, 110, 104,
+111, 32, 100, 101, 32, 98, 117, 102, 102, 101, 114, 32, 105, 110, 99, 111, 109, 112, 97, 116, 195, 173, 118, 101,
+108, 41, 34, 10, 34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 115, 116, 97, 114, 116, 32, 116, 104, 101, 32,
+105, 110, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102,
+111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 105, 110, 105, 99, 105, 97, 114, 32, 111, 32, 100,
+105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 33, 34, 10,
+34, 67, 111, 117, 108, 100, 110, 39, 116, 32, 115, 116, 97, 114, 116, 32, 116, 104, 101, 32, 111, 117, 116, 112,
 117, 116, 32, 100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32,
 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 105, 110, 105, 99, 105, 97, 114, 32, 111, 32, 100, 105, 115, 112,
-111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 33, 34, 10, 34, 67, 111,
-117, 108, 100, 110, 39, 116, 32, 115, 116, 97, 114, 116, 32, 116, 104, 101, 32, 111, 117, 116, 112, 117, 116, 32,
-100, 101, 118, 105, 99, 101, 33, 34, 32, 61, 32, 34, 78, 195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115,
-115, 195, 173, 118, 101, 108, 32, 105, 110, 105, 99, 105, 97, 114, 32, 111, 32, 100, 105, 115, 112, 111, 115, 105,
-116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 33, 34, 10, 10, 35, 32, 45, 45, 45, 32,
-87, 111, 114, 107, 102, 108, 111, 119, 32, 115, 104, 101, 108, 108, 58, 32, 107, 101, 121, 32, 109, 97, 112, 44,
-32, 119, 111, 114, 107, 115, 112, 97, 99, 101, 44, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107,
-32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 44, 32, 99, 111, 110, 116, 114, 111, 108, 32, 99, 111, 110, 116,
-114, 97, 99, 116, 44, 32, 104, 105, 110, 116, 32, 115, 116, 114, 105, 112, 44, 32, 116, 114, 97, 110, 115, 112,
-111, 114, 116, 10, 34, 80, 108, 97, 121, 32, 47, 32, 115, 116, 111, 112, 32, 40, 98, 97, 99, 107, 32, 116,
-111, 32, 119, 104, 101, 114, 101, 32, 112, 108, 97, 121, 98, 97, 99, 107, 32, 115, 116, 97, 114, 116, 101, 100,
-41, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 32, 47, 32, 112, 97, 114, 97, 114, 32, 40, 118, 111, 108,
-116, 97, 32, 112, 97, 114, 97, 32, 111, 110, 100, 101, 32, 99, 111, 109, 101, 195, 167, 111, 117, 41, 34, 10,
-34, 84, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105,
-97, 110, 111, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100, 111, 32, 100,
-111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 32, 108, 105, 103, 97, 47, 100, 101, 115,
-108, 105, 103, 97, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114, 32, 104, 105,
-100, 101, 32, 116, 104, 101, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 32, 61, 32, 34, 77, 111, 115, 116,
-114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 32, 97,
-32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32,
-111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107,
-34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101,
-115, 99, 111, 110, 100, 101, 114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 10,
-34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101,
-32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 44,
-32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 32, 111, 32, 80, 105, 97,
-110, 111, 32, 82, 111, 108, 108, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114,
-32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32, 34, 77, 111,
-115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114,
-32, 111, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115,
-32, 111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 77, 105, 120, 101, 114, 34, 32, 61, 32, 34, 77,
+111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 33, 34, 10, 10, 35, 32, 45,
+45, 45, 32, 87, 111, 114, 107, 102, 108, 111, 119, 32, 115, 104, 101, 108, 108, 58, 32, 107, 101, 121, 32, 109,
+97, 112, 44, 32, 119, 111, 114, 107, 115, 112, 97, 99, 101, 44, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82,
+97, 99, 107, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 44, 32, 99, 111, 110, 116, 114, 111, 108, 32, 99,
+111, 110, 116, 114, 97, 99, 116, 44, 32, 104, 105, 110, 116, 32, 115, 116, 114, 105, 112, 44, 32, 116, 114, 97,
+110, 115, 112, 111, 114, 116, 10, 34, 80, 108, 97, 121, 32, 47, 32, 115, 116, 111, 112, 32, 40, 98, 97, 99,
+107, 32, 116, 111, 32, 119, 104, 101, 114, 101, 32, 112, 108, 97, 121, 98, 97, 99, 107, 32, 115, 116, 97, 114,
+116, 101, 100, 41, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 32, 47, 32, 112, 97, 114, 97, 114, 32, 40,
+118, 111, 108, 116, 97, 32, 112, 97, 114, 97, 32, 111, 110, 100, 101, 32, 99, 111, 109, 101, 195, 167, 111, 117,
+41, 34, 10, 34, 84, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97,
+32, 112, 105, 97, 110, 111, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100,
+111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 32, 108, 105, 103, 97, 47,
+100, 101, 115, 108, 105, 103, 97, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114,
+32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 32, 61, 32, 34, 77,
 111, 115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101,
-114, 32, 111, 32, 77, 105, 120, 101, 114, 34, 10, 34, 77, 97, 120, 105, 109, 105, 122, 101, 32, 111, 114, 32,
-114, 101, 115, 116, 111, 114, 101, 32, 116, 104, 101, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 32, 61, 32,
-34, 77, 97, 120, 105, 109, 105, 122, 97, 114, 32, 111, 117, 32, 114, 101, 115, 116, 97, 117, 114, 97, 114, 32,
-97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 78, 101, 120, 116, 32, 112, 97, 116, 116, 101, 114,
-110, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10,
-34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 80, 97,
-116, 116, 101, 114, 110, 32, 97, 110, 116, 101, 114, 105, 111, 114, 34, 10, 34, 78, 101, 120, 116, 32, 101, 109,
-112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 40, 97, 110, 100, 32, 110, 97, 109, 101, 32, 105, 116,
-41, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 118,
-97, 122, 105, 111, 32, 40, 101, 32, 100, 97, 114, 32, 110, 111, 109, 101, 41, 34, 10, 34, 82, 101, 110, 97,
-109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111, 114, 32, 116, 104, 101, 32, 112, 97, 116, 116, 101, 114, 110,
-34, 32, 61, 32, 34, 82, 101, 110, 111, 109, 101, 97, 114, 32, 101, 32, 99, 111, 108, 111, 114, 105, 114, 32,
-111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 97, 110, 32, 101, 109,
-112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 98, 101, 102, 111, 114, 101, 32, 116, 104, 101, 32, 99,
-117, 114, 114, 101, 110, 116, 32, 111, 110, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 117,
-109, 32, 112, 97, 116, 116, 101, 114, 110, 32, 118, 97, 122, 105, 111, 32, 97, 110, 116, 101, 115, 32, 100, 111,
-32, 97, 116, 117, 97, 108, 34, 10, 34, 83, 97, 118, 101, 32, 112, 114, 111, 106, 101, 99, 116, 32, 97, 115,
-34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 112, 114, 111, 106, 101, 116, 111, 32, 99, 111, 109, 111,
-34, 10, 34, 83, 104, 111, 114, 116, 99, 117, 116, 32, 115, 104, 101, 101, 116, 34, 32, 61, 32, 34, 70, 111,
-108, 104, 97, 32, 100, 101, 32, 97, 116, 97, 108, 104, 111, 115, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32,
-116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 32, 97, 98, 111, 118, 101, 34, 32, 61, 32, 34, 83, 101,
-108, 101, 99, 105, 111, 110, 97, 114, 32, 111, 32, 99, 97, 110, 97, 108, 32, 100, 101, 32, 99, 105, 109, 97,
-34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 32, 98, 101,
-108, 111, 119, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 111, 32, 99, 97, 110,
-97, 108, 32, 100, 101, 32, 98, 97, 105, 120, 111, 34, 10, 34, 69, 120, 116, 101, 110, 100, 32, 116, 104, 101,
-32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 117, 112, 34, 32, 61, 32, 34, 69, 115, 116, 101, 110, 100,
-101, 114, 32, 97, 32, 115, 101, 108, 101, 195, 167, 195, 163, 111, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97,
-34, 10, 34, 69, 120, 116, 101, 110, 100, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32,
-100, 111, 119, 110, 34, 32, 61, 32, 34, 69, 115, 116, 101, 110, 100, 101, 114, 32, 97, 32, 115, 101, 108, 101,
-195, 167, 195, 163, 111, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120, 111, 34, 10, 34, 77, 111, 118, 101, 32,
-116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 117, 112,
-34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108,
-101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97, 34, 10, 34, 77, 111,
+114, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99,
+117, 115, 32, 111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82,
+97, 99, 107, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111,
+117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99,
+107, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114, 32, 104, 105, 100, 101, 32,
+116, 104, 101, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114,
+97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 32, 111, 32,
+80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115,
+32, 111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32,
+34, 77, 111, 115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110,
+100, 101, 114, 32, 111, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 83, 104, 111, 119, 44, 32, 102, 111,
+99, 117, 115, 32, 111, 114, 32, 104, 105, 100, 101, 32, 116, 104, 101, 32, 77, 105, 120, 101, 114, 34, 32, 61,
+32, 34, 77, 111, 115, 116, 114, 97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111,
+110, 100, 101, 114, 32, 111, 32, 77, 105, 120, 101, 114, 34, 10, 34, 77, 97, 120, 105, 109, 105, 122, 101, 32,
+111, 114, 32, 114, 101, 115, 116, 111, 114, 101, 32, 116, 104, 101, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34,
+32, 61, 32, 34, 77, 97, 120, 105, 109, 105, 122, 97, 114, 32, 111, 117, 32, 114, 101, 115, 116, 97, 117, 114,
+97, 114, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 78, 101, 120, 116, 32, 112, 97, 116,
+116, 101, 114, 110, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 112, 97, 116, 116, 101, 114,
+110, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32,
+34, 80, 97, 116, 116, 101, 114, 110, 32, 97, 110, 116, 101, 114, 105, 111, 114, 34, 10, 34, 78, 101, 120, 116,
+32, 101, 109, 112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 40, 97, 110, 100, 32, 110, 97, 109, 101,
+32, 105, 116, 41, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 112, 97, 116, 116, 101, 114,
+110, 32, 118, 97, 122, 105, 111, 32, 40, 101, 32, 100, 97, 114, 32, 110, 111, 109, 101, 41, 34, 10, 34, 82,
+101, 110, 97, 109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111, 114, 32, 116, 104, 101, 32, 112, 97, 116, 116,
+101, 114, 110, 34, 32, 61, 32, 34, 82, 101, 110, 111, 109, 101, 97, 114, 32, 101, 32, 99, 111, 108, 111, 114,
+105, 114, 32, 111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 97, 110,
+32, 101, 109, 112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 98, 101, 102, 111, 114, 101, 32, 116, 104,
+101, 32, 99, 117, 114, 114, 101, 110, 116, 32, 111, 110, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105,
+114, 32, 117, 109, 32, 112, 97, 116, 116, 101, 114, 110, 32, 118, 97, 122, 105, 111, 32, 97, 110, 116, 101, 115,
+32, 100, 111, 32, 97, 116, 117, 97, 108, 34, 10, 34, 83, 97, 118, 101, 32, 112, 114, 111, 106, 101, 99, 116,
+32, 97, 115, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 112, 114, 111, 106, 101, 116, 111, 32, 99,
+111, 109, 111, 34, 10, 34, 83, 104, 111, 114, 116, 99, 117, 116, 32, 115, 104, 101, 101, 116, 34, 32, 61, 32,
+34, 70, 111, 108, 104, 97, 32, 100, 101, 32, 97, 116, 97, 108, 104, 111, 115, 34, 10, 34, 83, 101, 108, 101,
+99, 116, 32, 116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 32, 97, 98, 111, 118, 101, 34, 32, 61, 32,
+34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 111, 32, 99, 97, 110, 97, 108, 32, 100, 101, 32, 99,
+105, 109, 97, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108,
+32, 98, 101, 108, 111, 119, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 111, 32,
+99, 97, 110, 97, 108, 32, 100, 101, 32, 98, 97, 105, 120, 111, 34, 10, 34, 69, 120, 116, 101, 110, 100, 32,
+116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 117, 112, 34, 32, 61, 32, 34, 69, 115, 116,
+101, 110, 100, 101, 114, 32, 97, 32, 115, 101, 108, 101, 195, 167, 195, 163, 111, 32, 112, 97, 114, 97, 32, 99,
+105, 109, 97, 34, 10, 34, 69, 120, 116, 101, 110, 100, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105,
+111, 110, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 69, 115, 116, 101, 110, 100, 101, 114, 32, 97, 32, 115,
+101, 108, 101, 195, 167, 195, 163, 111, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120, 111, 34, 10, 34, 77, 111,
 118, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115,
-32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105,
-115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120,
-111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 97, 108, 108, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34,
-32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32,
-99, 97, 110, 97, 105, 115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99,
-116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 67, 108, 111, 110, 97, 114, 32,
-111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 34, 10,
-34, 68, 101, 108, 101, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97,
-110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 69, 120, 99, 108, 117, 105, 114, 32, 111, 115, 32, 99, 97, 110,
-97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 34, 10, 34, 83, 101, 110, 100, 32,
-116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 116, 111,
-32, 102, 114, 101, 101, 32, 109, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34,
-77, 97, 110, 100, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111,
-110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105, 118, 114, 101,
-115, 32, 100, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 77, 117, 116, 101, 32, 111, 114, 32, 117, 110, 109,
-117, 116, 101, 32, 99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 83, 105, 108, 101,
-110, 99, 105, 97, 114, 32, 111, 117, 32, 114, 101, 97, 116, 105, 118, 97, 114, 32, 111, 32, 99, 97, 110, 97,
-108, 32, 123, 48, 125, 34, 10, 34, 83, 111, 108, 111, 32, 99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125,
-34, 32, 61, 32, 34, 83, 111, 108, 111, 32, 110, 111, 32, 99, 97, 110, 97, 108, 32, 123, 48, 125, 34, 10,
-34, 100, 114, 97, 103, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 101, 41, 44, 32, 119, 104, 101, 101,
-108, 44, 32, 65, 108, 116, 43, 99, 108, 105, 99, 107, 32, 114, 101, 115, 101, 116, 115, 34, 32, 61, 32, 34,
-97, 114, 114, 97, 115, 116, 101, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 111, 41, 44, 32, 114, 111,
-100, 97, 32, 100, 111, 32, 109, 111, 117, 115, 101, 44, 32, 65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 32,
-114, 101, 115, 101, 116, 97, 34, 10, 34, 77, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61,
-32, 34, 73, 110, 115, 101, 114, 116, 32, 100, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 77, 97, 115, 116,
-101, 114, 34, 32, 61, 32, 34, 77, 97, 115, 116, 101, 114, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 123,
-48, 125, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 116, 32, 123, 48, 125, 34, 10, 34, 78, 101, 120, 116,
-32, 102, 114, 101, 101, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109,
-111, 32, 105, 110, 115, 101, 114, 116, 32, 108, 105, 118, 114, 101, 34, 10, 34, 83, 101, 110, 100, 32, 116, 104,
-101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 116, 111, 32, 102,
-114, 101, 101, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34, 77, 97, 110, 100, 97, 114, 32, 111,
-115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97,
-114, 97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105, 118, 114, 101, 115, 34, 10, 34, 100, 114, 97, 103,
-32, 111, 114, 32, 119, 104, 101, 101, 108, 32, 116, 111, 32, 114, 111, 117, 116, 101, 44, 32, 100, 111, 117, 98,
-108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 110, 101, 120, 116, 32, 102, 114, 101, 101, 32, 105, 110, 115, 101,
-114, 116, 34, 32, 61, 32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 111, 117, 32, 114, 111, 100, 97, 32, 112,
-97, 114, 97, 32, 114, 111, 116, 101, 97, 114, 44, 32, 100, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101,
-58, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 105, 110, 115, 101, 114, 116, 32, 108, 105, 118, 114, 101, 34,
-10, 34, 67, 108, 105, 99, 107, 58, 32, 109, 117, 116, 101, 46, 32, 32, 67, 116, 114, 108, 43, 99, 108, 105,
-99, 107, 32, 111, 114, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 115, 111, 108, 111, 34,
-32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 115, 105, 108, 101, 110, 99, 105, 97, 114, 46, 32, 32,
-67, 116, 114, 108, 43, 99, 108, 105, 113, 117, 101, 32, 111, 117, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105,
-114, 101, 105, 116, 111, 58, 32, 115, 111, 108, 111, 34, 10, 34, 67, 108, 105, 99, 107, 58, 32, 111, 112, 101,
-110, 47, 99, 108, 111, 115, 101, 32, 116, 104, 101, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32,
-107, 101, 101, 112, 115, 32, 111, 116, 104, 101, 114, 115, 32, 111, 112, 101, 110, 41, 46, 32, 32, 67, 116, 114,
-108, 43, 99, 108, 105, 99, 107, 58, 32, 97, 117, 100, 105, 116, 105, 111, 110, 46, 32, 32, 68, 111, 117, 98,
-108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 32, 61, 32,
-34, 67, 108, 105, 113, 117, 101, 58, 32, 97, 98, 114, 101, 47, 102, 101, 99, 104, 97, 32, 111, 32, 101, 100,
-105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 109, 97, 110, 116, 195, 169, 109, 32, 111, 115, 32, 111, 117, 116,
-114, 111, 115, 32, 97, 98, 101, 114, 116, 111, 115, 41, 46, 32, 32, 67, 116, 114, 108, 43, 99, 108, 105, 113,
-117, 101, 58, 32, 111, 117, 118, 105, 114, 46, 32, 32, 68, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101,
-58, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 40, 67,
-116, 114, 108, 58, 32, 97, 100, 100, 47, 114, 101, 109, 111, 118, 101, 44, 32, 83, 104, 105, 102, 116, 58, 32,
-114, 97, 110, 103, 101, 44, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 97, 108, 108,
-41, 46, 32, 32, 65, 108, 116, 43, 85, 112, 47, 68, 111, 119, 110, 32, 109, 111, 118, 101, 115, 32, 116, 104,
-101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110,
-97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 105, 110, 99, 108, 117, 105, 114, 47, 116, 105, 114, 97, 114, 44,
-32, 83, 104, 105, 102, 116, 58, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 44, 32, 100, 117, 112, 108, 111,
-32, 99, 108, 105, 113, 117, 101, 58, 32, 116, 111, 100, 111, 115, 41, 46, 32, 32, 65, 108, 116, 43, 67, 105,
-109, 97, 47, 66, 97, 105, 120, 111, 32, 109, 111, 118, 101, 32, 97, 32, 115, 101, 108, 101, 195, 167, 195, 163,
-111, 34, 10, 34, 83, 116, 101, 112, 115, 58, 32, 99, 108, 105, 99, 107, 32, 116, 117, 114, 110, 115, 32, 111,
-110, 32, 97, 110, 100, 32, 100, 114, 97, 103, 115, 32, 116, 111, 32, 112, 97, 105, 110, 116, 44, 32, 114, 105,
-103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 101, 114, 97, 115, 101, 115, 34, 32, 61, 32, 34, 83, 116, 101,
-112, 115, 58, 32, 99, 108, 105, 113, 117, 101, 32, 108, 105, 103, 97, 32, 101, 32, 97, 114, 114, 97, 115, 116,
-97, 114, 32, 112, 105, 110, 116, 97, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111,
-32, 97, 112, 97, 103, 97, 34, 10, 34, 65, 100, 100, 32, 97, 32, 99, 104, 97, 110, 110, 101, 108, 32, 40,
-111, 114, 32, 100, 114, 111, 112, 32, 97, 117, 100, 105, 111, 32, 102, 105, 108, 101, 115, 32, 111, 110, 32, 116,
-104, 101, 32, 114, 97, 99, 107, 41, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117,
-109, 32, 99, 97, 110, 97, 108, 32, 40, 111, 117, 32, 115, 111, 108, 116, 101, 32, 97, 114, 113, 117, 105, 118,
-111, 115, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 110, 111, 32, 114, 97, 99, 107, 41, 34, 10, 34,
-67, 104, 97, 110, 110, 101, 108, 32, 115, 101, 116, 116, 105, 110, 103, 115, 46, 46, 46, 34, 32, 61, 32, 34,
-67, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 99, 97, 110, 97, 108,
-46, 46, 46, 34, 10, 34, 82, 101, 110, 97, 109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111, 114, 46, 46,
-46, 34, 32, 61, 32, 34, 82, 101, 110, 111, 109, 101, 97, 114, 32, 101, 32, 99, 111, 108, 111, 114, 105, 114,
-46, 46, 46, 34, 10, 34, 67, 108, 111, 110, 101, 32, 123, 48, 125, 32, 99, 104, 97, 110, 110, 101, 108, 115,
-34, 32, 61, 32, 34, 67, 108, 111, 110, 97, 114, 32, 123, 48, 125, 32, 99, 97, 110, 97, 105, 115, 34, 10,
-34, 67, 108, 111, 110, 101, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 67, 108, 111, 110, 97,
-114, 32, 99, 97, 110, 97, 108, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 99, 104, 97, 110, 110, 101, 108,
-32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 99, 97, 110, 97, 108, 32,
-97, 113, 117, 105, 34, 10, 34, 83, 101, 110, 100, 32, 116, 111, 32, 102, 114, 101, 101, 32, 109, 105, 120, 101,
-114, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34, 77, 97, 110, 100, 97, 114, 32, 112, 97, 114,
-97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105, 118, 114, 101, 115, 32, 100, 111, 32, 109, 105, 120, 101,
-114, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 123, 48, 125, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34,
-32, 61, 32, 34, 69, 120, 99, 108, 117, 105, 114, 32, 123, 48, 125, 32, 99, 97, 110, 97, 105, 115, 34, 10,
-34, 78, 97, 109, 101, 34, 32, 61, 32, 34, 78, 111, 109, 101, 34, 10, 34, 67, 108, 105, 99, 107, 32, 97,
-32, 99, 111, 108, 111, 114, 44, 32, 111, 114, 32, 112, 114, 101, 115, 115, 32, 70, 50, 32, 102, 111, 114, 32,
-97, 32, 114, 97, 110, 100, 111, 109, 32, 111, 110, 101, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 32,
-110, 117, 109, 97, 32, 99, 111, 114, 44, 32, 111, 117, 32, 97, 112, 101, 114, 116, 101, 32, 70, 50, 32, 112,
-97, 114, 97, 32, 117, 109, 97, 32, 97, 108, 101, 97, 116, 195, 179, 114, 105, 97, 34, 10, 34, 80, 108, 97,
-121, 59, 32, 112, 114, 101, 115, 115, 101, 100, 32, 97, 103, 97, 105, 110, 44, 32, 115, 116, 111, 112, 115, 32,
-97, 110, 100, 32, 103, 111, 101, 115, 32, 98, 97, 99, 107, 32, 116, 111, 32, 119, 104, 101, 114, 101, 32, 105,
-116, 32, 115, 116, 97, 114, 116, 101, 100, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 59, 32, 97, 112, 101,
-114, 116, 97, 100, 111, 32, 100, 101, 32, 110, 111, 118, 111, 44, 32, 112, 97, 114, 97, 32, 101, 32, 118, 111,
-108, 116, 97, 32, 112, 97, 114, 97, 32, 111, 110, 100, 101, 32, 99, 111, 109, 101, 195, 167, 111, 117, 34, 10,
-34, 83, 116, 111, 112, 32, 97, 110, 100, 32, 114, 101, 116, 117, 114, 110, 32, 116, 111, 32, 116, 104, 101, 32,
-115, 116, 97, 114, 116, 32, 40, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 97, 108, 108,
-32, 110, 111, 116, 101, 115, 32, 111, 102, 102, 41, 34, 32, 61, 32, 34, 80, 97, 114, 97, 114, 32, 101, 32,
-118, 111, 108, 116, 97, 114, 32, 97, 111, 32, 105, 110, 195, 173, 99, 105, 111, 32, 40, 100, 117, 112, 108, 111,
-32, 99, 108, 105, 113, 117, 101, 58, 32, 100, 101, 115, 108, 105, 103, 97, 32, 116, 111, 100, 97, 115, 32, 97,
-115, 32, 110, 111, 116, 97, 115, 41, 34, 10, 34, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32,
-115, 104, 111, 119, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 32, 61,
-32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 111, 115, 116, 114, 97,
-114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 10, 34, 82, 105, 103, 104, 116,
-45, 99, 108, 105, 99, 107, 58, 32, 115, 104, 111, 119, 32, 116, 104, 101, 32, 80, 108, 97, 121, 108, 105, 115,
-116, 34, 32, 61, 32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 111,
-115, 116, 114, 97, 114, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 67, 108, 105, 99, 107,
-58, 32, 115, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114, 32, 104, 105, 100, 101, 46, 32, 32,
-82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 115, 104, 111, 119, 32, 109, 97, 120, 105, 109, 105,
-122, 101, 100, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 109, 111, 115, 116, 114, 97, 114, 44,
-32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 46, 32, 32, 66, 111, 116,
-195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 111, 115, 116, 114, 97, 114, 32, 109, 97, 120,
-105, 109, 105, 122, 97, 100, 111, 34, 10, 34, 67, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114,
-110, 32, 40, 78, 117, 109, 112, 97, 100, 32, 43, 47, 45, 58, 32, 110, 101, 120, 116, 47, 112, 114, 101, 118,
-105, 111, 117, 115, 44, 32, 70, 52, 58, 32, 110, 101, 120, 116, 32, 101, 109, 112, 116, 121, 44, 32, 70, 50,
-58, 32, 114, 101, 110, 97, 109, 101, 41, 34, 32, 61, 32, 34, 80, 97, 116, 116, 101, 114, 110, 32, 97, 116,
-117, 97, 108, 32, 40, 78, 117, 109, 112, 97, 100, 32, 43, 47, 45, 58, 32, 112, 114, 195, 179, 120, 105, 109,
-111, 47, 97, 110, 116, 101, 114, 105, 111, 114, 44, 32, 70, 52, 58, 32, 112, 114, 195, 179, 120, 105, 109, 111,
-32, 118, 97, 122, 105, 111, 44, 32, 70, 50, 58, 32, 114, 101, 110, 111, 109, 101, 97, 114, 41, 34, 10, 34,
-80, 97, 116, 116, 101, 114, 110, 58, 32, 114, 101, 110, 97, 109, 101, 44, 32, 99, 111, 108, 111, 114, 44, 32,
-99, 108, 111, 110, 101, 44, 32, 105, 110, 115, 101, 114, 116, 44, 32, 115, 112, 108, 105, 116, 44, 32, 108, 101,
-110, 103, 116, 104, 44, 32, 100, 101, 108, 101, 116, 101, 34, 32, 61, 32, 34, 80, 97, 116, 116, 101, 114, 110,
-58, 32, 114, 101, 110, 111, 109, 101, 97, 114, 44, 32, 99, 111, 114, 44, 32, 99, 108, 111, 110, 97, 114, 44,
-32, 105, 110, 115, 101, 114, 105, 114, 44, 32, 100, 105, 118, 105, 100, 105, 114, 44, 32, 100, 117, 114, 97, 195,
-167, 195, 163, 111, 44, 32, 101, 120, 99, 108, 117, 105, 114, 34, 10, 34, 65, 117, 100, 105, 111, 32, 112, 114,
-111, 99, 101, 115, 115, 105, 110, 103, 32, 108, 111, 97, 100, 34, 32, 61, 32, 34, 67, 97, 114, 103, 97, 32,
-100, 111, 32, 112, 114, 111, 99, 101, 115, 115, 97, 109, 101, 110, 116, 111, 32, 100, 101, 32, 195, 161, 117, 100,
-105, 111, 34, 10, 34, 83, 104, 105, 102, 116, 43, 119, 104, 101, 101, 108, 32, 104, 101, 114, 101, 32, 99, 104,
-97, 110, 103, 101, 115, 32, 116, 104, 101, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 83, 104,
-105, 102, 116, 43, 114, 111, 100, 97, 32, 97, 113, 117, 105, 32, 116, 114, 111, 99, 97, 32, 111, 32, 112, 97,
-116, 116, 101, 114, 110, 34, 10, 34, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 58, 32, 99, 108, 105, 99,
-107, 32, 97, 100, 100, 115, 32, 97, 32, 110, 111, 116, 101, 44, 32, 100, 114, 97, 103, 32, 109, 111, 118, 101,
-115, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 100, 101, 108, 101, 116, 101, 115, 44, 32,
-67, 116, 114, 108, 43, 100, 114, 97, 103, 32, 115, 101, 108, 101, 99, 116, 115, 34, 32, 61, 32, 34, 80, 105,
-97, 110, 111, 32, 82, 111, 108, 108, 58, 32, 99, 108, 105, 113, 117, 101, 32, 97, 100, 105, 99, 105, 111, 110,
-97, 32, 110, 111, 116, 97, 44, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 109, 111, 118, 101, 44, 32, 98,
-111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 112, 97, 103, 97, 44, 32, 67, 116, 114,
-108, 43, 97, 114, 114, 97, 115, 116, 97, 114, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 34, 10, 34, 80,
-108, 97, 121, 108, 105, 115, 116, 58, 32, 99, 108, 105, 99, 107, 32, 112, 97, 105, 110, 116, 115, 32, 116, 104,
-101, 32, 99, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114, 110, 44, 32, 114, 105, 103, 104, 116,
-45, 99, 108, 105, 99, 107, 32, 100, 101, 108, 101, 116, 101, 115, 44, 32, 67, 116, 114, 108, 43, 100, 114, 97,
-103, 32, 115, 101, 108, 101, 99, 116, 115, 34, 32, 61, 32, 34, 80, 108, 97, 121, 108, 105, 115, 116, 58, 32,
-99, 108, 105, 113, 117, 101, 32, 112, 105, 110, 116, 97, 32, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 97,
-116, 117, 97, 108, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 112, 97,
-103, 97, 44, 32, 67, 116, 114, 108, 43, 97, 114, 114, 97, 115, 116, 97, 114, 32, 115, 101, 108, 101, 99, 105,
-111, 110, 97, 34, 10, 34, 84, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115,
-32, 97, 32, 112, 105, 97, 110, 111, 58, 32, 111, 110, 32, 40, 90, 46, 46, 77, 32, 97, 110, 100, 32, 81,
-46, 46, 80, 32, 112, 108, 97, 121, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104,
-97, 110, 110, 101, 108, 115, 41, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32, 80,
-67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 58, 32, 108, 105, 103, 97, 100, 111, 32, 40, 90, 46,
-46, 77, 32, 101, 32, 81, 46, 46, 80, 32, 116, 111, 99, 97, 109, 32, 111, 115, 32, 99, 97, 110, 97, 105,
-115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 41, 34, 10, 34, 84, 121, 112, 105, 110, 103,
-32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 58, 32, 111, 102,
-102, 32, 40, 108, 101, 116, 116, 101, 114, 32, 97, 110, 100, 32, 110, 117, 109, 98, 101, 114, 32, 107, 101, 121,
-115, 32, 97, 114, 101, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 41, 34, 32, 61, 32, 34, 84, 101, 99,
-108, 97, 100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 58, 32, 100,
-101, 115, 108, 105, 103, 97, 100, 111, 32, 40, 108, 101, 116, 114, 97, 115, 32, 101, 32, 110, 195, 186, 109, 101,
-114, 111, 115, 32, 115, 195, 163, 111, 32, 97, 116, 97, 108, 104, 111, 115, 41, 34, 10, 34, 83, 97, 118, 101,
-32, 108, 97, 121, 111, 117, 116, 32, 97, 115, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 108, 97,
-121, 111, 117, 116, 32, 99, 111, 109, 111, 34, 10, 34, 78, 97, 109, 101, 32, 111, 102, 32, 116, 104, 101, 32,
-108, 97, 121, 111, 117, 116, 58, 34, 32, 61, 32, 34, 78, 111, 109, 101, 32, 100, 111, 32, 108, 97, 121, 111,
-117, 116, 58, 34, 10, 34, 77, 121, 32, 108, 97, 121, 111, 117, 116, 34, 32, 61, 32, 34, 77, 101, 117, 32,
-108, 97, 121, 111, 117, 116, 34, 10, 34, 40, 110, 111, 110, 101, 32, 115, 97, 118, 101, 100, 32, 121, 101, 116,
-41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104, 117, 109, 32, 115, 97, 108, 118, 111, 32, 97, 105, 110, 100,
-97, 41, 34, 10, 34, 79, 112, 101, 110, 32, 108, 97, 121, 111, 117, 116, 115, 32, 102, 111, 108, 100, 101, 114,
-34, 32, 61, 32, 34, 65, 98, 114, 105, 114, 32, 112, 97, 115, 116, 97, 32, 100, 101, 32, 108, 97, 121, 111,
-117, 116, 115, 34, 10, 34, 83, 112, 108, 105, 116, 32, 98, 121, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32,
-61, 32, 34, 68, 105, 118, 105, 100, 105, 114, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 34, 10, 34, 84,
-104, 105, 115, 32, 112, 97, 116, 116, 101, 114, 110, 32, 104, 97, 115, 32, 110, 111, 32, 110, 111, 116, 101, 115,
-46, 34, 32, 61, 32, 34, 69, 115, 116, 101, 32, 112, 97, 116, 116, 101, 114, 110, 32, 110, 195, 163, 111, 32,
-116, 101, 109, 32, 110, 111, 116, 97, 115, 46, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 97, 110, 32, 101,
-109, 112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 98, 101, 102, 111, 114, 101, 32, 116, 104, 105, 115,
-32, 111, 110, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 117, 109, 32, 112, 97, 116, 116,
-101, 114, 110, 32, 118, 97, 122, 105, 111, 32, 97, 110, 116, 101, 115, 32, 100, 101, 115, 116, 101, 34, 10, 34,
-83, 112, 108, 105, 116, 32, 98, 121, 32, 99, 104, 97, 110, 110, 101, 108, 32, 40, 111, 110, 101, 32, 110, 101,
-119, 32, 112, 97, 116, 116, 101, 114, 110, 32, 112, 101, 114, 32, 99, 104, 97, 110, 110, 101, 108, 41, 34, 32,
-61, 32, 34, 68, 105, 118, 105, 100, 105, 114, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 32, 40, 117, 109,
-32, 112, 97, 116, 116, 101, 114, 110, 32, 110, 111, 118, 111, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 41,
-34, 10, 34, 100, 114, 97, 103, 32, 116, 104, 101, 32, 100, 101, 99, 105, 109, 97, 108, 115, 32, 102, 111, 114,
-32, 102, 105, 110, 101, 32, 99, 104, 97, 110, 103, 101, 115, 44, 32, 119, 104, 101, 101, 108, 44, 32, 100, 111,
-117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 116, 121, 112, 101, 34, 32, 61, 32, 34, 97,
-114, 114, 97, 115, 116, 101, 32, 111, 115, 32, 100, 101, 99, 105, 109, 97, 105, 115, 32, 112, 97, 114, 97, 32,
-97, 106, 117, 115, 116, 101, 32, 102, 105, 110, 111, 44, 32, 114, 111, 100, 97, 44, 32, 100, 117, 112, 108, 111,
-32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114, 97, 32, 100, 105, 103, 105, 116, 97, 114, 34, 10, 34, 100,
-114, 97, 103, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 110, 117, 109, 98, 101, 114, 32, 102, 111, 114,
-32, 66, 80, 77, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 101, 41, 44, 32, 119, 104, 101, 101, 108,
-44, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 116, 121, 112, 101, 34, 32,
-61, 32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 111, 32, 110, 195, 186, 109, 101, 114, 111, 32, 105, 110, 116,
-101, 105, 114, 111, 32, 112, 97, 114, 97, 32, 111, 32, 66, 80, 77, 32, 40, 67, 116, 114, 108, 58, 32, 102,
-105, 110, 111, 41, 44, 32, 114, 111, 100, 97, 44, 32, 100, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101,
-32, 112, 97, 114, 97, 32, 100, 105, 103, 105, 116, 97, 114, 34, 10, 34, 84, 121, 112, 101, 32, 118, 97, 108,
-117, 101, 46, 46, 46, 34, 32, 61, 32, 34, 68, 105, 103, 105, 116, 97, 114, 32, 118, 97, 108, 111, 114, 46,
-46, 46, 34, 10, 34, 84, 97, 112, 32, 116, 101, 109, 112, 111, 46, 46, 46, 34, 32, 61, 32, 34, 84, 97,
-112, 32, 116, 101, 109, 112, 111, 46, 46, 46, 34, 10, 34, 72, 97, 108, 102, 32, 40, 123, 48, 125, 32, 66,
-80, 77, 41, 34, 32, 61, 32, 34, 77, 101, 116, 97, 100, 101, 32, 40, 123, 48, 125, 32, 66, 80, 77, 41,
-34, 10, 34, 68, 111, 117, 98, 108, 101, 32, 40, 123, 48, 125, 32, 66, 80, 77, 41, 34, 32, 61, 32, 34,
-68, 111, 98, 114, 111, 32, 40, 123, 48, 125, 32, 66, 80, 77, 41, 34, 10, 34, 82, 101, 115, 101, 116, 32,
-40, 123, 48, 125, 41, 34, 32, 61, 32, 34, 82, 101, 115, 101, 116, 97, 114, 32, 40, 123, 48, 125, 41, 34,
-10, 34, 84, 97, 112, 34, 32, 61, 32, 34, 84, 97, 112, 34, 10, 34, 67, 108, 105, 99, 107, 32, 40, 111,
-114, 32, 112, 114, 101, 115, 115, 32, 84, 41, 32, 111, 110, 32, 101, 97, 99, 104, 32, 98, 101, 97, 116, 34,
-32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 32, 40, 111, 117, 32, 97, 112, 101, 114, 116, 101, 32, 84, 41,
-32, 101, 109, 32, 99, 97, 100, 97, 32, 116, 101, 109, 112, 111, 34, 10, 34, 123, 48, 125, 32, 116, 97, 112,
-115, 58, 32, 123, 49, 125, 32, 66, 80, 77, 34, 32, 61, 32, 34, 123, 48, 125, 32, 116, 111, 113, 117, 101,
-115, 58, 32, 123, 49, 125, 32, 66, 80, 77, 34, 10, 34, 70, 49, 32, 115, 104, 111, 114, 116, 99, 117, 116,
-115, 32, 32, 32, 70, 53, 45, 70, 57, 32, 112, 97, 110, 101, 108, 115, 32, 32, 32, 83, 112, 97, 99, 101,
-32, 112, 108, 97, 121, 47, 115, 116, 111, 112, 32, 32, 32, 67, 116, 114, 108, 43, 84, 32, 116, 121, 112, 105,
-110, 103, 32, 112, 105, 97, 110, 111, 32, 40, 123, 48, 125, 41, 34, 32, 61, 32, 34, 70, 49, 32, 97, 116,
-97, 108, 104, 111, 115, 32, 32, 32, 70, 53, 45, 70, 57, 32, 112, 97, 105, 110, 195, 169, 105, 115, 32, 32,
-32, 69, 115, 112, 97, 195, 167, 111, 32, 116, 111, 99, 97, 47, 112, 97, 114, 97, 32, 32, 32, 67, 116, 114,
-108, 43, 84, 32, 116, 101, 99, 108, 97, 100, 111, 45, 112, 105, 97, 110, 111, 32, 40, 123, 48, 125, 41, 34,
-10, 34, 111, 110, 34, 32, 61, 32, 34, 108, 105, 103, 97, 100, 111, 34, 10, 34, 111, 102, 102, 34, 32, 61,
-32, 34, 100, 101, 115, 108, 105, 103, 97, 100, 111, 34, 10, 34, 68, 101, 116, 97, 99, 104, 101, 100, 32, 112,
-97, 110, 101, 108, 115, 32, 40, 111, 119, 110, 32, 119, 105, 110, 100, 111, 119, 41, 34, 32, 61, 32, 34, 80,
-97, 105, 110, 195, 169, 105, 115, 32, 100, 101, 115, 116, 97, 99, 97, 100, 111, 115, 32, 40, 106, 97, 110, 101,
-108, 97, 32, 112, 114, 195, 179, 112, 114, 105, 97, 41, 34, 10, 34, 82, 101, 115, 101, 116, 32, 108, 97, 121,
-111, 117, 116, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 108, 97, 121, 111, 117, 116,
-32, 112, 97, 100, 114, 195, 163, 111, 34, 10, 34, 83, 97, 118, 101, 32, 108, 97, 121, 111, 117, 116, 32, 97,
-115, 46, 46, 46, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 108, 97, 121, 111, 117, 116, 32, 99,
-111, 109, 111, 46, 46, 46, 34, 10, 34, 76, 111, 97, 100, 32, 108, 97, 121, 111, 117, 116, 34, 32, 61, 32,
-34, 67, 97, 114, 114, 101, 103, 97, 114, 32, 108, 97, 121, 111, 117, 116, 34, 10, 34, 66, 114, 105, 110, 103,
-32, 98, 97, 99, 107, 32, 111, 102, 102, 45, 115, 99, 114, 101, 101, 110, 32, 112, 97, 110, 101, 108, 115, 34,
-32, 61, 32, 34, 84, 114, 97, 122, 101, 114, 32, 100, 101, 32, 118, 111, 108, 116, 97, 32, 112, 97, 105, 110,
-195, 169, 105, 115, 32, 102, 111, 114, 97, 32, 100, 97, 32, 116, 101, 108, 97, 34, 10, 34, 84, 121, 112, 105,
-110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 34, 32,
-61, 32, 34, 84, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105,
-97, 110, 111, 34, 10, 34, 75, 101, 101, 112, 32, 99, 104, 97, 110, 110, 101, 108, 32, 101, 100, 105, 116, 111,
-114, 115, 32, 111, 112, 101, 110, 32, 40, 97, 32, 99, 104, 97, 110, 110, 101, 108, 32, 98, 117, 116, 116, 111,
-110, 32, 99, 108, 105, 99, 107, 32, 100, 111, 101, 115, 110, 39, 116, 32, 99, 108, 111, 115, 101, 32, 116, 104,
-101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 101, 100, 105, 116, 111, 114, 41, 34, 32, 61, 32, 34, 77,
-97, 110, 116, 101, 114, 32, 101, 100, 105, 116, 111, 114, 101, 115, 32, 100, 101, 32, 99, 97, 110, 97, 108, 32,
-97, 98, 101, 114, 116, 111, 115, 32, 40, 99, 108, 105, 99, 97, 114, 32, 110, 117, 109, 32, 99, 97, 110, 97,
-108, 32, 110, 195, 163, 111, 32, 102, 101, 99, 104, 97, 32, 111, 32, 101, 100, 105, 116, 111, 114, 32, 97, 110,
-116, 101, 114, 105, 111, 114, 41, 34, 10, 34, 69, 100, 105, 116, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32,
-115, 104, 111, 114, 116, 99, 117, 116, 115, 32, 40, 107, 101, 121, 115, 46, 106, 115, 111, 110, 41, 46, 46, 46,
-34, 32, 61, 32, 34, 69, 100, 105, 116, 97, 114, 32, 97, 116, 97, 108, 104, 111, 115, 32, 100, 101, 32, 116,
-101, 99, 108, 97, 100, 111, 32, 40, 107, 101, 121, 115, 46, 106, 115, 111, 110, 41, 46, 46, 46, 34, 10, 34,
-82, 101, 108, 111, 97, 100, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 115, 104, 111, 114, 116, 99, 117, 116,
-115, 34, 32, 61, 32, 34, 82, 101, 99, 97, 114, 114, 101, 103, 97, 114, 32, 97, 116, 97, 108, 104, 111, 115,
-32, 100, 101, 32, 116, 101, 99, 108, 97, 100, 111, 34, 10, 34, 80, 97, 110, 101, 108, 115, 58, 32, 80, 108,
-97, 121, 108, 105, 115, 116, 44, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 44, 32, 80, 105,
-97, 110, 111, 32, 82, 111, 108, 108, 44, 32, 77, 105, 120, 101, 114, 44, 32, 66, 114, 111, 119, 115, 101, 114,
-34, 32, 61, 32, 34, 80, 97, 105, 110, 195, 169, 105, 115, 58, 32, 80, 108, 97, 121, 108, 105, 115, 116, 44,
-32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 44, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108,
-108, 44, 32, 77, 105, 120, 101, 114, 44, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 80, 67, 32, 107,
-101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 32, 40, 115, 101, 108, 101,
-99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 41, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97,
-100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 32, 40, 99, 97, 110,
-97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 41, 34, 10, 34, 78, 117, 109, 112,
-97, 100, 32, 43, 47, 45, 32, 32, 70, 52, 32, 32, 70, 50, 34, 32, 61, 32, 34, 78, 117, 109, 112, 97,
-100, 32, 43, 47, 45, 32, 32, 70, 52, 32, 32, 70, 50, 34, 10, 34, 78, 101, 120, 116, 47, 112, 114, 101,
-118, 105, 111, 117, 115, 32, 112, 97, 116, 116, 101, 114, 110, 44, 32, 110, 101, 120, 116, 32, 101, 109, 112, 116,
-121, 44, 32, 114, 101, 110, 97, 109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111, 114, 34, 32, 61, 32, 34,
-80, 97, 116, 116, 101, 114, 110, 32, 112, 114, 195, 179, 120, 105, 109, 111, 47, 97, 110, 116, 101, 114, 105, 111,
-114, 44, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 118, 97, 122, 105, 111, 44, 32, 114, 101, 110, 111, 109,
-101, 97, 114, 32, 101, 32, 99, 111, 108, 111, 114, 105, 114, 34, 10, 34, 87, 111, 114, 107, 115, 112, 97, 99,
-101, 34, 32, 61, 32, 34, 195, 129, 114, 101, 97, 32, 100, 101, 32, 116, 114, 97, 98, 97, 108, 104, 111, 34,
-10, 34, 68, 114, 97, 103, 32, 97, 32, 112, 97, 110, 101, 108, 32, 116, 105, 116, 108, 101, 34, 32, 61, 32,
-34, 65, 114, 114, 97, 115, 116, 97, 114, 32, 111, 32, 116, 195, 173, 116, 117, 108, 111, 32, 100, 111, 32, 112,
-97, 105, 110, 101, 108, 34, 10, 34, 77, 111, 118, 101, 32, 40, 115, 110, 97, 112, 115, 59, 32, 65, 108, 116,
-58, 32, 102, 114, 101, 101, 41, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 40, 101, 110, 99, 97, 105,
-120, 97, 59, 32, 65, 108, 116, 58, 32, 108, 105, 118, 114, 101, 41, 34, 10, 34, 68, 111, 117, 98, 108, 101,
-45, 99, 108, 105, 99, 107, 32, 97, 32, 116, 105, 116, 108, 101, 34, 32, 61, 32, 34, 68, 117, 112, 108, 111,
-32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 34, 10, 34, 77, 97, 120,
-105, 109, 105, 122, 101, 32, 47, 32, 114, 101, 115, 116, 111, 114, 101, 34, 32, 61, 32, 34, 77, 97, 120, 105,
-109, 105, 122, 97, 114, 32, 47, 32, 114, 101, 115, 116, 97, 117, 114, 97, 114, 34, 10, 34, 84, 105, 116, 108,
-101, 32, 98, 117, 116, 116, 111, 110, 115, 34, 32, 61, 32, 34, 66, 111, 116, 195, 181, 101, 115, 32, 100, 111,
-32, 116, 195, 173, 116, 117, 108, 111, 34, 10, 34, 68, 101, 116, 97, 99, 104, 32, 105, 110, 116, 111, 32, 97,
-32, 119, 105, 110, 100, 111, 119, 44, 32, 109, 97, 120, 105, 109, 105, 122, 101, 44, 32, 99, 108, 111, 115, 101,
-34, 32, 61, 32, 34, 68, 101, 115, 116, 97, 99, 97, 114, 32, 101, 109, 32, 106, 97, 110, 101, 108, 97, 44,
-32, 109, 97, 120, 105, 109, 105, 122, 97, 114, 44, 32, 102, 101, 99, 104, 97, 114, 34, 10, 34, 86, 105, 101,
-119, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 77, 101, 110, 117, 32, 69, 120, 105, 98, 105, 114, 34, 10,
-34, 82, 101, 115, 101, 116, 44, 32, 115, 97, 118, 101, 32, 97, 110, 100, 32, 108, 111, 97, 100, 32, 108, 97,
-121, 111, 117, 116, 115, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 44, 32, 115, 97, 108,
-118, 97, 114, 32, 101, 32, 99, 97, 114, 114, 101, 103, 97, 114, 32, 108, 97, 121, 111, 117, 116, 115, 34, 10,
-34, 67, 108, 105, 99, 107, 32, 116, 104, 101, 32, 110, 97, 109, 101, 34, 32, 61, 32, 34, 67, 108, 105, 113,
-117, 101, 32, 110, 111, 32, 110, 111, 109, 101, 34, 10, 34, 79, 112, 101, 110, 47, 99, 108, 111, 115, 101, 32,
-116, 104, 101, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 107, 101, 101, 112, 115, 32, 111, 116,
-104, 101, 114, 115, 32, 111, 112, 101, 110, 41, 34, 32, 61, 32, 34, 65, 98, 114, 101, 47, 102, 101, 99, 104,
-97, 32, 111, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 109, 97, 110, 116, 195, 169, 109, 32,
-111, 115, 32, 111, 117, 116, 114, 111, 115, 41, 34, 10, 34, 67, 116, 114, 108, 43, 99, 108, 105, 99, 107, 32,
-116, 104, 101, 32, 110, 97, 109, 101, 34, 32, 61, 32, 34, 67, 116, 114, 108, 43, 99, 108, 105, 113, 117, 101,
-32, 110, 111, 32, 110, 111, 109, 101, 34, 10, 34, 65, 117, 100, 105, 116, 105, 111, 110, 32, 116, 104, 101, 32,
-99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 79, 117, 118, 105, 114, 32, 111, 32, 99, 97, 110, 97,
-108, 34, 10, 34, 83, 101, 108, 101, 99, 116, 111, 114, 32, 47, 32, 85, 112, 44, 32, 68, 111, 119, 110, 34,
-32, 61, 32, 34, 83, 101, 108, 101, 116, 111, 114, 32, 47, 32, 67, 105, 109, 97, 44, 32, 66, 97, 105, 120,
-111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 40, 67, 116, 114, 108, 58, 32, 97, 100, 100, 44, 32, 83,
-104, 105, 102, 116, 58, 32, 114, 97, 110, 103, 101, 41, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111,
-110, 97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 105, 110, 99, 108, 117, 105, 114, 44, 32, 83, 104, 105, 102,
-116, 58, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 41, 34, 10, 34, 77, 111, 118, 101, 32, 116, 104, 101,
-32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 77,
-111, 118, 101, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97,
-100, 111, 115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 47, 32, 100, 101, 108, 101, 116, 101, 32, 116, 104, 101,
-32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 67,
-108, 111, 110, 97, 114, 32, 47, 32, 101, 120, 99, 108, 117, 105, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105,
-115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 34, 10, 34, 49, 46, 46, 48, 32, 47, 32,
-67, 116, 114, 108, 43, 49, 46, 46, 48, 34, 32, 61, 32, 34, 49, 46, 46, 48, 32, 47, 32, 67, 116, 114,
-108, 43, 49, 46, 46, 48, 34, 10, 34, 77, 117, 116, 101, 32, 47, 32, 115, 111, 108, 111, 32, 99, 104, 97,
-110, 110, 101, 108, 115, 32, 49, 45, 49, 48, 32, 40, 116, 121, 112, 105, 110, 103, 32, 112, 105, 97, 110, 111,
-32, 111, 102, 102, 41, 34, 32, 61, 32, 34, 83, 105, 108, 101, 110, 99, 105, 97, 114, 32, 47, 32, 115, 111,
-108, 111, 32, 110, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 49, 45, 49, 48, 32, 40, 116, 101, 99, 108,
-97, 100, 111, 45, 112, 105, 97, 110, 111, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 41, 34, 10, 34, 75,
-110, 111, 98, 115, 32, 97, 110, 100, 32, 102, 97, 100, 101, 114, 115, 34, 32, 61, 32, 34, 75, 110, 111, 98,
-115, 32, 101, 32, 102, 97, 100, 101, 114, 115, 34, 10, 34, 68, 114, 97, 103, 32, 40, 67, 116, 114, 108, 58,
-32, 102, 105, 110, 101, 41, 44, 32, 119, 104, 101, 101, 108, 44, 32, 65, 108, 116, 43, 99, 108, 105, 99, 107,
-32, 111, 114, 32, 109, 105, 100, 100, 108, 101, 45, 99, 108, 105, 99, 107, 32, 114, 101, 115, 101, 116, 115, 34,
-32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 111,
-41, 44, 32, 114, 111, 100, 97, 44, 32, 65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 32, 111, 117, 32, 98,
-111, 116, 195, 163, 111, 32, 100, 111, 32, 109, 101, 105, 111, 32, 114, 101, 115, 101, 116, 97, 34, 10, 34, 84,
-121, 112, 101, 32, 118, 97, 108, 117, 101, 44, 32, 114, 101, 115, 101, 116, 44, 32, 97, 117, 116, 111, 109, 97,
-116, 105, 111, 110, 44, 32, 77, 73, 68, 73, 32, 108, 105, 110, 107, 34, 32, 61, 32, 34, 68, 105, 103, 105,
-116, 97, 114, 32, 118, 97, 108, 111, 114, 44, 32, 114, 101, 115, 101, 116, 97, 114, 44, 32, 97, 117, 116, 111,
-109, 97, 195, 167, 195, 163, 111, 44, 32, 108, 105, 110, 107, 32, 77, 73, 68, 73, 34, 10, 34, 82, 105, 103,
-104, 116, 45, 99, 108, 105, 99, 107, 32, 80, 97, 116, 116, 101, 114, 110, 32, 47, 32, 83, 111, 110, 103, 34,
-32, 61, 32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 101, 109, 32, 80, 97,
-116, 116, 101, 114, 110, 32, 47, 32, 83, 111, 110, 103, 34, 10, 34, 83, 104, 111, 119, 32, 116, 104, 101, 32,
-67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 47, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34,
-32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97,
-99, 107, 32, 47, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 68, 111, 117, 98, 108, 101,
-45, 99, 108, 105, 99, 107, 32, 83, 116, 111, 112, 34, 32, 61, 32, 34, 68, 117, 112, 108, 111, 32, 99, 108,
-105, 113, 117, 101, 32, 110, 111, 32, 83, 116, 111, 112, 34, 10, 34, 65, 108, 108, 32, 110, 111, 116, 101, 115,
-32, 111, 102, 102, 34, 32, 61, 32, 34, 68, 101, 115, 108, 105, 103, 97, 114, 32, 116, 111, 100, 97, 115, 32,
-97, 115, 32, 110, 111, 116, 97, 115, 34, 10, 34, 65, 100, 100, 32, 97, 32, 109, 105, 120, 101, 114, 32, 105,
-110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 105,
-110, 115, 101, 114, 116, 32, 97, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 83, 111, 108, 111, 34, 32, 61,
-32, 34, 83, 111, 108, 111, 34, 10, 34, 83, 101, 110, 100, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 115,
-101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 32, 116, 111, 32, 116, 104, 105, 115, 32, 111,
-110, 101, 32, 40, 100, 114, 97, 103, 32, 97, 102, 116, 101, 114, 32, 101, 110, 97, 98, 108, 105, 110, 103, 58,
-32, 108, 101, 118, 101, 108, 41, 34, 32, 61, 32, 34, 69, 110, 118, 105, 111, 32, 100, 111, 32, 105, 110, 115,
-101, 114, 116, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 32, 112, 97, 114, 97, 32, 101, 115, 116,
-101, 32, 40, 97, 114, 114, 97, 115, 116, 101, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 108, 105, 103,
-97, 114, 58, 32, 110, 195, 173, 118, 101, 108, 41, 34, 10, 34, 67, 108, 105, 99, 107, 32, 115, 101, 108, 101,
-99, 116, 115, 32, 116, 104, 101, 32, 105, 110, 115, 101, 114, 116, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108,
-105, 99, 107, 32, 111, 112, 101, 110, 115, 32, 105, 116, 115, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 67,
-108, 105, 113, 117, 101, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 32, 111, 32, 105, 110, 115, 101, 114, 116,
-44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 98, 114, 101, 32, 111, 32,
-109, 101, 110, 117, 34, 10, 34, 69, 102, 102, 101, 99, 116, 32, 115, 108, 111, 116, 58, 32, 99, 108, 105, 99,
-107, 32, 101, 100, 105, 116, 115, 44, 32, 116, 104, 101, 32, 76, 69, 68, 32, 98, 121, 112, 97, 115, 115, 101,
-115, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 114, 101, 112, 108, 97, 99, 101, 44,
-32, 109, 111, 118, 101, 44, 32, 100, 101, 108, 101, 116, 101, 34, 32, 61, 32, 34, 83, 108, 111, 116, 32, 100,
-101, 32, 101, 102, 101, 105, 116, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 101, 100, 105, 116, 97, 44, 32,
-111, 32, 76, 69, 68, 32, 102, 97, 122, 32, 98, 121, 112, 97, 115, 115, 44, 32, 98, 111, 116, 195, 163, 111,
-32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 116, 114, 111, 99, 97, 114, 44, 32, 109, 111, 118, 101, 114, 44,
-32, 101, 120, 99, 108, 117, 105, 114, 34, 10, 34, 69, 109, 112, 116, 121, 32, 115, 108, 111, 116, 58, 32, 99,
-108, 105, 99, 107, 32, 116, 111, 32, 97, 100, 100, 32, 97, 110, 32, 101, 102, 102, 101, 99, 116, 34, 32, 61,
-32, 34, 83, 108, 111, 116, 32, 118, 97, 122, 105, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114,
-97, 32, 97, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 101, 102, 101, 105, 116, 111, 34, 10, 34,
-67, 101, 110, 116, 101, 114, 101, 100, 34, 32, 61, 32, 34, 67, 101, 110, 116, 114, 111, 34, 10, 34, 123, 48,
-125, 37, 32, 108, 101, 102, 116, 34, 32, 61, 32, 34, 123, 48, 125, 37, 32, 101, 115, 113, 117, 101, 114, 100,
-97, 34, 10, 34, 123, 48, 125, 37, 32, 114, 105, 103, 104, 116, 34, 32, 61, 32, 34, 123, 48, 125, 37, 32,
-100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 84, 121, 112, 101, 32, 118, 97, 108, 117, 101, 34, 32, 61, 32,
-34, 68, 105, 103, 105, 116, 97, 114, 32, 118, 97, 108, 111, 114, 34, 10, 34, 75, 110, 111, 98, 34, 32, 61,
-32, 34, 75, 110, 111, 98, 34, 10, 34, 67, 108, 111, 115, 101, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108,
-32, 40, 105, 116, 115, 32, 70, 45, 107, 101, 121, 32, 115, 104, 111, 119, 115, 32, 105, 116, 32, 97, 103, 97,
-105, 110, 41, 34, 32, 61, 32, 34, 70, 101, 99, 104, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32,
-40, 97, 32, 116, 101, 99, 108, 97, 32, 70, 32, 100, 101, 108, 101, 32, 109, 111, 115, 116, 114, 97, 32, 100,
-101, 32, 110, 111, 118, 111, 41, 34, 10, 34, 68, 111, 99, 107, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108,
-32, 98, 97, 99, 107, 32, 105, 110, 116, 111, 32, 116, 104, 101, 32, 109, 97, 105, 110, 32, 119, 105, 110, 100,
-111, 119, 34, 32, 61, 32, 34, 82, 101, 99, 111, 108, 111, 99, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101,
-108, 32, 110, 97, 32, 106, 97, 110, 101, 108, 97, 32, 112, 114, 105, 110, 99, 105, 112, 97, 108, 34, 10, 34,
-68, 101, 116, 97, 99, 104, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108, 32, 105, 110, 116, 111, 32, 105, 116,
-115, 32, 111, 119, 110, 32, 119, 105, 110, 100, 111, 119, 34, 32, 61, 32, 34, 68, 101, 115, 116, 97, 99, 97,
-114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 110, 117, 109, 97, 32, 106, 97, 110, 101, 108, 97, 32, 112,
-114, 195, 179, 112, 114, 105, 97, 34, 10, 34, 82, 101, 115, 116, 111, 114, 101, 32, 116, 104, 101, 32, 112, 97,
-110, 101, 108, 32, 115, 105, 122, 101, 32, 40, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116,
-104, 101, 32, 116, 105, 116, 108, 101, 41, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32,
-111, 32, 116, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97, 105, 110, 101, 108, 32, 40, 100, 117, 112,
-108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 41, 34, 10, 34,
-77, 97, 120, 105, 109, 105, 122, 101, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108, 32, 40, 100, 111, 117, 98,
-108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 104, 101, 32, 116, 105, 116, 108, 101, 41, 34, 32, 61, 32, 34,
-77, 97, 120, 105, 109, 105, 122, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 40, 100, 117, 112, 108,
-111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 41, 34, 10, 34, 68,
-114, 97, 103, 32, 116, 104, 101, 32, 101, 100, 103, 101, 32, 116, 111, 32, 114, 101, 115, 105, 122, 101, 32, 116,
-104, 101, 32, 112, 97, 110, 101, 108, 34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 101, 32, 97, 32, 98,
-111, 114, 100, 97, 32, 112, 97, 114, 97, 32, 114, 101, 100, 105, 109, 101, 110, 115, 105, 111, 110, 97, 114, 32,
-111, 32, 112, 97, 105, 110, 101, 108, 34, 10, 34, 68, 111, 99, 107, 115, 32, 98, 97, 99, 107, 32, 119, 105,
-116, 104, 32, 116, 104, 101, 32, 98, 117, 116, 116, 111, 110, 32, 111, 110, 32, 116, 104, 101, 32, 114, 105, 103,
-104, 116, 34, 32, 61, 32, 34, 86, 111, 108, 116, 97, 32, 112, 97, 114, 97, 32, 97, 32, 106, 97, 110, 101,
-108, 97, 32, 112, 114, 105, 110, 99, 105, 112, 97, 108, 32, 99, 111, 109, 32, 111, 32, 98, 111, 116, 195, 163,
-111, 32, 195, 160, 32, 100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 68, 114, 97, 103, 32, 116, 111, 32, 109,
-111, 118, 101, 32, 40, 65, 108, 116, 58, 32, 110, 111, 32, 115, 110, 97, 112, 112, 105, 110, 103, 41, 44, 32,
-100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 109, 97, 120, 105, 109, 105, 122, 101,
-34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 101, 32, 112, 97, 114, 97, 32, 109, 111, 118, 101, 114, 32,
-40, 65, 108, 116, 58, 32, 115, 101, 109, 32, 101, 110, 99, 97, 105, 120, 101, 41, 44, 32, 100, 117, 112, 108,
-111, 32, 99, 108, 105, 113, 117, 101, 32, 109, 97, 120, 105, 109, 105, 122, 97, 34, 10, 34, 70, 53, 32, 80,
-108, 97, 121, 108, 105, 115, 116, 32, 32, 32, 70, 54, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99,
-107, 32, 32, 32, 70, 55, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 32, 32, 70, 56, 32, 66,
-114, 111, 119, 115, 101, 114, 32, 32, 32, 70, 57, 32, 77, 105, 120, 101, 114, 34, 32, 61, 32, 34, 70, 53,
-32, 80, 108, 97, 121, 108, 105, 115, 116, 32, 32, 32, 70, 54, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82,
-97, 99, 107, 32, 32, 32, 70, 55, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 32, 32, 70, 56,
-32, 66, 114, 111, 119, 115, 101, 114, 32, 32, 32, 70, 57, 32, 77, 105, 120, 101, 114, 34, 10, 10, 35, 32,
-45, 45, 45, 32, 83, 116, 97, 114, 116, 45, 117, 112, 58, 32, 115, 112, 108, 97, 115, 104, 32, 115, 99, 114,
-101, 101, 110, 32, 97, 110, 100, 32, 115, 111, 117, 110, 100, 10, 34, 83, 116, 97, 114, 116, 105, 110, 103, 32,
-116, 104, 101, 32, 97, 117, 100, 105, 111, 32, 101, 110, 103, 105, 110, 101, 46, 46, 46, 34, 32, 61, 32, 34,
-73, 110, 105, 99, 105, 97, 110, 100, 111, 32, 111, 32, 109, 111, 116, 111, 114, 32, 100, 101, 32, 195, 161, 117,
-100, 105, 111, 46, 46, 46, 34, 10, 34, 76, 111, 97, 100, 105, 110, 103, 32, 116, 104, 101, 32, 119, 111, 114,
-107, 115, 112, 97, 99, 101, 46, 46, 46, 34, 32, 61, 32, 34, 67, 97, 114, 114, 101, 103, 97, 110, 100, 111,
-32, 97, 32, 195, 161, 114, 101, 97, 32, 100, 101, 32, 116, 114, 97, 98, 97, 108, 104, 111, 46, 46, 46, 34,
-10, 34, 68, 105, 103, 105, 116, 97, 108, 32, 97, 117, 100, 105, 111, 32, 119, 111, 114, 107, 115, 116, 97, 116,
-105, 111, 110, 34, 32, 61, 32, 34, 69, 115, 116, 97, 195, 167, 195, 163, 111, 32, 100, 101, 32, 116, 114, 97,
-98, 97, 108, 104, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 100, 105, 103, 105, 116, 97, 108, 34,
-10, 34, 86, 101, 114, 115, 105, 111, 110, 32, 123, 48, 125, 34, 32, 61, 32, 34, 86, 101, 114, 115, 195, 163,
-111, 32, 123, 48, 125, 34, 10, 34, 83, 104, 111, 119, 32, 116, 104, 101, 32, 115, 112, 108, 97, 115, 104, 32,
-115, 99, 114, 101, 101, 110, 32, 97, 116, 32, 115, 116, 97, 114, 116, 117, 112, 34, 32, 61, 32, 34, 77, 111,
-115, 116, 114, 97, 114, 32, 97, 32, 116, 101, 108, 97, 32, 100, 101, 32, 97, 98, 101, 114, 116, 117, 114, 97,
-32, 97, 111, 32, 105, 110, 105, 99, 105, 97, 114, 34, 10, 34, 80, 108, 97, 121, 32, 116, 104, 101, 32, 115,
-116, 97, 114, 116, 117, 112, 32, 115, 111, 117, 110, 100, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 32, 111,
-32, 115, 111, 109, 32, 100, 101, 32, 97, 98, 101, 114, 116, 117, 114, 97, 34, 10, 10, 35, 32, 45, 45, 45,
-32, 76, 97, 121, 111, 117, 116, 58, 32, 109, 97, 105, 110, 32, 116, 111, 111, 108, 98, 97, 114, 32, 97, 110,
-100, 32, 119, 105, 110, 100, 111, 119, 32, 116, 105, 116, 108, 101, 32, 98, 97, 114, 115, 10, 34, 80, 108, 117,
-103, 105, 110, 32, 112, 105, 99, 107, 101, 114, 58, 32, 97, 100, 100, 32, 97, 110, 32, 105, 110, 115, 116, 114,
-117, 109, 101, 110, 116, 32, 111, 114, 32, 112, 108, 117, 103, 105, 110, 32, 97, 115, 32, 97, 32, 110, 101, 119,
-32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 83, 101, 108, 101, 116, 111, 114, 32, 100, 101, 32,
-112, 108, 117, 103, 105, 110, 115, 58, 32, 97, 100, 105, 99, 105, 111, 110, 97, 32, 117, 109, 32, 105, 110, 115,
-116, 114, 117, 109, 101, 110, 116, 111, 32, 111, 117, 32, 112, 108, 117, 103, 105, 110, 32, 99, 111, 109, 111, 32,
-110, 111, 118, 111, 32, 99, 97, 110, 97, 108, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111,
-112, 116, 105, 111, 110, 115, 58, 32, 119, 104, 97, 116, 32, 116, 111, 32, 114, 101, 99, 111, 114, 100, 34, 32,
-61, 32, 34, 79, 112, 195, 167, 195, 181, 101, 115, 32, 100, 101, 32, 103, 114, 97, 118, 97, 195, 167, 195, 163,
-111, 58, 32, 111, 32, 113, 117, 101, 32, 103, 114, 97, 118, 97, 114, 34, 10, 34, 83, 119, 105, 110, 103, 32,
-111, 102, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 40, 97, 108, 108,
-32, 99, 104, 97, 110, 110, 101, 108, 115, 41, 34, 32, 61, 32, 34, 83, 119, 105, 110, 103, 32, 100, 111, 32,
-67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 40, 116, 111, 100, 111, 115, 32, 111, 115, 32, 99,
-97, 110, 97, 105, 115, 41, 34, 10, 34, 66, 65, 82, 32, 58, 32, 66, 69, 65, 84, 32, 58, 32, 83, 84,
-69, 80, 34, 32, 61, 32, 34, 67, 79, 77, 80, 32, 58, 32, 84, 69, 77, 80, 79, 32, 58, 32, 83, 84,
-69, 80, 34, 10, 34, 87, 105, 110, 100, 111, 119, 32, 111, 112, 116, 105, 111, 110, 115, 58, 32, 100, 101, 116,
-97, 99, 104, 44, 32, 109, 97, 120, 105, 109, 105, 122, 101, 44, 32, 99, 108, 111, 115, 101, 32, 97, 110, 100,
-32, 116, 104, 105, 115, 32, 112, 97, 110, 101, 108, 39, 115, 32, 111, 119, 110, 32, 115, 101, 116, 116, 105, 110,
-103, 115, 34, 32, 61, 32, 34, 79, 112, 195, 167, 195, 181, 101, 115, 32, 100, 97, 32, 106, 97, 110, 101, 108,
-97, 58, 32, 100, 101, 115, 116, 97, 99, 97, 114, 44, 32, 109, 97, 120, 105, 109, 105, 122, 97, 114, 44, 32,
-102, 101, 99, 104, 97, 114, 32, 101, 32, 111, 115, 32, 97, 106, 117, 115, 116, 101, 115, 32, 100, 101, 115, 116,
-101, 32, 112, 97, 105, 110, 101, 108, 34, 10, 34, 68, 101, 116, 97, 99, 104, 101, 100, 32, 40, 111, 119, 110,
-32, 119, 105, 110, 100, 111, 119, 41, 34, 32, 61, 32, 34, 68, 101, 115, 116, 97, 99, 97, 100, 97, 32, 40,
-106, 97, 110, 101, 108, 97, 32, 112, 114, 195, 179, 112, 114, 105, 97, 41, 34, 10, 34, 77, 97, 120, 105, 109,
-105, 122, 101, 100, 34, 32, 61, 32, 34, 77, 97, 120, 105, 109, 105, 122, 97, 100, 97, 34, 10, 34, 67, 108,
-111, 115, 101, 34, 32, 61, 32, 34, 70, 101, 99, 104, 97, 114, 34, 10,
+32, 117, 112, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32,
+115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97, 34, 10,
+34, 77, 111, 118, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110,
+101, 108, 115, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 99, 97,
+110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 98,
+97, 105, 120, 111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 97, 108, 108, 32, 99, 104, 97, 110, 110, 101,
+108, 115, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 116, 111, 100, 111, 115, 32,
+111, 115, 32, 99, 97, 110, 97, 105, 115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 116, 104, 101, 32, 115, 101,
+108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 67, 108, 111, 110,
+97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111,
+115, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32,
+99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 69, 120, 99, 108, 117, 105, 114, 32, 111, 115, 32,
+99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 34, 10, 34, 83, 101,
+110, 100, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115,
+32, 116, 111, 32, 102, 114, 101, 101, 32, 109, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32,
+61, 32, 34, 77, 97, 110, 100, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101,
+99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105,
+118, 114, 101, 115, 32, 100, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 77, 117, 116, 101, 32, 111, 114, 32,
+117, 110, 109, 117, 116, 101, 32, 99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 83,
+105, 108, 101, 110, 99, 105, 97, 114, 32, 111, 117, 32, 114, 101, 97, 116, 105, 118, 97, 114, 32, 111, 32, 99,
+97, 110, 97, 108, 32, 123, 48, 125, 34, 10, 34, 83, 111, 108, 111, 32, 99, 104, 97, 110, 110, 101, 108, 32,
+123, 48, 125, 34, 32, 61, 32, 34, 83, 111, 108, 111, 32, 110, 111, 32, 99, 97, 110, 97, 108, 32, 123, 48,
+125, 34, 10, 34, 100, 114, 97, 103, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 101, 41, 44, 32, 119,
+104, 101, 101, 108, 44, 32, 65, 108, 116, 43, 99, 108, 105, 99, 107, 32, 114, 101, 115, 101, 116, 115, 34, 32,
+61, 32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 111, 41, 44,
+32, 114, 111, 100, 97, 32, 100, 111, 32, 109, 111, 117, 115, 101, 44, 32, 65, 108, 116, 43, 99, 108, 105, 113,
+117, 101, 32, 114, 101, 115, 101, 116, 97, 34, 10, 34, 77, 105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116,
+34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 116, 32, 100, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 77,
+97, 115, 116, 101, 114, 34, 32, 61, 32, 34, 77, 97, 115, 116, 101, 114, 34, 10, 34, 73, 110, 115, 101, 114,
+116, 32, 123, 48, 125, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 116, 32, 123, 48, 125, 34, 10, 34, 78,
+101, 120, 116, 32, 102, 114, 101, 101, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 80, 114, 195, 179,
+120, 105, 109, 111, 32, 105, 110, 115, 101, 114, 116, 32, 108, 105, 118, 114, 101, 34, 10, 34, 83, 101, 110, 100,
+32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 116,
+111, 32, 102, 114, 101, 101, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34, 77, 97, 110, 100, 97,
+114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115,
+32, 112, 97, 114, 97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105, 118, 114, 101, 115, 34, 10, 34, 100,
+114, 97, 103, 32, 111, 114, 32, 119, 104, 101, 101, 108, 32, 116, 111, 32, 114, 111, 117, 116, 101, 44, 32, 100,
+111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 110, 101, 120, 116, 32, 102, 114, 101, 101, 32, 105,
+110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 111, 117, 32, 114, 111, 100,
+97, 32, 112, 97, 114, 97, 32, 114, 111, 116, 101, 97, 114, 44, 32, 100, 117, 112, 108, 111, 32, 99, 108, 105,
+113, 117, 101, 58, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 105, 110, 115, 101, 114, 116, 32, 108, 105, 118,
+114, 101, 34, 10, 34, 67, 108, 105, 99, 107, 58, 32, 109, 117, 116, 101, 46, 32, 32, 67, 116, 114, 108, 43,
+99, 108, 105, 99, 107, 32, 111, 114, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 115, 111,
+108, 111, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 115, 105, 108, 101, 110, 99, 105, 97, 114,
+46, 32, 32, 67, 116, 114, 108, 43, 99, 108, 105, 113, 117, 101, 32, 111, 117, 32, 98, 111, 116, 195, 163, 111,
+32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 115, 111, 108, 111, 34, 10, 34, 67, 108, 105, 99, 107, 58, 32,
+111, 112, 101, 110, 47, 99, 108, 111, 115, 101, 32, 116, 104, 101, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65,
+108, 116, 32, 107, 101, 101, 112, 115, 32, 111, 116, 104, 101, 114, 115, 32, 111, 112, 101, 110, 41, 46, 32, 32,
+67, 116, 114, 108, 43, 99, 108, 105, 99, 107, 58, 32, 97, 117, 100, 105, 116, 105, 111, 110, 46, 32, 32, 68,
+111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34,
+32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 97, 98, 114, 101, 47, 102, 101, 99, 104, 97, 32, 111,
+32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 109, 97, 110, 116, 195, 169, 109, 32, 111, 115, 32,
+111, 117, 116, 114, 111, 115, 32, 97, 98, 101, 114, 116, 111, 115, 41, 46, 32, 32, 67, 116, 114, 108, 43, 99,
+108, 105, 113, 117, 101, 58, 32, 111, 117, 118, 105, 114, 46, 32, 32, 68, 117, 112, 108, 111, 32, 99, 108, 105,
+113, 117, 101, 58, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 10, 34, 83, 101, 108, 101, 99, 116,
+32, 40, 67, 116, 114, 108, 58, 32, 97, 100, 100, 47, 114, 101, 109, 111, 118, 101, 44, 32, 83, 104, 105, 102,
+116, 58, 32, 114, 97, 110, 103, 101, 44, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32,
+97, 108, 108, 41, 46, 32, 32, 65, 108, 116, 43, 85, 112, 47, 68, 111, 119, 110, 32, 109, 111, 118, 101, 115,
+32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99,
+105, 111, 110, 97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 105, 110, 99, 108, 117, 105, 114, 47, 116, 105, 114,
+97, 114, 44, 32, 83, 104, 105, 102, 116, 58, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 44, 32, 100, 117,
+112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 58, 32, 116, 111, 100, 111, 115, 41, 46, 32, 32, 65, 108, 116,
+43, 67, 105, 109, 97, 47, 66, 97, 105, 120, 111, 32, 109, 111, 118, 101, 32, 97, 32, 115, 101, 108, 101, 195,
+167, 195, 163, 111, 34, 10, 34, 83, 116, 101, 112, 115, 58, 32, 99, 108, 105, 99, 107, 32, 116, 117, 114, 110,
+115, 32, 111, 110, 32, 97, 110, 100, 32, 100, 114, 97, 103, 115, 32, 116, 111, 32, 112, 97, 105, 110, 116, 44,
+32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 101, 114, 97, 115, 101, 115, 34, 32, 61, 32, 34,
+83, 116, 101, 112, 115, 58, 32, 99, 108, 105, 113, 117, 101, 32, 108, 105, 103, 97, 32, 101, 32, 97, 114, 114,
+97, 115, 116, 97, 114, 32, 112, 105, 110, 116, 97, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101,
+105, 116, 111, 32, 97, 112, 97, 103, 97, 34, 10, 34, 65, 100, 100, 32, 97, 32, 99, 104, 97, 110, 110, 101,
+108, 32, 40, 111, 114, 32, 100, 114, 111, 112, 32, 97, 117, 100, 105, 111, 32, 102, 105, 108, 101, 115, 32, 111,
+110, 32, 116, 104, 101, 32, 114, 97, 99, 107, 41, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97,
+114, 32, 117, 109, 32, 99, 97, 110, 97, 108, 32, 40, 111, 117, 32, 115, 111, 108, 116, 101, 32, 97, 114, 113,
+117, 105, 118, 111, 115, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 110, 111, 32, 114, 97, 99, 107, 41,
+34, 10, 34, 67, 104, 97, 110, 110, 101, 108, 32, 115, 101, 116, 116, 105, 110, 103, 115, 46, 46, 46, 34, 32,
+61, 32, 34, 67, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167, 195, 181, 101, 115, 32, 100, 111, 32, 99, 97,
+110, 97, 108, 46, 46, 46, 34, 10, 34, 82, 101, 110, 97, 109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111,
+114, 46, 46, 46, 34, 32, 61, 32, 34, 82, 101, 110, 111, 109, 101, 97, 114, 32, 101, 32, 99, 111, 108, 111,
+114, 105, 114, 46, 46, 46, 34, 10, 34, 67, 108, 111, 110, 101, 32, 123, 48, 125, 32, 99, 104, 97, 110, 110,
+101, 108, 115, 34, 32, 61, 32, 34, 67, 108, 111, 110, 97, 114, 32, 123, 48, 125, 32, 99, 97, 110, 97, 105,
+115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 67, 108,
+111, 110, 97, 114, 32, 99, 97, 110, 97, 108, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 99, 104, 97, 110,
+110, 101, 108, 32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 99, 97, 110,
+97, 108, 32, 97, 113, 117, 105, 34, 10, 34, 83, 101, 110, 100, 32, 116, 111, 32, 102, 114, 101, 101, 32, 109,
+105, 120, 101, 114, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34, 77, 97, 110, 100, 97, 114, 32,
+112, 97, 114, 97, 32, 105, 110, 115, 101, 114, 116, 115, 32, 108, 105, 118, 114, 101, 115, 32, 100, 111, 32, 109,
+105, 120, 101, 114, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 123, 48, 125, 32, 99, 104, 97, 110, 110, 101,
+108, 115, 34, 32, 61, 32, 34, 69, 120, 99, 108, 117, 105, 114, 32, 123, 48, 125, 32, 99, 97, 110, 97, 105,
+115, 34, 10, 34, 78, 97, 109, 101, 34, 32, 61, 32, 34, 78, 111, 109, 101, 34, 10, 34, 67, 108, 105, 99,
+107, 32, 97, 32, 99, 111, 108, 111, 114, 44, 32, 111, 114, 32, 112, 114, 101, 115, 115, 32, 70, 50, 32, 102,
+111, 114, 32, 97, 32, 114, 97, 110, 100, 111, 109, 32, 111, 110, 101, 34, 32, 61, 32, 34, 67, 108, 105, 113,
+117, 101, 32, 110, 117, 109, 97, 32, 99, 111, 114, 44, 32, 111, 117, 32, 97, 112, 101, 114, 116, 101, 32, 70,
+50, 32, 112, 97, 114, 97, 32, 117, 109, 97, 32, 97, 108, 101, 97, 116, 195, 179, 114, 105, 97, 34, 10, 34,
+80, 108, 97, 121, 59, 32, 112, 114, 101, 115, 115, 101, 100, 32, 97, 103, 97, 105, 110, 44, 32, 115, 116, 111,
+112, 115, 32, 97, 110, 100, 32, 103, 111, 101, 115, 32, 98, 97, 99, 107, 32, 116, 111, 32, 119, 104, 101, 114,
+101, 32, 105, 116, 32, 115, 116, 97, 114, 116, 101, 100, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 59, 32,
+97, 112, 101, 114, 116, 97, 100, 111, 32, 100, 101, 32, 110, 111, 118, 111, 44, 32, 112, 97, 114, 97, 32, 101,
+32, 118, 111, 108, 116, 97, 32, 112, 97, 114, 97, 32, 111, 110, 100, 101, 32, 99, 111, 109, 101, 195, 167, 111,
+117, 34, 10, 34, 83, 116, 111, 112, 32, 97, 110, 100, 32, 114, 101, 116, 117, 114, 110, 32, 116, 111, 32, 116,
+104, 101, 32, 115, 116, 97, 114, 116, 32, 40, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32,
+97, 108, 108, 32, 110, 111, 116, 101, 115, 32, 111, 102, 102, 41, 34, 32, 61, 32, 34, 80, 97, 114, 97, 114,
+32, 101, 32, 118, 111, 108, 116, 97, 114, 32, 97, 111, 32, 105, 110, 195, 173, 99, 105, 111, 32, 40, 100, 117,
+112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 58, 32, 100, 101, 115, 108, 105, 103, 97, 32, 116, 111, 100, 97,
+115, 32, 97, 115, 32, 110, 111, 116, 97, 115, 41, 34, 10, 34, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99,
+107, 58, 32, 115, 104, 111, 119, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107,
+34, 32, 61, 32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 111, 115,
+116, 114, 97, 114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 10, 34, 82, 105,
+103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 115, 104, 111, 119, 32, 116, 104, 101, 32, 80, 108, 97, 121,
+108, 105, 115, 116, 34, 32, 61, 32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58,
+32, 109, 111, 115, 116, 114, 97, 114, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 67, 108,
+105, 99, 107, 58, 32, 115, 104, 111, 119, 44, 32, 102, 111, 99, 117, 115, 32, 111, 114, 32, 104, 105, 100, 101,
+46, 32, 32, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 115, 104, 111, 119, 32, 109, 97, 120,
+105, 109, 105, 122, 101, 100, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 109, 111, 115, 116, 114,
+97, 114, 44, 32, 102, 111, 99, 97, 114, 32, 111, 117, 32, 101, 115, 99, 111, 110, 100, 101, 114, 46, 32, 32,
+66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 111, 115, 116, 114, 97, 114, 32,
+109, 97, 120, 105, 109, 105, 122, 97, 100, 111, 34, 10, 34, 67, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116,
+116, 101, 114, 110, 32, 40, 78, 117, 109, 112, 97, 100, 32, 43, 47, 45, 58, 32, 110, 101, 120, 116, 47, 112,
+114, 101, 118, 105, 111, 117, 115, 44, 32, 70, 52, 58, 32, 110, 101, 120, 116, 32, 101, 109, 112, 116, 121, 44,
+32, 70, 50, 58, 32, 114, 101, 110, 97, 109, 101, 41, 34, 32, 61, 32, 34, 80, 97, 116, 116, 101, 114, 110,
+32, 97, 116, 117, 97, 108, 32, 40, 78, 117, 109, 112, 97, 100, 32, 43, 47, 45, 58, 32, 112, 114, 195, 179,
+120, 105, 109, 111, 47, 97, 110, 116, 101, 114, 105, 111, 114, 44, 32, 70, 52, 58, 32, 112, 114, 195, 179, 120,
+105, 109, 111, 32, 118, 97, 122, 105, 111, 44, 32, 70, 50, 58, 32, 114, 101, 110, 111, 109, 101, 97, 114, 41,
+34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 58, 32, 114, 101, 110, 97, 109, 101, 44, 32, 99, 111, 108, 111,
+114, 44, 32, 99, 108, 111, 110, 101, 44, 32, 105, 110, 115, 101, 114, 116, 44, 32, 115, 112, 108, 105, 116, 44,
+32, 108, 101, 110, 103, 116, 104, 44, 32, 100, 101, 108, 101, 116, 101, 34, 32, 61, 32, 34, 80, 97, 116, 116,
+101, 114, 110, 58, 32, 114, 101, 110, 111, 109, 101, 97, 114, 44, 32, 99, 111, 114, 44, 32, 99, 108, 111, 110,
+97, 114, 44, 32, 105, 110, 115, 101, 114, 105, 114, 44, 32, 100, 105, 118, 105, 100, 105, 114, 44, 32, 100, 117,
+114, 97, 195, 167, 195, 163, 111, 44, 32, 101, 120, 99, 108, 117, 105, 114, 34, 10, 34, 65, 117, 100, 105, 111,
+32, 112, 114, 111, 99, 101, 115, 115, 105, 110, 103, 32, 108, 111, 97, 100, 34, 32, 61, 32, 34, 67, 97, 114,
+103, 97, 32, 100, 111, 32, 112, 114, 111, 99, 101, 115, 115, 97, 109, 101, 110, 116, 111, 32, 100, 101, 32, 195,
+161, 117, 100, 105, 111, 34, 10, 34, 83, 104, 105, 102, 116, 43, 119, 104, 101, 101, 108, 32, 104, 101, 114, 101,
+32, 99, 104, 97, 110, 103, 101, 115, 32, 116, 104, 101, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32,
+34, 83, 104, 105, 102, 116, 43, 114, 111, 100, 97, 32, 97, 113, 117, 105, 32, 116, 114, 111, 99, 97, 32, 111,
+32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 58, 32, 99,
+108, 105, 99, 107, 32, 97, 100, 100, 115, 32, 97, 32, 110, 111, 116, 101, 44, 32, 100, 114, 97, 103, 32, 109,
+111, 118, 101, 115, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 100, 101, 108, 101, 116, 101,
+115, 44, 32, 67, 116, 114, 108, 43, 100, 114, 97, 103, 32, 115, 101, 108, 101, 99, 116, 115, 34, 32, 61, 32,
+34, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 58, 32, 99, 108, 105, 113, 117, 101, 32, 97, 100, 105, 99,
+105, 111, 110, 97, 32, 110, 111, 116, 97, 44, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 109, 111, 118, 101,
+44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 112, 97, 103, 97, 44, 32,
+67, 116, 114, 108, 43, 97, 114, 114, 97, 115, 116, 97, 114, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 34,
+10, 34, 80, 108, 97, 121, 108, 105, 115, 116, 58, 32, 99, 108, 105, 99, 107, 32, 112, 97, 105, 110, 116, 115,
+32, 116, 104, 101, 32, 99, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114, 110, 44, 32, 114, 105,
+103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 100, 101, 108, 101, 116, 101, 115, 44, 32, 67, 116, 114, 108, 43,
+100, 114, 97, 103, 32, 115, 101, 108, 101, 99, 116, 115, 34, 32, 61, 32, 34, 80, 108, 97, 121, 108, 105, 115,
+116, 58, 32, 99, 108, 105, 113, 117, 101, 32, 112, 105, 110, 116, 97, 32, 111, 32, 112, 97, 116, 116, 101, 114,
+110, 32, 97, 116, 117, 97, 108, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32,
+97, 112, 97, 103, 97, 44, 32, 67, 116, 114, 108, 43, 97, 114, 114, 97, 115, 116, 97, 114, 32, 115, 101, 108,
+101, 99, 105, 111, 110, 97, 34, 10, 34, 84, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100,
+32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 58, 32, 111, 110, 32, 40, 90, 46, 46, 77, 32, 97, 110,
+100, 32, 81, 46, 46, 80, 32, 112, 108, 97, 121, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100,
+32, 99, 104, 97, 110, 110, 101, 108, 115, 41, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100, 111, 32, 100,
+111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 58, 32, 108, 105, 103, 97, 100, 111, 32,
+40, 90, 46, 46, 77, 32, 101, 32, 81, 46, 46, 80, 32, 116, 111, 99, 97, 109, 32, 111, 115, 32, 99, 97,
+110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 41, 34, 10, 34, 84, 121, 112,
+105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 58,
+32, 111, 102, 102, 32, 40, 108, 101, 116, 116, 101, 114, 32, 97, 110, 100, 32, 110, 117, 109, 98, 101, 114, 32,
+107, 101, 121, 115, 32, 97, 114, 101, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 41, 34, 32, 61, 32, 34,
+84, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111,
+58, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 32, 40, 108, 101, 116, 114, 97, 115, 32, 101, 32, 110, 195,
+186, 109, 101, 114, 111, 115, 32, 115, 195, 163, 111, 32, 97, 116, 97, 108, 104, 111, 115, 41, 34, 10, 34, 83,
+97, 118, 101, 32, 108, 97, 121, 111, 117, 116, 32, 97, 115, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114,
+32, 108, 97, 121, 111, 117, 116, 32, 99, 111, 109, 111, 34, 10, 34, 78, 97, 109, 101, 32, 111, 102, 32, 116,
+104, 101, 32, 108, 97, 121, 111, 117, 116, 58, 34, 32, 61, 32, 34, 78, 111, 109, 101, 32, 100, 111, 32, 108,
+97, 121, 111, 117, 116, 58, 34, 10, 34, 77, 121, 32, 108, 97, 121, 111, 117, 116, 34, 32, 61, 32, 34, 77,
+101, 117, 32, 108, 97, 121, 111, 117, 116, 34, 10, 34, 40, 110, 111, 110, 101, 32, 115, 97, 118, 101, 100, 32,
+121, 101, 116, 41, 34, 32, 61, 32, 34, 40, 110, 101, 110, 104, 117, 109, 32, 115, 97, 108, 118, 111, 32, 97,
+105, 110, 100, 97, 41, 34, 10, 34, 79, 112, 101, 110, 32, 108, 97, 121, 111, 117, 116, 115, 32, 102, 111, 108,
+100, 101, 114, 34, 32, 61, 32, 34, 65, 98, 114, 105, 114, 32, 112, 97, 115, 116, 97, 32, 100, 101, 32, 108,
+97, 121, 111, 117, 116, 115, 34, 10, 34, 83, 112, 108, 105, 116, 32, 98, 121, 32, 99, 104, 97, 110, 110, 101,
+108, 34, 32, 61, 32, 34, 68, 105, 118, 105, 100, 105, 114, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 34,
+10, 34, 84, 104, 105, 115, 32, 112, 97, 116, 116, 101, 114, 110, 32, 104, 97, 115, 32, 110, 111, 32, 110, 111,
+116, 101, 115, 46, 34, 32, 61, 32, 34, 69, 115, 116, 101, 32, 112, 97, 116, 116, 101, 114, 110, 32, 110, 195,
+163, 111, 32, 116, 101, 109, 32, 110, 111, 116, 97, 115, 46, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 97,
+110, 32, 101, 109, 112, 116, 121, 32, 112, 97, 116, 116, 101, 114, 110, 32, 98, 101, 102, 111, 114, 101, 32, 116,
+104, 105, 115, 32, 111, 110, 101, 34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 117, 109, 32, 112,
+97, 116, 116, 101, 114, 110, 32, 118, 97, 122, 105, 111, 32, 97, 110, 116, 101, 115, 32, 100, 101, 115, 116, 101,
+34, 10, 34, 83, 112, 108, 105, 116, 32, 98, 121, 32, 99, 104, 97, 110, 110, 101, 108, 32, 40, 111, 110, 101,
+32, 110, 101, 119, 32, 112, 97, 116, 116, 101, 114, 110, 32, 112, 101, 114, 32, 99, 104, 97, 110, 110, 101, 108,
+41, 34, 32, 61, 32, 34, 68, 105, 118, 105, 100, 105, 114, 32, 112, 111, 114, 32, 99, 97, 110, 97, 108, 32,
+40, 117, 109, 32, 112, 97, 116, 116, 101, 114, 110, 32, 110, 111, 118, 111, 32, 112, 111, 114, 32, 99, 97, 110,
+97, 108, 41, 34, 10, 34, 100, 114, 97, 103, 32, 116, 104, 101, 32, 100, 101, 99, 105, 109, 97, 108, 115, 32,
+102, 111, 114, 32, 102, 105, 110, 101, 32, 99, 104, 97, 110, 103, 101, 115, 44, 32, 119, 104, 101, 101, 108, 44,
+32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 116, 121, 112, 101, 34, 32, 61,
+32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 111, 115, 32, 100, 101, 99, 105, 109, 97, 105, 115, 32, 112, 97,
+114, 97, 32, 97, 106, 117, 115, 116, 101, 32, 102, 105, 110, 111, 44, 32, 114, 111, 100, 97, 44, 32, 100, 117,
+112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114, 97, 32, 100, 105, 103, 105, 116, 97, 114, 34,
+10, 34, 100, 114, 97, 103, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 110, 117, 109, 98, 101, 114, 32,
+102, 111, 114, 32, 66, 80, 77, 32, 40, 67, 116, 114, 108, 58, 32, 102, 105, 110, 101, 41, 44, 32, 119, 104,
+101, 101, 108, 44, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 116, 121, 112,
+101, 34, 32, 61, 32, 34, 97, 114, 114, 97, 115, 116, 101, 32, 111, 32, 110, 195, 186, 109, 101, 114, 111, 32,
+105, 110, 116, 101, 105, 114, 111, 32, 112, 97, 114, 97, 32, 111, 32, 66, 80, 77, 32, 40, 67, 116, 114, 108,
+58, 32, 102, 105, 110, 111, 41, 44, 32, 114, 111, 100, 97, 44, 32, 100, 117, 112, 108, 111, 32, 99, 108, 105,
+113, 117, 101, 32, 112, 97, 114, 97, 32, 100, 105, 103, 105, 116, 97, 114, 34, 10, 34, 84, 121, 112, 101, 32,
+118, 97, 108, 117, 101, 46, 46, 46, 34, 32, 61, 32, 34, 68, 105, 103, 105, 116, 97, 114, 32, 118, 97, 108,
+111, 114, 46, 46, 46, 34, 10, 34, 84, 97, 112, 32, 116, 101, 109, 112, 111, 46, 46, 46, 34, 32, 61, 32,
+34, 84, 97, 112, 32, 116, 101, 109, 112, 111, 46, 46, 46, 34, 10, 34, 72, 97, 108, 102, 32, 40, 123, 48,
+125, 32, 66, 80, 77, 41, 34, 32, 61, 32, 34, 77, 101, 116, 97, 100, 101, 32, 40, 123, 48, 125, 32, 66,
+80, 77, 41, 34, 10, 34, 68, 111, 117, 98, 108, 101, 32, 40, 123, 48, 125, 32, 66, 80, 77, 41, 34, 32,
+61, 32, 34, 68, 111, 98, 114, 111, 32, 40, 123, 48, 125, 32, 66, 80, 77, 41, 34, 10, 34, 82, 101, 115,
+101, 116, 32, 40, 123, 48, 125, 41, 34, 32, 61, 32, 34, 82, 101, 115, 101, 116, 97, 114, 32, 40, 123, 48,
+125, 41, 34, 10, 34, 84, 97, 112, 34, 32, 61, 32, 34, 84, 97, 112, 34, 10, 34, 67, 108, 105, 99, 107,
+32, 40, 111, 114, 32, 112, 114, 101, 115, 115, 32, 84, 41, 32, 111, 110, 32, 101, 97, 99, 104, 32, 98, 101,
+97, 116, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 32, 40, 111, 117, 32, 97, 112, 101, 114, 116, 101,
+32, 84, 41, 32, 101, 109, 32, 99, 97, 100, 97, 32, 116, 101, 109, 112, 111, 34, 10, 34, 123, 48, 125, 32,
+116, 97, 112, 115, 58, 32, 123, 49, 125, 32, 66, 80, 77, 34, 32, 61, 32, 34, 123, 48, 125, 32, 116, 111,
+113, 117, 101, 115, 58, 32, 123, 49, 125, 32, 66, 80, 77, 34, 10, 34, 70, 49, 32, 115, 104, 111, 114, 116,
+99, 117, 116, 115, 32, 32, 32, 70, 53, 45, 70, 57, 32, 112, 97, 110, 101, 108, 115, 32, 32, 32, 83, 112,
+97, 99, 101, 32, 112, 108, 97, 121, 47, 115, 116, 111, 112, 32, 32, 32, 67, 116, 114, 108, 43, 84, 32, 116,
+121, 112, 105, 110, 103, 32, 112, 105, 97, 110, 111, 32, 40, 123, 48, 125, 41, 34, 32, 61, 32, 34, 70, 49,
+32, 97, 116, 97, 108, 104, 111, 115, 32, 32, 32, 70, 53, 45, 70, 57, 32, 112, 97, 105, 110, 195, 169, 105,
+115, 32, 32, 32, 69, 115, 112, 97, 195, 167, 111, 32, 116, 111, 99, 97, 47, 112, 97, 114, 97, 32, 32, 32,
+67, 116, 114, 108, 43, 84, 32, 116, 101, 99, 108, 97, 100, 111, 45, 112, 105, 97, 110, 111, 32, 40, 123, 48,
+125, 41, 34, 10, 34, 111, 110, 34, 32, 61, 32, 34, 108, 105, 103, 97, 100, 111, 34, 10, 34, 111, 102, 102,
+34, 32, 61, 32, 34, 100, 101, 115, 108, 105, 103, 97, 100, 111, 34, 10, 34, 68, 101, 116, 97, 99, 104, 101,
+100, 32, 112, 97, 110, 101, 108, 115, 32, 40, 111, 119, 110, 32, 119, 105, 110, 100, 111, 119, 41, 34, 32, 61,
+32, 34, 80, 97, 105, 110, 195, 169, 105, 115, 32, 100, 101, 115, 116, 97, 99, 97, 100, 111, 115, 32, 40, 106,
+97, 110, 101, 108, 97, 32, 112, 114, 195, 179, 112, 114, 105, 97, 41, 34, 10, 34, 82, 101, 115, 101, 116, 32,
+108, 97, 121, 111, 117, 116, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 108, 97, 121,
+111, 117, 116, 32, 112, 97, 100, 114, 195, 163, 111, 34, 10, 34, 83, 97, 118, 101, 32, 108, 97, 121, 111, 117,
+116, 32, 97, 115, 46, 46, 46, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 108, 97, 121, 111, 117,
+116, 32, 99, 111, 109, 111, 46, 46, 46, 34, 10, 34, 76, 111, 97, 100, 32, 108, 97, 121, 111, 117, 116, 34,
+32, 61, 32, 34, 67, 97, 114, 114, 101, 103, 97, 114, 32, 108, 97, 121, 111, 117, 116, 34, 10, 34, 66, 114,
+105, 110, 103, 32, 98, 97, 99, 107, 32, 111, 102, 102, 45, 115, 99, 114, 101, 101, 110, 32, 112, 97, 110, 101,
+108, 115, 34, 32, 61, 32, 34, 84, 114, 97, 122, 101, 114, 32, 100, 101, 32, 118, 111, 108, 116, 97, 32, 112,
+97, 105, 110, 195, 169, 105, 115, 32, 102, 111, 114, 97, 32, 100, 97, 32, 116, 101, 108, 97, 34, 10, 34, 84,
+121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110,
+111, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111,
+32, 112, 105, 97, 110, 111, 34, 10, 34, 75, 101, 101, 112, 32, 99, 104, 97, 110, 110, 101, 108, 32, 101, 100,
+105, 116, 111, 114, 115, 32, 111, 112, 101, 110, 32, 40, 97, 32, 99, 104, 97, 110, 110, 101, 108, 32, 98, 117,
+116, 116, 111, 110, 32, 99, 108, 105, 99, 107, 32, 100, 111, 101, 115, 110, 39, 116, 32, 99, 108, 111, 115, 101,
+32, 116, 104, 101, 32, 112, 114, 101, 118, 105, 111, 117, 115, 32, 101, 100, 105, 116, 111, 114, 41, 34, 32, 61,
+32, 34, 77, 97, 110, 116, 101, 114, 32, 101, 100, 105, 116, 111, 114, 101, 115, 32, 100, 101, 32, 99, 97, 110,
+97, 108, 32, 97, 98, 101, 114, 116, 111, 115, 32, 40, 99, 108, 105, 99, 97, 114, 32, 110, 117, 109, 32, 99,
+97, 110, 97, 108, 32, 110, 195, 163, 111, 32, 102, 101, 99, 104, 97, 32, 111, 32, 101, 100, 105, 116, 111, 114,
+32, 97, 110, 116, 101, 114, 105, 111, 114, 41, 34, 10, 34, 69, 100, 105, 116, 32, 107, 101, 121, 98, 111, 97,
+114, 100, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 32, 40, 107, 101, 121, 115, 46, 106, 115, 111, 110, 41,
+46, 46, 46, 34, 32, 61, 32, 34, 69, 100, 105, 116, 97, 114, 32, 97, 116, 97, 108, 104, 111, 115, 32, 100,
+101, 32, 116, 101, 99, 108, 97, 100, 111, 32, 40, 107, 101, 121, 115, 46, 106, 115, 111, 110, 41, 46, 46, 46,
+34, 10, 34, 82, 101, 108, 111, 97, 100, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 115, 104, 111, 114, 116,
+99, 117, 116, 115, 34, 32, 61, 32, 34, 82, 101, 99, 97, 114, 114, 101, 103, 97, 114, 32, 97, 116, 97, 108,
+104, 111, 115, 32, 100, 101, 32, 116, 101, 99, 108, 97, 100, 111, 34, 10, 34, 80, 97, 110, 101, 108, 115, 58,
+32, 80, 108, 97, 121, 108, 105, 115, 116, 44, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 44,
+32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 44, 32, 77, 105, 120, 101, 114, 44, 32, 66, 114, 111, 119,
+115, 101, 114, 34, 32, 61, 32, 34, 80, 97, 105, 110, 195, 169, 105, 115, 58, 32, 80, 108, 97, 121, 108, 105,
+115, 116, 44, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 44, 32, 80, 105, 97, 110, 111, 32,
+82, 111, 108, 108, 44, 32, 77, 105, 120, 101, 114, 44, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 80,
+67, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97, 115, 32, 97, 32, 112, 105, 97, 110, 111, 32, 40, 115,
+101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 41, 34, 32, 61, 32, 34, 84, 101,
+99, 108, 97, 100, 111, 32, 100, 111, 32, 80, 67, 32, 99, 111, 109, 111, 32, 112, 105, 97, 110, 111, 32, 40,
+99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 41, 34, 10, 34, 78,
+117, 109, 112, 97, 100, 32, 43, 47, 45, 32, 32, 70, 52, 32, 32, 70, 50, 34, 32, 61, 32, 34, 78, 117,
+109, 112, 97, 100, 32, 43, 47, 45, 32, 32, 70, 52, 32, 32, 70, 50, 34, 10, 34, 78, 101, 120, 116, 47,
+112, 114, 101, 118, 105, 111, 117, 115, 32, 112, 97, 116, 116, 101, 114, 110, 44, 32, 110, 101, 120, 116, 32, 101,
+109, 112, 116, 121, 44, 32, 114, 101, 110, 97, 109, 101, 32, 97, 110, 100, 32, 99, 111, 108, 111, 114, 34, 32,
+61, 32, 34, 80, 97, 116, 116, 101, 114, 110, 32, 112, 114, 195, 179, 120, 105, 109, 111, 47, 97, 110, 116, 101,
+114, 105, 111, 114, 44, 32, 112, 114, 195, 179, 120, 105, 109, 111, 32, 118, 97, 122, 105, 111, 44, 32, 114, 101,
+110, 111, 109, 101, 97, 114, 32, 101, 32, 99, 111, 108, 111, 114, 105, 114, 34, 10, 34, 87, 111, 114, 107, 115,
+112, 97, 99, 101, 34, 32, 61, 32, 34, 195, 129, 114, 101, 97, 32, 100, 101, 32, 116, 114, 97, 98, 97, 108,
+104, 111, 34, 10, 34, 68, 114, 97, 103, 32, 97, 32, 112, 97, 110, 101, 108, 32, 116, 105, 116, 108, 101, 34,
+32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 97, 114, 32, 111, 32, 116, 195, 173, 116, 117, 108, 111, 32, 100,
+111, 32, 112, 97, 105, 110, 101, 108, 34, 10, 34, 77, 111, 118, 101, 32, 40, 115, 110, 97, 112, 115, 59, 32,
+65, 108, 116, 58, 32, 102, 114, 101, 101, 41, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 40, 101, 110,
+99, 97, 105, 120, 97, 59, 32, 65, 108, 116, 58, 32, 108, 105, 118, 114, 101, 41, 34, 10, 34, 68, 111, 117,
+98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 97, 32, 116, 105, 116, 108, 101, 34, 32, 61, 32, 34, 68, 117,
+112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 34, 10, 34,
+77, 97, 120, 105, 109, 105, 122, 101, 32, 47, 32, 114, 101, 115, 116, 111, 114, 101, 34, 32, 61, 32, 34, 77,
+97, 120, 105, 109, 105, 122, 97, 114, 32, 47, 32, 114, 101, 115, 116, 97, 117, 114, 97, 114, 34, 10, 34, 84,
+105, 116, 108, 101, 32, 98, 117, 116, 116, 111, 110, 115, 34, 32, 61, 32, 34, 66, 111, 116, 195, 181, 101, 115,
+32, 100, 111, 32, 116, 195, 173, 116, 117, 108, 111, 34, 10, 34, 68, 101, 116, 97, 99, 104, 32, 105, 110, 116,
+111, 32, 97, 32, 119, 105, 110, 100, 111, 119, 44, 32, 109, 97, 120, 105, 109, 105, 122, 101, 44, 32, 99, 108,
+111, 115, 101, 34, 32, 61, 32, 34, 68, 101, 115, 116, 97, 99, 97, 114, 32, 101, 109, 32, 106, 97, 110, 101,
+108, 97, 44, 32, 109, 97, 120, 105, 109, 105, 122, 97, 114, 44, 32, 102, 101, 99, 104, 97, 114, 34, 10, 34,
+86, 105, 101, 119, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 77, 101, 110, 117, 32, 69, 120, 105, 98, 105,
+114, 34, 10, 34, 82, 101, 115, 101, 116, 44, 32, 115, 97, 118, 101, 32, 97, 110, 100, 32, 108, 111, 97, 100,
+32, 108, 97, 121, 111, 117, 116, 115, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 44, 32,
+115, 97, 108, 118, 97, 114, 32, 101, 32, 99, 97, 114, 114, 101, 103, 97, 114, 32, 108, 97, 121, 111, 117, 116,
+115, 34, 10, 34, 67, 108, 105, 99, 107, 32, 116, 104, 101, 32, 110, 97, 109, 101, 34, 32, 61, 32, 34, 67,
+108, 105, 113, 117, 101, 32, 110, 111, 32, 110, 111, 109, 101, 34, 10, 34, 79, 112, 101, 110, 47, 99, 108, 111,
+115, 101, 32, 116, 104, 101, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 107, 101, 101, 112, 115,
+32, 111, 116, 104, 101, 114, 115, 32, 111, 112, 101, 110, 41, 34, 32, 61, 32, 34, 65, 98, 114, 101, 47, 102,
+101, 99, 104, 97, 32, 111, 32, 101, 100, 105, 116, 111, 114, 32, 40, 65, 108, 116, 32, 109, 97, 110, 116, 195,
+169, 109, 32, 111, 115, 32, 111, 117, 116, 114, 111, 115, 41, 34, 10, 34, 67, 116, 114, 108, 43, 99, 108, 105,
+99, 107, 32, 116, 104, 101, 32, 110, 97, 109, 101, 34, 32, 61, 32, 34, 67, 116, 114, 108, 43, 99, 108, 105,
+113, 117, 101, 32, 110, 111, 32, 110, 111, 109, 101, 34, 10, 34, 65, 117, 100, 105, 116, 105, 111, 110, 32, 116,
+104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 79, 117, 118, 105, 114, 32, 111, 32, 99,
+97, 110, 97, 108, 34, 10, 34, 83, 101, 108, 101, 99, 116, 111, 114, 32, 47, 32, 85, 112, 44, 32, 68, 111,
+119, 110, 34, 32, 61, 32, 34, 83, 101, 108, 101, 116, 111, 114, 32, 47, 32, 67, 105, 109, 97, 44, 32, 66,
+97, 105, 120, 111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 40, 67, 116, 114, 108, 58, 32, 97, 100, 100,
+44, 32, 83, 104, 105, 102, 116, 58, 32, 114, 97, 110, 103, 101, 41, 34, 32, 61, 32, 34, 83, 101, 108, 101,
+99, 105, 111, 110, 97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 105, 110, 99, 108, 117, 105, 114, 44, 32, 83,
+104, 105, 102, 116, 58, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 41, 34, 10, 34, 77, 111, 118, 101, 32,
+116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61,
+32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105,
+111, 110, 97, 100, 111, 115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 47, 32, 100, 101, 108, 101, 116, 101, 32,
+116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61,
+32, 34, 67, 108, 111, 110, 97, 114, 32, 47, 32, 101, 120, 99, 108, 117, 105, 114, 32, 111, 115, 32, 99, 97,
+110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 34, 10, 34, 49, 46, 46, 48,
+32, 47, 32, 67, 116, 114, 108, 43, 49, 46, 46, 48, 34, 32, 61, 32, 34, 49, 46, 46, 48, 32, 47, 32,
+67, 116, 114, 108, 43, 49, 46, 46, 48, 34, 10, 34, 77, 117, 116, 101, 32, 47, 32, 115, 111, 108, 111, 32,
+99, 104, 97, 110, 110, 101, 108, 115, 32, 49, 45, 49, 48, 32, 40, 116, 121, 112, 105, 110, 103, 32, 112, 105,
+97, 110, 111, 32, 111, 102, 102, 41, 34, 32, 61, 32, 34, 83, 105, 108, 101, 110, 99, 105, 97, 114, 32, 47,
+32, 115, 111, 108, 111, 32, 110, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 49, 45, 49, 48, 32, 40, 116,
+101, 99, 108, 97, 100, 111, 45, 112, 105, 97, 110, 111, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 41, 34,
+10, 34, 75, 110, 111, 98, 115, 32, 97, 110, 100, 32, 102, 97, 100, 101, 114, 115, 34, 32, 61, 32, 34, 75,
+110, 111, 98, 115, 32, 101, 32, 102, 97, 100, 101, 114, 115, 34, 10, 34, 68, 114, 97, 103, 32, 40, 67, 116,
+114, 108, 58, 32, 102, 105, 110, 101, 41, 44, 32, 119, 104, 101, 101, 108, 44, 32, 65, 108, 116, 43, 99, 108,
+105, 99, 107, 32, 111, 114, 32, 109, 105, 100, 100, 108, 101, 45, 99, 108, 105, 99, 107, 32, 114, 101, 115, 101,
+116, 115, 34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 97, 114, 32, 40, 67, 116, 114, 108, 58, 32, 102,
+105, 110, 111, 41, 44, 32, 114, 111, 100, 97, 44, 32, 65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 32, 111,
+117, 32, 98, 111, 116, 195, 163, 111, 32, 100, 111, 32, 109, 101, 105, 111, 32, 114, 101, 115, 101, 116, 97, 34,
+10, 34, 84, 121, 112, 101, 32, 118, 97, 108, 117, 101, 44, 32, 114, 101, 115, 101, 116, 44, 32, 97, 117, 116,
+111, 109, 97, 116, 105, 111, 110, 44, 32, 77, 73, 68, 73, 32, 108, 105, 110, 107, 34, 32, 61, 32, 34, 68,
+105, 103, 105, 116, 97, 114, 32, 118, 97, 108, 111, 114, 44, 32, 114, 101, 115, 101, 116, 97, 114, 44, 32, 97,
+117, 116, 111, 109, 97, 195, 167, 195, 163, 111, 44, 32, 108, 105, 110, 107, 32, 77, 73, 68, 73, 34, 10, 34,
+82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 80, 97, 116, 116, 101, 114, 110, 32, 47, 32, 83, 111,
+110, 103, 34, 32, 61, 32, 34, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 101, 109,
+32, 80, 97, 116, 116, 101, 114, 110, 32, 47, 32, 83, 111, 110, 103, 34, 10, 34, 83, 104, 111, 119, 32, 116,
+104, 101, 32, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 47, 32, 80, 108, 97, 121, 108, 105,
+115, 116, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 111, 32, 67, 104, 97, 110, 110, 101, 108,
+32, 82, 97, 99, 107, 32, 47, 32, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 68, 111, 117,
+98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 83, 116, 111, 112, 34, 32, 61, 32, 34, 68, 117, 112, 108, 111,
+32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 83, 116, 111, 112, 34, 10, 34, 65, 108, 108, 32, 110, 111,
+116, 101, 115, 32, 111, 102, 102, 34, 32, 61, 32, 34, 68, 101, 115, 108, 105, 103, 97, 114, 32, 116, 111, 100,
+97, 115, 32, 97, 115, 32, 110, 111, 116, 97, 115, 34, 10, 34, 65, 100, 100, 32, 97, 32, 109, 105, 120, 101,
+114, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117,
+109, 32, 105, 110, 115, 101, 114, 116, 32, 97, 111, 32, 109, 105, 120, 101, 114, 34, 10, 34, 83, 111, 108, 111,
+34, 32, 61, 32, 34, 83, 111, 108, 111, 34, 10, 34, 83, 101, 110, 100, 32, 102, 114, 111, 109, 32, 116, 104,
+101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 32, 116, 111, 32, 116, 104, 105,
+115, 32, 111, 110, 101, 32, 40, 100, 114, 97, 103, 32, 97, 102, 116, 101, 114, 32, 101, 110, 97, 98, 108, 105,
+110, 103, 58, 32, 108, 101, 118, 101, 108, 41, 34, 32, 61, 32, 34, 69, 110, 118, 105, 111, 32, 100, 111, 32,
+105, 110, 115, 101, 114, 116, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 32, 112, 97, 114, 97, 32,
+101, 115, 116, 101, 32, 40, 97, 114, 114, 97, 115, 116, 101, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32,
+108, 105, 103, 97, 114, 58, 32, 110, 195, 173, 118, 101, 108, 41, 34, 10, 34, 67, 108, 105, 99, 107, 32, 115,
+101, 108, 101, 99, 116, 115, 32, 116, 104, 101, 32, 105, 110, 115, 101, 114, 116, 44, 32, 114, 105, 103, 104, 116,
+45, 99, 108, 105, 99, 107, 32, 111, 112, 101, 110, 115, 32, 105, 116, 115, 32, 109, 101, 110, 117, 34, 32, 61,
+32, 34, 67, 108, 105, 113, 117, 101, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 32, 111, 32, 105, 110, 115,
+101, 114, 116, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 98, 114, 101,
+32, 111, 32, 109, 101, 110, 117, 34, 10, 34, 69, 102, 102, 101, 99, 116, 32, 115, 108, 111, 116, 58, 32, 99,
+108, 105, 99, 107, 32, 101, 100, 105, 116, 115, 44, 32, 116, 104, 101, 32, 76, 69, 68, 32, 98, 121, 112, 97,
+115, 115, 101, 115, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 114, 101, 112, 108, 97,
+99, 101, 44, 32, 109, 111, 118, 101, 44, 32, 100, 101, 108, 101, 116, 101, 34, 32, 61, 32, 34, 83, 108, 111,
+116, 32, 100, 101, 32, 101, 102, 101, 105, 116, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 101, 100, 105, 116,
+97, 44, 32, 111, 32, 76, 69, 68, 32, 102, 97, 122, 32, 98, 121, 112, 97, 115, 115, 44, 32, 98, 111, 116,
+195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 116, 114, 111, 99, 97, 114, 44, 32, 109, 111, 118,
+101, 114, 44, 32, 101, 120, 99, 108, 117, 105, 114, 34, 10, 34, 69, 109, 112, 116, 121, 32, 115, 108, 111, 116,
+58, 32, 99, 108, 105, 99, 107, 32, 116, 111, 32, 97, 100, 100, 32, 97, 110, 32, 101, 102, 102, 101, 99, 116,
+34, 32, 61, 32, 34, 83, 108, 111, 116, 32, 118, 97, 122, 105, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32,
+112, 97, 114, 97, 32, 97, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 101, 102, 101, 105, 116, 111,
+34, 10, 34, 67, 101, 110, 116, 101, 114, 101, 100, 34, 32, 61, 32, 34, 67, 101, 110, 116, 114, 111, 34, 10,
+34, 123, 48, 125, 37, 32, 108, 101, 102, 116, 34, 32, 61, 32, 34, 123, 48, 125, 37, 32, 101, 115, 113, 117,
+101, 114, 100, 97, 34, 10, 34, 123, 48, 125, 37, 32, 114, 105, 103, 104, 116, 34, 32, 61, 32, 34, 123, 48,
+125, 37, 32, 100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 84, 121, 112, 101, 32, 118, 97, 108, 117, 101, 34,
+32, 61, 32, 34, 68, 105, 103, 105, 116, 97, 114, 32, 118, 97, 108, 111, 114, 34, 10, 34, 75, 110, 111, 98,
+34, 32, 61, 32, 34, 75, 110, 111, 98, 34, 10, 34, 67, 108, 111, 115, 101, 32, 116, 104, 101, 32, 112, 97,
+110, 101, 108, 32, 40, 105, 116, 115, 32, 70, 45, 107, 101, 121, 32, 115, 104, 111, 119, 115, 32, 105, 116, 32,
+97, 103, 97, 105, 110, 41, 34, 32, 61, 32, 34, 70, 101, 99, 104, 97, 114, 32, 111, 32, 112, 97, 105, 110,
+101, 108, 32, 40, 97, 32, 116, 101, 99, 108, 97, 32, 70, 32, 100, 101, 108, 101, 32, 109, 111, 115, 116, 114,
+97, 32, 100, 101, 32, 110, 111, 118, 111, 41, 34, 10, 34, 68, 111, 99, 107, 32, 116, 104, 101, 32, 112, 97,
+110, 101, 108, 32, 98, 97, 99, 107, 32, 105, 110, 116, 111, 32, 116, 104, 101, 32, 109, 97, 105, 110, 32, 119,
+105, 110, 100, 111, 119, 34, 32, 61, 32, 34, 82, 101, 99, 111, 108, 111, 99, 97, 114, 32, 111, 32, 112, 97,
+105, 110, 101, 108, 32, 110, 97, 32, 106, 97, 110, 101, 108, 97, 32, 112, 114, 105, 110, 99, 105, 112, 97, 108,
+34, 10, 34, 68, 101, 116, 97, 99, 104, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108, 32, 105, 110, 116, 111,
+32, 105, 116, 115, 32, 111, 119, 110, 32, 119, 105, 110, 100, 111, 119, 34, 32, 61, 32, 34, 68, 101, 115, 116,
+97, 99, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 110, 117, 109, 97, 32, 106, 97, 110, 101, 108,
+97, 32, 112, 114, 195, 179, 112, 114, 105, 97, 34, 10, 34, 82, 101, 115, 116, 111, 114, 101, 32, 116, 104, 101,
+32, 112, 97, 110, 101, 108, 32, 115, 105, 122, 101, 32, 40, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99,
+107, 32, 116, 104, 101, 32, 116, 105, 116, 108, 101, 41, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114,
+97, 114, 32, 111, 32, 116, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 112, 97, 105, 110, 101, 108, 32, 40,
+100, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 41,
+34, 10, 34, 77, 97, 120, 105, 109, 105, 122, 101, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108, 32, 40, 100,
+111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 104, 101, 32, 116, 105, 116, 108, 101, 41, 34, 32,
+61, 32, 34, 77, 97, 120, 105, 109, 105, 122, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 40, 100,
+117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 116, 195, 173, 116, 117, 108, 111, 41, 34,
+10, 34, 68, 114, 97, 103, 32, 116, 104, 101, 32, 101, 100, 103, 101, 32, 116, 111, 32, 114, 101, 115, 105, 122,
+101, 32, 116, 104, 101, 32, 112, 97, 110, 101, 108, 34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 101, 32,
+97, 32, 98, 111, 114, 100, 97, 32, 112, 97, 114, 97, 32, 114, 101, 100, 105, 109, 101, 110, 115, 105, 111, 110,
+97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 34, 10, 34, 68, 111, 99, 107, 115, 32, 98, 97, 99, 107,
+32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 98, 117, 116, 116, 111, 110, 32, 111, 110, 32, 116, 104, 101, 32,
+114, 105, 103, 104, 116, 34, 32, 61, 32, 34, 86, 111, 108, 116, 97, 32, 112, 97, 114, 97, 32, 97, 32, 106,
+97, 110, 101, 108, 97, 32, 112, 114, 105, 110, 99, 105, 112, 97, 108, 32, 99, 111, 109, 32, 111, 32, 98, 111,
+116, 195, 163, 111, 32, 195, 160, 32, 100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 68, 114, 97, 103, 32, 116,
+111, 32, 109, 111, 118, 101, 32, 40, 65, 108, 116, 58, 32, 110, 111, 32, 115, 110, 97, 112, 112, 105, 110, 103,
+41, 44, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 109, 97, 120, 105, 109,
+105, 122, 101, 34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 101, 32, 112, 97, 114, 97, 32, 109, 111, 118,
+101, 114, 32, 40, 65, 108, 116, 58, 32, 115, 101, 109, 32, 101, 110, 99, 97, 105, 120, 101, 41, 44, 32, 100,
+117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 109, 97, 120, 105, 109, 105, 122, 97, 34, 10, 34, 70,
+53, 32, 80, 108, 97, 121, 108, 105, 115, 116, 32, 32, 32, 70, 54, 32, 67, 104, 97, 110, 110, 101, 108, 32,
+82, 97, 99, 107, 32, 32, 32, 70, 55, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 32, 32, 70,
+56, 32, 66, 114, 111, 119, 115, 101, 114, 32, 32, 32, 70, 57, 32, 77, 105, 120, 101, 114, 34, 32, 61, 32,
+34, 70, 53, 32, 80, 108, 97, 121, 108, 105, 115, 116, 32, 32, 32, 70, 54, 32, 67, 104, 97, 110, 110, 101,
+108, 32, 82, 97, 99, 107, 32, 32, 32, 70, 55, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 32,
+32, 70, 56, 32, 66, 114, 111, 119, 115, 101, 114, 32, 32, 32, 70, 57, 32, 77, 105, 120, 101, 114, 34, 10,
+10, 35, 32, 45, 45, 45, 32, 87, 111, 114, 107, 102, 108, 111, 119, 32, 80, 50, 58, 32, 104, 105, 115, 116,
+111, 114, 121, 44, 32, 107, 101, 121, 32, 109, 97, 112, 44, 32, 110, 111, 116, 101, 32, 116, 111, 111, 108, 115,
+44, 32, 109, 105, 120, 101, 114, 44, 32, 98, 114, 111, 119, 115, 101, 114, 44, 32, 114, 101, 99, 111, 114, 100,
+105, 110, 103, 10, 34, 65, 100, 100, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 65, 100, 105,
+99, 105, 111, 110, 97, 114, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 65, 100, 100, 32, 110, 111, 116,
+101, 115, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 110, 111,
+116, 97, 115, 58, 32, 123, 48, 125, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 110, 111, 116, 101, 115, 58,
+32, 123, 48, 125, 34, 32, 61, 32, 34, 65, 112, 97, 103, 97, 114, 32, 110, 111, 116, 97, 115, 58, 32, 123,
+48, 125, 34, 10, 34, 69, 100, 105, 116, 32, 110, 111, 116, 101, 115, 58, 32, 123, 48, 125, 34, 32, 61, 32,
+34, 69, 100, 105, 116, 97, 114, 32, 110, 111, 116, 97, 115, 58, 32, 123, 48, 125, 34, 10, 34, 82, 101, 110,
+97, 109, 101, 32, 112, 97, 116, 116, 101, 114, 110, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 82, 101, 110,
+111, 109, 101, 97, 114, 32, 112, 97, 116, 116, 101, 114, 110, 58, 32, 123, 48, 125, 34, 10, 34, 80, 97, 116,
+116, 101, 114, 110, 32, 108, 101, 110, 103, 116, 104, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 68, 117, 114,
+97, 195, 167, 195, 163, 111, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 58, 32, 123, 48, 125, 34, 10,
+34, 65, 100, 100, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110,
+97, 114, 32, 99, 97, 110, 97, 108, 34, 10, 34, 77, 111, 118, 101, 32, 99, 104, 97, 110, 110, 101, 108, 115,
+34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 99, 97, 110, 97, 105, 115, 34, 10, 34, 77, 117, 116, 101,
+58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 77, 117, 100, 111, 58, 32, 123, 48, 125, 34, 10, 34, 67, 104,
+97, 110, 110, 101, 108, 32, 108, 101, 118, 101, 108, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 78, 195, 173,
+118, 101, 108, 32, 100, 111, 32, 99, 97, 110, 97, 108, 58, 32, 123, 48, 125, 34, 10, 34, 67, 104, 97, 110,
+110, 101, 108, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 58, 32, 123, 48, 125, 34,
+10, 34, 65, 100, 100, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110,
+97, 114, 32, 105, 110, 115, 101, 114, 116, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 105, 110, 115, 101, 114,
+116, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 105, 110, 115, 101, 114, 116, 34, 10, 34, 77,
+111, 118, 101, 32, 105, 110, 115, 101, 114, 116, 115, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 105, 110,
+115, 101, 114, 116, 115, 34, 10, 34, 82, 111, 117, 116, 105, 110, 103, 58, 32, 123, 48, 125, 34, 32, 61, 32,
+34, 82, 111, 116, 101, 97, 109, 101, 110, 116, 111, 58, 32, 123, 48, 125, 34, 10, 34, 77, 105, 120, 101, 114,
+32, 108, 101, 118, 101, 108, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 78, 195, 173, 118, 101, 108, 32, 100,
+111, 32, 109, 105, 120, 101, 114, 58, 32, 123, 48, 125, 34, 10, 34, 77, 105, 120, 101, 114, 58, 32, 123, 48,
+125, 34, 32, 61, 32, 34, 77, 105, 120, 101, 114, 58, 32, 123, 48, 125, 34, 10, 34, 65, 100, 100, 32, 99,
+108, 105, 112, 115, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 99, 108, 105, 112, 101,
+115, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 99, 108, 105, 112, 115, 34, 32, 61, 32, 34, 65, 112, 97,
+103, 97, 114, 32, 99, 108, 105, 112, 101, 115, 34, 10, 34, 69, 100, 105, 116, 32, 99, 108, 105, 112, 115, 34,
+32, 61, 32, 34, 69, 100, 105, 116, 97, 114, 32, 99, 108, 105, 112, 101, 115, 34, 10, 34, 84, 105, 109, 101,
+32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 34, 32, 61, 32, 34, 83, 101, 108, 101, 195, 167, 195, 163, 111,
+32, 100, 101, 32, 116, 101, 109, 112, 111, 34, 10, 34, 77, 97, 114, 107, 101, 114, 115, 34, 32, 61, 32, 34,
+77, 97, 114, 99, 97, 100, 111, 114, 101, 115, 34, 10, 34, 65, 114, 114, 97, 110, 103, 101, 109, 101, 110, 116,
+115, 34, 32, 61, 32, 34, 65, 114, 114, 97, 110, 106, 111, 115, 34, 10, 34, 80, 108, 97, 121, 108, 105, 115,
+116, 32, 116, 114, 97, 99, 107, 115, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 115, 32, 100, 97, 32, 80,
+108, 97, 121, 108, 105, 115, 116, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 112, 97, 116, 116, 101, 114, 110,
+34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 112, 97, 116, 116, 101, 114, 110, 34,
+10, 34, 81, 117, 105, 99, 107, 45, 97, 100, 100, 32, 112, 97, 108, 101, 116, 116, 101, 58, 32, 105, 110, 115,
+116, 114, 117, 109, 101, 110, 116, 115, 32, 97, 110, 100, 32, 101, 102, 102, 101, 99, 116, 115, 34, 32, 61, 32,
+34, 80, 97, 108, 101, 116, 97, 32, 100, 101, 32, 105, 110, 115, 101, 114, 195, 167, 195, 163, 111, 32, 114, 195,
+161, 112, 105, 100, 97, 58, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 111, 115, 32, 101, 32, 101, 102,
+101, 105, 116, 111, 115, 34, 10, 34, 67, 108, 111, 110, 101, 32, 116, 104, 101, 32, 99, 117, 114, 114, 101, 110,
+116, 32, 112, 97, 116, 116, 101, 114, 110, 34, 32, 61, 32, 34, 67, 108, 111, 110, 97, 114, 32, 111, 32, 112,
+97, 116, 116, 101, 114, 110, 32, 97, 116, 117, 97, 108, 34, 10, 34, 77, 111, 118, 101, 32, 116, 104, 101, 32,
+99, 117, 114, 114, 101, 110, 116, 32, 112, 97, 116, 116, 101, 114, 110, 32, 117, 112, 34, 32, 61, 32, 34, 77,
+111, 118, 101, 114, 32, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 97, 116, 117, 97, 108, 32, 112, 97, 114,
+97, 32, 99, 105, 109, 97, 34, 10, 34, 77, 111, 118, 101, 32, 116, 104, 101, 32, 99, 117, 114, 114, 101, 110,
+116, 32, 112, 97, 116, 116, 101, 114, 110, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114,
+32, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32, 97, 116, 117, 97, 108, 32, 112, 97, 114, 97, 32, 98, 97,
+105, 120, 111, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111, 110, 47, 111, 102, 102, 34, 32,
+61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105,
+103, 97, 34, 10, 34, 77, 101, 116, 114, 111, 110, 111, 109, 101, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61,
+32, 34, 77, 101, 116, 114, 195, 180, 110, 111, 109, 111, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103,
+97, 34, 10, 34, 67, 111, 117, 110, 116, 45, 105, 110, 32, 98, 101, 102, 111, 114, 101, 32, 114, 101, 99, 111,
+114, 100, 105, 110, 103, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32, 34, 67, 111, 110, 116, 97, 103, 101,
+109, 32, 97, 110, 116, 101, 115, 32, 100, 101, 32, 103, 114, 97, 118, 97, 114, 32, 108, 105, 103, 97, 47, 100,
+101, 115, 108, 105, 103, 97, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 32, 119, 97, 105, 116, 115,
+32, 102, 111, 114, 32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 110, 111, 116, 101, 32, 111, 110, 47, 111,
+102, 102, 34, 32, 61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32, 101, 115, 112, 101, 114, 97,
+32, 97, 32, 112, 114, 105, 109, 101, 105, 114, 97, 32, 110, 111, 116, 97, 32, 108, 105, 103, 97, 47, 100, 101,
+115, 108, 105, 103, 97, 34, 10, 34, 85, 110, 100, 111, 32, 104, 105, 115, 116, 111, 114, 121, 34, 32, 61, 32,
+34, 72, 105, 115, 116, 195, 179, 114, 105, 99, 111, 32, 100, 101, 32, 100, 101, 115, 102, 97, 122, 101, 114, 34,
+10, 34, 83, 101, 97, 114, 99, 104, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32,
+34, 66, 117, 115, 99, 97, 114, 32, 110, 111, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 83, 116, 101,
+112, 32, 103, 114, 97, 112, 104, 32, 108, 97, 110, 101, 115, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32,
+34, 70, 97, 105, 120, 97, 115, 32, 100, 101, 32, 103, 114, 195, 161, 102, 105, 99, 111, 32, 100, 111, 115, 32,
+115, 116, 101, 112, 115, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 34, 10, 34, 82, 111, 116,
+97, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108,
+115, 39, 32, 115, 116, 101, 112, 115, 32, 108, 101, 102, 116, 34, 32, 61, 32, 34, 71, 105, 114, 97, 114, 32,
+111, 115, 32, 115, 116, 101, 112, 115, 32, 100, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101,
+99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 97, 32, 101, 115, 113, 117, 101, 114, 100, 97,
+34, 10, 34, 82, 111, 116, 97, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99,
+104, 97, 110, 110, 101, 108, 115, 39, 32, 115, 116, 101, 112, 115, 32, 114, 105, 103, 104, 116, 34, 32, 61, 32,
+34, 71, 105, 114, 97, 114, 32, 111, 115, 32, 115, 116, 101, 112, 115, 32, 100, 111, 115, 32, 99, 97, 110, 97,
+105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 97, 32, 100,
+105, 114, 101, 105, 116, 97, 34, 10, 34, 65, 114, 112, 101, 103, 103, 105, 97, 116, 101, 46, 46, 46, 34, 32,
+61, 32, 34, 65, 114, 112, 101, 106, 97, 114, 46, 46, 46, 34, 10, 34, 83, 116, 114, 117, 109, 46, 46, 46,
+34, 32, 61, 32, 34, 68, 101, 100, 105, 108, 104, 97, 114, 32, 40, 115, 116, 114, 117, 109, 41, 46, 46, 46,
+34, 10, 34, 70, 108, 105, 112, 46, 46, 46, 34, 32, 61, 32, 34, 69, 115, 112, 101, 108, 104, 97, 114, 46,
+46, 46, 34, 10, 34, 82, 97, 110, 100, 111, 109, 105, 115, 101, 46, 46, 46, 34, 32, 61, 32, 34, 65, 108,
+101, 97, 116, 111, 114, 105, 122, 97, 114, 46, 46, 46, 34, 10, 34, 83, 99, 97, 108, 101, 32, 108, 101, 118,
+101, 108, 115, 46, 46, 46, 34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 114, 32, 110, 195, 173, 118, 101,
+105, 115, 46, 46, 46, 34, 10, 34, 76, 105, 109, 105, 116, 32, 116, 111, 32, 97, 32, 114, 97, 110, 103, 101,
+46, 46, 46, 34, 32, 61, 32, 34, 76, 105, 109, 105, 116, 97, 114, 32, 97, 32, 117, 109, 97, 32, 102, 97,
+105, 120, 97, 46, 46, 46, 34, 10, 34, 90, 111, 111, 109, 32, 105, 110, 34, 32, 61, 32, 34, 65, 112, 114,
+111, 120, 105, 109, 97, 114, 34, 10, 34, 90, 111, 111, 109, 32, 111, 117, 116, 34, 32, 61, 32, 34, 65, 102,
+97, 115, 116, 97, 114, 34, 10, 34, 90, 111, 111, 109, 58, 32, 111, 110, 101, 32, 98, 97, 114, 34, 32, 61,
+32, 34, 90, 111, 111, 109, 58, 32, 117, 109, 32, 99, 111, 109, 112, 97, 115, 115, 111, 34, 10, 34, 90, 111,
+111, 109, 58, 32, 102, 111, 117, 114, 32, 98, 97, 114, 115, 34, 32, 61, 32, 34, 90, 111, 111, 109, 58, 32,
+113, 117, 97, 116, 114, 111, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 90, 111, 111, 109, 58,
+32, 115, 105, 120, 116, 101, 101, 110, 32, 98, 97, 114, 115, 34, 32, 61, 32, 34, 90, 111, 111, 109, 58, 32,
+100, 101, 122, 101, 115, 115, 101, 105, 115, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 90, 111,
+111, 109, 32, 116, 111, 32, 115, 104, 111, 119, 32, 101, 118, 101, 114, 121, 116, 104, 105, 110, 103, 34, 32, 61,
+32, 34, 90, 111, 111, 109, 32, 112, 97, 114, 97, 32, 109, 111, 115, 116, 114, 97, 114, 32, 116, 117, 100, 111,
+34, 10, 34, 90, 111, 111, 109, 32, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110,
+34, 32, 61, 32, 34, 90, 111, 111, 109, 32, 110, 97, 32, 115, 101, 108, 101, 195, 167, 195, 163, 111, 34, 10,
+34, 67, 101, 110, 116, 114, 101, 32, 116, 104, 101, 32, 118, 105, 101, 119, 32, 111, 110, 32, 116, 104, 101, 32,
+112, 108, 97, 121, 104, 101, 97, 100, 34, 32, 61, 32, 34, 67, 101, 110, 116, 114, 97, 108, 105, 122, 97, 114,
+32, 97, 32, 118, 105, 115, 116, 97, 32, 110, 111, 32, 99, 117, 114, 115, 111, 114, 32, 100, 101, 32, 114, 101,
+112, 114, 111, 100, 117, 195, 167, 195, 163, 111, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 116, 104, 101, 32,
+115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 108, 105, 112, 115, 32, 97, 110, 100, 32, 99, 108, 111, 115, 101,
+32, 116, 104, 101, 32, 103, 97, 112, 115, 34, 32, 61, 32, 34, 65, 112, 97, 103, 97, 114, 32, 111, 115, 32,
+99, 108, 105, 112, 101, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 101, 32, 102, 101,
+99, 104, 97, 114, 32, 111, 115, 32, 118, 195, 163, 111, 115, 34, 10, 34, 82, 105, 112, 112, 108, 101, 32, 101,
+100, 105, 116, 105, 110, 103, 32, 111, 110, 47, 111, 102, 102, 34, 32, 61, 32, 34, 69, 100, 105, 195, 167, 195,
+163, 111, 32, 114, 105, 112, 112, 108, 101, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 34, 10,
+34, 77, 111, 118, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114,
+116, 115, 32, 108, 101, 102, 116, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 111, 115, 32, 105, 110, 115,
+101, 114, 116, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 97,
+32, 101, 115, 113, 117, 101, 114, 100, 97, 34, 10, 34, 77, 111, 118, 101, 32, 116, 104, 101, 32, 115, 101, 108,
+101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 115, 32, 114, 105, 103, 104, 116, 34, 32, 61, 32, 34,
+77, 111, 118, 101, 114, 32, 111, 115, 32, 105, 110, 115, 101, 114, 116, 115, 32, 115, 101, 108, 101, 99, 105, 111,
+110, 97, 100, 111, 115, 32, 112, 97, 114, 97, 32, 97, 32, 100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 76,
+105, 110, 107, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108,
+115, 32, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116,
+34, 32, 61, 32, 34, 76, 105, 103, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108,
+101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 97, 111, 32, 105, 110, 115, 101, 114, 116, 32, 115, 101, 108, 101,
+99, 105, 111, 110, 97, 100, 111, 34, 10, 34, 76, 105, 110, 107, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99,
+116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 116, 111, 32, 105, 110, 115, 101, 114, 116, 115, 32,
+115, 116, 97, 114, 116, 105, 110, 103, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116,
+101, 100, 32, 111, 110, 101, 34, 32, 61, 32, 34, 76, 105, 103, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97,
+105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 97, 32, 105, 110, 115, 101, 114, 116,
+115, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 111, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100,
+111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32,
+108, 105, 110, 107, 101, 100, 32, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105,
+110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 111, 115, 32,
+99, 97, 110, 97, 105, 115, 32, 108, 105, 103, 97, 100, 111, 115, 32, 97, 111, 32, 105, 110, 115, 101, 114, 116,
+32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 112, 97,
+116, 116, 101, 114, 110, 32, 123, 48, 125, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114,
+32, 112, 97, 116, 116, 101, 114, 110, 32, 123, 48, 125, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32,
+102, 105, 108, 101, 32, 40, 112, 114, 101, 118, 105, 101, 119, 41, 34, 32, 61, 32, 34, 65, 114, 113, 117, 105,
+118, 111, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32, 40, 112, 114, 195, 169, 45, 101, 115, 99, 117, 116, 97,
+41, 34, 10, 34, 78, 101, 120, 116, 32, 102, 105, 108, 101, 32, 40, 112, 114, 101, 118, 105, 101, 119, 41, 34,
+32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109, 111, 32, 97, 114, 113, 117, 105, 118, 111, 32, 40, 112, 114,
+195, 169, 45, 101, 115, 99, 117, 116, 97, 41, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 102, 105,
+108, 101, 32, 105, 110, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97,
+110, 110, 101, 108, 34, 32, 61, 32, 34, 65, 114, 113, 117, 105, 118, 111, 32, 97, 110, 116, 101, 114, 105, 111,
+114, 32, 110, 111, 32, 99, 97, 110, 97, 108, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 34, 10,
+34, 78, 101, 120, 116, 32, 102, 105, 108, 101, 32, 105, 110, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101,
+99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 80, 114, 195, 179, 120, 105, 109,
+111, 32, 97, 114, 113, 117, 105, 118, 111, 32, 110, 111, 32, 99, 97, 110, 97, 108, 32, 115, 101, 108, 101, 99,
+105, 111, 110, 97, 100, 111, 34, 10, 34, 76, 111, 97, 100, 32, 116, 104, 101, 32, 102, 105, 108, 101, 32, 105,
+110, 116, 111, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108,
+34, 32, 61, 32, 34, 67, 97, 114, 114, 101, 103, 97, 114, 32, 111, 32, 97, 114, 113, 117, 105, 118, 111, 32,
+110, 111, 32, 99, 97, 110, 97, 108, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 34, 10, 34, 67,
+108, 105, 99, 107, 58, 32, 110, 101, 119, 32, 112, 111, 105, 110, 116, 32, 194, 183, 32, 100, 114, 97, 103, 58,
+32, 109, 111, 118, 101, 32, 40, 116, 104, 101, 110, 32, 83, 104, 105, 102, 116, 58, 32, 116, 105, 109, 101, 32,
+108, 111, 99, 107, 101, 100, 44, 32, 67, 116, 114, 108, 58, 32, 118, 97, 108, 117, 101, 32, 108, 111, 99, 107,
+101, 100, 41, 32, 194, 183, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 58, 32, 112, 111, 105, 110,
+116, 32, 109, 101, 110, 117, 32, 194, 183, 32, 65, 108, 116, 43, 100, 114, 97, 103, 58, 32, 99, 117, 114, 118,
+101, 32, 194, 183, 32, 67, 116, 114, 108, 43, 119, 104, 101, 101, 108, 58, 32, 122, 111, 111, 109, 34, 32, 61,
+32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 110, 111, 118, 111, 32, 112, 111, 110, 116, 111, 32, 194, 183, 32,
+97, 114, 114, 97, 115, 116, 97, 114, 58, 32, 109, 111, 118, 101, 114, 32, 40, 100, 101, 112, 111, 105, 115, 32,
+83, 104, 105, 102, 116, 58, 32, 116, 114, 97, 118, 97, 32, 111, 32, 116, 101, 109, 112, 111, 44, 32, 67, 116,
+114, 108, 58, 32, 116, 114, 97, 118, 97, 32, 111, 32, 118, 97, 108, 111, 114, 41, 32, 194, 183, 32, 98, 111,
+116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 101, 110, 117, 32, 100, 111, 32, 112, 111,
+110, 116, 111, 32, 194, 183, 32, 65, 108, 116, 43, 97, 114, 114, 97, 115, 116, 97, 114, 58, 32, 99, 117, 114,
+118, 97, 32, 194, 183, 32, 67, 116, 114, 108, 43, 114, 111, 100, 97, 58, 32, 122, 111, 111, 109, 34, 10, 34,
+67, 111, 112, 121, 32, 118, 97, 108, 117, 101, 34, 32, 61, 32, 34, 67, 111, 112, 105, 97, 114, 32, 118, 97,
+108, 111, 114, 34, 10, 34, 80, 97, 115, 116, 101, 32, 118, 97, 108, 117, 101, 34, 32, 61, 32, 34, 67, 111,
+108, 97, 114, 32, 118, 97, 108, 111, 114, 34, 10, 34, 83, 116, 114, 97, 105, 103, 104, 116, 32, 115, 101, 103,
+109, 101, 110, 116, 32, 40, 114, 101, 115, 101, 116, 32, 116, 104, 101, 32, 99, 117, 114, 118, 101, 41, 34, 32,
+61, 32, 34, 83, 101, 103, 109, 101, 110, 116, 111, 32, 114, 101, 116, 111, 32, 40, 122, 101, 114, 97, 32, 97,
+32, 99, 117, 114, 118, 97, 41, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 112, 111, 105, 110, 116, 34, 32,
+61, 32, 34, 65, 112, 97, 103, 97, 114, 32, 112, 111, 110, 116, 111, 34, 10, 34, 80, 111, 105, 110, 116, 32,
+118, 97, 108, 117, 101, 34, 32, 61, 32, 34, 86, 97, 108, 111, 114, 32, 100, 111, 32, 112, 111, 110, 116, 111,
+34, 10, 34, 66, 80, 77, 34, 32, 61, 32, 34, 66, 80, 77, 34, 10, 34, 80, 101, 114, 99, 101, 110, 116,
+32, 40, 48, 32, 116, 111, 32, 49, 48, 48, 41, 34, 32, 61, 32, 34, 80, 111, 114, 99, 101, 110, 116, 97,
+103, 101, 109, 32, 40, 48, 32, 97, 32, 49, 48, 48, 41, 34, 10, 34, 83, 99, 97, 108, 101, 32, 116, 104,
+101, 32, 118, 97, 108, 117, 101, 115, 32, 105, 110, 116, 111, 32, 97, 32, 114, 97, 110, 103, 101, 46, 46, 46,
+34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 114, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 32,
+112, 97, 114, 97, 32, 117, 109, 97, 32, 102, 97, 105, 120, 97, 46, 46, 46, 34, 10, 34, 70, 108, 105, 112,
+32, 116, 104, 101, 32, 118, 97, 108, 117, 101, 115, 32, 117, 112, 115, 105, 100, 101, 32, 100, 111, 119, 110, 34,
+32, 61, 32, 34, 73, 110, 118, 101, 114, 116, 101, 114, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 32,
+100, 101, 32, 99, 97, 98, 101, 195, 167, 97, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120, 111, 34, 10, 34,
+65, 108, 108, 32, 115, 101, 103, 109, 101, 110, 116, 115, 32, 115, 116, 114, 97, 105, 103, 104, 116, 34, 32, 61,
+32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32, 115, 101, 103, 109, 101, 110, 116, 111, 115, 32, 114, 101, 116,
+111, 115, 34, 10, 34, 83, 99, 97, 108, 101, 32, 116, 104, 101, 32, 118, 97, 108, 117, 101, 115, 32, 105, 110,
+116, 111, 32, 97, 32, 114, 97, 110, 103, 101, 34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 114, 32, 111,
+115, 32, 118, 97, 108, 111, 114, 101, 115, 32, 112, 97, 114, 97, 32, 117, 109, 97, 32, 102, 97, 105, 120, 97,
+34, 10, 34, 84, 104, 101, 32, 108, 111, 119, 101, 115, 116, 32, 112, 111, 105, 110, 116, 32, 103, 111, 101, 115,
+32, 116, 111, 32, 116, 104, 101, 32, 109, 105, 110, 105, 109, 117, 109, 32, 97, 110, 100, 32, 116, 104, 101, 32,
+104, 105, 103, 104, 101, 115, 116, 32, 116, 111, 32, 116, 104, 101, 32, 109, 97, 120, 105, 109, 117, 109, 32, 40,
+112, 101, 114, 99, 101, 110, 116, 41, 46, 34, 32, 61, 32, 34, 79, 32, 112, 111, 110, 116, 111, 32, 109, 97,
+105, 115, 32, 98, 97, 105, 120, 111, 32, 118, 97, 105, 32, 97, 111, 32, 109, 195, 173, 110, 105, 109, 111, 32,
+101, 32, 111, 32, 109, 97, 105, 115, 32, 97, 108, 116, 111, 32, 97, 111, 32, 109, 195, 161, 120, 105, 109, 111,
+32, 40, 112, 111, 114, 99, 101, 110, 116, 97, 103, 101, 109, 41, 46, 34, 10, 34, 77, 105, 110, 105, 109, 117,
+109, 34, 32, 61, 32, 34, 77, 195, 173, 110, 105, 109, 111, 34, 10, 34, 77, 97, 120, 105, 109, 117, 109, 34,
+32, 61, 32, 34, 77, 195, 161, 120, 105, 109, 111, 34, 10, 34, 83, 101, 97, 114, 99, 104, 32, 40, 67, 116,
+114, 108, 43, 70, 41, 58, 32, 107, 105, 99, 107, 32, 45, 108, 111, 111, 112, 44, 32, 115, 110, 97, 114, 101,
+32, 79, 82, 32, 99, 108, 97, 112, 44, 32, 104, 97, 116, 42, 46, 119, 97, 118, 34, 32, 61, 32, 34, 66,
+117, 115, 99, 97, 114, 32, 40, 67, 116, 114, 108, 43, 70, 41, 58, 32, 107, 105, 99, 107, 32, 45, 108, 111,
+111, 112, 44, 32, 115, 110, 97, 114, 101, 32, 79, 82, 32, 99, 108, 97, 112, 44, 32, 104, 97, 116, 42, 46,
+119, 97, 118, 34, 10, 34, 65, 100, 100, 32, 102, 111, 108, 100, 101, 114, 46, 46, 46, 34, 32, 61, 32, 34,
+65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 112, 97, 115, 116, 97, 46, 46, 46, 34, 10, 34, 65, 100, 100,
+32, 97, 32, 102, 111, 108, 100, 101, 114, 32, 116, 111, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114,
+34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 97, 32, 112, 97, 115, 116, 97,
+32, 97, 111, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 78, 111, 116, 104, 105, 110, 103, 32, 102, 111,
+117, 110, 100, 32, 102, 111, 114, 32, 92, 34, 123, 48, 125, 92, 34, 46, 34, 32, 61, 32, 34, 78, 97, 100,
+97, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 32, 112, 97, 114, 97, 32, 92, 34, 123, 48, 125, 92,
+34, 46, 34, 10, 34, 83, 101, 97, 114, 99, 104, 105, 110, 103, 32, 123, 48, 125, 46, 46, 46, 34, 32, 61,
+32, 34, 66, 117, 115, 99, 97, 110, 100, 111, 32, 101, 109, 32, 123, 48, 125, 46, 46, 46, 34, 10, 34, 83,
+104, 111, 119, 105, 110, 103, 32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 123, 48, 125, 32, 114, 101, 115,
+117, 108, 116, 115, 46, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 110, 100, 111, 32, 111, 115, 32, 112,
+114, 105, 109, 101, 105, 114, 111, 115, 32, 123, 48, 125, 32, 114, 101, 115, 117, 108, 116, 97, 100, 111, 115, 46,
+34, 10, 34, 68, 114, 97, 103, 58, 32, 115, 101, 116, 32, 32, 194, 183, 32, 32, 82, 105, 103, 104, 116, 45,
+100, 114, 97, 103, 58, 32, 114, 97, 109, 112, 32, 32, 194, 183, 32, 32, 65, 108, 116, 43, 99, 108, 105, 99,
+107, 58, 32, 114, 101, 115, 101, 116, 34, 32, 61, 32, 34, 65, 114, 114, 97, 115, 116, 97, 114, 58, 32, 100,
+101, 102, 105, 110, 101, 32, 32, 194, 183, 32, 32, 65, 114, 114, 97, 115, 116, 97, 114, 32, 99, 111, 109, 32,
+111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 114, 97, 109, 112, 97, 32, 32, 194, 183, 32, 32, 65, 108,
+116, 43, 99, 108, 105, 113, 117, 101, 58, 32, 114, 101, 115, 116, 97, 117, 114, 97, 34, 10, 34, 83, 101, 108,
+101, 99, 116, 32, 117, 110, 117, 115, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34,
+83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 109, 32, 117, 115,
+111, 34, 10, 34, 69, 118, 101, 114, 121, 32, 99, 104, 97, 110, 110, 101, 108, 32, 105, 115, 32, 117, 115, 101,
+100, 32, 98, 121, 32, 97, 32, 112, 97, 116, 116, 101, 114, 110, 32, 111, 114, 32, 97, 32, 80, 108, 97, 121,
+108, 105, 115, 116, 32, 99, 108, 105, 112, 46, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32,
+99, 97, 110, 97, 105, 115, 32, 115, 195, 163, 111, 32, 117, 115, 97, 100, 111, 115, 32, 112, 111, 114, 32, 117,
+109, 32, 112, 97, 116, 116, 101, 114, 110, 32, 111, 117, 32, 112, 111, 114, 32, 117, 109, 32, 99, 108, 105, 112,
+101, 32, 100, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 46, 34, 10, 34, 80, 117, 108, 115, 101, 115, 34,
+32, 61, 32, 34, 80, 117, 108, 115, 111, 115, 34, 10, 34, 76, 101, 110, 103, 116, 104, 32, 40, 115, 116, 101,
+112, 115, 41, 34, 32, 61, 32, 34, 68, 117, 114, 97, 195, 167, 195, 163, 111, 32, 40, 115, 116, 101, 112, 115,
+41, 34, 10, 34, 82, 111, 116, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 82, 111, 116, 97, 195, 167, 195,
+163, 111, 34, 10, 34, 69, 117, 99, 108, 105, 100, 101, 97, 110, 32, 102, 105, 108, 108, 58, 32, 123, 48, 125,
+34, 32, 61, 32, 34, 80, 114, 101, 101, 110, 99, 104, 105, 109, 101, 110, 116, 111, 32, 101, 117, 99, 108, 105,
+100, 105, 97, 110, 111, 58, 32, 123, 48, 125, 34, 10, 34, 65, 99, 99, 101, 112, 116, 34, 32, 61, 32, 34,
+65, 99, 101, 105, 116, 97, 114, 34, 10, 34, 69, 117, 99, 108, 105, 100, 101, 97, 110, 32, 102, 105, 108, 108,
+34, 32, 61, 32, 34, 80, 114, 101, 101, 110, 99, 104, 105, 109, 101, 110, 116, 111, 32, 101, 117, 99, 108, 105,
+100, 105, 97, 110, 111, 34, 10, 34, 71, 114, 97, 112, 104, 32, 108, 97, 110, 101, 58, 32, 99, 104, 111, 111,
+115, 101, 32, 119, 104, 97, 116, 32, 116, 104, 101, 32, 98, 97, 114, 115, 32, 101, 100, 105, 116, 32, 40, 67,
+116, 114, 108, 43, 75, 32, 104, 105, 100, 101, 115, 32, 116, 104, 101, 32, 108, 97, 110, 101, 41, 34, 32, 61,
+32, 34, 70, 97, 105, 120, 97, 32, 100, 101, 32, 103, 114, 195, 161, 102, 105, 99, 111, 58, 32, 101, 115, 99,
+111, 108, 104, 97, 32, 111, 32, 113, 117, 101, 32, 97, 115, 32, 98, 97, 114, 114, 97, 115, 32, 101, 100, 105,
+116, 97, 109, 32, 40, 67, 116, 114, 108, 43, 75, 32, 101, 115, 99, 111, 110, 100, 101, 32, 97, 32, 102, 97,
+105, 120, 97, 41, 34, 10, 34, 71, 114, 97, 112, 104, 32, 108, 97, 110, 101, 58, 32, 100, 114, 97, 103, 32,
+115, 101, 116, 115, 32, 116, 104, 101, 32, 115, 116, 101, 112, 115, 44, 32, 114, 105, 103, 104, 116, 45, 100, 114,
+97, 103, 32, 100, 114, 97, 119, 115, 32, 97, 32, 114, 97, 109, 112, 44, 32, 65, 108, 116, 43, 99, 108, 105,
+99, 107, 32, 114, 101, 115, 101, 116, 115, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 32, 100, 101, 32, 103,
+114, 195, 161, 102, 105, 99, 111, 58, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 100, 101, 102, 105, 110, 101,
+32, 111, 115, 32, 115, 116, 101, 112, 115, 44, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 99, 111, 109, 32,
+111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 100, 101, 115, 101, 110, 104, 97, 32, 117, 109, 97, 32, 114, 97,
+109, 112, 97, 44, 32, 65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 32, 114, 101, 115, 116, 97, 117, 114, 97,
+34, 10, 34, 70, 105, 108, 108, 32, 101, 118, 101, 114, 121, 32, 50, 32, 115, 116, 101, 112, 115, 34, 32, 61,
+32, 34, 80, 114, 101, 101, 110, 99, 104, 101, 114, 32, 97, 32, 99, 97, 100, 97, 32, 50, 32, 115, 116, 101,
+112, 115, 34, 10, 34, 70, 105, 108, 108, 32, 101, 118, 101, 114, 121, 32, 52, 32, 115, 116, 101, 112, 115, 34,
+32, 61, 32, 34, 80, 114, 101, 101, 110, 99, 104, 101, 114, 32, 97, 32, 99, 97, 100, 97, 32, 52, 32, 115,
+116, 101, 112, 115, 34, 10, 34, 70, 105, 108, 108, 32, 101, 118, 101, 114, 121, 32, 56, 32, 115, 116, 101, 112,
+115, 34, 32, 61, 32, 34, 80, 114, 101, 101, 110, 99, 104, 101, 114, 32, 97, 32, 99, 97, 100, 97, 32, 56,
+32, 115, 116, 101, 112, 115, 34, 10, 34, 69, 117, 99, 108, 105, 100, 101, 97, 110, 32, 102, 105, 108, 108, 46,
+46, 46, 34, 32, 61, 32, 34, 80, 114, 101, 101, 110, 99, 104, 105, 109, 101, 110, 116, 111, 32, 101, 117, 99,
+108, 105, 100, 105, 97, 110, 111, 46, 46, 46, 34, 10, 34, 82, 111, 116, 97, 116, 101, 32, 108, 101, 102, 116,
+34, 32, 61, 32, 34, 71, 105, 114, 97, 114, 32, 112, 97, 114, 97, 32, 97, 32, 101, 115, 113, 117, 101, 114,
+100, 97, 34, 10, 34, 82, 111, 116, 97, 116, 101, 32, 114, 105, 103, 104, 116, 34, 32, 61, 32, 34, 71, 105,
+114, 97, 114, 32, 112, 97, 114, 97, 32, 97, 32, 100, 105, 114, 101, 105, 116, 97, 34, 10, 34, 71, 114, 97,
+112, 104, 32, 108, 97, 110, 101, 115, 32, 40, 118, 101, 108, 111, 99, 105, 116, 121, 44, 32, 112, 97, 110, 44,
+32, 112, 105, 116, 99, 104, 46, 46, 46, 41, 34, 32, 61, 32, 34, 70, 97, 105, 120, 97, 115, 32, 100, 101,
+32, 103, 114, 195, 161, 102, 105, 99, 111, 32, 40, 118, 101, 108, 111, 99, 105, 116, 121, 44, 32, 112, 97, 110,
+44, 32, 97, 102, 105, 110, 97, 195, 167, 195, 163, 111, 46, 46, 46, 41, 34, 10, 34, 83, 116, 101, 112, 115,
+34, 32, 61, 32, 34, 83, 116, 101, 112, 115, 34, 10, 34, 66, 121, 32, 110, 97, 109, 101, 34, 32, 61, 32,
+34, 80, 111, 114, 32, 110, 111, 109, 101, 34, 10, 34, 66, 121, 32, 99, 111, 108, 111, 114, 34, 32, 61, 32,
+34, 80, 111, 114, 32, 99, 111, 114, 34, 10, 34, 66, 121, 32, 109, 105, 120, 101, 114, 32, 105, 110, 115, 101,
+114, 116, 34, 32, 61, 32, 34, 80, 111, 114, 32, 105, 110, 115, 101, 114, 116, 32, 100, 111, 32, 109, 105, 120,
+101, 114, 34, 10, 34, 66, 121, 32, 116, 121, 112, 101, 34, 32, 61, 32, 34, 80, 111, 114, 32, 116, 105, 112,
+111, 34, 10, 34, 83, 111, 114, 116, 32, 99, 104, 97, 110, 110, 101, 108, 115, 34, 32, 61, 32, 34, 79, 114,
+100, 101, 110, 97, 114, 32, 99, 97, 110, 97, 105, 115, 34, 10, 34, 67, 108, 105, 99, 107, 32, 97, 32, 115,
+116, 101, 112, 32, 116, 111, 32, 103, 111, 32, 98, 97, 99, 107, 32, 40, 111, 114, 32, 102, 111, 114, 119, 97,
+114, 100, 41, 32, 116, 111, 32, 105, 116, 46, 32, 78, 101, 119, 101, 115, 116, 32, 97, 116, 32, 116, 104, 101,
+32, 98, 111, 116, 116, 111, 109, 46, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 32, 110, 117, 109, 32,
+112, 97, 115, 115, 111, 32, 112, 97, 114, 97, 32, 118, 111, 108, 116, 97, 114, 32, 40, 111, 117, 32, 97, 118,
+97, 110, 195, 167, 97, 114, 41, 32, 97, 116, 195, 169, 32, 101, 108, 101, 46, 32, 79, 32, 109, 97, 105, 115,
+32, 114, 101, 99, 101, 110, 116, 101, 32, 102, 105, 99, 97, 32, 101, 109, 98, 97, 105, 120, 111, 46, 34, 10,
+34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 34, 32, 61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163,
+111, 34, 10, 34, 81, 117, 105, 99, 107, 45, 97, 100, 100, 32, 112, 97, 108, 101, 116, 116, 101, 34, 32, 61,
+32, 34, 80, 97, 108, 101, 116, 97, 32, 100, 101, 32, 105, 110, 115, 101, 114, 195, 167, 195, 163, 111, 32, 114,
+195, 161, 112, 105, 100, 97, 34, 10, 34, 84, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110,
+115, 101, 114, 116, 32, 104, 97, 115, 32, 110, 111, 32, 102, 114, 101, 101, 32, 101, 102, 102, 101, 99, 116, 32,
+115, 108, 111, 116, 46, 34, 32, 61, 32, 34, 79, 32, 105, 110, 115, 101, 114, 116, 32, 115, 101, 108, 101, 99,
+105, 111, 110, 97, 100, 111, 32, 110, 195, 163, 111, 32, 116, 101, 109, 32, 115, 108, 111, 116, 32, 100, 101, 32,
+101, 102, 101, 105, 116, 111, 32, 108, 105, 118, 114, 101, 46, 34, 10, 34, 67, 111, 117, 110, 116, 45, 105, 110,
+34, 32, 61, 32, 34, 67, 111, 110, 116, 97, 103, 101, 109, 34, 10, 34, 87, 97, 105, 116, 32, 102, 111, 114,
+32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 110, 111, 116, 101, 32, 116, 111, 32, 115, 116, 97, 114, 116,
+34, 32, 61, 32, 34, 69, 115, 112, 101, 114, 97, 114, 32, 97, 32, 112, 114, 105, 109, 101, 105, 114, 97, 32,
+110, 111, 116, 97, 32, 112, 97, 114, 97, 32, 99, 111, 109, 101, 195, 167, 97, 114, 34, 10, 34, 79, 118, 101,
+114, 100, 117, 98, 58, 32, 97, 100, 100, 32, 116, 111, 32, 116, 104, 101, 32, 112, 97, 116, 116, 101, 114, 110,
+34, 32, 61, 32, 34, 79, 118, 101, 114, 100, 117, 98, 58, 32, 115, 111, 109, 97, 32, 97, 111, 32, 112, 97,
+116, 116, 101, 114, 110, 34, 10, 34, 82, 101, 112, 108, 97, 99, 101, 58, 32, 97, 32, 114, 101, 99, 111, 114,
+100, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 39, 115, 32, 111, 108, 100, 32, 110, 111, 116, 101, 115, 32,
+97, 114, 101, 32, 99, 108, 101, 97, 114, 101, 100, 34, 32, 61, 32, 34, 83, 117, 98, 115, 116, 105, 116, 117,
+105, 114, 58, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 97, 110, 116, 105, 103, 97, 115, 32, 100, 101, 32,
+117, 109, 32, 99, 97, 110, 97, 108, 32, 103, 114, 97, 118, 97, 100, 111, 32, 115, 195, 163, 111, 32, 97, 112,
+97, 103, 97, 100, 97, 115, 34, 10, 34, 81, 117, 97, 110, 116, 105, 115, 101, 32, 114, 101, 99, 111, 114, 100,
+101, 100, 32, 110, 111, 116, 101, 115, 32, 116, 111, 32, 116, 104, 101, 32, 103, 108, 111, 98, 97, 108, 32, 103,
+114, 105, 100, 34, 32, 61, 32, 34, 81, 117, 97, 110, 116, 105, 122, 97, 114, 32, 97, 115, 32, 110, 111, 116,
+97, 115, 32, 103, 114, 97, 118, 97, 100, 97, 115, 32, 110, 97, 32, 103, 114, 97, 100, 101, 32, 103, 108, 111,
+98, 97, 108, 34, 10, 34, 83, 111, 110, 103, 32, 109, 111, 100, 101, 58, 32, 112, 108, 97, 99, 101, 32, 97,
+32, 112, 97, 116, 116, 101, 114, 110, 32, 99, 108, 105, 112, 32, 119, 104, 101, 114, 101, 32, 114, 101, 99, 111,
+114, 100, 105, 110, 103, 32, 115, 116, 97, 114, 116, 115, 34, 32, 61, 32, 34, 77, 111, 100, 111, 32, 83, 111,
+110, 103, 58, 32, 99, 111, 108, 111, 99, 97, 114, 32, 117, 109, 32, 99, 108, 105, 112, 101, 32, 100, 111, 32,
+112, 97, 116, 116, 101, 114, 110, 32, 111, 110, 100, 101, 32, 97, 32, 103, 114, 97, 118, 97, 195, 167, 195, 163,
+111, 32, 99, 111, 109, 101, 195, 167, 97, 34, 10, 34, 85, 110, 100, 111, 32, 104, 105, 115, 116, 111, 114, 121,
+46, 46, 46, 34, 32, 61, 32, 34, 72, 105, 115, 116, 195, 179, 114, 105, 99, 111, 32, 100, 101, 32, 100, 101,
+115, 102, 97, 122, 101, 114, 46, 46, 46, 34, 10, 34, 81, 117, 105, 99, 107, 45, 97, 100, 100, 32, 112, 97,
+108, 101, 116, 116, 101, 46, 46, 46, 34, 32, 61, 32, 34, 80, 97, 108, 101, 116, 97, 32, 100, 101, 32, 105,
+110, 115, 101, 114, 195, 167, 195, 163, 111, 32, 114, 195, 161, 112, 105, 100, 97, 46, 46, 46, 34, 10, 34, 82,
+101, 109, 111, 118, 101, 32, 116, 104, 105, 115, 32, 115, 101, 110, 100, 34, 32, 61, 32, 34, 82, 101, 109, 111,
+118, 101, 114, 32, 101, 115, 116, 101, 32, 101, 110, 118, 105, 111, 34, 10, 34, 83, 101, 110, 100, 32, 104, 101,
+114, 101, 34, 32, 61, 32, 34, 69, 110, 118, 105, 97, 114, 32, 112, 97, 114, 97, 32, 99, 195, 161, 34, 10,
+34, 83, 101, 110, 100, 32, 111, 110, 108, 121, 32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 69, 110, 118, 105,
+97, 114, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 99, 195, 161, 34, 10, 34, 83, 105, 100, 101, 99, 104,
+97, 105, 110, 32, 111, 110, 108, 121, 32, 40, 110, 111, 32, 97, 117, 100, 105, 111, 41, 58, 32, 116, 104, 101,
+32, 99, 111, 109, 112, 114, 101, 115, 115, 111, 114, 115, 32, 104, 101, 114, 101, 32, 108, 105, 115, 116, 101, 110,
+32, 116, 111, 32, 105, 116, 34, 32, 61, 32, 34, 83, 195, 179, 32, 115, 105, 100, 101, 99, 104, 97, 105, 110,
+32, 40, 115, 101, 109, 32, 195, 161, 117, 100, 105, 111, 41, 58, 32, 111, 115, 32, 99, 111, 109, 112, 114, 101,
+115, 115, 111, 114, 101, 115, 32, 100, 97, 113, 117, 105, 32, 101, 115, 99, 117, 116, 97, 109, 32, 101, 115, 116,
+101, 32, 105, 110, 115, 101, 114, 116, 34, 10, 34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 34, 32, 61, 32,
+34, 83, 105, 100, 101, 99, 104, 97, 105, 110, 34, 10, 34, 84, 104, 101, 32, 108, 105, 110, 107, 32, 119, 97,
+115, 32, 109, 97, 100, 101, 59, 32, 97, 100, 100, 32, 97, 32, 99, 111, 109, 112, 114, 101, 115, 115, 111, 114,
+32, 116, 111, 32, 116, 104, 105, 115, 32, 105, 110, 115, 101, 114, 116, 32, 116, 111, 32, 117, 115, 101, 32, 105,
+116, 46, 34, 32, 61, 32, 34, 65, 32, 108, 105, 103, 97, 195, 167, 195, 163, 111, 32, 102, 111, 105, 32, 102,
+101, 105, 116, 97, 59, 32, 97, 100, 105, 99, 105, 111, 110, 101, 32, 117, 109, 32, 99, 111, 109, 112, 114, 101,
+115, 115, 111, 114, 32, 97, 32, 101, 115, 116, 101, 32, 105, 110, 115, 101, 114, 116, 32, 112, 97, 114, 97, 32,
+117, 115, 195, 161, 45, 108, 97, 46, 34, 10, 34, 67, 108, 105, 99, 107, 58, 32, 109, 117, 116, 101, 46, 32,
+32, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 111, 114, 32, 67, 116, 114, 108, 43, 99, 108, 105,
+99, 107, 58, 32, 115, 111, 108, 111, 34, 32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 58, 32, 109, 117, 100,
+111, 46, 32, 32, 66, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 111, 117, 32, 67, 116,
+114, 108, 43, 99, 108, 105, 113, 117, 101, 58, 32, 115, 111, 108, 111, 34, 10, 34, 82, 101, 99, 111, 114, 100,
+32, 97, 114, 109, 58, 32, 97, 117, 100, 105, 111, 32, 116, 97, 107, 101, 115, 32, 102, 114, 111, 109, 32, 116,
+104, 101, 32, 105, 110, 112, 117, 116, 32, 112, 108, 97, 121, 32, 116, 104, 114, 111, 117, 103, 104, 32, 116, 104,
+105, 115, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 65, 114, 109, 97, 114, 32, 103, 114, 97, 118,
+97, 195, 167, 195, 163, 111, 58, 32, 97, 115, 32, 116, 111, 109, 97, 100, 97, 115, 32, 100, 101, 32, 195, 161,
+117, 100, 105, 111, 32, 100, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 116, 111, 99, 97, 109, 32, 112, 111,
+114, 32, 101, 115, 116, 101, 32, 105, 110, 115, 101, 114, 116, 34, 10, 34, 83, 101, 110, 100, 32, 102, 114, 111,
+109, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 32, 116, 111,
+32, 116, 104, 105, 115, 32, 111, 110, 101, 32, 40, 100, 114, 97, 103, 32, 97, 102, 116, 101, 114, 32, 101, 110,
+97, 98, 108, 105, 110, 103, 58, 32, 108, 101, 118, 101, 108, 59, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105,
+99, 107, 58, 32, 115, 105, 100, 101, 99, 104, 97, 105, 110, 44, 32, 111, 110, 108, 121, 32, 104, 101, 114, 101,
+41, 34, 32, 61, 32, 34, 69, 110, 118, 105, 111, 32, 100, 111, 32, 105, 110, 115, 101, 114, 116, 32, 115, 101,
+108, 101, 99, 105, 111, 110, 97, 100, 111, 32, 112, 97, 114, 97, 32, 101, 115, 116, 101, 32, 40, 97, 114, 114,
+97, 115, 116, 101, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 108, 105, 103, 97, 114, 58, 32, 110, 195,
+173, 118, 101, 108, 59, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 115, 105,
+100, 101, 99, 104, 97, 105, 110, 44, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 99, 195, 161, 41, 34, 10,
+34, 67, 108, 105, 99, 107, 32, 115, 101, 108, 101, 99, 116, 115, 32, 116, 104, 101, 32, 105, 110, 115, 101, 114,
+116, 32, 40, 67, 116, 114, 108, 58, 32, 97, 100, 100, 44, 32, 83, 104, 105, 102, 116, 58, 32, 114, 97, 110,
+103, 101, 41, 44, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 111, 112, 101, 110, 115, 32, 105,
+116, 115, 32, 109, 101, 110, 117, 59, 32, 65, 108, 116, 43, 76, 101, 102, 116, 47, 82, 105, 103, 104, 116, 32,
+109, 111, 118, 101, 115, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 34, 32, 61, 32, 34,
+67, 108, 105, 113, 117, 101, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 32, 111, 32, 105, 110, 115, 101, 114,
+116, 32, 40, 67, 116, 114, 108, 58, 32, 97, 100, 105, 99, 105, 111, 110, 97, 44, 32, 83, 104, 105, 102, 116,
+58, 32, 105, 110, 116, 101, 114, 118, 97, 108, 111, 41, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114,
+101, 105, 116, 111, 32, 97, 98, 114, 101, 32, 111, 32, 109, 101, 110, 117, 59, 32, 65, 108, 116, 43, 69, 115,
+113, 117, 101, 114, 100, 97, 47, 68, 105, 114, 101, 105, 116, 97, 32, 109, 111, 118, 101, 32, 97, 32, 115, 101,
+108, 101, 195, 167, 195, 163, 111, 34, 10, 34, 76, 105, 110, 107, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99,
+116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 76, 105,
+103, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100,
+111, 115, 32, 97, 113, 117, 105, 34, 10, 34, 76, 105, 110, 107, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99,
+116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 115, 32, 115, 116, 97, 114, 116, 105, 110, 103, 32, 104, 101,
+114, 101, 34, 32, 61, 32, 34, 76, 105, 103, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 115,
+101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100, 97, 113,
+117, 105, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 116, 104, 101, 32, 99, 104, 97, 110, 110, 101, 108, 115,
+32, 108, 105, 110, 107, 101, 100, 32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111,
+110, 97, 114, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 32, 108, 105, 103, 97, 100, 111, 115, 32, 97, 113,
+117, 105, 34, 10, 34, 82, 111, 117, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32,
+105, 110, 115, 101, 114, 116, 115, 32, 104, 101, 114, 101, 34, 32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32,
+111, 115, 32, 105, 110, 115, 101, 114, 116, 115, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32,
+112, 97, 114, 97, 32, 99, 195, 161, 34, 10, 34, 82, 111, 117, 116, 101, 32, 116, 104, 101, 32, 115, 101, 108,
+101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 115, 32, 111, 110, 108, 121, 32, 104, 101, 114, 101, 34,
+32, 61, 32, 34, 82, 111, 116, 101, 97, 114, 32, 111, 115, 32, 105, 110, 115, 101, 114, 116, 115, 32, 115, 101,
+108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 32, 115, 195, 179, 32, 112, 97, 114, 97, 32, 99, 195, 161, 34,
+10, 34, 77, 111, 118, 101, 32, 108, 101, 102, 116, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 112, 97,
+114, 97, 32, 97, 32, 101, 115, 113, 117, 101, 114, 100, 97, 34, 10, 34, 77, 111, 118, 101, 32, 114, 105, 103,
+104, 116, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 112, 97, 114, 97, 32, 97, 32, 100, 105, 114, 101,
+105, 116, 97, 34, 10, 34, 65, 108, 108, 32, 101, 102, 102, 101, 99, 116, 115, 32, 111, 102, 32, 116, 104, 105,
+115, 32, 105, 110, 115, 101, 114, 116, 32, 111, 110, 47, 111, 102, 102, 59, 32, 114, 105, 103, 104, 116, 45, 99,
+108, 105, 99, 107, 32, 111, 112, 101, 110, 115, 32, 111, 114, 32, 99, 108, 111, 115, 101, 115, 32, 116, 104, 101,
+105, 114, 32, 112, 108, 117, 103, 105, 110, 32, 119, 105, 110, 100, 111, 119, 115, 34, 32, 61, 32, 34, 84, 111,
+100, 111, 115, 32, 111, 115, 32, 101, 102, 101, 105, 116, 111, 115, 32, 100, 101, 115, 116, 101, 32, 105, 110, 115,
+101, 114, 116, 32, 108, 105, 103, 97, 47, 100, 101, 115, 108, 105, 103, 97, 59, 32, 98, 111, 116, 195, 163, 111,
+32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 98, 114, 101, 32, 111, 117, 32, 102, 101, 99, 104, 97, 32, 97,
+115, 32, 106, 97, 110, 101, 108, 97, 115, 32, 100, 111, 115, 32, 112, 108, 117, 103, 105, 110, 115, 34, 10, 34,
+69, 102, 102, 101, 99, 116, 32, 115, 108, 111, 116, 58, 32, 99, 108, 105, 99, 107, 32, 101, 100, 105, 116, 115,
+44, 32, 116, 104, 101, 32, 76, 69, 68, 32, 98, 121, 112, 97, 115, 115, 101, 115, 44, 32, 100, 114, 97, 103,
+32, 111, 114, 32, 119, 104, 101, 101, 108, 32, 114, 101, 111, 114, 100, 101, 114, 115, 44, 32, 114, 105, 103, 104,
+116, 45, 99, 108, 105, 99, 107, 58, 32, 114, 101, 112, 108, 97, 99, 101, 44, 32, 109, 111, 118, 101, 44, 32,
+100, 101, 108, 101, 116, 101, 34, 32, 61, 32, 34, 83, 108, 111, 116, 32, 100, 101, 32, 101, 102, 101, 105, 116,
+111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 101, 100, 105, 116, 97, 44, 32, 111, 32, 76, 69, 68, 32, 100,
+101, 115, 97, 116, 105, 118, 97, 44, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 111, 117, 32, 97, 32, 114,
+111, 100, 97, 32, 114, 101, 111, 114, 100, 101, 110, 97, 44, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114,
+101, 105, 116, 111, 58, 32, 115, 117, 98, 115, 116, 105, 116, 117, 105, 114, 44, 32, 109, 111, 118, 101, 114, 44,
+32, 97, 112, 97, 103, 97, 114, 34, 10, 34, 123, 48, 125, 32, 110, 111, 116, 101, 115, 46, 32, 67, 104, 97,
+110, 103, 101, 115, 32, 97, 114, 101, 32, 104, 101, 97, 114, 100, 32, 97, 110, 100, 32, 115, 101, 101, 110, 32,
+114, 105, 103, 104, 116, 32, 97, 119, 97, 121, 59, 32, 65, 99, 99, 101, 112, 116, 32, 107, 101, 101, 112, 115,
+32, 116, 104, 101, 109, 32, 97, 115, 32, 111, 110, 101, 32, 117, 110, 100, 111, 32, 115, 116, 101, 112, 46, 34,
+32, 61, 32, 34, 123, 48, 125, 32, 110, 111, 116, 97, 115, 46, 32, 65, 115, 32, 109, 117, 100, 97, 110, 195,
+167, 97, 115, 32, 115, 195, 163, 111, 32, 111, 117, 118, 105, 100, 97, 115, 32, 101, 32, 118, 105, 115, 116, 97,
+115, 32, 110, 97, 32, 104, 111, 114, 97, 59, 32, 65, 99, 101, 105, 116, 97, 114, 32, 97, 115, 32, 109, 97,
+110, 116, 195, 169, 109, 32, 99, 111, 109, 111, 32, 117, 109, 32, 112, 97, 115, 115, 111, 32, 100, 101, 32, 100,
+101, 115, 102, 97, 122, 101, 114, 46, 34, 10, 34, 115, 116, 101, 112, 115, 34, 32, 61, 32, 34, 115, 116, 101,
+112, 115, 34, 10, 34, 83, 112, 114, 101, 97, 100, 34, 32, 61, 32, 34, 69, 115, 112, 97, 108, 104, 97, 109,
+101, 110, 116, 111, 34, 10, 34, 67, 117, 114, 118, 101, 34, 32, 61, 32, 34, 67, 117, 114, 118, 97, 34, 10,
+34, 86, 101, 108, 111, 99, 105, 116, 121, 32, 112, 101, 114, 32, 110, 111, 116, 101, 34, 32, 61, 32, 34, 86,
+101, 108, 111, 99, 105, 116, 121, 32, 112, 111, 114, 32, 110, 111, 116, 97, 34, 10, 34, 68, 105, 114, 101, 99,
+116, 105, 111, 110, 34, 32, 61, 32, 34, 68, 105, 114, 101, 195, 167, 195, 163, 111, 34, 10, 34, 76, 111, 119,
+32, 116, 111, 32, 104, 105, 103, 104, 34, 32, 61, 32, 34, 68, 111, 32, 103, 114, 97, 118, 101, 32, 97, 111,
+32, 97, 103, 117, 100, 111, 34, 10, 34, 72, 105, 103, 104, 32, 116, 111, 32, 108, 111, 119, 34, 32, 61, 32,
+34, 68, 111, 32, 97, 103, 117, 100, 111, 32, 97, 111, 32, 103, 114, 97, 118, 101, 34, 10, 34, 65, 108, 116,
+101, 114, 110, 97, 116, 101, 34, 32, 61, 32, 34, 65, 108, 116, 101, 114, 110, 97, 114, 34, 10, 34, 75, 101,
+101, 112, 32, 116, 104, 101, 32, 101, 110, 100, 115, 34, 32, 61, 32, 34, 77, 97, 110, 116, 101, 114, 32, 111,
+115, 32, 102, 105, 110, 97, 105, 115, 34, 10, 34, 68, 111, 119, 110, 32, 97, 110, 100, 32, 117, 112, 34, 32,
+61, 32, 34, 68, 101, 115, 99, 101, 32, 101, 32, 115, 111, 98, 101, 34, 10, 34, 79, 99, 116, 97, 118, 101,
+115, 34, 32, 61, 32, 34, 79, 105, 116, 97, 118, 97, 115, 34, 10, 34, 70, 108, 105, 112, 32, 105, 110, 32,
+116, 105, 109, 101, 34, 32, 61, 32, 34, 69, 115, 112, 101, 108, 104, 97, 114, 32, 110, 111, 32, 116, 101, 109,
+112, 111, 34, 10, 34, 70, 108, 105, 112, 32, 105, 110, 32, 112, 105, 116, 99, 104, 34, 32, 61, 32, 34, 69,
+115, 112, 101, 108, 104, 97, 114, 32, 110, 97, 32, 97, 108, 116, 117, 114, 97, 34, 10, 34, 84, 105, 109, 105,
+110, 103, 34, 32, 61, 32, 34, 84, 101, 109, 112, 111, 34, 10, 34, 66, 111, 116, 104, 32, 100, 105, 114, 101,
+99, 116, 105, 111, 110, 115, 34, 32, 61, 32, 34, 78, 111, 115, 32, 100, 111, 105, 115, 32, 115, 101, 110, 116,
+105, 100, 111, 115, 34, 10, 34, 83, 99, 97, 108, 101, 32, 97, 116, 32, 116, 104, 101, 32, 115, 116, 97, 114,
+116, 34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 32, 110, 111, 32, 105, 110, 195, 173, 99, 105, 111, 34,
+10, 34, 83, 99, 97, 108, 101, 32, 97, 116, 32, 116, 104, 101, 32, 101, 110, 100, 34, 32, 61, 32, 34, 69,
+115, 99, 97, 108, 97, 32, 110, 111, 32, 102, 105, 109, 34, 10, 34, 79, 102, 102, 115, 101, 116, 34, 32, 61,
+32, 34, 68, 101, 115, 108, 111, 99, 97, 109, 101, 110, 116, 111, 34, 10, 34, 76, 111, 119, 101, 115, 116, 32,
+110, 111, 116, 101, 34, 32, 61, 32, 34, 78, 111, 116, 97, 32, 109, 97, 105, 115, 32, 103, 114, 97, 118, 101,
+34, 10, 34, 72, 105, 103, 104, 101, 115, 116, 32, 110, 111, 116, 101, 34, 32, 61, 32, 34, 78, 111, 116, 97,
+32, 109, 97, 105, 115, 32, 97, 103, 117, 100, 97, 34, 10, 34, 76, 111, 119, 101, 115, 116, 32, 118, 101, 108,
+111, 99, 105, 116, 121, 34, 32, 61, 32, 34, 77, 101, 110, 111, 114, 32, 118, 101, 108, 111, 99, 105, 116, 121,
+34, 10, 34, 72, 105, 103, 104, 101, 115, 116, 32, 118, 101, 108, 111, 99, 105, 116, 121, 34, 32, 61, 32, 34,
+77, 97, 105, 111, 114, 32, 118, 101, 108, 111, 99, 105, 116, 121, 34, 10, 34, 82, 101, 115, 101, 116, 34, 32,
+61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 34, 10, 34, 78, 101, 119, 32, 118, 97, 114, 105, 97,
+116, 105, 111, 110, 34, 32, 61, 32, 34, 78, 111, 118, 97, 32, 118, 97, 114, 105, 97, 195, 167, 195, 163, 111,
+34, 10, 34, 83, 116, 114, 117, 109, 34, 32, 61, 32, 34, 68, 101, 100, 105, 108, 104, 97, 114, 32, 40, 115,
+116, 114, 117, 109, 41, 34, 10, 34, 65, 114, 112, 101, 103, 103, 105, 97, 116, 101, 34, 32, 61, 32, 34, 65,
+114, 112, 101, 106, 97, 114, 34, 10, 34, 70, 108, 105, 112, 34, 32, 61, 32, 34, 69, 115, 112, 101, 108, 104,
+97, 114, 34, 10, 34, 82, 97, 110, 100, 111, 109, 105, 115, 101, 34, 32, 61, 32, 34, 65, 108, 101, 97, 116,
+111, 114, 105, 122, 97, 114, 34, 10, 34, 83, 99, 97, 108, 101, 32, 108, 101, 118, 101, 108, 115, 34, 32, 61,
+32, 34, 69, 115, 99, 97, 108, 97, 114, 32, 110, 195, 173, 118, 101, 105, 115, 34, 10, 34, 76, 105, 109, 105,
+116, 34, 32, 61, 32, 34, 76, 105, 109, 105, 116, 97, 114, 34, 10, 34, 84, 111, 111, 108, 115, 34, 32, 61,
+32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 115, 34, 10, 34, 84, 97, 108, 108, 101, 114, 32, 107,
+101, 121, 115, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 115, 32, 109, 97, 105, 115, 32, 97, 108, 116, 97,
+115, 34, 10, 34, 83, 104, 111, 114, 116, 101, 114, 32, 107, 101, 121, 115, 34, 32, 61, 32, 34, 84, 101, 99,
+108, 97, 115, 32, 109, 97, 105, 115, 32, 98, 97, 105, 120, 97, 115, 34, 10, 34, 83, 110, 97, 112, 32, 110,
+111, 116, 101, 115, 32, 116, 111, 32, 116, 104, 101, 32, 115, 99, 97, 108, 101, 34, 32, 61, 32, 34, 69, 110,
+99, 97, 105, 120, 97, 114, 32, 110, 111, 116, 97, 115, 32, 110, 97, 32, 101, 115, 99, 97, 108, 97, 34, 10,
+34, 77, 111, 118, 101, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 32, 111, 110, 116, 111, 32, 116, 104, 101,
+32, 115, 99, 97, 108, 101, 34, 32, 61, 32, 34, 77, 111, 118, 101, 114, 32, 97, 115, 32, 110, 111, 116, 97,
+115, 32, 112, 97, 114, 97, 32, 97, 32, 101, 115, 99, 97, 108, 97, 34, 10, 34, 82, 105, 112, 112, 108, 101,
+34, 32, 61, 32, 34, 82, 105, 112, 112, 108, 101, 34, 10, 34, 82, 105, 112, 112, 108, 101, 32, 101, 100, 105,
+116, 105, 110, 103, 32, 40, 114, 101, 115, 105, 122, 105, 110, 103, 32, 97, 110, 100, 32, 100, 101, 108, 101, 116,
+105, 110, 103, 32, 109, 111, 118, 101, 32, 116, 104, 101, 32, 108, 97, 116, 101, 114, 32, 99, 108, 105, 112, 115,
+41, 34, 32, 61, 32, 34, 69, 100, 105, 195, 167, 195, 163, 111, 32, 114, 105, 112, 112, 108, 101, 32, 40, 114,
+101, 100, 105, 109, 101, 110, 115, 105, 111, 110, 97, 114, 32, 101, 32, 97, 112, 97, 103, 97, 114, 32, 109, 111,
+118, 101, 109, 32, 111, 115, 32, 99, 108, 105, 112, 101, 115, 32, 115, 101, 103, 117, 105, 110, 116, 101, 115, 41,
+34, 10, 34, 84, 121, 112, 101, 32, 116, 111, 32, 102, 105, 108, 116, 101, 114, 32, 40, 101, 46, 103, 46, 32,
+114, 101, 118, 101, 114, 98, 44, 32, 115, 121, 110, 116, 104, 32, 79, 82, 32, 98, 97, 115, 115, 44, 32, 45,
+100, 101, 108, 97, 121, 41, 34, 32, 61, 32, 34, 68, 105, 103, 105, 116, 101, 32, 112, 97, 114, 97, 32, 102,
+105, 108, 116, 114, 97, 114, 32, 40, 101, 120, 46, 58, 32, 114, 101, 118, 101, 114, 98, 44, 32, 115, 121, 110,
+116, 104, 32, 79, 82, 32, 98, 97, 115, 115, 44, 32, 45, 100, 101, 108, 97, 121, 41, 34, 10, 34, 73, 110,
+115, 116, 114, 117, 109, 101, 110, 116, 115, 58, 32, 110, 101, 119, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32,
+61, 32, 34, 73, 110, 115, 116, 114, 117, 109, 101, 110, 116, 111, 115, 58, 32, 110, 111, 118, 111, 32, 99, 97,
+110, 97, 108, 34, 10, 34, 69, 102, 102, 101, 99, 116, 115, 58, 32, 105, 110, 116, 111, 32, 116, 104, 101, 32,
+115, 101, 108, 101, 99, 116, 101, 100, 32, 105, 110, 115, 101, 114, 116, 34, 32, 61, 32, 34, 69, 102, 101, 105,
+116, 111, 115, 58, 32, 110, 111, 32, 105, 110, 115, 101, 114, 116, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97,
+100, 111, 34, 10, 34, 69, 110, 116, 101, 114, 32, 97, 100, 100, 115, 32, 116, 104, 101, 32, 104, 105, 103, 104,
+108, 105, 103, 104, 116, 101, 100, 32, 105, 116, 101, 109, 44, 32, 85, 112, 47, 68, 111, 119, 110, 32, 109, 111,
+118, 101, 44, 32, 84, 97, 98, 32, 115, 119, 105, 116, 99, 104, 101, 115, 32, 108, 105, 115, 116, 115, 44, 32,
+69, 115, 99, 32, 99, 108, 111, 115, 101, 115, 34, 32, 61, 32, 34, 69, 110, 116, 101, 114, 32, 97, 100, 105,
+99, 105, 111, 110, 97, 32, 111, 32, 105, 116, 101, 109, 32, 100, 101, 115, 116, 97, 99, 97, 100, 111, 44, 32,
+67, 105, 109, 97, 47, 66, 97, 105, 120, 111, 32, 109, 111, 118, 101, 109, 44, 32, 84, 97, 98, 32, 116, 114,
+111, 99, 97, 32, 100, 101, 32, 108, 105, 115, 116, 97, 44, 32, 69, 115, 99, 32, 102, 101, 99, 104, 97, 34,
+10, 34, 98, 117, 105, 108, 116, 45, 105, 110, 34, 32, 61, 32, 34, 110, 97, 116, 105, 118, 111, 34, 10, 34,
+80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 119, 104, 101, 110, 32, 105, 116, 32, 104, 97, 115, 32, 112,
+105, 97, 110, 111, 45, 114, 111, 108, 108, 32, 110, 111, 116, 101, 115, 44, 32, 101, 108, 115, 101, 32, 67, 104,
+97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 32, 61, 32, 34, 80, 105, 97, 110, 111, 32, 82, 111, 108,
+108, 32, 113, 117, 97, 110, 100, 111, 32, 116, 101, 109, 32, 110, 111, 116, 97, 115, 32, 100, 101, 32, 80, 105,
+97, 110, 111, 32, 82, 111, 108, 108, 44, 32, 115, 101, 110, 195, 163, 111, 32, 67, 104, 97, 110, 110, 101, 108,
+32, 82, 97, 99, 107, 34, 10, 34, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 32, 61, 32,
+34, 67, 104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 34, 10, 34, 68, 111, 117, 98, 108, 101, 45, 99,
+108, 105, 99, 107, 32, 111, 110, 32, 97, 32, 112, 97, 116, 116, 101, 114, 110, 32, 99, 108, 105, 112, 32, 111,
+112, 101, 110, 115, 34, 32, 61, 32, 34, 68, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 110, 117,
+109, 32, 99, 108, 105, 112, 101, 32, 100, 101, 32, 112, 97, 116, 116, 101, 114, 110, 32, 97, 98, 114, 101, 34,
+10, 34, 85, 110, 109, 117, 116, 101, 34, 32, 61, 32, 34, 84, 105, 114, 97, 114, 32, 100, 111, 32, 109, 117,
+100, 111, 34, 10, 34, 83, 111, 108, 111, 32, 40, 109, 117, 116, 101, 32, 116, 104, 101, 32, 111, 116, 104, 101,
+114, 32, 116, 114, 97, 99, 107, 115, 41, 34, 32, 61, 32, 34, 83, 111, 108, 111, 32, 40, 115, 105, 108, 101,
+110, 99, 105, 97, 32, 97, 115, 32, 111, 117, 116, 114, 97, 115, 32, 102, 97, 105, 120, 97, 115, 41, 34, 10,
+34, 73, 110, 115, 101, 114, 116, 32, 97, 32, 116, 114, 97, 99, 107, 32, 97, 98, 111, 118, 101, 34, 32, 61,
+32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 117, 109, 97, 32, 102, 97, 105, 120, 97, 32, 97, 99, 105, 109,
+97, 34, 10, 34, 73, 110, 115, 101, 114, 116, 32, 97, 32, 116, 114, 97, 99, 107, 32, 98, 101, 108, 111, 119,
+34, 32, 61, 32, 34, 73, 110, 115, 101, 114, 105, 114, 32, 117, 109, 97, 32, 102, 97, 105, 120, 97, 32, 97,
+98, 97, 105, 120, 111, 34, 10, 34, 68, 101, 108, 101, 116, 101, 32, 116, 104, 101, 32, 116, 114, 97, 99, 107,
+32, 97, 110, 100, 32, 105, 116, 115, 32, 99, 108, 105, 112, 115, 34, 32, 61, 32, 34, 65, 112, 97, 103, 97,
+114, 32, 97, 32, 102, 97, 105, 120, 97, 32, 101, 32, 115, 101, 117, 115, 32, 99, 108, 105, 112, 101, 115, 34,
+10, 34, 79, 112, 101, 110, 32, 105, 110, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 32, 61, 32,
+34, 65, 98, 114, 105, 114, 32, 110, 111, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 34, 10, 34, 76,
+89, 78, 88, 32, 99, 97, 110, 39, 116, 32, 98, 117, 105, 108, 100, 32, 97, 110, 32, 101, 102, 102, 101, 99,
+116, 32, 102, 114, 111, 109, 32, 116, 104, 105, 115, 32, 112, 114, 101, 115, 101, 116, 46, 34, 32, 61, 32, 34,
+79, 32, 76, 89, 78, 88, 32, 110, 195, 163, 111, 32, 99, 111, 110, 115, 101, 103, 117, 101, 32, 109, 111, 110,
+116, 97, 114, 32, 117, 109, 32, 101, 102, 101, 105, 116, 111, 32, 97, 32, 112, 97, 114, 116, 105, 114, 32, 100,
+101, 115, 116, 101, 32, 112, 114, 101, 115, 101, 116, 46, 34, 10, 34, 83, 116, 111, 114, 101, 32, 116, 104, 101,
+32, 99, 117, 114, 114, 101, 110, 116, 32, 115, 101, 116, 116, 105, 110, 103, 115, 32, 97, 115, 32, 66, 34, 32,
+61, 32, 34, 71, 117, 97, 114, 100, 97, 114, 32, 111, 115, 32, 97, 106, 117, 115, 116, 101, 115, 32, 97, 116,
+117, 97, 105, 115, 32, 99, 111, 109, 111, 32, 66, 34, 10, 34, 83, 119, 97, 112, 32, 119, 105, 116, 104, 32,
+66, 34, 32, 61, 32, 34, 84, 114, 111, 99, 97, 114, 32, 99, 111, 109, 32, 66, 34, 10, 34, 70, 111, 114,
+103, 101, 116, 32, 66, 34, 32, 61, 32, 34, 69, 115, 113, 117, 101, 99, 101, 114, 32, 66, 34, 10, 34, 65,
+47, 66, 32, 99, 111, 109, 112, 97, 114, 101, 32, 40, 66, 32, 115, 116, 111, 114, 101, 100, 41, 34, 32, 61,
+32, 34, 67, 111, 109, 112, 97, 114, 97, 114, 32, 65, 47, 66, 32, 40, 66, 32, 103, 117, 97, 114, 100, 97,
+100, 111, 41, 34, 10, 34, 65, 47, 66, 32, 99, 111, 109, 112, 97, 114, 101, 34, 32, 61, 32, 34, 67, 111,
+109, 112, 97, 114, 97, 114, 32, 65, 47, 66, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 58, 32,
+119, 97, 105, 116, 105, 110, 103, 32, 102, 111, 114, 32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 110, 111,
+116, 101, 32, 40, 83, 112, 97, 99, 101, 32, 99, 97, 110, 99, 101, 108, 115, 41, 34, 32, 61, 32, 34, 71,
+114, 97, 118, 97, 195, 167, 195, 163, 111, 58, 32, 101, 115, 112, 101, 114, 97, 110, 100, 111, 32, 97, 32, 112,
+114, 105, 109, 101, 105, 114, 97, 32, 110, 111, 116, 97, 32, 40, 69, 115, 112, 97, 195, 167, 111, 32, 99, 97,
+110, 99, 101, 108, 97, 41, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 58, 32, 99, 111, 117, 110,
+116, 45, 105, 110, 46, 46, 46, 34, 32, 61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 58, 32,
+99, 111, 110, 116, 97, 103, 101, 109, 46, 46, 46, 34, 10, 10, 35, 32, 45, 45, 45, 32, 83, 116, 97, 114,
+116, 45, 117, 112, 58, 32, 115, 112, 108, 97, 115, 104, 32, 115, 99, 114, 101, 101, 110, 32, 97, 110, 100, 32,
+115, 111, 117, 110, 100, 10, 34, 83, 116, 97, 114, 116, 105, 110, 103, 32, 116, 104, 101, 32, 97, 117, 100, 105,
+111, 32, 101, 110, 103, 105, 110, 101, 46, 46, 46, 34, 32, 61, 32, 34, 73, 110, 105, 99, 105, 97, 110, 100,
+111, 32, 111, 32, 109, 111, 116, 111, 114, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 46, 46, 46, 34, 10,
+34, 76, 111, 97, 100, 105, 110, 103, 32, 116, 104, 101, 32, 119, 111, 114, 107, 115, 112, 97, 99, 101, 46, 46,
+46, 34, 32, 61, 32, 34, 67, 97, 114, 114, 101, 103, 97, 110, 100, 111, 32, 97, 32, 195, 161, 114, 101, 97,
+32, 100, 101, 32, 116, 114, 97, 98, 97, 108, 104, 111, 46, 46, 46, 34, 10, 34, 68, 105, 103, 105, 116, 97,
+108, 32, 97, 117, 100, 105, 111, 32, 119, 111, 114, 107, 115, 116, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34,
+69, 115, 116, 97, 195, 167, 195, 163, 111, 32, 100, 101, 32, 116, 114, 97, 98, 97, 108, 104, 111, 32, 100, 101,
+32, 195, 161, 117, 100, 105, 111, 32, 100, 105, 103, 105, 116, 97, 108, 34, 10, 34, 86, 101, 114, 115, 105, 111,
+110, 32, 123, 48, 125, 34, 32, 61, 32, 34, 86, 101, 114, 115, 195, 163, 111, 32, 123, 48, 125, 34, 10, 34,
+83, 104, 111, 119, 32, 116, 104, 101, 32, 115, 112, 108, 97, 115, 104, 32, 115, 99, 114, 101, 101, 110, 32, 97,
+116, 32, 115, 116, 97, 114, 116, 117, 112, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 97, 32,
+116, 101, 108, 97, 32, 100, 101, 32, 97, 98, 101, 114, 116, 117, 114, 97, 32, 97, 111, 32, 105, 110, 105, 99,
+105, 97, 114, 34, 10, 34, 80, 108, 97, 121, 32, 116, 104, 101, 32, 115, 116, 97, 114, 116, 117, 112, 32, 115,
+111, 117, 110, 100, 34, 32, 61, 32, 34, 84, 111, 99, 97, 114, 32, 111, 32, 115, 111, 109, 32, 100, 101, 32,
+97, 98, 101, 114, 116, 117, 114, 97, 34, 10, 10, 35, 32, 45, 45, 45, 32, 76, 97, 121, 111, 117, 116, 58,
+32, 109, 97, 105, 110, 32, 116, 111, 111, 108, 98, 97, 114, 32, 97, 110, 100, 32, 119, 105, 110, 100, 111, 119,
+32, 116, 105, 116, 108, 101, 32, 98, 97, 114, 115, 10, 34, 80, 108, 117, 103, 105, 110, 32, 112, 105, 99, 107,
+101, 114, 58, 32, 97, 100, 100, 32, 97, 110, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 32, 111, 114,
+32, 112, 108, 117, 103, 105, 110, 32, 97, 115, 32, 97, 32, 110, 101, 119, 32, 99, 104, 97, 110, 110, 101, 108,
+34, 32, 61, 32, 34, 83, 101, 108, 101, 116, 111, 114, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 58,
+32, 97, 100, 105, 99, 105, 111, 110, 97, 32, 117, 109, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 111,
+32, 111, 117, 32, 112, 108, 117, 103, 105, 110, 32, 99, 111, 109, 111, 32, 110, 111, 118, 111, 32, 99, 97, 110,
+97, 108, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111, 112, 116, 105, 111, 110, 115, 58, 32,
+119, 104, 97, 116, 32, 116, 111, 32, 114, 101, 99, 111, 114, 100, 34, 32, 61, 32, 34, 79, 112, 195, 167, 195,
+181, 101, 115, 32, 100, 101, 32, 103, 114, 97, 118, 97, 195, 167, 195, 163, 111, 58, 32, 111, 32, 113, 117, 101,
+32, 103, 114, 97, 118, 97, 114, 34, 10, 34, 83, 119, 105, 110, 103, 32, 111, 102, 32, 116, 104, 101, 32, 67,
+104, 97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 40, 97, 108, 108, 32, 99, 104, 97, 110, 110, 101, 108,
+115, 41, 34, 32, 61, 32, 34, 83, 119, 105, 110, 103, 32, 100, 111, 32, 67, 104, 97, 110, 110, 101, 108, 32,
+82, 97, 99, 107, 32, 40, 116, 111, 100, 111, 115, 32, 111, 115, 32, 99, 97, 110, 97, 105, 115, 41, 34, 10,
+34, 66, 65, 82, 32, 58, 32, 66, 69, 65, 84, 32, 58, 32, 83, 84, 69, 80, 34, 32, 61, 32, 34, 67,
+79, 77, 80, 32, 58, 32, 84, 69, 77, 80, 79, 32, 58, 32, 83, 84, 69, 80, 34, 10, 34, 87, 105, 110,
+100, 111, 119, 32, 111, 112, 116, 105, 111, 110, 115, 58, 32, 100, 101, 116, 97, 99, 104, 44, 32, 109, 97, 120,
+105, 109, 105, 122, 101, 44, 32, 99, 108, 111, 115, 101, 32, 97, 110, 100, 32, 116, 104, 105, 115, 32, 112, 97,
+110, 101, 108, 39, 115, 32, 111, 119, 110, 32, 115, 101, 116, 116, 105, 110, 103, 115, 34, 32, 61, 32, 34, 79,
+112, 195, 167, 195, 181, 101, 115, 32, 100, 97, 32, 106, 97, 110, 101, 108, 97, 58, 32, 100, 101, 115, 116, 97,
+99, 97, 114, 44, 32, 109, 97, 120, 105, 109, 105, 122, 97, 114, 44, 32, 102, 101, 99, 104, 97, 114, 32, 101,
+32, 111, 115, 32, 97, 106, 117, 115, 116, 101, 115, 32, 100, 101, 115, 116, 101, 32, 112, 97, 105, 110, 101, 108,
+34, 10, 34, 68, 101, 116, 97, 99, 104, 101, 100, 32, 40, 111, 119, 110, 32, 119, 105, 110, 100, 111, 119, 41,
+34, 32, 61, 32, 34, 68, 101, 115, 116, 97, 99, 97, 100, 97, 32, 40, 106, 97, 110, 101, 108, 97, 32, 112,
+114, 195, 179, 112, 114, 105, 97, 41, 34, 10, 34, 77, 97, 120, 105, 109, 105, 122, 101, 100, 34, 32, 61, 32,
+34, 77, 97, 120, 105, 109, 105, 122, 97, 100, 97, 34, 10, 34, 67, 108, 111, 115, 101, 34, 32, 61, 32, 34,
+70, 101, 99, 104, 97, 114, 34, 10, 10, 35, 32, 45, 45, 45, 32, 87, 111, 114, 107, 102, 108, 111, 119, 32,
+80, 50, 32, 105, 110, 32, 116, 104, 101, 32, 109, 97, 105, 110, 32, 116, 111, 111, 108, 98, 97, 114, 10, 34,
+67, 111, 117, 110, 116, 45, 105, 110, 32, 98, 101, 102, 111, 114, 101, 32, 114, 101, 99, 111, 114, 100, 105, 110,
+103, 58, 32, 123, 48, 125, 32, 98, 97, 114, 40, 115, 41, 34, 32, 61, 32, 34, 67, 111, 110, 116, 97, 103,
+101, 109, 32, 97, 110, 116, 101, 115, 32, 100, 101, 32, 103, 114, 97, 118, 97, 114, 58, 32, 123, 48, 125, 32,
+99, 111, 109, 112, 97, 115, 115, 111, 40, 115, 41, 34, 10, 34, 67, 111, 117, 110, 116, 45, 105, 110, 32, 98,
+101, 102, 111, 114, 101, 32, 114, 101, 99, 111, 114, 100, 105, 110, 103, 58, 32, 111, 102, 102, 34, 32, 61, 32,
+34, 67, 111, 110, 116, 97, 103, 101, 109, 32, 97, 110, 116, 101, 115, 32, 100, 101, 32, 103, 114, 97, 118, 97,
+114, 58, 32, 100, 101, 115, 108, 105, 103, 97, 100, 97, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103,
+32, 119, 97, 105, 116, 115, 32, 102, 111, 114, 32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 110, 111, 116,
+101, 58, 32, 111, 110, 34, 32, 61, 32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32, 101, 115, 112,
+101, 114, 97, 32, 97, 32, 112, 114, 105, 109, 101, 105, 114, 97, 32, 110, 111, 116, 97, 58, 32, 108, 105, 103,
+97, 100, 97, 34, 10, 34, 82, 101, 99, 111, 114, 100, 105, 110, 103, 32, 119, 97, 105, 116, 115, 32, 102, 111,
+114, 32, 116, 104, 101, 32, 102, 105, 114, 115, 116, 32, 110, 111, 116, 101, 58, 32, 111, 102, 102, 34, 32, 61,
+32, 34, 71, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32, 101, 115, 112, 101, 114, 97, 32, 97, 32, 112, 114,
+105, 109, 101, 105, 114, 97, 32, 110, 111, 116, 97, 58, 32, 100, 101, 115, 108, 105, 103, 97, 100, 97, 34, 10,
+34, 83, 110, 97, 112, 32, 110, 111, 116, 101, 115, 32, 116, 111, 32, 116, 104, 101, 32, 115, 99, 97, 108, 101,
+58, 32, 110, 101, 119, 32, 97, 110, 100, 32, 109, 111, 118, 101, 100, 32, 110, 111, 116, 101, 115, 44, 32, 97,
+110, 100, 32, 105, 110, 99, 111, 109, 105, 110, 103, 32, 77, 73, 68, 73, 44, 32, 108, 97, 110, 100, 32, 111,
+110, 32, 116, 104, 101, 32, 99, 104, 111, 115, 101, 110, 32, 115, 99, 97, 108, 101, 34, 32, 61, 32, 34, 69,
+110, 99, 97, 105, 120, 97, 114, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 110, 97, 32, 101, 115, 99, 97,
+108, 97, 58, 32, 110, 111, 116, 97, 115, 32, 110, 111, 118, 97, 115, 32, 101, 32, 109, 111, 118, 105, 100, 97,
+115, 44, 32, 101, 32, 111, 32, 77, 73, 68, 73, 32, 113, 117, 101, 32, 99, 104, 101, 103, 97, 44, 32, 99,
+97, 101, 109, 32, 110, 97, 32, 101, 115, 99, 97, 108, 97, 32, 101, 115, 99, 111, 108, 104, 105, 100, 97, 34,
+10,
 };
 } // namespace lynx::i18n::data

+ 20 - 0
src/ui/Icons.cpp

@@ -459,6 +459,26 @@ Shape make (Icon icon)
             line (st, 12.0f, 17.0f, 12.0f, 20.5f);
             line (st, 8.5f, 20.5f, 15.5f, 20.5f);
             break;
+        case Icon::countIn: // a stopwatch: dial, crown and a hand, with the first quarter filled
+        {
+            st.addEllipse (4.5f, 6.0f, 15.0f, 15.0f);
+            line (st, 10.0f, 3.0f, 14.0f, 3.0f);
+            line (st, 12.0f, 3.0f, 12.0f, 6.0f);
+            line (st, 12.0f, 13.5f, 12.0f, 9.5f);
+            juce::Path quarter;
+            quarter.startNewSubPath (12.0f, 13.5f);
+            quarter.addCentredArc (12.0f, 13.5f, 5.0f, 5.0f, 0.0f, 0.0f, pi * 0.5f, false);
+            quarter.closeSubPath();
+            fi.addPath (quarter);
+            break;
+        }
+        case Icon::waitInput: // an hourglass: two triangles between two bars, sand in the bottom one
+            line (st, 6.0f, 3.5f, 18.0f, 3.5f);
+            line (st, 6.0f, 20.5f, 18.0f, 20.5f);
+            polyline (st, { { 7.5f, 3.5f }, { 7.5f, 6.5f }, { 12.0f, 12.0f }, { 7.5f, 17.5f }, { 7.5f, 20.5f } });
+            polyline (st, { { 16.5f, 3.5f }, { 16.5f, 6.5f }, { 12.0f, 12.0f }, { 16.5f, 17.5f }, { 16.5f, 20.5f } });
+            polyline (fi, { { 12.0f, 16.0f }, { 15.0f, 19.5f }, { 9.0f, 19.5f } }, true);
+            break;
     }
 
     return s;

+ 3 - 2
src/ui/Icons.h

@@ -20,10 +20,11 @@ enum class Icon
     // workspace and control contract
     detach, dock, restore, keyboard, automate, rightClick, tap,
     brush, knife, zoom, listen, slip, ghost, // editor tools (Piano Roll / Playlist)
-    panelMenu, pluginPicker, mic // window options menu, plugin picker, recording options
+    panelMenu, pluginPicker, mic, // window options menu, plugin picker, recording options
+    countIn, waitInput // recording: count-in and wait for input
 };
 
-constexpr int iconCount = (int) Icon::mic + 1;
+constexpr int iconCount = (int) Icon::waitInput + 1;
 
 namespace icons
 {

+ 331 - 42
src/ui/MainComponent.cpp

@@ -1,4 +1,8 @@
 #include "ui/MainComponent.h"
+
+#include "ui/HistoryPanel.h"
+#include "ui/QuickAddPalette.h"
+#include "ui/ToolWindow.h"
 #include "ui/WindowOwner.h"
 
 #include "engine/PluginSandbox.h"
@@ -102,6 +106,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
       browser (e)
 {
     browser.onOpenProject = [this] (const juce::File& file) { confirmDiscard ([this, file] { openFile (file); }); };
+    browser.onLoadIntoChannel = [this] (const juce::File& file) { return rack.loadSampleIntoSelected (file); };
     if (persistent)
     {
         loadUiSettings();
@@ -124,11 +129,8 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     undoButton.onClick = [this] { engine.undo(); };
     redoButton.setTooltip (withKey (tr ("Redo"), "edit.redo"));
     redoButton.onClick = [this] { engine.redo(); };
-    pluginPickerButton.setTooltip (tr ("Plugin picker: add an instrument or plugin as a new channel"));
-    pluginPickerButton.onClick = [this] {
-        showPanel (Panel::channelRack);
-        rack.showAddChannelMenu();
-    };
+    pluginPickerButton.setTooltip (withKey (tr ("Plugin picker: add an instrument or plugin as a new channel"), "panel.quickAdd"));
+    pluginPickerButton.onClick = [this] { showQuickAdd(); };
 
     // transport: Play toggles play / stop-and-back; Stop returns to the start; double-click Stop = all notes off
     playButton.setTooltip (tr ("Play; pressed again, stops and goes back to where it started") + " (Space; Ctrl+Space pauses)");
@@ -155,6 +157,8 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
             juce::File::getSpecialLocation (juce::File::userMusicDirectory).getChildFile ("LYNX/Recordings").createDirectory();
             juce::File::getSpecialLocation (juce::File::userMusicDirectory).getChildFile ("LYNX/Recordings").startAsProcess();
         });
+        menu.addSeparator();
+        addRecordOptions (menu);
         menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (&recordMenuButton));
     };
 
@@ -190,6 +194,15 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     typingPianoButton.setIconColourWhenOn (theme::colour::accent);
     typingPianoButton.onClick = [this] { setTypingPiano (! typingPiano); };
 
+    // count-in and wait-for-input switches next to the metronome, as in FL's recording panel
+    for (auto* b : { &countInButton, &waitInputButton })
+    {
+        b->setOnColour (theme::colour::bg6);
+        b->setIconColourWhenOn (theme::colour::accent);
+    }
+    countInButton.onClick = [this] { runAction ("record.countIn"); };
+    waitInputButton.onClick = [this] { runAction ("record.waitForInput"); };
+
     for (int i = 0; i < workspace::panelCount; ++i)
     {
         const auto panel = (Panel) i;
@@ -263,15 +276,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     workspace.setContent (Panel::browser, browser, "Browser", Icon::browser);
     workspace.setTitleTooltip (Panel::channelRack, tr ("Shift+wheel here changes the pattern"));
     workspace.setTitleAccessory (Panel::channelRack, &swingSlider, 26); // FL keeps the global swing in the rack's title bar
-    workspace.onPanelMenu = [this] (Panel panel, juce::PopupMenu& menu) {
-        if (panel == Panel::channelRack)
-            menu.addSubMenu (tr ("Pattern"), makePatternMenu());
-        else if (panel == Panel::playlist)
-            menu.addItem (tr ("Maximize or restore the Playlist") + shortcutText ("panel.maximisePlaylist"), [this] {
-                workspace.toggleMaximised (Panel::playlist);
-                refreshPanelButtons();
-            });
-    };
+    workspace.onPanelMenu = [this] (Panel panel, juce::PopupMenu& menu) { addPanelMenuItems (panel, menu); };
     workspace.onFocusChanged = [this] (Panel) { refreshPanelButtons(); };
     workspace.onKeyInDetachedWindow = [this] (const juce::KeyPress& key) { return keyPressed (key); };
     workspace.onTitleWheel = [this] (Panel panel, const juce::MouseEvent& ev, const juce::MouseWheelDetails& wheel) {
@@ -285,6 +290,15 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     workspace.onDefaultLayout = [this] { fitChannelRack (true); };
     workspace.setPersistent (persistent);
     playlist.onOpenPattern = [this] { showPanel (Panel::channelRack); };
+    playlist.onOpenPianoRoll = [this] {
+        // edit a channel that plays in this pattern
+        const auto& song = engine.getSong();
+        const auto& notes = song.patterns[(std::size_t) song.currentPattern].notes;
+        const auto channel = engine.getSelectedChannel();
+        if (! notes.empty() && std::none_of (notes.begin(), notes.end(), [channel] (const Note& n) { return n.channel == channel; }))
+            engine.setSelectedChannel (notes.front().channel);
+        openPianoRoll();
+    };
     picker.onOpenPattern = [this] { showPanel (Panel::channelRack); };
     ui::setHint (pianoRoll, tr ("Piano Roll: click adds a note, drag moves, right-click deletes, Ctrl+drag selects"));
     ui::setHint (playlist, tr ("Playlist: click paints the current pattern, right-click deletes, Ctrl+drag selects"));
@@ -295,7 +309,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     addAndMakeVisible (menuBar);
 
     for (auto* c : std::initializer_list<juce::Component*> { &newButton, &openButton, &saveButton, &exportButton, &undoButton, &redoButton, &playButton, &stopButton,
-                                                             &recordButton, &recordMenuButton, &patternModeButton, &songModeButton, &metronomeButton, &typingPianoButton,
+                                                             &recordButton, &recordMenuButton, &patternModeButton, &songModeButton, &metronomeButton, &typingPianoButton, &countInButton, &waitInputButton,
                                                              &tempoDisplay, &patternBox, &newPatternButton, &patternMenuButton, &pluginPickerButton, &positionLabel,
                                                              &cpuLabel, &hintBar, &workspace, &scope })
     {
@@ -311,18 +325,19 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
     }
 
     for (auto* b : std::initializer_list<juce::Component*> { &newButton, &openButton, &saveButton, &exportButton, &undoButton, &redoButton, &playButton, &stopButton,
-                                                             &recordButton, &recordMenuButton, &patternModeButton, &songModeButton, &metronomeButton, &typingPianoButton,
+                                                             &recordButton, &recordMenuButton, &patternModeButton, &songModeButton, &metronomeButton, &typingPianoButton, &countInButton, &waitInputButton,
                                                              &newPatternButton, &patternMenuButton, &pluginPickerButton })
         b->setWantsKeyboardFocus (false);
 
     for (auto* b : { &newButton, &openButton, &saveButton, &exportButton, &undoButton, &redoButton, &recordMenuButton, &newPatternButton, &patternMenuButton,
-                     &pluginPickerButton, &metronomeButton, &typingPianoButton })
+                     &pluginPickerButton, &metronomeButton, &typingPianoButton, &countInButton, &waitInputButton })
         b->setFlat (true);
 
     ui::installSliderContract();
     addAndMakeVisible (gridBox); // global grid (editors)
     engine.addChangeListener (this);
     setTypingPiano (typingPiano);
+    refreshRecordOptionButtons();
     refreshToolbar();
     refreshPanelButtons();
 
@@ -342,6 +357,7 @@ MainComponent::~MainComponent()
     ParametricEqWindows::closeAll();
     closeAutomationEditors();
     closeChannelSettings();
+    closeAllToolWindows(); // note tools, history, quick-add (they edit the song)
     engine.removeChangeListener (this);
     stopTimer();
 }
@@ -404,7 +420,7 @@ void MainComponent::resized()
 
     const auto modeWidth = juce::jmax (patternModeButton.getIdealWidth (h - 2), songModeButton.getIdealWidth (h - 2));
     const auto transportWidth = modeWidth + 8 + 3 * (big + 4) + 4 + 96 + 6 + 116;
-    const auto recordWidth = 2 * h + 2;
+    const auto recordWidth = 3 * h + 4;
     const auto snapWidth = 20 + 4 + 172;
     const auto shortcutsWidth = 6 * h;
     const auto monitorWidth = 150;
@@ -474,17 +490,19 @@ void MainComponent::resized()
         put (positionLabel, positionArea.withTrimmedBottom (13).withTrimmedTop (2));
     }
 
-    // 3. recording options: metronome and typing piano over "what to record"
+    // 3. recording options: metronome, count-in and wait for input over "what to record" and typing piano
     if (showRecord)
     {
         divide();
         auto panel = take (recordWidth);
         put (metronomeButton, juce::Rectangle<int> (panel.getX(), row1, h, h));
-        put (typingPianoButton, juce::Rectangle<int> (panel.getX() + h + 2, row1, h, h));
+        put (countInButton, juce::Rectangle<int> (panel.getX() + h + 2, row1, h, h));
+        put (waitInputButton, juce::Rectangle<int> (panel.getX() + 2 * (h + 2), row1, h, h));
         put (recordMenuButton, juce::Rectangle<int> (panel.getX(), row2, h, h));
+        put (typingPianoButton, juce::Rectangle<int> (panel.getX() + h + 2, row2, h, h));
     }
     else
-        hide ({ &metronomeButton, &typingPianoButton, &recordMenuButton });
+        hide ({ &metronomeButton, &typingPianoButton, &recordMenuButton, &countInButton, &waitInputButton });
 
     // 4. global snap over the pattern selector
     if (showSnap)
@@ -618,6 +636,48 @@ bool MainComponent::runAction (const std::string& id)
     else if (is ("pattern.nextEmpty")) nextEmptyPattern();
     else if (is ("pattern.rename")) showRenamePattern (engine.getSong().currentPattern);
     else if (is ("pattern.insert")) insertPatternHere();
+    else if (is ("pattern.clone")) clonePatternNow();
+    else if (is ("pattern.moveUp")) movePatternNow (-1);
+    else if (is ("pattern.moveDown")) movePatternNow (1);
+    else if (id.rfind ("pattern.select", 0) == 0) selectPattern (std::stoi (id.substr (14)) - 1);
+    else if (is ("panel.quickAdd")) showQuickAdd();
+    else if (is ("edit.history")) showHistory();
+    else if (is ("browser.search"))
+    {
+        showPanel (Panel::browser);
+        browser.focusSearch();
+    }
+    else if (is ("transport.record")) engine.setRecording (! engine.isRecording());
+    else if (is ("transport.metronome"))
+    {
+        engine.getTransport().metronome.store (! engine.getTransport().metronome.load());
+        refreshModeButton();
+    }
+    else if (is ("record.countIn"))
+    {
+        auto o = engine.getRecordOptions();
+        o.countInBars = o.countInBars > 0 ? 0 : 1;
+        engine.setRecordOptions (o);
+        refreshRecordOptionButtons();
+    }
+    else if (is ("record.waitForInput"))
+    {
+        auto o = engine.getRecordOptions();
+        o.waitForInput = ! o.waitForInput;
+        engine.setRecordOptions (o);
+        refreshRecordOptionButtons();
+    }
+    else if (is ("rack.graphEditor")) rack.toggleGraphLanes();
+    else if (is ("rack.rotateLeft")) rack.rotateSelected (-1);
+    else if (is ("rack.rotateRight")) rack.rotateSelected (1);
+    else if (is ("browser.previous")) browser.step (-1, false);
+    else if (is ("browser.next")) browser.step (1, false);
+    else if (is ("browser.swapPrevious")) browser.step (-1, true);
+    else if (is ("browser.swapNext")) browser.step (1, true);
+    else if (is ("browser.load")) browser.loadSelected();
+    else if (id.rfind ("pianoRoll.", 0) == 0) return pianoRoll.runAction (id);
+    else if (id.rfind ("playlist.", 0) == 0) return playlist.runAction (id);
+    else if (id.rfind ("mixer.", 0) == 0) return mixer.runAction (id);
     else if (is ("file.new")) newProject();
     else if (is ("file.open")) chooseFileToOpen();
     else if (is ("file.save")) save (false);
@@ -736,6 +796,8 @@ void MainComponent::loadUiSettings()
             typingPiano = on;
         else if (key == "keepEditorsOpen")
             ChannelRackComponent::keepEditorsOpen = on;
+        else if (key == "editPatternsIn")
+            PlaylistComponent::editPatternsIn = juce::jlimit (0, 2, line.fromFirstOccurrenceOf ("=", false, false).trim().getIntValue());
     }
 
     startup = StartupOptions::load();
@@ -747,7 +809,8 @@ void MainComponent::saveUiSettings()
         return;
 
     uiSettingsFile().replaceWithText ("typingPiano=" + juce::String (typingPiano ? 1 : 0) + "\nkeepEditorsOpen="
-                                      + juce::String (ChannelRackComponent::keepEditorsOpen ? 1 : 0) + "\nsplash=" + juce::String (startup.splash ? 1 : 0)
+                                      + juce::String (ChannelRackComponent::keepEditorsOpen ? 1 : 0) + "\neditPatternsIn="
+                                      + juce::String (PlaylistComponent::editPatternsIn) + "\nsplash=" + juce::String (startup.splash ? 1 : 0)
                                       + "\nstartupSound=" + juce::String (startup.sound ? 1 : 0) + "\n");
 }
 
@@ -757,6 +820,12 @@ void MainComponent::playStop()
 {
     auto& transport = engine.getTransport();
 
+    if (engine.isWaitingForInput() || engine.isCountingIn()) // pressed again: cancel
+    {
+        engine.stop();
+        return;
+    }
+
     if (transport.playing.load())
     {
         engine.stop();
@@ -765,18 +834,18 @@ void MainComponent::playStop()
     else
     {
         playStartTicks = transport.positionTicks.load();
-        engine.play();
+        engine.startPlayback();
     }
 }
 
 void MainComponent::playPause()
 {
-    if (engine.getTransport().playing.load())
+    if (engine.getTransport().playing.load() || engine.isWaitingForInput() || engine.isCountingIn())
         engine.stop();
     else
     {
         playStartTicks = engine.getTransport().positionTicks.load();
-        engine.play();
+        engine.startPlayback();
     }
 }
 
@@ -935,6 +1004,208 @@ void MainComponent::insertPatternHere()
     engine.editSong ([] (Song& s) { insertPattern (s, s.currentPattern, newPatternName (s)); });
 }
 
+// --- window menus ------------------------------------------------------------------------------
+
+// Each window's own items, at the top of the menu in its title bar (FL keeps an editor's options in the
+// small menu at the left of its title bar). Items run the key map's actions, so they show their keys.
+void MainComponent::addPanelMenuItems (Panel panel, juce::PopupMenu& menu)
+{
+    auto action = [this] (juce::PopupMenu& m, const char* id, const juce::String& text, bool enabled = true, bool ticked = false) {
+        m.addItem (text + shortcutText (id), enabled, ticked, [this, id] { runAction (id); });
+    };
+    auto zoomMenu = [&action] (const juce::String& prefix) {
+        juce::PopupMenu zoom;
+        const std::pair<const char*, const char*> items[] = {
+            { "zoomIn", TR_NOOP ("Zoom in") }, { "zoomOut", TR_NOOP ("Zoom out") }, { "zoom1", TR_NOOP ("Zoom: one bar") },
+            { "zoom2", TR_NOOP ("Zoom: four bars") }, { "zoom3", TR_NOOP ("Zoom: sixteen bars") },
+            { "zoomAll", TR_NOOP ("Zoom to show everything") }, { "zoomSelection", TR_NOOP ("Zoom to the selection") },
+            { "centrePlayhead", TR_NOOP ("Centre the view on the playhead") }
+        };
+        for (const auto& [id, text] : items)
+            if (const auto* a = keys::findAction ((prefix + id).toStdString())) // the key map holds the id strings
+                action (zoom, a->id, tr (text));
+        return zoom;
+    };
+
+    switch (panel)
+    {
+        case Panel::channelRack:
+        {
+            menu.addSubMenu (tr ("Pattern"), makePatternMenu());
+            menu.addSeparator();
+            action (menu, "rack.graphEditor", tr ("Graph lanes (velocity, pan, pitch...)"), true, rack.areGraphLanesShown());
+            action (menu, "rack.rotateLeft", tr ("Rotate the selected channels' steps left"));
+            action (menu, "rack.rotateRight", tr ("Rotate the selected channels' steps right"));
+            juce::PopupMenu sort;
+            sort.addItem (tr ("By name"), [this] { rack.sortChannels (ChannelSort::name); });
+            sort.addItem (tr ("By color"), [this] { rack.sortChannels (ChannelSort::colour); });
+            sort.addItem (tr ("By mixer insert"), [this] { rack.sortChannels (ChannelSort::insert); });
+            sort.addItem (tr ("By type"), [this] { rack.sortChannels (ChannelSort::type); });
+            menu.addSubMenu (tr ("Sort channels"), sort);
+            menu.addItem (tr ("Select unused channels"), [this] { rack.selectUnused(); });
+            break;
+        }
+        case Panel::playlist:
+            menu.addItem (tr ("Maximize or restore the Playlist") + shortcutText ("panel.maximisePlaylist"), [this] {
+                workspace.toggleMaximised (Panel::playlist);
+                refreshPanelButtons();
+            });
+            menu.addSeparator();
+            action (menu, "playlist.ripple", tr ("Ripple editing (resizing and deleting move the later clips)"), true, playlist.isRippleOn());
+            action (menu, "playlist.rippleDelete", tr ("Delete the selected clips and close the gaps"));
+            menu.addSubMenu (tr ("Zoom"), zoomMenu ("playlist."));
+            break;
+        case Panel::pianoRoll:
+        {
+            juce::PopupMenu tools;
+            for (const auto* id : { "pianoRoll.arpeggiate", "pianoRoll.strum", "pianoRoll.flip", "pianoRoll.randomise",
+                                    "pianoRoll.scaleLevels", "pianoRoll.limit" })
+                if (const auto* a = keys::findAction (id))
+                    action (tools, a->id, tr (a->description));
+            menu.addSubMenu (tr ("Tools"), tools);
+            menu.addSubMenu (tr ("Zoom"), zoomMenu ("pianoRoll."));
+            menu.addItem (tr ("Snap notes to the scale"), pianoRoll.hasScale(), pianoRoll.isScaleSnapOn(),
+                          [this] { pianoRoll.setScaleSnap (! pianoRoll.isScaleSnapOn()); });
+            break;
+        }
+        case Panel::mixer:
+            action (menu, "mixer.moveLeft", tr ("Move the selected inserts left"));
+            action (menu, "mixer.moveRight", tr ("Move the selected inserts right"));
+            menu.addSeparator();
+            action (menu, "mixer.linkChannels", tr ("Link the selected channels to the selected insert"));
+            action (menu, "mixer.linkChannelsFrom", tr ("Link the selected channels to inserts starting from the selected one"));
+            action (menu, "mixer.selectLinkedChannels", tr ("Select the channels linked to the selected insert"));
+            break;
+        case Panel::browser:
+            action (menu, "browser.search", tr ("Search the Browser"));
+            menu.addItem (tr ("Add folder..."), [this] { browser.addUserFolder(); });
+            break;
+        default:
+            break;
+    }
+}
+
+// --- quick-add palette and history -------------------------------------------------------------
+
+void MainComponent::showQuickAdd()
+{
+    QuickAddTargets targets;
+    targets.effectsFirst = workspace.getFocused() == Panel::mixer;
+    targets.addInstrument = [this] (ChannelDef c) {
+        rack.addChannel (std::move (c), true);
+        showPanel (Panel::channelRack);
+    };
+    targets.addEffect = [this] (EffectSlot slot) {
+        if (! mixer.addEffectToSelected (std::move (slot)))
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Quick-add palette"),
+                                                    tr ("The selected insert has no free effect slot."));
+        else
+            showPanel (Panel::mixer);
+    };
+    openToolWindow (makeQuickAddPalette (engine, std::move (targets)), tr ("Quick-add palette"), "quickadd");
+}
+
+std::unique_ptr<juce::Component> MainComponent::makeQuickAddForSnapshot()
+{
+    QuickAddTargets targets;
+    targets.addInstrument = [] (ChannelDef) {};
+    targets.addEffect = [] (EffectSlot) {};
+    return makeQuickAddPalette (engine, std::move (targets));
+}
+
+void MainComponent::showHistory()
+{
+    if (auto* open = findToolWindow ("history"))
+    {
+        open->toFront (true);
+        return;
+    }
+
+    openToolWindow (makeHistoryPanel (engine), tr ("Undo history"), "history");
+}
+
+// --- recording options ---------------------------------------------------------------------------
+
+void MainComponent::updateRecordQuantise()
+{
+    // the global grid sets the record quantise; "none" and the zoom-dependent grids record as played
+    std::int64_t ticks = 0;
+
+    if (recordQuantiseOn)
+    {
+        const auto& option = grid::options()[(std::size_t) juce::jlimit (0, (int) grid::options().size() - 1, EditorGlobals::get().getGridOption())];
+        if (option.kind == grid::Kind::ticks)
+            ticks = option.ticks;
+        else if (option.kind == grid::Kind::bar)
+            ticks = (std::int64_t) ppq * juce::jmax (1, engine.getSong().beatsPerBar);
+    }
+
+    if (engine.getRecordOptions().quantise != ticks)
+    {
+        auto o = engine.getRecordOptions();
+        o.quantise = ticks;
+        engine.setRecordOptions (o);
+    }
+}
+
+void MainComponent::addRecordOptions (juce::PopupMenu& menu)
+{
+    const auto o = engine.getRecordOptions();
+    auto set = [this] (std::function<void (AudioEngine::RecordOptions&)> change) {
+        auto options = engine.getRecordOptions();
+        change (options);
+        engine.setRecordOptions (options);
+        refreshRecordOptionButtons();
+    };
+
+    juce::PopupMenu countIn;
+    countIn.addItem (tr ("Off"), true, o.countInBars == 0, [set] { set ([] (AudioEngine::RecordOptions& r) { r.countInBars = 0; }); });
+    for (int bars : { 1, 2, 4 })
+        countIn.addItem (bars == 1 ? tr ("1 bar") : tr ("{0} bars", { juce::String (bars) }), true, o.countInBars == bars,
+                         [set, bars] { set ([bars] (AudioEngine::RecordOptions& r) { r.countInBars = bars; }); });
+    menu.addSubMenu (tr ("Count-in") + shortcutText ("record.countIn"), countIn);
+    menu.addItem (tr ("Wait for the first note to start") + shortcutText ("record.waitForInput"), true, o.waitForInput,
+                  [set] { set ([] (AudioEngine::RecordOptions& r) { r.waitForInput = ! r.waitForInput; }); });
+    menu.addSeparator();
+    menu.addItem (tr ("Overdub: add to the pattern"), true, o.mode == RecordMode::overdub,
+                  [set] { set ([] (AudioEngine::RecordOptions& r) { r.mode = RecordMode::overdub; }); });
+    menu.addItem (tr ("Replace: a recorded channel's old notes are cleared"), true, o.mode == RecordMode::replace,
+                  [set] { set ([] (AudioEngine::RecordOptions& r) { r.mode = RecordMode::replace; }); });
+    menu.addSeparator();
+    menu.addItem (tr ("Quantise recorded notes to the global grid"), true, recordQuantiseOn, [this] {
+        recordQuantiseOn = ! recordQuantiseOn;
+        updateRecordQuantise();
+    });
+    menu.addItem (tr ("Song mode: place a pattern clip where recording starts"), true, o.placeSongClip,
+                  [set] { set ([] (AudioEngine::RecordOptions& r) { r.placeSongClip = ! r.placeSongClip; }); });
+}
+
+void MainComponent::refreshRecordOptionButtons()
+{
+    auto withKey = [this] (const juce::String& text, const char* id) {
+        const auto key = shortcutText (id).trim();
+        return key.isEmpty() ? text : text + " (" + key + ")";
+    };
+    const auto o = engine.getRecordOptions();
+    countInButton.setToggleState (o.countInBars > 0, juce::dontSendNotification);
+    countInButton.setTooltip (withKey (o.countInBars > 0 ? tr ("Count-in before recording: {0} bar(s)", { juce::String (o.countInBars) })
+                                                         : tr ("Count-in before recording: off"),
+                                       "record.countIn"));
+    waitInputButton.setToggleState (o.waitForInput, juce::dontSendNotification);
+    waitInputButton.setTooltip (withKey (o.waitForInput ? tr ("Recording waits for the first note: on") : tr ("Recording waits for the first note: off"),
+                                         "record.waitForInput"));
+}
+
+void MainComponent::clonePatternNow()
+{
+    engine.editSong ([] (Song& s) { clonePattern (s, s.currentPattern); });
+}
+
+void MainComponent::movePatternNow (int delta)
+{
+    engine.editSong ([delta] (Song& s) { movePattern (s, s.currentPattern, delta); });
+}
+
 void MainComponent::splitPatternByChannelNow()
 {
     int created = 0;
@@ -1023,22 +1294,9 @@ juce::PopupMenu MainComponent::makePatternMenu()
     menu.addSubMenu (tr ("Color"), colours);
     menu.addSubMenu (tr ("Length"), lengths);
     menu.addItem (tr ("Insert an empty pattern before this one") + shortcutText ("pattern.insert"), [this] { insertPatternHere(); });
-    menu.addItem (tr ("Clone"), [this, index] {
-        engine.editSong ([index] (Song& s) {
-            auto copy = s.patterns[(std::size_t) index];
-            copy.name += " (copy)";
-            s.patterns.insert (s.patterns.begin() + index + 1, std::move (copy));
-
-            // clips pointing to patterns after the new one shift by one position
-            s.forEachClipList ([index] (std::vector<Clip>& clips) {
-                for (auto& c : clips)
-                    if (c.kind == ClipKind::pattern && c.pattern > index)
-                        ++c.pattern;
-            });
-
-            s.currentPattern = index + 1;
-        });
-    });
+    menu.addItem (tr ("Clone") + shortcutText ("pattern.clone"), [this] { clonePatternNow(); });
+    menu.addItem (tr ("Move up") + shortcutText ("pattern.moveUp"), index > 0, false, [this] { movePatternNow (-1); });
+    menu.addItem (tr ("Move down") + shortcutText ("pattern.moveDown"), index + 1 < (int) song.patterns.size(), false, [this] { movePatternNow (1); });
     menu.addItem (tr ("Split by channel (one new pattern per channel)"), ! pattern.notes.empty(), false, [this] { splitPatternByChannelNow(); });
     juce::PopupMenu signatures;
 
@@ -1348,6 +1606,12 @@ void MainComponent::HintBar::paint (juce::Graphics& g)
 
 juce::String MainComponent::idleHint() const
 {
+    if (engine.isWaitingForInput())
+        return tr ("Recording: waiting for the first note (Space cancels)");
+
+    if (engine.isCountingIn())
+        return tr ("Recording: count-in...");
+
     return tr ("F1 shortcuts   F5-F9 panels   Space play/stop   Ctrl+T typing piano ({0})", { typingPiano ? tr ("on") : tr ("off") });
 }
 
@@ -1390,6 +1654,7 @@ void MainComponent::Scope::paint (juce::Graphics& g)
 void MainComponent::timerCallback()
 {
     scope.update();
+    updateRecordQuantise();
 
     if (engine.isModified() != lastModified)
     {
@@ -1440,6 +1705,8 @@ void MainComponent::timerCallback()
 
         if (engine.isLearningMidi())
             hint.text = tr ("Move a knob/fader on the MIDI controller to link it to the parameter...");
+        else if (engine.isWaitingForInput() || engine.isCountingIn())
+            hint.text = idleHint();
         else if (isShowing())
         {
             const auto source = juce::Desktop::getInstance().getMainMouseSource();
@@ -1705,6 +1972,13 @@ juce::PopupMenu MainComponent::getMenuForIndex (int index, const juce::String&)
     {
         menu.addItem (tr ("Undo") + shortcutText ("edit.undo"), engine.canUndo(), false, [this] { engine.undo(); });
         menu.addItem (tr ("Redo") + shortcutText ("edit.redo"), engine.canRedo(), false, [this] { engine.redo(); });
+        menu.addItem (tr ("Undo history...") + shortcutText ("edit.history"), [this] { showHistory(); });
+        menu.addSeparator();
+        menu.addItem (tr ("Quick-add palette...") + shortcutText ("panel.quickAdd"), [this] { showQuickAdd(); });
+        menu.addItem (tr ("Search the Browser") + shortcutText ("browser.search"), [this] {
+            showPanel (Panel::browser);
+            browser.focusSearch();
+        });
     }
     else if (index == 2)
     {
@@ -1760,9 +2034,24 @@ juce::PopupMenu MainComponent::getMenuForIndex (int index, const juce::String&)
         menu.addItem (tr ("Record input audio"), true, engine.isAudioRecordingArmed(), [this] {
             engine.setAudioRecordingArmed (! engine.isAudioRecordingArmed());
         });
-        menu.addItem (tr ("Metronome"), true, engine.getTransport().metronome.load(), [this] {
+        menu.addItem (tr ("Metronome") + shortcutText ("transport.metronome"), true, engine.getTransport().metronome.load(), [this] {
             metronomeButton.setToggleState (! metronomeButton.getToggleState(), juce::sendNotification);
         });
+        {
+            juce::PopupMenu recording;
+            addRecordOptions (recording);
+            menu.addSubMenu (tr ("Recording"), recording);
+        }
+        {
+            juce::PopupMenu editIn;
+            const char* choices[] = { TR_NOOP ("Piano Roll when it has piano-roll notes, else Channel Rack"), TR_NOOP ("Channel Rack"), TR_NOOP ("Piano Roll") };
+            for (int i = 0; i < 3; ++i)
+                editIn.addItem (tr (choices[i]), true, PlaylistComponent::editPatternsIn == i, [this, i] {
+                    PlaylistComponent::editPatternsIn = i;
+                    saveUiSettings();
+                });
+            menu.addSubMenu (tr ("Double-click on a pattern clip opens"), editIn);
+        }
         menu.addItem (tr ("Keep channel editors open (a channel button click doesn't close the previous editor)"), true,
                       ChannelRackComponent::keepEditorsOpen, [this] {
                           ChannelRackComponent::keepEditorsOpen = ! ChannelRackComponent::keepEditorsOpen;

+ 29 - 0
src/ui/MainComponent.h

@@ -50,11 +50,27 @@ public:
     void waitForBrowserForSnapshot() { browser.waitForListing (5000); }
     juce::StringArray getMenuNamesForSnapshot() { return getMenuBarNames(); }
     juce::PopupMenu getMenuForSnapshot (int index) { return getMenuForIndex (index, {}); }
+    juce::PopupMenu getPanelMenuForSnapshot (workspace::Panel panel)
+    {
+        juce::PopupMenu menu;
+        addPanelMenuItems (panel, menu);
+        return menu;
+    }
+    juce::PopupMenu getRecordMenuForSnapshot()
+    {
+        juce::PopupMenu menu;
+        addRecordOptions (menu);
+        return menu;
+    }
     void setHintForSnapshot (const ui::Hint& hint) { hintBar.setHint (hint); }
     static std::unique_ptr<juce::Component> makeHelpContent();
     static std::unique_ptr<juce::AlertWindow> makeAboutWindow();
     std::unique_ptr<juce::AlertWindow> makeConfirmDiscardWindow();
     PianoRollComponent& getPianoRollForSnapshot() { return pianoRoll; }
+    ChannelRackComponent& getRackForSnapshot() { return rack; }
+    BrowserComponent& getBrowserForSnapshot() { return browser; }
+    MixerComponent& getMixerForSnapshot() { return mixer; }
+    std::unique_ptr<juce::Component> makeQuickAddForSnapshot();
     PlaylistComponent& getPlaylistForSnapshot() { return playlist; }
     void selectMixerTrackForSnapshot (int track, int slot = -1)
     {
@@ -102,6 +118,16 @@ private:
     void nextEmptyPattern();
     void insertPatternHere();
     void splitPatternByChannelNow();
+    void clonePatternNow();
+    void movePatternNow (int delta);
+
+    // workflow P2 windows and menus
+    void showQuickAdd();
+    void addPanelMenuItems (Panel panel, juce::PopupMenu& menu); // a window's own items in its title-bar menu
+    void showHistory();
+    void addRecordOptions (juce::PopupMenu& menu); // count-in, wait, overdub/replace, quantise, song clip
+    void updateRecordQuantise(); // record quantise follows the global grid
+    bool recordQuantiseOn = true;
     void showRenamePattern (int index);
 
     // user settings (UI options)
@@ -150,6 +176,9 @@ private:
     IconButton patternModeButton { "patternMode", Icon::pattern }, songModeButton { "songMode", Icon::song };
     IconButton metronomeButton { "metronome", Icon::metronome };
     IconButton typingPianoButton { "typingPiano", Icon::keyboard };
+    IconButton countInButton { "countIn", Icon::countIn };
+    IconButton waitInputButton { "waitInput", Icon::waitInput };
+    void refreshRecordOptionButtons();
 
     // tempo: a number dragged by its digits (whole BPM or decimals), with tap tempo in its menu
     class TempoDisplay final : public juce::Component,

+ 486 - 14
src/ui/MixerComponent.cpp

@@ -1,7 +1,9 @@
 #include "ui/MixerComponent.h"
 
 #include "core/FlEffects.h"
+#include "core/MixerOps.h"
 #include "ui/AutomationUi.h"
+#include "ui/BrowserComponent.h"
 #include "ui/ExportDialog.h"
 
 #include "core/Effects.h"
@@ -104,6 +106,11 @@ juce::Rectangle<int> MixerStrips::routeArea (int t) const
     return { stripX (t) + 6, getHeight() - feedsHeight - 2, stripWidthOf (t) - 16, 16 };
 }
 
+juce::Rectangle<int> MixerStrips::armArea (int t) const
+{
+    return { stripX (t) + 4, 4, 14, 14 };
+}
+
 juce::Rectangle<int> MixerStrips::faderArea (int t) const
 {
     const auto top = headerHeight + panHeight + buttonsHeight + 8;
@@ -115,6 +122,8 @@ MixerStrips::Part MixerStrips::partAt (int t, juce::Point<int> p) const
     if (t == (int) engine.getSong().mixer.size())
         return Part::add;
 
+    if (t > 0 && armArea (t).contains (p))
+        return Part::arm;
     if (panArea (t).contains (p))
         return Part::pan;
     if (muteArea (t).contains (p))
@@ -148,8 +157,9 @@ void MixerStrips::paint (juce::Graphics& g)
         const auto& track = song.mixer[(std::size_t) t];
         const auto strip = juce::Rectangle<int> (x, 2, w - 4, getHeight() - 4);
         const auto isSelected = t == selected;
+        const auto inSelection = std::binary_search (selection.begin(), selection.end(), t);
 
-        g.setColour (isSelected ? colour::bg4 : (t == 0 ? colour::bg3 : colour::bg2));
+        g.setColour (isSelected || inSelection ? colour::bg4 : (t == 0 ? colour::bg3 : colour::bg2));
         g.fillRoundedRectangle (strip.toFloat(), radius::md);
 
         if (track.colour != 0) // thin colour band at the top
@@ -158,6 +168,12 @@ void MixerStrips::paint (juce::Graphics& g)
             g.fillRoundedRectangle (strip.toFloat().withHeight (3.0f).reduced (6.0f, 0.0f), 1.5f);
         }
 
+        if (inSelection && ! isSelected)
+        {
+            g.setColour (colour::accent.withAlpha (0.3f));
+            g.drawRoundedRectangle (strip.toFloat().reduced (0.5f), radius::md, 1.0f);
+        }
+
         if (isSelected)
         {
             g.setColour (colour::accent.withAlpha (0.55f));
@@ -166,6 +182,17 @@ void MixerStrips::paint (juce::Graphics& g)
             g.fillRoundedRectangle (strip.toFloat().withHeight (3.0f).reduced (6.0f, 0.0f), 1.5f);
         }
 
+        // record arm: the input recording goes through this insert
+        if (t > 0)
+        {
+            const auto armed = engine.isInsertArmed (t);
+            const auto r = armArea (t).toFloat().reduced (2.0f);
+            g.setColour (armed ? colour::record : colour::bg0);
+            g.fillEllipse (r);
+            g.setColour (armed ? colour::record.brighter (0.3f) : colour::borderStrong);
+            g.drawEllipse (r, 1.0f);
+        }
+
         // header: number and name
         g.setColour (isSelected ? colour::accent : colour::textSecondary);
         g.setFont (font (type::caption, isSelected));
@@ -344,6 +371,25 @@ void MixerStrips::mouseDown (const juce::MouseEvent& e)
         return;
     }
 
+    if (part == Part::arm)
+    {
+        engine.setInsertArmed (t, ! engine.isInsertArmed (t));
+        repaint();
+        return;
+    }
+
+    if (part == Part::route && e.mods.isPopupMenu())
+    {
+        showSendMenu (t);
+        return;
+    }
+
+    if (part == Part::mute && (e.mods.isPopupMenu() || e.mods.isCtrlDown())) // solo on the same LED
+    {
+        soloExclusive (t);
+        return;
+    }
+
     if (part == Part::route)
     {
         // the selection is the send source: don't change it
@@ -360,15 +406,30 @@ void MixerStrips::mouseDown (const juce::MouseEvent& e)
         return;
     }
 
-    if (selected != t)
+    if (part == Part::body && ! e.mods.isPopupMenu() && (e.mods.isCtrlDown() || e.mods.isShiftDown()) && t > 0)
     {
-        selected = t;
-        repaint();
+        auto s = selection;
+        if (e.mods.isShiftDown())
+        {
+            s.clear();
+            for (int i = juce::jmin (selected, t); i <= juce::jmax (selected, t); ++i)
+                s.push_back (i);
+        }
+        else if (auto it = std::find (s.begin(), s.end(), t); it != s.end() && s.size() > 1)
+            s.erase (it);
+        else
+            s.push_back (t);
 
-        if (onSelectionChanged)
-            onSelectionChanged (t);
+        setSelection (s, std::find (s.begin(), s.end(), t) != s.end() ? t : s.front());
+        return;
     }
 
+    // a plain click on a track outside the selection selects only it; inside, the group stays
+    if (! std::binary_search (selection.begin(), selection.end(), t))
+        setSelection ({ t }, t);
+    else if (selected != t)
+        setSelection (selection, t);
+
     if (part == Part::pan || part == Part::fader)
     {
         if (e.mods.isPopupMenu())
@@ -421,8 +482,16 @@ void MixerStrips::mouseDown (const juce::MouseEvent& e)
             }
 
             drag.begin (e, dragStartValue);
+            groupStart.clear();
+            groupGrab = part == Part::pan ? track.pan : track.volume;
+            if (selection.size() > 1) // the selected strips follow, keeping their offsets
+                for (auto s : selection)
+                    if (s != t && s < (int) engine.getSong().mixer.size())
+                        groupStart.push_back ({ s, part == Part::pan ? engine.getSong().mixer[(std::size_t) s].pan
+                                                                      : engine.getSong().mixer[(std::size_t) s].volume });
             return;
 
+        case Part::arm:
         case Part::route:
         case Part::body:
         case Part::none:
@@ -479,16 +548,123 @@ void MixerStrips::setValue (Part part, int t, double value)
     if (t < 0 || t >= (int) engine.getSong().mixer.size())
         return;
 
+    // during a drag of a selected strip, the other selected strips move by the same amount
+    const auto delta = (float) value - groupGrab;
+    const auto group = dragTrack == t && dragPart == part ? groupStart : std::vector<std::pair<int, float>> {};
+
     if (part == Part::pan)
-        engine.editSong ([t, v = (float) value] (Song& s) { s.mixer[(std::size_t) t].pan = v; });
+        engine.editSong ([t, v = (float) value, group, delta] (Song& s) {
+            s.mixer[(std::size_t) t].pan = v;
+            for (auto [other, start] : group)
+                if (other < (int) s.mixer.size())
+                    s.mixer[(std::size_t) other].pan = juce::jlimit (-1.0f, 1.0f, start + delta);
+        });
     else if (part == Part::fader)
-        engine.editSong ([t, v = (float) value] (Song& s) { s.mixer[(std::size_t) t].volume = v; });
+        engine.editSong ([t, v = (float) value, group, delta] (Song& s) {
+            s.mixer[(std::size_t) t].volume = v;
+            for (auto [other, start] : group)
+                if (other < (int) s.mixer.size())
+                    s.mixer[(std::size_t) other].volume = juce::jlimit (0.0f, 1.0f, start + delta);
+        });
+}
+
+void MixerStrips::setSelection (std::vector<int> tracks, int primary)
+{
+    const auto count = (int) engine.getSong().mixer.size();
+    tracks.erase (std::remove_if (tracks.begin(), tracks.end(), [count] (int t) { return t < 0 || t >= count; }), tracks.end());
+    primary = juce::jlimit (0, juce::jmax (0, count - 1), primary);
+    tracks.push_back (primary);
+    std::sort (tracks.begin(), tracks.end());
+    tracks.erase (std::unique (tracks.begin(), tracks.end()), tracks.end());
+    selection = tracks;
+    const auto changed = primary != selected;
+    selected = primary;
+    repaint();
+
+    if (changed && onSelectionChanged)
+        onSelectionChanged (selected);
+}
+
+bool MixerStrips::moveSelected (int delta)
+{
+    auto moved = selection;
+    bool ok = false;
+    engine.editSong ([&] (Song& s) { ok = mixerops::moveTracks (s, moved, delta); });
+
+    if (ok)
+        setSelection (moved, juce::jlimit (1, (int) engine.getSong().mixer.size() - 1, selected + (delta < 0 ? -1 : 1)));
+
+    return ok;
+}
+
+void MixerStrips::linkSelectedChannels (bool startingHere)
+{
+    const auto channels = engine.getSelectedChannels();
+    engine.editSong ([channels, t = selected, startingHere] (Song& s) { mixerops::linkChannels (s, channels, t, startingHere); });
+}
+
+void MixerStrips::selectLinkedChannels()
+{
+    const auto channels = mixerops::channelsOn (engine.getSong(), selected);
+
+    if (! channels.empty())
+        engine.setChannelSelection (channels, channels.front());
+}
+
+void MixerStrips::soloExclusive (int t)
+{
+    if (t <= 0)
+        return;
+
+    // solo only this track; again on the only soloed track clears the solo
+    engine.editSong ([t] (Song& s) {
+        const auto alone = s.mixer[(std::size_t) t].solo
+                           && std::none_of (s.mixer.begin() + 1, s.mixer.end(), [&] (const MixerTrack& m) { return &m != &s.mixer[(std::size_t) t] && m.solo; });
+        for (std::size_t i = 1; i < s.mixer.size(); ++i)
+            s.mixer[i].solo = ! alone && (int) i == t;
+    });
+}
+
+void MixerStrips::showSendMenu (int t)
+{
+    const auto& song = engine.getSong();
+    const auto from = selected;
+
+    if (from <= 0 || from == t)
+        return;
+
+    const auto fromName = juce::String::fromUTF8 (song.mixer[(std::size_t) from].name.c_str());
+    juce::PopupMenu menu;
+    menu.addSectionHeader (fromName + juce::String::fromUTF8 (" \xe2\x86\x92 ") + juce::String::fromUTF8 (song.mixer[(std::size_t) t].name.c_str()));
+    const auto on = song.routes (from, t);
+    menu.addItem (on ? tr ("Remove this send") : tr ("Send here"), on || song.canRoute (from, t), false, [this, from, t, on] {
+        engine.editSong ([from, t, on] (Song& s) { s.setRoute (from, t, ! on); });
+    });
+    menu.addItem (tr ("Send only here"), on || song.canRoute (from, t), false, [this, from, t] {
+        engine.editSong ([from, t] (Song& s) { mixerops::routeTo (s, { from }, t, true); });
+    });
+    menu.addItem (tr ("Sidechain only (no audio): the compressors here listen to it"), t > 0 && (on || song.canRoute (from, t)), false, [this, from, t] {
+        int linked = 0;
+        engine.editSong ([from, t, &linked] (Song& s) { linked = mixerops::sidechainTo (s, from, t); });
+        if (linked == 0)
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Sidechain"),
+                                                    tr ("The link was made; add a compressor to this insert to use it."));
+    });
+    menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
 }
 
 void MixerStrips::mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& wheel)
 {
     const auto t = trackAt (e.x);
 
+    if (t > 0 && t < (int) engine.getSong().mixer.size() && e.mods.isShiftDown() && partAt (t, e.getPosition()) == Part::body)
+    {
+        if (! std::binary_search (selection.begin(), selection.end(), t))
+            setSelection ({ t }, t);
+        moveSelected ((wheel.deltaY != 0.0f ? wheel.deltaY : -wheel.deltaX) > 0.0f ? -1 : 1);
+        return;
+    }
+
     if (t >= 0 && t < (int) engine.getSong().mixer.size())
         if (const auto part = partAt (t, e.getPosition()); part == Part::pan || part == Part::fader)
         {
@@ -521,13 +697,14 @@ ui::Hint MixerStrips::hintAt (juce::Point<int> p)
         case Part::pan:
         case Part::fader:
             return ui::valueHint (specFor (part, t), valueOf (part, t), tr ("drag (Ctrl: fine), wheel, Alt+click resets"));
-        case Part::mute: h.text = name + " - " + tr ("Mute"); break;
+        case Part::mute: h.text = name + " - " + tr ("Click: mute.  Right-click or Ctrl+click: solo"); break;
+        case Part::arm: h.text = name + " - " + tr ("Record arm: audio takes from the input play through this insert"); break;
         case Part::solo: h.text = name + " - " + tr ("Solo"); break;
-        case Part::route: h.text = name + " - " + tr ("Send from the selected insert to this one (drag after enabling: level)"); break;
+        case Part::route: h.text = name + " - " + tr ("Send from the selected insert to this one (drag after enabling: level; right-click: sidechain, only here)"); h.hasMenu = true; break;
         case Part::add: h.text = tr ("Add a mixer insert"); break;
         case Part::body:
         case Part::none:
-            h.text = name + " - " + tr ("Click selects the insert, right-click opens its menu");
+            h.text = name + " - " + tr ("Click selects the insert (Ctrl: add, Shift: range), right-click opens its menu; Alt+Left/Right moves the selection");
             h.hasMenu = true;
             break;
     }
@@ -560,6 +737,7 @@ void MixerStrips::mouseDoubleClick (const juce::MouseEvent& e)
 void MixerStrips::selectTrack (int track)
 {
     selected = juce::jlimit (0, juce::jmax (0, (int) engine.getSong().mixer.size() - 1), track);
+    selection = { selected };
     repaint();
 
     if (onSelectionChanged)
@@ -669,6 +847,50 @@ void MixerStrips::showMenu (int t)
         menu.addItem (tr ("Route channel \"{0}\" here", { juce::String::fromUTF8 (song.channels[(std::size_t) channel].name.c_str()) }),
                       [this, channel, t] { engine.editSong ([channel, t] (Song& s) { s.channels[(std::size_t) channel].mixerTrack = t; }); });
 
+    menu.addItem (tr ("Link the selected channels here") + "\tCtrl+L", [this, t] {
+        setSelection (selection, t);
+        linkSelectedChannels (false);
+    });
+    menu.addItem (tr ("Link the selected channels starting here") + "\tCtrl+Shift+L", [this, t] {
+        setSelection (selection, t);
+        linkSelectedChannels (true);
+    });
+    menu.addItem (tr ("Select the channels linked here") + "\tAlt+L", ! mixerops::channelsOn (song, t).empty(), false, [this, t] {
+        setSelection (selection, t);
+        selectLinkedChannels();
+    });
+
+    {
+        // route the other selected inserts into this one
+        std::vector<int> sources;
+        for (auto s : selection)
+            if (s > 0 && s != t)
+                sources.push_back (s);
+
+        if (! sources.empty())
+        {
+            menu.addItem (tr ("Route the selected inserts here"), [this, sources, t] {
+                engine.editSong ([sources, t] (Song& s) { mixerops::routeTo (s, sources, t, false); });
+            });
+            menu.addItem (tr ("Route the selected inserts only here"), [this, sources, t] {
+                engine.editSong ([sources, t] (Song& s) { mixerops::routeTo (s, sources, t, true); });
+            });
+        }
+    }
+
+    if (t > 0)
+    {
+        menu.addItem (tr ("Move left") + "\tAlt+Left", t > 1, false, [this, t] {
+            setSelection ({ t }, t);
+            moveSelected (-1);
+        });
+        menu.addItem (tr ("Move right") + "\tAlt+Right", t + 1 < (int) song.mixer.size(), false, [this, t] {
+            setSelection ({ t }, t);
+            moveSelected (1);
+        });
+    }
+    menu.addSeparator();
+
     if (selected > 0 && selected != t && (t == 0 || song.canRoute (selected, t) || song.routes (selected, t)))
         menu.addItem (tr ("Send \"{0}\" only to this track", { juce::String::fromUTF8 (song.mixer[(std::size_t) selected].name.c_str()) }),
                       [this, from = selected, t] {
@@ -738,6 +960,10 @@ void MixerStrips::showMenu (int t)
 void MixerStrips::changeListenerCallback (juce::ChangeBroadcaster*)
 {
     selected = juce::jlimit (0, juce::jmax (0, (int) engine.getSong().mixer.size() - 1), selected);
+    const auto count = (int) engine.getSong().mixer.size();
+    selection.erase (std::remove_if (selection.begin(), selection.end(), [count] (int t) { return t >= count; }), selection.end());
+    if (! std::binary_search (selection.begin(), selection.end(), selected))
+        selection = { selected };
     updateSize();
     repaint();
 }
@@ -771,12 +997,18 @@ namespace
 {
 constexpr int panelHeader = 30;
 constexpr int slotHeight = 24;
-constexpr EffectKind allEffects[] = { EffectKind::eq,     EffectKind::parametricEq, EffectKind::compressor, EffectKind::limiter,
+const EffectKind allEffects[] = { EffectKind::eq,     EffectKind::parametricEq, EffectKind::compressor, EffectKind::limiter,
                                       EffectKind::delay,  EffectKind::reverb,       EffectKind::chorus,     EffectKind::filter,
                                       EffectKind::distortion, EffectKind::utility, EffectKind::volumeGate,
                                       EffectKind::pitchShift, EffectKind::freqShift, EffectKind::lofi, EffectKind::effector, EffectKind::crossover, EffectKind::autoPan, EffectKind::vocoder, EffectKind::pitchCorrect };
 } // namespace
 
+const std::vector<EffectKind>& addableEffects()
+{
+    static const std::vector<EffectKind> list (std::begin (allEffects), std::end (allEffects));
+    return list;
+}
+
 EffectsPanel::EffectsPanel (AudioEngine& e)
     : engine (e)
 {
@@ -937,7 +1169,21 @@ void EffectsPanel::paint (juce::Graphics& g)
     g.setColour (colour::textPrimary);
     g.setFont (font (type::title, true));
     g.drawText (tr ("Effects: {0}", { juce::String::fromUTF8 (song.mixer[(std::size_t) track].name.c_str()) }), 10, 4,
-                getWidth() - 20, panelHeader - 8, juce::Justification::centredLeft, true);
+                getWidth() - 70, panelHeader - 8, juce::Justification::centredLeft, true);
+
+    // the insert's effects switch
+    if (! s->empty())
+    {
+        const auto on = mixerops::anyEffectEnabled (song, track);
+        const auto r = fxSwitchBounds().toFloat();
+        g.setColour (on ? colour::bg5 : colour::bg0);
+        g.fillRoundedRectangle (r, radius::sm);
+        g.setColour (muteLed (! on));
+        g.fillEllipse (r.withWidth (r.getHeight()).reduced (6.0f).translated (3.0f, 0.0f));
+        g.setColour (on ? colour::textPrimary : colour::textDisabled);
+        g.setFont (font (type::caption, true));
+        g.drawText ("FX", r.withTrimmedLeft (r.getHeight()).toNearestInt(), juce::Justification::centredLeft);
+    }
 
     g.setFont (font (type::body));
 
@@ -984,6 +1230,14 @@ void EffectsPanel::paint (juce::Graphics& g)
         }
     }
 
+    if (dragSlot >= 0 && dropSlot >= 0 && dropSlot != dragSlot) // where the dragged slot lands
+    {
+        const auto r = slotBounds (dropSlot);
+        const auto y = dropSlot > dragSlot ? r.getBottom() + 1 : r.getY() - 2;
+        g.setColour (colour::accent);
+        g.fillRect (r.getX(), y, r.getWidth(), 2);
+    }
+
     if (selectedSlot < 0 || selectedSlot >= (int) s->size())
         return;
 
@@ -1096,6 +1350,18 @@ void EffectsPanel::mouseDown (const juce::MouseEvent& e)
     if (s == nullptr)
         return;
 
+    if (! s->empty() && fxSwitchBounds().contains (e.getPosition()))
+    {
+        if (e.mods.isPopupMenu())
+            toggleAllWindows();
+        else
+        {
+            const auto on = ! mixerops::anyEffectEnabled (engine.getSong(), track);
+            engine.editSong ([t = track, on] (Song& song) { mixerops::setAllEffectsEnabled (song, t, on); });
+        }
+        return;
+    }
+
     for (int i = 0; i < maxEffectSlots; ++i)
     {
         const auto r = slotBounds (i);
@@ -1134,6 +1400,8 @@ void EffectsPanel::mouseDown (const juce::MouseEvent& e)
                 auto& slot = song.mixer[(std::size_t) t].effects[(std::size_t) i];
                 slot.enabled = ! slot.enabled;
             });
+        else
+            dragSlot = i; // dragging the name reorders the slot
         return;
     }
 
@@ -1270,6 +1538,18 @@ void EffectsPanel::mouseWheelMove (const juce::MouseEvent& e, const juce::MouseW
         return;
     }
 
+    // the wheel over a slot's name moves it up or down
+    if (const auto slot = slotAt (e.getPosition()); slot >= 0)
+    {
+        const auto to = slot + ((wheel.deltaY != 0.0f ? wheel.deltaY : -wheel.deltaX) > 0.0f ? -1 : 1);
+        bool moved = false;
+        engine.editSong ([t = track, slot, to, &moved] (Song& song) { moved = mixerops::moveEffectSlot (song, t, slot, to); });
+        if (moved)
+            selectedSlot = to;
+        repaint();
+        return;
+    }
+
     juce::Component::mouseWheelMove (e, wheel);
 }
 
@@ -1288,11 +1568,18 @@ ui::Hint EffectsPanel::hintAt (juce::Point<int> p)
         return ui::valueHint (specFor (param, selectedSlot), valueOf (param, selectedSlot), gesture);
 
     ui::Hint h;
+    if (fxSwitchBounds().contains (p) && slots() != nullptr && ! slots()->empty())
+    {
+        h.text = tr ("All effects of this insert on/off; right-click opens or closes their plugin windows");
+        h.hasMenu = true;
+        return h;
+    }
+
     for (int i = 0; i < maxEffectSlots; ++i)
         if (slotBounds (i).contains (p))
         {
             const auto used = slots() != nullptr && i < (int) slots()->size();
-            h.text = used ? tr ("Effect slot: click edits, the LED bypasses, right-click: replace, move, delete")
+            h.text = used ? tr ("Effect slot: click edits, the LED bypasses, drag or wheel reorders, right-click: replace, move, delete")
                           : tr ("Empty slot: click to add an effect");
             h.hasMenu = used;
         }
@@ -1302,6 +1589,22 @@ ui::Hint EffectsPanel::hintAt (juce::Point<int> p)
 
 void EffectsPanel::mouseDrag (const juce::MouseEvent& e)
 {
+    if (dragSlot >= 0)
+    {
+        if (e.getDistanceFromDragStart() > 4)
+        {
+            const auto count = slots() != nullptr ? (int) slots()->size() : 0;
+            const auto target = juce::jlimit (0, juce::jmax (0, count - 1), (e.y - panelHeader) / slotHeight);
+            if (target != dropSlot)
+            {
+                dropSlot = target;
+                setMouseCursor (juce::MouseCursor::DraggingHandCursor);
+                repaint();
+            }
+        }
+        return;
+    }
+
     if (dragParam == gateStepParam)
     {
         setGateStep (e.getPosition());
@@ -1322,6 +1625,19 @@ void EffectsPanel::mouseDrag (const juce::MouseEvent& e)
 
 void EffectsPanel::mouseUp (const juce::MouseEvent&)
 {
+    if (dragSlot >= 0 && dropSlot >= 0 && dropSlot != dragSlot)
+    {
+        bool moved = false;
+        engine.editSong ([t = track, from = dragSlot, to = dropSlot, &moved] (Song& song) { moved = mixerops::moveEffectSlot (song, t, from, to); });
+        if (moved)
+            selectedSlot = dropSlot;
+    }
+
+    if (dragSlot >= 0)
+        setMouseCursor (juce::MouseCursor::NormalCursor);
+
+    dragSlot = dropSlot = -1;
+    repaint();
     dragParam = -1;
     drag.end();
 }
@@ -1347,6 +1663,100 @@ void EffectsPanel::mouseDoubleClick (const juce::MouseEvent& e)
     });
 }
 
+bool EffectsPanel::isInterestedInDragSource (const SourceDetails& details)
+{
+    return BrowserComponent::isBrowserDrag (details) && BrowserComponent::draggedFile (details).hasFileExtension ("fst");
+}
+
+void EffectsPanel::itemDropped (const SourceDetails& details)
+{
+    dropPreset (BrowserComponent::draggedFile (details), details.localPosition);
+}
+
+bool EffectsPanel::isInterestedInFileDrag (const juce::StringArray& files)
+{
+    return files.size() == 1 && juce::File (files[0]).hasFileExtension ("fst");
+}
+
+void EffectsPanel::filesDropped (const juce::StringArray& files, int x, int y)
+{
+    if (! files.isEmpty())
+        dropPreset (juce::File (files[0]), { x, y });
+}
+
+bool EffectsPanel::dropPreset (const juce::File& file, juce::Point<int> position)
+{
+    juce::MemoryBlock data;
+
+    if (slots() == nullptr || ! file.loadFileAsData (data))
+        return false;
+
+    const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
+    const auto fx = effectFromFlPreset (std::vector<std::uint8_t> (bytes, bytes + data.getSize()), engine.getSong().bpm);
+
+    if (! fx)
+    {
+        juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Preset"),
+                                                tr ("LYNX can't build an effect from this preset."));
+        return false;
+    }
+
+    auto target = -1;
+    for (int i = 0; i < (int) slots()->size(); ++i)
+        if (slotBounds (i).contains (position))
+            target = i;
+
+    if (target < 0 && (int) slots()->size() >= maxEffectSlots)
+        return false;
+
+    engine.editSong ([t = track, target, fx = *fx] (Song& song) {
+        auto& effects = song.mixer[(std::size_t) t].effects;
+        if (target >= 0 && target < (int) effects.size())
+            effects[(std::size_t) target] = fx;
+        else
+            effects.push_back (fx);
+    });
+    selectedSlot = target >= 0 ? target : (int) slots()->size() - 1;
+    repaint();
+    return true;
+}
+
+juce::Rectangle<int> EffectsPanel::fxSwitchBounds() const
+{
+    return { getWidth() - 58, 6, 48, panelHeader - 12 };
+}
+
+int EffectsPanel::slotAt (juce::Point<int> p) const
+{
+    const auto* s = slots();
+    for (int i = 0; s != nullptr && i < (int) s->size(); ++i)
+        if (slotBounds (i).contains (p) && ! mixBounds (i).contains (p) && p.x >= slotBounds (i).getX() + 22)
+            return i;
+    return -1;
+}
+
+void EffectsPanel::toggleAllWindows()
+{
+    // opens every plugin effect window of the insert, or closes them all when one is open
+    const auto* s = slots();
+    if (s == nullptr)
+        return;
+
+    bool anyOpen = false;
+    for (int i = 0; i < (int) s->size(); ++i)
+        if (auto* p = dynamic_cast<PluginEffect*> (engine.getEffect (track, i).get()))
+            anyOpen = anyOpen || PluginWindows::isOpen (p->getInstance());
+
+    for (int i = 0; i < (int) s->size(); ++i)
+        if (auto* p = dynamic_cast<PluginEffect*> (engine.getEffect (track, i).get()))
+        {
+            if (anyOpen)
+                PluginWindows::close (p->getInstance());
+            else
+                openPluginWindow (i);
+        }
+}
+
 juce::Rectangle<int> EffectsPanel::pluginButtonBounds() const
 {
     return { 20, panelHeader + maxEffectSlots * slotHeight + 30, getWidth() - 40, 30 };
@@ -1482,6 +1892,27 @@ void EffectsPanel::showSlotMenu (int slot)
         sideMenu (tr ("Modulator from"), false);
         sideMenu (tr ("Carrier from"), true);
     }
+    {
+        // A/B compare: keep a copy of the settings, then swap between it and the current ones
+        const auto key = std::make_pair (track, slot);
+        const auto hasSpare = spare.count (key) > 0 && spare[key].kind == (*slots())[(std::size_t) slot].kind;
+        juce::PopupMenu ab;
+        ab.addItem (tr ("Store the current settings as B"), [this, key, slot] {
+            spare[key] = (*slots())[(std::size_t) slot];
+        });
+        ab.addItem (tr ("Swap with B"), hasSpare, false, [this, key, slot] {
+            const auto stored = spare[key];
+            spare[key] = (*slots())[(std::size_t) slot];
+            engine.editSong ([t = track, slot, stored] (Song& song) {
+                auto& target = song.mixer[(std::size_t) t].effects[(std::size_t) slot];
+                const auto enabled = target.enabled;
+                target = stored;
+                target.enabled = enabled;
+            });
+        });
+        ab.addItem (tr ("Forget B"), hasSpare, false, [this, key] { spare.erase (key); });
+        menu.addSubMenu (hasSpare ? tr ("A/B compare (B stored)") : tr ("A/B compare"), ab);
+    }
     menu.addItem (tr ("Move up"), slot > 0, false, [this, slot] {
         engine.editSong ([t = track, slot] (Song& song) { song.swapEffectSlots (t, slot, slot - 1); });
         selectedSlot = slot - 1;
@@ -1532,6 +1963,47 @@ MixerComponent::MixerComponent (AudioEngine& e)
     strips.onSelectionChanged = [this] (int track) { effects.setTrack (track); };
 }
 
+bool MixerComponent::runAction (const std::string& id)
+{
+    if (id == "mixer.moveLeft")
+        strips.moveSelected (-1);
+    else if (id == "mixer.moveRight")
+        strips.moveSelected (1);
+    else if (id == "mixer.linkChannels")
+        strips.linkSelectedChannels (false);
+    else if (id == "mixer.linkChannelsFrom")
+        strips.linkSelectedChannels (true);
+    else if (id == "mixer.selectLinkedChannels")
+        strips.selectLinkedChannels();
+    else
+        return false;
+
+    return true;
+}
+
+bool MixerComponent::addEffectToSelected (EffectSlot slot)
+{
+    const auto t = strips.getSelectedTrack();
+    bool added = false;
+    engine.editSong ([t, &slot, &added] (Song& s) {
+        if (s.mixer.empty())
+            s.mixer = Song::defaultMixer (0);
+        if (t < (int) s.mixer.size() && (int) s.mixer[(std::size_t) t].effects.size() < maxEffectSlots)
+        {
+            s.mixer[(std::size_t) t].effects.push_back (std::move (slot));
+            added = true;
+        }
+    });
+
+    if (added)
+    {
+        effects.setTrack (t);
+        effects.selectSlot ((int) engine.getSong().mixer[(std::size_t) t].effects.size() - 1);
+    }
+
+    return added;
+}
+
 void MixerComponent::selectFirstTrackWithEffects()
 {
     const auto& mixer = engine.getSong().mixer;

+ 43 - 1
src/ui/MixerComponent.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include <functional>
+#include <map>
 #include <vector>
 
 #include <juce_gui_basics/juce_gui_basics.h>
@@ -10,6 +11,9 @@
 
 namespace lynx
 {
+// The built-in effects offered in the slot menus and the quick-add palette, in menu order.
+const std::vector<EffectKind>& addableEffects();
+
 // FL-style mixer: one vertical strip per track (Master first).
 //  - fader and pan: the shared control contract (ui/ValueControl.h): drag (Ctrl: fine), wheel,
 //    Alt/middle-click or double-click resets, right-click: type value / reset / automation
@@ -43,11 +47,19 @@ public:
     void selectTrack (int track);
     std::function<void (int)> onSelectionChanged;
 
+    // Multi-selection (docs/WORKFLOW_FL.md P2, M1): Ctrl+click on a strip's header toggles it, Shift+click
+    // selects a range; selected faders and pans move together. Always contains the selected track.
+    const std::vector<int>& getSelection() const noexcept { return selection; }
+    void setSelection (std::vector<int> tracks, int primary);
+    bool moveSelected (int delta);           // Alt+Left/Right
+    void linkSelectedChannels (bool startingHere); // Ctrl+L / Ctrl+Shift+L
+    void selectLinkedChannels();             // Alt+L
+
     static constexpr int stripWidth = 70;
     static constexpr int masterWidth = 86;
 
 private:
-    enum class Part { none, pan, fader, mute, solo, route, body, add };
+    enum class Part { none, pan, fader, mute, solo, route, body, add, arm };
 
     void changeListenerCallback (juce::ChangeBroadcaster*) override;
     void timerCallback() override;
@@ -61,6 +73,12 @@ private:
     juce::Rectangle<int> muteArea (int track) const;
     juce::Rectangle<int> soloArea (int track) const;
     juce::Rectangle<int> routeArea (int track) const;
+    juce::Rectangle<int> armArea (int track) const;
+    void showSendMenu (int track);
+    void soloExclusive (int track);
+    std::vector<int> selection { 0 };
+    std::vector<std::pair<int, float>> groupStart; // (track, value) of the selection when a group drag starts
+    float groupGrab = 0.0f;
     void showMenu (int track);
     void showTrackEq (int track);
     ui::ValueSpec specFor (Part part, int track) const;
@@ -87,13 +105,24 @@ private:
 //  - knob to the right of the slot: dry/wet (drag; double-click resets to 100%)
 class EffectsPanel final : public juce::Component,
                            public ui::HintSource,
+                           public juce::DragAndDropTarget,
+                           public juce::FileDragAndDropTarget,
                            private juce::ChangeListener
 {
 public:
+    // Effect presets (.fst) dragged from the Browser or Explorer: dropped on a slot they replace it,
+    // anywhere else they go into the first free slot.
+    bool isInterestedInDragSource (const SourceDetails& details) override;
+    void itemDropped (const SourceDetails& details) override;
+    bool isInterestedInFileDrag (const juce::StringArray& files) override;
+    void filesDropped (const juce::StringArray& files, int x, int y) override;
+    bool dropPreset (const juce::File& file, juce::Point<int> position);
+
     explicit EffectsPanel (AudioEngine& engine);
     ~EffectsPanel() override;
 
     void setTrack (int track);
+    int getSelectedSlot() const noexcept { return selectedSlot; }
     void selectSlot (int slot)
     {
         selectedSlot = slot;
@@ -129,6 +158,12 @@ private:
     void showSlotMenu (int slot);
     juce::Rectangle<int> pluginButtonBounds() const;
     void openPluginWindow (int slot);
+    juce::Rectangle<int> fxSwitchBounds() const; // all effects on/off; right-click opens/closes their windows
+    void toggleAllWindows();
+    int slotAt (juce::Point<int> p) const;
+    int dragSlot = -1, dropSlot = -1; // dragging a slot to reorder it
+    // A/B compare: a spare state per (insert, slot), swapped with the live one on request (not saved)
+    std::map<std::pair<int, int>, EffectSlot> spare;
 
     AudioEngine& engine;
     int track = 0;
@@ -151,6 +186,13 @@ public:
     void selectTrack (int track) { strips.selectTrack (track); }
     void selectSlot (int slot) { effects.selectSlot (slot); }
 
+    // The key map's mixer.* actions.
+    bool runAction (const std::string& id);
+
+    // Adds an effect to the first free slot of the selected insert (quick-add palette). False when full.
+    bool addEffectToSelected (EffectSlot slot);
+    MixerStrips& getStripsForSnapshot() { return strips; }
+
     static constexpr int effectsWidth = 300;
 
 private:

+ 387 - 0
src/ui/NoteToolDialogs.cpp

@@ -0,0 +1,387 @@
+#include "ui/NoteToolDialogs.h"
+
+#include "core/NoteTools.h"
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+#include "ui/ToolWindow.h"
+
+namespace lynx
+{
+namespace
+{
+juce::String keyName (int key)
+{
+    static const char* names[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+    return juce::String (names[((key % 12) + 12) % 12]) + juce::String (key / 12);
+}
+
+juce::String percent (double v)
+{
+    return juce::String (juce::roundToInt (v * 100.0)) + "%";
+}
+
+struct Control
+{
+    enum Kind { slider, choice, toggle } kind = slider;
+    juce::String name;
+    double minimum = 0.0, maximum = 1.0, interval = 0.01, initial = 0.0;
+    std::function<juce::String (double)> format;
+    juce::StringArray choices;
+};
+
+class NoteToolPanel final : public juce::Component
+{
+public:
+    NoteToolPanel (AudioEngine& e, NoteTool t, std::vector<int> i, std::int64_t g)
+        : engine (e), tool (t), indices (std::move (i)), grid (juce::jmax<std::int64_t> (1, g))
+    {
+        const auto& song = engine.getSong();
+        patternIndex = song.currentPattern;
+        originals = song.patterns[(std::size_t) patternIndex].notes;
+        buildControls();
+
+        title.setText (tr (noteToolTitle (tool)), juce::dontSendNotification);
+        title.setFont (theme::font (theme::type::title, true));
+        addAndMakeVisible (title);
+        info.setText (tr ("{0} notes. Changes are heard and seen right away; Accept keeps them as one undo step.",
+                          { juce::String ((int) indices.size()) }),
+                      juce::dontSendNotification);
+        info.setFont (theme::font (theme::type::small));
+        info.setColour (juce::Label::textColourId, theme::colour::textSecondary);
+        addAndMakeVisible (info);
+
+        for (auto* b : { &acceptButton, &resetButton, &cancelButton })
+            addAndMakeVisible (b);
+
+        acceptButton.setColour (juce::TextButton::buttonColourId, theme::colour::accent);
+        acceptButton.onClick = [this] { accept(); };
+        resetButton.onClick = [this] { resetControls(); };
+        cancelButton.onClick = [this] { close(); };
+
+        if (tool == NoteTool::randomise)
+        {
+            seedButton.onClick = [this] {
+                ++seed;
+                preview();
+            };
+            addAndMakeVisible (seedButton);
+        }
+
+        setSize (420, 92 + rowHeight * (int) controls.size() + (tool == NoteTool::randomise ? rowHeight : 0) + 44);
+        preview();
+    }
+
+    ~NoteToolPanel() override
+    {
+        if (! accepted)
+            restore();
+    }
+
+    std::function<void()> onFinished;
+
+    void paint (juce::Graphics& g) override { g.fillAll (theme::colour::bg2); }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (14, 10);
+        title.setBounds (area.removeFromTop (24));
+        info.setBounds (area.removeFromTop (36));
+        area.removeFromTop (6);
+
+        for (std::size_t c = 0; c < controls.size(); ++c)
+        {
+            auto row = area.removeFromTop (rowHeight).reduced (0, 3);
+            labels[c]->setBounds (row.removeFromLeft (130));
+            editors[c]->setBounds (row);
+        }
+
+        if (tool == NoteTool::randomise)
+            seedButton.setBounds (area.removeFromTop (rowHeight).reduced (0, 3).withTrimmedLeft (130).withWidth (160));
+
+        auto buttons = area.removeFromBottom (30);
+        acceptButton.setBounds (buttons.removeFromRight (100));
+        buttons.removeFromRight (8);
+        cancelButton.setBounds (buttons.removeFromRight (90));
+        buttons.removeFromRight (8);
+        resetButton.setBounds (buttons.removeFromRight (90));
+    }
+
+private:
+    static constexpr int rowHeight = 30;
+
+    void add (Control c)
+    {
+        auto label = std::make_unique<juce::Label> (juce::String(), c.name);
+        label->setFont (theme::font (theme::type::body));
+        addAndMakeVisible (*label);
+        labels.push_back (std::move (label));
+
+        std::unique_ptr<juce::Component> editor;
+
+        if (c.kind == Control::slider)
+        {
+            auto s = std::make_unique<juce::Slider> (juce::Slider::LinearHorizontal, juce::Slider::TextBoxRight);
+            s->setTextBoxStyle (juce::Slider::TextBoxRight, false, 70, 20);
+            s->setRange (c.minimum, c.maximum, c.interval);
+            s->setValue (c.initial, juce::dontSendNotification);
+            s->setDoubleClickReturnValue (true, c.initial);
+            if (c.format)
+                s->textFromValueFunction = c.format;
+            s->updateText();
+            s->onValueChange = [this] { preview(); };
+            editor = std::move (s);
+        }
+        else if (c.kind == Control::choice)
+        {
+            auto box = std::make_unique<juce::ComboBox>();
+            box->addItemList (c.choices, 1);
+            box->setSelectedItemIndex ((int) c.initial, juce::dontSendNotification);
+            box->onChange = [this] { preview(); };
+            editor = std::move (box);
+        }
+        else
+        {
+            auto toggle = std::make_unique<juce::ToggleButton>();
+            toggle->setToggleState (c.initial > 0.5, juce::dontSendNotification);
+            toggle->onClick = [this] { preview(); };
+            editor = std::move (toggle);
+        }
+
+        addAndMakeVisible (*editor);
+        editors.push_back (std::move (editor));
+        controls.push_back (std::move (c));
+    }
+
+    double value (std::size_t i) const
+    {
+        if (auto* s = dynamic_cast<juce::Slider*> (editors[i].get()))
+            return s->getValue();
+        if (auto* b = dynamic_cast<juce::ComboBox*> (editors[i].get()))
+            return juce::jmax (0, b->getSelectedItemIndex());
+        if (auto* t = dynamic_cast<juce::ToggleButton*> (editors[i].get()))
+            return t->getToggleState() ? 1.0 : 0.0;
+        return 0.0;
+    }
+
+    void resetControls()
+    {
+        for (std::size_t i = 0; i < controls.size(); ++i)
+        {
+            const auto v = controls[i].initial;
+            if (auto* s = dynamic_cast<juce::Slider*> (editors[i].get()))
+                s->setValue (v, juce::dontSendNotification);
+            else if (auto* b = dynamic_cast<juce::ComboBox*> (editors[i].get()))
+                b->setSelectedItemIndex ((int) v, juce::dontSendNotification);
+            else if (auto* t = dynamic_cast<juce::ToggleButton*> (editors[i].get()))
+                t->setToggleState (v > 0.5, juce::dontSendNotification);
+        }
+        seed = 1;
+        preview();
+    }
+
+    void buildControls()
+    {
+        const auto steps = [] (double v) { return juce::String (v, 2) + " " + tr ("steps"); };
+        const auto signedPercent = [] (double v) { return (v > 0 ? "+" : "") + juce::String (juce::roundToInt (v * 100.0)) + "%"; };
+
+        switch (tool)
+        {
+            case NoteTool::strum:
+                add ({ Control::slider, tr ("Spread"), 0.0, 2.0, 0.01, 0.25, steps, {} });
+                add ({ Control::slider, tr ("Curve"), -1.0, 1.0, 0.01, 0.0, [] (double v) { return juce::String (v, 2); }, {} });
+                add ({ Control::slider, tr ("Velocity per note"), -0.25, 0.25, 0.01, 0.0, signedPercent, {} });
+                add ({ Control::choice, tr ("Direction"), 0, 1, 1, 0, {}, { tr ("Low to high"), tr ("High to low") } });
+                add ({ Control::toggle, tr ("Alternate"), 0, 1, 1, 0, {}, {} });
+                add ({ Control::toggle, tr ("Keep the ends"), 0, 1, 1, 1, {}, {} });
+                break;
+            case NoteTool::arpeggiate:
+                add ({ Control::choice, tr ("Step"), 0, 5, 1, 3, {}, { "1/4", "1/8", tr ("1/8 triplet"), "1/16", tr ("1/16 triplet"), "1/32" } });
+                add ({ Control::slider, tr ("Gate"), 0.05, 1.0, 0.01, 0.8, percent, {} });
+                add ({ Control::choice, tr ("Direction"), 0, 3, 1, 0, {}, { tr ("Up"), tr ("Down"), tr ("Up and down"), tr ("Down and up") } });
+                add ({ Control::slider, tr ("Octaves"), 1.0, 4.0, 1.0, 1.0, [] (double v) { return juce::String (juce::roundToInt (v)); }, {} });
+                break;
+            case NoteTool::flip:
+                add ({ Control::toggle, tr ("Flip in time"), 0, 1, 1, 1, {}, {} });
+                add ({ Control::toggle, tr ("Flip in pitch"), 0, 1, 1, 0, {}, {} });
+                break;
+            case NoteTool::randomise:
+                add ({ Control::slider, tr ("Velocity"), 0.0, 1.0, 0.01, 0.2, percent, {} });
+                add ({ Control::slider, tr ("Pan"), 0.0, 1.0, 0.01, 0.0, percent, {} });
+                add ({ Control::slider, tr ("Fine pitch"), 0.0, 1.0, 0.01, 0.0, percent, {} });
+                add ({ Control::slider, tr ("Timing"), 0.0, 0.5, 0.01, 0.0, steps, {} });
+                add ({ Control::slider, tr ("Length"), 0.0, 1.0, 0.01, 0.0, percent, {} });
+                add ({ Control::toggle, tr ("Both directions"), 0, 1, 1, 1, {}, {} });
+                break;
+            case NoteTool::scaleLevels:
+            {
+                juce::StringArray levels;
+                for (int l = 0; l < notetools::levelCount; ++l)
+                    levels.add (tr (notetools::levelName ((notetools::Level) l)));
+                add ({ Control::choice, tr ("Level"), 0, (double) levels.size() - 1, 1, 0, {}, levels });
+                add ({ Control::slider, tr ("Scale at the start"), 0.0, 2.0, 0.01, 1.0, percent, {} });
+                add ({ Control::slider, tr ("Scale at the end"), 0.0, 2.0, 0.01, 1.0, percent, {} });
+                add ({ Control::slider, tr ("Offset"), -1.0, 1.0, 0.01, 0.0, signedPercent, {} });
+                break;
+            }
+            case NoteTool::limit:
+                add ({ Control::slider, tr ("Lowest note"), 0.0, 127.0, 1.0, 36.0, [] (double v) { return keyName (juce::roundToInt (v)); }, {} });
+                add ({ Control::slider, tr ("Highest note"), 0.0, 127.0, 1.0, 84.0, [] (double v) { return keyName (juce::roundToInt (v)); }, {} });
+                add ({ Control::slider, tr ("Lowest velocity"), 0.0, 1.0, 0.01, 0.0, percent, {} });
+                add ({ Control::slider, tr ("Highest velocity"), 0.0, 1.0, 0.01, 1.0, percent, {} });
+                break;
+        }
+    }
+
+    // applies the tool with the current control values
+    void apply (Pattern& p) const
+    {
+        using namespace notetools;
+
+        switch (tool)
+        {
+            case NoteTool::strum:
+            {
+                StrumOptions o;
+                o.spread = (std::int64_t) std::llround (value (0) * ticksPerStep);
+                o.curve = (float) value (1);
+                o.velocityStep = (float) value (2);
+                o.downward = value (3) > 0.5;
+                o.alternate = value (4) > 0.5;
+                o.keepEnds = value (5) > 0.5;
+                strum (p, indices, o);
+                break;
+            }
+            case NoteTool::arpeggiate:
+            {
+                static const std::int64_t stepTicks[] = { ppq, ppq / 2, ppq / 3, ppq / 4, ppq / 6, ppq / 8 };
+                ArpeggiateOptions o;
+                o.step = stepTicks[juce::jlimit (0, 5, (int) value (0))];
+                o.gate = (float) value (1);
+                o.direction = (int) value (2);
+                o.octaves = juce::roundToInt (value (3));
+                arpeggiate (p, indices, o);
+                break;
+            }
+            case NoteTool::flip:
+                flip (p, indices, value (0) > 0.5, value (1) > 0.5);
+                break;
+            case NoteTool::randomise:
+            {
+                RandomiseOptions o;
+                o.velocity = (float) value (0);
+                o.pan = (float) value (1);
+                o.finePitch = (float) value (2);
+                o.timing = (std::int64_t) std::llround (value (3) * ticksPerStep);
+                o.length = (float) value (4);
+                o.bipolar = value (5) > 0.5;
+                o.seed = seed;
+                randomise (p, indices, o);
+                break;
+            }
+            case NoteTool::scaleLevels:
+                scaleLevels (p, indices, (Level) (int) value (0), (float) value (1), (float) value (2), (float) value (3));
+                break;
+            case NoteTool::limit:
+            {
+                LimitOptions o;
+                o.lowKey = juce::roundToInt (value (0));
+                o.highKey = juce::roundToInt (value (1));
+                o.minVelocity = (float) value (2);
+                o.maxVelocity = (float) value (3);
+                limit (p, indices, o);
+                break;
+            }
+        }
+
+        p.sortNotes();
+    }
+
+    bool patternStillThere() const { return patternIndex < (int) engine.getSong().patterns.size(); }
+
+    void restore()
+    {
+        if (patternStillThere())
+            engine.editSong ([this] (Song& s) { s.patterns[(std::size_t) patternIndex].notes = originals; }, false);
+    }
+
+    void preview()
+    {
+        if (patternStillThere())
+            engine.editSong ([this] (Song& s) {
+                auto& p = s.patterns[(std::size_t) patternIndex];
+                p.notes = originals;
+                apply (p);
+            }, false);
+    }
+
+    void accept()
+    {
+        if (patternStillThere())
+        {
+            restore();
+            engine.editSong ([this] (Song& s) { apply (s.patterns[(std::size_t) patternIndex]); });
+        }
+
+        accepted = true;
+        close();
+    }
+
+    void close()
+    {
+        if (! accepted)
+            restore();
+        accepted = true; // nothing left to undo in the destructor
+
+        if (onFinished)
+            onFinished();
+
+        closeToolWindowOf (*this);
+    }
+
+    AudioEngine& engine;
+    NoteTool tool;
+    std::vector<int> indices;
+    std::int64_t grid;
+    int patternIndex = 0;
+    std::vector<Note> originals;
+    std::uint32_t seed = 1;
+    bool accepted = false;
+
+    std::vector<Control> controls;
+    std::vector<std::unique_ptr<juce::Label>> labels;
+    std::vector<std::unique_ptr<juce::Component>> editors;
+    juce::Label title, info;
+    juce::TextButton acceptButton { tr ("Accept") }, resetButton { tr ("Reset") }, cancelButton { tr ("Cancel") };
+    juce::TextButton seedButton { tr ("New variation") };
+};
+} // namespace
+
+const char* noteToolTitle (NoteTool tool)
+{
+    switch (tool)
+    {
+        case NoteTool::strum: return TR_NOOP ("Strum");
+        case NoteTool::arpeggiate: return TR_NOOP ("Arpeggiate");
+        case NoteTool::flip: return TR_NOOP ("Flip");
+        case NoteTool::randomise: return TR_NOOP ("Randomise");
+        case NoteTool::scaleLevels: return TR_NOOP ("Scale levels");
+        case NoteTool::limit: return TR_NOOP ("Limit");
+    }
+    return "";
+}
+
+std::unique_ptr<juce::Component> makeNoteToolPanel (AudioEngine& engine, NoteTool tool, std::vector<int> indices, std::int64_t grid)
+{
+    return std::make_unique<NoteToolPanel> (engine, tool, std::move (indices), grid);
+}
+
+void showNoteTool (AudioEngine& engine, NoteTool tool, std::vector<int> indices, std::int64_t grid, std::function<void()> onFinished)
+{
+    if (indices.empty())
+        return;
+
+    auto panel = std::make_unique<NoteToolPanel> (engine, tool, std::move (indices), grid);
+    panel->onFinished = std::move (onFinished);
+    openToolWindow (std::move (panel), tr (noteToolTitle (tool)), "notetool");
+}
+} // namespace lynx

+ 27 - 0
src/ui/NoteToolDialogs.h

@@ -0,0 +1,27 @@
+#pragma once
+
+// Piano Roll note tool dialogs (docs/WORKFLOW_FL.md P2, R23): Strum, Arpeggiate, Flip, Randomise,
+// Scale levels and Limit. Each is a small window whose controls preview live on the pattern (not in the
+// history); Accept makes the change one undo step, Revert / closing puts the notes back.
+// The note maths lives in core/NoteTools.
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+enum class NoteTool { strum, arpeggiate, flip, randomise, scaleLevels, limit };
+
+const char* noteToolTitle (NoteTool tool); // English, for tr()
+
+// The panel (for --snapshot and tests); `indices` are notes of the current pattern, `grid` the editor's grid.
+std::unique_ptr<juce::Component> makeNoteToolPanel (AudioEngine& engine, NoteTool tool, std::vector<int> indices, std::int64_t grid);
+
+// Opens the tool in its own window. `onFinished` runs after Accept or Revert (the note indices changed).
+void showNoteTool (AudioEngine& engine, NoteTool tool, std::vector<int> indices, std::int64_t grid, std::function<void()> onFinished = {});
+} // namespace lynx

+ 223 - 33
src/ui/PianoRollComponent.cpp

@@ -1,6 +1,7 @@
 #include "ui/PianoRollComponent.h"
 
 #include "core/NoteEdit.h"
+#include "core/NoteTools.h"
 #include "engine/MidiFileIo.h"
 #include "engine/Text.h"
 #include "ui/I18n.h"
@@ -49,20 +50,9 @@ const std::vector<NamedIntervals>& chords()
     return list;
 }
 
-const std::vector<NamedIntervals>& scales()
+const std::vector<notetools::ScaleInfo>& scales()
 {
-    static const std::vector<NamedIntervals> list {
-        { TR_NOOP ("No scale"), {} },
-        { TR_NOOP ("Major"), { 0, 2, 4, 5, 7, 9, 11 } },
-        { TR_NOOP ("Natural minor"), { 0, 2, 3, 5, 7, 8, 10 } },
-        { TR_NOOP ("Harmonic minor"), { 0, 2, 3, 5, 7, 8, 11 } },
-        { TR_NOOP ("Major pentatonic"), { 0, 2, 4, 7, 9 } },
-        { TR_NOOP ("Minor pentatonic"), { 0, 3, 5, 7, 10 } },
-        { "Blues", { 0, 3, 5, 6, 7, 10 } },
-        { TR_NOOP ("Dorian"), { 0, 2, 3, 5, 7, 9, 10 } },
-        { TR_NOOP ("Phrygian"), { 0, 1, 3, 5, 7, 8, 10 } },
-    };
-    return list;
+    return notetools::scales();
 }
 
 } // namespace
@@ -120,7 +110,13 @@ PianoRollComponent::PianoRollComponent (AudioEngine& e)
     moreButton.setTooltip (tr ("Note operations, left-edge resizing and MIDI import/export"));
     moreButton.onClick = [this] { showMoreMenu(); };
 
-    for (auto* b : { &ghostButton, &moreButton })
+    scaleSnapButton.setOnColour (theme::colour::bg6);
+    scaleSnapButton.setIconColourWhenOn (theme::colour::accent);
+    scaleSnapButton.setFlat (true);
+    scaleSnapButton.setTooltip (tr ("Snap notes to the scale: new and moved notes, and incoming MIDI, land on the chosen scale"));
+    scaleSnapButton.onClick = [this] { setScaleSnap (! scaleSnap); };
+
+    for (auto* b : { &ghostButton, &scaleSnapButton, &moreButton })
     {
         b->setWantsKeyboardFocus (false);
         b->setMouseClickGrabsKeyboardFocus (false);
@@ -146,6 +142,7 @@ PianoRollComponent::PianoRollComponent (AudioEngine& e)
             scaleBox.addItem (tr ("{0} {1}", { juce::String (noteNames[root]), tr (scales()[(std::size_t) s].name) }), s * 100 + root + 1);
     }
     scaleBox.setSelectedId (1, juce::dontSendNotification);
+    scaleSnapButton.setEnabled (false); // until a scale is chosen
     scaleBox.setTooltip (tr ("Highlights the notes of a scale"));
 
     slideButton.setClickingTogglesState (true);
@@ -160,7 +157,11 @@ PianoRollComponent::PianoRollComponent (AudioEngine& e)
     {
         box->setWantsKeyboardFocus (false);
         box->setMouseClickGrabsKeyboardFocus (false);
-        box->onChange = [this] { repaint(); };
+        box->onChange = [this] {
+            publishScale();
+            scaleSnapButton.setEnabled (scaleIndex() > 0);
+            repaint();
+        };
         addAndMakeVisible (box);
     }
 
@@ -334,6 +335,10 @@ void PianoRollComponent::resized()
     place (slideButton, 54, true);
     place (chordBox, 86, true);
     place (scaleBox, 150, true);
+    if (scaleBox.isVisible())
+        place (scaleSnapButton, h);
+    else
+        scaleSnapButton.setVisible (false);
     place (moreButton, h);
     // the shortcut hint only shows when there is room for it
     const auto hintArea = juce::Rectangle<int> (bar.getX() + 4, 0, bar.getWidth() - 4, toolbarHeight);
@@ -375,16 +380,39 @@ std::vector<int> PianoRollComponent::chordIntervals() const
     return chords()[(std::size_t) index].intervals;
 }
 
-bool PianoRollComponent::inScale (int key) const
+int PianoRollComponent::scaleIndex() const
 {
     const auto id = scaleBox.getSelectedId();
+    return id <= 1 ? 0 : id / 100;
+}
 
-    if (id <= 1)
-        return false;
+int PianoRollComponent::scaleRoot() const
+{
+    const auto id = scaleBox.getSelectedId();
+    return id <= 1 ? 0 : (id % 100) - 1;
+}
+
+bool PianoRollComponent::inScale (int key) const
+{
+    return scaleIndex() > 0 && notetools::inScale (key, scaleRoot(), scaleIndex());
+}
+
+int PianoRollComponent::snapKey (int key) const
+{
+    return scaleSnap ? notetools::snapToScale (key, scaleRoot(), scaleIndex()) : key;
+}
+
+void PianoRollComponent::setScaleSnap (bool on)
+{
+    scaleSnap = on;
+    scaleSnapButton.setToggleState (on, juce::dontSendNotification);
+    publishScale();
+    repaint();
+}
 
-    const auto& intervals = scales()[(std::size_t) (id / 100)].intervals;
-    const auto root = (id % 100) - 1;
-    return std::find (intervals.begin(), intervals.end(), ((key - root) % 12 + 12) % 12) != intervals.end();
+void PianoRollComponent::publishScale()
+{
+    engine.setInputScale (scaleSnap ? scaleIndex() : 0, scaleRoot());
 }
 
 bool PianoRollComponent::isSelected (int index) const
@@ -888,8 +916,9 @@ void PianoRollComponent::paintNoteAt (std::int64_t start, int key, bool monophon
         if (n.key + interval <= 127)
         {
             auto chordNote = n;
-            chordNote.key = n.key + interval;
-            stamp.push_back (chordNote);
+            chordNote.key = snapKey (n.key + interval); // with scale snap the chord follows the scale
+            if (std::none_of (stamp.begin(), stamp.end(), [&chordNote] (const Note& o) { return o.key == chordNote.key; }))
+                stamp.push_back (chordNote);
         }
 
     editNotes ([&] (Pattern& p) {
@@ -917,6 +946,15 @@ void PianoRollComponent::mouseDown (const juce::MouseEvent& e)
     downMods = e.mods;
     startedOnEmpty = erasedSomething = holdExpired = false;
 
+    if (e.mods.isMiddleButtonDown()) // middle-drag pans both ways, in every tool
+    {
+        drag = Drag::pan;
+        panStartTicks = scrollTicks;
+        panStartY = scrollY;
+        setMouseCursor (juce::MouseCursor::DraggingHandCursor);
+        return;
+    }
+
     if (e.x < keyboardWidth && e.y >= headerHeight && e.y < gridArea().getBottom())
     {
         drag = Drag::keyboard;
@@ -1086,16 +1124,16 @@ void PianoRollComponent::mouseDown (const juce::MouseEvent& e)
         drag = Drag::paint;
         paintLength = juce::jmax<std::int64_t> (1, newNoteLength());
         const auto start = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), snapOn));
-        paintNoteAt (start, yToKey (e.y), e.mods.isShiftDown());
+        paintNoteAt (start, snapKey (yToKey (e.y)), e.mods.isShiftDown());
         nextPaintTick = start + paintLength;
-        previewOn (yToKey (e.y), 0.78f);
+        previewOn (snapKey (yToKey (e.y)), 0.78f);
         return;
     }
 
     Note n;
     n.start = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), snapOn));
     n.length = newNoteLength();
-    n.key = yToKey (e.y);
+    n.key = snapKey (yToKey (e.y));
     n.channel = engine.getSelectedChannel();
     n.slide = slideButton.getToggleState();
 
@@ -1104,8 +1142,9 @@ void PianoRollComponent::mouseDown (const juce::MouseEvent& e)
         if (n.key + interval <= 127)
         {
             auto chordNote = n;
-            chordNote.key = n.key + interval;
-            stamp.push_back (chordNote);
+            chordNote.key = snapKey (n.key + interval); // with scale snap the chord follows the scale
+            if (std::none_of (stamp.begin(), stamp.end(), [&chordNote] (const Note& o) { return o.key == chordNote.key; }))
+                stamp.push_back (chordNote);
         }
 
     std::vector<int> added;
@@ -1130,6 +1169,13 @@ void PianoRollComponent::mouseDrag (const juce::MouseEvent& e)
         case Drag::none:
             return;
 
+        case Drag::pan:
+            scrollTicks = juce::jmax (0.0, panStartTicks - e.getDistanceFromDragStartX() / pixelsPerTick);
+            scrollY = juce::jlimit (0, juce::jmax (0, 128 * rowHeight - gridArea().getHeight()), panStartY - e.getDistanceFromDragStartY());
+            updateScrollBars();
+            repaint();
+            return;
+
         case Drag::keyboard:
         {
             const auto key = yToKey (e.y);
@@ -1233,12 +1279,12 @@ void PianoRollComponent::mouseDrag (const juce::MouseEvent& e)
             const auto tick = snap (xToTick (e.x), snapOn);
             for (int guard = 0; tick >= nextPaintTick && guard < 64; ++guard)
             {
-                paintNoteAt (nextPaintTick, yToKey (e.y), e.mods.isShiftDown());
+                paintNoteAt (nextPaintTick, snapKey (yToKey (e.y)), e.mods.isShiftDown());
                 nextPaintTick += paintLength;
             }
 
-            if (yToKey (e.y) != previewKey)
-                previewOn (yToKey (e.y), 0.78f);
+            if (snapKey (yToKey (e.y)) != previewKey)
+                previewOn (snapKey (yToKey (e.y)), 0.78f);
             return;
         }
 
@@ -1246,7 +1292,7 @@ void PianoRollComponent::mouseDrag (const juce::MouseEvent& e)
         {
             const auto& grabbed = dragOriginals[(std::size_t) (std::find (dragIndices.begin(), dragIndices.end(), dragNote) - dragIndices.begin())];
             auto deltaTicks = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), snapOn) + grabOffset) - grabbed.start;
-            auto deltaKeys = yToKey (e.y) - grabbed.key;
+            auto deltaKeys = snapKey (yToKey (e.y)) - grabbed.key;
 
             // locks: Shift pressed after the click keeps the pitch, Ctrl keeps the time
             if (e.mods.isShiftDown() && ! downMods.isShiftDown())
@@ -1348,6 +1394,9 @@ void PianoRollComponent::mouseUp (const juce::MouseEvent& e)
     if (drag == Drag::listen)
         stopListening();
 
+    if (drag == Drag::pan)
+        setMouseCursor (juce::MouseCursor::NormalCursor);
+
     if (drag == Drag::move || drag == Drag::resize || drag == Drag::resizeLeft || drag == Drag::paint)
         sortNotes();
 
@@ -1608,15 +1657,156 @@ void PianoRollComponent::showMoreMenu()
     menu.addItem (tr ("Rotate left within the bar") + "\tCtrl+Shift+Left", [this, grid, bar] { runOperation ([grid, bar] (Pattern& p, const std::vector<int>& t) { noteedit::rotate (p, t, grid, bar, -1); return t; }); });
     menu.addItem (tr ("Rotate right within the bar") + "\tCtrl+Shift+Right", [this, grid, bar] { runOperation ([grid, bar] (Pattern& p, const std::vector<int>& t) { noteedit::rotate (p, t, grid, bar, 1); return t; }); });
     menu.addSeparator();
+    menu.addSubMenu (tr ("Tools"), toolsMenu());
+    {
+        juce::PopupMenu zoom;
+        zoom.addItem (tr ("Zoom in") + "\tPageUp", [this] { runAction ("pianoRoll.zoomIn"); });
+        zoom.addItem (tr ("Zoom out") + "\tPageDown", [this] { runAction ("pianoRoll.zoomOut"); });
+        zoom.addItem (tr ("Zoom: one bar") + "\tShift+1", [this] { runAction ("pianoRoll.zoom1"); });
+        zoom.addItem (tr ("Zoom: four bars") + "\tShift+2", [this] { runAction ("pianoRoll.zoom2"); });
+        zoom.addItem (tr ("Zoom: sixteen bars") + "\tShift+3", [this] { runAction ("pianoRoll.zoom3"); });
+        zoom.addItem (tr ("Zoom to show everything") + "\tShift+4", [this] { runAction ("pianoRoll.zoomAll"); });
+        zoom.addItem (tr ("Zoom to the selection") + "\tShift+5", [this] { runAction ("pianoRoll.zoomSelection"); });
+        zoom.addItem (tr ("Centre the view on the playhead") + "\tShift+0", [this] { runAction ("pianoRoll.centrePlayhead"); });
+        zoom.addSeparator();
+        zoom.addItem (tr ("Taller keys") + "\tCtrl+Alt+Wheel", [this] { rowHeight = juce::jmin (32, rowHeight + 2); updateScrollBars(); repaint(); });
+        zoom.addItem (tr ("Shorter keys"), [this] { rowHeight = juce::jmax (6, rowHeight - 2); updateScrollBars(); repaint(); });
+        menu.addSubMenu (tr ("Zoom"), zoom);
+    }
+    menu.addSeparator();
+    menu.addItem (tr ("Snap notes to the scale"), scaleIndex() > 0, scaleSnap, [this] { setScaleSnap (! scaleSnap); });
+    menu.addItem (tr ("Move the notes onto the scale"), scaleIndex() > 0, false, [this] {
+        const auto root = scaleRoot(), scale = scaleIndex();
+        runOperation ([root, scale] (Pattern& p, const std::vector<int>& t) { notetools::snapNotesToScale (p, t, root, scale); return t; });
+    });
+    menu.addSeparator();
     menu.addItem (tr ("Resize notes from the left edge too") + "\tCtrl+Alt+Home", true, resizeFromLeft, [this] { resizeFromLeft = ! resizeFromLeft; });
     menu.addSeparator();
     menu.addSubMenu ("MIDI", midiMenu());
     menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (&moreButton));
 }
 
+juce::PopupMenu PianoRollComponent::toolsMenu()
+{
+    juce::PopupMenu menu;
+    const std::pair<NoteTool, const char*> items[] = { { NoteTool::arpeggiate, "Alt+A" }, { NoteTool::strum, "Alt+S" },
+                                                       { NoteTool::flip, "Alt+Y" },       { NoteTool::randomise, "Alt+R" },
+                                                       { NoteTool::scaleLevels, "Alt+X" }, { NoteTool::limit, "Alt+K" } };
+
+    for (const auto& [tool, key] : items)
+        menu.addItem (tr (noteToolTitle (tool)) + "...\t" + key, [this, tool = tool] { openNoteTool (tool); });
+
+    return menu;
+}
+
+void PianoRollComponent::openNoteTool (NoteTool tool)
+{
+    const auto target = selectionOrAll();
+
+    if (target.empty())
+        return;
+
+    showNoteTool (engine, tool, target, gridTicks(), [safe = juce::Component::SafePointer<PianoRollComponent> (this)] {
+        if (safe != nullptr)
+            safe->setSelection ({});
+    });
+}
+
+void PianoRollComponent::zoomAroundCentre (double factor)
+{
+    const auto grid = gridArea();
+    const auto centre = xToTick (grid.getCentreX());
+    pixelsPerTick = juce::jlimit (2.0 / ticksPerStep, 120.0 / ticksPerStep, pixelsPerTick * factor);
+    scrollTicks = juce::jmax (0.0, centre - (grid.getCentreX() - keyboardWidth) / pixelsPerTick);
+    updateScrollBars();
+    repaint();
+}
+
+void PianoRollComponent::zoomToBars (int bars)
+{
+    const auto bar = (double) ppq * juce::jmax (1, engine.getSong().beatsPerBar);
+    const auto from = std::floor (scrollTicks / bar) * bar;
+    zoomToTicks (from, from + bars * bar);
+}
+
+void PianoRollComponent::zoomAll()
+{
+    const auto& song = engine.getSong();
+    zoomToTicks (0.0, (double) currentPattern (song).effectiveLength (song.beatsPerBar));
+}
+
+void PianoRollComponent::zoomToSelection()
+{
+    const auto target = selectionOrAll();
+
+    if (target.empty())
+        return zoomAll();
+
+    const auto& notes = currentPattern (engine.getSong()).notes;
+    std::int64_t from = INT64_MAX, to = 0;
+    int low = 127, high = 0;
+
+    for (auto i : target)
+    {
+        const auto& n = notes[(std::size_t) i];
+        from = juce::jmin (from, n.start);
+        to = juce::jmax (to, n.start + n.length);
+        low = juce::jmin (low, n.key);
+        high = juce::jmax (high, n.key);
+    }
+
+    const auto margin = (double) ticksPerStep;
+    zoomToTicks (juce::jmax (0.0, (double) from - margin), (double) to + margin);
+    scrollY = juce::jmax (0, (127 - (low + high) / 2) * rowHeight - gridArea().getHeight() / 2);
+    updateScrollBars();
+    repaint();
+}
+
+void PianoRollComponent::centreOnPlayhead()
+{
+    const auto& song = engine.getSong();
+    const auto length = (double) juce::jmax<std::int64_t> (1, currentPattern (song).effectiveLength (song.beatsPerBar));
+    const auto tick = std::fmod (engine.getTransport().positionTicks.load(), length);
+    scrollTicks = juce::jmax (0.0, tick - gridArea().getWidth() / pixelsPerTick / 2.0);
+    updateScrollBars();
+    repaint();
+}
+
+bool PianoRollComponent::runAction (const std::string& id)
+{
+    auto is = [&id] (const char* name) { return id == name; };
+
+    if (is ("pianoRoll.arpeggiate")) openNoteTool (NoteTool::arpeggiate);
+    else if (is ("pianoRoll.strum")) openNoteTool (NoteTool::strum);
+    else if (is ("pianoRoll.flip")) openNoteTool (NoteTool::flip);
+    else if (is ("pianoRoll.randomise")) openNoteTool (NoteTool::randomise);
+    else if (is ("pianoRoll.scaleLevels")) openNoteTool (NoteTool::scaleLevels);
+    else if (is ("pianoRoll.limit")) openNoteTool (NoteTool::limit);
+    else if (is ("pianoRoll.zoomIn")) zoomAroundCentre (1.25);
+    else if (is ("pianoRoll.zoomOut")) zoomAroundCentre (1.0 / 1.25);
+    else if (is ("pianoRoll.zoom1")) zoomToBars (1);
+    else if (is ("pianoRoll.zoom2")) zoomToBars (4);
+    else if (is ("pianoRoll.zoom3")) zoomToBars (16);
+    else if (is ("pianoRoll.zoomAll")) zoomAll();
+    else if (is ("pianoRoll.zoomSelection")) zoomToSelection();
+    else if (is ("pianoRoll.centrePlayhead")) centreOnPlayhead();
+    else
+        return false;
+
+    return true;
+}
+
 void PianoRollComponent::mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& wheel)
 {
-    if (e.mods.isCtrlDown())
+    if (e.mods.isCtrlDown() && e.mods.isAltDown())
+    {
+        // vertical zoom keeping the key under the mouse in place
+        const auto key = yToKey (e.y);
+        const auto offset = e.y - keyToY (key);
+        rowHeight = juce::jlimit (6, 32, rowHeight + (wheel.deltaY > 0 ? 2 : -2));
+        scrollY = juce::jmax (0, (127 - key) * rowHeight + offset - (e.y - headerHeight));
+    }
+    else if (e.mods.isCtrlDown())
     {
         // zoom keeping the tick under the mouse in place
         const auto anchor = xToTick (e.x);

+ 30 - 2
src/ui/PianoRollComponent.h

@@ -4,6 +4,7 @@
 
 #include "engine/AudioEngine.h"
 #include "ui/EditorTools.h"
+#include "ui/NoteToolDialogs.h"
 
 namespace lynx
 {
@@ -44,6 +45,17 @@ public:
     // Editing shortcuts; the main window forwards keys when the Piano Roll is visible.
     bool handleKey (const juce::KeyPress& key);
 
+    // The key map's pianoRoll.* actions (tool dialogs, zoom presets). Returns false for unknown ids.
+    bool runAction (const std::string& id);
+
+    // Note tool dialogs on the selection (or all of the channel's notes).
+    void openNoteTool (NoteTool tool);
+
+    // Scale snap: new and moved notes (and incoming MIDI) land on the highlighted scale.
+    bool isScaleSnapOn() const noexcept { return scaleSnap; }
+    void setScaleSnap (bool on);
+    bool hasScale() const { return scaleIndex() > 0; } // a scale is chosen in the toolbar
+
     // Centers the view on the channel's notes (called on open).
     void scrollToNotes();
 
@@ -53,17 +65,19 @@ public:
     // For snapshots: the tool in use and the Note inspector of the selection.
     void setToolForSnapshot (EditTool tool) { tools.setTool (tool); }
     std::unique_ptr<juce::Component> makeNoteInspectorForSnapshot (bool singleNote = false);
+    std::vector<int> noteIndicesForSnapshot() const { return selectionOrAll(); }
+    std::int64_t gridForSnapshot() const { return gridTicks(); }
 
     static constexpr int keyboardWidth = 64;
     static constexpr int toolbarHeight = 28;
     static constexpr int timelineHeight = 22;
     static constexpr int headerHeight = toolbarHeight + timelineHeight;
     static constexpr int velocityHeight = 72;
-    static constexpr int rowHeight = 14;
+    int rowHeight = 14; // vertical zoom (Ctrl+Alt+wheel): 6..32 px per key
     static constexpr int scrollBarSize = 12;
 
 private:
-    enum class Drag { none, move, resize, resizeLeft, erase, keyboard, select, velocity, paint, muting, knife, zoomRange, listen };
+    enum class Drag { none, move, resize, resizeLeft, erase, keyboard, select, velocity, paint, muting, knife, zoomRange, listen, pan };
 
     // Channel selector: the wheel steps through the channels with notes (Ctrl+wheel: all channels).
     class ChannelBox final : public juce::ComboBox
@@ -135,6 +149,7 @@ private:
     ChannelBox channelBox;
     juce::ComboBox snapBox;           // "Follow global grid" or this editor's own grid
     IconButton ghostButton { "ghosts", Icon::ghost };
+    IconButton scaleSnapButton { "scaleSnap", Icon::magnet }; // snap to the scale (next to the scale box)
     IconButton moreButton { "more", Icon::more }; // note operations, left-edge resize, MIDI import/export
     juce::ComboBox laneBox; // what the bottom lane edits: velocity, pan or fine pitch
     juce::ComboBox chordBox; // chord created on each click (like FL's "stamp")
@@ -142,6 +157,19 @@ private:
     juce::ComboBox scaleBox; // scale highlighted on the keyboard rows
     std::vector<int> chordIntervals() const;
     bool inScale (int key) const;
+    int scaleRoot() const;  // 0..11
+    int scaleIndex() const; // index into notetools::scales(), 0 = none
+    int snapKey (int key) const; // the key itself, or the nearest in-scale key while scale snap is on
+    void publishScale();
+    bool scaleSnap = false;
+    double panStartTicks = 0.0;
+    int panStartY = 0;
+    void zoomAroundCentre (double factor);
+    void zoomToBars (int bars);
+    void zoomToSelection();
+    void zoomAll();
+    void centreOnPlayhead();
+    juce::PopupMenu toolsMenu();
     std::unique_ptr<juce::FileChooser> chooser;
     juce::PopupMenu midiMenu();
     juce::Label hintLabel;

+ 434 - 10
src/ui/PlaylistComponent.cpp

@@ -1,5 +1,7 @@
 #include "ui/PlaylistComponent.h"
 
+#include "core/RackOps.h"
+
 #include "core/NoteEdit.h"
 #include "engine/Text.h"
 #include "ui/BrowserComponent.h"
@@ -631,6 +633,22 @@ const std::vector<float>* PlaylistComponent::waveformFor (const std::string& pat
     return peaks.empty() ? nullptr : &peaks;
 }
 
+void PlaylistComponent::paintOverChildren (juce::Graphics& g)
+{
+    if (! ripple)
+        return;
+
+    // ripple editing is on: a small tag in the grid's top-right corner
+    const auto grid = gridArea();
+    const auto tag = juce::Rectangle<float> ((float) grid.getRight() - 70.0f, (float) grid.getY() + 4.0f, 64.0f, 18.0f);
+    g.setColour (theme::colour::accentMuted);
+    g.fillRoundedRectangle (tag, theme::radius::sm);
+    g.setColour (theme::colour::accent);
+    g.drawRoundedRectangle (tag.reduced (0.5f), theme::radius::sm, 1.0f);
+    g.setFont (theme::font (theme::type::caption, true));
+    g.drawText (tr ("Ripple"), tag.toNearestInt(), juce::Justification::centred);
+}
+
 void PlaylistComponent::paintAudioClip (juce::Graphics& g, const Clip& c, juce::Rectangle<float> r)
 {
     const auto& song = engine.getSong();
@@ -729,6 +747,75 @@ void PlaylistComponent::paintAutomationClip (juce::Graphics& g, const Clip& c, j
 
     g.setColour (automation.target.kind == AutomationTargetKind::none ? theme::colour::textSecondary : theme::colour::automation.brighter (0.3f));
     g.strokePath (curve, juce::PathStrokeType (1.5f));
+
+    // the points inside the clip, as handles (edited right here)
+    if (r.getWidth() > 24.0f)
+        for (const auto& p : automation.points)
+        {
+            const auto songTick = (double) (c.start + p.tick - c.offset);
+            if (songTick < (double) c.start || songTick > (double) c.end())
+                continue;
+            const auto x = (float) tickToX (songTick);
+            const auto y = body.getBottom() - p.value * body.getHeight();
+            g.setColour (theme::colour::bg0);
+            g.fillEllipse (x - 3.5f, y - 3.5f, 7.0f, 7.0f);
+            g.setColour (theme::colour::automation.brighter (0.5f));
+            g.fillEllipse (x - 2.5f, y - 2.5f, 5.0f, 5.0f);
+        }
+}
+
+juce::Rectangle<float> PlaylistComponent::automationBody (const Clip& c) const
+{
+    const auto x0 = (float) tickToX ((double) c.start), x1 = (float) tickToX ((double) c.end());
+    const auto y = (float) trackToY (c.track);
+    const auto r = juce::Rectangle<float> (x0, y + 1.0f, juce::jmax (3.0f, x1 - x0 - 1.0f), (float) trackHeight - 3.0f);
+    return r.withTrimmedTop (14.0f).reduced (1.0f, 2.0f);
+}
+
+int PlaylistComponent::automationPointAt (int clip, juce::Point<int> pos) const
+{
+    const auto& song = engine.getSong();
+
+    if (clip < 0 || clip >= (int) song.playlist.size() || song.playlist[(std::size_t) clip].kind != ClipKind::automation)
+        return -1;
+
+    const auto& c = song.playlist[(std::size_t) clip];
+    if (c.automation < 0 || c.automation >= (int) song.automations.size())
+        return -1;
+
+    const auto body = automationBody (c);
+    const auto& points = song.automations[(std::size_t) c.automation].points;
+
+    for (int i = (int) points.size() - 1; i >= 0; --i)
+    {
+        const auto songTick = (double) (c.start + points[(std::size_t) i].tick - c.offset);
+        if (songTick < (double) c.start || songTick > (double) c.end())
+            continue;
+        const juce::Point<float> at ((float) tickToX (songTick), body.getBottom() - points[(std::size_t) i].value * body.getHeight());
+        if (at.getDistanceFrom (pos.toFloat()) <= 6.0f)
+            return i;
+    }
+
+    return -1;
+}
+
+bool PlaylistComponent::isOnAutomationCurve (int clip, juce::Point<int> pos) const
+{
+    const auto& song = engine.getSong();
+
+    if (clip < 0 || clip >= (int) song.playlist.size() || song.playlist[(std::size_t) clip].kind != ClipKind::automation)
+        return false;
+
+    const auto& c = song.playlist[(std::size_t) clip];
+    if (c.automation < 0 || c.automation >= (int) song.automations.size())
+        return false;
+
+    const auto body = automationBody (c);
+    if (! body.expanded (0.0f, 4.0f).contains (pos.toFloat()))
+        return false;
+
+    const auto value = song.automations[(std::size_t) c.automation].valueAt ((double) c.offset + xToTick (pos.x) - (double) c.start);
+    return std::abs (body.getBottom() - value * body.getHeight() - (float) pos.y) <= 5.0f;
 }
 
 int PlaylistComponent::fadeHandleAt (int index, juce::Point<int> p) const
@@ -872,13 +959,22 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
     downMods = e.mods;
     startedOnEmpty = erasedSomething = holdExpired = false;
 
+    if (e.mods.isMiddleButtonDown() && e.x >= headerWidth) // middle-drag pans, in every tool
+    {
+        drag = Drag::pan;
+        panStartTicks = scrollTicks;
+        panStartY = scrollY;
+        setMouseCursor (juce::MouseCursor::DraggingHandCursor);
+        return;
+    }
+
     // track header: LED mutes; right click renames
     if (e.x < headerWidth && e.y >= headerHeight && e.y < gridArea().getBottom())
     {
         const auto track = yToTrack (e.y);
 
         if (e.mods.isPopupMenu())
-            renameTrack (track);
+            showTrackMenu (track);
         else if (e.x < 20)
             engine.editSong ([track] (Song& s) {
                 if ((int) s.playlistTracks.size() <= track)
@@ -905,6 +1001,19 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
 
         loopAnchor = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), ! e.mods.isAltDown()));
 
+        // Shift+drag inside the time selection moves it with what it holds (Ctrl+Shift: a copy)
+        if (const auto& song = engine.getSong(); e.mods.isShiftDown() && song.hasLoop() && xToTick (e.x) >= (double) song.loopStart
+                                                    && xToTick (e.x) < (double) song.loopEnd)
+        {
+            drag = Drag::timeMove;
+            timeMoveOriginals = song.playlist;
+            timeMoveFrom = song.loopStart;
+            timeMoveTo = song.loopEnd;
+            timeMoveAnchor = loopAnchor;
+            timeMoveCopy = e.mods.isCtrlDown();
+            return;
+        }
+
         if (e.mods.isCtrlDown())
         {
             drag = Drag::loop;
@@ -925,6 +1034,18 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
 
     if (e.mods.isRightButtonDown())
     {
+        // on an automation point: delete that point
+        if (const auto point = automationPointAt (hit, e.getPosition()); point >= 0)
+        {
+            const auto automation = engine.getSong().playlist[(std::size_t) hit].automation;
+            engine.editSong ([automation, point] (Song& s) {
+                auto& points = s.automations[(std::size_t) automation].points;
+                if (points.size() > 1 && point < (int) points.size())
+                    points.erase (points.begin() + point);
+            });
+            return;
+        }
+
         // on the name strip: clip menu; on the body: delete (press and hold on empty space: Knife)
         if (hit >= 0 && e.y < trackToY (engine.getSong().playlist[(std::size_t) hit].track) + 15)
         {
@@ -932,13 +1053,28 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
             return;
         }
 
+        // double right-click on a clip: the first click deleted it; bring it back muted (or unmuted)
+        if (e.getNumberOfClicks() >= 2 && lastClipEraseTime != 0 && lastClipErasePos.getDistanceFrom (e.getPosition()) < 6
+            && juce::Time::getMillisecondCounter() - lastClipEraseTime < 1000)
+        {
+            lastClipEraseTime = 0;
+            engine.undo();
+            bool r = false, l = false;
+            if (const auto clip = clipAt (e.x, e.y, r, l); clip >= 0)
+                engine.editSong ([clip] (Song& s) { s.playlist[(std::size_t) clip].muted = ! s.playlist[(std::size_t) clip].muted; });
+            return;
+        }
+
         drag = Drag::erase;
         startedOnEmpty = hit < 0;
         setSelection ({}); // indices change while deleting
+        lastClipEraseTime = 0;
 
         if (hit >= 0)
         {
             erasedSomething = true;
+            lastClipEraseTime = juce::Time::getMillisecondCounter();
+            lastClipErasePos = e.getPosition();
             engine.editSong ([hit] (Song& s) { s.playlist.erase (s.playlist.begin() + hit); });
         }
         return;
@@ -1036,6 +1172,36 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
             break;
     }
 
+    // automation clip: drag a point, or click on the curve to add one (Pencil and Brush)
+    if (hit >= 0 && ! e.mods.isShiftDown() && (tool == EditTool::pencil || tool == EditTool::brush))
+    {
+        auto point = automationPointAt (hit, e.getPosition());
+
+        if (point < 0 && isOnAutomationCurve (hit, e.getPosition()))
+        {
+            const auto& c = engine.getSong().playlist[(std::size_t) hit];
+            AutomationPoint p;
+            p.tick = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), snapOn) - c.start + c.offset);
+            const auto body = automationBody (c);
+            p.value = juce::jlimit (0.0f, 1.0f, (body.getBottom() - (float) e.y) / juce::jmax (1.0f, body.getHeight()));
+            engine.editSong ([a = c.automation, p] (Song& s) {
+                auto& points = s.automations[(std::size_t) a].points;
+                points.push_back (p);
+                std::stable_sort (points.begin(), points.end(), [] (auto& l, auto& r) { return l.tick < r.tick; });
+            });
+            point = automationPointAt (hit, e.getPosition());
+        }
+
+        if (point >= 0)
+        {
+            setSelection ({});
+            drag = Drag::autoPoint;
+            autoClip = hit;
+            autoPoint = point;
+            return;
+        }
+    }
+
     // audio clip fade handles (drawn at the top corners of the body)
     if (hit >= 0)
         if (const auto fade = fadeHandleAt (hit, e.getPosition()); fade != 0)
@@ -1084,6 +1250,15 @@ void PlaylistComponent::mouseDown (const juce::MouseEvent& e)
     if (hit >= 0)
     {
         grabClips (rightEdge ? Drag::resize : leftEdge ? Drag::trimLeft : Drag::move);
+
+        if (drag == Drag::resize && ripple)
+        {
+            setSelection ({}); // a ripple resize works on the grabbed clip only
+            dragIndices = { hit };
+            dragOriginals = { engine.getSong().playlist[(std::size_t) hit] };
+            rippleOriginals = engine.getSong().playlist;
+        }
+
         const auto& c = engine.getSong().playlist[(std::size_t) hit];
 
         if (c.kind == ClipKind::pattern && c.pattern != engine.getSong().currentPattern)
@@ -1127,6 +1302,61 @@ void PlaylistComponent::mouseDrag (const juce::MouseEvent& e)
         case Drag::none:
             return;
 
+        case Drag::pan:
+            scrollTicks = juce::jmax (0.0, panStartTicks - e.getDistanceFromDragStartX() / pixelsPerTick);
+            scrollY = juce::jmax (0, panStartY - e.getDistanceFromDragStartY());
+            updateScrollBars();
+            repaint();
+            return;
+
+        case Drag::autoPoint:
+        {
+            const auto& song = engine.getSong();
+            if (autoClip < 0 || autoClip >= (int) song.playlist.size())
+                return;
+            const auto& c = song.playlist[(std::size_t) autoClip];
+            if (c.automation < 0 || c.automation >= (int) song.automations.size())
+                return;
+            const auto& points = song.automations[(std::size_t) c.automation].points;
+            if (autoPoint < 0 || autoPoint >= (int) points.size())
+                return;
+
+            // the point stays between its neighbours; Shift pressed after the click keeps the time, Ctrl the value
+            auto tick = snap (xToTick (e.x), snapOn) - c.start + c.offset;
+            const auto lo = autoPoint > 0 ? points[(std::size_t) autoPoint - 1].tick : 0;
+            const auto hi = autoPoint + 1 < (int) points.size() ? points[(std::size_t) autoPoint + 1].tick : std::numeric_limits<std::int64_t>::max();
+            tick = juce::jlimit (lo, hi, tick);
+            const auto body = automationBody (c);
+            auto value = juce::jlimit (0.0f, 1.0f, (body.getBottom() - (float) e.y) / juce::jmax (1.0f, body.getHeight()));
+
+            if (e.mods.isShiftDown() && ! downMods.isShiftDown())
+                tick = points[(std::size_t) autoPoint].tick;
+            if (e.mods.isCtrlDown() && ! downMods.isCtrlDown())
+                value = points[(std::size_t) autoPoint].value;
+
+            engine.editSong ([a = c.automation, i = autoPoint, tick, value] (Song& s) {
+                auto& p = s.automations[(std::size_t) a].points[(std::size_t) i];
+                p.tick = tick;
+                p.value = value;
+            });
+            return;
+        }
+
+        case Drag::timeMove:
+        {
+            const auto here = juce::jmax<std::int64_t> (0, snap (xToTick (e.x), snapOn));
+            const auto delta = juce::jmax (-timeMoveFrom, here - timeMoveAnchor);
+            std::vector<int> moved;
+            engine.editSong ([&] (Song& s) {
+                s.playlist = timeMoveOriginals;
+                moved = noteedit::moveTimeRange (s.playlist, timeMoveFrom, timeMoveTo, delta, timeMoveCopy);
+                s.loopStart = timeMoveFrom + delta;
+                s.loopEnd = timeMoveTo + delta;
+            });
+            setSelection (moved);
+            return;
+        }
+
         case Drag::seek:
         case Drag::listen:
             seekTo (e.x);
@@ -1318,6 +1548,15 @@ void PlaylistComponent::mouseDrag (const juce::MouseEvent& e)
             if (engine.getSong().playlist[(std::size_t) dragClip].length == grabbed.length + delta)
                 return;
 
+            if (ripple && ! rippleOriginals.empty()) // the later clips on the track follow the end
+            {
+                engine.editSong ([this, length = juce::jmax (minimum, grabbed.length + delta)] (Song& s) {
+                    s.playlist = rippleOriginals;
+                    noteedit::rippleResize (s.playlist, dragClip, length);
+                });
+                return;
+            }
+
             engine.editSong ([this, delta, minimum] (Song& s) {
                 for (std::size_t j = 0; j < dragIndices.size(); ++j)
                 {
@@ -1387,9 +1626,16 @@ void PlaylistComponent::mouseUp (const juce::MouseEvent& e)
     if (drag == Drag::listen)
         engine.stop();
 
-    if (drag == Drag::move || drag == Drag::resize || drag == Drag::trimLeft || drag == Drag::paint)
+    if (drag == Drag::pan)
+        setMouseCursor (juce::MouseCursor::NormalCursor);
+
+    if (drag == Drag::move || drag == Drag::resize || drag == Drag::trimLeft || drag == Drag::paint || drag == Drag::timeMove)
         sortClips();
 
+    rippleOriginals.clear();
+    timeMoveOriginals.clear();
+    autoClip = autoPoint = -1;
+
     drag = Drag::none;
     dragClip = -1;
     dragIndices.clear();
@@ -1492,6 +1738,43 @@ void PlaylistComponent::deleteTimeSelection()
     sortClips();
 }
 
+void PlaylistComponent::showTrackMenu (int track)
+{
+    const auto& song = engine.getSong();
+    const auto muted = song.isTrackMuted (track);
+    const auto count = numTracks();
+    juce::PopupMenu menu;
+    menu.addSectionHeader (track < (int) song.playlistTracks.size() && ! song.playlistTracks[(std::size_t) track].name.empty()
+                               ? juce::String::fromUTF8 (song.playlistTracks[(std::size_t) track].name.c_str())
+                               : tr ("Track {0}", { juce::String (track + 1) }));
+    menu.addItem (tr ("Rename..."), [this, track] { renameTrack (track); });
+    menu.addItem (muted ? tr ("Unmute") : tr ("Mute"), [this, track] {
+        engine.editSong ([track] (Song& s) {
+            if ((int) s.playlistTracks.size() <= track)
+                s.playlistTracks.resize ((std::size_t) track + 1);
+            s.playlistTracks[(std::size_t) track].muted = ! s.playlistTracks[(std::size_t) track].muted;
+        });
+    });
+    menu.addItem (tr ("Solo (mute the other tracks)"), [this, track, count] { engine.editSong ([track, count] (Song& s) { noteedit::soloTrack (s, track, count); }); });
+    menu.addSeparator();
+    menu.addItem (tr ("Insert a track above"), [this, track] {
+        setSelection ({});
+        engine.editSong ([track] (Song& s) { noteedit::insertTrack (s, track); });
+    });
+    menu.addItem (tr ("Insert a track below"), [this, track] {
+        setSelection ({});
+        engine.editSong ([track] (Song& s) { noteedit::insertTrack (s, track + 1); });
+    });
+    menu.addItem (tr ("Move up"), track > 0, false, [this, track] { engine.editSong ([track] (Song& s) { noteedit::swapTracks (s, track, track - 1); }); });
+    menu.addItem (tr ("Move down"), [this, track] { engine.editSong ([track] (Song& s) { noteedit::swapTracks (s, track, track + 1); }); });
+    menu.addSeparator();
+    menu.addItem (tr ("Delete the track and its clips"), [this, track] {
+        setSelection ({});
+        engine.editSong ([track] (Song& s) { noteedit::removeTrack (s, track); });
+    });
+    menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+}
+
 void PlaylistComponent::renameTrack (int track)
 {
     const auto& tracks = engine.getSong().playlistTracks;
@@ -1553,6 +1836,21 @@ void PlaylistComponent::showRulerMenu (int x)
         menu.addItem (tr ("Remove loop"), [this] { engine.editSong ([] (Song& s) { s.loopStart = s.loopEnd = 0; }, false); });
     }
 
+    menu.addSeparator();
+    menu.addItem (tr ("Ripple editing (resizing and deleting move the later clips)") + "\tShift+S", true, ripple, [this] { setRipple (! ripple); });
+    {
+        juce::PopupMenu zoom;
+        zoom.addItem (tr ("Zoom in") + "\tPageUp", [this] { runAction ("playlist.zoomIn"); });
+        zoom.addItem (tr ("Zoom out") + "\tPageDown", [this] { runAction ("playlist.zoomOut"); });
+        zoom.addItem (tr ("Zoom: one bar") + "\tShift+1", [this] { runAction ("playlist.zoom1"); });
+        zoom.addItem (tr ("Zoom: four bars") + "\tShift+2", [this] { runAction ("playlist.zoom2"); });
+        zoom.addItem (tr ("Zoom: sixteen bars") + "\tShift+3", [this] { runAction ("playlist.zoom3"); });
+        zoom.addItem (tr ("Zoom to show everything") + "\tShift+4", [this] { runAction ("playlist.zoomAll"); });
+        zoom.addItem (tr ("Zoom to the selection") + "\tShift+5", [this] { runAction ("playlist.zoomSelection"); });
+        zoom.addItem (tr ("Centre the view on the playhead") + "\tShift+0", [this] { runAction ("playlist.centrePlayhead"); });
+        menu.addSubMenu (tr ("Zoom"), zoom);
+    }
+
     menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
 }
 
@@ -1599,6 +1897,22 @@ void PlaylistComponent::showClipMenu (int index)
             sortClips();
         });
 
+    menu.addItem (clip.muted ? tr ("Unmute") : tr ("Mute"), [this, targets, m = ! clip.muted] {
+        engine.editSong ([targets, m] (Song& s) {
+            for (auto i : targets)
+                if (i < (int) s.playlist.size())
+                    s.playlist[(std::size_t) i].muted = m;
+        });
+    });
+    menu.addItem (tr ("Chop to grid"), [this, targets, grid = gridTicks()] {
+        setSelection ({});
+        engine.editSong ([targets, grid] (Song& s) {
+            for (auto i : targets)
+                noteedit::chopClip (s.playlist, i, grid);
+        });
+        sortClips();
+    });
+
     if (clip.kind == ClipKind::pattern)
     {
         menu.addSectionHeader (juce::String::fromUTF8 (engine.getSong().patterns[(std::size_t) clip.pattern].name.c_str()));
@@ -1642,6 +1956,10 @@ void PlaylistComponent::showClipMenu (int index)
             if (onOpenPattern)
                 onOpenPattern();
         });
+        menu.addItem (tr ("Open in Piano Roll"), [this] {
+            if (onOpenPianoRoll)
+                onOpenPianoRoll();
+        });
     }
 
     if (clip.kind == ClipKind::audio)
@@ -1744,6 +2062,99 @@ void PlaylistComponent::showClipMenu (int index)
     menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
 }
 
+void PlaylistComponent::setRipple (bool on)
+{
+    ripple = on;
+    repaint();
+}
+
+void PlaylistComponent::rippleDeleteSelection()
+{
+    if (selection.empty())
+        return;
+
+    auto doomed = selection;
+    setSelection ({});
+    engine.editSong ([&doomed] (Song& s) { noteedit::rippleDelete (s.playlist, doomed); });
+}
+
+void PlaylistComponent::zoomAroundCentre (double factor)
+{
+    const auto grid = gridArea();
+    const auto centre = xToTick (grid.getCentreX());
+    pixelsPerTick = juce::jlimit (4.0 / (4 * ppq), 800.0 / (4 * ppq), pixelsPerTick * factor);
+    scrollTicks = juce::jmax (0.0, centre - (grid.getCentreX() - headerWidth) / pixelsPerTick);
+    updateScrollBars();
+    repaint();
+}
+
+void PlaylistComponent::zoomToBars (int bars)
+{
+    const auto bar = (double) ppq * juce::jmax (1, engine.getSong().beatsPerBar);
+    const auto from = std::floor (scrollTicks / bar) * bar;
+    zoomToTicks (from, from + bars * bar);
+}
+
+void PlaylistComponent::zoomAll()
+{
+    zoomToTicks (0.0, (double) engine.getSong().songLength());
+}
+
+void PlaylistComponent::zoomToSelection()
+{
+    const auto& song = engine.getSong();
+
+    if (song.hasLoop() && selection.empty())
+        return zoomToTicks ((double) song.loopStart, (double) song.loopEnd);
+
+    if (selection.empty())
+        return zoomAll();
+
+    std::int64_t from = INT64_MAX, to = 0;
+    int top = 1 << 20;
+    for (auto i : selection)
+        if (i >= 0 && i < (int) song.playlist.size())
+        {
+            from = juce::jmin (from, song.playlist[(std::size_t) i].start);
+            to = juce::jmax (to, song.playlist[(std::size_t) i].end());
+            top = juce::jmin (top, song.playlist[(std::size_t) i].track);
+        }
+
+    zoomToTicks ((double) from, (double) to);
+    scrollY = juce::jmax (0, top * trackHeight);
+    updateScrollBars();
+    repaint();
+}
+
+void PlaylistComponent::centreOnPlayhead()
+{
+    const auto& song = engine.getSong();
+    const auto tick = std::fmod (engine.getTransport().positionTicks.load(), (double) juce::jmax<std::int64_t> (1, song.songLength()));
+    scrollTicks = juce::jmax (0.0, tick - gridArea().getWidth() / pixelsPerTick / 2.0);
+    updateScrollBars();
+    repaint();
+}
+
+bool PlaylistComponent::runAction (const std::string& id)
+{
+    auto is = [&id] (const char* name) { return id == name; };
+
+    if (is ("playlist.zoomIn")) zoomAroundCentre (1.25);
+    else if (is ("playlist.zoomOut")) zoomAroundCentre (1.0 / 1.25);
+    else if (is ("playlist.zoom1")) zoomToBars (1);
+    else if (is ("playlist.zoom2")) zoomToBars (4);
+    else if (is ("playlist.zoom3")) zoomToBars (16);
+    else if (is ("playlist.zoomAll")) zoomAll();
+    else if (is ("playlist.zoomSelection")) zoomToSelection();
+    else if (is ("playlist.centrePlayhead")) centreOnPlayhead();
+    else if (is ("playlist.rippleDelete")) rippleDeleteSelection();
+    else if (is ("playlist.ripple")) setRipple (! ripple);
+    else
+        return false;
+
+    return true;
+}
+
 void PlaylistComponent::deleteSelection()
 {
     if (selection.empty())
@@ -1881,9 +2292,12 @@ bool PlaylistComponent::handleKey (const juce::KeyPress& key)
         return true;
     }
 
-    if (code == juce::KeyPress::deleteKey)
+    if (code == juce::KeyPress::deleteKey && ! mods.isShiftDown())
     {
-        deleteSelection();
+        if (ripple)
+            rippleDeleteSelection();
+        else
+            deleteSelection();
         return true;
     }
 
@@ -1977,8 +2391,19 @@ void PlaylistComponent::mouseDoubleClick (const juce::MouseEvent& e)
 
     if (clip.kind == ClipKind::automation)
         openAutomationEditor (engine, clip.automation);
-    else if (clip.kind == ClipKind::pattern && onOpenPattern)
-        onOpenPattern();
+    else if (clip.kind == ClipKind::pattern)
+    {
+        auto pianoRoll = editPatternsIn == 2
+                         || (editPatternsIn == 0 && clip.pattern < (int) engine.getSong().patterns.size()
+                             && hasPianoRollNotes (engine.getSong().patterns[(std::size_t) clip.pattern]));
+        if (e.mods.isAltDown())
+            pianoRoll = ! pianoRoll;
+
+        if (pianoRoll && onOpenPianoRoll)
+            onOpenPianoRoll();
+        else if (! pianoRoll && onOpenPattern)
+            onOpenPattern();
+    }
 }
 
 bool PlaylistComponent::isInterestedInFileDrag (const juce::StringArray& files)
@@ -2122,14 +2547,13 @@ void PlaylistComponent::timerCallback()
 
 bool PlaylistComponent::isInterestedInDragSource (const SourceDetails& details)
 {
-    return details.description.toString() == BrowserComponent::dragDescription;
+    return BrowserComponent::isBrowserDrag (details);
 }
 
 void PlaylistComponent::itemDropped (const SourceDetails& details)
 {
-    if (auto* tree = dynamic_cast<juce::FileTreeComponent*> (details.sourceComponent.get()))
-        if (tree->getSelectedFile().existsAsFile())
-            filesDropped ({ tree->getSelectedFile().getFullPathName() }, details.localPosition.x, details.localPosition.y);
+    if (const auto file = BrowserComponent::draggedFile (details); file.existsAsFile())
+        filesDropped ({ file.getFullPathName() }, details.localPosition.x, details.localPosition.y);
 }
 // ---------------------------------------------------------------------------
 

+ 37 - 1
src/ui/PlaylistComponent.h

@@ -52,8 +52,14 @@ public:
     ~PlaylistComponent() override;
 
     std::function<void()> onOpenPattern;
+    std::function<void()> onOpenPianoRoll;
+
+    // Double-click on a pattern clip opens it in: 0 = the Piano Roll when it has piano-roll notes, else the
+    // Channel Rack; 1 = always the Channel Rack; 2 = always the Piano Roll. Alt+double-click opens the other one.
+    static inline int editPatternsIn = 0;
 
     void paint (juce::Graphics& g) override;
+    void paintOverChildren (juce::Graphics& g) override;
     void resized() override;
     void setTitleBarInsets (int left, int right) override;
     void mouseDown (const juce::MouseEvent& e) override;
@@ -66,6 +72,14 @@ public:
     // Editing shortcuts; the main window forwards keys when the Playlist is visible.
     bool handleKey (const juce::KeyPress& key);
 
+    // The key map's playlist.* actions (zoom presets, ripple editing). False for unknown ids.
+    bool runAction (const std::string& id);
+
+    // Ripple editing: resizing a clip's end moves the later clips on its track, deleting closes the gap.
+    bool isRippleOn() const noexcept { return ripple; }
+    void setRipple (bool on);
+    void rippleDeleteSelection();
+
     // dragging audio files creates audio clips (and a channel for each)
     bool isInterestedInFileDrag (const juce::StringArray& files) override;
     void filesDropped (const juce::StringArray& files, int x, int y) override;
@@ -88,7 +102,7 @@ public:
     static juce::Colour patternColour (const Song& song, int pattern);
 
 private:
-    enum class Drag { none, move, resize, trimLeft, slip, erase, seek, loop, select, fadeIn, fadeOut, paint, muting, knife, zoomRange, listen };
+    enum class Drag { none, move, resize, trimLeft, slip, erase, seek, loop, select, fadeIn, fadeOut, paint, muting, knife, zoomRange, listen, pan, timeMove, autoPoint };
 
     void changeListenerCallback (juce::ChangeBroadcaster*) override;
     void timerCallback() override;
@@ -138,6 +152,7 @@ private:
     void arrangementChosen();
     void renameArrangement();
     void renameTrack (int track);
+    void showTrackMenu (int track);
 
     AudioEngine& engine;
     juce::ScrollBar hBar { false }, vBar { true };
@@ -168,6 +183,27 @@ private:
     std::int64_t grabOffset = 0;
     double playheadTick = -1.0;
 
+    // workflow P2
+    bool ripple = false;
+    std::vector<Clip> rippleOriginals;   // the whole playlist when a ripple resize starts
+    double panStartTicks = 0.0;
+    int panStartY = 0;
+    std::vector<Clip> timeMoveOriginals; // Shift+drag on the ruler: the playlist when it started
+    std::int64_t timeMoveFrom = 0, timeMoveTo = 0, timeMoveAnchor = 0;
+    bool timeMoveCopy = false;
+    juce::uint32 lastClipEraseTime = 0;  // double right-click on a clip: mute instead of delete
+    juce::Point<int> lastClipErasePos;
+    // inline automation editing: points of automation clips are dragged, added on the curve, deleted by right-click
+    int autoClip = -1, autoPoint = -1;
+    juce::Rectangle<float> automationBody (const Clip& clip) const;
+    int automationPointAt (int clip, juce::Point<int> p) const;
+    bool isOnAutomationCurve (int clip, juce::Point<int> p) const;
+    void zoomAroundCentre (double factor);
+    void zoomToBars (int bars);
+    void zoomToSelection();
+    void zoomAll();
+    void centreOnPlayhead();
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PlaylistComponent)
 };
 // Playlist "Picker" (as in FL): list of patterns with their colors; clicking chooses the

+ 265 - 0
src/ui/QuickAddPalette.cpp

@@ -0,0 +1,265 @@
+#include "ui/QuickAddPalette.h"
+
+#include "core/Effects.h"
+#include "core/SearchQuery.h"
+#include "ui/I18n.h"
+#include "ui/MixerComponent.h"
+#include "ui/Theme.h"
+#include "ui/ToolWindow.h"
+
+namespace lynx
+{
+namespace
+{
+struct Entry
+{
+    juce::String name, detail;
+    std::function<void()> add;
+};
+
+class EntryList final : public juce::ListBox,
+                        private juce::ListBoxModel
+{
+public:
+    EntryList()
+    {
+        setModel (this);
+        setRowHeight (24);
+        setColour (juce::ListBox::backgroundColourId, theme::colour::bg1);
+        setOutlineThickness (0);
+        setWantsKeyboardFocus (false);
+    }
+
+    std::vector<Entry> all, shown;
+    std::function<void (const Entry&)> onChosen;
+
+    void filter (const juce::String& query)
+    {
+        const auto q = search::parse (query.toStdString());
+        shown.clear();
+        for (const auto& e : all)
+            if (search::matches (q, (e.name + " " + e.detail).toStdString()))
+                shown.push_back (e);
+        updateContent();
+        selectRow (shown.empty() ? -1 : 0);
+        repaint();
+    }
+
+    void chooseSelected()
+    {
+        const auto row = getSelectedRow();
+        if (row >= 0 && row < (int) shown.size() && onChosen)
+            onChosen (shown[(std::size_t) row]);
+    }
+
+private:
+    int getNumRows() override { return (int) shown.size(); }
+
+    void paintListBoxItem (int row, juce::Graphics& g, int width, int height, bool selected) override
+    {
+        if (row < 0 || row >= (int) shown.size())
+            return;
+
+        if (selected)
+        {
+            g.setColour (theme::colour::accentMuted);
+            g.fillRect (0, 0, width, height);
+        }
+
+        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);
+
+        if (e.detail.isNotEmpty())
+        {
+            g.setFont (theme::font (theme::type::caption));
+            g.setColour (theme::colour::textSecondary);
+            g.drawText (e.detail, 8, 0, width - 16, height, juce::Justification::centredRight, true);
+        }
+    }
+
+    void listBoxItemDoubleClicked (int row, const juce::MouseEvent&) override
+    {
+        if (row >= 0 && row < (int) shown.size() && onChosen)
+            onChosen (shown[(std::size_t) row]);
+    }
+};
+
+class QuickAddPalette final : public juce::Component,
+                              private juce::TextEditor::Listener,
+                              private juce::KeyListener
+{
+public:
+    QuickAddPalette (AudioEngine& engine, QuickAddTargets t) : targets (std::move (t))
+    {
+        search.setTextToShowWhenEmpty (tr ("Type to filter (e.g. reverb, synth OR bass, -delay)"), theme::colour::textDisabled);
+        search.addListener (this);
+        search.addKeyListener (this);
+        search.setWantsKeyboardFocus (true);
+        addAndMakeVisible (search);
+
+        for (auto* l : { &instrumentsTitle, &effectsTitle })
+        {
+            l->setFont (theme::font (theme::type::small, true));
+            l->setColour (juce::Label::textColourId, theme::colour::textSecondary);
+            addAndMakeVisible (*l);
+        }
+        instrumentsTitle.setText (tr ("Instruments: new channel"), juce::dontSendNotification);
+        effectsTitle.setText (tr ("Effects: into the selected insert"), juce::dontSendNotification);
+        hint.setText (tr ("Enter adds the highlighted item, Up/Down move, Tab switches lists, Esc closes"), juce::dontSendNotification);
+        hint.setFont (theme::font (theme::type::caption));
+        hint.setColour (juce::Label::textColourId, theme::colour::textDisabled);
+        addAndMakeVisible (hint);
+
+        // built-in instruments
+        const std::pair<InstrumentKind, const char*> builtIn[] = { { InstrumentKind::synth, TR_NOOP ("Synth") }, { InstrumentKind::kick, TR_NOOP ("Kick") },
+                                                                   { InstrumentKind::snare, TR_NOOP ("Snare") }, { InstrumentKind::hat, TR_NOOP ("Hat") },
+                                                                   { InstrumentKind::clap, TR_NOOP ("Clap") } };
+        for (const auto& [kind, name] : builtIn)
+            instruments.all.push_back ({ tr (name), tr ("built-in"), [this, kind = kind, english = juce::String (name)] {
+                                            ChannelDef c;
+                                            c.name = english.toStdString();
+                                            c.instrument = kind;
+                                            targets.addInstrument (c);
+                                        } });
+
+        for (auto kind : addableEffects())
+            effects.all.push_back ({ juce::String::fromUTF8 (effectInfo (kind).name), tr ("built-in"), [this, kind] { targets.addEffect (makeEffectSlot (kind)); } });
+
+        auto types = engine.getPluginHost().getKnownPlugins().getTypes();
+        std::sort (types.begin(), types.end(), [] (const auto& a, const auto& b) { return a.name.compareIgnoreCase (b.name) < 0; });
+
+        for (const auto& type : types)
+        {
+            PluginRef ref;
+            ref.id = type.createIdentifierString().toStdString();
+            ref.name = type.name.toStdString();
+            const auto detail = type.manufacturerName + " · " + type.pluginFormatName;
+
+            if (type.isInstrument)
+                instruments.all.push_back ({ type.name, detail, [this, ref] {
+                                                ChannelDef c;
+                                                c.name = ref.name;
+                                                c.instrument = InstrumentKind::plugin;
+                                                c.plugin = ref;
+                                                targets.addInstrument (c);
+                                            } });
+            else
+                effects.all.push_back ({ type.name, detail, [this, ref] {
+                                            EffectSlot slot;
+                                            slot.kind = EffectKind::plugin;
+                                            slot.plugin = ref;
+                                            targets.addEffect (slot);
+                                        } });
+        }
+
+        for (auto* list : { &instruments, &effects })
+        {
+            list->onChosen = [this] (const Entry& e) { choose (e); };
+            addAndMakeVisible (*list);
+            list->filter ({});
+        }
+
+        active = targets.effectsFirst ? &effects : &instruments;
+        setSize (640, 420);
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        g.fillAll (theme::colour::bg2);
+        g.setColour (theme::colour::accent);
+        const auto r = active->getBounds().toFloat().expanded (1.0f);
+        g.drawRect (r, 1.0f);
+    }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (10);
+        search.setBounds (area.removeFromTop (28));
+        area.removeFromTop (6);
+        hint.setBounds (area.removeFromBottom (18));
+        auto titles = area.removeFromTop (20);
+        instrumentsTitle.setBounds (titles.removeFromLeft (area.getWidth() / 2));
+        effectsTitle.setBounds (titles.withTrimmedLeft (6));
+        instruments.setBounds (area.removeFromLeft (area.getWidth() / 2).withTrimmedRight (3));
+        effects.setBounds (area.withTrimmedLeft (3));
+    }
+
+    void parentHierarchyChanged() override
+    {
+        if (isShowing())
+            search.grabKeyboardFocus();
+    }
+
+    bool keyPressed (const juce::KeyPress& key) override { return handleKey (key); }
+    bool keyPressed (const juce::KeyPress& key, juce::Component*) override { return handleKey (key); }
+
+    bool handleKey (const juce::KeyPress& key)
+    {
+        if (key == juce::KeyPress::returnKey)
+        {
+            active->chooseSelected();
+            return true;
+        }
+
+        if (key == juce::KeyPress::tabKey)
+        {
+            active = active == &instruments ? &effects : &instruments;
+            repaint();
+            return true;
+        }
+
+        if (key == juce::KeyPress::upKey || key == juce::KeyPress::downKey)
+        {
+            const auto count = (int) active->shown.size();
+            if (count > 0)
+            {
+                const auto row = juce::jlimit (0, count - 1, active->getSelectedRow() + (key == juce::KeyPress::upKey ? -1 : 1));
+                active->selectRow (row);
+                active->scrollToEnsureRowIsOnscreen (row);
+            }
+            return true;
+        }
+
+        return false;
+    }
+
+private:
+    void textEditorTextChanged (juce::TextEditor&) override
+    {
+        instruments.filter (search.getText());
+        effects.filter (search.getText());
+
+        // the list that has matches when the preferred one has none
+        if (active->shown.empty())
+        {
+            auto* other = active == &instruments ? &effects : &instruments;
+            if (! other->shown.empty())
+                active = other;
+        }
+        repaint();
+    }
+
+    void textEditorReturnKeyPressed (juce::TextEditor&) override { active->chooseSelected(); }
+
+    void choose (const Entry& e)
+    {
+        if (e.add)
+            e.add();
+        closeToolWindowOf (*this);
+    }
+
+    QuickAddTargets targets;
+    juce::TextEditor search;
+    juce::Label instrumentsTitle, effectsTitle, hint;
+    EntryList instruments, effects;
+    EntryList* active = nullptr;
+};
+} // namespace
+
+std::unique_ptr<juce::Component> makeQuickAddPalette (AudioEngine& engine, QuickAddTargets targets)
+{
+    return std::make_unique<QuickAddPalette> (engine, std::move (targets));
+}
+} // namespace lynx

+ 23 - 0
src/ui/QuickAddPalette.h

@@ -0,0 +1,23 @@
+#pragma once
+
+#include <functional>
+#include <memory>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+// Quick-add palette (docs/WORKFLOW_FL.md P2, B9; F8): every instrument (built-in and scanned plugins) on
+// the left, every effect on the right, filtered as you type (the Browser's search syntax). Double-click
+// or Enter adds the item: an instrument as a new channel, an effect into the selected mixer insert.
+struct QuickAddTargets
+{
+    std::function<void (ChannelDef)> addInstrument;
+    std::function<void (EffectSlot)> addEffect;
+    bool effectsFirst = false; // opened from the Mixer: typing and Enter go to the effects list
+};
+
+std::unique_ptr<juce::Component> makeQuickAddPalette (AudioEngine& engine, QuickAddTargets targets);
+} // namespace lynx

+ 90 - 0
src/ui/ToolWindow.cpp

@@ -0,0 +1,90 @@
+#include "ui/ToolWindow.h"
+
+#include "ui/Theme.h"
+#include "ui/WindowOwner.h"
+
+namespace lynx
+{
+namespace
+{
+class ToolWindow final : public juce::DocumentWindow
+{
+public:
+    ToolWindow (const juce::String& title, const juce::String& k)
+        : juce::DocumentWindow (title, theme::colour::bg2, juce::DocumentWindow::closeButton), key (k)
+    {
+        setUsingNativeTitleBar (true);
+        all().add (this);
+    }
+
+    ~ToolWindow() override { all().removeFirstMatchingValue (this); }
+
+    void closeButtonPressed() override { closeSoon(); }
+
+    bool keyPressed (const juce::KeyPress& k) override
+    {
+        if (k == juce::KeyPress::escapeKey)
+        {
+            closeSoon();
+            return true;
+        }
+        return juce::DocumentWindow::keyPressed (k);
+    }
+
+    void closeSoon()
+    {
+        setVisible (false);
+        juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<juce::Component> (this)] { delete safe.getComponent(); });
+    }
+
+    static juce::Array<ToolWindow*>& all()
+    {
+        static juce::Array<ToolWindow*> windows;
+        return windows;
+    }
+
+    juce::String key;
+};
+} // namespace
+
+juce::DocumentWindow* openToolWindow (std::unique_ptr<juce::Component> content, const juce::String& title, const juce::String& key)
+{
+    if (key.isNotEmpty())
+        if (auto* old = dynamic_cast<ToolWindow*> (findToolWindow (key)))
+            delete old;
+
+    auto* window = new ToolWindow (title, key);
+    window->setContentOwned (content.release(), true);
+    window->setResizable (false, false);
+
+    if (auto* main = juce::TopLevelWindow::getActiveTopLevelWindow())
+        window->setCentrePosition (main->getScreenBounds().getCentre());
+    else
+        window->centreWithSize (window->getWidth(), window->getHeight());
+
+    window->setVisible (true);
+    keepAboveMainWindow (*window);
+    window->toFront (true);
+    return window;
+}
+
+void closeToolWindowOf (juce::Component& content)
+{
+    if (auto* window = content.findParentComponentOfClass<ToolWindow>())
+        window->closeSoon();
+}
+
+void closeAllToolWindows()
+{
+    while (! ToolWindow::all().isEmpty())
+        delete ToolWindow::all().getLast();
+}
+
+juce::DocumentWindow* findToolWindow (const juce::String& key)
+{
+    for (auto* w : ToolWindow::all())
+        if (w->key == key && w->isVisible())
+            return w;
+    return nullptr;
+}
+} // namespace lynx

+ 22 - 0
src/ui/ToolWindow.h

@@ -0,0 +1,22 @@
+#pragma once
+
+#include <memory>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+namespace lynx
+{
+// A small non-modal window that owns `content`, stays above the main window and deletes itself when
+// closed (close button or Esc). Used by the note tool dialogs, the undo history and the quick-add palette.
+// `key` identifies the window: opening another with the same key closes the previous one.
+juce::DocumentWindow* openToolWindow (std::unique_ptr<juce::Component> content, const juce::String& title, const juce::String& key = {});
+
+// Closes the tool window that holds `content` (from inside it, e.g. an Accept button).
+void closeToolWindowOf (juce::Component& content);
+
+// Deletes every tool window now (the main window is closing).
+void closeAllToolWindows();
+
+// The open tool window with this key, or nullptr.
+juce::DocumentWindow* findToolWindow (const juce::String& key);
+} // namespace lynx

+ 57 - 1
src/ui/Workspace.cpp

@@ -429,6 +429,45 @@ private:
 
 // --- a detached panel's native window -----------------------------------------------------------
 
+// Detached windows snap to the screen edges, the main window and the other detached panels while they are
+// moved or resized (Alt held: no snapping). The native title bar's moves come through the constrainer.
+class SnapConstrainer final : public juce::ComponentBoundsConstrainer
+{
+public:
+    std::function<std::vector<juce::Rectangle<int>>()> others;
+
+    void checkBounds (juce::Rectangle<int>& bounds, const juce::Rectangle<int>& previous, const juce::Rectangle<int>& limits,
+                      bool stretchingTop, bool stretchingLeft, bool stretchingBottom, bool stretchingRight) override
+    {
+        juce::ComponentBoundsConstrainer::checkBounds (bounds, previous, limits, stretchingTop, stretchingLeft, stretchingBottom, stretchingRight);
+
+        if (juce::ModifierKeys::getCurrentModifiersRealtime().isAltDown() || previous.isEmpty())
+            return;
+
+        const auto* display = juce::Desktop::getInstance().getDisplays().getDisplayForRect (bounds);
+
+        if (display == nullptr)
+            return;
+
+        const auto area = display->userArea;
+        auto local = [&area] (juce::Rectangle<int> r) { return workspace::Rect { r.getX() - area.getX(), r.getY() - area.getY(), r.getWidth(), r.getHeight() }; };
+        std::vector<workspace::Rect> rects;
+
+        if (others)
+            for (const auto& o : others())
+                rects.push_back (local (o));
+
+        const auto edges = (stretchingLeft ? workspace::left : 0) | (stretchingTop ? workspace::top : 0) | (stretchingRight ? workspace::right : 0)
+                           | (stretchingBottom ? workspace::bottom : 0);
+
+        if (edges == 0 && bounds.getWidth() != previous.getWidth()) // a resize the window manager reports without edges
+            return;
+
+        const auto r = workspace::snap (local (bounds), rects, area.getWidth(), area.getHeight(), 10, edges);
+        bounds = { r.x + area.getX(), r.y + area.getY(), r.w, r.h };
+    }
+};
+
 class DetachedPanelWindow final : public juce::DocumentWindow
 {
 public:
@@ -439,7 +478,9 @@ public:
     {
         setUsingNativeTitleBar (true);
         setResizable (true, false);
-        setResizeLimits (workspace::minWidth, workspace::minHeight + Workspace::titleHeight, 10000, 10000);
+        snapping.setSizeLimits (workspace::minWidth, workspace::minHeight + Workspace::titleHeight, 10000, 10000);
+        snapping.others = [this] { return owner.otherWindowScreenBounds (panel); };
+        setConstrainer (&snapping);
         setContentNonOwned (&frame, false);
 
         if (screenBounds.isEmpty() || juce::Desktop::getInstance().getDisplays().getDisplayForRect (screenBounds) == nullptr)
@@ -479,6 +520,7 @@ public:
 private:
     Workspace& owner;
     Panel panel;
+    SnapConstrainer snapping;
 };
 
 // --- the desktop -------------------------------------------------------------------------------
@@ -627,6 +669,20 @@ void Workspace::frameMoved (Panel panel, juce::Rectangle<int> bounds)
     layout[panel].bounds = toRect (bounds);
 }
 
+std::vector<juce::Rectangle<int>> Workspace::otherWindowScreenBounds (Panel panel) const
+{
+    std::vector<juce::Rectangle<int>> out;
+
+    if (auto* top = getTopLevelComponent(); top != nullptr && top->isShowing())
+        out.push_back (top->getScreenBounds());
+
+    for (int i = 0; i < workspace::panelCount; ++i)
+        if ((Panel) i != panel && windows[(std::size_t) i] != nullptr && windows[(std::size_t) i]->isVisible())
+            out.push_back (windows[(std::size_t) i]->getBounds());
+
+    return out;
+}
+
 void Workspace::detachedWindowMoved (Panel panel, juce::Rectangle<int> screenBounds)
 {
     if (layout[panel].detached)

+ 2 - 0
src/ui/Workspace.h

@@ -89,6 +89,8 @@ public:
     void frameMoved (Panel panel, juce::Rectangle<int> bounds);
     std::vector<juce::Rectangle<int>> otherPanelBounds (Panel panel) const;
     void detachedWindowMoved (Panel panel, juce::Rectangle<int> screenBounds);
+    // Screen bounds a detached window snaps to: the main window and the other detached panels.
+    std::vector<juce::Rectangle<int>> otherWindowScreenBounds (Panel panel) const;
 
     static constexpr int titleHeight = 28;
 

+ 544 - 0
tests/WorkflowP2Tests.inc

@@ -0,0 +1,544 @@
+// Workflow P2 tests (docs/WORKFLOW_FL.md section 3.2, P2). Included at the end of tests.cpp.
+
+#include "core/History.h"
+#include "core/MixerOps.h"
+#include "core/NoteTools.h"
+#include "core/SearchQuery.h"
+
+namespace p2test
+{
+lynx::Note note (std::int64_t start, int key, std::int64_t length = lynx::ticksPerStep, int channel = 0, float velocity = 0.78f)
+{
+    lynx::Note n;
+    n.start = start;
+    n.key = key;
+    n.length = length;
+    n.channel = channel;
+    n.velocity = velocity;
+    return n;
+}
+
+std::vector<int> all (const lynx::Pattern& p)
+{
+    std::vector<int> out;
+    for (int i = 0; i < (int) p.notes.size(); ++i)
+        out.push_back (i);
+    return out;
+}
+
+std::vector<int> stepsOf (const lynx::Pattern& p, int channel)
+{
+    std::vector<int> out;
+    for (const auto& n : p.notes)
+        if (n.channel == channel)
+            out.push_back ((int) (n.start / lynx::ticksPerStep));
+    std::sort (out.begin(), out.end());
+    return out;
+}
+} // namespace p2test
+
+TEST (p2_note_levels_roundtrip)
+{
+    using namespace lynx::notetools;
+    lynx::Note n;
+    for (int l = 0; l < levelCount; ++l)
+    {
+        const auto level = (Level) l;
+        CHECK (std::abs (levelValue (n, level) - levelDefault (level)) < 1e-6f);
+        setLevelValue (n, level, 0.25f);
+        CHECK (std::abs (levelValue (n, level) - 0.25f) < 1e-5f);
+    }
+    CHECK (std::abs (n.pan + 0.5f) < 1e-5f && std::abs (n.finePitch + 60.0f) < 1e-3f);
+    setLevelValue (n, Level::velocity, 3.0f); // clamped
+    CHECK (n.velocity == 1.0f);
+    CHECK (levelIsBipolar (Level::pan) && ! levelIsBipolar (Level::velocity));
+}
+
+TEST (p2_scale_snap)
+{
+    using namespace lynx::notetools;
+    // C major (scale 1, root 0)
+    CHECK (inScale (60, 0, 1) && ! inScale (61, 0, 1) && inScale (61, 0, 0));
+    CHECK (snapToScale (61, 0, 1) == 60);  // C# -> C (tie goes down)
+    CHECK (snapToScale (66, 0, 1) == 65);  // F# -> F
+    CHECK (snapToScale (63, 0, 1) == 62);  // D# -> D
+    CHECK (snapToScale (61, 0, 0) == 61);  // no scale
+    // A minor pentatonic (scale 5, root 9): A C D E G
+    CHECK (snapToScale (70, 9, 5) == 69);  // A# -> A
+    CHECK (snapToScale (71, 9, 5) == 72);  // B -> C (one up beats two down)
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 61), p2test::note (0, 66) };
+    snapNotesToScale (p, { 0, 1 }, 0, 1);
+    CHECK (p.notes[0].key == 60 && p.notes[1].key == 65);
+}
+
+TEST (p2_strum)
+{
+    using namespace lynx::notetools;
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 64, 960), p2test::note (0, 60, 960), p2test::note (0, 67, 960), p2test::note (960, 72, 480, 0) };
+    StrumOptions o;
+    o.spread = 30;
+    o.velocityStep = 0.05f;
+    strum (p, p2test::all (p), o);
+    // low to high: 60 at 0, 64 at 30, 67 at 60; the ends stay at 960
+    CHECK (p.notes[1].start == 0 && p.notes[0].start == 30 && p.notes[2].start == 60);
+    CHECK (p.notes[0].start + p.notes[0].length == 960 && p.notes[2].length == 900);
+    CHECK (std::abs (p.notes[2].velocity - 0.88f) < 1e-5f);
+    CHECK (p.notes[3].start == 960); // a single note is not a chord
+
+    lynx::Pattern q;
+    q.notes = { p2test::note (0, 60), p2test::note (0, 64), p2test::note (480, 60), p2test::note (480, 64) };
+    o.alternate = true;
+    o.velocityStep = 0.0f;
+    o.keepEnds = false;
+    strum (q, p2test::all (q), o);
+    CHECK (q.notes[0].start == 0 && q.notes[1].start == 30);     // first chord: up
+    CHECK (q.notes[3].start == 480 && q.notes[2].start == 510);  // second chord: down
+    CHECK (q.notes[2].length == lynx::ticksPerStep);             // lengths kept
+}
+
+TEST (p2_arpeggiate)
+{
+    using namespace lynx::notetools;
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 60, 960), p2test::note (0, 64, 960), p2test::note (0, 67, 960) };
+    ArpeggiateOptions o;
+    o.step = 240;
+    o.gate = 0.5f;
+    auto added = arpeggiate (p, p2test::all (p), o);
+    CHECK (added.size() == 4 && p.notes.size() == 4);
+    CHECK (p.notes[0].key == 60 && p.notes[1].key == 64 && p.notes[2].key == 67 && p.notes[3].key == 60);
+    CHECK (p.notes[3].start == 720 && p.notes[0].length == 120);
+
+    lynx::Pattern q;
+    q.notes = { p2test::note (0, 60, 960), p2test::note (0, 64, 960) };
+    o.direction = ArpeggiateOptions::upDown;
+    o.octaves = 2;
+    o.step = 120;
+    arpeggiate (q, p2test::all (q), o);
+    // run 60 64 72 76, then back down 72 64
+    std::vector<int> keys;
+    for (const auto& n : q.notes)
+        keys.push_back (n.key);
+    CHECK ((keys == std::vector<int> { 60, 64, 72, 76, 72, 64, 60, 64 }));
+
+    lynx::Pattern single;
+    single.notes = { p2test::note (0, 60, 960) };
+    o.octaves = 1;
+    CHECK (arpeggiate (single, { 0 }, o).empty() && single.notes.size() == 1); // nothing to arpeggiate
+}
+
+TEST (p2_flip)
+{
+    using namespace lynx::notetools;
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 60, 240), p2test::note (480, 67, 480) }; // span 0..960, keys 60..67
+    flip (p, { 0, 1 }, true, false);
+    CHECK (p.notes[0].start == 720 && p.notes[1].start == 0);
+    flip (p, { 0, 1 }, false, true);
+    CHECK (p.notes[0].key == 67 && p.notes[1].key == 60);
+}
+
+TEST (p2_randomise_is_deterministic_and_bounded)
+{
+    using namespace lynx::notetools;
+    lynx::Pattern a;
+    for (int i = 0; i < 32; ++i)
+        a.notes.push_back (p2test::note (i * 240, 60, 240, 0, 0.5f));
+    auto b = a;
+    RandomiseOptions o;
+    o.velocity = 0.2f;
+    o.timing = 20;
+    o.seed = 7;
+    randomise (a, p2test::all (a), o);
+    randomise (b, p2test::all (b), o);
+    bool same = true, changed = false, bounded = true;
+    for (std::size_t i = 0; i < a.notes.size(); ++i)
+    {
+        same = same && a.notes[i].velocity == b.notes[i].velocity && a.notes[i].start == b.notes[i].start;
+        changed = changed || a.notes[i].velocity != 0.5f;
+        bounded = bounded && std::abs (a.notes[i].velocity - 0.5f) <= 0.2f + 1e-6f && std::abs (a.notes[i].start - (std::int64_t) i * 240) <= 20
+                  && a.notes[i].start >= 0;
+    }
+    CHECK (same && changed && bounded);
+    o.seed = 8;
+    randomise (b, p2test::all (b), o);
+    CHECK (b.notes[3].velocity != a.notes[3].velocity || b.notes[5].velocity != a.notes[5].velocity);
+
+    // one-sided: velocities only go down
+    lynx::Pattern c;
+    c.notes = { p2test::note (0, 60, 240, 0, 0.5f), p2test::note (240, 60, 240, 0, 0.5f), p2test::note (480, 60, 240, 0, 0.5f) };
+    o.bipolar = false;
+    o.timing = 0;
+    randomise (c, p2test::all (c), o);
+    CHECK (c.notes[0].velocity <= 0.5f && c.notes[1].velocity <= 0.5f && c.notes[2].velocity <= 0.5f);
+}
+
+TEST (p2_scale_levels_and_limit)
+{
+    using namespace lynx::notetools;
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 60, 240, 0, 0.8f), p2test::note (480, 60, 240, 0, 0.8f), p2test::note (960, 60, 240, 0, 0.8f) };
+    scaleLevels (p, p2test::all (p), Level::velocity, 1.0f, 0.0f, 0.0f); // fade out
+    CHECK (std::abs (p.notes[0].velocity - 0.8f) < 1e-5f && std::abs (p.notes[1].velocity - 0.4f) < 1e-5f && p.notes[2].velocity == 0.0f);
+    p.notes[0].pan = 0.5f;
+    scaleLevels (p, { 0 }, Level::pan, 0.5f, 0.5f, 0.0f); // pan scales around the centre
+    CHECK (std::abs (p.notes[0].pan - 0.25f) < 1e-5f);
+
+    lynx::Pattern q;
+    q.notes = { p2test::note (0, 30, 240, 0, 0.1f), p2test::note (0, 100, 240, 0, 0.95f), p2test::note (0, 60, 240, 0, 0.5f) };
+    LimitOptions o;
+    o.lowKey = 48;
+    o.highKey = 72;
+    o.minVelocity = 0.2f;
+    o.maxVelocity = 0.9f;
+    limit (q, p2test::all (q), o);
+    CHECK (q.notes[0].key == 54 && q.notes[1].key == 64 && q.notes[2].key == 60); // moved by octaves (pitch class kept)
+    CHECK (q.notes[0].velocity == 0.2f && q.notes[1].velocity == 0.9f && q.notes[2].velocity == 0.5f);
+    o.lowKey = 60;
+    o.highKey = 64; // narrower than an octave: clamped
+    limit (q, p2test::all (q), o);
+    CHECK (q.notes[0].key == 60 && q.notes[1].key == 64);
+}
+
+TEST (p2_euclidean_and_fill)
+{
+    using lynx::euclideanRhythm;
+    auto text = [] (const std::vector<bool>& r) {
+        std::string s;
+        for (auto b : r)
+            s += b ? 'x' : '.';
+        return s;
+    };
+    CHECK (text (euclideanRhythm (3, 8)) == "x..x..x.");
+    CHECK (text (euclideanRhythm (4, 16)) == "x...x...x...x...");
+    CHECK (text (euclideanRhythm (5, 8)) == "x.x.xx.x");
+    CHECK (text (euclideanRhythm (3, 8, 1)) == ".x..x..x");
+    CHECK (text (euclideanRhythm (3, 8, -1)) == "..x..x.x");
+    CHECK (text (euclideanRhythm (0, 4)) == "...." && text (euclideanRhythm (9, 4)) == "xxxx" && euclideanRhythm (2, 0).empty());
+
+    lynx::Pattern p;
+    lynx::fillEverySteps (p, 1, 4, 16);
+    CHECK ((p2test::stepsOf (p, 1) == std::vector<int> { 0, 4, 8, 12 }));
+    lynx::fillEverySteps (p, 1, 2, 16, 2); // adds 2, 6, 10, 14; keeps the others
+    CHECK (p2test::stepsOf (p, 1).size() == 8);
+
+    // a rhythm replaces the step notes but keeps notes off the grid and other channels
+    p.notes.push_back (p2test::note (100, 60, 60, 1));
+    p.notes.push_back (p2test::note (0, 60, 240, 2));
+    p.sortNotes();
+    lynx::setStepRhythm (p, 1, euclideanRhythm (3, 8), 16);
+    CHECK ((p2test::stepsOf (p, 1) == std::vector<int> { 0, 0, 3, 6, 8, 11, 14 })); // step 0 holds the off-grid note too
+    CHECK (p2test::stepsOf (p, 2).size() == 1);
+
+    lynx::Pattern r;
+    r.notes = { p2test::note (0, 60, 240, 0), p2test::note (15 * lynx::ticksPerStep, 62, 240, 0), p2test::note (0, 60, 240, 1) };
+    lynx::rotateSteps (r, 0, 1, 16);
+    CHECK ((p2test::stepsOf (r, 0) == std::vector<int> { 0, 1 }) && p2test::stepsOf (r, 1) == std::vector<int> { 0 });
+    lynx::rotateSteps (r, 0, -2, 16);
+    CHECK ((p2test::stepsOf (r, 0) == std::vector<int> { 14, 15 }));
+    CHECK (lynx::notesInStep (r, 0, 14).size() == 1 && lynx::notesInStep (r, 0, 3).empty());
+}
+
+TEST (p2_pattern_clone_and_move)
+{
+    auto song = lynx::Song::makeDefault();
+    song.patterns.push_back ({});
+    song.patterns[1].name = "B";
+    lynx::Clip c0, c1;
+    c0.pattern = 0;
+    c1.pattern = 1;
+    song.playlist = { c0, c1 };
+    const auto clone = lynx::clonePattern (song, 0);
+    CHECK (clone == 1 && song.patterns.size() == 3 && song.currentPattern == 1);
+    CHECK (song.patterns[1].notes.size() == song.patterns[0].notes.size() && song.patterns[1].name == song.patterns[0].name + " #2");
+    CHECK (song.playlist[0].pattern == 0 && song.playlist[1].pattern == 2); // "B" moved down one
+    CHECK (lynx::clonePattern (song, 0) == 1 && song.patterns[1].name == song.patterns[0].name + " #3");
+
+    CHECK (lynx::movePattern (song, 3, -1)); // "B" up
+    CHECK (song.patterns[2].name == "B" && song.playlist[1].pattern == 2);
+    CHECK (! lynx::movePattern (song, 0, -1) && ! lynx::movePattern (song, 3, 1));
+    song.currentPattern = 0;
+    CHECK (lynx::movePattern (song, 0, 1) && song.currentPattern == 1 && song.playlist[0].pattern == 1);
+}
+
+TEST (p2_channel_sort_and_unused)
+{
+    auto song = lynx::Song::makeDefault();
+    song.channels.resize (4);
+    song.channels[0].name = "kick";
+    song.channels[1].name = "Bass";
+    song.channels[2].name = "clap";
+    song.channels[3].name = "Arp";
+    song.channels[0].mixerTrack = 3;
+    song.channels[1].mixerTrack = 1;
+    song.channels[2].mixerTrack = 0;
+    song.channels[3].mixerTrack = 2;
+    CHECK ((lynx::channelSortOrder (song, lynx::ChannelSort::name) == std::vector<int> { 3, 1, 2, 0 }));
+    CHECK ((lynx::channelSortOrder (song, lynx::ChannelSort::insert) == std::vector<int> { 1, 3, 0, 2 })); // Master last
+    song.channels[0].colour = 0xff3d8fd1u; // blue
+    song.channels[1].colour = 0xffd94a4fu; // red
+    song.channels[2].colour = 0;
+    song.channels[3].colour = 0xff3fae6au; // green
+    CHECK ((lynx::channelSortOrder (song, lynx::ChannelSort::colour) == std::vector<int> { 1, 3, 0, 2 }));
+
+    for (auto& p : song.patterns)
+        p.notes.clear();
+    song.patterns[0].notes = { p2test::note (0, 60, 240, 1) };
+    lynx::Clip audio;
+    audio.kind = lynx::ClipKind::audio;
+    audio.channel = 3;
+    song.playlist = { audio };
+    CHECK ((lynx::unusedChannels (song) == std::vector<int> { 0, 2 }));
+}
+
+TEST (p2_mixer_swap_and_move)
+{
+    auto song = lynx::Song::makeDefault();
+    song.mixer = lynx::Song::defaultMixer (4);
+    song.mixer[1].name = "one";
+    song.mixer[2].name = "two";
+    song.channels.resize (2);
+    song.channels[0].mixerTrack = 1;
+    song.channels[1].mixerTrack = 2;
+    song.setRoute (1, 3, true, 0.5f);
+    lynx::EffectSlot comp;
+    comp.kind = lynx::EffectKind::compressor;
+    comp.sidechain = 1;
+    song.mixer[4].effects = { comp };
+    lynx::Automation a;
+    a.target = { lynx::AutomationTargetKind::mixerVolume, 2 };
+    song.automations = { a };
+
+    lynx::mixerops::swapTracks (song, 1, 2);
+    CHECK (song.mixer[1].name == "two" && song.mixer[2].name == "one");
+    CHECK (song.channels[0].mixerTrack == 2 && song.channels[1].mixerTrack == 1);
+    CHECK (song.routes (2, 3) && ! song.routes (1, 3) && song.mixer[4].effects[0].sidechain == 2);
+    CHECK (song.automations[0].target.index == 1);
+
+    std::vector<int> selection { 2, 3 };
+    CHECK (lynx::mixerops::moveTracks (song, selection, -1) && (selection == std::vector<int> { 1, 2 }));
+    CHECK (song.mixer[1].name == "one" && song.mixer[3].name == "two");
+    CHECK (! lynx::mixerops::moveTracks (song, selection, -1)); // the Master never moves
+    selection = { 0 };
+    CHECK (! lynx::mixerops::moveTracks (song, selection, 1));
+}
+
+TEST (p2_mixer_link_route_sidechain)
+{
+    auto song = lynx::Song::makeDefault();
+    song.mixer = lynx::Song::defaultMixer (3);
+    song.channels.resize (3);
+    auto inserts = lynx::mixerops::linkChannels (song, { 0, 1, 2 }, 2, true);
+    CHECK ((inserts == std::vector<int> { 2, 3, 4 }) && song.mixer.size() == 5); // one insert added
+    inserts = lynx::mixerops::linkChannels (song, { 0, 2 }, 1, false);
+    CHECK ((inserts == std::vector<int> { 1, 1 }) && (lynx::mixerops::channelsOn (song, 1) == std::vector<int> { 0, 2 }));
+
+    CHECK (lynx::mixerops::routeTo (song, { 2, 3 }, 4, false) == 2 && song.routes (2, 4) && song.routes (2, 0));
+    CHECK (lynx::mixerops::routeTo (song, { 2 }, 1, true) == 1 && song.routes (2, 1) && ! song.routes (2, 4) && ! song.routes (2, 0));
+    CHECK (lynx::mixerops::routeTo (song, { 4 }, 3, false) == 0); // 3 -> 4 already: a cycle
+
+    lynx::EffectSlot comp;
+    comp.kind = lynx::EffectKind::compressor;
+    song.mixer[1].effects = { comp };
+    CHECK (lynx::mixerops::sidechainTo (song, 3, 1) == 1 && song.mixer[1].effects[0].sidechain == 3);
+    CHECK (song.routes (3, 1) && song.mixer[3].sends.back().level == 0.0f);
+    const auto order = song.mixerOrder();
+    CHECK (std::find (order.begin(), order.end(), 3) < std::find (order.begin(), order.end(), 1));
+}
+
+TEST (p2_effect_slot_move_and_switch)
+{
+    auto song = lynx::Song::makeDefault();
+    song.mixer = lynx::Song::defaultMixer (2);
+    for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::delay, lynx::EffectKind::reverb })
+    {
+        lynx::EffectSlot s;
+        s.kind = kind;
+        song.mixer[1].effects.push_back (s);
+    }
+    lynx::Automation a;
+    a.target = { lynx::AutomationTargetKind::effectParam, 1, 0, 3 };
+    song.automations = { a };
+    CHECK (lynx::mixerops::moveEffectSlot (song, 1, 0, 2));
+    CHECK (song.mixer[1].effects[0].kind == lynx::EffectKind::delay && song.mixer[1].effects[2].kind == lynx::EffectKind::eq);
+    CHECK (song.automations[0].target.slot == 2);
+    CHECK (! lynx::mixerops::moveEffectSlot (song, 1, 0, 5));
+    lynx::mixerops::setAllEffectsEnabled (song, 1, false);
+    CHECK (! lynx::mixerops::anyEffectEnabled (song, 1));
+    lynx::mixerops::setAllEffectsEnabled (song, 1, true);
+    CHECK (lynx::mixerops::anyEffectEnabled (song, 1));
+}
+
+TEST (p2_history_labels)
+{
+    const auto before = lynx::Song::makeDefault();
+    auto after = before;
+    after.patterns[0].notes.push_back (p2test::note (0, 60));
+    CHECK (lynx::describeChangeText (before, after) == "Add notes: " + before.patterns[0].name);
+    after = before;
+    after.patterns[0].notes[0].velocity = 0.1f;
+    CHECK (lynx::describeChangeText (before, after) == "Edit notes: " + before.patterns[0].name);
+    after = before;
+    after.channels[1].muted = true;
+    CHECK (lynx::describeChangeText (before, after) == "Mute: " + before.channels[1].name);
+    after = before;
+    after.channels[1].volume = 0.2f;
+    CHECK (lynx::describeChangeText (before, after) == "Channel level: " + before.channels[1].name);
+    after = before;
+    after.channels.pop_back();
+    CHECK (std::string (lynx::describeChange (before, after).text) == "Delete channel");
+    after = before;
+    after.bpm = 99.0;
+    CHECK (lynx::describeChangeText (before, after) == "Tempo");
+    after = before;
+    after.mixer[1].volume = 0.3f;
+    CHECK (lynx::describeChangeText (before, after) == "Mixer level: " + before.mixer[1].name);
+    after = before;
+    after.playlist.push_back ({});
+    CHECK (lynx::describeChangeText (before, after) == "Add clips");
+    CHECK (lynx::describeChangeText (before, before) == "Edit");
+}
+
+TEST (p2_browser_search)
+{
+    using lynx::search::matches;
+    CHECK (matches ("", "anything.wav"));
+    CHECK (matches ("kick", "Big KICK 01.wav") && ! matches ("kick", "snare.wav"));
+    CHECK (matches ("kick 808", "808 Kick.wav") && ! matches ("kick 808", "909 Kick.wav"));
+    CHECK (matches ("kick AND 808", "kick_808.wav"));
+    CHECK (matches ("kick OR snare", "snare.wav") && matches ("kick OR snare", "kick.wav") && ! matches ("kick OR snare", "hat.wav"));
+    CHECK (! matches ("kick -loop", "kick loop.wav") && matches ("kick -loop", "kick one.wav"));
+    CHECK (! matches ("kick NOT loop", "kick loop.wav"));
+    CHECK (matches ("\"808 kick\"", "my 808 kick.wav") && ! matches ("\"808 kick\"", "kick 808.wav"));
+    CHECK (matches ("k*k.wav", "kick.wav") && ! matches ("k*k.wav", "kick.flac") && matches ("h?t*", "hat 01.wav"));
+    CHECK (lynx::search::wildcardMatch ("*", "") && ! lynx::search::wildcardMatch ("?", ""));
+}
+
+TEST (p2_record_commit_take)
+{
+    lynx::Pattern p;
+    p.notes = { p2test::note (0, 60, 240, 0), p2test::note (0, 60, 240, 1) };
+    std::vector<int> cleared;
+    // overdub with record quantise to steps
+    lynx::commitTake (p, { p2test::note (250, 62, 100, 0), p2test::note (130, 64, 100, 0) }, lynx::RecordMode::overdub, lynx::ticksPerStep, cleared);
+    CHECK (p.notes.size() == 4 && p.notes[2].start == 240 && p.notes[3].start == 240);
+    CHECK (p.notes[0].start == 0 && cleared.empty());
+
+    // replace: the channel's old notes go once, notes from later in the same take stay
+    lynx::commitTake (p, { p2test::note (480, 65, 100, 0) }, lynx::RecordMode::replace, 1, cleared);
+    CHECK (p.notes.size() == 2 && (cleared == std::vector<int> { 0 }));
+    lynx::commitTake (p, { p2test::note (720, 67, 100, 0) }, lynx::RecordMode::replace, 1, cleared);
+    CHECK (p.notes.size() == 3 && p2test::stepsOf (p, 1).size() == 1);
+}
+
+TEST (p2_record_song_mode_clip_and_count_in)
+{
+    auto song = lynx::Song::makeDefault();
+    song.playlist.clear();
+    const auto bar = (std::int64_t) lynx::ppq * song.beatsPerBar;
+    CHECK (lynx::placePatternClipAt (song, 0, bar + 100));
+    CHECK (song.playlist.size() == 1 && song.playlist[0].start == bar && song.playlist[0].track == 0);
+    CHECK (! lynx::placePatternClipAt (song, 0, bar + 200)); // already covered
+    song.patterns.emplace_back().name = "Other";
+    lynx::Clip other;
+    other.pattern = 1;
+    other.start = 3 * bar;
+    other.length = bar;
+    song.playlist.push_back (other);
+    CHECK (lynx::placePatternClipAt (song, 0, 3 * bar));
+    CHECK (song.playlist.back().track == 1); // track 0 is busy there
+    CHECK (lynx::countInLength (song, 2) == 2 * bar && lynx::countInLength (song, 0) == 0);
+}
+
+TEST (p2_ripple_and_time_range)
+{
+    std::vector<lynx::Clip> clips (4);
+    clips[0] = { 0, 0, 0, 100 };
+    clips[1] = { 0, 0, 100, 50 };
+    clips[2] = { 0, 0, 200, 50 };
+    clips[3] = { 0, 1, 120, 50 }; // another track
+    lynx::noteedit::rippleDelete (clips, { 1 });
+    CHECK (clips.size() == 3 && clips[1].start == 150 && clips[2].start == 120);
+
+    lynx::noteedit::rippleResize (clips, 0, 140);
+    CHECK (clips[0].length == 140 && clips[1].start == 190 && clips[2].start == 120);
+
+    std::vector<lynx::Clip> t (2);
+    t[0] = { 0, 0, 0, 400 };
+    t[1] = { 0, 1, 150, 50 };
+    const auto moved = lynx::noteedit::moveTimeRange (t, 100, 300, 500, false);
+    // clip 0 was cut at 100 and 300; its middle part and clip 1 moved by 500
+    CHECK (t.size() == 4 && moved.size() == 2);
+    CHECK (t[0].start == 0 && t[0].length == 100);
+    bool middle = false, tail = false;
+    for (const auto& c : t)
+    {
+        middle = middle || (c.track == 0 && c.start == 600 && c.length == 200 && c.offset == 100);
+        tail = tail || (c.track == 0 && c.start == 300 && c.length == 100 && c.offset == 300);
+    }
+    CHECK (middle && tail && t[1].start == 650);
+
+    std::vector<lynx::Clip> u (1);
+    u[0] = { 0, 0, 100, 100 };
+    const auto copies = lynx::noteedit::moveTimeRange (u, 0, 400, -1000, true);
+    CHECK (copies.size() == 1 && u.size() == 2 && u[1].start == 100 && u[0].start == 100); // clamped: the selection starts at 0
+}
+
+TEST (p2_key_map_bindings)
+{
+    using namespace lynx::keys;
+    KeyMap map;
+    CHECK (map.conflicts().empty());
+    CHECK (map.find ({ f8, none }, Context::global, false) == "panel.quickAdd");
+    CHECK (map.find ({ numpad3, none }, Context::playlist, true) == "pattern.select3");
+    CHECK (map.find ({ 'C', alt }, Context::pianoRoll, false) == "pattern.clone");
+    CHECK (map.find ({ 'C', alt }, Context::channelRack, false) == "rack.clone"); // the rack wins while focused
+    CHECK (map.find ({ 'A', alt }, Context::pianoRoll, false) == "pianoRoll.arpeggiate");
+    CHECK (map.find ({ '4', shift }, Context::playlist, true) == "playlist.zoomAll");
+    CHECK (map.find ({ left, alt }, Context::mixer, false) == "mixer.moveLeft");
+    CHECK (map.find ({ 'L', ctrl | shift }, Context::mixer, false) == "mixer.linkChannelsFrom");
+    CHECK (map.find ({ 'I', ctrl }, Context::global, false) == "record.waitForInput");
+    CHECK (toString ({ numpad7, none }) == "Numpad 7" && (parseChord ("Numpad 7") == Chord { numpad7, none }));
+}
+
+TEST (p2_playlist_tracks_and_chop)
+{
+    auto song = lynx::Song::makeDefault();
+    song.playlist.clear();
+    lynx::Clip a, b, c;
+    a.track = 0; a.length = 100;
+    b.track = 1; b.length = 100;
+    c.track = 2; c.length = 100;
+    song.playlist = { a, b, c };
+    song.playlistTracks.resize (2);
+    song.playlistTracks[1].name = "B";
+
+    lynx::noteedit::insertTrack (song, 1);
+    CHECK (song.playlist[0].track == 0 && song.playlist[1].track == 2 && song.playlist[2].track == 3);
+    CHECK (song.playlistTracks[2].name == "B" && song.playlistTracks[1].name.empty());
+
+    lynx::noteedit::swapTracks (song, 2, 3);
+    CHECK (song.playlist[1].track == 3 && song.playlist[2].track == 2 && song.playlistTracks[3].name == "B");
+
+    lynx::noteedit::removeTrack (song, 2);
+    CHECK (song.playlist.size() == 2 && song.playlist[1].track == 2 && song.playlistTracks[2].name == "B");
+
+    lynx::noteedit::soloTrack (song, 1, 4);
+    CHECK (! song.playlistTracks[1].muted && song.playlistTracks[0].muted && song.playlistTracks[3].muted);
+    lynx::noteedit::soloTrack (song, 1, 4); // again: everything plays
+    CHECK (! song.playlistTracks[0].muted && ! song.playlistTracks[3].muted);
+
+    std::vector<lynx::Clip> clips (1);
+    clips[0].start = 100;
+    clips[0].length = 1000;
+    const auto pieces = lynx::noteedit::chopClip (clips, 0, 480);
+    CHECK (pieces.size() == 3 && clips[0].length == 380 && clips[1].start == 480 && clips[1].length == 480 && clips[2].start == 960
+           && clips[2].length == 140 && clips[2].offset == 860);
+
+    lynx::Pattern steps, roll;
+    steps.notes = { p2test::note (0, 60), p2test::note (480, 60) };
+    roll.notes = { p2test::note (0, 64) };
+    CHECK (! lynx::hasPianoRollNotes (steps) && lynx::hasPianoRollNotes (roll));
+}

+ 515 - 8
tests/tests.cpp

@@ -32,7 +32,9 @@
 #include "core/Harmless.h"
 #include "core/Harmor.h"
 #include "core/Morphine.h"
+#include "core/Ogun.h"
 #include "core/HarmlessFx.h"
+#include "core/MaximusFx.h"
 #include "core/LiveEventQueue.h"
 #include "core/RackRenderer.h"
 #include "core/Scheduler.h"
@@ -756,11 +758,13 @@ TEST (flp_real_files)
         sytrusSounding = 0;
     int harmor = 0, harmorUsable = 0, harmorKind = 0, harmorSounding = 0;
     int gms = 0, gmsUsable = 0, gmsKind = 0, gmsSounding = 0, morphine = 0, morphineUsable = 0, morphineKind = 0, morphineSounding = 0, demoGoldens = 0;
+    int ogun = 0, ogunUsable = 0, ogunKind = 0, ogunSounding = 0;
     std::map<std::string, std::pair<int, int>> generators; // GMS/Ogun/Autogun/Sakura/DrumSynth: channels, decoded
     int ogunTrumpet = 0; // Ogun channels whose spectrum matches the REA "Trumpet" reference
     int peqSlots = 0, peqShaped = 0, reverbs = 0, reverbsDryless = 0, reverbsLowCut = 0;
     int dwChannels = 0, dwZones = 0, fpcKits = 0, padChannels = 0, padNotes = 0;
     int harmlessCompWanted = 0, harmlessCompLoaded = 0; // Harmless rack compressors / presets read from the installation
+    int maximusSlots = 0, maximusExact = 0, sgzSlots = 0, sgzExact = 0, vocodexSlots = 0, vocodexWithData = 0; // REA_rodada40
     // import with the installation's samples (realFlpDir is ...\Data): for DirectWave/FPC
     lynx::FlpImportOptions withFiles;
     const auto flRoot = std::filesystem::path (realFlpDir).parent_path().string();
@@ -875,6 +879,28 @@ TEST (flp_real_files)
                     padChannels += c.name.find (" - ") != std::string::npos && c.instrument == lynx::InstrumentKind::sampler ? 1 : 0;
                 }
                 fpcKits += hasFpc;
+                // Maximus / Soundgoodizer become the exact engine (REA_rodada40); Vocodex carries SG.dat (and its
+                // carrier's Sytrus preset) read from the installation
+                for (const auto& insert : p.mixer)
+                    for (const auto& slot : insert.slots)
+                    {
+                        maximusSlots += slot.plugin == "Maximus";
+                        sgzSlots += slot.plugin == "Soundgoodizer";
+                        vocodexSlots += slot.plugin == "Vocodex";
+                    }
+                for (const auto& t : full.mixer)
+                    for (const auto& fx : t.effects)
+                    {
+                        if (fx.kind == lynx::EffectKind::maximus)
+                        {
+                            const auto blob = lynx::maximusfx::unpack (fx.state);
+                            CHECK (blob && lynx::maximusfx::presetOf (*blob) != nullptr);
+                            if (blob)
+                                (blob->build == lynx::hlfx::MaximusBuild::soundgoodizer ? sgzExact : maximusExact) += 1;
+                        }
+                        if (fx.kind == lynx::EffectKind::vocodex)
+                            vocodexWithData += ! lynx::vocodex::splitInstallData (fx.state).second.sgDat.empty();
+                    }
                 for (const auto& pat : full.patterns)
                     for (const auto& n : pat.notes)
                     {
@@ -970,6 +996,27 @@ TEST (flp_real_files)
                     harmorSounding += e > 1e-6 ? 1 : 0;
                 }
 
+            // Ogun: every state in the demos plays on the exact engine (REA_rodada37) and sounds, with finite samples
+            for (const auto& c : p.channels)
+                if (c.pluginName == "Ogun")
+                {
+                    ++ogun;
+                    ogunUsable += lynx::ogunStateUsable (c.pluginState) ? 1 : 0;
+                }
+            for (const auto& c : song.channels)
+                if (c.instrument == lynx::InstrumentKind::ogun)
+                {
+                    ++ogunKind;
+                    const auto y = lynx::ogun::renderReference (c.pluginState, { { 0, 60, 0.8, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 6000 },
+                                                                                 { 2000, 67, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 8000 } }, 44100.0, 11025);
+                    double e = 0.0;
+                    bool finite = ! y.empty();
+                    for (auto v : y)
+                        finite = finite && std::isfinite (v), e += (double) v * v;
+                    CHECK (finite);
+                    ogunSounding += e > 1e-6 ? 1 : 0;
+                }
+
             // Sytrus: every state in the demos (zlib + 10 units) decodes, with finite values
             for (const auto& c : p.channels)
                 if (c.pluginName == "Sytrus")
@@ -1460,8 +1507,16 @@ TEST (flp_real_files)
                  gms, gmsUsable, gmsKind, gmsSounding, morphine, morphineUsable, morphineKind, morphineSounding, demoGoldens);
     CHECK (gmsUsable == gms && gms >= 9 && gmsKind == gms && gmsSounding == gmsKind);
     CHECK (morphineUsable == morphine && morphine >= 7 && morphineKind == morphine && morphineSounding == morphineKind && demoGoldens == 2);
+    std::printf ("  Ogun: %d channels, %d states usable by the engine, %d imported as Ogun (%d sounding)\n", ogun, ogunUsable, ogunKind, ogunSounding);
+    CHECK (ogunUsable == ogun && ogun >= 20 && ogunKind >= ogun && ogunSounding >= ogunKind * 9 / 10);
     std::printf ("  Harmless rack compressor: %d of %d presets read from the installation\n", harmlessCompLoaded, harmlessCompWanted);
     CHECK (harmlessCompLoaded == harmlessCompWanted && harmlessCompWanted > 100);
+    std::printf ("  Maximus: %d of %d slots on the exact engine; Soundgoodizer: %d of %d; Vocodex with SG.dat: %d of %d\n", maximusExact,
+                 maximusSlots, sgzExact, sgzSlots, vocodexWithData, vocodexSlots);
+    // REA_rodada40 §6: in Demo projects the 4 states left on the approximation use the Frequency Splitter linear-phase
+    // option; the other Data folders add states with options not decoded
+    CHECK (maximusSlots - maximusExact <= 16 && maximusExact >= 97 && sgzExact == sgzSlots && sgzSlots > 90);
+    CHECK (vocodexWithData == vocodexSlots && vocodexSlots >= 10);
 
     // 3x Osc channel presets shipped with FL (.fst): all become synth settings
     int presets = 0, presetsDecoded = 0;
@@ -5161,7 +5216,7 @@ int main (int argc, char** argv)
     if (argc > 1)
         realFlpDir = argv[1];
 
-    const char* only = std::getenv ("LYNX_TEST"); // optional: run only the tests whose name contains this
+    const char* only = std::getenv ("LYNX_TEST"); // run only the tests whose name contains this
     for (auto& [name, fn] : registry())
     {
         if (only != nullptr && std::strstr (name, only) == nullptr)
@@ -6592,6 +6647,256 @@ TEST (harmor_engine)
     CHECK (el < 1e-10 * er && er > 1e-3);
 }
 
+namespace
+{
+// An Ogun state written from scratch (REA_rodada37 §1.3 layout, version 18; zlib with stored blocks): richness 4
+// (255 partials), pre-decay, decay/release, fullness, Seed 1 + fixed Seed 2 with morph, 3-voice unison, a 2-stage
+// low-pass with an LFO on its cutoff, a volume envelope with a sustain point and a velocity map, declick, normalisation,
+// Impulse/Decay maps, and every plugin effect (EQ band, chorus, ping-pong delay, reverb). Everything else is neutral.
+std::vector<std::uint8_t> ogunTestState()
+{
+    std::vector<std::uint8_t> b;
+    auto i32 = [&] (std::int32_t v) { for (int k = 0; k < 4; ++k) b.push_back ((std::uint8_t) ((std::uint32_t) v >> (8 * k))); };
+    auto f32v = [&] (float v) { std::uint32_t u; std::memcpy (&u, &v, 4); i32 ((std::int32_t) u); };
+    auto f64 = [&] (double v) { std::uint64_t u; std::memcpy (&u, &v, 8); for (int k = 0; k < 8; ++k) b.push_back ((std::uint8_t) (u >> (8 * k))); };
+    struct Pt { double dx, y, tension; int mode; };
+    auto curve = [&] (int type, const std::vector<Pt>& pts, std::array<std::int32_t, 5> hdr) {
+        i32 (type), i32 (3), i32 ((std::int32_t) pts.size());
+        for (const auto& p : pts)
+        {
+            f64 (p.dx), f64 (p.y), f32v ((float) p.tension);
+            b.push_back ((std::uint8_t) p.mode), b.push_back (0), b.push_back (0), b.push_back (0);
+        }
+        for (auto h : hdr)
+            i32 (h);
+    };
+    const std::array<std::int32_t, 5> off { 0, 0, -1, -1, -1 }, on { 0, 1, -1, -1, -1 };
+    auto flat = [&] (int type, double y) { curve (type, { { 0, y, 0, 0 }, { 1, y, 0, 0 } }, off); };
+    std::array<std::int32_t, 64> P {};
+    const std::pair<int, int> values[] = { { 0, 128 }, { 5, 300 }, { 6, 3000 }, { 7, 2000 }, { 8, 200 }, { 9, 500 }, { 10, 12 },
+        { 11, 34 }, { 12, 3 }, { 13, 64 }, { 14, 64 }, { 15, 40 }, { 16, 64 }, { 17, 180 }, { 18, 60 }, { 19, 2 }, { 20, 300 },
+        { 21, 400 }, { 22, 40 }, { 23, 30 }, { 24, 20 }, { 25, 64 }, { 26, 40 }, { 27, 96 }, { 28, 100 }, { 29, 64 }, { 30, 2 },
+        { 31, 19 }, { 32, 221 }, { 33, 0 }, { 34, 50 }, { 35, 100 }, { 36, 20 }, { 37, 60 }, { 38, 2 }, { 39, 64 }, { 40, 300 },
+        { 43, 30000 }, { 46, 20000 }, { 49, 0 }, { 50, 2 }, { 51, 0 }, { 52, 9 }, { 53, 1 }, { 54, 0 },
+        { 55, 0x01000000 },   // +0x20b: pitch follows the key
+        { 56, 0x00010000 },   // +0x20e: declick
+        { 62, 0x00000100 } }; // +0x225: normalise
+    for (const auto& [i, v] : values)
+        P[(std::size_t) i] = v;
+    for (auto v : P)
+        i32 (v);
+    b.push_back (0), b.push_back (1), b.push_back (0); // delay: not tempo-based, on
+    i32 (1), i32 (1), i32 (1);                         // EQ band types: peaking
+    b.push_back (0);                                   // comment: 0 characters
+    for (int k = 0; k < 13; ++k)
+    {
+        static constexpr int sum[] = { 1, 2, 3, 9, 11, 12 };
+        const double neutral = std::find (std::begin (sum), std::end (sum), k) != std::end (sum) ? 0.5 : 1.0;
+        i32 (1);
+        f32v (0.0f), f32v (1.0f), f32v (k == 1 ? 0.3f : 0.0f);
+        if (k == 0) // volume envelope: attack, decay to the sustain point, release
+            curve (1, { { 0, 0, 0, 0 }, { 0.02, 1, 0.3, 0 }, { 0.3, 0.5, -0.4, 0 }, { 0.5, 0, 0.2, 0 } }, { 0, 1, 2, -1, 2 });
+        else
+            flat (1, neutral);
+        for (int a : { 128, 128, 128, 128 })
+            i32 (a);
+        if (k == 1) // cutoff LFO
+            curve (2, { { 0, 0.8, 0, 0 } }, on);
+        else
+            flat (2, 0.5);
+        for (int a : { k == 1 ? 40000 : 0, 0, 0, 0 })
+            i32 (a);
+        i32 (0);
+        for (int m = 0; m < 4; ++m)
+            if (k == 0 && m == 1)
+                curve (3, { { 0, 0.3, 0, 0 }, { 1, 1, -0.2, 0 } }, off); // velocity → volume
+            else
+                flat (3, neutral);
+    }
+    flat (3, 0.0);                                                // Forced: none
+    curve (3, { { 0, 0.6, 0, 0 }, { 1, 0.4, 0.3, 0 } }, off);     // Impulse EQ
+    curve (3, { { 0, 0.5, 0, 0 }, { 1, 0.3, 0, 0 } }, off);       // Decay EQ
+    flat (3, 0.5);                                                // Release EQ
+    // u32 version + zlib (stored blocks)
+    std::vector<std::uint8_t> s { 18, 0, 0, 0, 0x78, 0x01 };
+    for (std::size_t i = 0; i < b.size();)
+    {
+        const auto len = std::min<std::size_t> (65535, b.size() - i);
+        s.push_back (i + len >= b.size() ? 1 : 0);
+        s.push_back ((std::uint8_t) len), s.push_back ((std::uint8_t) (len >> 8));
+        s.push_back ((std::uint8_t) ~len), s.push_back ((std::uint8_t) (~len >> 8));
+        s.insert (s.end(), b.begin() + (std::ptrdiff_t) i, b.begin() + (std::ptrdiff_t) (i + len));
+        i += len;
+    }
+    std::uint32_t a1 = 1, a2 = 0;
+    for (auto c : b)
+        a1 = (a1 + c) % 65521u, a2 = (a2 + a1) % 65521u;
+    for (int sh = 24; sh >= 0; sh -= 8)
+        s.push_back ((std::uint8_t) (((a2 << 16) | a1) >> sh));
+    return s;
+}
+} // namespace
+
+TEST (ogun_engine)
+{
+    // REA_rodada37: state parsing, the engine against our reference model (ogmodel.py), host levels, export quality
+    const auto blob = ogunTestState();
+    if (const char* dump = std::getenv ("LYNX_DUMP_OGUN"))
+        std::ofstream (dump, std::ios::binary).write ((const char*) blob.data(), (std::streamsize) blob.size());
+    CHECK (lynx::ogunStateUsable (blob));
+    CHECK (lynx::ogunFallbacks (blob).empty());
+    CHECK (lynx::ogunParam (blob, 17) == 180 && lynx::ogunParam (blob, 52) == 9 && ! lynx::ogunParam (blob, 64));
+    auto broken = blob;
+    broken.resize (broken.size() - 300);
+    CHECK (! lynx::ogunStateUsable (broken));
+    auto old = blob;
+    old[0] = 13; // the articulator layout is from version 14
+    CHECK (! lynx::ogunStateUsable (old));
+
+    // reference model (REA round 37 ogmodel.Plugin(state).run: C5 velocity 0.75 released at 6144, G5 velocity 0.625 at 2048
+    // released at 8192; host block 512)
+    const std::vector<lynx::ogun::RefNote> notes { { 0, 60, 0.75, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 6144 }, { 2048, 67, 0.625, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 8192 } };
+    const auto ref = lynx::ogun::renderReference (blob, notes, 44100.0, 16384);
+    CHECK (ref.size() == 2 * 16384);
+    if (const char* dump = std::getenv ("LYNX_DUMP_OGUN_OUT"))
+        std::ofstream (dump, std::ios::binary).write ((const char*) ref.data(), (std::streamsize) (ref.size() * 4));
+    const std::tuple<int, float, float> golden[] {
+        { 100, -7.763202e-05f, -8.919523e-05f }, { 1000, 0.06195267f, 0.03858230f }, { 3000, 0.01363476f, -0.00378433f },
+        { 6000, -0.06601223f, -0.03084030f }, { 9000, 0.04204506f, 0.02452896f }, { 12000, 0.03420147f, -0.01837870f },
+        { 16383, -0.00465311f, -0.00119627f } };
+    for (const auto& [i, gl, gr] : golden)
+        CHECK (std::abs (ref[2 * (std::size_t) i] - gl) < 2e-6f && std::abs (ref[2 * (std::size_t) i + 1] - gr) < 2e-6f);
+
+    // the instrument plays like the reference renderer (Final.Vol 1, centre)
+    lynx::ChannelDef c;
+    c.instrument = lynx::InstrumentKind::ogun;
+    c.pluginState = blob;
+    auto render = [&] (const lynx::ChannelDef& def, int total, float gl, float gr, bool held = false) {
+        auto inst = lynx::makeInstrument (lynx::InstrumentKind::ogun);
+        inst->configure (def, 120.0);
+        inst->prepare (44100.0);
+        std::vector<float> l ((std::size_t) total), r ((std::size_t) total);
+        for (int s = 0; s < total; s += 512)
+        {
+            if (s == 0)
+                inst->noteOn (60, 0.75f);
+            if (s == 2048)
+                inst->noteOn (67, 0.625f);
+            if (s == 6144 && ! held)
+                inst->noteOff (60);
+            if (s == 8192 && ! held)
+                inst->noteOff (67);
+            inst->render (l.data() + s, r.data() + s, std::min (512, total - s), gl, gr);
+        }
+        return std::make_tuple (l, r, std::move (inst));
+    };
+    {
+        auto [l, r, inst] = render (c, 16384, 1.0f, 1.0f);
+        double worst = 0.0;
+        for (int i = 0; i < 16384; ++i)
+            worst = std::max ({ worst, (double) std::abs (ref[2 * (std::size_t) i] - l[(std::size_t) i]), (double) std::abs (ref[2 * (std::size_t) i + 1] - r[(std::size_t) i]) });
+        CHECK (worst == 0.0);
+        // the voices end and the effect tails die out: the instrument goes idle
+        std::vector<float> tail (44100), tailR (tail.size());
+        for (int k = 0; k < 20 && ! inst->idle(); ++k)
+            inst->render (tail.data(), tailR.data(), (int) tail.size(), 1.0f, 1.0f);
+        CHECK (inst->idle());
+    }
+    // FL's level law applied once (effects off): half the channel volume halves the output once the gain ramps
+    // (limited to 0.001 per sample) have settled on the sustain level; full right pan silences the left side
+    {
+        auto dry = c;
+        for (int i : { 19, 29, 40, 53 })
+            CHECK (lynx::ogunSetParam (dry.pluginState, i, 0)); // chorus, delay wet, EQ band and reverb off
+        CHECK (lynx::ogunStateUsable (dry.pluginState) && lynx::ogunParam (dry.pluginState, 19) == 0);
+        const auto full = std::get<0> (render (dry, 32768, 1.0f, 1.0f, true));
+        const auto half = std::get<0> (render (dry, 32768, 0.5f, 0.5f, true));
+        double worst = 0.0, peak = 0.0;
+        for (int i = 30000; i < 32768; ++i)
+            worst = std::max (worst, (double) std::abs (half[(std::size_t) i] - 0.5f * full[(std::size_t) i])),
+            peak = std::max (peak, (double) std::abs (full[(std::size_t) i]));
+        CHECK (worst <= 1e-7 * peak && peak > 1e-3);
+        // FL's default channel volume (100/128): FL hands Ogun Final.Vol = (11^v − 1)/10 (REA_rodada28 §4.1); LYNX's
+        // centred channel gains (√2·V·cos(π/4) each) give the reference model's level at that Final.Vol
+        const auto V = lynx::channelGain (0.78125f);
+        const auto g = V * std::cos (0.25f * 3.14159265f) * 1.41421356f;
+        const auto atDefault = std::get<0> (render (dry, 32768, g, g, true));
+        const auto refDefault = lynx::ogun::renderReference (dry.pluginState, { { 0, 60, 0.75, V, 0.0, 0.0, 0.0, 0.0, 0.5, -1 },
+                                                                                { 2048, 67, 0.625, V, 0.0, 0.0, 0.0, 0.0, 0.5, -1 } }, 44100.0, 32768);
+        double ei = 0.0, er0 = 0.0;
+        for (int i = 30000; i < 32768; ++i)
+            ei += (double) atDefault[(std::size_t) i] * atDefault[(std::size_t) i], er0 += (double) refDefault[2 * (std::size_t) i] * refDefault[2 * (std::size_t) i];
+        CHECK (er0 > 0.0 && std::abs (10.0 * std::log10 (ei / er0)) < 0.001);
+        const auto [pl, pr, pi] = render (dry, 4096, 0.0f, 1.41421356f);
+        double el = 0.0, er = 0.0;
+        for (int i = 0; i < 4096; ++i)
+            el += (double) pl[(std::size_t) i] * pl[(std::size_t) i], er += (double) pr[(std::size_t) i] * pr[(std::size_t) i];
+        CHECK (el < 1e-10 * er && er > 1e-3);
+    }
+    // export: FL renders Ogun at quality 4 (×2 rate, 32-point reader), LYNX too while it renders offline
+    {
+        lynx::setOfflineRendering (true);
+        auto [l, r, inst] = render (c, 8192, 1.0f, 1.0f);
+        lynx::setOfflineRendering (false);
+        lynx::ogun::RefOptions q4;
+        q4.quality = 4;
+        const auto ref4 = lynx::ogun::renderReference (blob, notes, 44100.0, 8192, q4);
+        double worst = 0.0, diff = 0.0;
+        for (int i = 0; i < 8192; ++i)
+            worst = std::max (worst, (double) std::abs (ref4[2 * (std::size_t) i] - l[(std::size_t) i])),
+            diff = std::max (diff, (double) std::abs (ref[2 * (std::size_t) i] - l[(std::size_t) i]));
+        CHECK (worst == 0.0 && diff > 1e-3);
+        const std::tuple<int, float, float> golden4[] {
+            { 100, 0.00605961f, 0.00628969f }, { 1000, 0.03729841f, 0.01727954f }, { 3000, -0.09010383f, -0.02551294f },
+            { 6000, 0.02167798f, -0.01115632f }, { 8191, 0.00320288f, -0.00615792f } };
+        for (const auto& [i, gl, gr] : golden4)
+            CHECK (std::abs (ref4[2 * (std::size_t) i] - gl) < 2e-6f && std::abs (ref4[2 * (std::size_t) i + 1] - gr) < 2e-6f);
+    }
+    // feature variants of the same state against the reference model (energy per side over 8192 samples, three
+    // samples; C1 released at 6144): qualities, richness, unison, the filter types, ALT DECAY, 1/√h, Seed 2 Random,
+    // infinite decay, logarithmic axis, velocity → position, other rates. Goldens from ogmodel.py (REA round 37).
+    {
+        struct Sample { int at; float l, r; };
+        struct Variant { const char* name; std::vector<std::pair<int, int>> params; int rate; double el, er; Sample s[3]; };
+        const Variant variants[] {
+        { "q1", { { 54, 1 } }, 44100, 11.0970402, 6.87820714, { { 1500, 0.0240363069f, -0.0148524037f }, { 4000, 0.0873190612f, -0.000715861097f }, { 7000, -0.0378603041f, -0.00338819111f } } },
+        { "q2", { { 54, 2 } }, 44100, 11.2405446, 6.68045082, { { 1500, 0.0448660068f, -0.00560745923f }, { 4000, -0.0122657465f, 0.0104285963f }, { 7000, -0.0216034129f, -0.0134632047f } } },
+        { "q3", { { 54, 3 } }, 44100, 11.3200608, 6.86196449, { { 1500, -0.0031537537f, -0.0242648814f }, { 4000, 0.0426301025f, 0.0364697985f }, { 7000, 0.00843803957f, 0.0302239582f } } },
+        { "rich16_q0", { { 52, 16 }, { 54, 0 } }, 44100, 26.7616786, 19.2591256, { { 1500, 0.0728010684f, -0.0116148153f }, { 4000, 0.0797849894f, 0.0765359923f }, { 7000, -0.00811834447f, -0.0104534971f } } },
+        { "uni9", { { 12, 9 }, { 15, 20 }, { 16, 0 }, { 14, 16 } }, 44100, 61.7485898, 36.6693432, { { 1500, 0.0531249829f, -0.0374071151f }, { 4000, 0.165054232f, -0.0192129575f }, { 7000, -0.0373774841f, -0.00196591392f } } },
+        { "lp1", { { 50, 1 }, { 49, 0 } }, 44100, 7.81941168, 4.72659869, { { 1500, 0.0377117358f, -0.0157920271f }, { 4000, 0.0747607499f, 0.00154248625f }, { 7000, -0.0510631353f, 0.00884498842f } } },
+        { "bp3flat", { { 50, 3 }, { 49, 1 }, { 51, 1 } }, 44100, 2.19181431, 1.29483907, { { 1500, 0.0291239917f, -0.00288665155f }, { 4000, -0.0084345676f, -0.00400509313f }, { 7000, -0.00592403999f, 0.00150578981f } } },
+        { "bs2", { { 50, 2 }, { 49, 2 } }, 44100, 32.8440514, 25.7202184, { { 1500, 0.0730303749f, -0.0496222489f }, { 4000, 0.0696200803f, 0.0595823973f }, { 7000, -0.0482789353f, 0.0764200836f } } },
+        { "hp3", { { 50, 3 }, { 49, 3 } }, 44100, 8.623214, 7.95253188, { { 1500, -0.0325722694f, 0.00703159999f }, { 4000, 0.0183976218f, -0.0372007042f }, { 7000, -0.0126833525f, -0.00160143059f } } },
+        { "alt", { { 62, 257 } }, 44100, 17.2485711, 9.99223979, { { 1500, -0.0319156498f, -0.0186850764f }, { 4000, -0.0769012421f, -0.0375530645f }, { 7000, 0.0310976505f, 0.0445244014f } } },
+        { "isqrt", { { 62, 65792 } }, 44100, 45.7309307, 27.1224593, { { 1500, -0.04376591f, -0.00845711026f }, { 4000, 0.0351300463f, -0.129557073f }, { 7000, 0.0096148327f, 0.00123740174f } } },
+        { "seed2rnd", { { 11, 0 } }, 44100, 16.8228819, 11.5433061, { { 1500, -0.0117614279f, -0.026497297f }, { 4000, 0.00265733898f, -0.07069581f }, { 7000, 0.00576663949f, 0.0565217957f } } },
+        { "decinf", { { 6, 10000 } }, 44100, 19.1879226, 11.0487311, { { 1500, -0.0324105881f, -0.0190765262f }, { 4000, -0.0809780285f, -0.0395730771f }, { 7000, 0.034197174f, 0.048585102f } } },
+        { "logx", { { 57, 16777216 } }, 44100, 12.3064326, 7.31519289, { { 1500, -0.0438990779f, 0.0096983267f }, { 4000, -0.0175748877f, 0.0313935578f }, { 7000, 0.0639200211f, 0.024419222f } } },
+        { "velpos", { { 56, 66304 } }, 44100, 4.9966925, 3.16540662, { { 1500, 0.0083851777f, -0.0165472236f }, { 4000, 0.0630451962f, 0.0156494901f }, { 7000, -0.0293043777f, -0.00182877108f } } },
+        { "fs48", {  }, 48000, 10.8813888, 6.53592373, { { 1500, -0.0485184453f, -0.0319588967f }, { 4000, 0.0230421089f, -0.0286604818f }, { 7000, -0.0117630213f, -0.017459048f } } },
+        { "fs96", {  }, 96000, 11.0189683, 6.39821883, { { 1500, -0.0267860368f, -0.0227564126f }, { 4000, 0.0238709711f, -0.0100849615f }, { 7000, -0.0034619756f, 0.0451687202f } } },
+        };
+        for (const auto& v : variants)
+        {
+            auto st = blob;
+            for (const auto& [i, x] : v.params)
+                CHECK (lynx::ogunSetParam (st, i, x));
+            const auto y = lynx::ogun::renderReference (st, { { 0, 60, 0.75, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6144 },
+                                                              { 2048, 67, 0.625, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1 } }, (double) v.rate, 8192);
+            double el = 0.0, er = 0.0, peak = 0.0;
+            for (std::size_t i = 0; i + 1 < y.size(); i += 2)
+                el += (double) y[i] * y[i], er += (double) y[i + 1] * y[i + 1], peak = std::max ({ peak, (double) std::abs (y[i]), (double) std::abs (y[i + 1]) });
+            bool ok = y.size() == 2 * 8192 && std::abs (el - v.el) <= 1e-5 * v.el && std::abs (er - v.er) <= 1e-5 * v.er;
+            for (const auto& smp : v.s)
+                ok = ok && std::abs (y[2 * (std::size_t) smp.at] - smp.l) <= 1e-5 * peak && std::abs (y[2 * (std::size_t) smp.at + 1] - smp.r) <= 1e-5 * peak;
+            if (! ok)
+                std::printf ("  Ogun variant %s differs from the model: energy %.9g %.9g (model %.9g %.9g)\n", v.name, el, er, v.el, v.er);
+            CHECK (ok);
+        }
+    }
+}
+
 // our own Maximus v7 state (layout REA_rodada8 §1.1): 7 globals, 4 × 13 band parameters, 8 envelopes (dx, y, tension, type)
 static std::vector<std::uint8_t> maximusTestState (const std::array<int, 7>& g, const std::array<std::array<int, 13>, 4>& bands,
                                                    const std::array<std::vector<std::array<double, 4>>, 8>& envs, int oversampling)
@@ -6626,6 +6931,101 @@ static std::vector<std::uint8_t> maximusTestState (const std::array<int, 7>& g,
     return d;
 }
 
+TEST (ogun_demo_channels)
+{
+    // every Ogun channel of FL's demo projects (with its plugin effects) against the round-37 reference model, which is
+    // within −60 dB of FL's DLL on all of them: three notes (C5 1.0 0–20000, G5 0.6 8000–26000, G4 0.95 16000–30000),
+    // 39 690 samples at 44.1 kHz, at the state's quality and at the export quality 4. Fingerprint: energy per side and
+    // four samples (the engine matches the model within float rounding, −125 dB or better on the whole signal).
+    if (realFlpDir.empty())
+        return;
+    struct Sample { int at; float l, r; };
+    struct Golden { const char* file; int ordinal; std::size_t stateSize; bool export4; double el, er; Sample s[4]; };
+    const Golden goldens[] {
+        { "Demo songs/Astes - Bien Duro.flp", 0, 64728, false, 710.708198, 710.708198, { { 5000, 0.133627325f, 0.133627325f }, { 12000, -0.143534407f, -0.143534407f }, { 25000, 0.079226315f, 0.079226315f }, { 35000, -0.0128487358f, -0.0128487358f } } }, // 3.3.1 Metal Drums: Drum
+        { "Demo songs/Astes - Bien Duro.flp", 0, 64728, true, 794.506558, 794.506558, { { 5000, -0.0112881307f, -0.0112881307f }, { 12000, -0.068779245f, -0.068779245f }, { 25000, -0.0289028231f, -0.0289028231f }, { 35000, -0.0161623377f, -0.0161623377f } } }, // 3.3.1 Metal Drums: Drum
+        { "Demo songs/Astes - Bien Duro.flp", 1, 4261, false, 297.957631, 297.957631, { { 5000, -0.000330464332f, -0.000330464332f }, { 12000, -0.00156057056f, -0.00156057056f }, { 25000, -9.24126434e-05f, -9.24126434e-05f }, { 35000, 0.0f, 0.0f } } }, // 3.3.1 Metal Drums: Click
+        { "Demo songs/Astes - Bien Duro.flp", 1, 4261, true, 189.545711, 189.545711, { { 5000, 0.00102557975f, 0.00102557975f }, { 12000, -0.00522088073f, -0.00522088073f }, { 25000, 5.81103013e-05f, 5.81103013e-05f }, { 35000, 0.0f, 0.0f } } }, // 3.3.1 Metal Drums: Click
+        { "Demo songs/Astes - Bien Duro.flp", 2, 133836, false, 125.683557, 125.683557, { { 5000, 0.0176561493f, 0.0176561493f }, { 12000, 0.019205872f, 0.019205872f }, { 25000, 0.0046372693f, 0.0046372693f }, { 35000, -0.00165430119f, -0.00165430119f } } }, // 3.3.2 Tibetan
+        { "Demo songs/Astes - Bien Duro.flp", 2, 133836, true, 105.621798, 105.621798, { { 5000, 0.00897848886f, 0.00897848886f }, { 12000, -0.0171215143f, -0.0171215143f }, { 25000, -0.00821319036f, -0.00821319036f }, { 35000, -0.00245537539f, -0.00245537539f } } }, // 3.3.2 Tibetan
+        { "Demo songs/Astes - Bien Duro.flp", 3, 97085, false, 2066.75611, 2066.75611, { { 5000, -0.101155393f, -0.101155393f }, { 12000, 0.355391592f, 0.355391592f }, { 25000, 0.00365939317f, 0.00365939317f }, { 35000, -0.0191957876f, -0.0191957876f } } }, // 3.3.3 Chase
+        { "Demo songs/Astes - Bien Duro.flp", 3, 97085, true, 1667.28674, 1667.28674, { { 5000, -0.236701503f, -0.236701503f }, { 12000, -0.126374632f, -0.126374632f }, { 25000, 0.0533663221f, 0.0533663221f }, { 35000, -0.0100225089f, -0.0100225089f } } }, // 3.3.3 Chase
+        { "Demo songs/Edlan & Ella Noël - Song For You.flp", 0, 819, false, 551.263856, 371.038684, { { 5000, 0.0253486633f, 0.160556272f }, { 12000, 0.194370747f, -0.0359776132f }, { 25000, -0.00528950989f, 0.01478827f }, { 35000, 0.110768802f, -0.0237054806f } } }, // Bellish 11
+        { "Demo songs/Edlan & Ella Noël - Song For You.flp", 0, 819, true, 547.662092, 381.048456, { { 5000, 0.0401367024f, 0.0261611789f }, { 12000, -0.157383129f, -0.0282031279f }, { 25000, -0.000249146833f, 0.0388034321f }, { 35000, -0.105665907f, 0.0320193283f } } }, // Bellish 11
+        { "Demo songs/LollieVox & Lezina J - I'll Be Your Madonna.flp", 0, 105571, false, 833.288142, 909.880193, { { 5000, 0.0276863724f, 0.214677185f }, { 12000, 0.00827352796f, 0.141611829f }, { 25000, -0.160458148f, 0.0101522766f }, { 35000, -0.0157076102f, 0.00129696913f } } }, // High Chords
+        { "Demo songs/LollieVox & Lezina J - I'll Be Your Madonna.flp", 0, 105571, true, 928.749154, 967.940976, { { 5000, -0.0623336285f, -0.0959333256f }, { 12000, 0.0601816922f, -0.0748261437f }, { 25000, -0.0872222036f, -0.101655915f }, { 35000, -0.002591094f, 0.0107459351f } } }, // High Chords
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 0, 813, false, 21576.8988, 21576.8988, { { 5000, 0.00724618789f, 0.00724618789f }, { 12000, 0.0337664448f, 0.0337664448f }, { 25000, -1.44279329e-05f, -1.44279329e-05f }, { 35000, 0.0f, 0.0f } } }, // Kick
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 0, 813, true, 17857.5027, 17857.5027, { { 5000, -0.0114536202f, -0.0114536202f }, { 12000, -0.00848954543f, -0.00848954543f }, { 25000, 1.20320046e-05f, 1.20320046e-05f }, { 35000, 0.0f, 0.0f } } }, // Kick
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 1, 789, false, 172.127165, 170.39981, { { 5000, -0.00470701791f, -0.000373305753f }, { 12000, 0.0417476855f, 0.0339940563f }, { 25000, 0.0204325765f, 0.0191226583f }, { 35000, -0.000425090868f, -0.000144533216f } } }, // Clap
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 1, 789, true, 163.557022, 149.810459, { { 5000, 0.00246403809f, 0.0228729937f }, { 12000, 0.0378073864f, 0.0445459485f }, { 25000, -0.0242712852f, -0.0313444398f }, { 35000, -0.00112735468f, -0.00138637482f } } }, // Clap
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 2, 635, false, 125.48103, 127.519836, { { 5000, -0.00389297446f, 0.00181007839f }, { 12000, -0.0543250106f, -0.0736973509f }, { 25000, -0.00448145531f, 0.000426211918f }, { 35000, 5.35470353e-05f, 4.34564136e-05f } } }, // High Hat
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 2, 635, true, 245.916518, 254.34816, { { 5000, 0.00147765165f, 0.00267027458f }, { 12000, 0.0883170143f, 0.173417449f }, { 25000, -0.00118842872f, 0.000863731664f }, { 35000, -0.000298409053f, -9.04561821e-05f } } }, // High Hat
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 3, 45647, false, 271.486026, 271.486026, { { 5000, -4.96093298e-06f, -4.96093298e-06f }, { 12000, 0.000292191253f, 0.000292191253f }, { 25000, -8.18665136e-10f, -8.18665136e-10f }, { 35000, 0.0f, 0.0f } } }, // HiHat
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 3, 45647, true, 167.753037, 167.753037, { { 5000, 2.2048649e-05f, 2.2048649e-05f }, { 12000, -1.77328075e-05f, -1.77328075e-05f }, { 25000, -3.00809999e-09f, -3.00809999e-09f }, { 35000, 0.0f, 0.0f } } }, // HiHat
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 4, 887, false, 6005.75168, 6293.90961, { { 5000, -0.19636783f, -0.0313744769f }, { 12000, 0.178472087f, 0.601032794f }, { 25000, -0.351912051f, -0.0497151017f }, { 35000, -0.182245821f, -0.181938142f } } }, // Snare
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 4, 887, true, 6151.47444, 6049.47136, { { 5000, -0.102814399f, 0.0690701902f }, { 12000, 0.0902677849f, 0.114889771f }, { 25000, -0.173990116f, 0.140671447f }, { 35000, 0.0744562522f, 0.0291433111f } } }, // Snare
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 5, 705, false, 6511.3723, 5580.42134, { { 5000, 0.478397369f, 0.536334693f }, { 12000, -0.312448859f, -0.301919997f }, { 25000, 0.260874003f, -0.0129742175f }, { 35000, 0.0223956257f, 0.033103168f } } }, // Swebass 1
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 5, 705, true, 6415.0768, 5859.44881, { { 5000, 0.0342692807f, 0.00727743423f }, { 12000, -0.0324966274f, 0.125386745f }, { 25000, -0.0785191655f, -0.25017795f }, { 35000, -0.0524680056f, -0.0384391509f } } }, // Swebass 1
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 6, 708, false, 2487.6041, 2190.17262, { { 5000, -0.0770967156f, -0.00940297544f }, { 12000, 0.329836905f, 0.183736563f }, { 25000, 0.0137981772f, -0.0334252715f }, { 35000, 0.0132095823f, 0.0277119074f } } }, // Swebass 2
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 6, 708, true, 2519.26975, 2230.77243, { { 5000, -0.204216316f, -0.16732122f }, { 12000, 0.0762225091f, 0.0964485779f }, { 25000, -0.0833523944f, -0.132980049f }, { 35000, -0.015998248f, 0.0112942485f } } }, // Swebass 2
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 7, 109827, false, 1326.11782, 1397.71125, { { 5000, 0.0306534693f, 0.026510708f }, { 12000, -0.139238164f, -0.104713492f }, { 25000, 0.106734768f, 0.0295313746f }, { 35000, 0.258899271f, 0.260215104f } } }, // Midnight Lady
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 7, 109827, true, 1252.058, 1287.83169, { { 5000, -0.0980920121f, -0.108575724f }, { 12000, 0.131130368f, 0.176118359f }, { 25000, 0.0581845529f, 0.174699515f }, { 35000, -0.17453593f, 0.0978319347f } } }, // Midnight Lady
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 8, 34816, false, 10793.0192, 11904.6549, { { 5000, 0.36459741f, -0.0714551434f }, { 12000, 0.565215111f, -0.205066338f }, { 25000, -0.652977228f, -0.432422459f }, { 35000, -0.284279644f, -0.122116163f } } }, // Supersaw
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 8, 34816, true, 10132.5107, 11590.7617, { { 5000, 0.192168862f, 0.0883051828f }, { 12000, -0.590734482f, 0.512839496f }, { 25000, 0.682625771f, 0.287306368f }, { 35000, -0.00662239315f, 0.700808227f } } }, // Supersaw
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 9, 94266, false, 826.69243, 1157.08939, { { 5000, 0.0348474756f, -0.168766886f }, { 12000, -0.0719366521f, 0.288826376f }, { 25000, 0.181558818f, 0.0424098521f }, { 35000, -0.321783781f, -0.0548994206f } } }, // Airguitar 3
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 9, 94266, true, 830.517691, 772.62552, { { 5000, -0.208309069f, 0.152180359f }, { 12000, -0.264171928f, 0.163982511f }, { 25000, 0.0313629843f, -0.187507361f }, { 35000, 0.133838147f, 0.0704783946f } } }, // Airguitar 3
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 10, 1004, false, 12678.7464, 11831.2032, { { 5000, 0.192205578f, 0.613839507f }, { 12000, 0.269521117f, -0.585603476f }, { 25000, 0.0944993123f, 0.0806781948f }, { 35000, -0.16715017f, 0.412193805f } } }, // Trumpet
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 10, 1004, true, 12261.8266, 9962.482, { { 5000, 0.422391087f, -0.251674503f }, { 12000, -0.46900028f, -0.57652849f }, { 25000, -0.535878778f, 0.115671799f }, { 35000, -0.545713186f, 0.0383624472f } } }, // Trumpet
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 11, 30605, false, 1358.26232, 1520.29691, { { 5000, -0.0350573957f, 0.0372484438f }, { 12000, 0.0963054374f, -0.130206674f }, { 25000, 0.0404771306f, -0.270439237f }, { 35000, -0.0870027244f, 0.0245792065f } } }, // Silverswirll
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 11, 30605, true, 964.637209, 1040.25756, { { 5000, 0.111636952f, -0.00114471605f }, { 12000, 0.0483313873f, 0.0637735277f }, { 25000, -0.152803347f, 0.101604536f }, { 35000, 0.0288163591f, 0.0194431469f } } }, // Silverswirll
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 12, 34708, false, 21463.1948, 22013.1021, { { 5000, -0.00810255855f, -0.0122786947f }, { 12000, -0.163549975f, -0.203571558f }, { 25000, 0.419101298f, -1.1141516f }, { 35000, 0.498232335f, -0.394363374f } } }, // Padsaw
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 12, 34708, true, 22903.9209, 21556.3509, { { 5000, -0.00977799948f, -0.0114432834f }, { 12000, -0.0759382695f, 0.077038914f }, { 25000, -0.556497335f, -1.22787583f }, { 35000, -1.31076968f, -1.73392022f } } }, // Padsaw
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 13, 6395, false, 3516.18148, 3565.45486, { { 5000, -0.0564712696f, -0.262329876f }, { 12000, 0.113444217f, 0.168150783f }, { 25000, -0.45024398f, -0.694699228f }, { 35000, 0.151807249f, -0.00405737339f } } }, // Turbular Bells 2
+        { "Product demos/Electric Loop - The Ogun Dream.flp", 13, 6395, true, 3571.34372, 3626.15163, { { 5000, -0.0878480822f, -0.275067806f }, { 12000, 0.230907321f, 0.28320539f }, { 25000, -0.470044613f, -0.701287091f }, { 35000, 0.195627496f, 0.0175700653f } } }, // Turbular Bells 2
+    };
+    std::map<std::string, std::vector<std::vector<std::uint8_t>>> states;
+    int checked = 0;
+    for (const auto& g : goldens)
+    {
+        if (! states.contains (g.file))
+        {
+            std::ifstream in (std::filesystem::path (realFlpDir) / "Demo projects" / g.file, std::ios::binary);
+            const std::vector<std::uint8_t> bytes ((std::istreambuf_iterator<char> (in)), std::istreambuf_iterator<char>());
+            auto& list = states[g.file];
+            if (! bytes.empty())
+                for (const auto& c : flp::parseProject (bytes).channels)
+                    if (c.pluginName == "Ogun")
+                        list.push_back (c.pluginState);
+        }
+        const auto& list = states[g.file];
+        if (list.empty())
+            continue; // not this installation
+        CHECK ((int) list.size() > g.ordinal);
+        if ((int) list.size() <= g.ordinal)
+            continue;
+        const auto& st = list[(std::size_t) g.ordinal];
+        CHECK (st.size() == g.stateSize);
+        lynx::ogun::RefOptions opt;
+        opt.quality = g.export4 ? 4 : -1;
+        const auto y = lynx::ogun::renderReference (st, { { 0, 60, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20000 },
+                                                          { 8000, 67, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 26000 },
+                                                          { 16000, 55, 0.95, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 30000 } }, 44100.0, 39690, opt);
+        double el = 0.0, er = 0.0, peak = 0.0;
+        for (std::size_t i = 0; i + 1 < y.size(); i += 2)
+            el += (double) y[i] * y[i], er += (double) y[i + 1] * y[i + 1], peak = std::max ({ peak, (double) std::abs (y[i]), (double) std::abs (y[i + 1]) });
+        bool ok = y.size() == 2 * 39690 && std::abs (el - g.el) <= 1e-5 * g.el && std::abs (er - g.er) <= 1e-5 * g.er;
+        for (const auto& smp : g.s)
+            ok = ok && std::abs (y[2 * (std::size_t) smp.at] - smp.l) <= 2e-5 * peak && std::abs (y[2 * (std::size_t) smp.at + 1] - smp.r) <= 2e-5 * peak;
+        if (! ok)
+            std::printf ("  Ogun %s #%d (q%s) differs from the model: energy %.9g %.9g (model %.9g %.9g)\n", g.file, g.ordinal,
+                         g.export4 ? "4" : "-state", el, er, g.el, g.er);
+        CHECK (ok);
+        ++checked;
+    }
+    std::printf ("  Ogun: %d demo renders checked against the reference model\n", checked);
+    CHECK (checked == (int) std::size (goldens));
+}
+
 TEST (harmless_rack)
 {
     // REA_rodada36: Harmless's effects rack against our reference model (rack.py / maxmodel.py, which match the
@@ -6687,9 +7087,10 @@ TEST (harmless_rack)
         std::array<int, 100> p {};
         p[98] = 1000;
         const auto [l, r] = run (p, 1, preset, 4096, 4096);
-        const std::tuple<int, float, float> golden[] { { 100, 0.02499794f, 0.88166064f }, { 1000, 0.56971455f, -0.62808162f },
-                                                       { 2047, -0.27541649f, 0.70913559f }, { 3000, 0.32431602f, -0.37985173f },
-                                                       { 4095, -0.12743534f, -0.15237498f } };
+        // SG_x64.dll's own output (EXEC, REA_rodada40: bit-identical to the port)
+        const std::tuple<int, float, float> golden[] { { 100, 0.024997942f, 0.88166064f }, { 1000, 0.56971401f, -0.62808102f },
+                                                       { 2047, -0.27541628f, 0.709135f }, { 3000, 0.32431623f, -0.37985197f },
+                                                       { 4095, -0.12743522f, -0.15237485f } };
         for (const auto& [i, gl, gr] : golden)
             CHECK (std::abs (l[(std::size_t) i] - gl) < 2e-6f && std::abs (r[(std::size_t) i] - gr) < 2e-6f);
         float peak = 0.0f;
@@ -6712,9 +7113,10 @@ TEST (harmless_rack)
         std::array<int, 100> p {};
         p[98] = 600;
         const auto [l, r] = run (p, 2, preset, 4096, 4096);
-        const std::tuple<int, float, float> golden[] { { 100, 0.0f, 0.0f }, { 1000, -0.46856275f, -0.63261062f },
-                                                       { 2047, 0.20268074f, 0.5414567f }, { 3000, -0.25614089f, -0.49984524f },
-                                                       { 4095, 0.10172816f, 0.0505573f } };
+        // SG_x64.dll's own output (EXEC, REA_rodada40; the port is within −142 dB of it)
+        const std::tuple<int, float, float> golden[] { { 100, 0.0f, 0.0f }, { 1000, -0.46856543f, -0.63262129f },
+                                                       { 2047, 0.20268451f, 0.54145539f }, { 3000, -0.25613472f, -0.49985155f },
+                                                       { 4095, 0.10172445f, 0.050564945f } };
         for (const auto& [i, gl, gr] : golden)
             CHECK (std::abs (l[(std::size_t) i] - gl) < 2e-6f && std::abs (r[(std::size_t) i] - gr) < 2e-6f);
     }
@@ -6738,9 +7140,112 @@ TEST (harmless_rack)
         const auto found = lynx::hlfx::maximusStateFromFst (fst);
         CHECK (found && *found == st);
         auto rms = st;
-        rms[4 + 4 * (7 + 13 * 3 + 12)] = 1; // RMS detector on the master (decoded in REA_rodada38: Harmor's preset 2)
+        rms[4 + 4 * (7 + 13 * 3 + 12)] = 1; // RMS detector on the master (decoded in REA_rodada40)
         CHECK (lynx::hlfx::makeMaximusPreset (rms) != nullptr);
+        auto masterMid = st;
+        masterMid[0x1fc] = 1; // "Master Mid mode": not decoded
+        CHECK (lynx::hlfx::makeMaximusPreset (masterMid) == nullptr);
+    }
+}
+
+TEST (maximus_engine)
+{
+    // REA_rodada40: the engine on its own (MaximusProcessor), states of our own against the installation's DLLs
+    // (goldens = the DLL's output for the same input, EXEC), and the containers of the mixer effect and Vocodex
+    std::vector<float> inL (4096), inR (4096);
+    for (int i = 0; i < 4096; ++i)
+    {
+        inL[(std::size_t) i] = (float) (1.5 * std::sin (2.0 * 3.141592653589793 * 440.0 * i / 44100.0) * std::min (1.0, i / 400.0));
+        inR[(std::size_t) i] = (float) (1.2 * std::sin (2.0 * 3.141592653589793 * 660.0 * i / 44100.0));
+    }
+    auto run = [&] (std::shared_ptr<const lynx::hlfx::MaximusPreset> preset, int mix) {
+        lynx::hlfx::MaximusProcessor m;
+        m.prepare (std::move (preset), 44100.0, mix);
+        std::vector<float> l (inL), r (inR);
+        for (int s = 0; s < 4096; s += 512)
+            m.process (l.data() + s, r.data() + s, 512);
+        return std::make_pair (l, r);
+    };
+    using Env = std::vector<std::array<double, 4>>;
+    const Env def { { 0.0, 0.0, 0.0, 0 }, { 0.5, 0.5, 0.0, 0 }, { 0.5, 0.5, 0.0, 0 } };
+    const Env knee { { 0.0, 0.0, 0.0, 0 }, { 0.35, 0.35, 0.0, 0 }, { 0.65, 0.6, 0.36, 7 } };
+    const Env t0 { { 0.0, 0.0, 0.0, 0 }, { 0.5, 0.5, 0.14, 0 }, { 0.5, 0.5, 0.0, 0 } };
+    const Env m0 { { 0.0, 0.0, 0.0, 0 }, { 0.5, 0.5, 0.0, 0 }, { 0.5, 0.6, 0.085, 0 } };
+    auto band = [] (int mode, int pre = 1000, int post = 1000, int sep = 0, int sat = 0, int ceil = 1000, int att = 1115, int rel2 = 0,
+                    int sus = 2882, int rms = 0) { return std::array<int, 13> { mode, pre, post, sep, sat, ceil, att, rel2, 2, 5000, 3, sus, rms }; };
+    auto check = [] (const std::pair<std::vector<float>, std::vector<float>>& out, const std::vector<std::tuple<int, float, float>>& golden) {
+        for (const auto& [i, gl, gr] : golden)
+            CHECK (std::abs (out.first[(std::size_t) i] - gl) < 2e-6f && std::abs (out.second[(std::size_t) i] - gr) < 2e-6f);
+    };
+    // RMS detectors, saturation mode B, a 5 Hz low cut, 12 dB high split (SG_x64.dll: port within −152 dB)
+    auto st3 = maximusTestState ({ 19800, 1, 48065, 0, 1115, 1000, 0 },
+                                 { band (0, 1500, 1000, 0, 400, 900, 1115, 0, 2882, 1), band (0, 1340, 1000, 0, 0, 1000, 1115, 0, 1570, 1),
+                                   band (1, 1000, 1200, 0, 1000, 1000), band (0, 1000, 1000, 0, 250, 1000, 1115, 4464, 2882, 1) },
+                                 { def, def, knee, def, t0, def, m0, def }, 0);
+    const auto p3 = lynx::hlfx::makeMaximusPreset (st3);
+    CHECK (p3 != nullptr);
+    check (run (p3, 1000), { { 100, 0.0f, 0.0f }, { 1000, 0.87061065f, 0.64004499f }, { 2047, -0.97266865f, 0.60940075f },
+                             { 3000, 0.96658099f, 0.9250561f }, { 4095, 0.99094611f, -0.964059f } });
+    // the same with solo on (UI byte 0x1EF) and the low band selected (0x1E0): bit-identical to SG_x64.dll
+    auto solo = st3;
+    solo[0x1ef] = 1;
+    std::memset (solo.data() + 0x1e0, 0, 4);
+    check (run (lynx::hlfx::makeMaximusPreset (solo), 1000),
+           { { 100, 3.2922967e-06f, 0.00036916698f }, { 1000, 0.15653539f, -0.047913823f }, { 2047, -0.17336531f, 0.019099623f },
+             { 3000, 0.17185682f, -0.017173048f }, { 4095, 0.16714551f, 0.019473195f } });
+    // the legacy linear-phase FIR band split (UI byte 0x1FD; SG_x64.dll: port within −148 dB)
+    auto fir = st3;
+    fir[0x1fd] = 1;
+    check (run (lynx::hlfx::makeMaximusPreset (fir), 1000),
+           { { 100, 0.0f, 0.0f }, { 1000, 0.97986746f, 0.18555209f }, { 2047, -0.98930448f, -0.95970845f },
+             { 3000, 0.98856646f, -0.44592777f }, { 4095, 0.99069679f, 0.94382554f } });
+    // Soundgoodizer_x64.dll's own build with a v4 file (its presets' layout): a copy of the round-36 state without
+    // oversampling, through a byte-identical copy of the installation's DLL with this file as its preset (EXEC)
+    const auto st2 = maximusTestState ({ 19800, 1, 48065, 1, 891, 600, 32768 },
+                                       { band (1, 1264, 1296, 500, -500, 1200), band (0, 1340, 1000, -348, 0, 1000, 1115, 0, 1570),
+                                         band (0, 1364, 1152, 0, 0, 1000, 1115, 0, 1186), band (0, 1000, 1000, 0, -196, 1000, 1115, 4464, 1538) },
+                                       { def, def, knee, def, t0, def, m0, def }, 0);
+    std::vector<std::uint8_t> v4 { 4, 0, 0, 0 };
+    v4.insert (v4.end(), st2.begin() + 4, st2.begin() + 0x1f5);
+    v4.insert (v4.end(), st2.begin() + 0x1fe, st2.end());
+    const auto p4 = lynx::hlfx::makeMaximusPreset (v4, lynx::hlfx::MaximusBuild::soundgoodizer);
+    CHECK (p4 != nullptr);
+    check (run (p4, 600), { { 100, 0.0f, 0.0f }, { 1000, -0.60926896f, -0.6652832f }, { 2047, 0.40872875f, 0.36375371f },
+                            { 3000, -0.41941205f, -0.61312866f }, { 4095, -0.12878418f, 0.27944946f } });
+    CHECK (lynx::hlfx::makeMaximusPreset (st2, lynx::hlfx::MaximusBuild::soundgoodizer) != nullptr); // v7: also read by that build
+    // the mixer effect's container and the effect itself
+    lynx::maximusfx::Blob blob;
+    blob.build = lynx::hlfx::MaximusBuild::soundgoodizer;
+    blob.mix = 600;
+    blob.state = v4;
+    const auto packed = lynx::maximusfx::pack (blob);
+    const auto back = lynx::maximusfx::unpack (packed);
+    CHECK (back && back->build == blob.build && back->mix == 600 && back->state == v4);
+    auto slot = lynx::makeEffectSlot (lynx::EffectKind::maximus);
+    slot.state = packed;
+    auto fx = lynx::makeEffect (slot);
+    fx->prepare (44100.0);
+    {
+        std::vector<float> l (inL), r (inR);
+        for (int s = 0; s < 4096; s += 1024) // longer host blocks are split into the engine's 512-frame calls
+            fx->process (l.data() + s, r.data() + s, 1024, slot.params, 120.0);
+        const auto ref = run (p4, 600);
+        CHECK (l == ref.first && r == ref.second);
     }
+    const std::vector<std::uint8_t> sgState { 3, 0, 0, 0, 2, 0, 0, 0, 0x78, 2, 0, 0 };
+    const auto sg = lynx::maximusfx::parseSoundgoodizer (sgState);
+    CHECK (sg && sg->preset == 2 && sg->amount == 632 && std::string (lynx::maximusfx::soundgoodizerPresetFile (2)) == "c.dat");
+    CHECK (lynx::soundgoodizerPresetPath (sgState) == "Plugins\\Fruity\\Effects\\Soundgoodizer\\Data\\Presets\\c.dat");
+    CHECK (lynx::soundgoodizerExact (sgState, v4).has_value() && ! lynx::soundgoodizerExact (sgState, {}).has_value());
+    // Vocodex's appended installation data survives a round trip and leaves FL's state untouched
+    const std::vector<std::uint8_t> flState { 8, 0, 0, 0, 1, 2, 3 };
+    lynx::vocodex::InstallData data;
+    data.sgDat = st2;
+    data.carrierState = { 9, 9, 9 };
+    const auto joined = lynx::vocodex::appendInstallData (flState, data);
+    const auto [raw, files] = lynx::vocodex::splitInstallData (joined);
+    CHECK (raw == flState && files.sgDat == st2 && files.carrierState == data.carrierState);
+    CHECK (lynx::vocodex::splitInstallData (flState).first == flState);
 }
 
 // ---- Sytrus (REA_rodada31) -------------------------------------------------------------------------------------------
@@ -7463,3 +7968,5 @@ TEST (morphine_engine)
     }
     CHECK (diff == 0.0 && energy > 1e-3);
 }
+// Workflow P2 (docs/WORKFLOW_FL.md)
+#include "WorkflowP2Tests.inc"

+ 50 - 0
tools/make_doc_icon.py

@@ -0,0 +1,50 @@
+# Generates the LYNX project-file icon (a dark page with a folded corner, a red band and the LYNX badge).
+# Usage: python3 tools/make_doc_icon.py resources/lynx_icon_256.png resources/LYNX_doc.ico [preview.png]
+import sys
+from PIL import Image, ImageDraw, ImageFilter
+
+S = 1024
+badge = Image.open(sys.argv[1]).convert("RGBA")
+
+page = Image.new("RGBA", (S, S), (0, 0, 0, 0))
+left, right, top, bottom = 150, 874, 40, 984
+fold = 230
+outline = [(left, top), (right - fold, top), (right, top + fold), (right, bottom), (left, bottom)]
+
+# soft shadow under the page
+shadow = Image.new("RGBA", (S, S), (0, 0, 0, 0))
+ImageDraw.Draw(shadow).polygon([(x + 14, y + 20) for x, y in outline], fill=(0, 0, 0, 120))
+page = Image.alpha_composite(page, shadow.filter(ImageFilter.GaussianBlur(22)))
+
+body = Image.new("RGBA", (S, S), (0, 0, 0, 0))
+d = ImageDraw.Draw(body)
+d.polygon(outline, fill=(38, 38, 43, 255))
+# vertical sheen: lighter at the top
+sheen = Image.linear_gradient("L").resize((S, S)).point(lambda v: int(40 * (1 - v / 255)))
+light = Image.new("RGBA", (S, S), (255, 255, 255, 0))
+light.putalpha(sheen)
+mask = Image.new("L", (S, S), 0)
+ImageDraw.Draw(mask).polygon(outline, fill=255)
+light.putalpha(Image.composite(light.getchannel("A"), Image.new("L", (S, S), 0), mask))
+body = Image.alpha_composite(body, light)
+d = ImageDraw.Draw(body)
+# red band at the bottom (the accent colour)
+d.rectangle((left, bottom - 150, right, bottom), fill=(214, 40, 40, 255))
+d.rectangle((left, bottom - 150, right, bottom - 138), fill=(240, 80, 70, 255))
+# folded corner
+d.polygon([(right - fold, top), (right - fold, top + fold), (right, top + fold)], fill=(78, 78, 86, 255))
+d.line([(right - fold, top), (right, top + fold)], fill=(20, 20, 24, 255), width=6)
+# thin border
+d.line(outline + [outline[0]], fill=(90, 90, 98, 255), width=8, joint="curve")
+page = Image.alpha_composite(page, body)
+
+# the LYNX badge in the middle of the page
+size = 560
+b = badge.resize((size, size), Image.LANCZOS)
+page.alpha_composite(b, ((left + right - size) // 2, top + fold - 40))
+
+sizes = [16, 20, 24, 32, 40, 48, 64, 96, 128, 256]
+page.save(sys.argv[2], format="ICO", sizes=[(s, s) for s in sizes])
+if len(sys.argv) > 3:
+    page.resize((256, 256), Image.LANCZOS).save(sys.argv[3])
+print("ok")

+ 83 - 0
tools/ogunrender.cpp

@@ -0,0 +1,83 @@
+// Renders an Ogun state with LYNX's engine exactly like our round-37 reference model drives it (verification harness,
+// REA_rodada37 §1.21): ogunrender <state.bin> <out.f32> <length> <rate> [q=N] [tempo=X] [blk=N] [counter=N] [maxpoly=N]
+// [kills=0|1] [note=start,key,vel,fvol,fpan,pofs,fcut,fres,relvel,off ...] [j0=s0,s1,...]
+// Output: interleaved stereo float32. Prints the render time and the fallbacks the state relies on.
+
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <fstream>
+#include <iterator>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "core/Ogun.h"
+
+int main (int argc, char** argv)
+{
+    if (argc < 5)
+    {
+        std::fprintf (stderr, "usage: ogunrender state.bin out.f32 length rate [q=N] [tempo=X] [blk=N] [counter=N] [maxpoly=N] [kills=0|1] "
+                              "[note=start,key,vel,fvol,fpan,pofs,fcut,fres,relvel,off ...] [j0=s0,s1,...]\n");
+        return 2;
+    }
+    std::ifstream in (argv[1], std::ios::binary);
+    const std::vector<std::uint8_t> state ((std::istreambuf_iterator<char> (in)), std::istreambuf_iterator<char>());
+    const int length = std::atoi (argv[3]);
+    const double rate = std::atof (argv[4]);
+    lynx::ogun::RefOptions opt;
+    std::vector<lynx::ogun::RefNote> notes;
+    for (int i = 5; i < argc; ++i)
+    {
+        const std::string a = argv[i];
+        auto val = [&] { return a.substr (a.find ('=') + 1); };
+        if (a.rfind ("q=", 0) == 0)
+            opt.quality = std::atoi (val().c_str());
+        else if (a.rfind ("tempo=", 0) == 0)
+            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 ("counter=", 0) == 0)
+            opt.counter = std::atoi (val().c_str());
+        else if (a.rfind ("maxpoly=", 0) == 0)
+            opt.maxPolyphony = std::atoi (val().c_str());
+        else if (a.rfind ("kills=", 0) == 0)
+            opt.hostKills = std::atoi (val().c_str()) != 0;
+        else if (a.rfind ("j0=", 0) == 0)
+        {
+            std::stringstream ss (val());
+            std::string t;
+            while (std::getline (ss, t, ','))
+                opt.j0Shift.push_back (std::atoi (t.c_str()));
+        }
+        else if (a.rfind ("note=", 0) == 0)
+        {
+            std::stringstream ss (val());
+            std::string t;
+            std::vector<double> v;
+            while (std::getline (ss, t, ','))
+                v.push_back (std::atof (t.c_str()));
+            v.resize (10, 0.0);
+            lynx::ogun::RefNote n;
+            n.start = (int) v[0], n.key = (int) v[1], n.velocity = v[2], n.finalVol = v[3], n.finalPan = v[4];
+            n.pitchOffset = v[5], n.fcut = v[6], n.fres = v[7], n.releaseVelocity = v[8], n.release = (int) v[9];
+            notes.push_back (n);
+        }
+    }
+    const auto t0 = std::chrono::steady_clock::now();
+    const auto out = lynx::ogun::renderReference (state, notes, rate, length, opt);
+    const auto ms = std::chrono::duration<double, std::milli> (std::chrono::steady_clock::now() - t0).count();
+    if (out.empty())
+    {
+        std::fprintf (stderr, "state not usable\n");
+        return 1;
+    }
+    std::ofstream o (argv[2], std::ios::binary);
+    o.write ((const char*) out.data(), (std::streamsize) (out.size() * sizeof (float)));
+    std::printf ("render_ms=%.1f\n", ms);
+    for (const auto& s : lynx::ogunFallbacks (state))
+        std::printf ("fallback: %s\n", s.c_str());
+    return 0;
+}

+ 1 - 1
tools/renderwav.cpp

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