Explorar el Código

Merge branch 'feature/tools83'

Ka1-S hace 1 mes
padre
commit
65e30ca

+ 3 - 0
CMakeLists.txt

@@ -111,6 +111,8 @@ target_sources(lynx_core PRIVATE
 # workflow P2 (note tools, mixer operations, history labels, browser search)
 target_sources(lynx_core PRIVATE
     src/core/NoteTools.cpp
+    src/core/PianoRollTools.cpp
+    src/core/EventEdit.cpp
     src/core/MixerOps.cpp
     src/core/History.cpp
     src/core/SearchQuery.cpp)
@@ -223,6 +225,7 @@ if(LYNX_BUILD_APP)
     # workflow P2: note tool dialogs, tool windows, undo history, quick-add palette
     target_sources(LYNX PRIVATE
         src/ui/NoteToolDialogs.cpp
+        src/ui/EventEditor.cpp
         src/ui/ToolWindow.cpp
         src/ui/HistoryPanel.cpp
         src/ui/MissingFilesDialog.cpp

+ 163 - 0
docs/analise/REA_rodada83.md

@@ -0,0 +1,163 @@
+# Round 83: Piano Roll tools (quantizer, chopper, flamer, LFO, claw machine, articulator, riff machine, chord progression) and the Event editor
+
+Branch `feature/tools83`. English, clean-room: FL Studio's code was decompiled to learn **what** each tool does
+(formulas, ranges, defaults); LYNX's code is its own and no Image-Line code or pseudocode is in the repository.
+FL's score templates (`.fsc`) and chord progression presets are **read at run time from the user's installation**
+(like GMS samples); nothing of them is committed.
+
+Evidence markers: **[DECOMP]** decompiled/disassembled FL code, **[DATA]** Delphi form resources / installation
+files, **[model]** our reading where the code alone does not settle it, **not confirmed** where unknown.
+
+- Target: `FLEngine_x64.dll` of FL Studio 2026 (same build as rounds 69/72/76). Tools: Ghidra 12.1.4 headless on a
+  copy of round 76's analysed project (`~/ghproj/r83`), our scripts `gh/scripts/DecAt.java`, `Xr.java`; our Python
+  readers in `~/.claude/jobs/f8789b49/tmp/r83/py/`: `dfm.py` (binary DFM, all properties), `vmt.py` (Delphi
+  published method table → handler addresses), `fields.py` (published field table → component offsets),
+  `vdiff.py` (virtual slots a form overrides). Decompilations: `gh/d*.c, q*.c, s*.c, l*.c, t*.c, lg*.c, rm.c`.
+
+## 0. How FL's tool forms are built [DECOMP]
+
+All tools derive from `TPRBaseToolForm`. Each control's `OnChange` stores the values and calls the base
+"update" (`0xdd2410`), which re-runs the tool's virtual **Process** (VMT slot `+0x390`) on a copy of the original
+notes: a live preview; Accept keeps it. Other overridden slots: `+0x388` save state, `+0x398` init (e.g. next free
+note group), `+0x3a0` reset to defaults, `+0x3a8` randomise ("throw dice" in the riff machine). A tool processes
+the selected notes if there is a selection, else all notes (`note+0x13 & 0x80` against the form's selection flag).
+Integer helpers: `FUN_0040c660` = round half to even (x64 `cvtsd2si`), wheel strengths are 0..128 with
+`(a·s) / 128` rounding toward zero.
+
+Tick units FL keeps for the current PPQ (static values at PPQ 96): `0x15d89c0` = 96 (one beat), `0x15d89c4` = 24
+(one step), `0x15d89c8` = 96 (one beat), `0x15d89cc` = 4 (minimum note length, 1/24 beat) **[model: values at
+PPQ 96; the writers were not traced]**.
+
+## 1. Quantizer — `TPRQuantizeForm` (Process `0xbd4bb0`, per note `0xbd47e0`)
+
+- [DATA] Controls: template (a score `.fsc`, default `Quantization\Default.fsc` = sixteen 1/16 notes), Start time
+  strength 0..128 (default 64), Duration strength 0..128 (64), Sensitivity 12..192 (36), duration mode
+  {Leave duration, Leave end time, Quantize duration, Quantize end time} (default 0), level strengths for pan,
+  velocity, release, mod X, mod Y, pitch 0..128 (128).
+- [DECOMP] The template repeats with period P = its length (end of the last note, a note counts at least 1 tick)
+  rounded **up to whole beats**. Nearest template point to time t: search the template notes in the periods
+  before, at and after `t div P`; candidate = period start + note start (+ note length − 1 when matching an end);
+  keep the one with |t − candidate| **strictly** below the window (sensitivity × step / 48). No candidate: t stays.
+- [DECOMP] start += (target − start) · strength / 128. Mode 1: keep the end (length = old end − new start + 1,
+  minimum length); mode 2: length moves toward the matched template note's length; mode 3: the end moves toward
+  the nearest template end (search with "end" points), then length = end − start + 1.
+- [DECOMP] Levels (only with a matched template note): velocity target = template velocity × note velocity / 100;
+  other levels target = template value + (note value − the level's default); value += (target − value) · strength
+  / 128, clamped. A note whose velocity becomes 0 is removed.
+
+## 2. Chopper — `TPRSliceForm` (Process `0xdea9e0`, pattern load `0xdea500`)
+
+- [DATA] Controls: pattern (`Chopping\Default.fsc`), Time mul 1..7 → ×{1/8, 1/4, 1/2, 1, 2, 3, 4} (table
+  `0x1527984`, default 4 = ×1), Absolute pattern (default on), Group notes, level strengths (default 128).
+- [DECOMP] Loading: positions and lengths × time mul (rounded, length ≥ 1); period = the pattern's length × mul; a
+  note of colour 12 sets the period to its (scaled) length and is dropped.
+- [DECOMP] Each note (length > 0) is replaced by the pattern repeated from the note start (Absolute: from the
+  previous period boundary of the song, so the pattern stays on the song grid) up to the note end. Each piece:
+  length = min(pattern note length, note end − piece start); a pattern note of colour 4 lasts to the note end in
+  the first round and is dropped in later rounds; pieces before the note start are cut at it; key = note key +
+  pattern key − 60 (clamped 0..131); slide flag from the pattern note; levels blended like the quantizer.
+
+## 3. Flamer — `TPRFlamForm` (Process `0xdebce0`)
+
+- [DATA] Time −192..192 (default 192), Velocity 0..128 (85), Absolute, Before. Presets (table `0x1527c00`):
+  Flam (−64, 85, absolute), Early flam (−64, 85, absolute, before), Double stroke (192, 85, relative),
+  Early double stroke (−192, 85, relative, before).
+- [DECOMP] Offset T: relative = time × step / 192 (integer); absolute = round(time × 100/192 ms × BPM × PPQ /
+  60000). When `before ≠ (T < 0)` the original moves to start − T, else it stays; the added note starts at
+  (original position) + T. Both are clamped at 0. The added note (only if it lands elsewhere) gets velocity ×
+  velocity wheel / 128; if it comes first, it is shortened so it ends where the original starts.
+
+## 4. LFO — `TPRLFOForm` (Process `0xde87c0`)
+
+- [DATA] Start/End boxes: Value 0..65536 (32768), Range −65536..65536 (16384), Speed 0..40960 (20480); End
+  enabled; "log" speed; Shape {Sine, Triangle, Square}; Phase 0..65535 (32768).
+- [DECOMP] Speed exponent e = 7 − speed / 4096; period (ticks) = max(1, beat × 2^e) **[model: the exponent base
+  is a run-time double, 2 matches the speed menu "1 step … 512 steps"]**. Over the time range [a, b), per tick:
+  φ ← frac(φ); wave = sin(2πφ) | 1 − |4φ − 2| | 1 − 2·round(φ); value = min + (V + p·ΔV)·k + wave·(R + p·ΔR)·k
+  with k = (max − min)/65536, p = (t − a)/(b − a); clamp; then φ += 1/period, and the period (or, with "log", the
+  exponent) moves linearly toward the end value. Initial φ = phase/65536 + {0.25, 0.75, 0.5} by shape. In the
+  Piano Roll each note gets the value at its start tick (notes before a get the value at a).
+
+## 5. Claw machine — `TPRTripletForm` (Process `0xdef770`, time warp `0xdef670`)
+
+- [DATA] Period {Beat, 2, 4, 8, 16 beats}; Trash every {1/4, 2/4, 3/4, 4/4, 1/3, 2/3, 3/3, 1/2, 2/2, (none)}
+  (Reset: 4/4); Time dist −1024..1024 (0); Stretch to compensate (on); Remove short notes (on).
+- [DECOMP] Slice s = P / n. Positions are rotated by k slices (k = n − a for "a/n") so the trashed slice is the last
+  of the period; a note starting in it moves to the next period, an end inside it is pulled back; then every whole
+  trashed slice before/inside the note is removed (start −= (start div P)·s, length −= ((length + start mod P)
+  div P)·s) and the rotation is undone (negative starts are cut at 0).
+- [DECOMP] Then a time warp: t' = t × (stretch ? n/(n−1) : 1); inside each period P the fraction f is bent by
+  c = sign(d)·(101^|d| − 1)/2 (d = dist/1024): c > 0: f ← 1 − ((|c|+1)^(1−f) − 1)/|c|; c < 0: f ← ((|c|+1)^f − 1)/|c|;
+  result rounded. Start and end are warped; length ≤ 0 (or below the minimum with "Remove short notes") deletes
+  the note, else length ≥ minimum.
+
+## 6. Articulator — `TPRLegatoForm` (Process `0xdd3550`)
+
+- [DATA] Multiply 10..100 % (100), Variation 0..100 % (0), Gap 0..240 (0, in 1/960 beat), Seed, Use lengths, Chop
+  chords, Only with selection. Presets: Legato 100 %, Portato 75 %, Staccato 20 % (table `0x15269e4`), Ensure small
+  gap (100 %, gap 20, use lengths), Just chop chords.
+- [DECOMP] Chop chords: at every distinct note start, notes that started earlier and are still sounding are cut
+  there and continued by a copy. Then each note's room d = distance to the next note that starts at least the
+  minimum length later; the last notes: their own length if they end on a bar line, else up to the next bar line
+  **[model: `0x1062fd0` read as "next bar"]**. Length = min(base × multiply, d − gap) with base = d (or the note's
+  own length with "Use lengths"), minus rand·variation·length (MT19937 seeded with the seed, rand = u32 / 2³²),
+  rounded, at least the minimum. The notes of the last chord all take the last note's length.
+
+## 7. Riff machine — `TPRScoreCreatorForm` (Process `0xdd1290`)
+
+- [DECOMP] A chain of the other tools embedded as 8 steps (ids at `0x152678c`): Prog = chopper (patterns
+  `Chopping\Riff machine step 1\`), Chord = chopper (`…step 2\`), Arp = arpeggiator (`Arpeggiator\Riff machine\`),
+  Levels = randomizer, Mirror = flipper, Art = articulator, Groove = quantizer (`Quantization\Riff machine\`), Fit =
+  limiter. Unless "Work on existing score", the pattern is replaced by one note of Length bars at key 48 before the
+  steps run. "Throw dice" calls each tool's randomise slot (e.g. chopper: random pattern, time mul ×{1/2, 1, 2},
+  random level strengths 64..128).
+- LYNX builds the same chain from its own tools (its arpeggiator, randomiser, flip and limiter are LYNX designs).
+
+## 8. Chord progression — `TPRChordToolForm`
+
+- [DATA] The tool is a Python package (`System\Tools\Chord progression\*.pyc`: Markov model, rhythm, performance
+  patterns) with presets in `Chords\presets.cpt` (Roman numerals, e.g. "I-V-vi-IV: Hopeful") and
+  `rhythm_presets.cpt` (`>` hit, `-` hold, `` ` `` rest). The model was **not** decompiled; LYNX's generator is its own
+  design (a small table of common diatonic moves, an "adventurous" control) and reads the installation's preset
+  files at run time when present.
+
+## 9. Event editor — `TEventEditForm`
+
+- [DATA] FL's event editor is the Piano Roll form in "event" mode with Draw/Paint/Delete/Select/Zoom tools, a target
+  control selector and step editing. FL stores pattern events as `.flp` event `0xDF` per pattern: 12-byte records
+  {u32 tick, u16 parameter, u16 target, i32 value} (12 demo projects use it). The value scale is the parameter's own
+  (e.g. 0..12800 for volumes) and the mixer target word is not decoded: **import not done** (not confirmed).
+
+## 10. What LYNX implements (our own code)
+
+- `src/core/PianoRollTools.{h,cpp}` (no JUCE, tested in `tests/tests.cpp` `prtools_*`): `parseScore` (FL `.fsc`: 24-byte
+  note records, and the 20-byte records of files written before FL 5 — 236 of the installation's score files — with
+  the < 5.3.0 colour shift, so FL's old chopping patterns keep their colour-4/12 meaning), `gridScore`; `quantize`,
+  `chop`, `flam`, `lfo`/`lfoCurve`, `claw`, `articulate` with FL's formulas above (ticks scaled from FL's PPQ to
+  LYNX's 960; levels as LYNX floats instead of FL bytes, so level rounding differs by < 1/128); chord progression
+  (`parseProgression` for FL's Roman-numeral preset syntax incl. ♭/♯, ∆, °, sus, add, 7/9/11/13, slash bass;
+  `toNumerals`, `generateProgression` — our own weighted table of diatonic moves, `writeProgression` with voice
+  leading, bass note and FL's rhythm cells); `riffMachine` (the 8-step chain of §7 over LYNX's tools; built-in
+  progression/chord shapes of our own when the installation's step patterns are missing).
+- `src/core/EventEdit.{h,cpp}` and `Song.h` `PatternEvents`: pattern event lanes (target + held values), draw/line/
+  erase/scale/randomise/LFO operations; `.lynx` saves them per pattern (`"events"`); channel/insert renumbering
+  follows them (`Song::forEachTarget`); undo label "Edit events".
+- Playback (`RackRenderer`): each lane takes an automation slot after the song's automations and binds like an
+  automation clip of its target (pattern events win over a clip of the same target). Pattern mode: the current
+  pattern's lanes at the looped position; song mode: inside a clip of the pattern its events, after it the value
+  it ended with, before the first clip the target's own value (position-only, like automation clips). Plugin
+  parameters driven by pattern events are also sent in pattern mode.
+- UI: `src/ui/NoteToolDialogs.*` (Quantize, Chop, Flam, LFO, Claw machine, Articulate, Riff machine, Chord
+  progression: live preview, Accept = one undo step; templates listed from the installation's
+  `Data/Patches/Scores/{Quantization,Chopping,Chopping/Riff machine step N}` and the chord tool's `presets.cpt` /
+  `rhythm_presets.cpt`); Piano Roll Tools menu. `src/ui/EventEditor.*`: Event editor window (target, Draw/Line/
+  Select, snap, Scale/Offset, Randomise, LFO, Clear), opened from the Piano Roll Tools menu ("Edit events...") and
+  every knob menu that offers "Create automation clip" ("Edit events in the pattern").
+
+## Where I stopped / next steps
+
+- Not done: FL `.flp` pattern events (0xDF) import — value scales per parameter not decoded; FL's arpeggiator /
+  randomizer / limiter algorithms in the riff machine (LYNX's own tools are used); FL's chord progression model
+  (Markov data in `.pyc`) — LYNX's generator is its own; the quantizer "groove" templates' extra FL features
+  (template preview graph); articulator "Only with selection" (LYNX looks for the next note among the processed
+  notes only).

+ 12 - 12
docs/analise/UI_windows_inventory.md

@@ -78,7 +78,7 @@ window); **missing** = nothing yet; **n/a** = not applicable to LYNX.
 | TPLClipPropForm "Clip properties" | missing | (playlist is another agent's area) |
 | TPLMergeArrangementForm "Merge arrangement" | missing | arrangements exist |
 | TPRNotePropForm "Note properties" | exists | Note inspector in the Piano Roll |
-| TEventEditForm "Piano roll - " (event editor) | missing | automation editor covers automation clips only |
+| TEventEditForm "Piano roll - " (event editor) | **exists (round 83)** | Event editor: pattern events of a target (draw, line, select, scale, randomise, LFO); knob menus "Edit events in the pattern" |
 | TEnvMapForm "Mapping" (velocity/controller curves) | missing | |
 | TParamCtrlForm (link to controller) | exists | "Link to MIDI controller" |
 | TMIDIInputForm "Remote control settings", TMIDIInputForm_Generic "Global link settings" | partial | MIDI learn exists, no settings dialog |
@@ -97,20 +97,20 @@ window); **missing** = nothing yet; **n/a** = not applicable to LYNX.
 
 | FL form (Caption) | LYNX | Notes |
 |---|---|---|
-| TPRQuantizeForm "Piano roll - quantizer" | partial | quantise starts / starts and lengths (menu), no dialog with strength/swing |
-| TPRSliceForm "Piano roll - chopper" | partial | "Chop to grid" |
+| TPRQuantizeForm "Piano roll - quantizer" | **exists (round 83)** | Quantize: FL templates (.fsc) or the grid + swing, start/duration strength, duration modes, sensitivity, level strengths |
+| TPRSliceForm "Piano roll - chopper" | **exists (round 83)** | Chop: FL chopping patterns (.fsc) or the grid, time multiplier, song-grid alignment, level strengths |
 | TPRArpForm "Piano roll - arpeggiator" | exists | Arpeggiate tool |
 | TPRStrumForm "Piano roll - strumizer" | exists | Strum tool |
 | TPRFlipForm "Piano roll - score flipper" | exists | Flip tool |
 | TPRRandomForm "Piano roll - randomizer" | exists | Randomise tool |
 | TPRLevelScaleForm "Piano roll - level scaling" | exists | Scale levels tool |
 | TPRKeyLimitForm "Piano roll - limiter / transposer" | exists | Limit tool |
-| TPRLegatoForm "Piano roll - articulator" | partial | "Make legato" |
-| TPRFlamForm "Piano roll - flamer" | missing | |
-| TPRLFOForm "Piano roll - LFO" | missing | |
-| TPRTripletForm "Piano roll - claw machine" | missing | |
-| TPRScoreCreatorForm "Piano roll - riff machine" | missing | |
-| TPRChordToolForm "Piano roll - generate chord progression" | missing | |
+| TPRLegatoForm "Piano roll - articulator" | **exists (round 83)** | Articulate: legato/portato/staccato presets, length, variation, gap, chop chords |
+| TPRFlamForm "Piano roll - flamer" | **exists (round 83)** | Flam: FL presets, time (steps or ms), velocity, before |
+| TPRLFOForm "Piano roll - LFO" | **exists (round 83)** | LFO on a note level (and in the Event editor) |
+| TPRTripletForm "Piano roll - claw machine" | **exists (round 83)** | Claw machine: period, remove every, time distortion, stretch |
+| TPRScoreCreatorForm "Piano roll - riff machine" | **exists (round 83)** | Riff machine: FL's 8-step chain over LYNX's tools, throw dice |
+| TPRChordToolForm "Piano roll - generate chord progression" | **exists (round 83)** | Chord progression: presets (FL's presets.cpt), Roman numerals, generator, rhythm, voicing (own generator) |
 | TPRFillForm "Advanced fill" | partial | fill every N steps, Euclidean fill |
 
 ### Edison / audio editor tools (TME* forms)
@@ -127,10 +127,10 @@ Round 82 did items 1 (General + Audio; not pan law / data folder), 2, 4 (inputs;
 1. **Settings › General** (moves the scattered Options items into one page) and **Settings › Audio** as a page
    (today a separate dialog); Project page: pan law, data folder.
 2. **Plugin manager**: scanned plugins (name, vendor, format, path, status), scan folders, rescan, failed plugins.
-3. **Event editor** for a channel's or insert's parameter events (FL's TEventEditForm), next to automation clips.
+3. ~~Event editor~~ (round 83).
 4. **MIDI settings** page: inputs on/off, which channel each input plays, output/sync.
-5. Piano roll tools still missing: quantizer dialog (strength, swing, start/end), chopper dialog, flamer, LFO,
-   articulator dialog, claw machine, riff machine, chord progression.
+5. ~~Piano roll tools~~ (round 83: quantizer, chopper, flamer, LFO, articulator, claw machine, riff machine, chord
+   progression).
 6. **Shortcut manager** (a GUI over keys.json).
 7. **Touch keyboard** window.
 8. **Clip properties**, **Merge arrangement** (after the Playlist work of the other agents lands).

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

@@ -1336,6 +1336,117 @@ countries: br
 "Ghost notes" = "Notas fantasma"
 "Note tools" = "Ferramentas de notas"
 "Snap to scale" = "Encaixar na escala"
+
+# --- Piano Roll tools (round 83)
+"Quantize" = "Quantizar"
+"Chop" = "Picotar"
+"LFO" = "LFO"
+"Claw machine" = "Claw machine"
+"Articulate" = "Articular"
+"Riff machine" = "Riff machine"
+"Chord progression" = "Progressão de acordes"
+"Throw dice" = "Jogar os dados"
+"Generate" = "Gerar"
+"Level strengths" = "Força nos níveis"
+"Template" = "Modelo"
+"Piano roll grid" = "Grade do Piano Roll"
+"Grid swing" = "Swing da grade"
+"Start time" = "Início"
+"Duration" = "Duração"
+"Leave duration" = "Manter a duração"
+"Leave end time" = "Manter o fim"
+"Quantize duration" = "Quantizar a duração"
+"Quantize end time" = "Quantizar o fim"
+"Duration strength" = "Força na duração"
+"Sensitivity" = "Sensibilidade"
+"Time" = "Tempo"
+"Keep on the song grid" = "Manter na grade da música"
+"Custom" = "Personalizado"
+"Flam" = "Flam"
+"Early flam" = "Flam antecipado"
+"Double stroke" = "Toque duplo"
+"Early double stroke" = "Toque duplo antecipado"
+"Time in milliseconds" = "Tempo em milissegundos"
+"Before the note" = "Antes da nota"
+"Phase" = "Fase"
+"Value" = "Valor"
+"Change toward the end" = "Mudar até o fim"
+"Logarithmic speed change" = "Mudança de velocidade logarítmica"
+"1 beat" = "1 tempo"
+"4 beats" = "4 tempos"
+"8 beats" = "8 tempos"
+"16 beats" = "16 tempos"
+"Remove every" = "Remover a cada"
+"Time distortion" = "Distorção do tempo"
+"Stretch to compensate" = "Esticar para compensar"
+"Remove short notes" = "Remover notas curtas"
+"Legato" = "Legato"
+"Portato" = "Portato"
+"Staccato" = "Staccato"
+"Small gaps" = "Pequenos espaços"
+"Only chop chords" = "Só picotar acordes"
+"Variation" = "Variação"
+"Gap" = "Espaço"
+"Variation seed" = "Semente da variação"
+"Scale the notes' own lengths" = "Usar a duração das próprias notas"
+"Chop chords" = "Picotar acordes"
+"Built-in" = "Embutido"
+"bars" = "compassos"
+"Work on the existing notes" = "Trabalhar sobre as notas existentes"
+"1. Progression" = "1. Progressão"
+"Rhythm and melody" = "Ritmo e melodia"
+"2. Chords" = "2. Acordes"
+"Chord shape" = "Forma do acorde"
+"3. Arpeggio" = "3. Arpejo"
+"4. Humanize levels" = "4. Humanizar níveis"
+"5. Mirror" = "5. Espelhar"
+"6. Articulation" = "6. Articulação"
+"7. Groove" = "7. Groove"
+"8. Fit to the scale" = "8. Encaixar na escala"
+"Key" = "Tom"
+"Scale" = "Escala"
+"(typed or generated)" = "(digitada ou gerada)"
+"minor" = "menor"
+"Held chords" = "Acordes sustentados"
+"Progression" = "Progressão"
+"Chords to generate" = "Acordes a gerar"
+"Adventurous" = "Ousadia"
+"Chord length" = "Duração do acorde"
+"2 bars" = "2 compassos"
+"Rhythm" = "Ritmo"
+"Bass note" = "Nota no baixo"
+"Smooth voicing" = "Voicing suave"
+"This template could not be read." = "Não foi possível ler este modelo."
+"This pattern could not be read." = "Não foi possível ler este padrão."
+"Type chords as Roman numerals, e.g. I-V-vi-IV or ii7 V7 Imaj7." = "Digite os acordes em algarismos romanos, por exemplo I-V-vi-IV ou ii7 V7 Imaj7."
+"Writes new notes on the selected channel. Accept keeps them as one undo step." = "Escreve notas novas no canal selecionado. Aceitar as mantém como um passo de desfazer."
+"Replaces {0} notes of the selected channel. Accept keeps the result as one undo step." = "Substitui {0} notas do canal selecionado. Aceitar mantém o resultado como um passo de desfazer."
+"Climb" = "Subida"
+"Gallop" = "Galope"
+"Long" = "Longo"
+"Syncopated" = "Sincopado"
+"Single" = "Nota única"
+"Fifth" = "Quinta"
+"Minor triad" = "Tríade menor"
+"Major triad" = "Tríade maior"
+"Minor 7th" = "Menor com sétima"
+"Chords" = "Acordes"
+"Edit events in the pattern" = "Editar eventos no pattern"
+"Edit events..." = "Editar eventos..."
+"Event editor" = "Editor de eventos"
+"Events - {0}" = "Eventos - {0}"
+"Draw" = "Desenhar"
+"Line" = "Linha"
+"Select" = "Selecionar"
+"Draw: drag to set the values; right-drag erases" = "Desenhar: arraste para definir os valores; arrastar com o botão direito apaga"
+"Line: drag a straight ramp" = "Linha: arraste uma rampa reta"
+"Select: drag a time range for the tools below" = "Selecionar: arraste um trecho de tempo para as ferramentas abaixo"
+"1 step" = "1 step"
+"4 bars" = "4 compassos"
+"Clear" = "Limpar"
+"Remove the events of the selection (or of the whole pattern)" = "Remove os eventos da seleção (ou do pattern inteiro)"
+"No events yet for {0}. Draw to add them; they play with the pattern." = "Ainda não há eventos para {0}. Desenhe para adicioná-los; eles tocam com o pattern."
+"Edit events: {0}" = "Editar eventos: {0}"
 "MIDI settings..." = "Configurações de MIDI..."
 "General settings..." = "Configurações gerais..."
 "Plugin manager..." = "Gerenciador de plugins..."

+ 1 - 1
scripts/build-local.sh

@@ -19,7 +19,7 @@ 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"
+CORE="$CORE src/core/NoteTools.cpp src/core/PianoRollTools.cpp src/core/EventEdit.cpp src/core/MixerOps.cpp src/core/History.cpp src/core/SearchQuery.cpp"
 # start-up sound (procedural)
 CORE="$CORE src/core/StartupSound.cpp"
 # FL's 3x Osc engine (REA round 47)

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

@@ -87,9 +87,9 @@ APP_SOURCES+=(src/core/KeyMap.cpp src/core/Workspace.cpp src/core/RackOps.cpp sr
 # 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)
+APP_SOURCES+=(src/core/NoteTools.cpp src/core/PianoRollTools.cpp src/core/EventEdit.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)
+APP_SOURCES+=(src/ui/NoteToolDialogs.cpp src/ui/EventEditor.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)
 # main window chrome: hint bar and toolbar widgets

+ 26 - 1
src/Main.cpp

@@ -27,6 +27,8 @@
 #include "ui/PluginManager.h"
 #include "ui/ShortcutManager.h"
 #include "ui/NoteToolDialogs.h"
+#include "ui/EventEditor.h"
+#include "core/EventEdit.h"
 #include "ui/ParametricEqEditor.h"
 #include "ui/Splash.h"
 #include "ui/Theme.h"
@@ -1515,11 +1517,34 @@ private:
                                                                          { lynx::NoteTool::flip, "-tool-flip.png" },
                                                                          { lynx::NoteTool::randomise, "-tool-randomise.png" },
                                                                          { lynx::NoteTool::scaleLevels, "-tool-scalelevels.png" },
-                                                                         { lynx::NoteTool::limit, "-tool-limit.png" } };
+                                                                         { lynx::NoteTool::limit, "-tool-limit.png" },
+                                                                         { lynx::NoteTool::quantize, "-tool-quantize.png" },
+                                                                         { lynx::NoteTool::chop, "-tool-chop.png" },
+                                                                         { lynx::NoteTool::flam, "-tool-flam.png" },
+                                                                         { lynx::NoteTool::lfo, "-tool-lfo.png" },
+                                                                         { lynx::NoteTool::claw, "-tool-claw.png" },
+                                                                         { lynx::NoteTool::articulate, "-tool-articulate.png" },
+                                                                         { lynx::NoteTool::riffMachine, "-tool-riff.png" },
+                                                                         { lynx::NoteTool::chordProgression, "-tool-chords.png" } };
                 for (const auto& [tool, name] : tools)
                     saveWindow (lynx::makeNoteToolPanel (offline, tool, roll.noteIndicesForSnapshot(), roll.gridForSnapshot()), name);
             }
 
+            // round 83: the event editor, with sample events on the selected channel's volume (removed afterwards)
+            {
+                const lynx::AutomationTarget volume { lynx::AutomationTargetKind::channelVolume, offline.getSelectedChannel() };
+                const auto before = offline.getSong().patterns[(std::size_t) offline.getSong().currentPattern].events;
+                offline.editSong ([&] (lynx::Song& s) {
+                    auto& lane = lynx::eventedit::laneFor (s.patterns[(std::size_t) s.currentPattern], volume);
+                    lynx::eventedit::line (lane, 0, lynx::ppq * 2, 0.2f, 0.9f, lynx::ticksPerStep);
+                    lynx::prtools::LfoOptions lfo;
+                    lfo.startSpeed = 7 * 4096; // one beat
+                    lynx::eventedit::applyLfo (lane, lynx::ppq * 2, lynx::ppq * 4, lfo, lynx::ticksPerStep);
+                }, false);
+                saveWindow (lynx::makeEventEditor (offline, volume), "-eventeditor.png");
+                offline.editSong ([&] (lynx::Song& s) { s.patterns[(std::size_t) s.currentPattern].events = before; }, false);
+            }
+
             // the Channel Rack with the step graph lane (velocity), and the Euclidean fill window
             ui.selectTabForSnapshot (0);
             ui.getRackForSnapshot().setGraphLevelForSnapshot (0);

+ 131 - 0
src/core/EventEdit.cpp

@@ -0,0 +1,131 @@
+#include "core/EventEdit.h"
+
+#include <algorithm>
+#include <cmath>
+#include <random>
+
+namespace lynx::eventedit
+{
+namespace
+{
+void sortLane (PatternEvents& lane)
+{
+    std::stable_sort (lane.events.begin(), lane.events.end(), [] (const PatternEvent& a, const PatternEvent& b) { return a.tick < b.tick; });
+}
+
+float clamp01 (float v) noexcept
+{
+    return std::clamp (v, 0.0f, 1.0f);
+}
+} // namespace
+
+PatternEvents* findLane (Pattern& pattern, const AutomationTarget& target) noexcept
+{
+    for (auto& l : pattern.events)
+        if (l.target == target)
+            return &l;
+    return nullptr;
+}
+
+const PatternEvents* findLane (const Pattern& pattern, const AutomationTarget& target) noexcept
+{
+    for (const auto& l : pattern.events)
+        if (l.target == target)
+            return &l;
+    return nullptr;
+}
+
+PatternEvents& laneFor (Pattern& pattern, const AutomationTarget& target)
+{
+    if (auto* l = findLane (pattern, target))
+        return *l;
+
+    pattern.events.push_back ({ target, {} });
+    return pattern.events.back();
+}
+
+void removeEmptyLanes (Pattern& pattern)
+{
+    pattern.events.erase (std::remove_if (pattern.events.begin(), pattern.events.end(),
+                                          [] (const PatternEvents& l) { return l.events.empty() || l.target.kind == AutomationTargetKind::none; }),
+                          pattern.events.end());
+}
+
+void setEvent (PatternEvents& lane, std::int64_t tick, float value)
+{
+    tick = std::max<std::int64_t> (0, tick);
+    auto it = std::lower_bound (lane.events.begin(), lane.events.end(), tick, [] (const PatternEvent& e, std::int64_t t) { return e.tick < t; });
+
+    if (it != lane.events.end() && it->tick == tick)
+        it->value = clamp01 (value);
+    else
+        lane.events.insert (it, { tick, clamp01 (value) });
+}
+
+void erase (PatternEvents& lane, std::int64_t from, std::int64_t to)
+{
+    lane.events.erase (std::remove_if (lane.events.begin(), lane.events.end(), [from, to] (const PatternEvent& e) { return e.tick >= from && e.tick < to; }),
+                       lane.events.end());
+}
+
+void fill (PatternEvents& lane, std::int64_t from, std::int64_t to, float value, std::int64_t step)
+{
+    line (lane, from, to, value, value, step);
+}
+
+void line (PatternEvents& lane, std::int64_t from, std::int64_t to, float v0, float v1, std::int64_t step)
+{
+    step = std::max<std::int64_t> (1, step);
+    from = std::max<std::int64_t> (0, from);
+
+    if (to <= from)
+        to = from + step;
+
+    erase (lane, from, to);
+    const auto span = (double) std::max<std::int64_t> (1, to - from - step);
+
+    for (auto t = from; t < to; t += step)
+    {
+        const auto f = to - from > step ? (double) (t - from) / span : 0.0;
+        lane.events.push_back ({ t, clamp01 ((float) (v0 + (v1 - v0) * std::min (1.0, f))) });
+    }
+
+    sortLane (lane);
+}
+
+void scale (PatternEvents& lane, std::int64_t from, std::int64_t to, float factor, float offset, bool bipolar)
+{
+    const auto centre = bipolar ? 0.5f : 0.0f;
+
+    for (auto& e : lane.events)
+        if (e.tick >= from && e.tick < to)
+            e.value = clamp01 (centre + (e.value - centre) * factor + offset);
+}
+
+void randomize (PatternEvents& lane, std::int64_t from, std::int64_t to, float amount, std::uint32_t seed)
+{
+    std::mt19937 random (seed);
+    std::uniform_real_distribution<float> spread (-1.0f, 1.0f);
+
+    for (auto& e : lane.events)
+        if (e.tick >= from && e.tick < to)
+            e.value = clamp01 (e.value + spread (random) * amount);
+}
+
+void applyLfo (PatternEvents& lane, std::int64_t from, std::int64_t to, const prtools::LfoOptions& options, std::int64_t step)
+{
+    step = std::max<std::int64_t> (1, step);
+    from = std::max<std::int64_t> (0, from);
+
+    if (to <= from)
+        return;
+
+    const auto curve = prtools::lfoCurve (options, to - from);
+    erase (lane, from, to);
+
+    for (auto t = from; t < to; t += step)
+        lane.events.push_back ({ t, curve[(std::size_t) (t - from)] });
+
+    sortLane (lane);
+}
+} // namespace lynx::eventedit

+ 36 - 0
src/core/EventEdit.h

@@ -0,0 +1,36 @@
+#pragma once
+
+// Event editor operations (round 83): edits a pattern's parameter events (Pattern::events, like FL's pattern
+// events). Values are 0..1; each event holds until the next. Pure functions, no JUCE.
+
+#include <cstdint>
+#include <vector>
+
+#include "core/PianoRollTools.h"
+#include "core/Song.h"
+
+namespace lynx::eventedit
+{
+PatternEvents* findLane (Pattern& pattern, const AutomationTarget& target) noexcept;
+const PatternEvents* findLane (const Pattern& pattern, const AutomationTarget& target) noexcept;
+// The lane of `target`, created when missing.
+PatternEvents& laneFor (Pattern& pattern, const AutomationTarget& target);
+// Drops lanes without events or without a target.
+void removeEmptyLanes (Pattern& pattern);
+
+// Sets the event at `tick` (replacing one at the same tick).
+void setEvent (PatternEvents& lane, std::int64_t tick, float value);
+// Removes the events in [from, to).
+void erase (PatternEvents& lane, std::int64_t from, std::int64_t to);
+// One event per `step` over [from, to), all at `value` (what the draw tool writes for the cells it crosses).
+void fill (PatternEvents& lane, std::int64_t from, std::int64_t to, float value, std::int64_t step);
+// A straight line from `v0` at `from` to `v1` at `to`: one event per `step` (the line tool).
+void line (PatternEvents& lane, std::int64_t from, std::int64_t to, float v0, float v1, std::int64_t step);
+// value -> centre + (value - centre) * factor + offset for the events in [from, to); centre = 0.5 for bipolar
+// targets (pan), else 0.
+void scale (PatternEvents& lane, std::int64_t from, std::int64_t to, float factor, float offset, bool bipolar);
+// Moves each event in [from, to) by up to +-amount (seeded, deterministic).
+void randomize (PatternEvents& lane, std::int64_t from, std::int64_t to, float amount, std::uint32_t seed);
+// Writes FL's piano roll LFO (prtools::lfoCurve) over [from, to), one event per `step`.
+void applyLfo (PatternEvents& lane, std::int64_t from, std::int64_t to, const prtools::LfoOptions& options, std::int64_t step);
+} // namespace lynx::eventedit

+ 9 - 0
src/core/History.cpp

@@ -108,6 +108,15 @@ ChangeLabel describeChange (const Song& before, const Song& after)
             return label (TR_NOOP ("Rename pattern: {0}"), b.name);
         if (a.lengthTicks != b.lengthTicks)
             return label (TR_NOOP ("Pattern length: {0}"), b.name);
+
+        const auto sameEvents = a.events.size() == b.events.size()
+                                && std::equal (a.events.begin(), a.events.end(), b.events.begin(), [] (const PatternEvents& x, const PatternEvents& y) {
+                                       return x.target == y.target && x.events.size() == y.events.size()
+                                              && std::equal (x.events.begin(), x.events.end(), y.events.begin(),
+                                                             [] (const PatternEvent& e, const PatternEvent& f) { return e.tick == f.tick && e.value == f.value; });
+                                   });
+        if (! sameEvents)
+            return label (TR_NOOP ("Edit events: {0}"), b.name);
     }
 
     // channels

+ 1541 - 0
src/core/PianoRollTools.cpp

@@ -0,0 +1,1541 @@
+#include "core/PianoRollTools.h"
+
+#include <algorithm>
+#include <cmath>
+#include <map>
+#include <random>
+#include <set>
+
+#include "flp/Flp.h"
+
+namespace lynx::prtools
+{
+namespace
+{
+constexpr std::int64_t beatTicks = ppq;
+constexpr std::int64_t minimumLength = ppq / 24; // FL's minimum note length (1/24 beat; REA_rodada83 §0)
+
+// FL's Round (round half to even, like x64 cvtsd2si)
+std::int64_t roundEven (double v) noexcept
+{
+    return (std::int64_t) std::nearbyint (v);
+}
+
+// a / b rounded toward zero, like Delphi's div
+std::int64_t divTrunc (std::int64_t a, std::int64_t b) noexcept
+{
+    return a / b;
+}
+
+// floor division and modulo (for positions, which are never negative in FL)
+std::int64_t floorDiv (std::int64_t a, std::int64_t b) noexcept
+{
+    auto q = a / b;
+    if ((a % b != 0) && ((a < 0) != (b < 0)))
+        --q;
+    return q;
+}
+
+std::int64_t floorMod (std::int64_t a, std::int64_t b) noexcept
+{
+    return a - floorDiv (a, b) * b;
+}
+
+std::vector<int> validSorted (const Pattern& p, std::vector<int> indices)
+{
+    indices.erase (std::remove_if (indices.begin(), indices.end(), [&p] (int i) { return i < 0 || i >= (int) p.notes.size(); }),
+                   indices.end());
+    std::sort (indices.begin(), indices.end());
+    indices.erase (std::unique (indices.begin(), indices.end()), indices.end());
+    return indices;
+}
+
+// Takes the notes at `indices` out of the pattern (sorted by start, stable), lets `fn` rewrite them, puts the
+// result back and re-sorts the pattern.
+template <typename Fn>
+void rewrite (Pattern& pattern, const std::vector<int>& indices, Fn&& fn)
+{
+    const auto valid = validSorted (pattern, indices);
+
+    if (valid.empty())
+        return;
+
+    std::vector<Note> work;
+    work.reserve (valid.size());
+
+    for (auto i : valid)
+        work.push_back (pattern.notes[(std::size_t) i]);
+
+    std::stable_sort (work.begin(), work.end(), [] (const Note& a, const Note& b) { return a.start < b.start; });
+
+    for (auto it = valid.rbegin(); it != valid.rend(); ++it)
+        pattern.notes.erase (pattern.notes.begin() + *it);
+
+    fn (work);
+
+    pattern.notes.insert (pattern.notes.end(), work.begin(), work.end());
+    pattern.sortNotes();
+}
+
+// FL's level blend toward a template note (quantizer/chopper): velocity target = template x note / 100 (FL bytes),
+// others target = template + (note - default); value += (target - value) x strength.
+void blendLevels (Note& n, const ScoreNote& t, const LevelStrengths& s)
+{
+    const auto blend = [] (float value, float target, float strength) { return value + (target - value) * strength; };
+
+    const auto velocityTarget = t.velocity * 128.0f / 100.0f * n.velocity;
+    n.velocity = std::clamp (blend (n.velocity, velocityTarget, s.velocity), 0.0f, 1.0f);
+    n.pan = std::clamp (blend (n.pan, t.pan + n.pan, s.pan), -1.0f, 1.0f);
+    n.release = std::clamp (blend (n.release, t.release + (n.release - 0.5f), s.release), 0.0f, 1.0f);
+    n.finePitch = std::clamp (blend (n.finePitch, t.finePitch + n.finePitch, s.pitch), -120.0f, 120.0f);
+    n.modX = std::clamp (blend (n.modX, t.modX + (n.modX - 128.0f / 255.0f), s.modX), 0.0f, 1.0f);
+    n.modY = std::clamp (blend (n.modY, t.modY + (n.modY - 128.0f / 255.0f), s.modY), 0.0f, 1.0f);
+}
+
+std::int64_t barTicks (int beatsPerBar) noexcept
+{
+    return beatTicks * std::max (1, beatsPerBar);
+}
+} // namespace
+
+// --- score templates --------------------------------------------------------------------------
+
+std::int64_t Score::length() const noexcept
+{
+    std::int64_t end = 0;
+
+    for (const auto& n : notes)
+        end = std::max (end, n.start + std::max<std::int64_t> (1, n.length));
+
+    return end;
+}
+
+std::optional<Score> parseScore (std::span<const std::uint8_t> bytes)
+{
+    // An .fsc is an .flp holding one pattern's notes (event 0xE0). Files written before FL 5 use 20-byte note
+    // records (no group/release); colours of files before 5.3.0 are stored >> 2 (REA_rodada2 §4.1).
+    try
+    {
+        flp::EventReader reader (bytes);
+        const auto filePpq = std::max<int> (1, reader.header().ppq);
+        const auto rescale = [filePpq] (std::int64_t t) { return roundEven ((double) t * ppq / filePpq); };
+        std::uint32_t version = 0;
+        flp::Event e;
+        Score score;
+
+        while (reader.next (e))
+        {
+            if (e.id == 0xC7 && e.isData())
+                version = flp::parseVersionNumber (std::string (e.data.begin(), std::find (e.data.begin(), e.data.end(), (std::uint8_t) 0)));
+
+            if (e.id != 0xE0 || ! e.isData() || ! score.notes.empty())
+                continue;
+
+            const auto oldRecords = version != 0 && version < 5000000u;
+            const std::size_t size = oldRecords ? 20 : 24;
+
+            if (e.data.size() % size != 0)
+                continue;
+
+            const auto u16 = [&e] (std::size_t o) { return (int) (e.data[o] | (e.data[o + 1] << 8)); };
+            const auto u32 = [&e] (std::size_t o) {
+                return (std::uint32_t) e.data[o] | ((std::uint32_t) e.data[o + 1] << 8) | ((std::uint32_t) e.data[o + 2] << 16)
+                       | ((std::uint32_t) e.data[o + 3] << 24);
+            };
+
+            for (std::size_t o = 0; o + size <= e.data.size(); o += size)
+            {
+                ScoreNote n;
+                n.start = rescale (u32 (o));
+                n.length = rescale (u32 (o + 8));
+                n.slide = (u16 (o + 4) & 0xF) == 8;
+                int fine = 120, release = 64, extra = 0, pan = 64, velocity = 100, modX = 128, modY = 128;
+
+                if (oldRecords)
+                {
+                    n.key = e.data[o + 12];
+                    fine = e.data[o + 13];
+                    extra = e.data[o + 15];
+                    pan = e.data[o + 16];
+                    velocity = e.data[o + 17];
+                    modX = e.data[o + 18];
+                    modY = e.data[o + 19];
+                }
+                else
+                {
+                    n.key = u16 (o + 12);
+                    fine = e.data[o + 16];
+                    release = e.data[o + 18];
+                    extra = e.data[o + 19];
+                    pan = e.data[o + 20];
+                    velocity = e.data[o + 21];
+                    modX = e.data[o + 22];
+                    modY = e.data[o + 23];
+                }
+
+                if (version != 0 && version < 3001006u)
+                    fine = 120;
+                if (version != 0 && version < 6005000u)
+                    release = 64;
+                n.colour = version != 0 && version < 5003000u ? ((extra & 0x0F) << 2) & 0x0F : extra & 0x0F;
+                n.velocity = velocity / 128.0f;
+                n.pan = std::clamp ((pan - 64) / 64.0f, -1.0f, 1.0f);
+                n.release = release / 128.0f;
+                n.finePitch = (float) std::clamp (fine - 120, -120, 120);
+                n.modX = modX / 255.0f;
+                n.modY = modY / 255.0f;
+                score.notes.push_back (n);
+            }
+        }
+
+        if (score.notes.empty())
+            return std::nullopt;
+
+        std::stable_sort (score.notes.begin(), score.notes.end(), [] (auto& a, auto& b) { return a.start < b.start; });
+        return score;
+    }
+    catch (const std::exception&)
+    {
+    }
+
+    return std::nullopt;
+}
+
+Score gridScore (std::int64_t step, float swing)
+{
+    Score score;
+    score.name = "Grid";
+    step = std::clamp<std::int64_t> (step, 1, beatTicks);
+    const auto count = std::max<std::int64_t> (1, beatTicks / step);
+
+    for (std::int64_t i = 0; i < count; ++i)
+    {
+        ScoreNote n;
+        n.start = i * step + ((i % 2) == 1 ? (std::int64_t) std::llround (std::clamp (swing, 0.0f, 1.0f) * (double) step * 0.5) : 0);
+        n.length = step;
+        score.notes.push_back (n);
+    }
+
+    return score;
+}
+
+// --- quantizer --------------------------------------------------------------------------------
+
+namespace
+{
+struct GrooveMatch
+{
+    std::int64_t target = 0;
+    const ScoreNote* note = nullptr;
+};
+
+// The nearest template point (start, or end when `end`) to `t` in the period before, at and after t's period,
+// strictly inside `window`; FL's search (REA_rodada83 §1).
+GrooveMatch nearestGroove (const Score& groove, std::int64_t period, std::int64_t t, std::int64_t window, bool end)
+{
+    GrooveMatch m;
+    m.target = t;
+
+    if (groove.notes.empty() || period <= 0)
+        return m;
+
+    auto base = (divTrunc (t, period) - 1) * period;
+    auto best = window;
+
+    for (int r = 0; r < 3; ++r, base += period)
+        for (const auto& n : groove.notes)
+        {
+            auto candidate = base + n.start;
+            if (end)
+                candidate += n.length - 1;
+
+            const auto distance = std::abs (t - candidate);
+
+            if (distance < best)
+            {
+                best = distance;
+                m.target = candidate;
+                m.note = &n;
+            }
+        }
+
+    return m;
+}
+
+std::int64_t moveToward (std::int64_t value, std::int64_t target, float strength)
+{
+    // FL: value + ((target - value) * s) / 128 with s = 0..128, rounded toward zero
+    const auto s = (std::int64_t) std::llround (std::clamp (strength, 0.0f, 1.0f) * 128.0f);
+    return value + divTrunc ((target - value) * s, 128);
+}
+} // namespace
+
+void quantize (Pattern& pattern, const std::vector<int>& indices, const Score& groove, const QuantizeOptions& o)
+{
+    // FL rounds the template's period up to whole beats
+    const auto period = std::max<std::int64_t> (1, (groove.length() + beatTicks - 1) / beatTicks) * beatTicks;
+    const auto window = (std::int64_t) std::clamp (o.sensitivity, 12, 192) * ticksPerStep / 48;
+
+    rewrite (pattern, indices, [&] (std::vector<Note>& notes) {
+        for (auto& n : notes)
+        {
+            const auto end = n.start + n.length - 1;
+            const auto m = nearestGroove (groove, period, n.start, window, false);
+            n.start = std::max<std::int64_t> (0, moveToward (n.start, m.target, o.start));
+
+            if (m.note != nullptr)
+                blendLevels (n, *m.note, o.levels);
+
+            if (o.durationMode != QuantizeOptions::leaveDuration && n.length > 0)
+            {
+                if (o.durationMode == QuantizeOptions::quantizeDuration)
+                {
+                    if (m.note != nullptr)
+                        n.length = moveToward (n.length, m.note->length, o.duration);
+                }
+                else
+                {
+                    auto newEnd = end;
+
+                    if (o.durationMode == QuantizeOptions::quantizeEnd)
+                        newEnd = moveToward (end, nearestGroove (groove, period, end, window, true).target, o.duration);
+
+                    n.length = std::max (minimumLength, newEnd - n.start + 1);
+                }
+
+                n.length = std::max<std::int64_t> (1, n.length);
+            }
+        }
+
+        // FL drops the notes whose velocity became 0
+        notes.erase (std::remove_if (notes.begin(), notes.end(), [] (const Note& n) { return n.velocity <= 0.0f; }), notes.end());
+    });
+}
+
+// --- chopper ----------------------------------------------------------------------------------
+
+float chopTimeMultiplier (int wheel) noexcept
+{
+    static const float table[] = { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 3.0f, 4.0f };
+    return table[std::clamp (wheel, 1, 7) - 1];
+}
+
+void chop (Pattern& pattern, const std::vector<int>& indices, const Score& source, const ChopOptions& o)
+{
+    // the pattern scaled by the time multiplier; a colour-12 note only sets the period
+    const auto mul = chopTimeMultiplier (o.timeMul);
+    std::vector<ScoreNote> pat;
+    std::int64_t period = std::max<std::int64_t> (1, roundEven ((double) ((float) source.length() * mul)));
+
+    for (auto n : source.notes)
+    {
+        n.start = roundEven ((double) ((float) n.start * mul));
+        n.length = std::max<std::int64_t> (1, roundEven ((double) ((float) n.length * mul)));
+
+        if (n.colour == 12)
+        {
+            period = n.length;
+            continue;
+        }
+
+        pat.push_back (n);
+    }
+
+    std::stable_sort (pat.begin(), pat.end(), [] (auto& a, auto& b) { return a.start < b.start; });
+
+    if (pat.empty())
+        return;
+
+    rewrite (pattern, indices, [&] (std::vector<Note>& notes) {
+        std::vector<Note> out;
+
+        for (const auto& n : notes)
+        {
+            if (n.length <= 0)
+            {
+                out.push_back (n);
+                continue;
+            }
+
+            auto offset = o.absolute ? -floorMod (n.start, period) : 0;
+            const auto end = n.start + n.length;
+            bool firstRound = true;
+            std::size_t k = 0;
+
+            for (;;)
+            {
+                const auto& p = pat[k];
+                auto pos = n.start + offset + p.start;
+
+                if (pos >= end)
+                    break;
+
+                auto length = std::min (p.length, end - pos);
+
+                if (p.colour == 4) // lasts to the note's end, only in the first round
+                    length = firstRound ? end - pos : 0;
+
+                if (pos < n.start)
+                {
+                    length -= n.start - pos;
+                    pos = n.start;
+                }
+
+                if (length > 0)
+                {
+                    Note piece = n;
+                    piece.start = pos;
+                    piece.length = length;
+                    piece.key = std::clamp (n.key + p.key - 60, 0, 127);
+                    piece.slide = p.slide;
+                    blendLevels (piece, p, o.levels);
+                    out.push_back (piece);
+                }
+
+                if (++k == pat.size())
+                {
+                    k = 0;
+                    offset += period;
+                    firstRound = false;
+                }
+            }
+        }
+
+        notes = std::move (out);
+    });
+}
+
+// --- flamer -----------------------------------------------------------------------------------
+
+FlamOptions flamPreset (FlamPreset preset) noexcept
+{
+    switch (preset)
+    {
+        case FlamPreset::flam: return { -64, 85, true, false };
+        case FlamPreset::earlyFlam: return { -64, 85, true, true };
+        case FlamPreset::doubleStroke: return { 192, 85, false, false };
+        case FlamPreset::earlyDoubleStroke: return { -192, 85, false, true };
+    }
+    return {};
+}
+
+std::int64_t flamOffset (const FlamOptions& o, double bpm) noexcept
+{
+    const auto time = std::clamp (o.time, -192, 192);
+
+    if (! o.absolute)
+        return divTrunc ((std::int64_t) time * ticksPerStep, 192);
+
+    const auto ms = time * (100.0 / 192.0);
+    return roundEven (ms * std::max (1.0, bpm) * ppq / 60000.0);
+}
+
+void flam (Pattern& pattern, const std::vector<int>& indices, const FlamOptions& o, double bpm)
+{
+    const auto t = flamOffset (o, bpm);
+    const auto velocity = std::clamp (o.velocity, 0, 128) / 128.0f;
+
+    rewrite (pattern, indices, [&] (std::vector<Note>& notes) {
+        std::vector<Note> out;
+
+        for (const auto& n : notes)
+        {
+            auto original = n.start;
+
+            if (o.before != (t < 0))
+                original = n.start - t;
+
+            const auto extra = original + t;
+            Note moved = n;
+            moved.start = std::max<std::int64_t> (0, original);
+            out.push_back (moved);
+
+            if (std::max<std::int64_t> (0, extra) != original)
+            {
+                Note added = n;
+                added.start = std::max<std::int64_t> (0, extra);
+                added.velocity = std::clamp (n.velocity * velocity, 0.0f, 1.0f);
+
+                if (added.start < original && original - added.start < added.length)
+                    added.length = original - added.start;
+
+                if (added.length > 0)
+                    out.push_back (added);
+            }
+        }
+
+        notes = std::move (out);
+    });
+}
+
+// --- LFO --------------------------------------------------------------------------------------
+
+double lfoPeriod (int speed) noexcept
+{
+    const auto exponent = 7.0 - std::clamp (speed, 0, 40960) / 4096.0;
+    return std::max (1.0, (double) beatTicks * std::exp2 (exponent));
+}
+
+std::vector<float> lfoCurve (const LfoOptions& o, std::int64_t length)
+{
+    length = std::max<std::int64_t> (1, length);
+    std::vector<float> out ((std::size_t) length);
+
+    const double k = 1.0 / 65536.0;
+    const auto startValue = (double) o.startValue, startRange = (double) o.startRange;
+    const auto valueDelta = o.useEnd ? (double) (o.endValue - o.startValue) : 0.0;
+    const auto rangeDelta = o.useEnd ? (double) (o.endRange - o.startRange) : 0.0;
+    const auto endSpeed = o.useEnd ? o.endSpeed : o.startSpeed;
+
+    // the period (or with log speed, the exponent) moves linearly from the start to the end value
+    double speedNow = 0.0, speedStep = 0.0;
+
+    if (o.logSpeed)
+    {
+        speedNow = 7.0 - std::clamp (o.startSpeed, 0, 40960) / 4096.0;
+        speedStep = ((7.0 - std::clamp (endSpeed, 0, 40960) / 4096.0) - speedNow) / (double) length;
+    }
+    else
+    {
+        speedNow = lfoPeriod (o.startSpeed);
+        speedStep = (lfoPeriod (endSpeed) - speedNow) / (double) length;
+    }
+
+    static const double shapeOffset[] = { 0.25, 0.75, 0.5 };
+    const auto shape = std::clamp (o.shape, 0, 2);
+    double phase = std::clamp (o.phase, 0, 65535) * k + shapeOffset[shape];
+
+    for (std::int64_t t = 0; t < length; ++t)
+    {
+        phase -= std::floor (phase);
+        double wave = 0.0;
+
+        if (shape == LfoOptions::sine)
+            wave = std::sin (phase * 6.283185307179586);
+        else if (shape == LfoOptions::triangle)
+            wave = 1.0 - std::abs (phase * 4.0 - 2.0);
+        else
+            wave = (double) (1 - 2 * roundEven (phase));
+
+        const auto p = (double) t / (double) length;
+        const auto v = (startValue + p * valueDelta) * k + wave * (startRange + p * rangeDelta) * k;
+        out[(std::size_t) t] = (float) std::clamp (v, 0.0, 1.0);
+
+        const auto period = o.logSpeed ? std::max (1.0, (double) beatTicks * std::exp2 (speedNow)) : speedNow;
+        phase += 1.0 / period;
+        speedNow += speedStep;
+    }
+
+    return out;
+}
+
+void lfo (Pattern& pattern, const std::vector<int>& indices, notetools::Level level, const LfoOptions& o)
+{
+    const auto valid = validSorted (pattern, indices);
+
+    if (valid.empty())
+        return;
+
+    std::int64_t from = pattern.notes[(std::size_t) valid.front()].start, to = from + 1;
+
+    for (auto i : valid)
+    {
+        const auto& n = pattern.notes[(std::size_t) i];
+        from = std::min (from, n.start);
+        to = std::max (to, n.start + std::max<std::int64_t> (1, n.length));
+    }
+
+    const auto curve = lfoCurve (o, to - from);
+
+    for (auto i : valid)
+    {
+        auto& n = pattern.notes[(std::size_t) i];
+        const auto t = std::clamp<std::int64_t> (n.start - from, 0, (std::int64_t) curve.size() - 1);
+        notetools::setLevelValue (n, level, curve[(std::size_t) t]);
+    }
+}
+
+// --- claw machine -----------------------------------------------------------------------------
+
+const std::vector<const char*>& clawTrashNames()
+{
+    static const std::vector<const char*> names { "1/4", "2/4", "3/4", "4/4", "1/3", "2/3", "3/3", "1/2", "2/2", "(none)" };
+    return names;
+}
+
+void claw (Pattern& pattern, const std::vector<int>& indices, const ClawOptions& o)
+{
+    const auto period = beatTicks << std::clamp (o.period, 0, 4);
+    const auto trash = std::clamp (o.trash, 0, 9);
+    // n slices per period; the trashed slice is rotated to the end of the period (k slices)
+    const int slices = trash < 4 ? 4 : trash < 7 ? 3 : trash < 9 ? 2 : -1;
+    static const int rotation[] = { 3, 2, 1, 0, 2, 1, 0, 1, 0, 0 };
+
+    const auto slice = slices > 0 ? period / slices : period;
+    const auto shift = slices > 0 ? rotation[trash] * slice : 0;
+    const auto keep = period - slice;
+    const auto scale = slices > 0 && o.stretch ? (double) slices / (double) (slices - 1) : 1.0;
+
+    // time warp curve
+    const auto d = std::clamp (o.timeDistortion, -1024, 1024) / 1024.0f;
+    const auto c = (float) ((double) (float) (std::pow (101.0, (double) std::abs (d)) - 1.0) * (d < 0 ? -1.0 : d > 0 ? 1.0 : 0.0) * 0.5);
+    const auto inv = c != 0.0f ? (float) (1.0 / std::abs ((double) c)) : 0.0f;
+    const auto logc = c != 0.0f ? (float) std::log (std::abs ((double) c) + 1.0) : 0.0f;
+
+    const auto warp = [&] (std::int64_t x) {
+        const auto t = (double) x * scale;
+        const auto base = (std::int64_t) std::floor (t / (double) period) * period;
+        auto f = (t - (double) base) / (double) period;
+
+        if (c > 0.0f)
+            f = 1.0 - (std::exp ((1.0 - f) * (double) logc) - 1.0) * (double) inv;
+        else if (c < 0.0f)
+            f = (std::exp (f * (double) logc) - 1.0) * (double) inv;
+
+        return roundEven ((double) base + f * (double) period);
+    };
+
+    rewrite (pattern, indices, [&] (std::vector<Note>& notes) {
+        std::vector<Note> out;
+
+        for (auto n : notes)
+        {
+            const auto originalLength = n.length;
+
+            if (slices > 0)
+            {
+                n.start += shift;
+
+                // FL's integer div/mod (truncating, as the lengths can go negative)
+                if (n.start % period > keep) // starts in the trashed slice: move to the next period
+                {
+                    const auto skip = period - n.start % period;
+                    n.start += skip;
+                    n.length -= skip;
+                }
+
+                const auto endInPeriod = (n.start + n.length) % period;
+                if (endInPeriod > keep)
+                    n.length -= endInPeriod - keep;
+
+                const auto start = n.start;
+                n.start -= (start / period) * slice;
+                n.length -= ((n.length + start % period) / period) * slice;
+                n.start -= shift;
+            }
+
+            if (n.start < 0)
+            {
+                n.length += n.start;
+                n.start = 0;
+            }
+
+            if (originalLength < 1)
+            {
+                n.start = warp (n.start);
+                if (n.length >= 0)
+                    out.push_back (n);
+                continue;
+            }
+
+            const auto end = warp (n.start + n.length);
+            n.start = warp (n.start);
+            n.length = end - n.start;
+
+            if (n.length < 1 || (o.removeShort && n.length < minimumLength))
+                continue;
+
+            n.length = std::max (n.length, minimumLength);
+            out.push_back (n);
+        }
+
+        notes = std::move (out);
+    });
+}
+
+// --- articulator ------------------------------------------------------------------------------
+
+ArticulateOptions articulatePreset (ArticulatePreset preset) noexcept
+{
+    ArticulateOptions o;
+
+    switch (preset)
+    {
+        case ArticulatePreset::legato: o.multiply = 100; break;
+        case ArticulatePreset::portato: o.multiply = 75; break;
+        case ArticulatePreset::staccato: o.multiply = 20; break;
+        case ArticulatePreset::smallGaps: o.multiply = 100; o.gap = 20; o.useLengths = true; break;
+        case ArticulatePreset::chopChordsOnly: o.multiply = 100; o.chopChords = true; o.useLengths = true; break;
+    }
+
+    return o;
+}
+
+void articulate (Pattern& pattern, const std::vector<int>& indices, const ArticulateOptions& o, int beatsPerBar)
+{
+    const auto bar = barTicks (beatsPerBar);
+    const auto multiply = std::clamp (o.multiply, 10, 100) * 0.01f;
+    const auto variation = std::clamp (o.variation, 0, 100) * 0.01f;
+    const auto gap = roundEven ((double) std::clamp (o.gap, 0, 240) * ppq / 960.0);
+    std::mt19937 random (o.seed);
+
+    rewrite (pattern, indices, [&] (std::vector<Note>& notes) {
+        if (o.chopChords) // cut held notes where a later note starts, continued by a copy
+        {
+            std::vector<Note> sorted = notes;
+            std::int64_t last = -1;
+
+            for (std::size_t i = 0; i < sorted.size(); ++i)
+            {
+                const auto s = sorted[i].start;
+                if (s <= last)
+                    continue;
+                last = s;
+
+                const auto count = sorted.size();
+                for (std::size_t j = 0; j < count && sorted[j].start < s; ++j)
+                {
+                    auto& held = sorted[j];
+                    if (held.start + held.length > s)
+                    {
+                        Note rest = held;
+                        rest.start = s;
+                        rest.length = held.start + held.length - s;
+                        held.length = s - held.start;
+                        sorted.push_back (rest);
+                    }
+                }
+
+                std::stable_sort (sorted.begin() + (std::ptrdiff_t) i, sorted.end(),
+                                  [] (const Note& a, const Note& b) { return a.start < b.start; });
+            }
+
+            notes = std::move (sorted);
+        }
+
+        const auto count = notes.size();
+        std::vector<std::int64_t> lengths (count);
+
+        for (std::size_t i = 0; i < count; ++i)
+        {
+            const auto& n = notes[i];
+            std::int64_t room = 0;
+            bool found = false;
+
+            for (std::size_t j = i + 1; j < count; ++j)
+                if (notes[j].start >= n.start + minimumLength)
+                {
+                    room = notes[j].start - n.start;
+                    found = true;
+                    break;
+                }
+
+            if (! found)
+            {
+                const auto end = n.start + n.length;
+                const auto nearestBar = roundEven ((double) end / (double) bar) * bar;
+                room = end == nearestBar ? n.length : (floorDiv (end + bar - 1, bar) * bar) - n.start;
+            }
+
+            const auto base = o.useLengths ? n.length : room;
+            auto length = std::min ((float) base * multiply, (float) (room - gap));
+
+            if (variation != 0.0f)
+                length = (float) ((double) length - (double) random() * 2.3283064365386963e-10 * (double) (length * variation));
+
+            lengths[i] = std::max (minimumLength, roundEven ((double) length));
+        }
+
+        for (std::size_t i = 0; i < count; ++i)
+            notes[i].length = lengths[i];
+
+        // the notes of the last chord take the last note's length
+        if (! o.useLengths && count > 1)
+            for (std::size_t i = 0; i + 1 < count; ++i)
+                if (notes[i].start == notes[count - 1].start)
+                    notes[i].length = lengths[count - 1];
+    });
+}
+
+// --- chord progression ------------------------------------------------------------------------
+
+namespace
+{
+const int majorSteps[] = { 0, 2, 4, 5, 7, 9, 11 };
+const int minorSteps[] = { 0, 2, 3, 5, 7, 8, 10 };
+
+int pitchClass (int v) noexcept
+{
+    return ((v % 12) + 12) % 12;
+}
+
+// "I".."VII" (either case) at the start of `s`; returns the degree 0..6 and how many characters it used
+bool readNumeral (const std::string& s, std::size_t& pos, int& degree, bool& upper)
+{
+    static const char* names[] = { "VII", "III", "VI", "IV", "II", "V", "I" };
+    static const int degrees[] = { 6, 2, 5, 3, 1, 4, 0 };
+
+    for (int i = 0; i < 7; ++i)
+    {
+        const std::string n = names[i];
+        if (pos + n.size() > s.size())
+            continue;
+
+        bool allUpper = true, allLower = true, match = true;
+
+        for (std::size_t k = 0; k < n.size(); ++k)
+        {
+            const auto c = s[pos + k];
+            if (std::toupper ((unsigned char) c) != n[k]) { match = false; break; }
+            allUpper = allUpper && std::isupper ((unsigned char) c);
+            allLower = allLower && std::islower ((unsigned char) c);
+        }
+
+        if (match && (allUpper || allLower))
+        {
+            degree = degrees[i];
+            upper = allUpper;
+            pos += n.size();
+            return true;
+        }
+    }
+
+    return false;
+}
+
+bool startsWith (const std::string& s, std::size_t pos, const char* what)
+{
+    const std::string w = what;
+    return s.compare (pos, w.size(), w) == 0;
+}
+
+// accidentals: b, #, and the UTF-8 flat/sharp signs
+int readAccidentals (const std::string& s, std::size_t& pos)
+{
+    int shift = 0;
+
+    for (;;)
+    {
+        if (startsWith (s, pos, "\xE2\x99\xAD")) { shift--; pos += 3; }       // flat sign
+        else if (startsWith (s, pos, "\xE2\x99\xAF")) { shift++; pos += 3; }  // sharp sign
+        else if (pos < s.size() && s[pos] == 'b' && pos + 1 < s.size()
+                 && std::string ("IViv").find (s[pos + 1]) != std::string::npos) { shift--; pos++; }
+        else if (pos < s.size() && s[pos] == '#') { shift++; pos++; }
+        else break;
+    }
+
+    return shift;
+}
+
+std::optional<Chord> parseChordSymbol (const std::string& s, int tonic, bool minor)
+{
+    std::size_t pos = 0;
+    while (pos < s.size() && s[pos] == ' ')
+        ++pos;
+
+    const auto shift = readAccidentals (s, pos);
+    int degree = 0;
+    bool upper = true;
+
+    if (! readNumeral (s, pos, degree, upper))
+        return std::nullopt;
+
+    // numerals are read against the major scale of the tonic ("bVI" = the flat sixth), also in minor keys
+    (void) minor;
+    const auto& steps = majorSteps;
+    Chord c;
+    c.root = pitchClass (tonic + steps[degree] + shift);
+    std::vector<int> third { 0, upper ? 4 : 3, 7 };
+    bool seventh = false, majorSeventh = false, dim = false, halfDim = false;
+    std::vector<int> extra;
+    int sus = 0;
+    bool added = false;
+
+    while (pos < s.size())
+    {
+        while (pos < s.size() && s[pos] == ' ')
+            ++pos;
+        if (pos >= s.size())
+            break;
+
+        if (s[pos] == '/')
+        {
+            ++pos;
+            std::size_t p = pos;
+            const auto bassShift = readAccidentals (s, p);
+            int bassDegree = 0;
+            bool bassUpper = true;
+
+            if (! readNumeral (s, p, bassDegree, bassUpper))
+                return std::nullopt;
+
+            c.bass = pitchClass (tonic + steps[bassDegree] + bassShift);
+            pos = p;
+            continue;
+        }
+
+        if (startsWith (s, pos, "\xE2\x88\x86")) { majorSeventh = true; pos += 3; continue; } // increment sign (maj7)
+        if (startsWith (s, pos, "\xC2\xB0")) { dim = true; pos += 2; continue; }              // degree sign
+        if (startsWith (s, pos, "maj7")) { majorSeventh = true; pos += 4; continue; }
+        if (startsWith (s, pos, "sus2")) { sus = 2; pos += 4; continue; }
+        if (startsWith (s, pos, "sus4")) { sus = 4; pos += 4; continue; }
+        if (startsWith (s, pos, "add")) { added = true; pos += 3; continue; }
+        if (startsWith (s, pos, "dim")) { dim = true; pos += 3; continue; }
+        if (startsWith (s, pos, "\xE2\x99\xAD" "5")) { halfDim = true; pos += 4; continue; } // flat 5
+        if (startsWith (s, pos, "b5")) { halfDim = true; pos += 2; continue; }
+
+        // extensions: "add9" adds only the ninth; a plain 9, 11 or 13 also implies the seventh
+        int extension = 0;
+        if (startsWith (s, pos, "13")) { extension = 21; pos += 2; }
+        else if (startsWith (s, pos, "11")) { extension = 17; pos += 2; }
+        else if (s[pos] == '9') { extension = 14; pos++; }
+        else if (s[pos] == '7') { seventh = true; pos++; continue; }
+        else if (s[pos] == '6') { extension = 9; pos++; }
+        else if (s[pos] == '4') { extension = 5; pos++; }
+        else if (s[pos] == '2') { extension = 2; pos++; }
+
+        if (extension != 0)
+        {
+            if (! added && extension >= 14)
+                seventh = true;
+            extra.push_back (extension);
+            added = false;
+            continue;
+        }
+
+        return std::nullopt;
+    }
+
+    if (dim)
+        third = { 0, 3, 6 };
+    if (halfDim)
+        third[2] = 6;
+    if (sus == 2)
+        third[1] = 2;
+    else if (sus == 4)
+        third[1] = 5;
+
+    c.intervals = third;
+
+    if (majorSeventh)
+        c.intervals.push_back (11);
+    else if (seventh)
+        c.intervals.push_back (dim && ! halfDim ? 9 : 10);
+
+    for (auto e : extra)
+        c.intervals.push_back (e);
+
+    std::sort (c.intervals.begin(), c.intervals.end());
+    c.intervals.erase (std::unique (c.intervals.begin(), c.intervals.end()), c.intervals.end());
+    return c;
+}
+} // namespace
+
+std::optional<std::vector<Chord>> parseProgression (const std::string& text, int tonic, bool minor)
+{
+    std::vector<Chord> out;
+    std::string part;
+
+    const auto flush = [&]() -> bool {
+        auto trimmed = part;
+        while (! trimmed.empty() && trimmed.back() == ' ')
+            trimmed.pop_back();
+        while (! trimmed.empty() && trimmed.front() == ' ')
+            trimmed.erase (trimmed.begin());
+        part.clear();
+
+        if (trimmed.empty())
+            return true;
+
+        const auto chord = parseChordSymbol (trimmed, tonic, minor);
+        if (! chord)
+            return false;
+        out.push_back (*chord);
+        return true;
+    };
+
+    // chords are separated by '-' or ','; a space separates them too unless what follows is a quality ("ii 7",
+    // "I ∆", "vi /bVI")
+    for (std::size_t i = 0; i < text.size(); ++i)
+    {
+        const auto c = text[i];
+
+        if (c == ':')
+            break;
+
+        if (c == '-' || c == ',')
+        {
+            if (! flush())
+                return std::nullopt;
+            continue;
+        }
+
+        if (c == ' ')
+        {
+            std::size_t p = i + 1;
+            while (p < text.size() && text[p] == ' ')
+                ++p;
+            std::size_t q = p;
+            readAccidentals (text, q);
+            int d = 0;
+            bool up = false;
+            std::size_t r = q;
+
+            if (p < text.size() && text[p] != '/' && readNumeral (text, r, d, up) && ! part.empty())
+            {
+                if (! flush())
+                    return std::nullopt;
+                continue;
+            }
+        }
+
+        part += c;
+    }
+
+    if (! flush() || out.empty())
+        return std::nullopt;
+
+    return out;
+}
+
+std::string chordName (const Chord& c)
+{
+    static const char* names[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+    std::string s = names[pitchClass (c.root)];
+    const auto has = [&c] (int i) { return std::find (c.intervals.begin(), c.intervals.end(), i) != c.intervals.end(); };
+
+    if (has (3) && has (6) && ! has (7))
+        s += has (10) ? "m7b5" : has (9) ? "dim7" : "dim";
+    else
+    {
+        if (has (3))
+            s += "m";
+        if (has (11))
+            s += "maj7";
+        else if (has (10))
+            s += "7";
+        if (has (2) && ! has (3) && ! has (4))
+            s += "sus2";
+        if (has (5) && ! has (3) && ! has (4))
+            s += "sus4";
+        if (has (14))
+            s += has (10) || has (11) ? "(9)" : "add9";
+    }
+
+    if (c.bass >= 0 && c.bass != c.root)
+        s += std::string ("/") + names[pitchClass (c.bass)];
+
+    return s;
+}
+
+std::string toNumerals (const std::vector<Chord>& chords, int tonic)
+{
+    static const char* upperNames[] = { "I", "II", "III", "IV", "V", "VI", "VII" };
+    // pitch class above the tonic -> degree of the major scale and accidental
+    static const int degreeOf[12] = { 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6 };
+    static const int flatOf[12] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
+    std::string out;
+
+    for (const auto& c : chords)
+    {
+        if (! out.empty())
+            out += "-";
+
+        const auto has = [&c] (int i) { return std::find (c.intervals.begin(), c.intervals.end(), i) != c.intervals.end(); };
+        const auto rel = pitchClass (c.root - tonic);
+        std::string n = upperNames[degreeOf[rel]];
+
+        if (flatOf[rel])
+            n = "b" + n;
+
+        const auto minorThird = has (3) && ! has (4);
+        if (minorThird)
+            for (auto& ch : n)
+                if (ch != 'b')
+                    ch = (char) std::tolower ((unsigned char) ch);
+
+        if (has (3) && has (6) && ! has (7))
+            n += has (10) ? "7b5" : "dim";
+        else
+        {
+            if (has (2) && ! has (3) && ! has (4))
+                n += "sus2";
+            if (has (5) && ! has (3) && ! has (4))
+                n += "sus4";
+            if (has (11))
+                n += "maj7";
+            else if (has (10))
+                n += "7";
+        }
+
+        if (has (14))
+            n += "add9";
+
+        if (c.bass >= 0 && c.bass != c.root)
+        {
+            const auto b = pitchClass (c.bass - tonic);
+            n += std::string ("/") + (flatOf[b] ? "b" : "") + upperNames[degreeOf[b]];
+        }
+
+        out += n;
+    }
+
+    return out;
+}
+
+std::vector<ProgressionPreset> parseProgressionPresets (const std::string& text)
+{
+    std::vector<ProgressionPreset> out;
+    bool minor = false;
+    std::size_t start = 0;
+
+    while (start <= text.size())
+    {
+        auto end = text.find ('\n', start);
+        if (end == std::string::npos)
+            end = text.size();
+
+        auto line = text.substr (start, end - start);
+        start = end + 1;
+
+        while (! line.empty() && (line.back() == '\r' || line.back() == ' '))
+            line.pop_back();
+
+        if (line.empty())
+            continue;
+
+        if (line[0] == '-')
+        {
+            minor = line.find ("inor") != std::string::npos;
+            continue;
+        }
+
+        ProgressionPreset p;
+        p.name = line;
+        p.numerals = line.substr (0, line.find (':'));
+        p.minor = minor;
+
+        if (parseProgression (p.numerals, 0, minor))
+            out.push_back (p);
+    }
+
+    return out;
+}
+
+const std::vector<ProgressionPreset>& builtInProgressions()
+{
+    // common, well-known diatonic progressions
+    static const std::vector<ProgressionPreset> list {
+        { "I-V-vi-IV", "I-V-vi-IV", false },   { "I-vi-IV-V", "I-vi-IV-V", false }, { "vi-IV-I-V", "vi-IV-I-V", false },
+        { "I-IV-V-IV", "I-IV-V-IV", false },   { "ii7-V7-Imaj7", "ii7-V7-Imaj7", false }, { "I-IV-vi-V", "I-IV-vi-V", false },
+        { "i-VI-III-VII", "i-VI-III-VII", true }, { "i-iv-v-i", "i-iv-v-i", true }, { "i-VII-VI-VII", "i-VII-VI-VII", true },
+        { "i-iv-VII-III", "i-iv-VII-III", true },
+    };
+    return list;
+}
+
+std::vector<Chord> generateProgression (int tonic, bool minor, int count, float adventure, std::uint32_t seed)
+{
+    // LYNX's own table of moves between scale degrees (0..6): the usual functional pulls, with weights; more
+    // "adventurous" settings flatten the weights and allow sevenths and borrowed chords.
+    static const float moves[7][7] = {
+        // to:  I    ii   iii  IV   V    vi   vii
+        { 0.2f, 0.6f, 0.4f, 1.0f, 1.0f, 0.9f, 0.1f }, // from I
+        { 0.3f, 0.1f, 0.2f, 0.4f, 1.0f, 0.3f, 0.3f }, // ii
+        { 0.3f, 0.2f, 0.1f, 0.7f, 0.3f, 1.0f, 0.1f }, // iii
+        { 0.9f, 0.5f, 0.2f, 0.1f, 1.0f, 0.4f, 0.2f }, // IV
+        { 1.0f, 0.2f, 0.3f, 0.5f, 0.1f, 0.8f, 0.1f }, // V
+        { 0.4f, 0.7f, 0.4f, 1.0f, 0.7f, 0.1f, 0.1f }, // vi
+        { 1.0f, 0.1f, 0.5f, 0.1f, 0.2f, 0.3f, 0.0f }, // vii
+    };
+
+    count = std::clamp (count, 1, 64);
+    adventure = std::clamp (adventure, 0.0f, 1.0f);
+    std::mt19937 random (seed);
+    std::uniform_real_distribution<float> uniform (0.0f, 1.0f);
+
+    const auto& steps = minor ? minorSteps : majorSteps;
+    static const bool majorUpper[] = { true, false, false, true, true, false, false };
+    static const bool minorUpper[] = { false, false, true, false, false, true, true };
+
+    std::vector<Chord> out;
+    int degree = 0;
+
+    for (int i = 0; i < count; ++i)
+    {
+        if (i > 0)
+        {
+            float weights[7], total = 0.0f;
+
+            for (int d = 0; d < 7; ++d)
+            {
+                weights[d] = moves[degree][d] * (1.0f - adventure) + adventure * 0.5f;
+                if (i == count - 1 && count > 2) // end on a chord that leads home
+                    weights[d] *= (d == 4 || d == 3) ? 2.0f : 1.0f;
+                total += weights[d];
+            }
+
+            auto pick = uniform (random) * total;
+            int next = 0;
+
+            for (; next < 6; ++next)
+            {
+                pick -= weights[next];
+                if (pick <= 0.0f)
+                    break;
+            }
+
+            degree = next;
+        }
+
+        Chord c;
+        c.root = pitchClass (tonic + steps[degree]);
+        const auto upper = minor ? minorUpper[degree] : majorUpper[degree];
+        const auto diminished = (! minor && degree == 6) || (minor && degree == 1);
+        c.intervals = diminished ? std::vector<int> { 0, 3, 6 } : std::vector<int> { 0, upper ? 4 : 3, 7 };
+
+        if (minor && degree == 4 && uniform (random) < 0.5f * (1.0f - adventure)) // the harmonic minor's major V
+            c.intervals = { 0, 4, 7 };
+
+        if (uniform (random) < adventure * 0.6f) // sevenths (diatonic)
+        {
+            const auto seventh = pitchClass (steps[(degree + 6) % 7] - steps[degree]);
+            c.intervals.push_back (seventh == 0 ? 11 : seventh);
+        }
+
+        if (uniform (random) < adventure * 0.25f) // a borrowed / altered colour
+            c.intervals.push_back (14);
+
+        out.push_back (c);
+    }
+
+    return out;
+}
+
+std::vector<RhythmPreset> parseRhythmPresets (const std::string& text)
+{
+    std::vector<RhythmPreset> out;
+    std::size_t start = 0;
+
+    while (start < text.size())
+    {
+        auto end = text.find ('\n', start);
+        if (end == std::string::npos)
+            end = text.size();
+
+        auto line = text.substr (start, end - start);
+        start = end + 1;
+
+        while (! line.empty() && (line.back() == '\r' || line.back() == ' '))
+            line.pop_back();
+
+        std::vector<std::string> fields;
+        std::size_t p = 0;
+
+        while (p <= line.size())
+        {
+            auto q = line.find (',', p);
+            if (q == std::string::npos)
+                q = line.size();
+            fields.push_back (line.substr (p, q - p));
+            p = q + 1;
+        }
+
+        if (fields.size() < 3 || fields[2] == "r") // random rhythms (FL's generator) are not supported
+            continue;
+
+        RhythmPreset r;
+        r.name = fields[0];
+
+        for (std::size_t i = 2; i < fields.size(); ++i)
+            if (fields[i].size() == 1)
+                r.cells += fields[i][0];
+
+        if (! r.cells.empty())
+            out.push_back (r);
+    }
+
+    return out;
+}
+
+std::vector<int> writeProgression (Pattern& pattern, int channel, std::int64_t start, const std::vector<Chord>& chords,
+                                   const ChordWriteOptions& o)
+{
+    std::vector<Note> added;
+    const auto length = std::max<std::int64_t> (ticksPerStep, o.chordLength);
+    const auto baseC = 12 * (std::clamp (o.octave, 1, 8) + 1); // C of the octave (C4 = 60)
+    std::vector<int> previous;
+
+    for (std::size_t i = 0; i < chords.size(); ++i)
+    {
+        const auto& c = chords[i];
+        std::vector<int> keys;
+
+        for (auto iv : c.intervals)
+            keys.push_back (baseC + c.root + iv);
+
+        // voice leading: try inversions near the previous chord's centre
+        if (o.voiceLead && ! previous.empty() && keys.size() >= 3)
+        {
+            const auto centre = [] (const std::vector<int>& k) { double s = 0; for (auto v : k) s += v; return s / (double) k.size(); };
+            const auto target = centre (previous);
+            auto best = keys;
+
+            for (int shift = -(int) keys.size(); shift <= (int) keys.size(); ++shift)
+            {
+                auto candidate = keys;
+                std::sort (candidate.begin(), candidate.end());
+
+                for (int s = 0; s < std::abs (shift); ++s)
+                {
+                    if (shift > 0) { candidate.front() += 12; std::sort (candidate.begin(), candidate.end()); }
+                    else { candidate.back() -= 12; std::sort (candidate.begin(), candidate.end()); }
+                }
+
+                if (std::abs (centre (candidate) - target) < std::abs (centre (best) - target))
+                    best = candidate;
+            }
+
+            keys = best;
+        }
+
+        previous = keys;
+        const auto chordStart = start + (std::int64_t) i * length;
+
+        // rhythm: cells split 4 x chord length; '>' starts a hit, '-' holds it, anything else rests
+        std::vector<std::pair<std::int64_t, std::int64_t>> hits;
+
+        if (o.rhythm.empty())
+            hits.push_back ({ chordStart, length });
+        else
+        {
+            const auto cells = (std::int64_t) o.rhythm.size();
+            const auto block = 4 * length;
+            const auto cell = std::max<std::int64_t> (1, block / cells);
+            const auto blockStart = start + ((std::int64_t) i / 4) * block;
+
+            for (std::int64_t k = 0; k < cells; ++k)
+            {
+                const auto t = blockStart + k * cell;
+                if (t < chordStart || t >= chordStart + length)
+                    continue;
+
+                if (o.rhythm[(std::size_t) k] == '>' || o.rhythm[(std::size_t) k] == 'p')
+                    hits.push_back ({ t, cell });
+                else if (o.rhythm[(std::size_t) k] == '-' && ! hits.empty() && hits.back().first + hits.back().second == t)
+                    hits.back().second += cell;
+            }
+        }
+
+        for (const auto& [t, len] : hits)
+        {
+            for (auto k : keys)
+            {
+                Note n;
+                n.start = t;
+                n.length = len;
+                n.channel = channel;
+                n.key = std::clamp (k, 0, 127);
+                n.velocity = o.velocity;
+                added.push_back (n);
+            }
+
+            if (o.bassNote)
+            {
+                Note n;
+                n.start = t;
+                n.length = len;
+                n.channel = channel;
+                n.key = std::clamp (baseC - 12 + (c.bass >= 0 ? c.bass : c.root), 0, 127);
+                n.velocity = o.velocity;
+                added.push_back (n);
+            }
+        }
+    }
+
+    const auto first = (int) pattern.notes.size();
+    pattern.notes.insert (pattern.notes.end(), added.begin(), added.end());
+
+    // find the new notes again after sorting
+    std::vector<int> result;
+    std::vector<bool> isNew (pattern.notes.size(), false);
+    for (auto i = (std::size_t) first; i < pattern.notes.size(); ++i)
+        isNew[i] = true;
+
+    std::vector<std::pair<Note, bool>> tagged;
+    for (std::size_t i = 0; i < pattern.notes.size(); ++i)
+        tagged.push_back ({ pattern.notes[i], isNew[i] });
+    std::stable_sort (tagged.begin(), tagged.end(), [] (auto& a, auto& b) { return a.first.start < b.first.start; });
+
+    for (std::size_t i = 0; i < tagged.size(); ++i)
+    {
+        pattern.notes[i] = tagged[i].first;
+        if (tagged[i].second)
+            result.push_back ((int) i);
+    }
+
+    return result;
+}
+
+// --- riff machine -----------------------------------------------------------------------------
+
+namespace
+{
+ScoreNote scoreNote (std::int64_t start, std::int64_t length, int key, float velocity = 100.0f / 128.0f)
+{
+    ScoreNote n;
+    n.start = start;
+    n.length = length;
+    n.key = key;
+    n.velocity = velocity;
+    return n;
+}
+
+// LYNX's own riff shapes: (step, length in steps, key offset from 60) over one bar
+struct Shape
+{
+    const char* name;
+    std::vector<std::array<int, 3>> notes;
+};
+
+const std::vector<Shape>& progressionShapes()
+{
+    static const std::vector<Shape> shapes {
+        { TR_NOOP ("Pulse"), { { 0, 2, 0 }, { 2, 2, 0 }, { 4, 2, 7 }, { 6, 2, 0 }, { 8, 2, 3 }, { 10, 2, 0 }, { 12, 2, 7 }, { 14, 2, 5 } } },
+        { TR_NOOP ("Climb"), { { 0, 3, 0 }, { 3, 3, 2 }, { 6, 2, 3 }, { 8, 3, 5 }, { 11, 3, 7 }, { 14, 2, 10 } } },
+        { TR_NOOP ("Offbeat"), { { 2, 2, 0 }, { 6, 2, 0 }, { 10, 2, 7 }, { 14, 2, 5 } } },
+        { TR_NOOP ("Gallop"), { { 0, 1, 0 }, { 1, 1, 0 }, { 2, 2, 12 }, { 4, 1, 0 }, { 5, 1, 0 }, { 6, 2, 10 }, { 8, 1, 0 }, { 9, 1, 0 }, { 10, 2, 7 }, { 12, 4, 5 } } },
+        { TR_NOOP ("Long"), { { 0, 6, 0 }, { 6, 2, 3 }, { 8, 6, 5 }, { 14, 2, 7 } } },
+        { TR_NOOP ("Syncopated"), { { 0, 3, 0 }, { 3, 3, 0 }, { 6, 2, 12 }, { 8, 3, 7 }, { 11, 3, 5 }, { 14, 2, 3 } } },
+    };
+    return shapes;
+}
+
+const std::vector<Shape>& chordShapes()
+{
+    static const std::vector<Shape> shapes {
+        { TR_NOOP ("Single"), { { 0, 16, 0 } } },
+        { TR_NOOP ("Fifth"), { { 0, 16, 0 }, { 0, 16, 7 } } },
+        { TR_NOOP ("Minor triad"), { { 0, 16, 0 }, { 0, 16, 3 }, { 0, 16, 7 } } },
+        { TR_NOOP ("Major triad"), { { 0, 16, 0 }, { 0, 16, 4 }, { 0, 16, 7 } } },
+        { TR_NOOP ("Octaves"), { { 0, 16, 0 }, { 0, 16, 12 } } },
+        { TR_NOOP ("Minor 7th"), { { 0, 16, 0 }, { 0, 16, 3 }, { 0, 16, 7 }, { 0, 16, 10 } } },
+    };
+    return shapes;
+}
+
+Score shapeScore (const Shape& s, bool fullLength)
+{
+    Score score;
+    score.name = s.name;
+
+    for (const auto& n : s.notes)
+        score.notes.push_back (scoreNote ((std::int64_t) n[0] * ticksPerStep, (std::int64_t) n[1] * ticksPerStep, 60 + n[2]));
+
+    if (fullLength) // chord shapes: hold to the note end (FL's colour 4 behaviour)
+        for (auto& n : score.notes)
+            n.colour = 4;
+
+    return score;
+}
+} // namespace
+
+Score builtInRiffProgression (int variant)
+{
+    const auto& s = progressionShapes();
+    return shapeScore (s[(std::size_t) (((variant % (int) s.size()) + (int) s.size()) % (int) s.size())], false);
+}
+
+Score builtInRiffChord (int variant)
+{
+    const auto& s = chordShapes();
+    return shapeScore (s[(std::size_t) (((variant % (int) s.size()) + (int) s.size()) % (int) s.size())], true);
+}
+
+int builtInRiffProgressionCount() noexcept { return (int) progressionShapes().size(); }
+int builtInRiffChordCount() noexcept { return (int) chordShapes().size(); }
+
+std::vector<int> riffMachine (Pattern& pattern, const std::vector<int>& indices, const RiffOptions& o, int beatsPerBar)
+{
+    // work on a separate pattern holding only the riff's notes
+    Pattern work;
+    const auto valid = validSorted (pattern, indices);
+
+    if (o.onExistingNotes)
+        for (auto i : valid)
+            work.notes.push_back (pattern.notes[(std::size_t) i]);
+
+    for (auto it = valid.rbegin(); it != valid.rend(); ++it)
+        pattern.notes.erase (pattern.notes.begin() + *it);
+
+    if (! o.onExistingNotes)
+    {
+        Note base;
+        base.start = o.start;
+        base.length = (std::int64_t) std::clamp (o.bars, 1, 64) * barTicks (beatsPerBar);
+        base.channel = o.channel;
+        base.key = 48;
+        base.velocity = 100.0f / 128.0f;
+        work.notes.push_back (base);
+    }
+
+    work.sortNotes();
+    const auto all = [&work] {
+        std::vector<int> v ((std::size_t) work.notes.size());
+        for (std::size_t i = 0; i < v.size(); ++i)
+            v[i] = (int) i;
+        return v;
+    };
+
+    const auto last = std::clamp (o.stepsUpTo, 0, 7);
+
+    for (int step = 0; step <= last; ++step)
+    {
+        if (! o.enabled[step] || work.notes.empty())
+            continue;
+
+        switch (step)
+        {
+            case 0: chop (work, all(), o.progression.notes.empty() ? builtInRiffProgression (0) : o.progression, o.progressionChop); break;
+            case 1: chop (work, all(), o.chord.notes.empty() ? builtInRiffChord (0) : o.chord, o.chordChop); break;
+            case 2: notetools::arpeggiate (work, all(), o.arp); break;
+            case 3: notetools::randomise (work, all(), o.levels); break;
+            case 4: notetools::flip (work, all(), o.flipTime, o.flipPitch); break;
+            case 5: articulate (work, all(), o.articulation, beatsPerBar); break;
+            case 6: quantize (work, all(), o.groove.notes.empty() ? gridScore (ticksPerStep) : o.groove, o.grooveOptions); break;
+            case 7:
+                notetools::limit (work, all(), o.fit);
+                if (o.fitScale > 0)
+                    notetools::snapNotesToScale (work, all(), o.fitRoot, o.fitScale);
+                break;
+            default: break;
+        }
+
+        work.sortNotes();
+    }
+
+    const auto first = pattern.notes.size();
+
+    for (auto n : work.notes)
+    {
+        n.channel = o.channel;
+        pattern.notes.push_back (n);
+    }
+
+    // indices of the riff's notes after sorting
+    std::vector<std::pair<Note, bool>> tagged;
+    for (std::size_t i = 0; i < pattern.notes.size(); ++i)
+        tagged.push_back ({ pattern.notes[i], i >= first });
+    std::stable_sort (tagged.begin(), tagged.end(), [] (auto& a, auto& b) { return a.first.start < b.first.start; });
+
+    std::vector<int> result;
+    for (std::size_t i = 0; i < tagged.size(); ++i)
+    {
+        pattern.notes[i] = tagged[i].first;
+        if (tagged[i].second)
+            result.push_back ((int) i);
+    }
+
+    return result;
+}
+} // namespace lynx::prtools

+ 229 - 0
src/core/PianoRollTools.h

@@ -0,0 +1,229 @@
+#pragma once
+
+// More Piano Roll tools (round 83): quantizer with templates, chopper, flamer, LFO, claw machine, articulator,
+// riff machine and chord progression. The behaviour of the first six follows FL Studio's tools as analysed in
+// docs/analise/REA_rodada83.md (formulas, ranges, defaults; our own code). Score templates (.fsc) are read from
+// the user's FL Studio installation at run time; built-in templates are used when there is none.
+// Pure functions over Pattern, no JUCE.
+
+#include <cstdint>
+#include <optional>
+#include <span>
+#include <string>
+#include <vector>
+
+#include "core/NoteTools.h"
+#include "core/Song.h"
+
+namespace lynx::prtools
+{
+// --- score templates (.fsc) -------------------------------------------------------------------
+struct ScoreNote
+{
+    std::int64_t start = 0, length = 0; // ticks (LYNX PPQ)
+    int key = 60;
+    float velocity = 100.0f / 128.0f;   // 0..1 (FL byte / 128)
+    float pan = 0.0f;                   // -1..1
+    float release = 0.5f;               // 0..1
+    float finePitch = 0.0f;             // cents
+    float modX = 128.0f / 255.0f, modY = 128.0f / 255.0f;
+    int colour = 0;                     // FL note colour / MIDI channel 0..15
+    bool slide = false;
+};
+
+struct Score
+{
+    std::string name;
+    std::vector<ScoreNote> notes; // sorted by start
+
+    // end of the last note (a note counts at least one tick); 0 when empty
+    std::int64_t length() const noexcept;
+};
+
+// Reads an FL score file (.fsc: an .flp with one pattern of notes), rescaled to LYNX's PPQ.
+std::optional<Score> parseScore (std::span<const std::uint8_t> bytes);
+// One note per `step` over one beat (quantizer default), with `swing` (0..1) delaying every other step by
+// up to half a step.
+Score gridScore (std::int64_t step, float swing = 0.0f);
+
+// Per-level strengths (0..1) used when a template's levels are blended into the notes (quantizer, chopper).
+struct LevelStrengths
+{
+    float pan = 1.0f, velocity = 1.0f, release = 1.0f, modX = 1.0f, modY = 1.0f, pitch = 1.0f;
+};
+
+// --- quantizer --------------------------------------------------------------------------------
+struct QuantizeOptions
+{
+    enum DurationMode { leaveDuration, leaveEnd, quantizeDuration, quantizeEnd };
+    float start = 0.5f;        // start time strength 0..1 (FL default 64/128)
+    float duration = 0.5f;     // duration strength 0..1
+    int sensitivity = 36;      // FL wheel 12..192: the search window is sensitivity/48 steps
+    int durationMode = leaveDuration;
+    LevelStrengths levels;     // FL default: 100 %
+};
+
+// Moves the notes toward the template's repeated note starts (see REA_rodada83 §1). Notes whose velocity
+// becomes 0 are removed. Returns the indices of the notes that remain (re-sorted pattern).
+void quantize (Pattern& pattern, const std::vector<int>& indices, const Score& groove, const QuantizeOptions& options);
+
+// --- chopper ----------------------------------------------------------------------------------
+struct ChopOptions
+{
+    int timeMul = 4;           // FL wheel 1..7: x1/8, 1/4, 1/2, 1, 2, 3, 4
+    bool absolute = true;      // the pattern stays on the song's grid (else it restarts at each note)
+    LevelStrengths levels;
+};
+
+float chopTimeMultiplier (int wheel) noexcept;
+// Replaces each note by the pattern repeated over its length (REA_rodada83 §2).
+void chop (Pattern& pattern, const std::vector<int>& indices, const Score& choppingPattern, const ChopOptions& options);
+
+// --- flamer -----------------------------------------------------------------------------------
+struct FlamOptions
+{
+    int time = 192;            // FL wheel -192..192: relative = 1/192 step, absolute = 100/192 ms
+    int velocity = 85;         // 0..128: the added note's velocity, relative to the original
+    bool absolute = false;
+    bool before = false;
+};
+
+enum class FlamPreset { flam, earlyFlam, doubleStroke, earlyDoubleStroke };
+FlamOptions flamPreset (FlamPreset preset) noexcept;
+std::int64_t flamOffset (const FlamOptions& options, double bpm) noexcept; // ticks
+void flam (Pattern& pattern, const std::vector<int>& indices, const FlamOptions& options, double bpm);
+
+// --- LFO --------------------------------------------------------------------------------------
+struct LfoOptions
+{
+    enum Shape { sine, triangle, square };
+    int startValue = 32768, startRange = 16384, startSpeed = 20480; // FL wheels (0..65536, ±65536, 0..40960)
+    bool useEnd = false;
+    int endValue = 32768, endRange = 16384, endSpeed = 20480;
+    bool logSpeed = false;
+    int shape = sine;
+    int phase = 32768;         // 0..65535
+};
+
+// Period in ticks for a speed wheel value (beat x 2^(7 - speed/4096)).
+double lfoPeriod (int speed) noexcept;
+// Values 0..1 for each tick of a span of `length` ticks (length >= 1).
+std::vector<float> lfoCurve (const LfoOptions& options, std::int64_t length);
+// Sets `level` of each note to the LFO value at its start, over the span of the notes.
+void lfo (Pattern& pattern, const std::vector<int>& indices, notetools::Level level, const LfoOptions& options);
+
+// --- claw machine -----------------------------------------------------------------------------
+struct ClawOptions
+{
+    int period = 0;            // 0..4: 1, 2, 4, 8, 16 beats
+    int trash = 3;             // 0..9: 1/4, 2/4, 3/4, 4/4, 1/3, 2/3, 3/3, 1/2, 2/2, none
+    int timeDistortion = 0;    // -1024..1024
+    bool stretch = true;       // stretch to compensate for the removed time
+    bool removeShort = true;   // remove notes that become shorter than the minimum
+};
+
+const std::vector<const char*>& clawTrashNames(); // "1/4" ... "(none)"
+// Removes a slice of every period and bends time inside the period (REA_rodada83 §5).
+void claw (Pattern& pattern, const std::vector<int>& indices, const ClawOptions& options);
+
+// --- articulator ------------------------------------------------------------------------------
+struct ArticulateOptions
+{
+    int multiply = 100;        // 10..100 %
+    int variation = 0;         // 0..100 %
+    int gap = 0;               // 0..240, in 1/960 beat
+    bool useLengths = false;   // scale the notes' own lengths instead of the room to the next note
+    bool chopChords = false;   // cut held notes where a later note starts
+    std::uint32_t seed = 0;
+};
+
+enum class ArticulatePreset { legato, portato, staccato, smallGaps, chopChordsOnly };
+ArticulateOptions articulatePreset (ArticulatePreset preset) noexcept;
+// Returns the indices of the processed notes after the change (chop chords adds notes).
+void articulate (Pattern& pattern, const std::vector<int>& indices, const ArticulateOptions& options, int beatsPerBar);
+
+// --- chord progression (LYNX's own generator) ------------------------------------------------
+struct Chord
+{
+    int root = 0;              // pitch class 0..11 of the chord root
+    std::vector<int> intervals; // semitones above the root (0 first)
+    int bass = -1;             // pitch class of a different bass note (slash chord), -1 = none
+
+    bool operator== (const Chord&) const = default;
+};
+
+// Parses "I-V-vi-IV", "ii7 V7 I∆", "IV/♭VII", "Isus2 add9"... in the key of `tonic` (pitch class) and `minor`.
+// Returns nothing when a part cannot be read.
+std::optional<std::vector<Chord>> parseProgression (const std::string& text, int tonic, bool minor);
+std::string chordName (const Chord& chord); // "Am7", "C/E"...
+// Roman numerals of the chords in the key of `tonic` ("I-V-vi-IV"), readable by parseProgression.
+std::string toNumerals (const std::vector<Chord>& chords, int tonic);
+
+struct ProgressionPreset
+{
+    std::string name;          // "I-V-vi-IV: Hopeful"
+    std::string numerals;      // "I-V-vi-IV"
+    bool minor = false;
+};
+
+// The installation's presets (FL's Chords/presets.cpt text) or, without it, a few common progressions.
+std::vector<ProgressionPreset> parseProgressionPresets (const std::string& text);
+const std::vector<ProgressionPreset>& builtInProgressions();
+
+// Generates `count` chords in the key: common diatonic moves, more unusual ones as `adventure` (0..1) grows.
+std::vector<Chord> generateProgression (int tonic, bool minor, int count, float adventure, std::uint32_t seed);
+
+struct ChordWriteOptions
+{
+    std::int64_t chordLength = 4 * ppq; // one bar in 4/4
+    int octave = 4;            // octave of the chord roots (C4 = 60)
+    bool bassNote = true;      // add the root (or the slash bass) an octave below
+    bool voiceLead = true;     // inversions that keep the chords close to the first one
+    std::string rhythm;        // FL rhythm cells for 4 x chord length: '>' hit, '-' hold, '`' rest; empty = held
+    float velocity = 100.0f / 128.0f;
+};
+
+// Writes the chords as notes of `channel` from `start`; returns the indices of the new notes.
+std::vector<int> writeProgression (Pattern& pattern, int channel, std::int64_t start, const std::vector<Chord>& chords,
+                                   const ChordWriteOptions& options);
+
+struct RhythmPreset
+{
+    std::string name;
+    std::string cells;         // e.g. ">---" x 4
+};
+std::vector<RhythmPreset> parseRhythmPresets (const std::string& text); // FL's rhythm_presets.cpt (CSV)
+
+// --- riff machine -----------------------------------------------------------------------------
+struct RiffOptions
+{
+    int bars = 4;              // 1..64
+    int channel = 0;
+    std::int64_t start = 0;
+    bool onExistingNotes = false;
+    int stepsUpTo = 7;         // preview up to this step (0..7)
+
+    // 0 Prog (chop), 1 Chord (chop), 2 Arp, 3 Levels, 4 Mirror, 5 Articulate, 6 Groove (quantize), 7 Fit (limit)
+    bool enabled[8] { true, true, false, false, false, true, false, true };
+    Score progression, chord;  // chopping patterns of steps 0 and 1 (empty = built-in)
+    ChopOptions progressionChop, chordChop;
+    notetools::ArpeggiateOptions arp;
+    notetools::RandomiseOptions levels;
+    bool flipTime = false, flipPitch = true;
+    ArticulateOptions articulation;
+    Score groove;              // empty = 1/16 grid
+    QuantizeOptions grooveOptions;
+    notetools::LimitOptions fit;
+    int fitRoot = 0, fitScale = 1; // snap to scale (notetools::scales index; 0 = none)
+};
+
+// Built-in chopping patterns for the first two steps (`variant` picks one): rhythm + melody, and chord shapes.
+Score builtInRiffProgression (int variant);
+Score builtInRiffChord (int variant);
+int builtInRiffProgressionCount() noexcept;
+int builtInRiffChordCount() noexcept;
+
+// Runs the chain. Without `onExistingNotes`, the channel's notes in `indices` are replaced by one note of `bars`
+// bars at key 48 before the steps run. Returns the indices of the riff's notes.
+std::vector<int> riffMachine (Pattern& pattern, const std::vector<int>& indices, const RiffOptions& options, int beatsPerBar);
+} // namespace lynx::prtools

+ 101 - 7
src/core/RackRenderer.cpp

@@ -445,13 +445,8 @@ void RackState::buildAutomationTables()
     hasAutomation = false;
     tempoAutomation = -1;
 
-    // the last automation of the same target wins
-    for (int a = 0; a < count; ++a)
-    {
-        if (automationClips[(std::size_t) a].empty() && ! automations[(std::size_t) a].isLive())
-            continue;
-
-        const auto& t = automations[(std::size_t) a].target;
+    // binds automation slot `a` (an automation, or a pattern event lane after them) to its target
+    const auto bind = [this] (int a, const AutomationTarget& t) {
         const auto channelOk = t.index >= 0 && t.index < (int) song.channels.size();
         const auto trackOk = t.index >= 0 && t.index < (int) song.mixer.size();
         auto used = true;
@@ -499,7 +494,47 @@ void RackState::buildAutomationTables()
         }
 
         hasAutomation = hasAutomation || used;
+    };
+
+    // the last automation of the same target wins
+    for (int a = 0; a < count; ++a)
+    {
+        if (automationClips[(std::size_t) a].empty() && ! automations[(std::size_t) a].isLive())
+            continue;
+
+        bind (a, automations[(std::size_t) a].target);
     }
+
+    // pattern events (event editor): slots after the automations; they win over automation clips of the same
+    // target. The tempo is not driven by pattern events.
+    eventLanes.clear();
+    patternClips.assign (song.patterns.size(), {});
+
+    for (int i = 0; i < (int) song.playlist.size(); ++i)
+    {
+        const auto& c = song.playlist[(std::size_t) i];
+        if (c.kind == ClipKind::pattern && c.pattern >= 0 && c.pattern < (int) song.patterns.size() && c.length > 0 && ! c.muted
+            && ! song.isTrackMuted (c.track))
+            patternClips[(std::size_t) c.pattern].push_back (i);
+    }
+
+    for (auto& clips : patternClips)
+        std::sort (clips.begin(), clips.end(),
+                   [this] (int a, int b) { return song.playlist[(std::size_t) a].start < song.playlist[(std::size_t) b].start; });
+
+    auto slot = count;
+
+    for (int p = 0; p < (int) song.patterns.size(); ++p)
+        for (int l = 0; l < (int) song.patterns[(std::size_t) p].events.size(); ++l)
+        {
+            const auto& lane = song.patterns[(std::size_t) p].events[(std::size_t) l];
+
+            if (lane.events.empty() || lane.target.kind == AutomationTargetKind::tempo || slot >= maxAutomations)
+                continue;
+
+            eventLanes.push_back ({ p, l, slot });
+            bind (slot++, lane.target);
+        }
 }
 
 namespace
@@ -640,9 +675,60 @@ void RackRenderer::updateAutomation (const RackState& state, double startTick) n
             automationValues[(std::size_t) a] = automation.mapLive (state.effects[(std::size_t) src.track][(std::size_t) src.slot]->controlOutput (src.output));
     }
 
+    // pattern events: in pattern mode the current pattern's (looped); in song mode those of the pattern clip
+    // that covers the position. Elsewhere the value holds.
+    if (! state.eventLanes.empty())
+    {
+        if (song.mode != PlayMode::song)
+        {
+            const auto current = song.currentPattern;
+
+            if (current >= 0 && current < (int) song.patterns.size())
+            {
+                const auto& pattern = song.patterns[(std::size_t) current];
+                const auto length = (double) std::max<std::int64_t> (1, pattern.effectiveLength (song.beatsPerBar));
+                const auto t = std::fmod (std::max (0.0, startTick), length);
+
+                for (const auto& lane : state.eventLanes)
+                    if (lane.pattern == current)
+                        automationValues[(std::size_t) lane.slot] = pattern.events[(std::size_t) lane.lane].valueAt (t);
+            }
+        }
+        else
+        {
+            const auto length = (double) std::max<std::int64_t> (1, state.schedule.songLength);
+            const auto tick = std::fmod (std::max (0.0, startTick), length);
+
+            // inside a clip of the pattern: its events; after one: the value it ended with; before the first:
+            // no value (the target's own). Depends only on the position, like automation clips.
+            for (const auto& lane : state.eventLanes)
+            {
+                const auto& events = song.patterns[(std::size_t) lane.pattern].events[(std::size_t) lane.lane];
+                auto value = std::numeric_limits<float>::quiet_NaN();
+
+                for (auto i : state.patternClips[(std::size_t) lane.pattern]) // sorted by start
+                {
+                    const auto& c = song.playlist[(std::size_t) i];
+
+                    if (tick < (double) c.start)
+                        break;
+
+                    value = tick < (double) c.end() ? events.valueAt (tick - (double) c.start + (double) c.offset)
+                                                    : events.valueAt ((double) (c.offset + c.length) - 1.0);
+                }
+
+                automationValues[(std::size_t) lane.slot] = value;
+            }
+        }
+    }
+
     // in pattern mode the Playlist does not play: values stay as they were
     if (song.mode != PlayMode::song)
+    {
+        if (! state.eventLanes.empty()) // only the plugin parameters driven by pattern events
+            applyPluginParams (state, std::min<int> ((int) song.automations.size(), RackState::maxAutomations));
         return;
+    }
 
     const auto length = (double) std::max<std::int64_t> (1, state.schedule.songLength);
     const auto tick = std::fmod (std::max (0.0, startTick), length);
@@ -651,8 +737,16 @@ void RackRenderer::updateAutomation (const RackState& state, double startTick) n
         if (! state.automationClips[a].empty())
             automationValues[a] = automationValueAt (song, song.automations[a], state.automationClips[a], tick);
 
+    applyPluginParams (state, 0);
+}
+
+void RackRenderer::applyPluginParams (const RackState& state, int firstSlot) noexcept
+{
     for (const auto& b : state.pluginParams)
     {
+        if (b.automation < firstSlot)
+            continue;
+
         const auto v = automationValues[(std::size_t) b.automation];
 
         if (std::isnan (v))

+ 9 - 0
src/core/RackRenderer.h

@@ -40,6 +40,14 @@ struct RackState
     std::vector<std::vector<int>> effectMixAuto;                                 // [track][slot]: dry/wet
     std::vector<int> liveAutomations;                                            // automations with a live source (controllers)
 
+    // pattern events (event editor): each lane uses an automation slot after the song's automations
+    struct EventLane
+    {
+        int pattern = 0, lane = 0, slot = 0;
+    };
+    std::vector<EventLane> eventLanes;
+    std::vector<std::vector<int>> patternClips; // per pattern: its clips in the Playlist, by start
+
     struct PluginParamBinding
     {
         int automation = 0;
@@ -163,6 +171,7 @@ private:
     void runEffects (const RackState& state, int track, int n) noexcept;
     void setSidechain (const RackState& state, const EffectSlot& slot, Effect& effect, int track) noexcept;
     void updateAutomation (const RackState& state, double startTick) noexcept;
+    void applyPluginParams (const RackState& state, int firstSlot) noexcept; // bindings from this automation slot on
     float automated (int automation, float base) const noexcept;
     float* trackBuffer (int track, int channel) noexcept;
 

+ 11 - 0
src/core/Song.cpp

@@ -1,6 +1,7 @@
 #include "core/Song.h"
 
 #include <algorithm>
+#include <iterator>
 #include <cmath>
 #include <functional>
 #include <limits>
@@ -682,6 +683,16 @@ float Automation::mapLive (float v) const noexcept
     return std::clamp (curve[i] + (curve[i + 1] - curve[i]) * f, 0.0f, 1.0f);
 }
 
+float PatternEvents::valueAt (double tick) const noexcept
+{
+    if (events.empty())
+        return 0.5f;
+
+    // the last event at or before `tick`
+    auto it = std::upper_bound (events.begin(), events.end(), tick, [] (double t, const PatternEvent& e) { return t < (double) e.tick; });
+    return it == events.begin() ? events.front().value : std::prev (it)->value;
+}
+
 float Automation::valueAt (double tick) const noexcept
 {
     if (points.empty())

+ 43 - 21
src/core/Song.h

@@ -459,27 +459,6 @@ struct Note
 // is odd move, with triangular weight by distance to the grid; half a step at swing 1.
 std::int64_t swingDelay (std::int64_t start, float swing, float channelMix = 1.0f) noexcept;
 
-struct Pattern
-{
-    std::string name;
-    std::vector<Note> notes;  // sorted by start (kept by sortNotes)
-    std::int64_t lengthTicks = 0; // 0 = automatic (rounds up to bars)
-    std::uint32_t colour = 0;     // 0xFFRRGGBB; 0 = automatic (by index)
-
-    void sortNotes();
-    std::int64_t effectiveLength (int beatsPerBar) const noexcept;
-
-    bool hasStep (int channel, int step) const noexcept;
-    void toggleStep (int channel, int step);
-};
-
-enum class ClipKind : std::uint8_t
-{
-    pattern,
-    audio,
-    automation
-};
-
 // What an automation clip controls. Values always 0..1 (like the model's knobs).
 enum class AutomationTargetKind : std::uint8_t
 {
@@ -511,6 +490,46 @@ struct AutomationTarget
     }
 };
 
+// Event editor (round 83): a pattern's own parameter events, like FL's pattern events (.flp 0xDF). Each event
+// holds its value (0..1, like automation) until the next one; while the pattern plays they drive the target.
+struct PatternEvent
+{
+    std::int64_t tick = 0; // from the start of the pattern
+    float value = 0.5f;    // 0..1
+};
+
+struct PatternEvents
+{
+    AutomationTarget target;
+    std::vector<PatternEvent> events; // sorted by tick, one per tick
+
+    // Value at `tick` (held from the previous event; before the first = the first value).
+    float valueAt (double tick) const noexcept;
+};
+
+struct Pattern
+{
+    std::string name;
+    std::vector<Note> notes;  // sorted by start (kept by sortNotes)
+    std::int64_t lengthTicks = 0; // 0 = automatic (rounds up to bars)
+    std::uint32_t colour = 0;     // 0xFFRRGGBB; 0 = automatic (by index)
+    std::vector<PatternEvents> events; // event editor lanes (one per target)
+
+    void sortNotes();
+    std::int64_t effectiveLength (int beatsPerBar) const noexcept;
+
+    bool hasStep (int channel, int step) const noexcept;
+    void toggleStep (int channel, int step);
+};
+
+enum class ClipKind : std::uint8_t
+{
+    pattern,
+    audio,
+    automation
+};
+
+
 struct AutomationPoint
 {
     std::int64_t tick = 0; // from the start of the automation
@@ -653,6 +672,9 @@ struct Song
             fn (a.target);
         for (auto& l : midiLinks)
             fn (l.target);
+        for (auto& p : patterns)
+            for (auto& lane : p.events)
+                fn (lane.target);
     }
     void removeDeadMidiLinks();
 

+ 35 - 0
src/engine/ProjectFile.cpp

@@ -704,6 +704,25 @@ juce::String toJson (const Song& song)
         }
 
         o->setProperty ("notes", notes);
+
+        // event editor lanes: [kind, index, slot, param] + [[tick, value], ...]
+        juce::Array<juce::var> lanes;
+        for (const auto& lane : p.events)
+        {
+            if (lane.events.empty() || lane.target.kind == AutomationTargetKind::none)
+                continue;
+
+            auto l = std::make_unique<juce::DynamicObject>();
+            l->setProperty ("target", juce::Array<juce::var> { targetKindName (lane.target.kind), lane.target.index, lane.target.slot, lane.target.param });
+            juce::Array<juce::var> events;
+            for (const auto& e : lane.events)
+                events.add (juce::Array<juce::var> { (juce::int64) e.tick, juce::roundToInt (e.value * 10000.0f) / 10000.0 });
+            l->setProperty ("events", events);
+            lanes.add (juce::var (l.release()));
+        }
+        if (! lanes.isEmpty())
+            o->setProperty ("events", lanes);
+
         patterns.add (juce::var (o.release()));
     }
 
@@ -1132,6 +1151,22 @@ std::optional<Song> fromJson (const juce::String& json, juce::String& error)
                 }
 
             pattern.sortNotes();
+
+            if (auto* lanes = p["events"].getArray())
+                for (const auto& l : *lanes)
+                {
+                    PatternEvents lane;
+                    if (const auto& t = l["target"]; t.isArray() && t.size() == 4)
+                        lane.target = { targetKindFromName (t[0].toString()), (int) t[1], (int) t[2], (int) t[3] };
+                    if (auto* events = l["events"].getArray())
+                        for (const auto& e : *events)
+                            if (e.isArray() && e.size() >= 2)
+                                lane.events.push_back ({ juce::jmax<juce::int64> (0, (juce::int64) e[0]), juce::jlimit (0.0f, 1.0f, (float) (double) e[1]) });
+                    std::stable_sort (lane.events.begin(), lane.events.end(), [] (const PatternEvent& a, const PatternEvent& b) { return a.tick < b.tick; });
+                    if (lane.target.kind != AutomationTargetKind::none && ! lane.events.empty())
+                        pattern.events.push_back (std::move (lane));
+                }
+
             song.patterns.push_back (std::move (pattern));
         }
 

+ 3 - 0
src/ui/AutomationUi.cpp

@@ -7,6 +7,7 @@
 #include "engine/Text.h"
 #include "core/EditorGestures.h"
 #include "ui/EditorTools.h"
+#include "ui/EventEditor.h"
 #include "ui/I18n.h"
 #include "ui/Theme.h"
 #include "ui/ValueControl.h"
@@ -703,6 +704,8 @@ std::unique_ptr<juce::Component> makeAutomationEditor (AudioEngine& engine, int
 void addAutomationItem (juce::PopupMenu& menu, AudioEngine& engine, const AutomationTarget& target)
 {
     menu.addItem (tr ("Create automation clip"), [&engine, target] { createAutomationClip (engine, target); });
+    if (target.kind != AutomationTargetKind::tempo)
+        menu.addItem (tr ("Edit events in the pattern"), [&engine, target] { openEventEditor (engine, target); });
     menu.addItem (tr ("Link to MIDI controller (move a knob on the controller)"), [&engine, target] {
         engine.learnMidiController (target);
     });

+ 723 - 0
src/ui/EventEditor.cpp

@@ -0,0 +1,723 @@
+#include "ui/EventEditor.h"
+
+#include <algorithm>
+#include <cmath>
+#include <functional>
+#include <limits>
+#include <optional>
+
+#include "core/EventEdit.h"
+#include "ui/AutomationUi.h"
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+#include "ui/ToolWindow.h"
+
+namespace lynx
+{
+namespace
+{
+bool sameTarget (const AutomationTarget& a, const AutomationTarget& b) noexcept
+{
+    return a == b;
+}
+
+bool bipolarTarget (const AutomationTarget& t) noexcept
+{
+    return t.kind == AutomationTargetKind::channelPan || t.kind == AutomationTargetKind::mixerPan;
+}
+
+class EventEditor final : public juce::Component,
+                          private juce::ChangeListener,
+                          private juce::Timer
+{
+public:
+    EventEditor (AudioEngine& e, const AutomationTarget& t)
+        : engine (e), target (t)
+    {
+        engine.addChangeListener (this);
+
+        title.setFont (theme::font (theme::type::title, true));
+        addAndMakeVisible (title);
+        addAndMakeVisible (targetBox);
+        targetBox.onChange = [this] {
+            const auto i = targetBox.getSelectedItemIndex();
+            if (i >= 0 && i < (int) targets.size())
+            {
+                target = targets[(std::size_t) i];
+                selectionStart = selectionEnd = -1;
+                repaint();
+            }
+        };
+
+        const std::pair<juce::TextButton*, const char*> tools[] = { { &drawButton, TR_NOOP ("Draw") }, { &lineButton, TR_NOOP ("Line") },
+                                                                    { &selectButton, TR_NOOP ("Select") } };
+        for (const auto& [b, name] : tools)
+        {
+            b->setButtonText (tr (name));
+            b->setClickingTogglesState (true);
+            b->setRadioGroupId (8301);
+            b->setColour (juce::TextButton::buttonOnColourId, theme::colour::accent);
+            addAndMakeVisible (*b);
+        }
+
+        drawButton.setToggleState (true, juce::dontSendNotification);
+        drawButton.setTooltip (tr ("Draw: drag to set the values; right-drag erases"));
+        lineButton.setTooltip (tr ("Line: drag a straight ramp"));
+        selectButton.setTooltip (tr ("Select: drag a time range for the tools below"));
+
+        gridLabel.setText (tr ("Snap"), juce::dontSendNotification);
+        addAndMakeVisible (gridLabel);
+        gridBox.addItemList ({ tr ("1/2 step"), tr ("1 step"), tr ("1/2 beat"), tr ("1 beat"), tr ("1 bar") }, 1);
+        gridBox.setSelectedItemIndex (1, juce::dontSendNotification);
+        gridBox.onChange = [this] { repaint(); };
+        addAndMakeVisible (gridBox);
+
+        // selection tools
+        for (auto* l : { &scaleLabel, &offsetLabel, &randomLabel, &lfoLabel })
+        {
+            l->setFont (theme::font (theme::type::small));
+            l->setColour (juce::Label::textColourId, theme::colour::textSecondary);
+            addAndMakeVisible (*l);
+        }
+        scaleLabel.setText (tr ("Scale"), juce::dontSendNotification);
+        offsetLabel.setText (tr ("Offset"), juce::dontSendNotification);
+        randomLabel.setText (tr ("Randomise"), juce::dontSendNotification);
+        lfoLabel.setText ("LFO", juce::dontSendNotification);
+
+        setupSlider (scaleSlider, 0.0, 2.0, 1.0, [] (double v) { return juce::String (juce::roundToInt (v * 100.0)) + "%"; });
+        setupSlider (offsetSlider, -1.0, 1.0, 0.0, [] (double v) { return (v > 0 ? "+" : "") + juce::String (juce::roundToInt (v * 100.0)) + "%"; });
+        setupSlider (amountSlider, 0.0, 0.5, 0.1, [] (double v) { return juce::String (juce::roundToInt (v * 100.0)) + "%"; });
+
+        scaleSlider.onValueChange = offsetSlider.onValueChange = [this] { previewScale(); };
+        scaleSlider.onDragStart = offsetSlider.onDragStart = [this] { beginGesture(); };
+        scaleSlider.onDragEnd = offsetSlider.onDragEnd = [this] {
+            commitGesture();
+            const juce::ScopedValueSetter<bool> quiet (resettingSliders, true);
+            scaleSlider.setValue (1.0, juce::dontSendNotification);
+            offsetSlider.setValue (0.0, juce::dontSendNotification);
+        };
+
+        randomButton.setButtonText (tr ("Apply"));
+        randomButton.onClick = [this] {
+            ++seed;
+            edit ([this] (PatternEvents& lane, std::int64_t from, std::int64_t to) {
+                eventedit::randomize (lane, from, to, (float) amountSlider.getValue(), seed);
+            });
+        };
+        addAndMakeVisible (randomButton);
+
+        shapeBox.addItemList ({ tr ("Sine"), tr ("Triangle"), tr ("Square") }, 1);
+        shapeBox.setSelectedItemIndex (0, juce::dontSendNotification);
+        addAndMakeVisible (shapeBox);
+        periodBox.addItemList ({ tr ("1 beat"), tr ("2 beats"), tr ("1 bar"), tr ("2 bars"), tr ("4 bars") }, 1);
+        periodBox.setSelectedItemIndex (2, juce::dontSendNotification);
+        addAndMakeVisible (periodBox);
+        lfoButton.setButtonText (tr ("Apply"));
+        lfoButton.onClick = [this] { applyLfo(); };
+        addAndMakeVisible (lfoButton);
+
+        clearButton.setButtonText (tr ("Clear"));
+        clearButton.setTooltip (tr ("Remove the events of the selection (or of the whole pattern)"));
+        clearButton.onClick = [this] {
+            edit ([] (PatternEvents& lane, std::int64_t from, std::int64_t to) { eventedit::erase (lane, from, to); });
+        };
+        addAndMakeVisible (clearButton);
+
+        rebuildTargets();
+        setSize (900, 400);
+        setWantsKeyboardFocus (true);
+        startTimerHz (30);
+    }
+
+    ~EventEditor() override { engine.removeChangeListener (this); }
+
+    void paint (juce::Graphics& g) override
+    {
+        using namespace theme;
+        g.fillAll (colour::bg2);
+
+        const auto& song = engine.getSong();
+        const auto& pattern = currentPattern();
+        const auto area = plotArea();
+        const auto length = patternLength();
+        const auto bar = (std::int64_t) ppq * juce::jmax (1, song.beatsPerBar);
+
+        g.setColour (colour::bg0);
+        g.fillRect (area.withTop (area.getY() - rulerHeight));
+
+        // beyond the pattern's end
+        const auto endX = (int) tickToX ((double) length);
+        if (endX < area.getRight())
+        {
+            g.setColour (colour::bg2.withAlpha (0.75f));
+            g.fillRect (area.withLeft (juce::jmax (area.getX(), endX)));
+        }
+
+        // grid: steps, beats, bars (with numbers on the ruler)
+        const auto lastTick = (std::int64_t) xToTick (area.getRight());
+        for (auto tick = (std::int64_t) std::floor (scroll / ticksPerStep) * ticksPerStep; tick <= lastTick; tick += ticksPerStep)
+        {
+            const auto x = (float) tickToX ((double) tick);
+            const auto isBar = tick % bar == 0, isBeat = tick % ppq == 0;
+
+            if (! isBeat && ticksPerStep * pixelsPerTick < 5.0)
+                continue;
+
+            g.setColour (isBar ? colour::gridBar : isBeat ? colour::gridBeat : colour::gridStep);
+            g.drawVerticalLine ((int) x, (float) area.getY(), (float) area.getBottom());
+
+            if (isBar)
+            {
+                g.setColour (colour::textSecondary);
+                g.setFont (font (type::caption));
+                g.drawText (juce::String (tick / bar + 1), (int) x + 3, area.getY() - rulerHeight, 40, rulerHeight, juce::Justification::centredLeft);
+            }
+        }
+
+        for (auto v : { 0.25f, 0.5f, 0.75f })
+        {
+            g.setColour (colour::gridStep.brighter (v == 0.5f && bipolarTarget (target) ? 0.4f : 0.15f));
+            g.drawHorizontalLine ((int) valueToY (v), (float) area.getX(), (float) area.getRight());
+        }
+
+        // the channel's notes, faint, along the bottom (where the events will play)
+        if (target.kind == AutomationTargetKind::channelVolume || target.kind == AutomationTargetKind::channelPan
+            || target.kind == AutomationTargetKind::channelParam)
+        {
+            g.setColour (colour::noteHard.withAlpha (0.35f));
+            for (const auto& n : pattern.notes)
+                if (n.channel == target.index)
+                {
+                    const auto x0 = (float) tickToX ((double) n.start), x1 = (float) tickToX ((double) (n.start + n.length));
+                    if (x1 >= (float) area.getX() && x0 <= (float) area.getRight())
+                        g.fillRect (juce::Rectangle<float> (x0, (float) area.getBottom() - 5.0f, juce::jmax (2.0f, x1 - x0 - 1.0f), 4.0f));
+                }
+        }
+
+        // selection
+        if (selectionEnd > selectionStart)
+        {
+            const auto x0 = (float) tickToX ((double) selectionStart), x1 = (float) tickToX ((double) selectionEnd);
+            g.setColour (colour::selectionFill);
+            g.fillRect (juce::Rectangle<float> (x0, (float) area.getY(), x1 - x0, (float) area.getHeight()));
+            g.setColour (colour::selection);
+            g.drawVerticalLine ((int) x0, (float) area.getY(), (float) area.getBottom());
+            g.drawVerticalLine ((int) x1, (float) area.getY(), (float) area.getBottom());
+        }
+
+        // the events: a bar per event, held until the next one
+        const auto* lane = eventedit::findLane (pattern, target);
+        const auto base = bipolarTarget (target) ? valueToY (0.5f) : (float) area.getBottom();
+
+        if (lane != nullptr && ! lane->events.empty())
+        {
+            const auto& ev = lane->events;
+            for (std::size_t i = 0; i < ev.size(); ++i)
+            {
+                const auto end = i + 1 < ev.size() ? ev[i + 1].tick : juce::jmax (length, ev[i].tick + gridTicks());
+                const auto x0 = (float) tickToX ((double) ev[i].tick) + 1.0f, x1 = (float) tickToX ((double) end) - 1.0f;
+
+                if (x1 < (float) area.getX() || x0 > (float) area.getRight())
+                    continue;
+
+                const auto y = valueToY (ev[i].value);
+                const auto top = juce::jmin (y, base), bottom = juce::jmax (y, base);
+                g.setColour (colour::automation.withAlpha (0.28f));
+                g.fillRect (juce::Rectangle<float> (x0, top, juce::jmax (1.0f, x1 - x0), juce::jmax (1.0f, bottom - top)));
+                g.setColour (colour::automation);
+                g.fillRect (juce::Rectangle<float> (x0, y - 1.0f, juce::jmax (2.0f, x1 - x0), 2.5f));
+            }
+        }
+        else
+        {
+            g.setColour (colour::textSecondary);
+            g.setFont (font (type::body));
+            g.drawText (tr ("No events yet for {0}. Draw to add them; they play with the pattern.", { describeAutomationTarget (engine, target) }),
+                        area.reduced (20), juce::Justification::centred);
+        }
+
+        // line tool preview
+        if (lineFrom)
+        {
+            g.setColour (colour::textPrimary.withAlpha (0.8f));
+            g.drawLine ((float) tickToX ((double) lineFrom->first), valueToY (lineFrom->second), (float) lineTo.x, (float) lineTo.y, 1.5f);
+        }
+
+        // playback position
+        if (playhead >= 0.0)
+        {
+            g.setColour (colour::playhead);
+            g.drawVerticalLine ((int) tickToX (playhead), (float) area.getY() - rulerHeight, (float) area.getBottom());
+        }
+
+        // value read-out under the mouse
+        if (hoverValue >= 0.0f)
+        {
+            g.setColour (colour::textPrimary);
+            g.setFont (font (type::small));
+            g.drawText (juce::String (juce::roundToInt (hoverValue * 100.0f)) + "%", area.getRight() - 60, area.getY() + 4, 54, 16,
+                        juce::Justification::centredRight);
+        }
+
+        if (endX >= area.getX() && endX < area.getRight())
+        {
+            g.setColour (colour::textDisabled);
+            g.drawVerticalLine (endX, (float) area.getY() - rulerHeight, (float) area.getBottom());
+        }
+
+        g.setColour (colour::border);
+        g.drawRect (area.withTop (area.getY() - rulerHeight));
+    }
+
+    void resized() override
+    {
+        auto r = getLocalBounds().reduced (12, 8);
+        auto top = r.removeFromTop (30);
+        title.setBounds (top.removeFromLeft (230));
+        targetBox.setBounds (top.removeFromLeft (240).reduced (0, 2));
+        top.removeFromLeft (12);
+        for (auto* b : { &drawButton, &lineButton, &selectButton })
+            b->setBounds (top.removeFromLeft (64).reduced (1, 2));
+        top.removeFromLeft (12);
+        gridLabel.setBounds (top.removeFromLeft (40));
+        gridBox.setBounds (top.removeFromLeft (110).reduced (0, 2));
+        clearButton.setBounds (top.removeFromRight (70).reduced (0, 2));
+
+        auto tools = r.removeFromBottom (32);
+        r.removeFromBottom (6);
+        canvas = r.withTrimmedTop (4);
+
+        scaleLabel.setBounds (tools.removeFromLeft (42));
+        scaleSlider.setBounds (tools.removeFromLeft (140).reduced (0, 4));
+        tools.removeFromLeft (8);
+        offsetLabel.setBounds (tools.removeFromLeft (44));
+        offsetSlider.setBounds (tools.removeFromLeft (140).reduced (0, 4));
+        tools.removeFromLeft (12);
+        randomLabel.setBounds (tools.removeFromLeft (66));
+        amountSlider.setBounds (tools.removeFromLeft (110).reduced (0, 4));
+        randomButton.setBounds (tools.removeFromLeft (56).reduced (2, 3));
+        tools.removeFromLeft (10);
+        lfoLabel.setBounds (tools.removeFromLeft (28));
+        shapeBox.setBounds (tools.removeFromLeft (84).reduced (1, 3));
+        periodBox.setBounds (tools.removeFromLeft (78).reduced (1, 3));
+        lfoButton.setBounds (tools.removeFromLeft (56).reduced (2, 3));
+
+        if (! fitted && plotArea().getWidth() > 50) // the whole pattern, with a little room after it
+        {
+            fitted = true;
+            pixelsPerTick = juce::jlimit (2.0 / ticksPerStep, 80.0 / ticksPerStep, (plotArea().getWidth() - 8) / (patternLength() * 1.15));
+        }
+    }
+
+    // --- mouse ---------------------------------------------------------------------------------
+
+    void mouseDown (const juce::MouseEvent& e) override
+    {
+        if (! plotArea().contains (e.getPosition()))
+            return;
+
+        grabKeyboardFocus();
+        const auto tick = snap (xToTick (e.x));
+
+        if (selectButton.getToggleState())
+        {
+            selectionAnchor = tick;
+            selectionStart = selectionEnd = -1;
+            repaint();
+            return;
+        }
+
+        beginGesture();
+
+        if (lineButton.getToggleState() && ! e.mods.isRightButtonDown())
+        {
+            lineFrom = std::make_pair (tick, yToValue (e.y));
+            lineTo = e.getPosition();
+            return;
+        }
+
+        lastDraw = std::make_pair (tick, yToValue (e.y));
+        drawCells (tick, yToValue (e.y), tick, yToValue (e.y), e.mods.isRightButtonDown());
+    }
+
+    void mouseDrag (const juce::MouseEvent& e) override
+    {
+        const auto tick = snap (xToTick (juce::jlimit (plotArea().getX(), plotArea().getRight() - 1, e.x)));
+        hoverValue = yToValue (e.y);
+
+        if (selectButton.getToggleState() && selectionAnchor >= 0)
+        {
+            selectionStart = juce::jmin (selectionAnchor, tick);
+            selectionEnd = juce::jmax (selectionAnchor, tick) + gridTicks();
+            repaint();
+            return;
+        }
+
+        if (lineFrom)
+        {
+            lineTo = e.getPosition();
+            repaint();
+            return;
+        }
+
+        if (lastDraw)
+        {
+            drawCells (lastDraw->first, lastDraw->second, tick, yToValue (e.y), e.mods.isRightButtonDown());
+            lastDraw = std::make_pair (tick, yToValue (e.y));
+        }
+    }
+
+    void mouseUp (const juce::MouseEvent& e) override
+    {
+        if (selectButton.getToggleState())
+        {
+            if (selectionEnd <= selectionStart) // a click clears the selection
+                selectionStart = selectionEnd = -1;
+            selectionAnchor = -1;
+            repaint();
+            return;
+        }
+
+        if (lineFrom)
+        {
+            const auto from = *lineFrom;
+            const auto to = std::make_pair (snap (xToTick (e.x)), yToValue (e.y));
+            lineFrom.reset();
+            const auto step = gridTicks();
+            previewGesture ([&] (PatternEvents& lane) {
+                if (to.first >= from.first)
+                    eventedit::line (lane, from.first, to.first + step, from.second, to.second, step);
+                else
+                    eventedit::line (lane, to.first, from.first + step, to.second, from.second, step);
+            });
+        }
+
+        lastDraw.reset();
+        commitGesture();
+    }
+
+    void mouseMove (const juce::MouseEvent& e) override
+    {
+        const auto inside = plotArea().contains (e.getPosition());
+        hoverValue = inside ? yToValue (e.y) : -1.0f;
+        repaint();
+    }
+
+    void mouseExit (const juce::MouseEvent&) override
+    {
+        hoverValue = -1.0f;
+        repaint();
+    }
+
+    void mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& w) override
+    {
+        if (e.mods.isCtrlDown())
+        {
+            const auto at = xToTick (e.x);
+            pixelsPerTick = juce::jlimit (2.0 / ticksPerStep, 80.0 / ticksPerStep, pixelsPerTick * (w.deltaY > 0 ? 1.2 : 1.0 / 1.2));
+            scroll = juce::jmax (0.0, at - (e.x - plotArea().getX()) / pixelsPerTick);
+        }
+        else
+            scroll = juce::jmax (0.0, scroll - (w.deltaY + w.deltaX) * 400.0 / (pixelsPerTick * ticksPerStep) * ticksPerStep / 16.0);
+
+        repaint();
+    }
+
+    bool keyPressed (const juce::KeyPress& key) override
+    {
+        if (key == juce::KeyPress::deleteKey || key == juce::KeyPress::backspaceKey)
+        {
+            edit ([] (PatternEvents& lane, std::int64_t from, std::int64_t to) { eventedit::erase (lane, from, to); });
+            return true;
+        }
+
+        if (key == juce::KeyPress ('a', juce::ModifierKeys::commandModifier, 0))
+        {
+            selectionStart = 0;
+            selectionEnd = patternLength();
+            repaint();
+            return true;
+        }
+
+        return false;
+    }
+
+private:
+    static constexpr int rulerHeight = 18;
+
+    // --- model access ---------------------------------------------------------------------------
+
+    const Pattern& currentPattern() const
+    {
+        const auto& song = engine.getSong();
+        return song.patterns[(std::size_t) juce::jlimit (0, (int) song.patterns.size() - 1, song.currentPattern)];
+    }
+
+    static Pattern& currentPattern (Song& s)
+    {
+        return s.patterns[(std::size_t) juce::jlimit (0, (int) s.patterns.size() - 1, s.currentPattern)];
+    }
+
+    std::int64_t patternLength() const
+    {
+        return juce::jmax<std::int64_t> (ticksPerStep, currentPattern().effectiveLength (engine.getSong().beatsPerBar));
+    }
+
+    std::int64_t gridTicks() const
+    {
+        static const std::int64_t steps[] = { ticksPerStep / 2, ticksPerStep, ppq / 2, ppq, -1 };
+        const auto i = juce::jlimit (0, 4, gridBox.getSelectedItemIndex());
+        return steps[i] > 0 ? steps[i] : (std::int64_t) ppq * juce::jmax (1, engine.getSong().beatsPerBar);
+    }
+
+    std::int64_t snap (double tick) const
+    {
+        const auto g = gridTicks();
+        return juce::jmax<std::int64_t> (0, (std::int64_t) std::floor (tick / (double) g) * g);
+    }
+
+    void rebuildTargets()
+    {
+        const auto& song = engine.getSong();
+        targets.clear();
+        const auto add = [this] (const AutomationTarget& t) {
+            if (t.kind != AutomationTargetKind::none && t.kind != AutomationTargetKind::tempo
+                && std::none_of (targets.begin(), targets.end(), [&] (const AutomationTarget& o) { return sameTarget (o, t); }))
+                targets.push_back (t);
+        };
+
+        add (target);
+        const auto channel = engine.getSelectedChannel();
+        if (channel >= 0 && channel < (int) song.channels.size())
+        {
+            add ({ AutomationTargetKind::channelVolume, channel });
+            add ({ AutomationTargetKind::channelPan, channel });
+        }
+        for (const auto& lane : currentPattern().events)
+            if (! lane.events.empty())
+                add (lane.target);
+
+        targetBox.clear (juce::dontSendNotification);
+        for (std::size_t i = 0; i < targets.size(); ++i)
+        {
+            const auto* lane = eventedit::findLane (currentPattern(), targets[i]);
+            const auto marker = lane != nullptr && ! lane->events.empty() ? juce::String (" *") : juce::String();
+            targetBox.addItem (describeAutomationTarget (engine, targets[i]) + marker, (int) i + 1);
+            if (sameTarget (targets[i], target))
+                targetBox.setSelectedItemIndex ((int) i, juce::dontSendNotification);
+        }
+
+        title.setText (tr ("Events - {0}", { juce::String::fromUTF8 (currentPattern().name.c_str()) }), juce::dontSendNotification);
+    }
+
+    // --- editing --------------------------------------------------------------------------------
+
+    void beginGesture()
+    {
+        if (! gestureStart)
+            gestureStart = currentPattern().events;
+    }
+
+    // edits the live pattern (no undo step yet)
+    void previewGesture (const std::function<void (PatternEvents&)>& fn)
+    {
+        const auto t = target;
+        engine.editSong ([&] (Song& s) { fn (eventedit::laneFor (currentPattern (s), t)); }, false);
+        repaint();
+    }
+
+    // replaces the live lane by `fn` applied to the gesture's starting state
+    void previewFromStart (const std::function<void (PatternEvents&)>& fn)
+    {
+        if (! gestureStart)
+            return;
+
+        const auto t = target;
+        const auto start = *gestureStart;
+        engine.editSong ([&] (Song& s) {
+            auto& p = currentPattern (s);
+            p.events = start;
+            fn (eventedit::laneFor (p, t));
+        }, false);
+        repaint();
+    }
+
+    void commitGesture()
+    {
+        if (! gestureStart)
+            return;
+
+        auto after = currentPattern().events;
+        auto before = std::move (*gestureStart);
+        gestureStart.reset();
+
+        engine.editSong ([&] (Song& s) { currentPattern (s).events = before; }, false);
+        engine.editSong ([&] (Song& s) {
+            auto& p = currentPattern (s);
+            p.events = std::move (after);
+            eventedit::removeEmptyLanes (p);
+        });
+        rebuildTargets();
+        repaint();
+    }
+
+    // one undo step: `fn` on the selection (or the whole pattern)
+    void edit (const std::function<void (PatternEvents&, std::int64_t, std::int64_t)>& fn)
+    {
+        const auto from = selectionEnd > selectionStart ? selectionStart : 0;
+        const auto to = selectionEnd > selectionStart ? selectionEnd : juce::jmax (patternLength(), lastEventTick() + 1);
+        beginGesture();
+        previewGesture ([&] (PatternEvents& lane) { fn (lane, from, to); });
+        commitGesture();
+    }
+
+    std::int64_t lastEventTick() const
+    {
+        const auto* lane = eventedit::findLane (currentPattern(), target);
+        return lane != nullptr && ! lane->events.empty() ? lane->events.back().tick : 0;
+    }
+
+    void drawCells (std::int64_t fromTick, float fromValue, std::int64_t toTick, float toValue, bool erase)
+    {
+        const auto step = gridTicks();
+        const auto a = juce::jmin (fromTick, toTick), b = juce::jmax (fromTick, toTick);
+        const auto va = fromTick <= toTick ? fromValue : toValue, vb = fromTick <= toTick ? toValue : fromValue;
+
+        previewGesture ([&] (PatternEvents& lane) {
+            if (erase)
+                eventedit::erase (lane, a, b + step);
+            else
+                eventedit::line (lane, a, b + step, va, vb, step);
+        });
+    }
+
+    void previewScale()
+    {
+        if (resettingSliders)
+            return;
+
+        const auto standalone = ! gestureStart; // typed into the text box: one step at once
+        beginGesture();
+        const auto from = selectionEnd > selectionStart ? selectionStart : 0;
+        const auto to = selectionEnd > selectionStart ? selectionEnd : std::numeric_limits<std::int64_t>::max();
+        const auto factor = (float) scaleSlider.getValue(), offset = (float) offsetSlider.getValue();
+        const auto bipolar = bipolarTarget (target);
+        previewFromStart ([&] (PatternEvents& lane) { eventedit::scale (lane, from, to, factor, offset, bipolar); });
+
+        if (standalone && ! scaleSlider.isMouseButtonDown() && ! offsetSlider.isMouseButtonDown())
+        {
+            commitGesture();
+            const juce::ScopedValueSetter<bool> quiet (resettingSliders, true);
+            scaleSlider.setValue (1.0, juce::dontSendNotification);
+            offsetSlider.setValue (0.0, juce::dontSendNotification);
+        }
+    }
+
+    void applyLfo()
+    {
+        static const double periodBeats[] = { 1.0, 2.0, 4.0, 8.0, 16.0 };
+        prtools::LfoOptions o;
+        o.shape = shapeBox.getSelectedItemIndex();
+        // FL's speed wheel for the period: beat x 2^(7 - speed/4096)
+        o.startSpeed = juce::roundToInt ((7.0 - std::log2 (periodBeats[juce::jlimit (0, 4, periodBox.getSelectedItemIndex())])) * 4096.0);
+        o.phase = 0;
+        const auto step = gridTicks();
+        edit ([&] (PatternEvents& lane, std::int64_t from, std::int64_t to) { eventedit::applyLfo (lane, from, to, o, step); });
+    }
+
+    void setupSlider (juce::Slider& s, double min, double max, double initial, std::function<juce::String (double)> format)
+    {
+        s.setSliderStyle (juce::Slider::LinearHorizontal);
+        s.setTextBoxStyle (juce::Slider::TextBoxRight, false, 48, 18);
+        s.setRange (min, max, 0.01);
+        s.setValue (initial, juce::dontSendNotification);
+        s.setDoubleClickReturnValue (true, initial);
+        s.textFromValueFunction = std::move (format);
+        s.updateText();
+        addAndMakeVisible (s);
+    }
+
+    // --- geometry -------------------------------------------------------------------------------
+
+    juce::Rectangle<int> plotArea() const { return canvas.withTrimmedTop (rulerHeight); }
+    double tickToX (double tick) const { return plotArea().getX() + (tick - scroll) * pixelsPerTick; }
+    double xToTick (int x) const { return scroll + (x - plotArea().getX()) / pixelsPerTick; }
+    float valueToY (float v) const
+    {
+        const auto a = plotArea().reduced (0, 6);
+        return (float) a.getBottom() - v * (float) a.getHeight();
+    }
+    float yToValue (int y) const
+    {
+        const auto a = plotArea().reduced (0, 6);
+        return juce::jlimit (0.0f, 1.0f, (float) (a.getBottom() - y) / (float) juce::jmax (1, a.getHeight()));
+    }
+
+    void changeListenerCallback (juce::ChangeBroadcaster*) override
+    {
+        if (! gestureStart)
+        {
+            rebuildTargets();
+            repaint();
+        }
+    }
+
+    void timerCallback() override
+    {
+        auto tick = -1.0;
+        const auto& song = engine.getSong();
+
+        if (engine.getTransport().playing.load())
+        {
+            const auto position = engine.getTransport().positionTicks.load();
+
+            if (song.mode != PlayMode::song)
+                tick = std::fmod (position, (double) patternLength());
+            else
+            {
+                const auto p = std::fmod (position, (double) juce::jmax<std::int64_t> (1, song.songLength()));
+                for (const auto& c : song.playlist)
+                    if (c.kind == ClipKind::pattern && c.pattern == song.currentPattern && p >= (double) c.start && p < (double) c.end())
+                        tick = p - (double) c.start + (double) c.offset;
+            }
+        }
+
+        if (tick != playhead)
+        {
+            playhead = tick;
+            repaint();
+        }
+    }
+
+    AudioEngine& engine;
+    AutomationTarget target;
+    std::vector<AutomationTarget> targets;
+
+    juce::Label title, gridLabel, scaleLabel, offsetLabel, randomLabel, lfoLabel;
+    juce::ComboBox targetBox, gridBox, shapeBox, periodBox;
+    juce::TextButton drawButton, lineButton, selectButton, randomButton, lfoButton, clearButton;
+    juce::Slider scaleSlider, offsetSlider, amountSlider;
+
+    juce::Rectangle<int> canvas;
+    double pixelsPerTick = 0.05, scroll = 0.0, playhead = -1.0;
+    bool fitted = false, resettingSliders = false;
+    float hoverValue = -1.0f;
+    std::int64_t selectionStart = -1, selectionEnd = -1, selectionAnchor = -1;
+    std::optional<std::pair<std::int64_t, float>> lineFrom, lastDraw;
+    juce::Point<int> lineTo;
+    std::optional<std::vector<PatternEvents>> gestureStart;
+    std::uint32_t seed = 1;
+};
+} // namespace
+
+void openEventEditor (AudioEngine& engine, const AutomationTarget& target)
+{
+    // one event editor at a time: the same key replaces an open one
+    openToolWindow (std::make_unique<EventEditor> (engine, target), tr ("Event editor"), "eventeditor");
+}
+
+std::unique_ptr<juce::Component> makeEventEditor (AudioEngine& engine, const AutomationTarget& target)
+{
+    return std::make_unique<EventEditor> (engine, target);
+}
+} // namespace lynx

+ 21 - 0
src/ui/EventEditor.h

@@ -0,0 +1,21 @@
+#pragma once
+
+// Event editor (round 83, FL's event editor): edits the current pattern's events of one target (channel volume,
+// pan, a plugin or mixer parameter) as a bar graph. Tools: draw, line, select; on the selection (or the whole
+// pattern): scale/offset, randomise, FL's LFO, clear. Each gesture is one undo step. While the pattern plays, its
+// events drive the target (core/RackRenderer).
+
+#include <memory>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+// Opens (or brings to front) the event editor of the current pattern, showing `target`.
+void openEventEditor (AudioEngine& engine, const AutomationTarget& target);
+
+// Just the editor (for --snapshot mode).
+std::unique_ptr<juce::Component> makeEventEditor (AudioEngine& engine, const AutomationTarget& target);
+} // namespace lynx

+ 503 - 318
src/ui/I18nData.h

@@ -3929,323 +3929,508 @@ inline constexpr unsigned char ptBR[] = {
 116, 101, 32, 116, 111, 111, 108, 115, 34, 32, 61, 32, 34, 70, 101, 114, 114, 97, 109, 101, 110, 116, 97, 115,
 32, 100, 101, 32, 110, 111, 116, 97, 115, 34, 10, 34, 83, 110, 97, 112, 32, 116, 111, 32, 115, 99, 97, 108,
 101, 34, 32, 61, 32, 34, 69, 110, 99, 97, 105, 120, 97, 114, 32, 110, 97, 32, 101, 115, 99, 97, 108, 97,
-34, 10, 34, 77, 73, 68, 73, 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, 101, 32, 77, 73, 68, 73, 46,
-46, 46, 34, 10, 34, 71, 101, 110, 101, 114, 97, 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, 103, 101, 114,
-97, 105, 115, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 109, 97, 110, 97, 103, 101, 114, 46,
-46, 46, 34, 32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 100, 111, 114, 32, 100, 101, 32, 112, 108,
-117, 103, 105, 110, 115, 46, 46, 46, 34, 10, 34, 77, 97, 110, 97, 103, 101, 32, 115, 104, 111, 114, 116, 99,
-117, 116, 115, 46, 46, 46, 34, 32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 114, 32, 97, 116, 97,
-108, 104, 111, 115, 46, 46, 46, 34, 10, 34, 70, 97, 105, 108, 101, 100, 32, 116, 111, 32, 108, 111, 97, 100,
-34, 32, 61, 32, 34, 70, 97, 108, 104, 111, 117, 32, 97, 111, 32, 99, 97, 114, 114, 101, 103, 97, 114, 34,
-10, 34, 70, 105, 108, 101, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 34, 32, 61, 32, 34, 65, 114, 113,
-117, 105, 118, 111, 32, 110, 195, 163, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 34, 10, 34, 83,
-101, 97, 114, 99, 104, 32, 110, 97, 109, 101, 44, 32, 118, 101, 110, 100, 111, 114, 44, 32, 102, 111, 114, 109,
-97, 116, 32, 111, 114, 32, 102, 105, 108, 101, 34, 32, 61, 32, 34, 66, 117, 115, 99, 97, 114, 32, 110, 111,
-109, 101, 44, 32, 102, 97, 98, 114, 105, 99, 97, 110, 116, 101, 44, 32, 102, 111, 114, 109, 97, 116, 111, 32,
-111, 117, 32, 97, 114, 113, 117, 105, 118, 111, 34, 10, 34, 65, 108, 108, 34, 32, 61, 32, 34, 84, 111, 100,
-111, 115, 34, 10, 34, 73, 110, 115, 116, 114, 117, 109, 101, 110, 116, 115, 34, 32, 61, 32, 34, 73, 110, 115,
-116, 114, 117, 109, 101, 110, 116, 111, 115, 34, 10, 34, 69, 102, 102, 101, 99, 116, 115, 34, 32, 61, 32, 34,
-69, 102, 101, 105, 116, 111, 115, 34, 10, 34, 70, 97, 118, 111, 117, 114, 105, 116, 101, 115, 34, 32, 61, 32,
-34, 70, 97, 118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 70, 97, 105, 108, 101, 100, 34, 32, 61, 32, 34,
-67, 111, 109, 32, 102, 97, 108, 104, 97, 34, 10, 34, 86, 101, 110, 100, 111, 114, 34, 32, 61, 32, 34, 70,
-97, 98, 114, 105, 99, 97, 110, 116, 101, 34, 10, 34, 84, 121, 112, 101, 34, 32, 61, 32, 34, 84, 105, 112,
-111, 34, 10, 34, 83, 116, 97, 116, 117, 115, 34, 32, 61, 32, 34, 69, 115, 116, 97, 100, 111, 34, 10, 34,
-123, 48, 125, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 115, 44, 32, 123, 49, 125, 32, 101, 102, 102,
-101, 99, 116, 115, 44, 32, 123, 50, 125, 32, 119, 105, 116, 104, 32, 112, 114, 111, 98, 108, 101, 109, 115, 34,
-32, 61, 32, 34, 123, 48, 125, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 111, 115, 44, 32, 123, 49,
-125, 32, 101, 102, 101, 105, 116, 111, 115, 44, 32, 123, 50, 125, 32, 99, 111, 109, 32, 112, 114, 111, 98, 108,
-101, 109, 97, 115, 34, 10, 34, 69, 102, 102, 101, 99, 116, 34, 32, 61, 32, 34, 69, 102, 101, 105, 116, 111,
-34, 10, 34, 70, 97, 118, 111, 117, 114, 105, 116, 101, 58, 32, 108, 105, 115, 116, 101, 100, 32, 102, 105, 114,
-115, 116, 32, 119, 104, 101, 110, 32, 97, 100, 100, 105, 110, 103, 32, 97, 32, 112, 108, 117, 103, 105, 110, 34,
-32, 61, 32, 34, 70, 97, 118, 111, 114, 105, 116, 111, 58, 32, 97, 112, 97, 114, 101, 99, 101, 32, 112, 114,
-105, 109, 101, 105, 114, 111, 32, 97, 111, 32, 97, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 112,
-108, 117, 103, 105, 110, 34, 10, 34, 84, 104, 101, 32, 115, 99, 97, 110, 32, 99, 111, 117, 108, 100, 110, 39,
-116, 32, 108, 111, 97, 100, 32, 116, 104, 105, 115, 32, 102, 105, 108, 101, 32, 40, 105, 116, 32, 99, 114, 97,
-115, 104, 101, 100, 44, 32, 104, 117, 110, 103, 32, 111, 114, 32, 105, 115, 110, 39, 116, 32, 97, 32, 112, 108,
-117, 103, 105, 110, 41, 46, 32, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 62, 32, 84, 114, 121,
-32, 97, 103, 97, 105, 110, 46, 34, 32, 61, 32, 34, 65, 32, 98, 117, 115, 99, 97, 32, 110, 195, 163, 111,
-32, 99, 111, 110, 115, 101, 103, 117, 105, 117, 32, 99, 97, 114, 114, 101, 103, 97, 114, 32, 101, 115, 116, 101,
-32, 97, 114, 113, 117, 105, 118, 111, 32, 40, 116, 114, 97, 118, 111, 117, 44, 32, 112, 97, 114, 111, 117, 32,
-100, 101, 32, 114, 101, 115, 112, 111, 110, 100, 101, 114, 32, 111, 117, 32, 110, 195, 163, 111, 32, 195, 169, 32,
-117, 109, 32, 112, 108, 117, 103, 105, 110, 41, 46, 32, 67, 108, 105, 113, 117, 101, 32, 99, 111, 109, 32, 111,
-32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 62, 32, 84, 101, 110, 116, 97, 114,
-32, 100, 101, 32, 110, 111, 118, 111, 46, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 102, 114, 111, 109, 32,
-102, 97, 118, 111, 117, 114, 105, 116, 101, 115, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 100,
-111, 115, 32, 102, 97, 118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 65, 100, 100, 32, 116, 111, 32, 102, 97,
-118, 111, 117, 114, 105, 116, 101, 115, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 97,
-111, 115, 32, 102, 97, 118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 84, 114, 121, 32, 97, 103, 97, 105, 110,
-32, 40, 115, 99, 97, 110, 32, 116, 104, 105, 115, 32, 102, 105, 108, 101, 32, 110, 111, 119, 41, 34, 32, 61,
-32, 34, 84, 101, 110, 116, 97, 114, 32, 100, 101, 32, 110, 111, 118, 111, 32, 40, 101, 120, 97, 109, 105, 110,
-97, 114, 32, 101, 115, 116, 101, 32, 97, 114, 113, 117, 105, 118, 111, 32, 97, 103, 111, 114, 97, 41, 34, 10,
-34, 82, 101, 109, 111, 118, 101, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 108, 105, 115, 116, 34, 32, 61,
-32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 100, 97, 32, 108, 105, 115, 116, 97, 34, 10, 34, 83, 104, 111,
-119, 32, 105, 110, 32, 102, 111, 108, 100, 101, 114, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32,
-110, 97, 32, 112, 97, 115, 116, 97, 34, 10, 34, 67, 111, 112, 121, 32, 112, 97, 116, 104, 34, 32, 61, 32,
-34, 67, 111, 112, 105, 97, 114, 32, 99, 97, 109, 105, 110, 104, 111, 34, 10, 34, 82, 101, 115, 99, 97, 110,
-32, 97, 108, 108, 32, 112, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97,
-114, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 112, 108, 117, 103, 105, 110, 115, 32, 100, 101, 32, 110, 111,
-118, 111, 34, 10, 34, 76, 89, 78, 88, 32, 102, 111, 114, 103, 101, 116, 115, 32, 101, 118, 101, 114, 121, 32,
-112, 108, 117, 103, 105, 110, 32, 105, 116, 32, 102, 111, 117, 110, 100, 32, 40, 97, 110, 100, 32, 116, 104, 101,
-32, 111, 110, 101, 115, 32, 116, 104, 97, 116, 32, 102, 97, 105, 108, 101, 100, 41, 32, 97, 110, 100, 32, 101,
-120, 97, 109, 105, 110, 101, 115, 32, 97, 108, 108, 32, 112, 108, 117, 103, 105, 110, 32, 102, 111, 108, 100, 101,
-114, 115, 32, 97, 103, 97, 105, 110, 46, 32, 84, 104, 105, 115, 32, 99, 97, 110, 32, 116, 97, 107, 101, 32,
-97, 32, 102, 101, 119, 32, 109, 105, 110, 117, 116, 101, 115, 59, 32, 76, 89, 78, 88, 32, 115, 116, 97, 121,
-115, 32, 117, 115, 97, 98, 108, 101, 32, 109, 101, 97, 110, 119, 104, 105, 108, 101, 46, 34, 32, 61, 32, 34,
-79, 32, 76, 89, 78, 88, 32, 101, 115, 113, 117, 101, 99, 101, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32,
-112, 108, 117, 103, 105, 110, 115, 32, 113, 117, 101, 32, 101, 110, 99, 111, 110, 116, 114, 111, 117, 32, 40, 101,
-32, 111, 115, 32, 113, 117, 101, 32, 102, 97, 108, 104, 97, 114, 97, 109, 41, 32, 101, 32, 101, 120, 97, 109,
-105, 110, 97, 32, 100, 101, 32, 110, 111, 118, 111, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 112, 97, 115,
-116, 97, 115, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 46, 32, 73, 115, 115, 111, 32, 112, 111, 100,
-101, 32, 108, 101, 118, 97, 114, 32, 97, 108, 103, 117, 110, 115, 32, 109, 105, 110, 117, 116, 111, 115, 59, 32,
-101, 110, 113, 117, 97, 110, 116, 111, 32, 105, 115, 115, 111, 32, 111, 32, 76, 89, 78, 88, 32, 99, 111, 110,
-116, 105, 110, 117, 97, 32, 117, 116, 105, 108, 105, 122, 195, 161, 118, 101, 108, 46, 34, 10, 34, 82, 101, 115,
-99, 97, 110, 34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 114, 32, 100, 101, 32, 110, 111, 118, 111,
-34, 10, 34, 65, 100, 100, 32, 97, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 34, 32, 61, 32,
-34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 97, 114, 113, 117, 105, 118, 111, 32, 100, 101,
-32, 112, 108, 117, 103, 105, 110, 34, 10, 34, 83, 99, 97, 110, 110, 105, 110, 103, 58, 32, 123, 48, 125, 34,
-32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 110, 100, 111, 58, 32, 123, 48, 125, 34, 10, 34, 76, 97,
-115, 116, 32, 115, 99, 97, 110, 58, 32, 49, 32, 110, 101, 119, 32, 112, 108, 117, 103, 105, 110, 46, 34, 32,
-61, 32, 34, 195, 154, 108, 116, 105, 109, 97, 32, 98, 117, 115, 99, 97, 58, 32, 49, 32, 112, 108, 117, 103,
-105, 110, 32, 110, 111, 118, 111, 46, 34, 10, 34, 76, 97, 115, 116, 32, 115, 99, 97, 110, 58, 32, 123, 48,
-125, 32, 110, 101, 119, 32, 112, 108, 117, 103, 105, 110, 115, 46, 34, 32, 61, 32, 34, 195, 154, 108, 116, 105,
-109, 97, 32, 98, 117, 115, 99, 97, 58, 32, 123, 48, 125, 32, 112, 108, 117, 103, 105, 110, 115, 32, 110, 111,
-118, 111, 115, 46, 34, 10, 34, 69, 97, 99, 104, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 32,
-105, 115, 32, 101, 120, 97, 109, 105, 110, 101, 100, 32, 105, 110, 32, 97, 32, 115, 101, 112, 97, 114, 97, 116,
-101, 32, 112, 114, 111, 99, 101, 115, 115, 58, 32, 111, 110, 101, 32, 116, 104, 97, 116, 32, 99, 114, 97, 115,
-104, 101, 115, 32, 105, 115, 32, 109, 97, 114, 107, 101, 100, 32, 97, 115, 32, 102, 97, 105, 108, 101, 100, 32,
-97, 110, 100, 32, 115, 107, 105, 112, 112, 101, 100, 32, 108, 97, 116, 101, 114, 46, 34, 32, 61, 32, 34, 67,
-97, 100, 97, 32, 97, 114, 113, 117, 105, 118, 111, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 32, 195, 169,
-32, 101, 120, 97, 109, 105, 110, 97, 100, 111, 32, 101, 109, 32, 117, 109, 32, 112, 114, 111, 99, 101, 115, 115,
-111, 32, 115, 101, 112, 97, 114, 97, 100, 111, 58, 32, 117, 109, 32, 113, 117, 101, 32, 116, 114, 97, 118, 97,
-32, 195, 169, 32, 109, 97, 114, 99, 97, 100, 111, 32, 99, 111, 109, 111, 32, 102, 97, 108, 104, 111, 32, 101,
-32, 112, 117, 108, 97, 100, 111, 32, 100, 101, 112, 111, 105, 115, 46, 34, 10, 34, 70, 105, 110, 100, 32, 110,
-101, 119, 32, 112, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 66, 117, 115, 99, 97, 114, 32, 112, 108,
-117, 103, 105, 110, 115, 32, 110, 111, 118, 111, 115, 34, 10, 34, 82, 101, 115, 99, 97, 110, 32, 97, 108, 108,
-46, 46, 46, 34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 114, 32, 116, 117, 100, 111, 32, 100, 101,
-32, 110, 111, 118, 111, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 102, 111, 108, 100, 101, 114,
-115, 46, 46, 46, 34, 32, 61, 32, 34, 80, 97, 115, 116, 97, 115, 32, 100, 101, 32, 112, 108, 117, 103, 105,
-110, 115, 46, 46, 46, 34, 10, 34, 65, 100, 100, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 46,
-46, 46, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 97, 114, 113, 117, 105, 118, 111,
-32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 109,
-97, 110, 97, 103, 101, 114, 34, 32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 100, 111, 114, 32, 100,
-101, 32, 112, 108, 117, 103, 105, 110, 115, 34, 10, 34, 77, 73, 68, 73, 34, 32, 61, 32, 34, 77, 73, 68,
-73, 34, 10, 34, 65, 32, 110, 101, 119, 32, 108, 97, 110, 103, 117, 97, 103, 101, 32, 105, 115, 32, 97, 112,
-112, 108, 105, 101, 100, 32, 119, 104, 101, 110, 32, 76, 89, 78, 88, 32, 114, 101, 115, 116, 97, 114, 116, 115,
-46, 34, 32, 61, 32, 34, 85, 109, 32, 110, 111, 118, 111, 32, 105, 100, 105, 111, 109, 97, 32, 195, 169, 32,
-97, 112, 108, 105, 99, 97, 100, 111, 32, 113, 117, 97, 110, 100, 111, 32, 111, 32, 76, 89, 78, 88, 32, 114,
-101, 105, 110, 105, 99, 105, 97, 46, 34, 10, 34, 73, 110, 116, 101, 114, 102, 97, 99, 101, 32, 115, 105, 122,
-101, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 97, 32, 105, 110, 116, 101, 114, 102, 97,
-99, 101, 34, 10, 34, 77, 97, 120, 105, 109, 117, 109, 32, 117, 110, 100, 111, 32, 108, 101, 118, 101, 108, 115,
-34, 32, 61, 32, 34, 77, 195, 161, 120, 105, 109, 111, 32, 100, 101, 32, 110, 195, 173, 118, 101, 105, 115, 32,
-100, 101, 32, 100, 101, 115, 102, 97, 122, 101, 114, 34, 10, 34, 83, 97, 118, 101, 32, 97, 32, 98, 97, 99,
-107, 117, 112, 32, 99, 111, 112, 121, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 117, 109, 97, 32,
-99, 195, 179, 112, 105, 97, 32, 100, 101, 32, 115, 101, 103, 117, 114, 97, 110, 195, 167, 97, 34, 10, 34, 78,
-101, 118, 101, 114, 34, 32, 61, 32, 34, 78, 117, 110, 99, 97, 34, 10, 34, 69, 118, 101, 114, 121, 32, 109,
-105, 110, 117, 116, 101, 34, 32, 61, 32, 34, 65, 32, 99, 97, 100, 97, 32, 109, 105, 110, 117, 116, 111, 34,
-10, 34, 69, 118, 101, 114, 121, 32, 123, 48, 125, 32, 109, 105, 110, 117, 116, 101, 115, 34, 32, 61, 32, 34,
-65, 32, 99, 97, 100, 97, 32, 123, 48, 125, 32, 109, 105, 110, 117, 116, 111, 115, 34, 10, 34, 66, 97, 99,
-107, 117, 112, 115, 32, 107, 101, 112, 116, 32, 112, 101, 114, 32, 112, 114, 111, 106, 101, 99, 116, 34, 32, 61,
-32, 34, 67, 195, 179, 112, 105, 97, 115, 32, 109, 97, 110, 116, 105, 100, 97, 115, 32, 112, 111, 114, 32, 112,
-114, 111, 106, 101, 116, 111, 34, 10, 34, 65, 112, 112, 108, 105, 101, 115, 32, 116, 111, 32, 112, 108, 117, 103,
-105, 110, 115, 32, 111, 112, 101, 110, 101, 100, 32, 102, 114, 111, 109, 32, 110, 111, 119, 32, 111, 110, 59, 32,
-114, 101, 111, 112, 101, 110, 32, 116, 104, 101, 32, 112, 114, 111, 106, 101, 99, 116, 32, 116, 111, 32, 109, 111,
-118, 101, 32, 116, 104, 101, 32, 111, 116, 104, 101, 114, 115, 46, 34, 32, 61, 32, 34, 86, 97, 108, 101, 32,
-112, 97, 114, 97, 32, 111, 115, 32, 112, 108, 117, 103, 105, 110, 115, 32, 97, 98, 101, 114, 116, 111, 115, 32,
-100, 97, 113, 117, 105, 32, 101, 109, 32, 100, 105, 97, 110, 116, 101, 59, 32, 114, 101, 97, 98, 114, 97, 32,
-111, 32, 112, 114, 111, 106, 101, 116, 111, 32, 112, 97, 114, 97, 32, 109, 111, 118, 101, 114, 32, 111, 115, 32,
-111, 117, 116, 114, 111, 115, 46, 34, 10, 34, 83, 101, 101, 44, 32, 115, 101, 97, 114, 99, 104, 32, 97, 110,
-100, 32, 99, 104, 97, 110, 103, 101, 32, 101, 118, 101, 114, 121, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32,
-115, 104, 111, 114, 116, 99, 117, 116, 46, 34, 32, 61, 32, 34, 86, 101, 106, 97, 44, 32, 98, 117, 115, 113,
-117, 101, 32, 101, 32, 97, 108, 116, 101, 114, 101, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116, 97,
-108, 104, 111, 115, 32, 100, 101, 32, 116, 101, 99, 108, 97, 100, 111, 46, 34, 10, 34, 76, 97, 110, 103, 117,
-97, 103, 101, 32, 97, 110, 100, 32, 100, 105, 115, 112, 108, 97, 121, 34, 32, 61, 32, 34, 73, 100, 105, 111,
-109, 97, 32, 101, 32, 101, 120, 105, 98, 105, 195, 167, 195, 163, 111, 34, 10, 34, 83, 116, 97, 114, 116, 117,
-112, 34, 32, 61, 32, 34, 73, 110, 105, 99, 105, 97, 108, 105, 122, 97, 195, 167, 195, 163, 111, 34, 10, 34,
-69, 100, 105, 116, 105, 110, 103, 34, 32, 61, 32, 34, 69, 100, 105, 195, 167, 195, 163, 111, 34, 10, 34, 66,
-97, 99, 107, 117, 112, 34, 32, 61, 32, 34, 67, 195, 179, 112, 105, 97, 32, 100, 101, 32, 115, 101, 103, 117,
-114, 97, 110, 195, 167, 97, 34, 10, 34, 80, 108, 117, 103, 105, 110, 115, 32, 97, 110, 100, 32, 115, 104, 111,
-114, 116, 99, 117, 116, 115, 34, 32, 61, 32, 34, 80, 108, 117, 103, 105, 110, 115, 32, 101, 32, 97, 116, 97,
-108, 104, 111, 115, 34, 10, 34, 79, 112, 101, 110, 32, 98, 97, 99, 107, 117, 112, 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, 97, 115, 32, 99, 195,
-179, 112, 105, 97, 115, 34, 10, 34, 68, 114, 105, 118, 101, 114, 34, 32, 61, 32, 34, 68, 114, 105, 118, 101,
-114, 34, 10, 34, 79, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105,
-115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 34, 10, 34, 73, 110,
-112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105, 116, 105,
-118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 34, 10, 34, 66, 117, 102, 102, 101, 114, 32, 115,
-105, 122, 101, 34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 98, 117, 102, 102, 101,
-114, 34, 10, 34, 83, 109, 97, 108, 108, 101, 114, 32, 98, 117, 102, 102, 101, 114, 115, 32, 97, 110, 115, 119,
-101, 114, 32, 102, 97, 115, 116, 101, 114, 32, 119, 104, 101, 110, 32, 121, 111, 117, 32, 112, 108, 97, 121, 59,
-32, 108, 97, 114, 103, 101, 114, 32, 111, 110, 101, 115, 32, 103, 105, 118, 101, 32, 116, 104, 101, 32, 67, 80,
-85, 32, 109, 111, 114, 101, 32, 114, 111, 111, 109, 32, 40, 102, 101, 119, 101, 114, 32, 99, 108, 105, 99, 107,
-115, 41, 46, 34, 32, 61, 32, 34, 66, 117, 102, 102, 101, 114, 115, 32, 109, 101, 110, 111, 114, 101, 115, 32,
-114, 101, 115, 112, 111, 110, 100, 101, 109, 32, 109, 97, 105, 115, 32, 114, 195, 161, 112, 105, 100, 111, 32, 113,
-117, 97, 110, 100, 111, 32, 118, 111, 99, 195, 170, 32, 116, 111, 99, 97, 59, 32, 109, 97, 105, 111, 114, 101,
-115, 32, 100, 195, 163, 111, 32, 109, 97, 105, 115, 32, 102, 111, 108, 103, 97, 32, 195, 160, 32, 67, 80, 85,
-32, 40, 109, 101, 110, 111, 115, 32, 101, 115, 116, 97, 108, 111, 115, 41, 46, 34, 10, 34, 87, 105, 116, 104,
-32, 114, 101, 99, 111, 114, 100, 105, 110, 103, 32, 111, 110, 44, 32, 116, 104, 101, 32, 115, 111, 117, 110, 100,
-32, 99, 97, 114, 100, 32, 105, 110, 112, 117, 116, 32, 98, 101, 99, 111, 109, 101, 115, 32, 97, 32, 80, 108,
-97, 121, 108, 105, 115, 116, 32, 99, 108, 105, 112, 32, 40, 116, 104, 101, 32, 73, 110, 112, 117, 116, 32, 100,
-101, 118, 105, 99, 101, 32, 97, 98, 111, 118, 101, 41, 46, 34, 32, 61, 32, 34, 67, 111, 109, 32, 97, 32,
-103, 114, 97, 118, 97, 195, 167, 195, 163, 111, 32, 108, 105, 103, 97, 100, 97, 44, 32, 97, 32, 101, 110, 116,
-114, 97, 100, 97, 32, 100, 97, 32, 112, 108, 97, 99, 97, 32, 100, 101, 32, 115, 111, 109, 32, 118, 105, 114,
-97, 32, 117, 109, 32, 99, 108, 105, 112, 101, 32, 110, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 32, 40,
-111, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97,
-32, 97, 99, 105, 109, 97, 41, 46, 34, 10, 34, 123, 48, 125, 32, 115, 97, 109, 112, 108, 101, 115, 32, 40,
-123, 49, 125, 32, 109, 115, 41, 34, 32, 61, 32, 34, 123, 48, 125, 32, 97, 109, 111, 115, 116, 114, 97, 115,
-32, 40, 123, 49, 125, 32, 109, 115, 41, 34, 10, 34, 78, 111, 32, 97, 117, 100, 105, 111, 32, 100, 101, 118,
-105, 99, 101, 32, 105, 115, 32, 111, 112, 101, 110, 58, 32, 99, 104, 111, 111, 115, 101, 32, 97, 110, 32, 111,
-117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 46, 34, 32, 61, 32, 34, 78, 101, 110, 104, 117, 109,
-32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 97,
-98, 101, 114, 116, 111, 58, 32, 101, 115, 99, 111, 108, 104, 97, 32, 117, 109, 32, 100, 105, 115, 112, 111, 115,
-105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 46, 34, 10, 34, 123, 48, 125, 32, 105,
-115, 32, 114, 117, 110, 110, 105, 110, 103, 58, 32, 123, 49, 125, 32, 72, 122, 44, 32, 111, 117, 116, 112, 117,
-116, 32, 108, 97, 116, 101, 110, 99, 121, 32, 123, 50, 125, 32, 109, 115, 34, 32, 61, 32, 34, 123, 48, 125,
-32, 101, 115, 116, 195, 161, 32, 114, 111, 100, 97, 110, 100, 111, 58, 32, 123, 49, 125, 32, 72, 122, 44, 32,
-108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 123, 50, 125, 32,
-109, 115, 34, 10, 34, 65, 117, 100, 105, 111, 32, 67, 80, 85, 32, 108, 111, 97, 100, 58, 32, 123, 48, 125,
-37, 34, 32, 61, 32, 34, 67, 97, 114, 103, 97, 32, 100, 101, 32, 67, 80, 85, 32, 100, 111, 32, 195, 161,
-117, 100, 105, 111, 58, 32, 123, 48, 125, 37, 34, 10, 34, 123, 48, 125, 32, 100, 114, 111, 112, 111, 117, 116,
-115, 32, 40, 98, 117, 102, 102, 101, 114, 32, 117, 110, 100, 101, 114, 114, 117, 110, 115, 41, 32, 115, 111, 32,
-102, 97, 114, 34, 32, 61, 32, 34, 123, 48, 125, 32, 102, 97, 108, 104, 97, 115, 32, 40, 98, 117, 102, 102,
-101, 114, 32, 101, 115, 118, 97, 122, 105, 97, 100, 111, 41, 32, 97, 116, 195, 169, 32, 97, 103, 111, 114, 97,
-34, 10, 34, 65, 117, 100, 105, 111, 32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105, 115, 112,
-111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 34, 10, 34, 68, 114, 105, 118,
-101, 114, 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, 100, 114, 105, 118, 101, 114, 46, 46, 46, 34,
-10, 34, 80, 108, 97, 121, 32, 97, 32, 116, 101, 115, 116, 32, 115, 111, 117, 110, 100, 34, 32, 61, 32, 34,
-84, 111, 99, 97, 114, 32, 117, 109, 32, 115, 111, 109, 32, 100, 101, 32, 116, 101, 115, 116, 101, 34, 10, 34,
-65, 110, 121, 32, 77, 73, 68, 73, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 81, 117, 97,
-108, 113, 117, 101, 114, 32, 99, 97, 110, 97, 108, 32, 77, 73, 68, 73, 34, 10, 34, 77, 73, 68, 73, 32,
-99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 32, 77, 73,
-68, 73, 32, 123, 48, 125, 34, 10, 34, 80, 108, 97, 121, 115, 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, 84, 111, 99, 97, 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, 80,
-108, 97, 121, 115, 32, 123, 48, 125, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32, 123, 48, 125, 34, 10, 34,
-80, 108, 97, 121, 115, 32, 99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 84, 111,
-99, 97, 32, 111, 32, 99, 97, 110, 97, 108, 32, 123, 48, 125, 34, 10, 34, 69, 97, 99, 104, 32, 105, 110,
-112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 32, 99, 97, 110, 32, 98, 101, 32, 116, 117, 114, 110, 101, 100,
-32, 111, 102, 102, 44, 32, 108, 105, 115, 116, 101, 110, 32, 116, 111, 32, 111, 110, 101, 32, 77, 73, 68, 73,
-32, 99, 104, 97, 110, 110, 101, 108, 32, 111, 110, 108, 121, 32, 97, 110, 100, 32, 112, 108, 97, 121, 32, 97,
-32, 102, 105, 120, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 32, 111, 102, 32, 116, 104, 101, 32, 67, 104,
-97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 105, 110, 115, 116, 101, 97, 100, 32, 111, 102, 32, 116, 104,
-101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 111, 110, 101, 115, 46, 34, 32, 61, 32, 34, 67, 97, 100,
-97, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97,
-32, 112, 111, 100, 101, 32, 115, 101, 114, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 44, 32, 111, 117, 118,
-105, 114, 32, 115, 195, 179, 32, 117, 109, 32, 99, 97, 110, 97, 108, 32, 77, 73, 68, 73, 32, 101, 32, 116,
-111, 99, 97, 114, 32, 117, 109, 32, 99, 97, 110, 97, 108, 32, 102, 105, 120, 111, 32, 100, 111, 32, 67, 104,
-97, 110, 110, 101, 108, 32, 82, 97, 99, 107, 32, 101, 109, 32, 118, 101, 122, 32, 100, 111, 115, 32, 115, 101,
-108, 101, 99, 105, 111, 110, 97, 100, 111, 115, 46, 34, 10, 34, 78, 111, 32, 77, 73, 68, 73, 32, 105, 110,
-112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 115, 32, 102, 111, 117, 110, 100, 46, 32, 67, 111, 110, 110, 101,
-99, 116, 32, 111, 110, 101, 32, 97, 110, 100, 32, 114, 101, 102, 114, 101, 115, 104, 32, 116, 104, 101, 32, 108,
-105, 115, 116, 46, 34, 32, 61, 32, 34, 78, 101, 110, 104, 117, 109, 32, 100, 105, 115, 112, 111, 115, 105, 116,
-105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 77, 73, 68, 73, 32, 101, 110, 99, 111,
-110, 116, 114, 97, 100, 111, 46, 32, 67, 111, 110, 101, 99, 116, 101, 32, 117, 109, 32, 101, 32, 97, 116, 117,
-97, 108, 105, 122, 101, 32, 97, 32, 108, 105, 115, 116, 97, 46, 34, 10, 34, 65, 115, 32, 112, 108, 97, 121,
-101, 100, 34, 32, 61, 32, 34, 67, 111, 109, 111, 32, 116, 111, 99, 97, 100, 111, 34, 10, 34, 83, 111, 102,
-116, 32, 40, 108, 105, 103, 104, 116, 32, 112, 108, 97, 121, 105, 110, 103, 32, 115, 111, 117, 110, 100, 115, 32,
-108, 111, 117, 100, 101, 114, 41, 34, 32, 61, 32, 34, 83, 117, 97, 118, 101, 32, 40, 116, 111, 99, 97, 114,
-32, 108, 101, 118, 101, 32, 115, 111, 97, 32, 109, 97, 105, 115, 32, 102, 111, 114, 116, 101, 41, 34, 10, 34,
-72, 97, 114, 100, 32, 40, 110, 101, 101, 100, 115, 32, 104, 97, 114, 100, 101, 114, 32, 112, 108, 97, 121, 105,
-110, 103, 41, 34, 32, 61, 32, 34, 68, 117, 114, 111, 32, 40, 112, 101, 100, 101, 32, 116, 111, 113, 117, 101,
-32, 109, 97, 105, 115, 32, 102, 111, 114, 116, 101, 41, 34, 10, 34, 70, 105, 120, 101, 100, 32, 40, 101, 118,
-101, 114, 121, 32, 110, 111, 116, 101, 32, 97, 116, 32, 102, 117, 108, 108, 32, 118, 101, 108, 111, 99, 105, 116,
-121, 41, 34, 32, 61, 32, 34, 70, 105, 120, 111, 32, 40, 116, 111, 100, 97, 32, 110, 111, 116, 97, 32, 99,
-111, 109, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 32, 109, 195, 161, 120, 105, 109, 97, 41, 34, 10,
-34, 70, 111, 114, 32, 110, 111, 116, 101, 115, 32, 102, 114, 111, 109, 32, 77, 73, 68, 73, 32, 100, 101, 118,
-105, 99, 101, 115, 32, 40, 116, 104, 101, 32, 116, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114,
-100, 32, 97, 108, 119, 97, 121, 115, 32, 112, 108, 97, 121, 115, 32, 97, 116, 32, 116, 104, 101, 32, 80, 105,
-97, 110, 111, 32, 82, 111, 108, 108, 39, 115, 32, 118, 101, 108, 111, 99, 105, 116, 121, 41, 46, 34, 32, 61,
-32, 34, 80, 97, 114, 97, 32, 110, 111, 116, 97, 115, 32, 100, 101, 32, 100, 105, 115, 112, 111, 115, 105, 116,
-105, 118, 111, 115, 32, 77, 73, 68, 73, 32, 40, 111, 32, 116, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32,
-99, 111, 109, 112, 117, 116, 97, 100, 111, 114, 32, 115, 101, 109, 112, 114, 101, 32, 116, 111, 99, 97, 32, 99,
-111, 109, 32, 97, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 32, 100, 111, 32, 80, 105, 97, 110, 111,
-32, 82, 111, 108, 108, 41, 46, 34, 10, 34, 67, 111, 110, 116, 114, 111, 108, 108, 101, 114, 32, 116, 121, 112,
-101, 34, 32, 61, 32, 34, 84, 105, 112, 111, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 97, 100, 111,
-114, 34, 10, 34, 71, 101, 110, 101, 114, 105, 99, 32, 99, 111, 110, 116, 114, 111, 108, 108, 101, 114, 58, 32,
-108, 105, 110, 107, 32, 97, 32, 107, 110, 111, 98, 32, 111, 114, 32, 102, 97, 100, 101, 114, 32, 119, 105, 116,
-104, 32, 97, 32, 99, 111, 110, 116, 114, 111, 108, 39, 115, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99,
-107, 32, 109, 101, 110, 117, 32, 62, 32, 76, 105, 110, 107, 32, 116, 111, 32, 77, 73, 68, 73, 32, 99, 111,
-110, 116, 114, 111, 108, 108, 101, 114, 46, 34, 32, 61, 32, 34, 67, 111, 110, 116, 114, 111, 108, 97, 100, 111,
-114, 32, 103, 101, 110, 195, 169, 114, 105, 99, 111, 58, 32, 108, 105, 103, 117, 101, 32, 117, 109, 32, 107, 110,
-111, 98, 32, 111, 117, 32, 102, 97, 100, 101, 114, 32, 112, 101, 108, 111, 32, 109, 101, 110, 117, 32, 100, 101,
-32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 100, 101, 32, 117, 109, 32, 99, 111,
-110, 116, 114, 111, 108, 101, 32, 62, 32, 86, 105, 110, 99, 117, 108, 97, 114, 32, 97, 111, 32, 99, 111, 110,
-116, 114, 111, 108, 97, 100, 111, 114, 32, 77, 73, 68, 73, 46, 34, 10, 34, 80, 105, 99, 107, 117, 112, 32,
-40, 116, 97, 107, 101, 111, 118, 101, 114, 32, 109, 111, 100, 101, 41, 34, 32, 61, 32, 34, 67, 97, 112, 116,
-117, 114, 97, 32, 40, 109, 111, 100, 111, 32, 116, 97, 107, 101, 111, 118, 101, 114, 41, 34, 10, 34, 65, 32,
-99, 111, 110, 116, 114, 111, 108, 108, 101, 114, 32, 109, 111, 118, 101, 115, 32, 97, 32, 112, 97, 114, 97, 109,
-101, 116, 101, 114, 32, 111, 110, 108, 121, 32, 97, 102, 116, 101, 114, 32, 114, 101, 97, 99, 104, 105, 110, 103,
-32, 105, 116, 115, 32, 99, 117, 114, 114, 101, 110, 116, 32, 118, 97, 108, 117, 101, 44, 32, 115, 111, 32, 110,
-111, 116, 104, 105, 110, 103, 32, 106, 117, 109, 112, 115, 46, 34, 32, 61, 32, 34, 85, 109, 32, 99, 111, 110,
-116, 114, 111, 108, 97, 100, 111, 114, 32, 115, 195, 179, 32, 109, 111, 118, 101, 32, 117, 109, 32, 112, 97, 114,
-195, 162, 109, 101, 116, 114, 111, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 97, 108, 99, 97, 110, 195,
-167, 97, 114, 32, 111, 32, 118, 97, 108, 111, 114, 32, 97, 116, 117, 97, 108, 32, 100, 101, 108, 101, 44, 32,
-101, 110, 116, 195, 163, 111, 32, 110, 97, 100, 97, 32, 112, 117, 108, 97, 46, 34, 10, 34, 76, 105, 110, 107,
-115, 32, 105, 110, 32, 116, 104, 105, 115, 32, 112, 114, 111, 106, 101, 99, 116, 34, 32, 61, 32, 34, 86, 195,
-173, 110, 99, 117, 108, 111, 115, 32, 110, 101, 115, 116, 101, 32, 112, 114, 111, 106, 101, 116, 111, 34, 10, 34,
-99, 104, 46, 32, 123, 48, 125, 34, 32, 61, 32, 34, 99, 97, 110, 46, 32, 123, 48, 125, 34, 10, 34, 73,
-110, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 115, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105,
-116, 105, 118, 111, 115, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 34, 10, 34, 78, 111, 116, 101, 115,
-34, 32, 61, 32, 34, 78, 111, 116, 97, 115, 34, 10, 34, 67, 111, 110, 116, 114, 111, 108, 108, 101, 114, 115,
-34, 32, 61, 32, 34, 67, 111, 110, 116, 114, 111, 108, 97, 100, 111, 114, 101, 115, 34, 10, 34, 82, 101, 102,
-114, 101, 115, 104, 32, 100, 101, 118, 105, 99, 101, 32, 108, 105, 115, 116, 34, 32, 61, 32, 34, 65, 116, 117,
-97, 108, 105, 122, 97, 114, 32, 108, 105, 115, 116, 97, 32, 100, 101, 32, 100, 105, 115, 112, 111, 115, 105, 116,
-105, 118, 111, 115, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 108, 105, 110, 107, 34, 32, 61, 32, 34, 82,
-101, 109, 111, 118, 101, 114, 32, 118, 195, 173, 110, 99, 117, 108, 111, 34, 10, 34, 82, 101, 109, 111, 118, 101,
-32, 97, 108, 108, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 116, 111, 100, 111, 115, 34, 10,
-34, 69, 118, 101, 114, 121, 119, 104, 101, 114, 101, 34, 32, 61, 32, 34, 69, 109, 32, 116, 111, 100, 111, 32,
-108, 117, 103, 97, 114, 34, 10, 34, 80, 114, 101, 115, 115, 32, 116, 104, 101, 32, 110, 101, 119, 32, 107, 101,
-121, 115, 32, 110, 111, 119, 32, 40, 69, 115, 99, 32, 99, 97, 110, 99, 101, 108, 115, 41, 34, 32, 61, 32,
-34, 80, 114, 101, 115, 115, 105, 111, 110, 101, 32, 97, 115, 32, 110, 111, 118, 97, 115, 32, 116, 101, 99, 108,
-97, 115, 32, 97, 103, 111, 114, 97, 32, 40, 69, 115, 99, 32, 99, 97, 110, 99, 101, 108, 97, 41, 34, 10,
-34, 83, 101, 97, 114, 99, 104, 32, 97, 110, 32, 97, 99, 116, 105, 111, 110, 32, 111, 114, 32, 97, 32, 107,
-101, 121, 32, 40, 101, 46, 103, 46, 32, 92, 34, 67, 116, 114, 108, 43, 76, 92, 34, 41, 34, 32, 61, 32,
-34, 66, 117, 115, 99, 97, 114, 32, 117, 109, 97, 32, 97, 195, 167, 195, 163, 111, 32, 111, 117, 32, 116, 101,
-99, 108, 97, 32, 40, 101, 120, 46, 58, 32, 92, 34, 67, 116, 114, 108, 43, 76, 92, 34, 41, 34, 10, 34,
-65, 108, 108, 32, 112, 108, 97, 99, 101, 115, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32,
-108, 117, 103, 97, 114, 101, 115, 34, 10, 34, 67, 104, 97, 110, 103, 101, 100, 32, 111, 110, 108, 121, 34, 32,
-61, 32, 34, 83, 195, 179, 32, 97, 108, 116, 101, 114, 97, 100, 111, 115, 34, 10, 34, 40, 110, 111, 32, 115,
-104, 111, 114, 116, 99, 117, 116, 41, 34, 32, 61, 32, 34, 40, 115, 101, 109, 32, 97, 116, 97, 108, 104, 111,
-41, 34, 10, 34, 123, 48, 125, 32, 97, 99, 116, 105, 111, 110, 115, 34, 32, 61, 32, 34, 123, 48, 125, 32,
-97, 195, 167, 195, 181, 101, 115, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 97, 110, 32, 97, 99, 116, 105,
-111, 110, 32, 116, 111, 32, 99, 104, 97, 110, 103, 101, 32, 105, 116, 115, 32, 115, 104, 111, 114, 116, 99, 117,
-116, 34, 32, 61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 101, 32, 117, 109, 97, 32, 97, 195, 167, 195,
-163, 111, 32, 112, 97, 114, 97, 32, 97, 108, 116, 101, 114, 97, 114, 32, 111, 32, 97, 116, 97, 108, 104, 111,
-34, 10, 34, 87, 111, 114, 107, 115, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 70, 117, 110, 99, 105, 111,
-110, 97, 58, 32, 123, 48, 125, 34, 10, 34, 119, 105, 110, 115, 32, 111, 118, 101, 114, 32, 97, 32, 115, 104,
-111, 114, 116, 99, 117, 116, 32, 111, 102, 32, 116, 104, 101, 32, 115, 97, 109, 101, 32, 107, 101, 121, 115, 32,
-116, 104, 97, 116, 32, 119, 111, 114, 107, 115, 32, 101, 118, 101, 114, 121, 119, 104, 101, 114, 101, 34, 32, 61,
-32, 34, 118, 101, 110, 99, 101, 32, 117, 109, 32, 97, 116, 97, 108, 104, 111, 32, 99, 111, 109, 32, 97, 115,
-32, 109, 101, 115, 109, 97, 115, 32, 116, 101, 99, 108, 97, 115, 32, 113, 117, 101, 32, 102, 117, 110, 99, 105,
-111, 110, 97, 32, 101, 109, 32, 116, 111, 100, 111, 32, 108, 117, 103, 97, 114, 34, 10, 34, 123, 48, 125, 32,
-105, 115, 32, 117, 115, 101, 100, 32, 98, 121, 32, 123, 49, 125, 32, 105, 110, 32, 116, 104, 101, 32, 115, 97,
-109, 101, 32, 112, 108, 97, 99, 101, 46, 32, 65, 115, 115, 105, 103, 110, 32, 109, 111, 118, 101, 115, 32, 105,
-116, 32, 104, 101, 114, 101, 46, 34, 32, 61, 32, 34, 123, 48, 125, 32, 195, 169, 32, 117, 115, 97, 100, 111,
-32, 112, 111, 114, 32, 123, 49, 125, 32, 110, 111, 32, 109, 101, 115, 109, 111, 32, 108, 117, 103, 97, 114, 46,
-32, 65, 116, 114, 105, 98, 117, 105, 114, 32, 109, 111, 118, 101, 32, 112, 97, 114, 97, 32, 99, 195, 161, 46,
-34, 10, 34, 82, 101, 115, 101, 116, 32, 97, 108, 108, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 34, 32,
-61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116,
-97, 108, 104, 111, 115, 34, 10, 34, 69, 118, 101, 114, 121, 32, 115, 104, 111, 114, 116, 99, 117, 116, 32, 103,
-111, 101, 115, 32, 98, 97, 99, 107, 32, 116, 111, 32, 76, 89, 78, 88, 39, 115, 32, 100, 101, 102, 97, 117,
-108, 116, 32, 107, 101, 121, 115, 46, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116,
-97, 108, 104, 111, 115, 32, 118, 111, 108, 116, 97, 109, 32, 195, 160, 115, 32, 116, 101, 99, 108, 97, 115, 32,
-112, 97, 100, 114, 195, 163, 111, 32, 100, 111, 32, 76, 89, 78, 88, 46, 34, 10, 34, 82, 101, 115, 101, 116,
-32, 97, 108, 108, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 117, 100, 111, 34,
-10, 34, 65, 100, 100, 32, 115, 104, 111, 114, 116, 99, 117, 116, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105,
-111, 110, 97, 114, 32, 97, 116, 97, 108, 104, 111, 34, 10, 34, 67, 104, 97, 110, 103, 101, 34, 32, 61, 32,
-34, 65, 108, 116, 101, 114, 97, 114, 34, 10, 34, 82, 101, 115, 101, 116, 32, 97, 108, 108, 46, 46, 46, 34,
-32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 117, 100, 111, 46, 46, 46, 34, 10, 34,
-79, 112, 101, 110, 32, 107, 101, 121, 115, 46, 106, 115, 111, 110, 34, 32, 61, 32, 34, 65, 98, 114, 105, 114,
-32, 107, 101, 121, 115, 46, 106, 115, 111, 110, 34, 10, 34, 65, 115, 115, 105, 103, 110, 32, 97, 110, 121, 119,
-97, 121, 34, 32, 61, 32, 34, 65, 116, 114, 105, 98, 117, 105, 114, 32, 109, 101, 115, 109, 111, 32, 97, 115,
-115, 105, 109, 34, 10, 34, 77, 97, 110, 97, 103, 101, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 34, 32,
-61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 114, 32, 97, 116, 97, 108, 104, 111, 115, 34, 10, 34, 40,
-111, 112, 101, 110, 32, 97, 110, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 32, 102, 105,
-114, 115, 116, 41, 34, 32, 61, 32, 34, 40, 97, 98, 114, 97, 32, 117, 109, 32, 100, 105, 115, 112, 111, 115,
-105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 97, 110, 116, 101, 115, 41, 34, 10,
-34, 40, 99, 104, 111, 111, 115, 101, 41, 34, 32, 61, 32, 34, 40, 101, 115, 99, 111, 108, 104, 97, 41, 34,
-10,
+34, 10, 10, 35, 32, 45, 45, 45, 32, 80, 105, 97, 110, 111, 32, 82, 111, 108, 108, 32, 116, 111, 111, 108,
+115, 32, 40, 114, 111, 117, 110, 100, 32, 56, 51, 41, 10, 34, 81, 117, 97, 110, 116, 105, 122, 101, 34, 32,
+61, 32, 34, 81, 117, 97, 110, 116, 105, 122, 97, 114, 34, 10, 34, 67, 104, 111, 112, 34, 32, 61, 32, 34,
+80, 105, 99, 111, 116, 97, 114, 34, 10, 34, 76, 70, 79, 34, 32, 61, 32, 34, 76, 70, 79, 34, 10, 34,
+67, 108, 97, 119, 32, 109, 97, 99, 104, 105, 110, 101, 34, 32, 61, 32, 34, 67, 108, 97, 119, 32, 109, 97,
+99, 104, 105, 110, 101, 34, 10, 34, 65, 114, 116, 105, 99, 117, 108, 97, 116, 101, 34, 32, 61, 32, 34, 65,
+114, 116, 105, 99, 117, 108, 97, 114, 34, 10, 34, 82, 105, 102, 102, 32, 109, 97, 99, 104, 105, 110, 101, 34,
+32, 61, 32, 34, 82, 105, 102, 102, 32, 109, 97, 99, 104, 105, 110, 101, 34, 10, 34, 67, 104, 111, 114, 100,
+32, 112, 114, 111, 103, 114, 101, 115, 115, 105, 111, 110, 34, 32, 61, 32, 34, 80, 114, 111, 103, 114, 101, 115,
+115, 195, 163, 111, 32, 100, 101, 32, 97, 99, 111, 114, 100, 101, 115, 34, 10, 34, 84, 104, 114, 111, 119, 32,
+100, 105, 99, 101, 34, 32, 61, 32, 34, 74, 111, 103, 97, 114, 32, 111, 115, 32, 100, 97, 100, 111, 115, 34,
+10, 34, 71, 101, 110, 101, 114, 97, 116, 101, 34, 32, 61, 32, 34, 71, 101, 114, 97, 114, 34, 10, 34, 76,
+101, 118, 101, 108, 32, 115, 116, 114, 101, 110, 103, 116, 104, 115, 34, 32, 61, 32, 34, 70, 111, 114, 195, 167,
+97, 32, 110, 111, 115, 32, 110, 195, 173, 118, 101, 105, 115, 34, 10, 34, 84, 101, 109, 112, 108, 97, 116, 101,
+34, 32, 61, 32, 34, 77, 111, 100, 101, 108, 111, 34, 10, 34, 80, 105, 97, 110, 111, 32, 114, 111, 108, 108,
+32, 103, 114, 105, 100, 34, 32, 61, 32, 34, 71, 114, 97, 100, 101, 32, 100, 111, 32, 80, 105, 97, 110, 111,
+32, 82, 111, 108, 108, 34, 10, 34, 71, 114, 105, 100, 32, 115, 119, 105, 110, 103, 34, 32, 61, 32, 34, 83,
+119, 105, 110, 103, 32, 100, 97, 32, 103, 114, 97, 100, 101, 34, 10, 34, 83, 116, 97, 114, 116, 32, 116, 105,
+109, 101, 34, 32, 61, 32, 34, 73, 110, 195, 173, 99, 105, 111, 34, 10, 34, 68, 117, 114, 97, 116, 105, 111,
+110, 34, 32, 61, 32, 34, 68, 117, 114, 97, 195, 167, 195, 163, 111, 34, 10, 34, 76, 101, 97, 118, 101, 32,
+100, 117, 114, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 77, 97, 110, 116, 101, 114, 32, 97, 32, 100, 117,
+114, 97, 195, 167, 195, 163, 111, 34, 10, 34, 76, 101, 97, 118, 101, 32, 101, 110, 100, 32, 116, 105, 109, 101,
+34, 32, 61, 32, 34, 77, 97, 110, 116, 101, 114, 32, 111, 32, 102, 105, 109, 34, 10, 34, 81, 117, 97, 110,
+116, 105, 122, 101, 32, 100, 117, 114, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 81, 117, 97, 110, 116, 105,
+122, 97, 114, 32, 97, 32, 100, 117, 114, 97, 195, 167, 195, 163, 111, 34, 10, 34, 81, 117, 97, 110, 116, 105,
+122, 101, 32, 101, 110, 100, 32, 116, 105, 109, 101, 34, 32, 61, 32, 34, 81, 117, 97, 110, 116, 105, 122, 97,
+114, 32, 111, 32, 102, 105, 109, 34, 10, 34, 68, 117, 114, 97, 116, 105, 111, 110, 32, 115, 116, 114, 101, 110,
+103, 116, 104, 34, 32, 61, 32, 34, 70, 111, 114, 195, 167, 97, 32, 110, 97, 32, 100, 117, 114, 97, 195, 167,
+195, 163, 111, 34, 10, 34, 83, 101, 110, 115, 105, 116, 105, 118, 105, 116, 121, 34, 32, 61, 32, 34, 83, 101,
+110, 115, 105, 98, 105, 108, 105, 100, 97, 100, 101, 34, 10, 34, 84, 105, 109, 101, 34, 32, 61, 32, 34, 84,
+101, 109, 112, 111, 34, 10, 34, 75, 101, 101, 112, 32, 111, 110, 32, 116, 104, 101, 32, 115, 111, 110, 103, 32,
+103, 114, 105, 100, 34, 32, 61, 32, 34, 77, 97, 110, 116, 101, 114, 32, 110, 97, 32, 103, 114, 97, 100, 101,
+32, 100, 97, 32, 109, 195, 186, 115, 105, 99, 97, 34, 10, 34, 67, 117, 115, 116, 111, 109, 34, 32, 61, 32,
+34, 80, 101, 114, 115, 111, 110, 97, 108, 105, 122, 97, 100, 111, 34, 10, 34, 70, 108, 97, 109, 34, 32, 61,
+32, 34, 70, 108, 97, 109, 34, 10, 34, 69, 97, 114, 108, 121, 32, 102, 108, 97, 109, 34, 32, 61, 32, 34,
+70, 108, 97, 109, 32, 97, 110, 116, 101, 99, 105, 112, 97, 100, 111, 34, 10, 34, 68, 111, 117, 98, 108, 101,
+32, 115, 116, 114, 111, 107, 101, 34, 32, 61, 32, 34, 84, 111, 113, 117, 101, 32, 100, 117, 112, 108, 111, 34,
+10, 34, 69, 97, 114, 108, 121, 32, 100, 111, 117, 98, 108, 101, 32, 115, 116, 114, 111, 107, 101, 34, 32, 61,
+32, 34, 84, 111, 113, 117, 101, 32, 100, 117, 112, 108, 111, 32, 97, 110, 116, 101, 99, 105, 112, 97, 100, 111,
+34, 10, 34, 84, 105, 109, 101, 32, 105, 110, 32, 109, 105, 108, 108, 105, 115, 101, 99, 111, 110, 100, 115, 34,
+32, 61, 32, 34, 84, 101, 109, 112, 111, 32, 101, 109, 32, 109, 105, 108, 105, 115, 115, 101, 103, 117, 110, 100,
+111, 115, 34, 10, 34, 66, 101, 102, 111, 114, 101, 32, 116, 104, 101, 32, 110, 111, 116, 101, 34, 32, 61, 32,
+34, 65, 110, 116, 101, 115, 32, 100, 97, 32, 110, 111, 116, 97, 34, 10, 34, 80, 104, 97, 115, 101, 34, 32,
+61, 32, 34, 70, 97, 115, 101, 34, 10, 34, 86, 97, 108, 117, 101, 34, 32, 61, 32, 34, 86, 97, 108, 111,
+114, 34, 10, 34, 67, 104, 97, 110, 103, 101, 32, 116, 111, 119, 97, 114, 100, 32, 116, 104, 101, 32, 101, 110,
+100, 34, 32, 61, 32, 34, 77, 117, 100, 97, 114, 32, 97, 116, 195, 169, 32, 111, 32, 102, 105, 109, 34, 10,
+34, 76, 111, 103, 97, 114, 105, 116, 104, 109, 105, 99, 32, 115, 112, 101, 101, 100, 32, 99, 104, 97, 110, 103,
+101, 34, 32, 61, 32, 34, 77, 117, 100, 97, 110, 195, 167, 97, 32, 100, 101, 32, 118, 101, 108, 111, 99, 105,
+100, 97, 100, 101, 32, 108, 111, 103, 97, 114, 195, 173, 116, 109, 105, 99, 97, 34, 10, 34, 49, 32, 98, 101,
+97, 116, 34, 32, 61, 32, 34, 49, 32, 116, 101, 109, 112, 111, 34, 10, 34, 52, 32, 98, 101, 97, 116, 115,
+34, 32, 61, 32, 34, 52, 32, 116, 101, 109, 112, 111, 115, 34, 10, 34, 56, 32, 98, 101, 97, 116, 115, 34,
+32, 61, 32, 34, 56, 32, 116, 101, 109, 112, 111, 115, 34, 10, 34, 49, 54, 32, 98, 101, 97, 116, 115, 34,
+32, 61, 32, 34, 49, 54, 32, 116, 101, 109, 112, 111, 115, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 101,
+118, 101, 114, 121, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 97, 32, 99, 97, 100, 97, 34,
+10, 34, 84, 105, 109, 101, 32, 100, 105, 115, 116, 111, 114, 116, 105, 111, 110, 34, 32, 61, 32, 34, 68, 105,
+115, 116, 111, 114, 195, 167, 195, 163, 111, 32, 100, 111, 32, 116, 101, 109, 112, 111, 34, 10, 34, 83, 116, 114,
+101, 116, 99, 104, 32, 116, 111, 32, 99, 111, 109, 112, 101, 110, 115, 97, 116, 101, 34, 32, 61, 32, 34, 69,
+115, 116, 105, 99, 97, 114, 32, 112, 97, 114, 97, 32, 99, 111, 109, 112, 101, 110, 115, 97, 114, 34, 10, 34,
+82, 101, 109, 111, 118, 101, 32, 115, 104, 111, 114, 116, 32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 82,
+101, 109, 111, 118, 101, 114, 32, 110, 111, 116, 97, 115, 32, 99, 117, 114, 116, 97, 115, 34, 10, 34, 76, 101,
+103, 97, 116, 111, 34, 32, 61, 32, 34, 76, 101, 103, 97, 116, 111, 34, 10, 34, 80, 111, 114, 116, 97, 116,
+111, 34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 116, 111, 34, 10, 34, 83, 116, 97, 99, 99, 97, 116, 111,
+34, 32, 61, 32, 34, 83, 116, 97, 99, 99, 97, 116, 111, 34, 10, 34, 83, 109, 97, 108, 108, 32, 103, 97,
+112, 115, 34, 32, 61, 32, 34, 80, 101, 113, 117, 101, 110, 111, 115, 32, 101, 115, 112, 97, 195, 167, 111, 115,
+34, 10, 34, 79, 110, 108, 121, 32, 99, 104, 111, 112, 32, 99, 104, 111, 114, 100, 115, 34, 32, 61, 32, 34,
+83, 195, 179, 32, 112, 105, 99, 111, 116, 97, 114, 32, 97, 99, 111, 114, 100, 101, 115, 34, 10, 34, 86, 97,
+114, 105, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 86, 97, 114, 105, 97, 195, 167, 195, 163, 111, 34, 10,
+34, 71, 97, 112, 34, 32, 61, 32, 34, 69, 115, 112, 97, 195, 167, 111, 34, 10, 34, 86, 97, 114, 105, 97,
+116, 105, 111, 110, 32, 115, 101, 101, 100, 34, 32, 61, 32, 34, 83, 101, 109, 101, 110, 116, 101, 32, 100, 97,
+32, 118, 97, 114, 105, 97, 195, 167, 195, 163, 111, 34, 10, 34, 83, 99, 97, 108, 101, 32, 116, 104, 101, 32,
+110, 111, 116, 101, 115, 39, 32, 111, 119, 110, 32, 108, 101, 110, 103, 116, 104, 115, 34, 32, 61, 32, 34, 85,
+115, 97, 114, 32, 97, 32, 100, 117, 114, 97, 195, 167, 195, 163, 111, 32, 100, 97, 115, 32, 112, 114, 195, 179,
+112, 114, 105, 97, 115, 32, 110, 111, 116, 97, 115, 34, 10, 34, 67, 104, 111, 112, 32, 99, 104, 111, 114, 100,
+115, 34, 32, 61, 32, 34, 80, 105, 99, 111, 116, 97, 114, 32, 97, 99, 111, 114, 100, 101, 115, 34, 10, 34,
+66, 117, 105, 108, 116, 45, 105, 110, 34, 32, 61, 32, 34, 69, 109, 98, 117, 116, 105, 100, 111, 34, 10, 34,
+98, 97, 114, 115, 34, 32, 61, 32, 34, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 87, 111, 114,
+107, 32, 111, 110, 32, 116, 104, 101, 32, 101, 120, 105, 115, 116, 105, 110, 103, 32, 110, 111, 116, 101, 115, 34,
+32, 61, 32, 34, 84, 114, 97, 98, 97, 108, 104, 97, 114, 32, 115, 111, 98, 114, 101, 32, 97, 115, 32, 110,
+111, 116, 97, 115, 32, 101, 120, 105, 115, 116, 101, 110, 116, 101, 115, 34, 10, 34, 49, 46, 32, 80, 114, 111,
+103, 114, 101, 115, 115, 105, 111, 110, 34, 32, 61, 32, 34, 49, 46, 32, 80, 114, 111, 103, 114, 101, 115, 115,
+195, 163, 111, 34, 10, 34, 82, 104, 121, 116, 104, 109, 32, 97, 110, 100, 32, 109, 101, 108, 111, 100, 121, 34,
+32, 61, 32, 34, 82, 105, 116, 109, 111, 32, 101, 32, 109, 101, 108, 111, 100, 105, 97, 34, 10, 34, 50, 46,
+32, 67, 104, 111, 114, 100, 115, 34, 32, 61, 32, 34, 50, 46, 32, 65, 99, 111, 114, 100, 101, 115, 34, 10,
+34, 67, 104, 111, 114, 100, 32, 115, 104, 97, 112, 101, 34, 32, 61, 32, 34, 70, 111, 114, 109, 97, 32, 100,
+111, 32, 97, 99, 111, 114, 100, 101, 34, 10, 34, 51, 46, 32, 65, 114, 112, 101, 103, 103, 105, 111, 34, 32,
+61, 32, 34, 51, 46, 32, 65, 114, 112, 101, 106, 111, 34, 10, 34, 52, 46, 32, 72, 117, 109, 97, 110, 105,
+122, 101, 32, 108, 101, 118, 101, 108, 115, 34, 32, 61, 32, 34, 52, 46, 32, 72, 117, 109, 97, 110, 105, 122,
+97, 114, 32, 110, 195, 173, 118, 101, 105, 115, 34, 10, 34, 53, 46, 32, 77, 105, 114, 114, 111, 114, 34, 32,
+61, 32, 34, 53, 46, 32, 69, 115, 112, 101, 108, 104, 97, 114, 34, 10, 34, 54, 46, 32, 65, 114, 116, 105,
+99, 117, 108, 97, 116, 105, 111, 110, 34, 32, 61, 32, 34, 54, 46, 32, 65, 114, 116, 105, 99, 117, 108, 97,
+195, 167, 195, 163, 111, 34, 10, 34, 55, 46, 32, 71, 114, 111, 111, 118, 101, 34, 32, 61, 32, 34, 55, 46,
+32, 71, 114, 111, 111, 118, 101, 34, 10, 34, 56, 46, 32, 70, 105, 116, 32, 116, 111, 32, 116, 104, 101, 32,
+115, 99, 97, 108, 101, 34, 32, 61, 32, 34, 56, 46, 32, 69, 110, 99, 97, 105, 120, 97, 114, 32, 110, 97,
+32, 101, 115, 99, 97, 108, 97, 34, 10, 34, 75, 101, 121, 34, 32, 61, 32, 34, 84, 111, 109, 34, 10, 34,
+83, 99, 97, 108, 101, 34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 34, 10, 34, 40, 116, 121, 112, 101,
+100, 32, 111, 114, 32, 103, 101, 110, 101, 114, 97, 116, 101, 100, 41, 34, 32, 61, 32, 34, 40, 100, 105, 103,
+105, 116, 97, 100, 97, 32, 111, 117, 32, 103, 101, 114, 97, 100, 97, 41, 34, 10, 34, 109, 105, 110, 111, 114,
+34, 32, 61, 32, 34, 109, 101, 110, 111, 114, 34, 10, 34, 72, 101, 108, 100, 32, 99, 104, 111, 114, 100, 115,
+34, 32, 61, 32, 34, 65, 99, 111, 114, 100, 101, 115, 32, 115, 117, 115, 116, 101, 110, 116, 97, 100, 111, 115,
+34, 10, 34, 80, 114, 111, 103, 114, 101, 115, 115, 105, 111, 110, 34, 32, 61, 32, 34, 80, 114, 111, 103, 114,
+101, 115, 115, 195, 163, 111, 34, 10, 34, 67, 104, 111, 114, 100, 115, 32, 116, 111, 32, 103, 101, 110, 101, 114,
+97, 116, 101, 34, 32, 61, 32, 34, 65, 99, 111, 114, 100, 101, 115, 32, 97, 32, 103, 101, 114, 97, 114, 34,
+10, 34, 65, 100, 118, 101, 110, 116, 117, 114, 111, 117, 115, 34, 32, 61, 32, 34, 79, 117, 115, 97, 100, 105,
+97, 34, 10, 34, 67, 104, 111, 114, 100, 32, 108, 101, 110, 103, 116, 104, 34, 32, 61, 32, 34, 68, 117, 114,
+97, 195, 167, 195, 163, 111, 32, 100, 111, 32, 97, 99, 111, 114, 100, 101, 34, 10, 34, 50, 32, 98, 97, 114,
+115, 34, 32, 61, 32, 34, 50, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 82, 104, 121, 116,
+104, 109, 34, 32, 61, 32, 34, 82, 105, 116, 109, 111, 34, 10, 34, 66, 97, 115, 115, 32, 110, 111, 116, 101,
+34, 32, 61, 32, 34, 78, 111, 116, 97, 32, 110, 111, 32, 98, 97, 105, 120, 111, 34, 10, 34, 83, 109, 111,
+111, 116, 104, 32, 118, 111, 105, 99, 105, 110, 103, 34, 32, 61, 32, 34, 86, 111, 105, 99, 105, 110, 103, 32,
+115, 117, 97, 118, 101, 34, 10, 34, 84, 104, 105, 115, 32, 116, 101, 109, 112, 108, 97, 116, 101, 32, 99, 111,
+117, 108, 100, 32, 110, 111, 116, 32, 98, 101, 32, 114, 101, 97, 100, 46, 34, 32, 61, 32, 34, 78, 195, 163,
+111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 108, 101, 114, 32, 101, 115, 116, 101,
+32, 109, 111, 100, 101, 108, 111, 46, 34, 10, 34, 84, 104, 105, 115, 32, 112, 97, 116, 116, 101, 114, 110, 32,
+99, 111, 117, 108, 100, 32, 110, 111, 116, 32, 98, 101, 32, 114, 101, 97, 100, 46, 34, 32, 61, 32, 34, 78,
+195, 163, 111, 32, 102, 111, 105, 32, 112, 111, 115, 115, 195, 173, 118, 101, 108, 32, 108, 101, 114, 32, 101, 115,
+116, 101, 32, 112, 97, 100, 114, 195, 163, 111, 46, 34, 10, 34, 84, 121, 112, 101, 32, 99, 104, 111, 114, 100,
+115, 32, 97, 115, 32, 82, 111, 109, 97, 110, 32, 110, 117, 109, 101, 114, 97, 108, 115, 44, 32, 101, 46, 103,
+46, 32, 73, 45, 86, 45, 118, 105, 45, 73, 86, 32, 111, 114, 32, 105, 105, 55, 32, 86, 55, 32, 73, 109,
+97, 106, 55, 46, 34, 32, 61, 32, 34, 68, 105, 103, 105, 116, 101, 32, 111, 115, 32, 97, 99, 111, 114, 100,
+101, 115, 32, 101, 109, 32, 97, 108, 103, 97, 114, 105, 115, 109, 111, 115, 32, 114, 111, 109, 97, 110, 111, 115,
+44, 32, 112, 111, 114, 32, 101, 120, 101, 109, 112, 108, 111, 32, 73, 45, 86, 45, 118, 105, 45, 73, 86, 32,
+111, 117, 32, 105, 105, 55, 32, 86, 55, 32, 73, 109, 97, 106, 55, 46, 34, 10, 34, 87, 114, 105, 116, 101,
+115, 32, 110, 101, 119, 32, 110, 111, 116, 101, 115, 32, 111, 110, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99,
+116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 46, 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, 69, 115, 99, 114, 101, 118, 101, 32, 110, 111, 116, 97, 115, 32, 110, 111, 118, 97, 115,
+32, 110, 111, 32, 99, 97, 110, 97, 108, 32, 115, 101, 108, 101, 99, 105, 111, 110, 97, 100, 111, 46, 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, 82,
+101, 112, 108, 97, 99, 101, 115, 32, 123, 48, 125, 32, 110, 111, 116, 101, 115, 32, 111, 102, 32, 116, 104, 101,
+32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 46, 32, 65, 99, 99, 101, 112,
+116, 32, 107, 101, 101, 112, 115, 32, 116, 104, 101, 32, 114, 101, 115, 117, 108, 116, 32, 97, 115, 32, 111, 110,
+101, 32, 117, 110, 100, 111, 32, 115, 116, 101, 112, 46, 34, 32, 61, 32, 34, 83, 117, 98, 115, 116, 105, 116,
+117, 105, 32, 123, 48, 125, 32, 110, 111, 116, 97, 115, 32, 100, 111, 32, 99, 97, 110, 97, 108, 32, 115, 101,
+108, 101, 99, 105, 111, 110, 97, 100, 111, 46, 32, 65, 99, 101, 105, 116, 97, 114, 32, 109, 97, 110, 116, 195,
+169, 109, 32, 111, 32, 114, 101, 115, 117, 108, 116, 97, 100, 111, 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, 67, 108, 105, 109,
+98, 34, 32, 61, 32, 34, 83, 117, 98, 105, 100, 97, 34, 10, 34, 71, 97, 108, 108, 111, 112, 34, 32, 61,
+32, 34, 71, 97, 108, 111, 112, 101, 34, 10, 34, 76, 111, 110, 103, 34, 32, 61, 32, 34, 76, 111, 110, 103,
+111, 34, 10, 34, 83, 121, 110, 99, 111, 112, 97, 116, 101, 100, 34, 32, 61, 32, 34, 83, 105, 110, 99, 111,
+112, 97, 100, 111, 34, 10, 34, 83, 105, 110, 103, 108, 101, 34, 32, 61, 32, 34, 78, 111, 116, 97, 32, 195,
+186, 110, 105, 99, 97, 34, 10, 34, 70, 105, 102, 116, 104, 34, 32, 61, 32, 34, 81, 117, 105, 110, 116, 97,
+34, 10, 34, 77, 105, 110, 111, 114, 32, 116, 114, 105, 97, 100, 34, 32, 61, 32, 34, 84, 114, 195, 173, 97,
+100, 101, 32, 109, 101, 110, 111, 114, 34, 10, 34, 77, 97, 106, 111, 114, 32, 116, 114, 105, 97, 100, 34, 32,
+61, 32, 34, 84, 114, 195, 173, 97, 100, 101, 32, 109, 97, 105, 111, 114, 34, 10, 34, 77, 105, 110, 111, 114,
+32, 55, 116, 104, 34, 32, 61, 32, 34, 77, 101, 110, 111, 114, 32, 99, 111, 109, 32, 115, 195, 169, 116, 105,
+109, 97, 34, 10, 34, 67, 104, 111, 114, 100, 115, 34, 32, 61, 32, 34, 65, 99, 111, 114, 100, 101, 115, 34,
+10, 34, 69, 100, 105, 116, 32, 101, 118, 101, 110, 116, 115, 32, 105, 110, 32, 116, 104, 101, 32, 112, 97, 116,
+116, 101, 114, 110, 34, 32, 61, 32, 34, 69, 100, 105, 116, 97, 114, 32, 101, 118, 101, 110, 116, 111, 115, 32,
+110, 111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10, 34, 69, 100, 105, 116, 32, 101, 118, 101, 110, 116, 115,
+46, 46, 46, 34, 32, 61, 32, 34, 69, 100, 105, 116, 97, 114, 32, 101, 118, 101, 110, 116, 111, 115, 46, 46,
+46, 34, 10, 34, 69, 118, 101, 110, 116, 32, 101, 100, 105, 116, 111, 114, 34, 32, 61, 32, 34, 69, 100, 105,
+116, 111, 114, 32, 100, 101, 32, 101, 118, 101, 110, 116, 111, 115, 34, 10, 34, 69, 118, 101, 110, 116, 115, 32,
+45, 32, 123, 48, 125, 34, 32, 61, 32, 34, 69, 118, 101, 110, 116, 111, 115, 32, 45, 32, 123, 48, 125, 34,
+10, 34, 68, 114, 97, 119, 34, 32, 61, 32, 34, 68, 101, 115, 101, 110, 104, 97, 114, 34, 10, 34, 76, 105,
+110, 101, 34, 32, 61, 32, 34, 76, 105, 110, 104, 97, 34, 10, 34, 83, 101, 108, 101, 99, 116, 34, 32, 61,
+32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 97, 114, 34, 10, 34, 68, 114, 97, 119, 58, 32, 100, 114, 97,
+103, 32, 116, 111, 32, 115, 101, 116, 32, 116, 104, 101, 32, 118, 97, 108, 117, 101, 115, 59, 32, 114, 105, 103,
+104, 116, 45, 100, 114, 97, 103, 32, 101, 114, 97, 115, 101, 115, 34, 32, 61, 32, 34, 68, 101, 115, 101, 110,
+104, 97, 114, 58, 32, 97, 114, 114, 97, 115, 116, 101, 32, 112, 97, 114, 97, 32, 100, 101, 102, 105, 110, 105,
+114, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 59, 32, 97, 114, 114, 97, 115, 116, 97, 114, 32, 99,
+111, 109, 32, 111, 32, 98, 111, 116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 97, 112, 97, 103,
+97, 34, 10, 34, 76, 105, 110, 101, 58, 32, 100, 114, 97, 103, 32, 97, 32, 115, 116, 114, 97, 105, 103, 104,
+116, 32, 114, 97, 109, 112, 34, 32, 61, 32, 34, 76, 105, 110, 104, 97, 58, 32, 97, 114, 114, 97, 115, 116,
+101, 32, 117, 109, 97, 32, 114, 97, 109, 112, 97, 32, 114, 101, 116, 97, 34, 10, 34, 83, 101, 108, 101, 99,
+116, 58, 32, 100, 114, 97, 103, 32, 97, 32, 116, 105, 109, 101, 32, 114, 97, 110, 103, 101, 32, 102, 111, 114,
+32, 116, 104, 101, 32, 116, 111, 111, 108, 115, 32, 98, 101, 108, 111, 119, 34, 32, 61, 32, 34, 83, 101, 108,
+101, 99, 105, 111, 110, 97, 114, 58, 32, 97, 114, 114, 97, 115, 116, 101, 32, 117, 109, 32, 116, 114, 101, 99,
+104, 111, 32, 100, 101, 32, 116, 101, 109, 112, 111, 32, 112, 97, 114, 97, 32, 97, 115, 32, 102, 101, 114, 114,
+97, 109, 101, 110, 116, 97, 115, 32, 97, 98, 97, 105, 120, 111, 34, 10, 34, 49, 32, 115, 116, 101, 112, 34,
+32, 61, 32, 34, 49, 32, 115, 116, 101, 112, 34, 10, 34, 52, 32, 98, 97, 114, 115, 34, 32, 61, 32, 34,
+52, 32, 99, 111, 109, 112, 97, 115, 115, 111, 115, 34, 10, 34, 67, 108, 101, 97, 114, 34, 32, 61, 32, 34,
+76, 105, 109, 112, 97, 114, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 116, 104, 101, 32, 101, 118, 101, 110,
+116, 115, 32, 111, 102, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 105, 111, 110, 32, 40, 111, 114, 32,
+111, 102, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 112, 97, 116, 116, 101, 114, 110, 41, 34, 32, 61,
+32, 34, 82, 101, 109, 111, 118, 101, 32, 111, 115, 32, 101, 118, 101, 110, 116, 111, 115, 32, 100, 97, 32, 115,
+101, 108, 101, 195, 167, 195, 163, 111, 32, 40, 111, 117, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 32,
+105, 110, 116, 101, 105, 114, 111, 41, 34, 10, 34, 78, 111, 32, 101, 118, 101, 110, 116, 115, 32, 121, 101, 116,
+32, 102, 111, 114, 32, 123, 48, 125, 46, 32, 68, 114, 97, 119, 32, 116, 111, 32, 97, 100, 100, 32, 116, 104,
+101, 109, 59, 32, 116, 104, 101, 121, 32, 112, 108, 97, 121, 32, 119, 105, 116, 104, 32, 116, 104, 101, 32, 112,
+97, 116, 116, 101, 114, 110, 46, 34, 32, 61, 32, 34, 65, 105, 110, 100, 97, 32, 110, 195, 163, 111, 32, 104,
+195, 161, 32, 101, 118, 101, 110, 116, 111, 115, 32, 112, 97, 114, 97, 32, 123, 48, 125, 46, 32, 68, 101, 115,
+101, 110, 104, 101, 32, 112, 97, 114, 97, 32, 97, 100, 105, 99, 105, 111, 110, 195, 161, 45, 108, 111, 115, 59,
+32, 101, 108, 101, 115, 32, 116, 111, 99, 97, 109, 32, 99, 111, 109, 32, 111, 32, 112, 97, 116, 116, 101, 114,
+110, 46, 34, 10, 34, 69, 100, 105, 116, 32, 101, 118, 101, 110, 116, 115, 58, 32, 123, 48, 125, 34, 32, 61,
+32, 34, 69, 100, 105, 116, 97, 114, 32, 101, 118, 101, 110, 116, 111, 115, 58, 32, 123, 48, 125, 34, 10, 34,
+77, 73, 68, 73, 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, 101, 32, 77, 73, 68, 73, 46, 46, 46, 34,
+10, 34, 71, 101, 110, 101, 114, 97, 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, 103, 101, 114, 97, 105, 115,
+46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 109, 97, 110, 97, 103, 101, 114, 46, 46, 46, 34,
+32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 100, 111, 114, 32, 100, 101, 32, 112, 108, 117, 103, 105,
+110, 115, 46, 46, 46, 34, 10, 34, 77, 97, 110, 97, 103, 101, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115,
+46, 46, 46, 34, 32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 114, 32, 97, 116, 97, 108, 104, 111,
+115, 46, 46, 46, 34, 10, 34, 70, 97, 105, 108, 101, 100, 32, 116, 111, 32, 108, 111, 97, 100, 34, 32, 61,
+32, 34, 70, 97, 108, 104, 111, 117, 32, 97, 111, 32, 99, 97, 114, 114, 101, 103, 97, 114, 34, 10, 34, 70,
+105, 108, 101, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 34, 32, 61, 32, 34, 65, 114, 113, 117, 105, 118,
+111, 32, 110, 195, 163, 111, 32, 101, 110, 99, 111, 110, 116, 114, 97, 100, 111, 34, 10, 34, 83, 101, 97, 114,
+99, 104, 32, 110, 97, 109, 101, 44, 32, 118, 101, 110, 100, 111, 114, 44, 32, 102, 111, 114, 109, 97, 116, 32,
+111, 114, 32, 102, 105, 108, 101, 34, 32, 61, 32, 34, 66, 117, 115, 99, 97, 114, 32, 110, 111, 109, 101, 44,
+32, 102, 97, 98, 114, 105, 99, 97, 110, 116, 101, 44, 32, 102, 111, 114, 109, 97, 116, 111, 32, 111, 117, 32,
+97, 114, 113, 117, 105, 118, 111, 34, 10, 34, 65, 108, 108, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 34,
+10, 34, 73, 110, 115, 116, 114, 117, 109, 101, 110, 116, 115, 34, 32, 61, 32, 34, 73, 110, 115, 116, 114, 117,
+109, 101, 110, 116, 111, 115, 34, 10, 34, 69, 102, 102, 101, 99, 116, 115, 34, 32, 61, 32, 34, 69, 102, 101,
+105, 116, 111, 115, 34, 10, 34, 70, 97, 118, 111, 117, 114, 105, 116, 101, 115, 34, 32, 61, 32, 34, 70, 97,
+118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 70, 97, 105, 108, 101, 100, 34, 32, 61, 32, 34, 67, 111, 109,
+32, 102, 97, 108, 104, 97, 34, 10, 34, 86, 101, 110, 100, 111, 114, 34, 32, 61, 32, 34, 70, 97, 98, 114,
+105, 99, 97, 110, 116, 101, 34, 10, 34, 84, 121, 112, 101, 34, 32, 61, 32, 34, 84, 105, 112, 111, 34, 10,
+34, 83, 116, 97, 116, 117, 115, 34, 32, 61, 32, 34, 69, 115, 116, 97, 100, 111, 34, 10, 34, 123, 48, 125,
+32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 115, 44, 32, 123, 49, 125, 32, 101, 102, 102, 101, 99, 116,
+115, 44, 32, 123, 50, 125, 32, 119, 105, 116, 104, 32, 112, 114, 111, 98, 108, 101, 109, 115, 34, 32, 61, 32,
+34, 123, 48, 125, 32, 105, 110, 115, 116, 114, 117, 109, 101, 110, 116, 111, 115, 44, 32, 123, 49, 125, 32, 101,
+102, 101, 105, 116, 111, 115, 44, 32, 123, 50, 125, 32, 99, 111, 109, 32, 112, 114, 111, 98, 108, 101, 109, 97,
+115, 34, 10, 34, 69, 102, 102, 101, 99, 116, 34, 32, 61, 32, 34, 69, 102, 101, 105, 116, 111, 34, 10, 34,
+70, 97, 118, 111, 117, 114, 105, 116, 101, 58, 32, 108, 105, 115, 116, 101, 100, 32, 102, 105, 114, 115, 116, 32,
+119, 104, 101, 110, 32, 97, 100, 100, 105, 110, 103, 32, 97, 32, 112, 108, 117, 103, 105, 110, 34, 32, 61, 32,
+34, 70, 97, 118, 111, 114, 105, 116, 111, 58, 32, 97, 112, 97, 114, 101, 99, 101, 32, 112, 114, 105, 109, 101,
+105, 114, 111, 32, 97, 111, 32, 97, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 112, 108, 117, 103,
+105, 110, 34, 10, 34, 84, 104, 101, 32, 115, 99, 97, 110, 32, 99, 111, 117, 108, 100, 110, 39, 116, 32, 108,
+111, 97, 100, 32, 116, 104, 105, 115, 32, 102, 105, 108, 101, 32, 40, 105, 116, 32, 99, 114, 97, 115, 104, 101,
+100, 44, 32, 104, 117, 110, 103, 32, 111, 114, 32, 105, 115, 110, 39, 116, 32, 97, 32, 112, 108, 117, 103, 105,
+110, 41, 46, 32, 82, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 62, 32, 84, 114, 121, 32, 97, 103,
+97, 105, 110, 46, 34, 32, 61, 32, 34, 65, 32, 98, 117, 115, 99, 97, 32, 110, 195, 163, 111, 32, 99, 111,
+110, 115, 101, 103, 117, 105, 117, 32, 99, 97, 114, 114, 101, 103, 97, 114, 32, 101, 115, 116, 101, 32, 97, 114,
+113, 117, 105, 118, 111, 32, 40, 116, 114, 97, 118, 111, 117, 44, 32, 112, 97, 114, 111, 117, 32, 100, 101, 32,
+114, 101, 115, 112, 111, 110, 100, 101, 114, 32, 111, 117, 32, 110, 195, 163, 111, 32, 195, 169, 32, 117, 109, 32,
+112, 108, 117, 103, 105, 110, 41, 46, 32, 67, 108, 105, 113, 117, 101, 32, 99, 111, 109, 32, 111, 32, 98, 111,
+116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 62, 32, 84, 101, 110, 116, 97, 114, 32, 100, 101,
+32, 110, 111, 118, 111, 46, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 102, 114, 111, 109, 32, 102, 97, 118,
+111, 117, 114, 105, 116, 101, 115, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 100, 111, 115, 32,
+102, 97, 118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 65, 100, 100, 32, 116, 111, 32, 102, 97, 118, 111, 117,
+114, 105, 116, 101, 115, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 97, 111, 115, 32,
+102, 97, 118, 111, 114, 105, 116, 111, 115, 34, 10, 34, 84, 114, 121, 32, 97, 103, 97, 105, 110, 32, 40, 115,
+99, 97, 110, 32, 116, 104, 105, 115, 32, 102, 105, 108, 101, 32, 110, 111, 119, 41, 34, 32, 61, 32, 34, 84,
+101, 110, 116, 97, 114, 32, 100, 101, 32, 110, 111, 118, 111, 32, 40, 101, 120, 97, 109, 105, 110, 97, 114, 32,
+101, 115, 116, 101, 32, 97, 114, 113, 117, 105, 118, 111, 32, 97, 103, 111, 114, 97, 41, 34, 10, 34, 82, 101,
+109, 111, 118, 101, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 108, 105, 115, 116, 34, 32, 61, 32, 34, 82,
+101, 109, 111, 118, 101, 114, 32, 100, 97, 32, 108, 105, 115, 116, 97, 34, 10, 34, 83, 104, 111, 119, 32, 105,
+110, 32, 102, 111, 108, 100, 101, 114, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 110, 97, 32,
+112, 97, 115, 116, 97, 34, 10, 34, 67, 111, 112, 121, 32, 112, 97, 116, 104, 34, 32, 61, 32, 34, 67, 111,
+112, 105, 97, 114, 32, 99, 97, 109, 105, 110, 104, 111, 34, 10, 34, 82, 101, 115, 99, 97, 110, 32, 97, 108,
+108, 32, 112, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 114, 32, 116,
+111, 100, 111, 115, 32, 111, 115, 32, 112, 108, 117, 103, 105, 110, 115, 32, 100, 101, 32, 110, 111, 118, 111, 34,
+10, 34, 76, 89, 78, 88, 32, 102, 111, 114, 103, 101, 116, 115, 32, 101, 118, 101, 114, 121, 32, 112, 108, 117,
+103, 105, 110, 32, 105, 116, 32, 102, 111, 117, 110, 100, 32, 40, 97, 110, 100, 32, 116, 104, 101, 32, 111, 110,
+101, 115, 32, 116, 104, 97, 116, 32, 102, 97, 105, 108, 101, 100, 41, 32, 97, 110, 100, 32, 101, 120, 97, 109,
+105, 110, 101, 115, 32, 97, 108, 108, 32, 112, 108, 117, 103, 105, 110, 32, 102, 111, 108, 100, 101, 114, 115, 32,
+97, 103, 97, 105, 110, 46, 32, 84, 104, 105, 115, 32, 99, 97, 110, 32, 116, 97, 107, 101, 32, 97, 32, 102,
+101, 119, 32, 109, 105, 110, 117, 116, 101, 115, 59, 32, 76, 89, 78, 88, 32, 115, 116, 97, 121, 115, 32, 117,
+115, 97, 98, 108, 101, 32, 109, 101, 97, 110, 119, 104, 105, 108, 101, 46, 34, 32, 61, 32, 34, 79, 32, 76,
+89, 78, 88, 32, 101, 115, 113, 117, 101, 99, 101, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 112, 108, 117,
+103, 105, 110, 115, 32, 113, 117, 101, 32, 101, 110, 99, 111, 110, 116, 114, 111, 117, 32, 40, 101, 32, 111, 115,
+32, 113, 117, 101, 32, 102, 97, 108, 104, 97, 114, 97, 109, 41, 32, 101, 32, 101, 120, 97, 109, 105, 110, 97,
+32, 100, 101, 32, 110, 111, 118, 111, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 112, 97, 115, 116, 97, 115,
+32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 46, 32, 73, 115, 115, 111, 32, 112, 111, 100, 101, 32, 108,
+101, 118, 97, 114, 32, 97, 108, 103, 117, 110, 115, 32, 109, 105, 110, 117, 116, 111, 115, 59, 32, 101, 110, 113,
+117, 97, 110, 116, 111, 32, 105, 115, 115, 111, 32, 111, 32, 76, 89, 78, 88, 32, 99, 111, 110, 116, 105, 110,
+117, 97, 32, 117, 116, 105, 108, 105, 122, 195, 161, 118, 101, 108, 46, 34, 10, 34, 82, 101, 115, 99, 97, 110,
+34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 114, 32, 100, 101, 32, 110, 111, 118, 111, 34, 10, 34,
+65, 100, 100, 32, 97, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 34, 32, 61, 32, 34, 65, 100,
+105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 32, 97, 114, 113, 117, 105, 118, 111, 32, 100, 101, 32, 112, 108,
+117, 103, 105, 110, 34, 10, 34, 83, 99, 97, 110, 110, 105, 110, 103, 58, 32, 123, 48, 125, 34, 32, 61, 32,
+34, 69, 120, 97, 109, 105, 110, 97, 110, 100, 111, 58, 32, 123, 48, 125, 34, 10, 34, 76, 97, 115, 116, 32,
+115, 99, 97, 110, 58, 32, 49, 32, 110, 101, 119, 32, 112, 108, 117, 103, 105, 110, 46, 34, 32, 61, 32, 34,
+195, 154, 108, 116, 105, 109, 97, 32, 98, 117, 115, 99, 97, 58, 32, 49, 32, 112, 108, 117, 103, 105, 110, 32,
+110, 111, 118, 111, 46, 34, 10, 34, 76, 97, 115, 116, 32, 115, 99, 97, 110, 58, 32, 123, 48, 125, 32, 110,
+101, 119, 32, 112, 108, 117, 103, 105, 110, 115, 46, 34, 32, 61, 32, 34, 195, 154, 108, 116, 105, 109, 97, 32,
+98, 117, 115, 99, 97, 58, 32, 123, 48, 125, 32, 112, 108, 117, 103, 105, 110, 115, 32, 110, 111, 118, 111, 115,
+46, 34, 10, 34, 69, 97, 99, 104, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 32, 105, 115, 32,
+101, 120, 97, 109, 105, 110, 101, 100, 32, 105, 110, 32, 97, 32, 115, 101, 112, 97, 114, 97, 116, 101, 32, 112,
+114, 111, 99, 101, 115, 115, 58, 32, 111, 110, 101, 32, 116, 104, 97, 116, 32, 99, 114, 97, 115, 104, 101, 115,
+32, 105, 115, 32, 109, 97, 114, 107, 101, 100, 32, 97, 115, 32, 102, 97, 105, 108, 101, 100, 32, 97, 110, 100,
+32, 115, 107, 105, 112, 112, 101, 100, 32, 108, 97, 116, 101, 114, 46, 34, 32, 61, 32, 34, 67, 97, 100, 97,
+32, 97, 114, 113, 117, 105, 118, 111, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 32, 195, 169, 32, 101, 120,
+97, 109, 105, 110, 97, 100, 111, 32, 101, 109, 32, 117, 109, 32, 112, 114, 111, 99, 101, 115, 115, 111, 32, 115,
+101, 112, 97, 114, 97, 100, 111, 58, 32, 117, 109, 32, 113, 117, 101, 32, 116, 114, 97, 118, 97, 32, 195, 169,
+32, 109, 97, 114, 99, 97, 100, 111, 32, 99, 111, 109, 111, 32, 102, 97, 108, 104, 111, 32, 101, 32, 112, 117,
+108, 97, 100, 111, 32, 100, 101, 112, 111, 105, 115, 46, 34, 10, 34, 70, 105, 110, 100, 32, 110, 101, 119, 32,
+112, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 66, 117, 115, 99, 97, 114, 32, 112, 108, 117, 103, 105,
+110, 115, 32, 110, 111, 118, 111, 115, 34, 10, 34, 82, 101, 115, 99, 97, 110, 32, 97, 108, 108, 46, 46, 46,
+34, 32, 61, 32, 34, 69, 120, 97, 109, 105, 110, 97, 114, 32, 116, 117, 100, 111, 32, 100, 101, 32, 110, 111,
+118, 111, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 102, 111, 108, 100, 101, 114, 115, 46, 46,
+46, 34, 32, 61, 32, 34, 80, 97, 115, 116, 97, 115, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 115, 46,
+46, 46, 34, 10, 34, 65, 100, 100, 32, 112, 108, 117, 103, 105, 110, 32, 102, 105, 108, 101, 46, 46, 46, 34,
+32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114, 32, 97, 114, 113, 117, 105, 118, 111, 32, 100, 101,
+32, 112, 108, 117, 103, 105, 110, 46, 46, 46, 34, 10, 34, 80, 108, 117, 103, 105, 110, 32, 109, 97, 110, 97,
+103, 101, 114, 34, 32, 61, 32, 34, 71, 101, 114, 101, 110, 99, 105, 97, 100, 111, 114, 32, 100, 101, 32, 112,
+108, 117, 103, 105, 110, 115, 34, 10, 34, 77, 73, 68, 73, 34, 32, 61, 32, 34, 77, 73, 68, 73, 34, 10,
+34, 65, 32, 110, 101, 119, 32, 108, 97, 110, 103, 117, 97, 103, 101, 32, 105, 115, 32, 97, 112, 112, 108, 105,
+101, 100, 32, 119, 104, 101, 110, 32, 76, 89, 78, 88, 32, 114, 101, 115, 116, 97, 114, 116, 115, 46, 34, 32,
+61, 32, 34, 85, 109, 32, 110, 111, 118, 111, 32, 105, 100, 105, 111, 109, 97, 32, 195, 169, 32, 97, 112, 108,
+105, 99, 97, 100, 111, 32, 113, 117, 97, 110, 100, 111, 32, 111, 32, 76, 89, 78, 88, 32, 114, 101, 105, 110,
+105, 99, 105, 97, 46, 34, 10, 34, 73, 110, 116, 101, 114, 102, 97, 99, 101, 32, 115, 105, 122, 101, 34, 32,
+61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 97, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 34,
+10, 34, 77, 97, 120, 105, 109, 117, 109, 32, 117, 110, 100, 111, 32, 108, 101, 118, 101, 108, 115, 34, 32, 61,
+32, 34, 77, 195, 161, 120, 105, 109, 111, 32, 100, 101, 32, 110, 195, 173, 118, 101, 105, 115, 32, 100, 101, 32,
+100, 101, 115, 102, 97, 122, 101, 114, 34, 10, 34, 83, 97, 118, 101, 32, 97, 32, 98, 97, 99, 107, 117, 112,
+32, 99, 111, 112, 121, 34, 32, 61, 32, 34, 83, 97, 108, 118, 97, 114, 32, 117, 109, 97, 32, 99, 195, 179,
+112, 105, 97, 32, 100, 101, 32, 115, 101, 103, 117, 114, 97, 110, 195, 167, 97, 34, 10, 34, 78, 101, 118, 101,
+114, 34, 32, 61, 32, 34, 78, 117, 110, 99, 97, 34, 10, 34, 69, 118, 101, 114, 121, 32, 109, 105, 110, 117,
+116, 101, 34, 32, 61, 32, 34, 65, 32, 99, 97, 100, 97, 32, 109, 105, 110, 117, 116, 111, 34, 10, 34, 69,
+118, 101, 114, 121, 32, 123, 48, 125, 32, 109, 105, 110, 117, 116, 101, 115, 34, 32, 61, 32, 34, 65, 32, 99,
+97, 100, 97, 32, 123, 48, 125, 32, 109, 105, 110, 117, 116, 111, 115, 34, 10, 34, 66, 97, 99, 107, 117, 112,
+115, 32, 107, 101, 112, 116, 32, 112, 101, 114, 32, 112, 114, 111, 106, 101, 99, 116, 34, 32, 61, 32, 34, 67,
+195, 179, 112, 105, 97, 115, 32, 109, 97, 110, 116, 105, 100, 97, 115, 32, 112, 111, 114, 32, 112, 114, 111, 106,
+101, 116, 111, 34, 10, 34, 65, 112, 112, 108, 105, 101, 115, 32, 116, 111, 32, 112, 108, 117, 103, 105, 110, 115,
+32, 111, 112, 101, 110, 101, 100, 32, 102, 114, 111, 109, 32, 110, 111, 119, 32, 111, 110, 59, 32, 114, 101, 111,
+112, 101, 110, 32, 116, 104, 101, 32, 112, 114, 111, 106, 101, 99, 116, 32, 116, 111, 32, 109, 111, 118, 101, 32,
+116, 104, 101, 32, 111, 116, 104, 101, 114, 115, 46, 34, 32, 61, 32, 34, 86, 97, 108, 101, 32, 112, 97, 114,
+97, 32, 111, 115, 32, 112, 108, 117, 103, 105, 110, 115, 32, 97, 98, 101, 114, 116, 111, 115, 32, 100, 97, 113,
+117, 105, 32, 101, 109, 32, 100, 105, 97, 110, 116, 101, 59, 32, 114, 101, 97, 98, 114, 97, 32, 111, 32, 112,
+114, 111, 106, 101, 116, 111, 32, 112, 97, 114, 97, 32, 109, 111, 118, 101, 114, 32, 111, 115, 32, 111, 117, 116,
+114, 111, 115, 46, 34, 10, 34, 83, 101, 101, 44, 32, 115, 101, 97, 114, 99, 104, 32, 97, 110, 100, 32, 99,
+104, 97, 110, 103, 101, 32, 101, 118, 101, 114, 121, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 115, 104, 111,
+114, 116, 99, 117, 116, 46, 34, 32, 61, 32, 34, 86, 101, 106, 97, 44, 32, 98, 117, 115, 113, 117, 101, 32,
+101, 32, 97, 108, 116, 101, 114, 101, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116, 97, 108, 104, 111,
+115, 32, 100, 101, 32, 116, 101, 99, 108, 97, 100, 111, 46, 34, 10, 34, 76, 97, 110, 103, 117, 97, 103, 101,
+32, 97, 110, 100, 32, 100, 105, 115, 112, 108, 97, 121, 34, 32, 61, 32, 34, 73, 100, 105, 111, 109, 97, 32,
+101, 32, 101, 120, 105, 98, 105, 195, 167, 195, 163, 111, 34, 10, 34, 83, 116, 97, 114, 116, 117, 112, 34, 32,
+61, 32, 34, 73, 110, 105, 99, 105, 97, 108, 105, 122, 97, 195, 167, 195, 163, 111, 34, 10, 34, 69, 100, 105,
+116, 105, 110, 103, 34, 32, 61, 32, 34, 69, 100, 105, 195, 167, 195, 163, 111, 34, 10, 34, 66, 97, 99, 107,
+117, 112, 34, 32, 61, 32, 34, 67, 195, 179, 112, 105, 97, 32, 100, 101, 32, 115, 101, 103, 117, 114, 97, 110,
+195, 167, 97, 34, 10, 34, 80, 108, 117, 103, 105, 110, 115, 32, 97, 110, 100, 32, 115, 104, 111, 114, 116, 99,
+117, 116, 115, 34, 32, 61, 32, 34, 80, 108, 117, 103, 105, 110, 115, 32, 101, 32, 97, 116, 97, 108, 104, 111,
+115, 34, 10, 34, 79, 112, 101, 110, 32, 98, 97, 99, 107, 117, 112, 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, 97, 115, 32, 99, 195, 179, 112, 105,
+97, 115, 34, 10, 34, 68, 114, 105, 118, 101, 114, 34, 32, 61, 32, 34, 68, 114, 105, 118, 101, 114, 34, 10,
+34, 79, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111,
+115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 34, 10, 34, 73, 110, 112, 117, 116,
+32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32,
+100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 34, 10, 34, 66, 117, 102, 102, 101, 114, 32, 115, 105, 122, 101,
+34, 32, 61, 32, 34, 84, 97, 109, 97, 110, 104, 111, 32, 100, 111, 32, 98, 117, 102, 102, 101, 114, 34, 10,
+34, 83, 109, 97, 108, 108, 101, 114, 32, 98, 117, 102, 102, 101, 114, 115, 32, 97, 110, 115, 119, 101, 114, 32,
+102, 97, 115, 116, 101, 114, 32, 119, 104, 101, 110, 32, 121, 111, 117, 32, 112, 108, 97, 121, 59, 32, 108, 97,
+114, 103, 101, 114, 32, 111, 110, 101, 115, 32, 103, 105, 118, 101, 32, 116, 104, 101, 32, 67, 80, 85, 32, 109,
+111, 114, 101, 32, 114, 111, 111, 109, 32, 40, 102, 101, 119, 101, 114, 32, 99, 108, 105, 99, 107, 115, 41, 46,
+34, 32, 61, 32, 34, 66, 117, 102, 102, 101, 114, 115, 32, 109, 101, 110, 111, 114, 101, 115, 32, 114, 101, 115,
+112, 111, 110, 100, 101, 109, 32, 109, 97, 105, 115, 32, 114, 195, 161, 112, 105, 100, 111, 32, 113, 117, 97, 110,
+100, 111, 32, 118, 111, 99, 195, 170, 32, 116, 111, 99, 97, 59, 32, 109, 97, 105, 111, 114, 101, 115, 32, 100,
+195, 163, 111, 32, 109, 97, 105, 115, 32, 102, 111, 108, 103, 97, 32, 195, 160, 32, 67, 80, 85, 32, 40, 109,
+101, 110, 111, 115, 32, 101, 115, 116, 97, 108, 111, 115, 41, 46, 34, 10, 34, 87, 105, 116, 104, 32, 114, 101,
+99, 111, 114, 100, 105, 110, 103, 32, 111, 110, 44, 32, 116, 104, 101, 32, 115, 111, 117, 110, 100, 32, 99, 97,
+114, 100, 32, 105, 110, 112, 117, 116, 32, 98, 101, 99, 111, 109, 101, 115, 32, 97, 32, 80, 108, 97, 121, 108,
+105, 115, 116, 32, 99, 108, 105, 112, 32, 40, 116, 104, 101, 32, 73, 110, 112, 117, 116, 32, 100, 101, 118, 105,
+99, 101, 32, 97, 98, 111, 118, 101, 41, 46, 34, 32, 61, 32, 34, 67, 111, 109, 32, 97, 32, 103, 114, 97,
+118, 97, 195, 167, 195, 163, 111, 32, 108, 105, 103, 97, 100, 97, 44, 32, 97, 32, 101, 110, 116, 114, 97, 100,
+97, 32, 100, 97, 32, 112, 108, 97, 99, 97, 32, 100, 101, 32, 115, 111, 109, 32, 118, 105, 114, 97, 32, 117,
+109, 32, 99, 108, 105, 112, 101, 32, 110, 97, 32, 80, 108, 97, 121, 108, 105, 115, 116, 32, 40, 111, 32, 100,
+105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 97, 99,
+105, 109, 97, 41, 46, 34, 10, 34, 123, 48, 125, 32, 115, 97, 109, 112, 108, 101, 115, 32, 40, 123, 49, 125,
+32, 109, 115, 41, 34, 32, 61, 32, 34, 123, 48, 125, 32, 97, 109, 111, 115, 116, 114, 97, 115, 32, 40, 123,
+49, 125, 32, 109, 115, 41, 34, 10, 34, 78, 111, 32, 97, 117, 100, 105, 111, 32, 100, 101, 118, 105, 99, 101,
+32, 105, 115, 32, 111, 112, 101, 110, 58, 32, 99, 104, 111, 111, 115, 101, 32, 97, 110, 32, 111, 117, 116, 112,
+117, 116, 32, 100, 101, 118, 105, 99, 101, 46, 34, 32, 61, 32, 34, 78, 101, 110, 104, 117, 109, 32, 100, 105,
+115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 32, 97, 98, 101, 114,
+116, 111, 58, 32, 101, 115, 99, 111, 108, 104, 97, 32, 117, 109, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105,
+118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 46, 34, 10, 34, 123, 48, 125, 32, 105, 115, 32, 114,
+117, 110, 110, 105, 110, 103, 58, 32, 123, 49, 125, 32, 72, 122, 44, 32, 111, 117, 116, 112, 117, 116, 32, 108,
+97, 116, 101, 110, 99, 121, 32, 123, 50, 125, 32, 109, 115, 34, 32, 61, 32, 34, 123, 48, 125, 32, 101, 115,
+116, 195, 161, 32, 114, 111, 100, 97, 110, 100, 111, 58, 32, 123, 49, 125, 32, 72, 122, 44, 32, 108, 97, 116,
+195, 170, 110, 99, 105, 97, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 123, 50, 125, 32, 109, 115, 34,
+10, 34, 65, 117, 100, 105, 111, 32, 67, 80, 85, 32, 108, 111, 97, 100, 58, 32, 123, 48, 125, 37, 34, 32,
+61, 32, 34, 67, 97, 114, 103, 97, 32, 100, 101, 32, 67, 80, 85, 32, 100, 111, 32, 195, 161, 117, 100, 105,
+111, 58, 32, 123, 48, 125, 37, 34, 10, 34, 123, 48, 125, 32, 100, 114, 111, 112, 111, 117, 116, 115, 32, 40,
+98, 117, 102, 102, 101, 114, 32, 117, 110, 100, 101, 114, 114, 117, 110, 115, 41, 32, 115, 111, 32, 102, 97, 114,
+34, 32, 61, 32, 34, 123, 48, 125, 32, 102, 97, 108, 104, 97, 115, 32, 40, 98, 117, 102, 102, 101, 114, 32,
+101, 115, 118, 97, 122, 105, 97, 100, 111, 41, 32, 97, 116, 195, 169, 32, 97, 103, 111, 114, 97, 34, 10, 34,
+65, 117, 100, 105, 111, 32, 100, 101, 118, 105, 99, 101, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105,
+116, 105, 118, 111, 32, 100, 101, 32, 195, 161, 117, 100, 105, 111, 34, 10, 34, 68, 114, 105, 118, 101, 114, 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, 100, 114, 105, 118, 101, 114, 46, 46, 46, 34, 10, 34, 80,
+108, 97, 121, 32, 97, 32, 116, 101, 115, 116, 32, 115, 111, 117, 110, 100, 34, 32, 61, 32, 34, 84, 111, 99,
+97, 114, 32, 117, 109, 32, 115, 111, 109, 32, 100, 101, 32, 116, 101, 115, 116, 101, 34, 10, 34, 65, 110, 121,
+32, 77, 73, 68, 73, 32, 99, 104, 97, 110, 110, 101, 108, 34, 32, 61, 32, 34, 81, 117, 97, 108, 113, 117,
+101, 114, 32, 99, 97, 110, 97, 108, 32, 77, 73, 68, 73, 34, 10, 34, 77, 73, 68, 73, 32, 99, 104, 97,
+110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 32, 77, 73, 68, 73, 32,
+123, 48, 125, 34, 10, 34, 80, 108, 97, 121, 115, 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, 84, 111, 99, 97, 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, 80, 108, 97, 121,
+115, 32, 123, 48, 125, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32, 123, 48, 125, 34, 10, 34, 80, 108, 97,
+121, 115, 32, 99, 104, 97, 110, 110, 101, 108, 32, 123, 48, 125, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32,
+111, 32, 99, 97, 110, 97, 108, 32, 123, 48, 125, 34, 10, 34, 69, 97, 99, 104, 32, 105, 110, 112, 117, 116,
+32, 100, 101, 118, 105, 99, 101, 32, 99, 97, 110, 32, 98, 101, 32, 116, 117, 114, 110, 101, 100, 32, 111, 102,
+102, 44, 32, 108, 105, 115, 116, 101, 110, 32, 116, 111, 32, 111, 110, 101, 32, 77, 73, 68, 73, 32, 99, 104,
+97, 110, 110, 101, 108, 32, 111, 110, 108, 121, 32, 97, 110, 100, 32, 112, 108, 97, 121, 32, 97, 32, 102, 105,
+120, 101, 100, 32, 99, 104, 97, 110, 110, 101, 108, 32, 111, 102, 32, 116, 104, 101, 32, 67, 104, 97, 110, 110,
+101, 108, 32, 82, 97, 99, 107, 32, 105, 110, 115, 116, 101, 97, 100, 32, 111, 102, 32, 116, 104, 101, 32, 115,
+101, 108, 101, 99, 116, 101, 100, 32, 111, 110, 101, 115, 46, 34, 32, 61, 32, 34, 67, 97, 100, 97, 32, 100,
+105, 115, 112, 111, 115, 105, 116, 105, 118, 111, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 112, 111,
+100, 101, 32, 115, 101, 114, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 44, 32, 111, 117, 118, 105, 114, 32,
+115, 195, 179, 32, 117, 109, 32, 99, 97, 110, 97, 108, 32, 77, 73, 68, 73, 32, 101, 32, 116, 111, 99, 97,
+114, 32, 117, 109, 32, 99, 97, 110, 97, 108, 32, 102, 105, 120, 111, 32, 100, 111, 32, 67, 104, 97, 110, 110,
+101, 108, 32, 82, 97, 99, 107, 32, 101, 109, 32, 118, 101, 122, 32, 100, 111, 115, 32, 115, 101, 108, 101, 99,
+105, 111, 110, 97, 100, 111, 115, 46, 34, 10, 34, 78, 111, 32, 77, 73, 68, 73, 32, 105, 110, 112, 117, 116,
+32, 100, 101, 118, 105, 99, 101, 115, 32, 102, 111, 117, 110, 100, 46, 32, 67, 111, 110, 110, 101, 99, 116, 32,
+111, 110, 101, 32, 97, 110, 100, 32, 114, 101, 102, 114, 101, 115, 104, 32, 116, 104, 101, 32, 108, 105, 115, 116,
+46, 34, 32, 61, 32, 34, 78, 101, 110, 104, 117, 109, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111,
+32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 77, 73, 68, 73, 32, 101, 110, 99, 111, 110, 116, 114,
+97, 100, 111, 46, 32, 67, 111, 110, 101, 99, 116, 101, 32, 117, 109, 32, 101, 32, 97, 116, 117, 97, 108, 105,
+122, 101, 32, 97, 32, 108, 105, 115, 116, 97, 46, 34, 10, 34, 65, 115, 32, 112, 108, 97, 121, 101, 100, 34,
+32, 61, 32, 34, 67, 111, 109, 111, 32, 116, 111, 99, 97, 100, 111, 34, 10, 34, 83, 111, 102, 116, 32, 40,
+108, 105, 103, 104, 116, 32, 112, 108, 97, 121, 105, 110, 103, 32, 115, 111, 117, 110, 100, 115, 32, 108, 111, 117,
+100, 101, 114, 41, 34, 32, 61, 32, 34, 83, 117, 97, 118, 101, 32, 40, 116, 111, 99, 97, 114, 32, 108, 101,
+118, 101, 32, 115, 111, 97, 32, 109, 97, 105, 115, 32, 102, 111, 114, 116, 101, 41, 34, 10, 34, 72, 97, 114,
+100, 32, 40, 110, 101, 101, 100, 115, 32, 104, 97, 114, 100, 101, 114, 32, 112, 108, 97, 121, 105, 110, 103, 41,
+34, 32, 61, 32, 34, 68, 117, 114, 111, 32, 40, 112, 101, 100, 101, 32, 116, 111, 113, 117, 101, 32, 109, 97,
+105, 115, 32, 102, 111, 114, 116, 101, 41, 34, 10, 34, 70, 105, 120, 101, 100, 32, 40, 101, 118, 101, 114, 121,
+32, 110, 111, 116, 101, 32, 97, 116, 32, 102, 117, 108, 108, 32, 118, 101, 108, 111, 99, 105, 116, 121, 41, 34,
+32, 61, 32, 34, 70, 105, 120, 111, 32, 40, 116, 111, 100, 97, 32, 110, 111, 116, 97, 32, 99, 111, 109, 32,
+118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 32, 109, 195, 161, 120, 105, 109, 97, 41, 34, 10, 34, 70, 111,
+114, 32, 110, 111, 116, 101, 115, 32, 102, 114, 111, 109, 32, 77, 73, 68, 73, 32, 100, 101, 118, 105, 99, 101,
+115, 32, 40, 116, 104, 101, 32, 116, 121, 112, 105, 110, 103, 32, 107, 101, 121, 98, 111, 97, 114, 100, 32, 97,
+108, 119, 97, 121, 115, 32, 112, 108, 97, 121, 115, 32, 97, 116, 32, 116, 104, 101, 32, 80, 105, 97, 110, 111,
+32, 82, 111, 108, 108, 39, 115, 32, 118, 101, 108, 111, 99, 105, 116, 121, 41, 46, 34, 32, 61, 32, 34, 80,
+97, 114, 97, 32, 110, 111, 116, 97, 115, 32, 100, 101, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111,
+115, 32, 77, 73, 68, 73, 32, 40, 111, 32, 116, 101, 99, 108, 97, 100, 111, 32, 100, 111, 32, 99, 111, 109,
+112, 117, 116, 97, 100, 111, 114, 32, 115, 101, 109, 112, 114, 101, 32, 116, 111, 99, 97, 32, 99, 111, 109, 32,
+97, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 32, 100, 111, 32, 80, 105, 97, 110, 111, 32, 82, 111,
+108, 108, 41, 46, 34, 10, 34, 67, 111, 110, 116, 114, 111, 108, 108, 101, 114, 32, 116, 121, 112, 101, 34, 32,
+61, 32, 34, 84, 105, 112, 111, 32, 100, 101, 32, 99, 111, 110, 116, 114, 111, 108, 97, 100, 111, 114, 34, 10,
+34, 71, 101, 110, 101, 114, 105, 99, 32, 99, 111, 110, 116, 114, 111, 108, 108, 101, 114, 58, 32, 108, 105, 110,
+107, 32, 97, 32, 107, 110, 111, 98, 32, 111, 114, 32, 102, 97, 100, 101, 114, 32, 119, 105, 116, 104, 32, 97,
+32, 99, 111, 110, 116, 114, 111, 108, 39, 115, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 109,
+101, 110, 117, 32, 62, 32, 76, 105, 110, 107, 32, 116, 111, 32, 77, 73, 68, 73, 32, 99, 111, 110, 116, 114,
+111, 108, 108, 101, 114, 46, 34, 32, 61, 32, 34, 67, 111, 110, 116, 114, 111, 108, 97, 100, 111, 114, 32, 103,
+101, 110, 195, 169, 114, 105, 99, 111, 58, 32, 108, 105, 103, 117, 101, 32, 117, 109, 32, 107, 110, 111, 98, 32,
+111, 117, 32, 102, 97, 100, 101, 114, 32, 112, 101, 108, 111, 32, 109, 101, 110, 117, 32, 100, 101, 32, 98, 111,
+116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 100, 101, 32, 117, 109, 32, 99, 111, 110, 116, 114,
+111, 108, 101, 32, 62, 32, 86, 105, 110, 99, 117, 108, 97, 114, 32, 97, 111, 32, 99, 111, 110, 116, 114, 111,
+108, 97, 100, 111, 114, 32, 77, 73, 68, 73, 46, 34, 10, 34, 80, 105, 99, 107, 117, 112, 32, 40, 116, 97,
+107, 101, 111, 118, 101, 114, 32, 109, 111, 100, 101, 41, 34, 32, 61, 32, 34, 67, 97, 112, 116, 117, 114, 97,
+32, 40, 109, 111, 100, 111, 32, 116, 97, 107, 101, 111, 118, 101, 114, 41, 34, 10, 34, 65, 32, 99, 111, 110,
+116, 114, 111, 108, 108, 101, 114, 32, 109, 111, 118, 101, 115, 32, 97, 32, 112, 97, 114, 97, 109, 101, 116, 101,
+114, 32, 111, 110, 108, 121, 32, 97, 102, 116, 101, 114, 32, 114, 101, 97, 99, 104, 105, 110, 103, 32, 105, 116,
+115, 32, 99, 117, 114, 114, 101, 110, 116, 32, 118, 97, 108, 117, 101, 44, 32, 115, 111, 32, 110, 111, 116, 104,
+105, 110, 103, 32, 106, 117, 109, 112, 115, 46, 34, 32, 61, 32, 34, 85, 109, 32, 99, 111, 110, 116, 114, 111,
+108, 97, 100, 111, 114, 32, 115, 195, 179, 32, 109, 111, 118, 101, 32, 117, 109, 32, 112, 97, 114, 195, 162, 109,
+101, 116, 114, 111, 32, 100, 101, 112, 111, 105, 115, 32, 100, 101, 32, 97, 108, 99, 97, 110, 195, 167, 97, 114,
+32, 111, 32, 118, 97, 108, 111, 114, 32, 97, 116, 117, 97, 108, 32, 100, 101, 108, 101, 44, 32, 101, 110, 116,
+195, 163, 111, 32, 110, 97, 100, 97, 32, 112, 117, 108, 97, 46, 34, 10, 34, 76, 105, 110, 107, 115, 32, 105,
+110, 32, 116, 104, 105, 115, 32, 112, 114, 111, 106, 101, 99, 116, 34, 32, 61, 32, 34, 86, 195, 173, 110, 99,
+117, 108, 111, 115, 32, 110, 101, 115, 116, 101, 32, 112, 114, 111, 106, 101, 116, 111, 34, 10, 34, 99, 104, 46,
+32, 123, 48, 125, 34, 32, 61, 32, 34, 99, 97, 110, 46, 32, 123, 48, 125, 34, 10, 34, 73, 110, 112, 117,
+116, 32, 100, 101, 118, 105, 99, 101, 115, 34, 32, 61, 32, 34, 68, 105, 115, 112, 111, 115, 105, 116, 105, 118,
+111, 115, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 34, 10, 34, 78, 111, 116, 101, 115, 34, 32, 61,
+32, 34, 78, 111, 116, 97, 115, 34, 10, 34, 67, 111, 110, 116, 114, 111, 108, 108, 101, 114, 115, 34, 32, 61,
+32, 34, 67, 111, 110, 116, 114, 111, 108, 97, 100, 111, 114, 101, 115, 34, 10, 34, 82, 101, 102, 114, 101, 115,
+104, 32, 100, 101, 118, 105, 99, 101, 32, 108, 105, 115, 116, 34, 32, 61, 32, 34, 65, 116, 117, 97, 108, 105,
+122, 97, 114, 32, 108, 105, 115, 116, 97, 32, 100, 101, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105, 118, 111,
+115, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 108, 105, 110, 107, 34, 32, 61, 32, 34, 82, 101, 109, 111,
+118, 101, 114, 32, 118, 195, 173, 110, 99, 117, 108, 111, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 97, 108,
+108, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 116, 111, 100, 111, 115, 34, 10, 34, 69, 118,
+101, 114, 121, 119, 104, 101, 114, 101, 34, 32, 61, 32, 34, 69, 109, 32, 116, 111, 100, 111, 32, 108, 117, 103,
+97, 114, 34, 10, 34, 80, 114, 101, 115, 115, 32, 116, 104, 101, 32, 110, 101, 119, 32, 107, 101, 121, 115, 32,
+110, 111, 119, 32, 40, 69, 115, 99, 32, 99, 97, 110, 99, 101, 108, 115, 41, 34, 32, 61, 32, 34, 80, 114,
+101, 115, 115, 105, 111, 110, 101, 32, 97, 115, 32, 110, 111, 118, 97, 115, 32, 116, 101, 99, 108, 97, 115, 32,
+97, 103, 111, 114, 97, 32, 40, 69, 115, 99, 32, 99, 97, 110, 99, 101, 108, 97, 41, 34, 10, 34, 83, 101,
+97, 114, 99, 104, 32, 97, 110, 32, 97, 99, 116, 105, 111, 110, 32, 111, 114, 32, 97, 32, 107, 101, 121, 32,
+40, 101, 46, 103, 46, 32, 92, 34, 67, 116, 114, 108, 43, 76, 92, 34, 41, 34, 32, 61, 32, 34, 66, 117,
+115, 99, 97, 114, 32, 117, 109, 97, 32, 97, 195, 167, 195, 163, 111, 32, 111, 117, 32, 116, 101, 99, 108, 97,
+32, 40, 101, 120, 46, 58, 32, 92, 34, 67, 116, 114, 108, 43, 76, 92, 34, 41, 34, 10, 34, 65, 108, 108,
+32, 112, 108, 97, 99, 101, 115, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32, 108, 117, 103,
+97, 114, 101, 115, 34, 10, 34, 67, 104, 97, 110, 103, 101, 100, 32, 111, 110, 108, 121, 34, 32, 61, 32, 34,
+83, 195, 179, 32, 97, 108, 116, 101, 114, 97, 100, 111, 115, 34, 10, 34, 40, 110, 111, 32, 115, 104, 111, 114,
+116, 99, 117, 116, 41, 34, 32, 61, 32, 34, 40, 115, 101, 109, 32, 97, 116, 97, 108, 104, 111, 41, 34, 10,
+34, 123, 48, 125, 32, 97, 99, 116, 105, 111, 110, 115, 34, 32, 61, 32, 34, 123, 48, 125, 32, 97, 195, 167,
+195, 181, 101, 115, 34, 10, 34, 83, 101, 108, 101, 99, 116, 32, 97, 110, 32, 97, 99, 116, 105, 111, 110, 32,
+116, 111, 32, 99, 104, 97, 110, 103, 101, 32, 105, 116, 115, 32, 115, 104, 111, 114, 116, 99, 117, 116, 34, 32,
+61, 32, 34, 83, 101, 108, 101, 99, 105, 111, 110, 101, 32, 117, 109, 97, 32, 97, 195, 167, 195, 163, 111, 32,
+112, 97, 114, 97, 32, 97, 108, 116, 101, 114, 97, 114, 32, 111, 32, 97, 116, 97, 108, 104, 111, 34, 10, 34,
+87, 111, 114, 107, 115, 58, 32, 123, 48, 125, 34, 32, 61, 32, 34, 70, 117, 110, 99, 105, 111, 110, 97, 58,
+32, 123, 48, 125, 34, 10, 34, 119, 105, 110, 115, 32, 111, 118, 101, 114, 32, 97, 32, 115, 104, 111, 114, 116,
+99, 117, 116, 32, 111, 102, 32, 116, 104, 101, 32, 115, 97, 109, 101, 32, 107, 101, 121, 115, 32, 116, 104, 97,
+116, 32, 119, 111, 114, 107, 115, 32, 101, 118, 101, 114, 121, 119, 104, 101, 114, 101, 34, 32, 61, 32, 34, 118,
+101, 110, 99, 101, 32, 117, 109, 32, 97, 116, 97, 108, 104, 111, 32, 99, 111, 109, 32, 97, 115, 32, 109, 101,
+115, 109, 97, 115, 32, 116, 101, 99, 108, 97, 115, 32, 113, 117, 101, 32, 102, 117, 110, 99, 105, 111, 110, 97,
+32, 101, 109, 32, 116, 111, 100, 111, 32, 108, 117, 103, 97, 114, 34, 10, 34, 123, 48, 125, 32, 105, 115, 32,
+117, 115, 101, 100, 32, 98, 121, 32, 123, 49, 125, 32, 105, 110, 32, 116, 104, 101, 32, 115, 97, 109, 101, 32,
+112, 108, 97, 99, 101, 46, 32, 65, 115, 115, 105, 103, 110, 32, 109, 111, 118, 101, 115, 32, 105, 116, 32, 104,
+101, 114, 101, 46, 34, 32, 61, 32, 34, 123, 48, 125, 32, 195, 169, 32, 117, 115, 97, 100, 111, 32, 112, 111,
+114, 32, 123, 49, 125, 32, 110, 111, 32, 109, 101, 115, 109, 111, 32, 108, 117, 103, 97, 114, 46, 32, 65, 116,
+114, 105, 98, 117, 105, 114, 32, 109, 111, 118, 101, 32, 112, 97, 114, 97, 32, 99, 195, 161, 46, 34, 10, 34,
+82, 101, 115, 101, 116, 32, 97, 108, 108, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 34, 32, 61, 32, 34,
+82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116, 97, 108, 104,
+111, 115, 34, 10, 34, 69, 118, 101, 114, 121, 32, 115, 104, 111, 114, 116, 99, 117, 116, 32, 103, 111, 101, 115,
+32, 98, 97, 99, 107, 32, 116, 111, 32, 76, 89, 78, 88, 39, 115, 32, 100, 101, 102, 97, 117, 108, 116, 32,
+107, 101, 121, 115, 46, 34, 32, 61, 32, 34, 84, 111, 100, 111, 115, 32, 111, 115, 32, 97, 116, 97, 108, 104,
+111, 115, 32, 118, 111, 108, 116, 97, 109, 32, 195, 160, 115, 32, 116, 101, 99, 108, 97, 115, 32, 112, 97, 100,
+114, 195, 163, 111, 32, 100, 111, 32, 76, 89, 78, 88, 46, 34, 10, 34, 82, 101, 115, 101, 116, 32, 97, 108,
+108, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 117, 100, 111, 34, 10, 34, 65,
+100, 100, 32, 115, 104, 111, 114, 116, 99, 117, 116, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97,
+114, 32, 97, 116, 97, 108, 104, 111, 34, 10, 34, 67, 104, 97, 110, 103, 101, 34, 32, 61, 32, 34, 65, 108,
+116, 101, 114, 97, 114, 34, 10, 34, 82, 101, 115, 101, 116, 32, 97, 108, 108, 46, 46, 46, 34, 32, 61, 32,
+34, 82, 101, 115, 116, 97, 117, 114, 97, 114, 32, 116, 117, 100, 111, 46, 46, 46, 34, 10, 34, 79, 112, 101,
+110, 32, 107, 101, 121, 115, 46, 106, 115, 111, 110, 34, 32, 61, 32, 34, 65, 98, 114, 105, 114, 32, 107, 101,
+121, 115, 46, 106, 115, 111, 110, 34, 10, 34, 65, 115, 115, 105, 103, 110, 32, 97, 110, 121, 119, 97, 121, 34,
+32, 61, 32, 34, 65, 116, 114, 105, 98, 117, 105, 114, 32, 109, 101, 115, 109, 111, 32, 97, 115, 115, 105, 109,
+34, 10, 34, 77, 97, 110, 97, 103, 101, 32, 115, 104, 111, 114, 116, 99, 117, 116, 115, 34, 32, 61, 32, 34,
+71, 101, 114, 101, 110, 99, 105, 97, 114, 32, 97, 116, 97, 108, 104, 111, 115, 34, 10, 34, 40, 111, 112, 101,
+110, 32, 97, 110, 32, 111, 117, 116, 112, 117, 116, 32, 100, 101, 118, 105, 99, 101, 32, 102, 105, 114, 115, 116,
+41, 34, 32, 61, 32, 34, 40, 97, 98, 114, 97, 32, 117, 109, 32, 100, 105, 115, 112, 111, 115, 105, 116, 105,
+118, 111, 32, 100, 101, 32, 115, 97, 195, 173, 100, 97, 32, 97, 110, 116, 101, 115, 41, 34, 10, 34, 40, 99,
+104, 111, 111, 115, 101, 41, 34, 32, 61, 32, 34, 40, 101, 115, 99, 111, 108, 104, 97, 41, 34, 10,
 };
 } // namespace lynx::i18n::data

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 745 - 75
src/ui/NoteToolDialogs.cpp


+ 12 - 5
src/ui/NoteToolDialogs.h

@@ -1,9 +1,10 @@
 #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.
+// Piano Roll note tool dialogs (docs/WORKFLOW_FL.md P2, R23; round 83): Strum, Arpeggiate, Flip, Randomise,
+// Scale levels, Limit, Quantize, Chop, Flam, LFO, Claw machine, Articulate, Riff machine and Chord progression.
+// Each is a small window whose controls preview live on the pattern (not in the history); Accept makes the change
+// one undo step, Cancel / closing puts the notes back.
+// The note maths lives in core/NoteTools and core/PianoRollTools.
 
 #include <cstdint>
 #include <memory>
@@ -15,9 +16,15 @@
 
 namespace lynx
 {
-enum class NoteTool { strum, arpeggiate, flip, randomise, scaleLevels, limit };
+enum class NoteTool
+{
+    strum, arpeggiate, flip, randomise, scaleLevels, limit,
+    quantize, chop, flam, lfo, claw, articulate, riffMachine, chordProgression
+};
 
 const char* noteToolTitle (NoteTool tool); // English, for tr()
+// Tools that write new notes and can open without any (riff machine, chord progression).
+bool noteToolGenerates (NoteTool tool) noexcept;
 
 // 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);

+ 14 - 1
src/ui/PianoRollComponent.cpp

@@ -5,6 +5,7 @@
 #include "core/NoteTools.h"
 #include "engine/MidiFileIo.h"
 #include "engine/Text.h"
+#include "ui/EventEditor.h"
 #include "ui/HintBar.h"
 #include "ui/I18n.h"
 #include "ui/Theme.h"
@@ -2333,6 +2334,18 @@ juce::PopupMenu PianoRollComponent::toolsMenu()
     for (const auto& [tool, key] : items)
         menu.addItem (tr (noteToolTitle (tool)) + "...\t" + key, [this, tool = tool] { openNoteTool (tool); });
 
+    // round 83: FL's quantizer, chopper, flamer, LFO, claw machine, articulator; riff machine, chord progression
+    menu.addSeparator();
+    for (auto tool : { NoteTool::quantize, NoteTool::chop, NoteTool::flam, NoteTool::lfo, NoteTool::claw, NoteTool::articulate })
+        menu.addItem (tr (noteToolTitle (tool)) + "...", [this, tool] { openNoteTool (tool); });
+    menu.addSeparator();
+    for (auto tool : { NoteTool::riffMachine, NoteTool::chordProgression })
+        menu.addItem (tr (noteToolTitle (tool)) + "...", [this, tool] { openNoteTool (tool); });
+    menu.addSeparator();
+    menu.addItem (tr ("Edit events..."), [this] {
+        openEventEditor (engine, { AutomationTargetKind::channelVolume, engine.getSelectedChannel() });
+    });
+
     return menu;
 }
 
@@ -2340,7 +2353,7 @@ void PianoRollComponent::openNoteTool (NoteTool tool)
 {
     const auto target = selectionOrAll();
 
-    if (target.empty())
+    if (target.empty() && ! noteToolGenerates (tool))
         return;
 
     showNoteTool (engine, tool, target, gridTicks(), [safe = juce::Component::SafePointer<PianoRollComponent> (this)] {

+ 452 - 0
tests/tests.cpp

@@ -35,6 +35,8 @@
 #include "core/FlWrapper.h"
 #include "core/FlPluginDb.h"
 #include "core/MissingFiles.h"
+#include "core/PianoRollTools.h"
+#include "core/EventEdit.h"
 #include "core/Preferences.h"
 #include "core/History.h"
 #include "core/Gms.h"
@@ -14237,4 +14239,454 @@ TEST (project_info_history_and_flp_import)
     CHECK (song.info.comments == "line 1\nline 2");
 }
 #include "UiFixTests.inc"
+
+// ---------------------------------------------------------------------------
+// Piano Roll tools of round 83 (expected values worked out from FL's formulas, docs/analise/REA_rodada83.md)
+
+namespace
+{
+lynx::Note prNote (std::int64_t start, std::int64_t length, int key = 60, float velocity = 100.0f / 128.0f)
+{
+    lynx::Note n;
+    n.start = start;
+    n.length = length;
+    n.key = key;
+    n.velocity = velocity;
+    return n;
+}
+
+std::vector<int> allOf (const lynx::Pattern& p)
+{
+    std::vector<int> v;
+    for (int i = 0; i < (int) p.notes.size(); ++i)
+        v.push_back (i);
+    return v;
+}
+} // namespace
+
+TEST (prtools_score_file)
+{
+    using namespace lynx::prtools;
+    FlpBuilder b (96);
+    b.ascii (0xC7, "20.9.0");
+    b.u8 (0x41); b.u16 (0);
+    auto notes = noteRecord (0, 0, 24, 60, 100);
+    auto n2 = noteRecord (48, 0, 24, 67, 64);
+    n2[19] = 4; // colour 4
+    notes.insert (notes.end(), n2.begin(), n2.end());
+    b.data (0xE0, notes);
+    const auto score = parseScore (b.bytes);
+    CHECK (score && score->notes.size() == 2);
+    if (score && score->notes.size() == 2)
+    {
+        CHECK (score->notes[0].start == 0 && score->notes[0].length == 240 && score->notes[0].key == 60);
+        CHECK (score->notes[1].start == 480 && score->notes[1].colour == 4 && score->notes[1].velocity == 0.5f);
+        CHECK (score->length() == 720);
+    }
+    CHECK (! parseScore (std::vector<std::uint8_t> { 1, 2, 3 }));
+
+    const auto grid = gridScore (240);
+    CHECK (grid.notes.size() == 4 && grid.length() == 960 && grid.notes[3].start == 720);
+    CHECK (gridScore (240, 1.0f).notes[1].start == 240 + 120);
+
+    if (! realFlpDir.empty()) // the installation's templates
+    {
+        std::ifstream f (realFlpDir + "/Patches/Scores/Quantization/Default.fsc", std::ios::binary);
+        std::vector<std::uint8_t> bytes ((std::istreambuf_iterator<char> (f)), {});
+        const auto fsc = parseScore (bytes);
+        CHECK (fsc && fsc->notes.size() == 16 && fsc->length() == 3840 && fsc->notes[1].start == 240);
+
+        // an old (FL 3.5, 20-byte records) chopping pattern with colour-3 notes, read as colour 12
+        std::ifstream g (realFlpDir + "/Patches/Scores/Chopping/Default.fsc", std::ios::binary);
+        std::vector<std::uint8_t> chopBytes ((std::istreambuf_iterator<char> (g)), {});
+        const auto chop = parseScore (chopBytes);
+        CHECK (chop && ! chop->notes.empty());
+    }
+}
+
+TEST (prtools_quantize)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    const auto grid = gridScore (240);
+
+    Pattern p;
+    p.notes = { prNote (1010, 500), prNote (1130, 100) };
+    QuantizeOptions o; // start strength 64/128, sensitivity 36 (180 ticks)
+    quantize (p, allOf (p), grid, o);
+    CHECK (p.notes[0].start == 985 && p.notes[0].length == 500); // 1010 - (50 * 64) / 128
+    CHECK (p.notes[1].start == 1165);                            // toward 1200: 1130 + (70 * 64) / 128
+
+    p.notes = { prNote (1010, 500), prNote (1130, 100) };
+    o.start = 1.0f;
+    o.sensitivity = 12; // 60 ticks: 1130 is 70 away from 1200
+    quantize (p, allOf (p), grid, o);
+    CHECK (p.notes[0].start == 960 && p.notes[1].start == 1130);
+
+    p.notes = { prNote (1010, 500) };
+    o.sensitivity = 36;
+    o.durationMode = QuantizeOptions::leaveEnd;
+    quantize (p, allOf (p), grid, o);
+    CHECK (p.notes[0].start == 960 && p.notes[0].length == 550); // the end (1509) stays
+
+    p.notes = { prNote (1010, 500) };
+    o.durationMode = QuantizeOptions::quantizeEnd;
+    o.duration = 1.0f;
+    quantize (p, allOf (p), grid, o);
+    CHECK (p.notes[0].start == 960 && p.notes[0].length == 1439 - 960 + 1); // end 1509 -> the nearest end 1439
+
+    // levels: a template velocity of 50/100 halves the velocity; 0 removes the note
+    Score half = grid;
+    for (auto& n : half.notes)
+        n.velocity = 50.0f / 128.0f;
+    p.notes = { prNote (960, 100, 60, 0.8f) };
+    o = {};
+    quantize (p, allOf (p), half, o);
+    CHECK (std::abs (p.notes[0].velocity - 0.4f) < 1e-5f);
+    for (auto& n : half.notes)
+        n.velocity = 0.0f;
+    quantize (p, allOf (p), half, o);
+    CHECK (p.notes.empty());
+}
+
+TEST (prtools_chop)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    Score pat;
+    pat.notes = { ScoreNote { 0, 240, 60 }, ScoreNote { 480, 240, 67 } }; // period 720
+
+    Pattern p;
+    p.notes = { prNote (0, 1920, 50) };
+    ChopOptions o;
+    chop (p, allOf (p), pat, o);
+    CHECK (p.notes.size() == 5);
+    if (p.notes.size() == 5)
+    {
+        CHECK (p.notes[0].start == 0 && p.notes[0].key == 50 && p.notes[1].start == 480 && p.notes[1].key == 57);
+        CHECK (p.notes[2].start == 720 && p.notes[3].start == 1200 && p.notes[4].start == 1440 && p.notes[4].length == 240);
+    }
+
+    // absolute: the pattern stays on the song grid; a piece before the note start is cut
+    p.notes = { prNote (100, 600, 50) };
+    chop (p, allOf (p), pat, o);
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 100 && p.notes[0].length == 140 && p.notes[1].start == 480);
+    o.absolute = false;
+    p.notes = { prNote (100, 600, 50) };
+    chop (p, allOf (p), pat, o);
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 100 && p.notes[0].length == 240 && p.notes[1].start == 580
+           && p.notes[1].length == 120);
+
+    // time mul x2 (wheel 5); colour 4 holds to the end in the first round only
+    o = {};
+    o.timeMul = 5;
+    p.notes = { prNote (0, 1920, 60) };
+    chop (p, allOf (p), pat, o);
+    CHECK (p.notes.size() == 3 && p.notes[1].start == 960 && p.notes[1].length == 480 && p.notes[2].start == 1440);
+    pat.notes[1].colour = 4;
+    o.timeMul = 4;
+    p.notes = { prNote (0, 1920, 60) };
+    chop (p, allOf (p), pat, o);
+    CHECK (p.notes.size() == 4 && p.notes[1].length == 1920 - 480 && p.notes[3].start == 1440);
+}
+
+TEST (prtools_flam)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    Pattern p;
+    p.notes = { prNote (960, 480, 60, 0.75f) };
+    flam (p, allOf (p), flamPreset (FlamPreset::doubleStroke), 120.0); // +1 step after
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 960 && p.notes[1].start == 1200 && p.notes[1].length == 480);
+    CHECK (std::abs (p.notes[1].velocity - 0.75f * 85.0f / 128.0f) < 1e-6f);
+
+    p.notes = { prNote (960, 480) };
+    flam (p, allOf (p), flamPreset (FlamPreset::earlyDoubleStroke), 120.0); // the flam one step before, shortened
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 720 && p.notes[0].length == 240 && p.notes[1].start == 960);
+
+    // absolute: -64 = -33.3 ms = -64 ticks at 120 BPM (960 PPQ); the original moves, the flam stays on the grid
+    CHECK (flamOffset (flamPreset (FlamPreset::flam), 120.0) == -64);
+    p.notes = { prNote (960, 480) };
+    flam (p, allOf (p), flamPreset (FlamPreset::flam), 120.0);
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 960 && p.notes[0].length == 64 && p.notes[1].start == 1024);
+    p.notes = { prNote (960, 480) };
+    flam (p, allOf (p), flamPreset (FlamPreset::earlyFlam), 120.0);
+    CHECK (p.notes.size() == 2 && p.notes[0].start == 896 && p.notes[1].start == 960 && p.notes[1].length == 480);
+}
+
+TEST (prtools_lfo)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    CHECK (lfoPeriod (20480) == 3840.0 && lfoPeriod (0) == 960.0 * 128 && lfoPeriod (40960) == 120.0);
+
+    LfoOptions o; // sine, phase 1/2: starts at the bottom (value 1/2, range 1/4)
+    const auto c = lfoCurve (o, 3840);
+    CHECK (std::abs (c[0] - 0.25f) < 1e-4f && std::abs (c[960] - 0.5f) < 1e-3f && std::abs (c[1920] - 0.75f) < 1e-3f);
+
+    o.shape = LfoOptions::square;
+    o.phase = 0; // phase 0.5: Round (0.5) = 0 (half to even) -> +1, then -1
+    const auto sq = lfoCurve (o, 3840);
+    CHECK (sq[0] == 0.75f && sq[10] == 0.25f && sq[2000] == 0.75f);
+
+    o = {};
+    o.useEnd = true;
+    o.endRange = 0; // the range fades out
+    const auto fade = lfoCurve (o, 3840);
+    CHECK (std::abs (fade[3839] - 0.5f) < 0.01f);
+
+    Pattern p;
+    p.notes = { prNote (0, 100), prNote (960, 100), prNote (1920, 100) };
+    lfo (p, allOf (p), notetools::Level::velocity, LfoOptions {});
+    CHECK (std::abs (p.notes[0].velocity - 0.25f) < 1e-4f && std::abs (p.notes[1].velocity - 0.5f) < 1e-3f
+           && std::abs (p.notes[2].velocity - 0.75f) < 1e-3f);
+}
+
+TEST (prtools_claw)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    ClawOptions o; // beat, trash the 4th quarter, stretch, remove short notes
+    Pattern p;
+    p.notes = { prNote (0, 240), prNote (960, 240), prNote (750, 100), prNote (1440, 240) };
+    claw (p, allOf (p), o);
+    CHECK (p.notes.size() == 3); // the note inside the trashed slice is gone
+    if (p.notes.size() == 3)
+    {
+        CHECK (p.notes[0].start == 0 && p.notes[0].length == 320);
+        CHECK (p.notes[1].start == 960 && p.notes[1].length == 320);
+        CHECK (p.notes[2].start == 1600 && p.notes[2].length == 320); // 1440 - 240 = 1200 -> x 4/3
+    }
+
+    o.trash = 9; // none: only the warp, which is neutral
+    p.notes = { prNote (100, 300) };
+    claw (p, allOf (p), o);
+    CHECK (p.notes.size() == 1 && p.notes[0].start == 100 && p.notes[0].length == 300);
+
+    o.timeDistortion = 1024; // strong bend: the period's ends stay, the middle moves
+    p.notes = { prNote (0, 480), prNote (960, 480) };
+    claw (p, allOf (p), o);
+    CHECK (p.notes[0].start == 0 && p.notes[1].start == 960 && p.notes[0].length > 480 && p.notes[1].length > 480);
+
+    o.trash = 0; // the first quarter
+    o.timeDistortion = 0;
+    o.stretch = false;
+    p.notes = { prNote (0, 240), prNote (240, 240) };
+    claw (p, allOf (p), o);
+    CHECK (p.notes.size() == 1 && p.notes[0].start == 0 && p.notes[0].length == 240);
+}
+
+TEST (prtools_articulate)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    Pattern p;
+    p.notes = { prNote (0, 100), prNote (480, 100), prNote (960, 100) };
+    articulate (p, allOf (p), articulatePreset (ArticulatePreset::legato), 4);
+    CHECK (p.notes[0].length == 480 && p.notes[1].length == 480 && p.notes[2].length == 3840 - 960); // to the bar line
+
+    p.notes = { prNote (0, 100), prNote (480, 100), prNote (960, 2880) };
+    articulate (p, allOf (p), articulatePreset (ArticulatePreset::staccato), 4);
+    CHECK (p.notes[0].length == 96 && p.notes[1].length == 96 && p.notes[2].length == 576); // ends on a bar: own length
+
+    auto o = articulatePreset (ArticulatePreset::legato);
+    o.gap = 20;
+    p.notes = { prNote (0, 100), prNote (480, 100) };
+    articulate (p, allOf (p), o, 4);
+    CHECK (p.notes[0].length == 460);
+
+    // chop chords: a held note is cut where the next one starts
+    p.notes = { prNote (0, 960, 48), prNote (480, 480, 60) };
+    articulate (p, allOf (p), articulatePreset (ArticulatePreset::chopChordsOnly), 4);
+    CHECK (p.notes.size() == 3 && p.notes[0].length == 480 && p.notes[1].start == 480 && p.notes[2].start == 480);
+
+    // variation is seeded (MT19937): same seed, same result; lengths only get shorter
+    o = articulatePreset (ArticulatePreset::legato);
+    o.variation = 50;
+    o.seed = 7;
+    Pattern a, b2;
+    a.notes = b2.notes = { prNote (0, 100), prNote (480, 100), prNote (960, 100) };
+    articulate (a, allOf (a), o, 4);
+    articulate (b2, allOf (b2), o, 4);
+    CHECK (a.notes[0].length == b2.notes[0].length && a.notes[0].length <= 480 && a.notes[0].length >= 240);
+}
+
+TEST (prtools_chords)
+{
+    using namespace lynx::prtools;
+    auto c = parseProgression ("I-V-vi-IV", 0, false);
+    CHECK (c && c->size() == 4);
+    if (c && c->size() == 4)
+    {
+        CHECK ((*c)[0].root == 0 && (*c)[1].root == 7 && (*c)[2].root == 9 && (*c)[3].root == 5);
+        CHECK ((*c)[2].intervals == std::vector<int> ({ 0, 3, 7 }) && chordName ((*c)[2]) == "Am");
+    }
+
+    c = parseProgression ("ii 7-V 7-I \xE2\x88\x86-IV/\xE2\x99\xADVII", 0, false);
+    CHECK (c && c->size() == 4);
+    if (c && c->size() == 4)
+    {
+        CHECK ((*c)[0].intervals == std::vector<int> ({ 0, 3, 7, 10 }) && chordName ((*c)[0]) == "Dm7");
+        CHECK ((*c)[2].intervals == std::vector<int> ({ 0, 4, 7, 11 }) && chordName ((*c)[2]) == "Cmaj7");
+        CHECK ((*c)[3].root == 5 && (*c)[3].bass == 10 && chordName ((*c)[3]) == "F/A#");
+    }
+
+    c = parseProgression ("i-v-\xE2\x99\xADVI-iv", 9, true); // A minor: Am Em F Dm
+    CHECK (c && c->size() == 4 && (*c)[2].root == 5 && (*c)[3].root == 2 && (*c)[1].intervals[1] == 3);
+    CHECK (parseProgression ("Isus2 add9", 0, false) && parseProgression ("Isus2 add9", 0, false)->front().intervals
+                                                             == std::vector<int> ({ 0, 2, 7, 14 }));
+    CHECK (! parseProgression ("I-X-V", 0, false));
+
+    const auto presets = parseProgressionPresets ("-Major\r\n\r\nI-V-vi-IV: Hopeful\r\nI-vi-IV-V: Optimistic\r\n\r\n-Minor\r\n\r\ni-iv-v-i\r\n");
+    CHECK (presets.size() == 3 && presets[0].numerals == "I-V-vi-IV" && ! presets[0].minor && presets[2].minor);
+
+    const auto rhythms = parseRhythmPresets ("Default,4,>,-,-,-,>,-,-,-,>,-,-,-,>,-,-,-\nRandom 1,4,r,16,2,1.5\n");
+    CHECK (rhythms.size() == 1 && rhythms[0].cells == ">--->--->--->---");
+
+    const auto g = generateProgression (0, false, 8, 0.3f, 5);
+    CHECK (g.size() == 8 && g[0].root == 0 && g == generateProgression (0, false, 8, 0.3f, 5));
+    for (std::uint32_t seed = 1; seed < 40; ++seed) // numerals read back as the same chords
+    {
+        const auto gen = generateProgression (2, seed % 2 == 0, 8, 1.0f, seed);
+        const auto back = parseProgression (toNumerals (gen, 2), 2, seed % 2 == 0);
+        CHECK (back && *back == gen);
+    }
+    CHECK (toNumerals (*parseProgression ("I-V-vi-IV/bVII", 0, false), 0) == "I-V-vi-IV/bVII");
+
+    lynx::Pattern p;
+    const auto chords = *parseProgression ("I-IV", 0, false);
+    ChordWriteOptions w;
+    const auto added = writeProgression (p, 2, 0, chords, w);
+    CHECK (added.size() == 8 && p.notes.size() == 8 && p.notes[0].channel == 2);
+    CHECK (std::any_of (p.notes.begin(), p.notes.end(), [] (auto& n) { return n.key == 48; })); // bass C3
+    w.rhythm = ">-`->-`->-`->-`-";
+    lynx::Pattern r;
+    writeProgression (r, 0, 0, chords, w);
+    CHECK (r.notes.size() == 8 && r.notes[0].length == 1920); // '>' + '-' of 960-tick cells
+}
+
+TEST (prtools_riff_machine)
+{
+    using namespace lynx;
+    using namespace lynx::prtools;
+    Pattern p;
+    p.notes = { prNote (0, 100, 70) };
+    p.notes[0].channel = 1;
+    RiffOptions o;
+    o.channel = 1;
+    o.bars = 2;
+    const auto notes = riffMachine (p, { 0 }, o, 4);
+    CHECK (! notes.empty() && notes.size() == p.notes.size());
+    CHECK (std::all_of (p.notes.begin(), p.notes.end(), [] (auto& n) {
+        return n.channel == 1 && n.start >= 0 && n.start < 2 * 3840 && n.key >= 36 && n.key <= 84;
+    }));
+
+    // only the first step: the progression shape, chopped from one note at key 48
+    o.stepsUpTo = 0;
+    Pattern q;
+    const auto first = riffMachine (q, {}, o, 4);
+    CHECK (first.size() == builtInRiffProgression (0).notes.size() * 2 && q.notes[0].key == 48);
+}
+
+TEST (event_editor_lanes)
+{
+    using namespace lynx;
+    Pattern p;
+    const AutomationTarget vol { AutomationTargetKind::channelVolume, 2 };
+    auto& lane = eventedit::laneFor (p, vol);
+    CHECK (p.events.size() == 1 && &eventedit::laneFor (p, vol) == &lane && eventedit::findLane (p, { AutomationTargetKind::channelPan, 2 }) == nullptr);
+
+    eventedit::fill (lane, 0, 960, 0.25f, 240);
+    CHECK (lane.events.size() == 4 && lane.events[3].tick == 720 && lane.events[3].value == 0.25f);
+    CHECK (lane.valueAt (-5.0) == 0.25f && lane.valueAt (5000.0) == 0.25f);
+
+    eventedit::line (lane, 960, 1920, 0.0f, 1.0f, 240); // 4 cells: 0, 1/3, 2/3, 1
+    CHECK (lane.events.size() == 8 && lane.events[4].value == 0.0f && lane.events[7].value == 1.0f);
+    CHECK (std::abs (lane.valueAt (1500.0) - 2.0f / 3.0f) < 1e-6f); // held from 1440
+
+    eventedit::setEvent (lane, 1440, 0.1f);
+    CHECK (lane.events.size() == 8 && lane.valueAt (1440.0) == 0.1f);
+    eventedit::setEvent (lane, 100, 0.9f);
+    CHECK (lane.events.size() == 9 && lane.events[1].tick == 100);
+
+    eventedit::scale (lane, 0, 960, 2.0f, 0.0f, false);
+    CHECK (lane.events[0].value == 0.5f && lane.events[1].value == 1.0f); // clamped
+    eventedit::scale (lane, 0, 960, 0.0f, 0.0f, true); // bipolar: toward the centre
+    CHECK (lane.events[0].value == 0.5f && lane.events[2].value == 0.5f);
+
+    eventedit::erase (lane, 0, 960);
+    CHECK (lane.events.size() == 4 && lane.events.front().tick == 960);
+
+    auto copy = lane;
+    eventedit::randomize (lane, 0, 4000, 0.2f, 3);
+    eventedit::randomize (copy, 0, 4000, 0.2f, 3);
+    CHECK (lane.events[1].value == copy.events[1].value && std::abs (lane.events[1].value - 1.0f / 3.0f) <= 0.2f + 1e-6f);
+
+    prtools::LfoOptions o;
+    eventedit::applyLfo (lane, 0, 3840, o, 960); // FL's LFO: bottom, middle, top, middle
+    CHECK (lane.events.size() == 4 && std::abs (lane.events[0].value - 0.25f) < 1e-4f && std::abs (lane.events[2].value - 0.75f) < 1e-3f);
+
+    p.events.push_back ({ { AutomationTargetKind::channelPan, 1 }, {} });
+    eventedit::removeEmptyLanes (p);
+    CHECK (p.events.size() == 1);
+
+    // undo label
+    auto before = Song::makeDefault();
+    auto after = before;
+    after.patterns[0].events.push_back ({ vol, { { 0, 0.5f } } });
+    CHECK (describeChangeText (before, after) == "Edit events: " + after.patterns[0].name);
+
+    // channel removal re-targets the lanes like automations
+    auto song = Song::makeDefault();
+    song.patterns[0].events.push_back ({ { AutomationTargetKind::channelVolume, 3 }, { { 0, 0.5f } } });
+    song.removeChannel (1);
+    CHECK (song.patterns[0].events[0].target.index == 2);
+}
+
+TEST (event_editor_playback)
+{
+    // pattern events on the Master volume: silent first half of each pattern, sound in the second half
+    auto song = lynx::Song::makeDefault();
+    song.bpm = 120.0;
+    const auto bar = (std::int64_t) lynx::ppq * 4;
+    song.patterns[0].lengthTicks = bar;
+    song.patterns[0].notes.clear();
+    for (int s = 0; s < 16; ++s)
+        song.patterns[0].notes.push_back ({ s * 240, 200, 0, 60 });
+    song.patterns[0].events.push_back ({ { lynx::AutomationTargetKind::mixerVolume, 0 }, { { 0, 0.0f }, { bar / 2, 0.8f } } });
+
+    const auto peaks = [&] (lynx::PlayMode mode) {
+        song.mode = mode;
+        song.playlist.clear();
+        song.playlist.push_back ({ 0, 0, bar, bar, 0 }); // one clip, in the second bar
+        const double sr = 48000.0;
+        auto state = lynx::RackState::build (song, nullptr, sr);
+        lynx::RackRenderer r;
+        r.prepare (sr, 512);
+        std::vector<float> l (512), rr (512);
+        const auto tps = lynx::ticksPerSample (song.bpm, sr);
+        std::array<float, 6> peak {}; // half bars
+        for (double tick = 0.0; tick < (double) (bar * 3); tick += 512 * tps)
+        {
+            r.process (state.get(), true, tick, 512, l.data(), rr.data());
+            // blocks inside a half bar, away from its edges (the gain glides over one chunk at a change)
+            const auto blockEnd = tick + 512 * tps;
+            const auto half = (std::size_t) (tick / (double) (bar / 2));
+            const auto edge = (double) half * (double) (bar / 2);
+            if (half > 5 || tick - edge < 2 * 512 * tps || blockEnd > edge + (double) (bar / 2))
+                continue;
+            for (auto v : l)
+                peak[half] = std::max (peak[half], std::abs (v));
+        }
+        return std::make_pair (state->eventLanes.size(), peak);
+    };
+
+    const auto [lanesSong, song3] = peaks (lynx::PlayMode::song);
+    CHECK (lanesSong == 1);
+    CHECK (song3[2] < 1.0e-4f && song3[3] > 0.01f); // inside the clip: silent, then sound
+
+    const auto [lanesPattern, loop] = peaks (lynx::PlayMode::pattern);
+    CHECK (lanesPattern == 1);
+    CHECK (loop[0] < 1.0e-4f && loop[1] > 0.01f && loop[2] < 1.0e-4f && loop[3] > 0.01f);
+}
 #include "PrefsTests.inc"

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio