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

Merge origin/main into feature/extfx164

Ka1-S 1 месяц назад
Родитель
Сommit
daf6fabd93

+ 81 - 0
docs/analise/REA_rodada164e-clippitch.md

@@ -0,0 +1,81 @@
+# Round 164e (misc164p): FL audio clip pitch import, checked against FL
+
+2026-10-27. Round 163c (REA_rodada163c-pitch.md) stopped applying an FL audio clip channel's header pitch and root note
+on an unchecked assumption, and FL's time-stretch PITCH knob was never read. This round measured what FL really does.
+Evidence markers: [FL] rendered by FL Studio 2026 (`FL64.exe /R /Ewav`) and measured; [CODE] LYNX source; [TEST]
+tests/ClipPitch164Tests.inc; [WIN] LYNX Windows build (`LYNX.exe --render`).
+
+## 1. Method
+
+- Test projects: a small FL 25.2 project (one Sampler, two audio clip channels, no effects) used as a template; a script
+  (tmp/misc164p/mk.py, mk2.py) rewrites the second audio clip channel: sample = a 2 s 440 Hz sine
+  (C:\Users\kauan\lynx-test\misc164p\sine440.wav), header pitch (0xDB +8), root note (0x87), fine tune (0x8E), the
+  0xD7 time-stretch fields (TIME +0x60, PITCH +0x64, MUL +0x68, MODE +0x6C), one Playlist audio clip of 6 beats at
+  86 BPM; mk2.py makes the same channel a Sampler channel played by a pattern note instead.
+- FL renders each one from the command line (FL lock held, minutes); pitch = interpolated FFT peak of the steady part,
+  length = while above 30% of the peak (tmp/misc164p/meas.py). Projects and renders: C:\Users\kauan\lynx-test\misc164p
+  (copy on D:\lynx-work\misc164p).
+- 0xD7 layout (matches the public PyFLP description): +0x60 TIME, +0x64 PITCH (cents, signed), +0x68 MUL
+  (2^(v/10000)), +0x6C MODE (0 Resample, -1 Stretch, 1, 2, 5 … élastique / auto modes).
+
+## 2. What FL does [FL]
+
+| case (audio clip unless noted) | FL pitch (cents) | FL length (s) |
+|---|---|---|
+| base | 0.0 | 2.000 |
+| header pitch +400 / -300 | +400.0 / -300.0 | 1.587 / 2.378 |
+| root note 48 / 67 | +1200.0 / -700.0 | 1.000 / 2.996 |
+| fine tune +50 | +50.0 | 1.943 |
+| stretch PITCH +700, Resample | 0.0 (ignored) | 2.000 |
+| stretch PITCH -1200, Resample | 0.0 (ignored) | 2.000 |
+| stretch PITCH +700, modes -1 / 1 / 2 / 5 | +698.4 / +699.7 / +694.6 / +699.7 | 2.000 |
+| header +400, Stretch mode | +398.1 | 2.000 |
+| header +400 + PITCH +700, Resample / Stretch | +400.0 / +1099.6 | 1.587 / 2.004 |
+| root 67, Stretch / fine +50, Stretch | -701.3 / +48.1 | 2.001 / 1.999 |
+| TIME 1 beat, Resample / Stretch + PITCH +700 | +1823 (2 s squeezed) / +696.7 | 0.698 / 0.692 |
+| MUL x2 without TIME, Resample / Stretch | -1200.0 / -0.5 | 4.000 / 4.004 |
+| Sampler channel, key C5: PITCH +700 Resample / Stretch | 0.0 / +698.4 | 2.000 / 2.000 |
+| Sampler channel: header +400 Stretch; key G5 Resample / Stretch | +398.1; +700.0 / +698.4 | 2.000; 1.335 / 2.000 |
+| Sampler channel: MUL x2, Resample / Stretch | -1200.0 / -0.5 | 4.000 / 4.004 |
+
+So an audio clip plays like a C5 note of its channel: header pitch, root note and fine tune all transpose it. Every
+mode but Resample keeps the length (also without a TIME) and adds the PITCH knob; Resample ignores the PITCH knob.
+MUL without a TIME stretches the sample by 2^(MUL/10000). Sampler channels follow the same rules.
+
+## 3. Changes
+
+- `src/flp/Flp.*`: reads the PITCH knob (0xD7 +0x64, `stretchPitch`).
+- `src/core/FlpImport.cpp`: the round-163 line that zeroed an audio clip channel's pitch is gone (header pitch + root
+  note reach it again); new `applyFlStretchPanel` for Sampler and audio clip channels: a non-Resample mode turns on
+  "keep length" (with its stretch method) and adds the PITCH knob; MUL without TIME becomes a stretch in beats at the
+  project tempo (needs the sample's length: new `FlpImportOptions::sampleSeconds`, filled by AudioEngine from the
+  decoded sample, which the rack reuses).
+- [TEST] `c164p_fl_clip_and_sampler_pitch_import` (every row of §2 as an import case), `c164p_stretch_panel_rules`.
+
+## 4. LYNX against FL [WIN]
+
+Windows build (build-win-misc164p), `LYNX.exe --render <case>.flp out.wav 5` on the same FL test projects, measured the
+same way. Every case of §2 now matches FL: pitch within FL's own stretcher error (FL: +694.6…+699.7 cents for +700 in
+the stretch modes, LYNX +700.0) and length within 6 ms (MUL x2: FL 4.000 / 4.004 s, LYNX 4.000 / 3.999 s). The 0.1.18
+build played all audio clip cases at 0 cents (header pitch, root note, stretch PITCH, MUL all ignored) and the
+Sampler-channel stretch PITCH / MUL cases at 0 cents. Table: D:\lynx-work\misc164p\lengths.txt, renders in
+D:\lynx-work\misc164p\renders.
+
+FL demo projects, FL render vs LYNX render, mean 1 s chroma cosine (60 Hz–4 kHz, windows with sound):
+
+| demo | 0.1.18 | now |
+|---|---|---|
+| NewStuff (31 pitched audio clips: stretch PITCH ±1200, Stretch mode) | 0.818 (71/236 windows < 0.8) | 0.938 (13/236) |
+| Asher Postman - Future House (header pitch +400, Auto mode + MUL) | 0.693 | 0.700 |
+| Astes - Bien Duro (stretch PITCH ±1200 on vocals, E3 modes) | 0.763 | 0.768 |
+
+(The last two differ from FL for other reasons — synths, effects — the pitch import only moves them closer.)
+
+Cost: loading NewStuff 4.5 s (0.1.18: 6.4 s); rendering its 240 s took 99 s instead of 38 s because 17 clip channels
+now run the per-voice pitch shifter keeping their length, as FL does (FL itself took 151 s for the render).
+
+## Where I stopped
+
+- Done and verified (§2–§4); build-local with FL Data 0 failures.
+- Not done: FL's main pitch on audio clips (LYNX: clips don't follow it) was not measured; MUL without TIME is turned
+  into beats at the project's starting tempo (FL's is probably tempo-free — a later tempo change in LYNX stretches it).

+ 67 - 0
docs/analise/REA_rodada164e-modwheel.md

@@ -0,0 +1,67 @@
+# Round 164e (misc164m): the mod wheel and aftertouch on native instruments
+
+2026-10-27. Brief: "LYNX's Sampler, Synth and the FL-engine instruments respond to CC1 (and aftertouch) where FL's do
+(sampler162 left it plugin-only) — map like FL does per instrument". Evidence markers: [DECOMP] disassembly /
+decompilation of FL's own DLLs (objdump, Ghidra 12 headless, our scripts in tmp/misc164m/gh); [EXEC] FL's DLLs loaded
+unmodified by our own harness (tmp/misc164m/run/mi.c, from round 41's ms.c: CreatePlugInstance with a fake host that
+logs every host Dispatcher call, `midi=<n>,<msg>` calls the plugin's MIDIIn); [STR] strings; [DOC] web; [TEST] tests in
+tests/Misc164mTests.inc.
+
+## 1. How FL gets a controller's mod wheel to a plugin
+
+- FL's plugin SDK: a plugin receives raw MIDI (CCs, channel pressure) only through `TFruityPlug::MIDIIn` (vtable slot
+  16), and only after asking for it with the host dispatcher `FHD_WantMIDIInput` (id 5, "switch in Value"). Notes come
+  through TriggerVoice, the channel pitch / pitch wheel through the voice's Final.Pitch.
+- [EXEC] At creation, FL's **Fruity Wrapper** (VST/VST3/CLAP host) calls host dispatcher 5; the Patcher implements
+  MIDIIn. No native generator calls 5 (logged for MiniSynth, GMS, Morphine, Toxic Biohazard, Sawer, Sakura, PoiZone,
+  DirectWave, FL Slayer, 3x Osc, Wasp).
+- [DECOMP] MIDIIn (slot 16) of every Delphi generator shell (VMT found from CreatePlugInstance, tmp script
+  `midiin.py`): **abstract** (Delphi's abstract-error stub) for 3x Osc, Autogun, BassDrum, BeepMap, Drumaxx, Drumpad,
+  FL Keys, FLEX, FPC, Fruit Kick, Fruity DX10, DrumSynth Live, Granulizer, Slicer, Slicer 2, Slicex, Harmless, Harmor,
+  Kepler, Kepler Exo, MIDI Out, Ogun, Plucked!, PoiZone, Sakura, SoundFont Player, Sytrus, Transistor Bass, Wave
+  Traveller (calling it would raise run-time error 210, so FL never does). Implemented: Fruity Wrapper, Patcher,
+  ReWired, Wasp / Wasp XT, Sawer (it hands the message to its engine).
+- [DECOMP] The C++ "framework" generators (MiniSynth, GMS, Morphine, Toxic Biohazard, and the engines behind Sawer /
+  PoiZone / Sakura) have a MIDIIn and a CC table (value / 127 at `+0x1268`, pressure at `+0x166c`, the per-plugin CC
+  handlers: MiniSynth CC 1 → mod wheel `+0x39d8`, GMS CC 1 → `+0x3a14`, Toxic/Sawer/PoiZone sustain / reset /
+  MIDI-learn), but the request for MIDI input (`Dispatcher(5, 0, 1)`) and the forwarding to the engine are gated by a
+  module flag (`+0x52b`) that is 0 in FL's generator builds (`+0x52a` = 0 = generator: plugin flags 0x200011).
+- [EXEC] Even when MIDIIn is called directly with CC 1 = 127 and channel pressure 64, the engine's CC table entry and
+  pressure stay 0 (MiniSynth, GMS, Morphine, Toxic Biohazard: engine at shell `+0x228`, proved by the note's velocity
+  100/127 = 0.7874 landing in its velocity table) — the generator path only forwards notes to the shell's keyboard.
+- [STR] FL's remote-control targets include "Omni - Mod wheel (Wrapper)" (FLEngine_x64.dll): the focused **wrapper**'s
+  mod wheel. [DOC] Novation's FLkey notes and the Image-Line forum ("every single native synth ignores the mod wheel")
+  agree: CC 1 has no default function in FL; it is linked by hand (right-click a control › Link to controller).
+
+**Conclusion.** In FL 2026 no native generator — Sampler / audio clips (channel), 3x Osc, Sytrus, Harmor, Harmless,
+GMS, Morphine, MiniSynth, PoiZone, Toxic Biohazard, Sakura, Sawer, DirectWave, FL Slayer, DX10, Kepler, Ogun, Transistor
+Bass, the drum generators… — responds to the mod wheel or to aftertouch by itself. Their engines' "mod wheel" /
+"aftertouch" sources (Sakura's matrix, GMS's matrix rows, PoiZone's MW destination, Toxic's and Sawer's MIDI matrix,
+DirectWave's "Mod Wheel" source, DX10's mod wheel) are fed in FL only by their own on-screen controls / automation
+(PoiZone's wheel = parameter 157, Slayer's = parameter 28) or stay 0. LYNX already behaves the same: its native engines
+ignore CC 1 / pressure (`Instrument::controlChange` default), hosted plugins get the raw message (round 162c), and
+"Link to MIDI controller" (any knob's right-click) is FL's way to put the mod wheel on a native parameter.
+
+## 2. What changed
+
+- **Patcher** (`src/core/Patcher.*`): FL's Patcher implements MIDIIn and passes MIDI to the plugins inside; LYNX's
+  Patcher passed the live notes but dropped the mod wheel, the other CCs, channel pressure and the pitch wheel. Now
+  `PatcherInstrument::midiMessage / pitchBend / controlChange` reach the instruments cabled to "From LYNX" notes (a
+  VST inside a Patcher gets its mod wheel and aftertouch; LYNX's Sampler / Synth inside bend by the channel's range).
+  [TEST `misc164m_patcher_passes_live_controllers_to_its_instruments`]
+- Native engines unchanged on purpose. [TEST `misc164m_native_engines_keep_ignoring_the_mod_wheel_like_fl`: a Sakura
+  patch with mod wheel → level keeps the wheel at 0 whatever CC 1 does.]
+
+## 3. Not done / notes
+
+- LYNX's SoundFont player moves its "Mod wheel" knob from a live CC 1 (round 158 choice). FL's SoundFont Player has
+  no MIDI input (MIDIIn abstract), so this is a LYNX extra, left as it is.
+- The sustain pedal (CC 64) is not handled for LYNX's native instruments; FL's channel handles it on the host side
+  (not checked in this round).
+- Not checked with FL running and a real controller: this PC has no MIDI loopback (Windows MIDI Services runs but no
+  loopback endpoint exists; installing one needs the user). The evidence is the code path above and the harness runs.
+
+## Where I stopped
+
+- Done: research (above), Patcher forwarding + tests (commit 8e2c1df0). [VERIFIED] build-local with FL Data: 1757356 checks, 0 failures (both misc164m tests ran); Windows build (build-win-misc164m) OK.
+- Next round, if wanted: sustain pedal (CC64) on native instruments needs its own FL check first; a live FL MIDI test needs a loopback MIDI device on the machine.

+ 83 - 0
docs/analise/REA_rodada164e.md

@@ -0,0 +1,83 @@
+# Round 164e (misc164) — Browser folders window, content filter hides empty folders, Mixer knobs vs EQ, fixed-size windows taller than the screen, Linux check
+
+2026-10-27. What 0.1.18 left over (tmp/round164-brief.md "r164e misc164"). Two parts went to sub-rounds with their own docs:
+mod wheel / aftertouch on the native instruments → REA_rodada164e-modwheel.md (misc164m); FL audio clip pitch import →
+REA_rodada164e-clippitch.md (misc164p). Evidence markers: [CODE] LYNX source; [TEST] tests/Misc164Tests.inc
+(build-local); [LIN] Linux build in WSL (WSLg), screenshots; [WIN] Windows build.
+
+## 1. Browser: "Show folders..." window
+- Before [CODE]: *Show folders* was a checklist sub-menu (one click per folder, the menu closes each time); a folder
+  the user added could not be taken out again (only hidden).
+- Now: the options button beside the search box (and the folder menu's *Browser* sub-menu) › *Show folders...* opens
+  a window per Browser (main / Sample browser, key `browser-folders` / `sample-browser-folders`): every entry with a
+  tick (applies at once; the whole row is clickable), its path under the name, *Current project* and *Plugin
+  database* first; the user's own folders say "(your folder)" and have an × (*Remove this folder from the Browsers*,
+  the folder stays on disk); *Add folder...*, *Show all*, *Close*. Under a content filter the window says that folders
+  with nothing of that kind are left out and marks each root that has nothing to list. A user folder can also be
+  removed from its right-click menu. The window follows changes made elsewhere (right-click › Hide, filter).
+- Snapshot `-browser-folders.png` [LIN].
+
+## 2. The content filter leaves out folders with nothing to list
+- Before [CODE]: with *Show: Samples and SoundFonts* (or Audio / Presets / Projects) every folder was still listed,
+  many of them empty once opened.
+- Now: a folder (and a top-level folder) whose tree holds no file of that kind is left out. The answer comes from the
+  Browser's search index (round 162: it already lists every folder's usable files), never from the disk while
+  drawing: `search::Index::folderMatches` marks every indexed folder that holds a matching file at any depth (and its
+  parents), and the folders of completely walked trees that hold none. `search::Service::folderMatches` caches it per
+  filter until the index changes (`Index::generation`), and only `try_lock`s the index: while the background worker
+  holds it, the last answer is used — no UI stall. A folder the index doesn't know yet (never indexed, or its tree not
+  walked to the end) stays listed. When the index changes (start-up pass, refresh, a search's re-check), the open tree
+  drops the folders found empty, keeping what is open and selected (`FileTree::pruneFolders`).
+- Cost: one pass over the index per filter and index change (string extension checks; tens of thousands of files are
+  a few ms), on the message thread only when the filter or index changed.
+- [TEST] `misc164_browser_filter_hides_empty_folders` (unknown before the tree is complete; samples keep the parents of
+  a deep SoundFont; presets / projects; a file arriving changes the generation and the answer; Windows drive roots).
+- Snapshots `-browser164-all.png`, `-browser164-samples.png`, `-browser164-projects.png` (a small library made by the
+  snapshot: Drums/Kicks, Keys, Presets/Synth, Projects/MIDI, Notes, Empty/Nothing).
+
+## 3. Mixer: the selected effect's knobs no longer cut by the EQ
+- Before [CODE]: `EffectsPanel::neededHeight` counted the slots and the effect's title row only, so at medium heights
+  (e.g. 680 px, UI zoom 150 %) the EQ stayed open and the clip region cut the knobs' names and values.
+- Now the panel's needed height includes the selected effect's controls (knob grid at its shortest rows, the volume
+  gate's steps, the vocoder's band levels, LYNX Tune's keys, the parametric / Facet EQ curve, the plugin button,
+  the parallel container's branches): when they and the open EQ don't both fit, the EQ folds; when even that
+  doesn't fit, the panel scrolls (ui163's rule). Selecting another effect refits it (EffectsPanel timer, only when
+  the slot or its kind changed).
+- [LIN] `-mixer163-450/560/680/820.png`: 680 now folds the EQ with Ceiling / Gain / Release names and values whole;
+  820 keeps the EQ open below them; 450 scrolls.
+
+## 4. Fixed-size windows taller than the screen
+- Before [CODE]: ui163's `fitWindowOnScreen` shrinks resizable windows; a fixed-size one (every tool window: Settings,
+  New project, Clip properties, Plugin manager, Shortcuts...; Export, Customize toolbar, crash report dialogs) only
+  moved so its title bar is on the screen — its bottom (OK / Accept buttons) stayed below the screen.
+- Now `fitContentToScreen` (ui/WindowOwner) puts such a content into a scrolling viewport the size of the usable
+  screen minus the window frame (the window's own frame once on screen, else another LYNX window's, else 32/8 px),
+  and follows the content's later size changes; content that fits is untouched (no wrapper). Used by
+  `openToolWindow` and the three fixed-size `DialogWindow`s. Size rule `windowfit::scrollFit` (core/WindowFit.h).
+- [TEST] `misc164_fixed_window_scrolls_when_taller_than_the_screen`. `--fittest` got a step for it (a 520 x
+  screen+300 px tool window must fit whole, its content in a viewport); `LYNX_FITTEST_MS` keeps each window longer
+  for screenshots.
+
+## 5. Linux check of ui163's window fitting [LIN]
+- WSLg (Weston + XWayland), 1920x1080, `LYNX --fittest` at 100 / 150 / 200 %, screenshots taken from Windows
+  (D:\lynx-work\misc164\lin-fit-*.png): the tall tool window's title bar and close button are on the screen, the
+  fixed-size tool window fits with a scroll bar, the resizable window shrinks after the zoom change.
+- Finding: Weston reports its invisible drop shadow in the frame size (`_NET_FRAME_EXTENTS`: 59 px top, 38 px on
+  each side at 100 %), so the old `--fittest` check said FAIL while the windows were visibly fine. The check now
+  subtracts such a shadow on Linux (a frame side ≥ 16 px) and allows 4 px. The fit itself treats the shadow as frame,
+  which only makes windows a little smaller than necessary there.
+
+## Verification
+- build-local with FL Data: 0 failures (tests above). Linux GUI build in WSL (build-linux, WSLg) and Windows build
+  (build-win-misc164).
+- [WIN] `--fittest` at 150 % and 200 % on the real 1920x1080 desktop: all OK (the fixed-size tool window lands at
+  548x688 at 150 %, i.e. the whole work area, with its content in a viewport). `--snapshot`:
+  D:\lynx-work\misc164\win\snap\w-browser-folders.png, w-browser164-*.png, w-mixer163-*.png.
+- [LIN] `--fittest` at 100 / 150 % OK; at 200 % the check still says FAIL by a few px while the screenshot
+  (D:\lynx-work\misc164\lin200-fixed.png) shows title bar, close button and bottom on the screen — WSLg's frame
+  extents don't follow JUCE's scale; a measurement artifact, noted. Snapshots in D:\lynx-work\misc164\linsnap.
+
+## Where I stopped
+- All five items done (1–4 here, mod wheel and clip pitch in their sub-round docs). Landing as misc164.
+- Not done: the fixed-size windows are fitted when they open (and when their content changes size), not again when
+  the UI zoom changes while they are open (close and reopen them).

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

@@ -4868,3 +4868,22 @@ countries: br
 "Delay compensated (PDC)" = "Atraso compensado (PDC)"
 "Round trip: {0} samples" = "Ida e volta: {0} amostras"
 "Ping" = "Ping"
+
+# round 164e (misc164): Browser folders window
+"Show folders..." = "Mostrar pastas..."
+"Remove this folder from the Browsers" = "Remover esta pasta dos Browsers"
+"Add one of your own folders to the Browsers (samples, projects, SoundFonts...)" = "Adicionar uma pasta sua aos Browsers (samples, projetos, SoundFonts...)"
+"Show all" = "Mostrar todas"
+"Tick every folder" = "Marcar todas as pastas"
+"Folders shown in the Sample browser" = "Pastas mostradas no Browser de samples"
+"Folders shown in the Browser" = "Pastas mostradas no Browser"
+"Untick what you don't use: it leaves this Browser and its searches. Nothing is deleted." = "Desmarque o que você não usa: sai deste Browser e das buscas dele. Nada é apagado."
+"Listing \"{0}\": folders with nothing of that kind are left out of the tree." = "Listando \"{0}\": pastas sem nada desse tipo ficam fora da árvore."
+"Shown: untick to hide it from this Browser" = "Mostrada: desmarque para ocultá-la deste Browser"
+"Hidden: tick to show it" = "Oculta: marque para mostrá-la"
+"Remove this folder from the Browsers (the folder itself stays on the disk)" = "Remover esta pasta dos Browsers (a pasta continua no disco)"
+"(your folder)" = "(sua pasta)"
+"nothing to list under the filter" = "nada para listar com o filtro"
+"the project's patterns, channels, samples and history" = "patterns, canais, samples e histórico do projeto"
+"LYNX's, FL's and your installed plugins" = "plugins do LYNX, do FL e os que você instalou"
+"Sample browser folders" = "Pastas do Browser de samples"

+ 60 - 6
src/Main.cpp

@@ -2267,11 +2267,20 @@ private:
                 if (auto* peer = w.getPeer())
                     if (const auto f = peer->getFrameSizeIfPresent())
                         frame = *f;
-                const auto outer = frame.addedTo (w.getBounds());
+                auto outer = frame.addedTo (w.getBounds());
                 const auto* display = juce::Desktop::getInstance().getDisplays().getDisplayForRect (outer);
                 const auto area = display != nullptr ? display->userArea : outer;
-                const auto passed = outer.getY() >= area.getY() && outer.getRight() <= area.getRight() && outer.getX() >= area.getX()
-                                    && (! whole || outer.getBottom() <= area.getBottom() + 1);
+               #if JUCE_LINUX
+                // round 164: a compositor that draws the frame itself (WSLg's Weston) reports its invisible shadow in
+                // the frame (59 px on top, 38 around at 100%): only what is visible is checked, give or take 4 px
+                const auto shadow = frame.getLeft() >= 16 ? frame.getLeft() : 0;
+                outer = outer.reduced (shadow);
+                const auto slack = shadow > 0 ? 4 : 0;
+               #else
+                const auto slack = 0;
+               #endif
+                const auto passed = outer.getY() >= area.getY() - slack && outer.getRight() <= area.getRight() + slack && outer.getX() >= area.getX() - slack
+                                    && (! whole || outer.getBottom() <= area.getBottom() + 1 + slack);
                 report << (passed ? "ok   " : "FAIL ") << what << " window=" << outer.toString() << " (frame " << frame.getTop() << ","
                        << frame.getLeft() << ") screen=" << area.toString() << "\n";
                 ok = ok && passed;
@@ -2291,7 +2300,8 @@ private:
                 tall->setCentrePosition (area.getCentre());
                 tall->setVisible (true);
                 lynx::keepAboveMainWindow (*tall);
-                startTimer (700);
+                // LYNX_FITTEST_MS: how long each window stays (default 700 ms; longer to take screenshots of them)
+                startTimer (juce::jlimit (300, 60000, juce::SystemStats::getEnvironmentVariable ("LYNX_FITTEST_MS", "700").getIntValue()));
             }
 
             void timerCallback() override
@@ -2301,6 +2311,29 @@ private:
                 {
                     check ("tall tool window: title bar and close button on the screen", *tall, false);
                     tall.reset();
+                    // round 164: a fixed-size LYNX tool window whose content is taller than the screen: it scrolls
+                    auto content = std::make_unique<juce::Component>();
+                    const auto screen = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
+                    content->setSize (520, screen.getHeight() + 300);
+                    lynx::openToolWindow (std::move (content), "LYNX fit test - fixed size", "fittest-fixed");
+                    return;
+                }
+                if (step == 2)
+                {
+                    if (auto* w = lynx::findToolWindow ("fittest-fixed"))
+                    {
+                        check ("fixed-size tool window taller than the screen: fits (its content scrolls)", *w, true);
+                        const auto scrolls = w->getContentComponent() != nullptr && w->getContentComponent()->getNumChildComponents() > 0
+                                             && dynamic_cast<juce::Viewport*> (w->getContentComponent()->getChildComponent (0)) != nullptr;
+                        report << (scrolls ? "ok   " : "FAIL ") << "its content is in a scrolling viewport\n";
+                        ok = ok && scrolls;
+                    }
+                    else
+                    {
+                        report << "FAIL fixed-size tool window not found\n";
+                        ok = false;
+                    }
+                    lynx::closeAllToolWindows();
                     // a resizable window that fits at 100%, then the zoom goes up (the main window's case)
                     juce::Desktop::getInstance().setGlobalScaleFactor (1.0f);
                     big = std::make_unique<juce::DocumentWindow> ("LYNX fit test - zoom", lynx::theme::colour::bg2, juce::DocumentWindow::allButtons);
@@ -2312,13 +2345,13 @@ private:
                     big->setVisible (true);
                     return;
                 }
-                if (step == 2)
+                if (step == 3)
                 {
                     juce::Desktop::getInstance().setGlobalScaleFactor ((float) percent / 100.0f);
                     juce::Timer::callAfterDelay (200, [] { lynx::fitAllWindowsOnScreen(); });
                     return;
                 }
-                if (step == 3)
+                if (step == 4)
                 {
                     check ("resizable window after the zoom change: fits the screen", *big, true);
                     big.reset();
@@ -5470,6 +5503,27 @@ private:
             offline.dispatchPendingMessages();
             saveSnapshot (ui, prefix + "-browser-plugins.png");
             ui.getBrowserForSnapshot().setTab (lynx::BrowserComponent::allTab);
+            saveWindow (ui.getBrowserForSnapshot().makeFoldersPanelForSnapshot(), "-browser-folders.png"); // round 164
+            {
+                // round 164: the content filter leaves out the folders with nothing to list (a small library)
+                const auto lib = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-snapshot-library");
+                lib.deleteRecursively();
+                for (const auto* path : { "Drums/Kicks/kick 1.wav", "Drums/Kicks/kick 2.wav", "Drums/snare.wav", "Keys/pad.sf2", "Presets/Synth/lead.fst",
+                                          "Projects/beat.flp", "Projects/MIDI/chords.mid", "Notes/readme.txt", "Empty/Nothing/.keep" })
+                    lib.getChildFile (path).create();
+                ui.showDesktopForSnapshot (false);
+                ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::all);
+                offline.dispatchPendingMessages();
+                saveSnapshot (ui, prefix + "-browser164-all.png");
+                ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::samples);
+                offline.dispatchPendingMessages();
+                saveSnapshot (ui, prefix + "-browser164-samples.png");
+                ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::projects);
+                offline.dispatchPendingMessages();
+                saveSnapshot (ui, prefix + "-browser164-projects.png");
+                lib.deleteRecursively();
+                ui.getBrowserForSnapshot().resetViewForSnapshot();
+            }
 
             // the undo history after a few edits
             offline.editSong ([] (lynx::Song& s) { s.bpm += 1.0; });

+ 27 - 5
src/core/FlpImport.cpp

@@ -442,6 +442,19 @@ std::vector<std::uint8_t> dx10Snapshot (const flp::Channel& c)
     return s;
 }
 
+void applyFlStretchPanel (SamplerSettings& s, int mode, int pitchCents, int mul, float timeTicks, double sampleSeconds, double bpm)
+{
+    if (mode != 0)
+    {
+        s.keepPitch = true;
+        s.stretchMethod = stretchMethodForFlMode (mode);
+        s.pitch = std::clamp (s.pitch + std::clamp (pitchCents, -4800, 4800) / 100.0f, -24.0f, 24.0f);
+    }
+
+    if (timeTicks <= 0.0f && mul != 0 && sampleSeconds > 0.0 && bpm > 0.0)
+        s.stretchBeats = std::clamp ((float) (sampleSeconds * std::pow (2.0, mul / 10000.0) * bpm / 60.0), 0.0f, 4096.0f);
+}
+
 void splitDrumChannel (Song& song, int channel, const std::vector<DrumPad>& pads)
 {
     if (channel < 0 || channel >= (int) song.channels.size() || pads.empty())
@@ -841,11 +854,8 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
         if (c.rootNote >= 0 && c.rootNote <= 127)
             def.sampler.pitch = std::clamp (def.sampler.pitch + (float) (60 - c.rootNote), -24.0f, 24.0f);
 
-        // an FL audio clip channel's header pitch and root note are not its time-stretch pitch: LYNX played its clips
-        // untransposed before round 163 made the channel pitch transpose clips, and keeps them so ([ASSUMPTION], not
-        // measured in FL; FL's stretch pitch is not read yet)
-        if (isAudioClip)
-            def.sampler.pitch = 0.0f;
+        // an FL audio clip plays like a C5 note of its channel: the header pitch, the root note and the fine tune
+        // transpose it too [FL: measured, REA_rodada164e-clippitch §2 — round 163 had dropped them on an assumption]
 
         def.swingMix = std::clamp (c.swingMix / 128.0f, 0.0f, 1.0f);
         def.cutGroup = c.cutGroup;
@@ -1797,6 +1807,18 @@ Song importFlp (const flp::Project& input, const FlpImportOptions& options)
             def.sampler.keepPitch = c.stretchMode != 0; // only FL's "Resample" changes the pitch
             def.sampler.stretchMethod = stretchMethodForFlMode (c.stretchMode);
         }
+
+        // FL's time-stretching panel on a sample channel or an audio clip [FL: measured, REA_rodada164e-clippitch §2]:
+        // every mode but Resample keeps the length (also without a TIME: the keys, the pitch knob and the root note
+        // transpose keeping the length) and adds its PITCH knob; Resample ignores that knob. MUL without a TIME
+        // stretches the sample by 2^(MUL/10000) (Resample: slower and lower), at the project's tempo here.
+        if ((c.type == flp::ChannelType::sampler || isAudioClip)
+            && (def.instrument == InstrumentKind::sampler || def.instrument == InstrumentKind::audioClip))
+        {
+            const auto needsLength = c.stretchTime <= 0.0f && c.stretchMul != 0 && ! def.samplePath.empty() && options.sampleSeconds;
+            applyFlStretchPanel (def.sampler, c.stretchMode, c.stretchPitch, c.stretchMul, c.stretchTime,
+                                 needsLength ? options.sampleSeconds (def.samplePath) : 0.0, song.bpm);
+        }
         // report: what happened to this channel's generator/sample
         if (options.report != nullptr)
         {

+ 7 - 0
src/core/FlpImport.h

@@ -49,6 +49,8 @@ struct FlpImportOptions
     // frames (0 = unknown) and saving of a WAV embedded in the project (returns the path).
     std::function<std::vector<std::uint8_t> (const std::string& path)> readFile;
     std::function<std::int64_t (const std::string& path)> sampleFrames;
+    // Optional: a sample's length in seconds (0 = unknown) — FL's time-stretch MUL without a TIME stretches it by a factor
+    std::function<double (const std::string& path)> sampleSeconds;
     std::function<std::string (const std::vector<std::uint8_t>& wav, const std::string& name)> saveEmbedded;
 
     FlpImportReport* report = nullptr; // optional
@@ -94,6 +96,11 @@ struct DrumPad
 // pad are dropped. Channel indices of patterns, automations and clips are adjusted.
 void splitDrumChannel (Song& song, int channel, const std::vector<DrumPad>& pads);
 
+// FL's Time stretching panel (0xD7) on a sample channel or an audio clip, as FL plays it (REA_rodada164e-clippitch):
+// every mode but Resample (0) keeps the length and adds the PITCH knob (cents); MUL without a TIME stretches the
+// sample (sampleSeconds long) by 2^(mul/10000), turned into beats at `bpm`.
+void applyFlStretchPanel (SamplerSettings& s, int mode, int pitchCents, int mul, float timeTicks, double sampleSeconds, double bpm);
+
 // FL channel/plugin preset (.fst) of a synthesizer the import converts (3x Osc, Sytrus,
 // Harmor, GMS, Harmless...) or native GMS preset (.gmsynth), as internal synth settings.
 // nullopt if the generator isn't one of these or the file couldn't be read.

+ 26 - 0
src/core/Patcher.cpp

@@ -608,6 +608,29 @@ void Graph::noteOffPort (int port, int key, int midiChannel) noexcept
         deliver (patchMidiPortPin (port), false, key, 0.0f, midiChannel);
 }
 
+template <typename F>
+void Graph::forNoteTargets (F&& f) noexcept
+{
+    if (pinTargets.empty())
+        return;
+    for (const auto& t : pinTargets[0])
+        if (auto& i = nodes[(std::size_t) t.node]->instrument)
+            f (*i);
+}
+
+void Graph::midiMessage (const std::uint8_t* bytes, int size) noexcept
+{
+    forNoteTargets ([&] (Instrument& i) { i.midiMessage (bytes, size); });
+}
+void Graph::pitchBend (float semitones) noexcept
+{
+    forNoteTargets ([&] (Instrument& i) { i.pitchBend (semitones); });
+}
+void Graph::controlChange (int cc, float value) noexcept
+{
+    forNoteTargets ([&] (Instrument& i) { i.controlChange (cc, value); });
+}
+
 bool Graph::takesMidiPort (int port) const noexcept
 {
     return port >= 0 && port < patchMidiPorts && ! pinTargets[(std::size_t) patchMidiPortPin (port)].empty();
@@ -905,6 +928,9 @@ public:
     void noteOn (int key, float velocity) noexcept override { graph.noteOn (key, velocity); }
     void noteOff (int key) noexcept override { graph.noteOff (key); }
     void allNotesOff() noexcept override { graph.allNotesOff(); }
+    void midiMessage (const std::uint8_t* bytes, int size) noexcept override { graph.midiMessage (bytes, size); }
+    void pitchBend (float semitones) noexcept override { graph.pitchBend (semitones); }
+    void controlChange (int cc, float value) noexcept override { graph.controlChange (cc, value); }
     void noteOnMidi (int key, float velocity, int midiChannel) noexcept override { graph.noteOnMidi (key, velocity, midiChannel); }
     void noteOffMidi (int key, int midiChannel) noexcept override { graph.noteOffMidi (key, midiChannel); }
     void noteOnPort (int port, int key, float velocity, int midiChannel) noexcept override { graph.noteOnPort (port, key, velocity, midiChannel); }

+ 8 - 0
src/core/Patcher.h

@@ -100,6 +100,12 @@ public:
     void noteOnPort (int port, int key, float velocity, int midiChannel) noexcept;
     void noteOffPort (int port, int key, int midiChannel) noexcept;
     bool takesMidiPort (int port) const noexcept;
+    // a controller's mod wheel, other CCs, channel pressure and pitch wheel played into the Patcher's channel (round
+    // 164e): like FL's Patcher (it takes MIDI input and passes it on), the instruments cabled to "From LYNX" notes get
+    // them as if they were the channel (hosted plugins the MIDI message, LYNX's samplers the bend)
+    void midiMessage (const std::uint8_t* bytes, int size) noexcept;
+    void pitchBend (float semitones) noexcept;
+    void controlChange (int cc, float value) noexcept;
     void allNotesOff() noexcept;
     void slideTo (int key, float cents, float samples) noexcept;
     void setNextNoteExpression (float pan, float cents, bool porta) noexcept;
@@ -126,6 +132,8 @@ public:
 
 private:
     struct Node;
+    template <typename F>
+    void forNoteTargets (F&& f) noexcept;
     struct AudioWire;
     struct ControlWire;
     struct Values;

+ 34 - 0
src/core/SearchIndex.cpp

@@ -31,6 +31,7 @@ void Index::drop (const std::string& folder, char separator)
         return;
     const auto subfolders = found->second.subfolders;
     folders.erase (found);
+    ++gen;
     for (const auto& s : subfolders)
         drop (join (folder, s, separator), separator);
 }
@@ -85,6 +86,7 @@ int Index::refresh (const std::string& root, const FileSystem& fs, const std::fu
                     if (std::find (listing.subfolders.begin(), listing.subfolders.end(), old) == listing.subfolders.end())
                         drop (join (folder, old, fs.separator), fs.separator);
             auto& entry = folders[folder];
+            ++gen;
             entry.time = time;
             entry.files = std::move (listing.files);
             entry.subfolders = std::move (listing.subfolders);
@@ -124,6 +126,37 @@ std::vector<std::string> Index::find (const std::string& query, const std::vecto
     return found;
 }
 
+FolderMatches Index::folderMatches (const std::function<bool (const std::string&)>& accept) const
+{
+    FolderMatches result;
+    result.generation = gen;
+    for (const auto& [path, folder] : folders)
+    {
+        if (result.some.count (path) > 0 || std::none_of (folder.files.begin(), folder.files.end(), accept))
+            continue;
+        // this folder and every indexed folder above it hold something
+        auto at = path;
+        while (result.some.insert (at).second)
+        {
+            const auto cut = at.find_last_of ("/\\");
+            if (cut == std::string::npos || cut == 0)
+                break;
+            auto parent = at.substr (0, cut);
+            if (folders.count (parent) == 0)
+            {
+                parent += at[cut]; // a drive's root keeps its separator ("C:\\")
+                if (folders.count (parent) == 0)
+                    break;
+            }
+            at = std::move (parent);
+        }
+    }
+    for (const auto& [path, folder] : folders)
+        if (result.some.count (path) == 0 && isComplete (path))
+            result.none.insert (path);
+    return result;
+}
+
 bool Index::isComplete (const std::string& folder) const
 {
     return std::any_of (complete.begin(), complete.end(), [this, &folder] (const std::string& r) { return isUnder (folder, r) && folders.count (r) > 0; });
@@ -156,6 +189,7 @@ std::string Index::toText() const
 bool Index::fromText (const std::string& text)
 {
     clear();
+    ++gen;
     std::istringstream in (text);
     std::string line;
     if (! std::getline (in, line) || line != "LYNX browser index 1")

+ 32 - 1
src/core/SearchIndex.h

@@ -27,6 +27,25 @@ struct FolderListing
     std::vector<std::string> subfolders; // names of the subfolders
 };
 
+// Which indexed folders hold, at any depth, a file a filter accepts (round 164: the Browser's content filter hides the
+// folders it would show empty). A folder that is not indexed, or not inside a tree walked to the end, is unknown.
+struct FolderMatches
+{
+    enum class Contents
+    {
+        unknown,
+        none,
+        some
+    };
+    std::set<std::string> some, none;
+    std::uint64_t generation = 0; // Index::generation() when it was worked out
+
+    Contents of (const std::string& folder) const
+    {
+        return some.count (folder) > 0 ? Contents::some : none.count (folder) > 0 ? Contents::none : Contents::unknown;
+    }
+};
+
 struct FileSystem
 {
     std::function<std::int64_t (const std::string& folder)> folderTime; // −1 when the folder no longer exists
@@ -53,10 +72,21 @@ public:
     {
         folders.clear();
         complete.clear();
+        ++gen;
     }
 
+    // Changes whenever the index does (round 164: what was worked out from it is out of date).
+    std::uint64_t generation() const noexcept { return gen; }
+
+    // The folders holding (directly or below) a file `accept` takes, and those of the complete trees holding none.
+    FolderMatches folderMatches (const std::function<bool (const std::string& fileName)>& accept) const;
+
     // A folder tree walked to the end (round 162): searching it needs no walk first. A folder inside one counts too.
-    void markComplete (const std::string& root) { complete.insert (root); }
+    void markComplete (const std::string& root)
+    {
+        if (complete.insert (root).second)
+            ++gen;
+    }
     bool isComplete (const std::string& folder) const;
 
     static bool isUnder (const std::string& path, const std::string& root);
@@ -74,6 +104,7 @@ private:
     };
     std::map<std::string, Folder> folders; // full path -> contents
     std::set<std::string> complete;
+    std::uint64_t gen = 0;
     static std::string join (const std::string& folder, const std::string& name, char separator);
     void drop (const std::string& folder, char separator);
 };

+ 11 - 0
src/core/SearchService.cpp

@@ -189,6 +189,17 @@ void Service::loadIndex()
     setStatus ([] (IndexStatus& s) { s.loaded = true; });
 }
 
+std::shared_ptr<const FolderMatches> Service::folderMatches (int key, const std::function<bool (const std::string&)>& accept)
+{
+    auto& cached = matchCache[key];
+    std::unique_lock<std::mutex> guard (indexLock, std::try_to_lock);
+    if (! guard.owns_lock())
+        return cached;
+    if (cached == nullptr || cached->generation != index.generation())
+        cached = std::make_shared<const FolderMatches> (index.folderMatches (accept));
+    return cached;
+}
+
 void Service::saveIndex()
 {
     if (! callbacks.save)

+ 9 - 0
src/core/SearchService.h

@@ -19,6 +19,8 @@
 #include <cstdint>
 #include <deque>
 #include <functional>
+#include <map>
+#include <memory>
 #include <mutex>
 #include <optional>
 #include <string>
@@ -77,6 +79,11 @@ public:
 
     IndexStatus status() const;
 
+    // Which folders hold a file `accept` takes (round 164: the Browser's content filter), worked out from the index
+    // and kept per `key` until the index changes. Never waits for the worker: while it holds the index, the last
+    // answer for `key` (or nullptr) is returned. Call from one thread (the message thread).
+    std::shared_ptr<const FolderMatches> folderMatches (int key, const std::function<bool (const std::string&)>& accept);
+
     // Waits until the worker has nothing to do (tests, --snapshot); false on time-out.
     bool waitIdle (int timeoutMs);
 
@@ -116,6 +123,8 @@ private:
     mutable std::mutex indexLock; // guards `index`
     Index index;
 
+    std::map<int, std::shared_ptr<const FolderMatches>> matchCache; // (the caller's thread)
+
     mutable std::mutex lock; // guards everything below
     std::condition_variable wake;
     bool stopping = false, working = true; // working: the worker has a job (or is reading the index file)

+ 24 - 0
src/core/WindowFit.h

@@ -28,4 +28,28 @@ inline Box place (Box outer, Box area)
     y = std::max (y, area.y);
     return { x, y, outer.w, outer.h };
 }
+// Round 164: the size of a fixed-size window's content when it must fit the usable screen (`areaW` x `areaH`,
+// minus the window frame): a content that is too tall (or too wide) scrolls in a viewport of this size, the scroll
+// bar taking `scrollBar` px beside it. A content that fits keeps its size (`scrolls` false).
+struct ScrollFit
+{
+    int w = 0, h = 0;
+    bool scrollsV = false, scrollsH = false;
+    bool scrolls() const { return scrollsV || scrollsH; }
+};
+
+inline ScrollFit scrollFit (int contentW, int contentH, int areaW, int areaH, int frameW, int frameH, int scrollBar)
+{
+    const auto maxW = std::max (100, areaW - frameW), maxH = std::max (100, areaH - frameH);
+    ScrollFit fit;
+    fit.scrollsV = contentH > maxH;
+    // a vertical scroll bar needs room beside the content; without the room, the content scrolls sideways too
+    const auto wantW = contentW + (fit.scrollsV ? scrollBar : 0);
+    fit.scrollsH = wantW > maxW;
+    fit.w = std::min (wantW, maxW);
+    fit.h = std::min (contentH + (fit.scrollsH ? scrollBar : 0), maxH);
+    if (fit.scrollsH && ! fit.scrollsV && contentH + scrollBar > maxH)
+        fit.scrollsV = true;
+    return fit;
+}
 } // namespace lynx::windowfit

+ 7 - 0
src/engine/AudioEngine.cpp

@@ -2113,6 +2113,13 @@ void AudioEngine::prepareFlpImport (const juce::File& file, const std::map<std::
                 decoded->push_back (sample); // kept: the rack uses it next (it was decoded twice before)
             return sample != nullptr ? (std::int64_t) sample->frames() : 0;
         };
+        options.sampleSeconds = [&library, decoded] (const std::string& path) -> double {
+            const auto sample = library.load (juce::String::fromUTF8 (path.c_str()));
+            if (sample == nullptr || sample->sampleRate <= 0.0)
+                return 0.0;
+            decoded->push_back (sample);
+            return (double) sample->frames() / sample->sampleRate;
+        };
         // WAV that only exists inside the .flp (Slicex): goes to %APPDATA%\LYNX\flp-embedded, keyed by content
         options.saveEmbedded = [] (const std::vector<std::uint8_t>& wav, const std::string& name) -> std::string {
             const auto folder = PluginHost::settingsFolder().getChildFile ("flp-embedded");

+ 1 - 0
src/flp/Flp.cpp

@@ -612,6 +612,7 @@ Project parseProject (std::span<const std::uint8_t> file, bool channelPreset)
                     if (e.data.size() >= 116)
                         c.pitchRange = readLE<std::int32_t> (e.data, 112);
                     c.stretchTimeRaw = readLE<std::uint32_t> (e.data, 0x60);
+                    c.stretchPitch = readLE<std::int32_t> (e.data, 0x64);
                     c.stretchMul = readLE<std::int32_t> (e.data, 0x68);
                     c.stretchMode = readLE<std::int32_t> (e.data, 0x6C);
 

+ 1 - 0
src/flp/Flp.h

@@ -150,6 +150,7 @@ struct Channel
 
     // 0xD7: time-stretch
     std::uint32_t stretchTimeRaw = 0; // in 1/192 of a beat: int or float, depending on Project::flagsA9
+    int stretchPitch = 0;             // Time stretching › PITCH (cents); FL ignores it in Resample mode (REA_rodada164e-clippitch)
     int stretchMul = 0;               // factor = 2^(v/10000)
     int stretchMode = 0;              // 0 resample, < 0 real-time stretch, >= 1 offline
     float stretchTime = 0.0f;         // already decoded (1/192 of a beat)

+ 371 - 21
src/ui/BrowserComponent.cpp

@@ -25,6 +25,7 @@
 #include "ui/ChannelRackComponent.h"
 #include "ui/MixerComponent.h"
 #include "ui/SoundFontEditor.h"
+#include "ui/ToolWindow.h"
 
 namespace lynx
 {
@@ -529,6 +530,44 @@ public:
         repaint();
     }
 
+    // Removes the folders on disk `drop` takes (round 164: the content filter found them empty), keeping what is open
+    // and selected. False when nothing went.
+    bool pruneFolders (const std::function<bool (const juce::File&)>& drop)
+    {
+        if (flat || root == nullptr)
+            return false;
+        auto* keep = juce::isPositiveAndBelow (selected, (int) rows.size()) ? rows[(std::size_t) selected] : nullptr;
+        bool removed = false, lostSelection = false;
+        std::function<void (Node&)> walk = [&] (Node& n) {
+            for (auto it = n.children.begin(); it != n.children.end();)
+            {
+                auto& c = **it;
+                if (c.kind == Kind::fsFolder && drop (c.file))
+                {
+                    for (auto* s = keep; s != nullptr; s = s->parent)
+                        lostSelection = lostSelection || s == &c;
+                    it = n.children.erase (it);
+                    removed = true;
+                    continue;
+                }
+                if (c.kind == Kind::fsFolder && c.loaded)
+                    walk (c);
+                ++it;
+            }
+        };
+        walk (*root);
+        if (! removed)
+            return false;
+        rebuild();
+        selected = -1;
+        if (! lostSelection)
+            for (int i = 0; i < (int) rows.size(); ++i)
+                if (rows[(std::size_t) i] == keep)
+                    selected = i;
+        hovered = -1;
+        return true;
+    }
+
     juce::File selectedFile() const
     {
         return juce::isPositiveAndBelow (selected, (int) rows.size()) ? rows[(std::size_t) selected]->file : juce::File();
@@ -614,6 +653,15 @@ public:
 
     // FL's folder "Expand all": the folder and its sub-folders open (on disk: down to `depth` levels, so a big
     // library is not scanned at once)
+    // --snapshot: opens the top-level folder `f` and its sub-folders (round 164)
+    void expandTop (const juce::File& f, int depth)
+    {
+        if (root != nullptr)
+            for (auto& c : root->children)
+                if (c->kind == Kind::fsFolder && c->file == f)
+                    expandFolder (*c, depth);
+    }
+
     void expandFolder (Node& n, int depth)
     {
         n.expanded = true;
@@ -1122,6 +1170,8 @@ private:
         {
             if (f.isHidden() || f.getFileName().startsWithChar ('.'))
                 continue;
+            if (browser.filterHides (f)) // nothing in it is listed under the content filter (round 164)
+                continue;
             auto c = std::make_unique<Node>();
             c->kind = Kind::fsFolder;
             c->file = f;
@@ -2096,6 +2146,31 @@ bool BrowserComponent::lists (const juce::File& file) const
     return browserview::listed (file.getFileName().toStdString(), view.filter) || file.isDirectory();
 }
 
+std::shared_ptr<const search::FolderMatches> BrowserComponent::filterMatches() const
+{
+    if (view.filter == browserview::ContentFilter::all || searcher == nullptr)
+        return nullptr;
+    const auto filter = view.filter;
+    return searcher->service->folderMatches ((int) filter, [filter] (const std::string& name) { return browserview::listed (name, filter); });
+}
+
+bool BrowserComponent::filterHides (const juce::File& folder) const
+{
+    // from the search index (cached; never waits for it): a folder it doesn't know yet stays listed
+    const auto matches = filterMatches();
+    return matches != nullptr && matches->of (folder.getFullPathName().toStdString()) == search::FolderMatches::Contents::none;
+}
+
+void BrowserComponent::applyFilterToTree()
+{
+    const auto matches = filterMatches();
+    if (matches == nullptr || matches->generation == prunedGeneration)
+        return;
+    prunedGeneration = matches->generation;
+    if (tree->pruneFolders ([this] (const juce::File& f) { return filterHides (f); }))
+        treeView->setViewPosition (treeView->getViewPosition()); // (keeps the scroll inside the shorter list)
+}
+
 void BrowserComponent::setContentFilter (browserview::ContentFilter filter)
 {
     if (filter == view.filter)
@@ -2103,7 +2178,9 @@ void BrowserComponent::setContentFilter (browserview::ContentFilter filter)
     view.filter = filter;
     saveView();
     refreshViewButton();
+    prunedGeneration = 0;
     rebuildTree();
+    refreshFoldersPanel();
     if (searchBox.getText().trim().isNotEmpty())
         runSearch();
 }
@@ -2172,32 +2249,250 @@ void BrowserComponent::addViewItems (juce::PopupMenu& menu)
     }
     menu.addSubMenu (tr ("Show") + ": " + tr (browserview::contentFilterLabel (view.filter)), filters);
 
-    // which top-level entries are shown (a checklist; hidden ones come back from here)
-    juce::PopupMenu folders;
-    auto toggle = [safe] (const juce::String& id) {
+    // which top-level entries are shown and the user's own folders: a window (round 164; a checklist sub-menu before)
+    menu.addItem (tr ("Show folders..."), [safe] {
         if (safe != nullptr)
-            safe->setRootShown (id, ! safe->view.shows (id.toStdString()));
+            safe->showFoldersDialog();
+    });
+}
+
+// --- the "Show folders" window (round 164) --------------------------------------------------------------
+
+// Which top-level entries this Browser shows, as a checklist (ticks apply at once), the user's own folders with a
+// Remove button, Add folder..., Show all. Each entry says where it is and, under a content filter, whether it holds
+// anything to list (those folders are left out of the tree while the filter is on).
+class BrowserComponent::FoldersPanel final : public juce::Component
+{
+public:
+    using Entry = FolderEntry;
+
+    explicit FoldersPanel (BrowserComponent* b) : browser (b)
+    {
+        title.setFont (theme::font (theme::type::body, true));
+        title.setColour (juce::Label::textColourId, theme::colour::textPrimary);
+        addAndMakeVisible (title);
+        note.setFont (theme::font (theme::type::small));
+        note.setColour (juce::Label::textColourId, theme::colour::textSecondary);
+        note.setJustificationType (juce::Justification::topLeft);
+        addAndMakeVisible (note);
+        list.setViewedComponent (&rows, false);
+        list.setScrollBarsShown (true, false);
+        list.setScrollBarThickness (10);
+        addAndMakeVisible (list);
+
+        addFolder.setButtonText (tr ("Add folder..."));
+        addFolder.setTooltip (tr ("Add one of your own folders to the Browsers (samples, projects, SoundFonts...)"));
+        addFolder.onClick = [this] { if (browser != nullptr) browser->addUserFolder(); };
+        showAll.setButtonText (tr ("Show all"));
+        showAll.setTooltip (tr ("Tick every folder"));
+        showAll.onClick = [this] { if (browser != nullptr) browser->showAllRoots(); };
+        close.setButtonText (tr ("Close"));
+        close.setColour (juce::TextButton::buttonColourId, theme::colour::accent);
+        close.setColour (juce::TextButton::textColourOffId, theme::colour::onAccent);
+        close.onClick = [this] { closeToolWindowOf (*this); };
+        for (auto* button : { &addFolder, &showAll, &close })
+            addAndMakeVisible (button);
+        refresh();
+        setSize (520, 470);
+    }
+
+    // the browser's entries again (a tick, an added / removed folder, the filter changed)
+    void refresh()
+    {
+        if (browser == nullptr)
+            return;
+        setEntries (browser->folderEntries(), browser->role == Role::samples,
+                    browser->view.filter == browserview::ContentFilter::all ? juce::String() : tr (browserview::contentFilterLabel (browser->view.filter)));
+    }
+
+    void setEntries (std::vector<Entry> newEntries, bool sampleBrowser, const juce::String& filterName)
+    {
+        entries = std::move (newEntries);
+        title.setText (sampleBrowser ? tr ("Folders shown in the Sample browser") : tr ("Folders shown in the Browser"), juce::dontSendNotification);
+        auto text = tr ("Untick what you don't use: it leaves this Browser and its searches. Nothing is deleted.");
+        if (filterName.isNotEmpty())
+            text << "\n" << tr ("Listing \"{0}\": folders with nothing of that kind are left out of the tree.", { filterName });
+        note.setText (text, juce::dontSendNotification);
+        int shown = 0;
+        for (const auto& e : entries)
+            shown += e.shown ? 1 : 0;
+        showAll.setEnabled (shown < (int) entries.size());
+
+        rows.deleteAllChildren();
+        for (int i = 0; i < (int) entries.size(); ++i)
+            rows.addAndMakeVisible (new Row (*this, i));
+        layoutRows();
+    }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (14, 12);
+        title.setBounds (area.removeFromTop (22));
+        note.setBounds (area.removeFromTop (note.getText().containsChar ('\n') ? 36 : 20));
+        area.removeFromTop (6);
+        auto bottom = area.removeFromBottom (28);
+        close.setBounds (bottom.removeFromRight (90));
+        addFolder.setBounds (bottom.removeFromLeft (120));
+        bottom.removeFromLeft (8);
+        showAll.setBounds (bottom.removeFromLeft (90));
+        area.removeFromBottom (10);
+        list.setBounds (area);
+        layoutRows();
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        g.fillAll (theme::colour::bg2);
+        g.setColour (theme::colour::border);
+        g.drawRect (list.getBounds().expanded (1), 1);
+    }
+
+    static constexpr int rowHeight = 34;
+
+private:
+    struct Row final : public juce::Component
+    {
+        Row (FoldersPanel& p, int i) : panel (p), index (i)
+        {
+            const auto& e = panel.entries[(std::size_t) i];
+            tick.setToggleState (e.shown, juce::dontSendNotification);
+            tick.setTooltip (e.shown ? tr ("Shown: untick to hide it from this Browser") : tr ("Hidden: tick to show it"));
+            tick.onClick = [this] { panel.toggle (index, tick.getToggleState()); };
+            addAndMakeVisible (tick);
+            if (e.user)
+            {
+                remove.setTooltip (tr ("Remove this folder from the Browsers (the folder itself stays on the disk)"));
+                remove.setFlat (true);
+                remove.onClick = [this] { panel.remove (index); };
+                addAndMakeVisible (remove);
+            }
+        }
+
+        void resized() override
+        {
+            auto area = getLocalBounds().reduced (6, 0);
+            tick.setBounds (area.removeFromLeft (26).withSizeKeepingCentre (24, 24));
+            if (remove.isVisible())
+                remove.setBounds (area.removeFromRight (26).withSizeKeepingCentre (22, 22));
+        }
+
+        void paint (juce::Graphics& g) override
+        {
+            const auto& e = panel.entries[(std::size_t) index];
+            if (index % 2 == 1)
+                g.fillAll (theme::colour::bg2.brighter (0.06f));
+            auto area = getLocalBounds().reduced (6, 2).withTrimmedLeft (32).withTrimmedRight (remove.isVisible() ? 30 : 0);
+            auto top = area.removeFromTop (area.getHeight() / 2 + 1);
+            g.setFont (theme::font (theme::type::body, e.shown));
+            g.setColour (e.shown ? theme::colour::textPrimary : theme::colour::textDisabled);
+            juce::String name = e.name;
+            if (e.user)
+                name << "  " << tr ("(your folder)");
+            g.drawText (name, top, juce::Justification::bottomLeft, true);
+            g.setFont (theme::font (theme::type::small));
+            g.setColour (theme::colour::textDisabled);
+            auto detail = e.path;
+            if (e.empty)
+                detail = tr ("nothing to list under the filter") + "  ·  " + detail;
+            g.drawFittedText (detail, area, juce::Justification::topLeft, 1, 0.9f);
+        }
+
+        void mouseUp (const juce::MouseEvent& e) override
+        {
+            if (e.mouseWasClicked() && ! e.mods.isPopupMenu())
+                tick.triggerClick(); // the whole row ticks
+        }
+
+        FoldersPanel& panel;
+        int index;
+        juce::ToggleButton tick;
+        IconButton remove { "remove folder", Icon::close };
     };
-    folders.addItem (tr ("Current project"), true, view.shows (browserview::projectRootId), [toggle] { toggle (browserview::projectRootId); });
-    folders.addItem (tr ("Plugin database"), true, view.shows (browserview::pluginsRootId), [toggle] { toggle (browserview::pluginsRootId); });
+
+    void layoutRows()
+    {
+        const auto width = list.getWidth() - (entries.size() * (std::size_t) rowHeight > (std::size_t) list.getHeight() ? 10 : 0);
+        rows.setSize (juce::jmax (0, width), (int) entries.size() * rowHeight);
+        for (int i = 0; i < rows.getNumChildComponents(); ++i)
+            rows.getChildComponent (i)->setBounds (0, i * rowHeight, rows.getWidth(), rowHeight);
+    }
+
+    void toggle (int index, bool shown)
+    {
+        if (browser != nullptr && juce::isPositiveAndBelow (index, (int) entries.size()))
+        {
+            const auto id = entries[(std::size_t) index].id;
+            juce::MessageManager::callAsync ([safe = browser, id, shown] { // (rebuilds the rows: not inside a row's click)
+                if (safe != nullptr)
+                    safe->setRootShown (id, shown);
+            });
+        }
+    }
+
+    void remove (int index)
+    {
+        if (browser != nullptr && juce::isPositiveAndBelow (index, (int) entries.size()))
+        {
+            const juce::File folder (entries[(std::size_t) index].path);
+            juce::MessageManager::callAsync ([safe = browser, folder] {
+                if (safe != nullptr)
+                    safe->removeUserFolder (folder);
+            });
+        }
+    }
+
+    juce::Component::SafePointer<BrowserComponent> browser;
+    std::vector<Entry> entries;
+    juce::Label title, note;
+    juce::Viewport list;
+    juce::Component rows;
+    juce::TextButton addFolder, showAll, close;
+};
+
+std::vector<BrowserComponent::FolderEntry> BrowserComponent::folderEntries() const
+{
+    std::vector<FolderEntry> out;
+    out.push_back ({ browserview::projectRootId, tr ("Current project"), tr ("the project's patterns, channels, samples and history"),
+                     view.shows (browserview::projectRootId), false, false });
+    out.push_back ({ browserview::pluginsRootId, tr ("Plugin database"), tr ("LYNX's, FL's and your installed plugins"),
+                     view.shows (browserview::pluginsRootId), false, false });
     for (int i = 0; i < allRoots.size(); ++i)
     {
-        const auto id = allRoots[i].getFullPathName();
-        juce::PopupMenu::Item item (allRootNames[i]);
-        item.setTicked (view.shows (id.toStdString())).setAction ([toggle, id] { toggle (id); });
-        item.shortcutKeyDescription = allRoots[i].getParentDirectory().getFileName();
-        folders.addItem (std::move (item));
+        FolderEntry e;
+        e.id = e.path = allRoots[i].getFullPathName();
+        e.name = allRootNames[i];
+        e.shown = view.shows (e.id.toStdString());
+        e.user = allRootKinds[(std::size_t) i] == browserview::RootKind::user;
+        e.empty = filterHides (allRoots[i]);
+        out.push_back (std::move (e));
     }
-    folders.addSeparator();
-    folders.addItem (tr ("Show all folders"), ! view.hidden.empty(), false, [safe] {
-        if (safe != nullptr)
-            safe->showAllRoots();
-    });
-    folders.addItem (tr ("Add folder..."), [safe] {
-        if (safe != nullptr)
-            safe->addUserFolder();
-    });
-    menu.addSubMenu (tr ("Show folders"), folders);
+    return out;
+}
+
+void BrowserComponent::refreshFoldersPanel()
+{
+    if (auto* panel = dynamic_cast<FoldersPanel*> (foldersPanel.getComponent()))
+        panel->refresh();
+}
+
+void BrowserComponent::showFoldersDialog()
+{
+    auto panel = std::make_unique<FoldersPanel> (this);
+    foldersPanel = panel.get();
+    openToolWindow (std::move (panel), role == Role::samples ? tr ("Sample browser folders") : tr ("Browser folders"),
+                    role == Role::samples ? "sample-browser-folders" : "browser-folders");
+}
+
+std::unique_ptr<juce::Component> BrowserComponent::makeFoldersPanelForSnapshot()
+{
+    auto panel = std::make_unique<FoldersPanel> (this);
+    // a user folder (with its Remove button) and one hidden entry, whatever this machine has
+    auto entries = folderEntries();
+    entries.push_back ({ "D:\\Samples\\Drums", "Drums", "D:\\Samples\\Drums", true, true, false });
+    if (entries.size() > 3)
+        entries[2].shown = false;
+    panel->setEntries (std::move (entries), false, {});
+    return panel;
 }
 
 void BrowserComponent::showViewMenu()
@@ -2324,6 +2619,7 @@ void BrowserComponent::rebuildRoots()
             rootNames.add (allRootNames[i]);
         }
     refreshViewButton();
+    refreshFoldersPanel();
 
     starred.clear();
     for (const auto& line : juce::StringArray::fromLines (starredFile().loadFileAsString()))
@@ -2370,6 +2666,8 @@ void BrowserComponent::rebuildTree()
         {
             if (! roots.contains (allRoots[i]))
                 continue; // hidden from this Browser (round 163)
+            if (filterHides (allRoots[i]))
+                continue; // nothing in it is listed under the content filter (round 164)
             // the FL folders keep their colour by position; the user's own folders share one
             auto colour = rootColour (i < 9 ? i : 99);
             top.push_back (FileTree::makeFolder (allRoots[i], allRootNames[i], colour));
@@ -2408,6 +2706,7 @@ void BrowserComponent::changeListenerCallback (juce::ChangeBroadcaster* source)
     }
     if (source == &searcher->indexChanged)
     {
+        applyFilterToTree();
         // the background check found changed folders: the results shown are searched again, in place
         if (resultsView->isVisible() && tab != projectTab && searchBox.getText().trim().isNotEmpty())
             runSearch (true);
@@ -2437,6 +2736,19 @@ void BrowserComponent::addUserFolder()
     });
 }
 
+void BrowserComponent::removeUserFolder (const juce::File& folder)
+{
+    auto lines = juce::StringArray::fromLines (userFoldersFile().loadFileAsString());
+    lines.removeEmptyStrings();
+    for (int i = lines.size(); --i >= 0;)
+        if (juce::File (lines[i].trim()) == folder)
+            lines.remove (i);
+    userFoldersFile().replaceWithText (lines.joinIntoString ("\n"));
+    if (view.hidden.erase (folder.getFullPathName().toStdString()) > 0) // (a hidden mark of a folder no longer listed)
+        saveView();
+    rebuildRoots();
+}
+
 BrowserComponent::~BrowserComponent()
 {
     engine.removeChangeListener (this);
@@ -2623,7 +2935,14 @@ void BrowserComponent::showFolderMenu (const juce::File& folder, std::function<v
     menu.addItem (tr ("Copy the file path"), [folder] { juce::SystemClipboard::copyTextToClipboard (folder.getFullPathName()); });
     menu.addSeparator();
     if (const auto id = rootId (folder); id.isNotEmpty() && tab == allTab)
+    {
         addHideItem (menu, id, allRootNames[allRoots.indexOf (folder)]);
+        if (allRootKinds[(std::size_t) allRoots.indexOf (folder)] == browserview::RootKind::user)
+            menu.addItem (tr ("Remove this folder from the Browsers"), [safe = juce::Component::SafePointer<BrowserComponent> (this), folder] {
+                if (safe != nullptr)
+                    safe->removeUserFolder (folder);
+            });
+    }
     juce::PopupMenu browserMenu;
     addViewItems (browserMenu);
     browserMenu.addSeparator();
@@ -2701,6 +3020,36 @@ void BrowserComponent::selectFirstSampleForSnapshot()
     }
 }
 
+void BrowserComponent::showFilterForSnapshot (const juce::File& folder, browserview::ContentFilter filter)
+{
+    // a folder of the user's (not saved) listed under `filter` once the index knows it (nothing saved either)
+    if (! allRoots.contains (folder))
+    {
+        allRoots.add (folder);
+        allRootNames.add (folder.getFileName());
+        allRootKinds.push_back (browserview::RootKind::user);
+    }
+    roots.clear();
+    roots.add (folder);
+    view.filter = filter;
+    view.setShown (browserview::projectRootId, false);
+    view.setShown (browserview::pluginsRootId, false);
+    searcher->service->refresh (toPaths ({ folder }));
+    searcher->service->waitIdle (60000);
+    prunedGeneration = 0;
+    setTab (allTab);
+    rebuildTree();
+    tree->expandTop (folder, 3);
+    refreshViewButton();
+}
+
+void BrowserComponent::resetViewForSnapshot()
+{
+    viewLoaded = false; // (read again: the snapshot's changes were never saved)
+    prunedGeneration = 0;
+    rebuildRoots();
+}
+
 void BrowserComponent::showPluginDatabaseForSnapshot()
 {
     openPluginFolders = { tr ("Plugin database"), tr ("Plugin database") + "/" + tr ("Generators"), tr ("Generators") + "/" + tr ("FL engines"),
@@ -2874,6 +3223,7 @@ void BrowserComponent::searchAnswered (const search::SearchResult& r, const juce
 
 void BrowserComponent::indexStatusChanged()
 {
+    applyFilterToTree(); // the index changed: folders found empty under the content filter go (round 164)
     const auto st = searcher->service->status();
     juce::String line;
     if (resultsView->isVisible() && tab != projectTab && searchBox.getText().trim().isNotEmpty())

+ 26 - 1
src/ui/BrowserComponent.h

@@ -1,6 +1,8 @@
 #pragma once
 
+#include <memory>
 #include <set>
+#include <vector>
 
 #include <juce_gui_basics/juce_gui_basics.h>
 
@@ -11,6 +13,7 @@
 namespace lynx::search
 {
 struct SearchResult;
+struct FolderMatches;
 }
 
 namespace lynx
@@ -120,7 +123,10 @@ public:
     void selectFirstSampleForSnapshot();
     // --snapshot: the PROJECT tab with the patterns, generators and samples open, a sample selected
     void showProjectForSnapshot();
-    void showPluginDatabaseForSnapshot(); // its Generators / Effects FL engines open (round 142)
+    void showPluginDatabaseForSnapshot();
+    // --snapshot (round 164): only `folder`, opened, listed under `filter` (folders with nothing to list left out)
+    void showFilterForSnapshot (const juce::File& folder, browserview::ContentFilter filter);
+    void resetViewForSnapshot(); // its Generators / Effects FL engines open (round 142)
     // --snapshot: shows this audio file in the preview strip (without playing it)
     void showPreviewForSnapshot (const juce::File& file);
     // Up/Down (load = false) or Shift+Up/Down (load = true); Enter = loadSelected()
@@ -158,6 +164,11 @@ public:
     class PreviewStrip; // waveform of the selected sample
     class TabBar;       // ALL / PROJECT / STARRED
     class DetailsBox;   // date, size / version and folder of the selection (FL's details box)
+    class FoldersPanel; // the "Show folders" window: which folders this Browser shows, the user's own folders (round 164)
+
+    // The "Show folders" window of this Browser (one per Browser), and its content for --snapshot.
+    void showFoldersDialog();
+    std::unique_ptr<juce::Component> makeFoldersPanelForSnapshot();
 
     // starred files and folders (one path per line in the settings folder)
     bool isStarred (const juce::File& file) const { return starred.contains (file.getFullPathName()); }
@@ -183,6 +194,20 @@ private:
     void saveView() const;
     bool viewLoaded = false, viewFromFile = false;
     bool lists (const juce::File& file) const; // a file listed under the content filter
+    // round 164: a folder whose files are all left out by the content filter (from the search index; unknown: false)
+    bool filterHides (const juce::File& folder) const;
+    std::shared_ptr<const search::FolderMatches> filterMatches() const;
+    void applyFilterToTree();
+    void removeUserFolder (const juce::File& folder); // takes one of the user's own folders out of the Browsers
+    juce::Component::SafePointer<juce::Component> foldersPanel;
+    void refreshFoldersPanel();
+    struct FolderEntry
+    {
+        juce::String id, name, path;
+        bool shown = true, user = false, empty = false; // empty: nothing in it is listed under the content filter
+    };
+    std::vector<FolderEntry> folderEntries() const; // the open "Show folders" window's content // drops the folders the index now knows to be empty under the filter
+    std::uint64_t prunedGeneration = 0;
     void addHideItem (juce::PopupMenu& menu, const juce::String& id, const juce::String& label);
     juce::String rootId (const juce::File& folder) const; // the root's id, empty if `folder` isn't a root
     juce::StringArray starred;

+ 1 - 1
src/ui/CrashReporter.cpp

@@ -776,7 +776,7 @@ private:
 void launch (std::unique_ptr<ReportPanel> panel, const juce::String& title)
 {
     juce::DialogWindow::LaunchOptions options;
-    options.content.setOwned (panel.release());
+    options.content.setOwned (fitContentToScreen (std::move (panel)).release());
     options.dialogTitle = title;
     options.dialogBackgroundColour = theme::colour::bg2;
     options.useNativeTitleBar = true;

+ 1 - 1
src/ui/ExportDialog.cpp

@@ -730,7 +730,7 @@ std::unique_ptr<juce::Component> makeExportPanel (AudioEngine& engine, int forma
 void showExportDialog (AudioEngine& engine, const juce::File& suggestedFolder, const juce::String& suggestedName, int format)
 {
     juce::DialogWindow::LaunchOptions options;
-    options.content.setOwned (new ExportPanel (engine, suggestedFolder, suggestedName.isNotEmpty() ? suggestedName : "LYNX", true, format));
+    options.content.setOwned (fitContentToScreen (std::make_unique<ExportPanel> (engine, suggestedFolder, suggestedName.isNotEmpty() ? suggestedName : "LYNX", true, format)).release());
     options.dialogTitle = tr ("Export audio");
     options.dialogBackgroundColour = theme::colour::bg2;
     options.useNativeTitleBar = true;

+ 65 - 1
src/ui/I18nData.h

@@ -14368,6 +14368,70 @@ inline constexpr unsigned char ptBR[] = {
 32, 40, 80, 68, 67, 41, 34, 10, 34, 82, 111, 117, 110, 100, 32, 116, 114, 105, 112, 58, 32, 123, 48, 125,
 32, 115, 97, 109, 112, 108, 101, 115, 34, 32, 61, 32, 34, 73, 100, 97, 32, 101, 32, 118, 111, 108, 116, 97,
 58, 32, 123, 48, 125, 32, 97, 109, 111, 115, 116, 114, 97, 115, 34, 10, 34, 80, 105, 110, 103, 34, 32, 61,
-32, 34, 80, 105, 110, 103, 34, 10,
+32, 34, 80, 105, 110, 103, 34, 10, 10, 35, 32, 114, 111, 117, 110, 100, 32, 49, 54, 52, 101, 32, 40, 109,
+105, 115, 99, 49, 54, 52, 41, 58, 32, 66, 114, 111, 119, 115, 101, 114, 32, 102, 111, 108, 100, 101, 114, 115,
+32, 119, 105, 110, 100, 111, 119, 10, 34, 83, 104, 111, 119, 32, 102, 111, 108, 100, 101, 114, 115, 46, 46, 46,
+34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 112, 97, 115, 116, 97, 115, 46, 46, 46, 34, 10,
+34, 82, 101, 109, 111, 118, 101, 32, 116, 104, 105, 115, 32, 102, 111, 108, 100, 101, 114, 32, 102, 114, 111, 109,
+32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 115, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101,
+114, 32, 101, 115, 116, 97, 32, 112, 97, 115, 116, 97, 32, 100, 111, 115, 32, 66, 114, 111, 119, 115, 101, 114,
+115, 34, 10, 34, 65, 100, 100, 32, 111, 110, 101, 32, 111, 102, 32, 121, 111, 117, 114, 32, 111, 119, 110, 32,
+102, 111, 108, 100, 101, 114, 115, 32, 116, 111, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 115, 32,
+40, 115, 97, 109, 112, 108, 101, 115, 44, 32, 112, 114, 111, 106, 101, 99, 116, 115, 44, 32, 83, 111, 117, 110,
+100, 70, 111, 110, 116, 115, 46, 46, 46, 41, 34, 32, 61, 32, 34, 65, 100, 105, 99, 105, 111, 110, 97, 114,
+32, 117, 109, 97, 32, 112, 97, 115, 116, 97, 32, 115, 117, 97, 32, 97, 111, 115, 32, 66, 114, 111, 119, 115,
+101, 114, 115, 32, 40, 115, 97, 109, 112, 108, 101, 115, 44, 32, 112, 114, 111, 106, 101, 116, 111, 115, 44, 32,
+83, 111, 117, 110, 100, 70, 111, 110, 116, 115, 46, 46, 46, 41, 34, 10, 34, 83, 104, 111, 119, 32, 97, 108,
+108, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 114, 32, 116, 111, 100, 97, 115, 34, 10, 34, 84, 105,
+99, 107, 32, 101, 118, 101, 114, 121, 32, 102, 111, 108, 100, 101, 114, 34, 32, 61, 32, 34, 77, 97, 114, 99,
+97, 114, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 112, 97, 115, 116, 97, 115, 34, 10, 34, 70, 111, 108,
+100, 101, 114, 115, 32, 115, 104, 111, 119, 110, 32, 105, 110, 32, 116, 104, 101, 32, 83, 97, 109, 112, 108, 101,
+32, 98, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32, 34, 80, 97, 115, 116, 97, 115, 32, 109, 111, 115, 116,
+114, 97, 100, 97, 115, 32, 110, 111, 32, 66, 114, 111, 119, 115, 101, 114, 32, 100, 101, 32, 115, 97, 109, 112,
+108, 101, 115, 34, 10, 34, 70, 111, 108, 100, 101, 114, 115, 32, 115, 104, 111, 119, 110, 32, 105, 110, 32, 116,
+104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32, 34, 80, 97, 115, 116, 97, 115, 32, 109, 111,
+115, 116, 114, 97, 100, 97, 115, 32, 110, 111, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 85, 110, 116,
+105, 99, 107, 32, 119, 104, 97, 116, 32, 121, 111, 117, 32, 100, 111, 110, 39, 116, 32, 117, 115, 101, 58, 32,
+105, 116, 32, 108, 101, 97, 118, 101, 115, 32, 116, 104, 105, 115, 32, 66, 114, 111, 119, 115, 101, 114, 32, 97,
+110, 100, 32, 105, 116, 115, 32, 115, 101, 97, 114, 99, 104, 101, 115, 46, 32, 78, 111, 116, 104, 105, 110, 103,
+32, 105, 115, 32, 100, 101, 108, 101, 116, 101, 100, 46, 34, 32, 61, 32, 34, 68, 101, 115, 109, 97, 114, 113,
+117, 101, 32, 111, 32, 113, 117, 101, 32, 118, 111, 99, 195, 170, 32, 110, 195, 163, 111, 32, 117, 115, 97, 58,
+32, 115, 97, 105, 32, 100, 101, 115, 116, 101, 32, 66, 114, 111, 119, 115, 101, 114, 32, 101, 32, 100, 97, 115,
+32, 98, 117, 115, 99, 97, 115, 32, 100, 101, 108, 101, 46, 32, 78, 97, 100, 97, 32, 195, 169, 32, 97, 112,
+97, 103, 97, 100, 111, 46, 34, 10, 34, 76, 105, 115, 116, 105, 110, 103, 32, 92, 34, 123, 48, 125, 92, 34,
+58, 32, 102, 111, 108, 100, 101, 114, 115, 32, 119, 105, 116, 104, 32, 110, 111, 116, 104, 105, 110, 103, 32, 111,
+102, 32, 116, 104, 97, 116, 32, 107, 105, 110, 100, 32, 97, 114, 101, 32, 108, 101, 102, 116, 32, 111, 117, 116,
+32, 111, 102, 32, 116, 104, 101, 32, 116, 114, 101, 101, 46, 34, 32, 61, 32, 34, 76, 105, 115, 116, 97, 110,
+100, 111, 32, 92, 34, 123, 48, 125, 92, 34, 58, 32, 112, 97, 115, 116, 97, 115, 32, 115, 101, 109, 32, 110,
+97, 100, 97, 32, 100, 101, 115, 115, 101, 32, 116, 105, 112, 111, 32, 102, 105, 99, 97, 109, 32, 102, 111, 114,
+97, 32, 100, 97, 32, 195, 161, 114, 118, 111, 114, 101, 46, 34, 10, 34, 83, 104, 111, 119, 110, 58, 32, 117,
+110, 116, 105, 99, 107, 32, 116, 111, 32, 104, 105, 100, 101, 32, 105, 116, 32, 102, 114, 111, 109, 32, 116, 104,
+105, 115, 32, 66, 114, 111, 119, 115, 101, 114, 34, 32, 61, 32, 34, 77, 111, 115, 116, 114, 97, 100, 97, 58,
+32, 100, 101, 115, 109, 97, 114, 113, 117, 101, 32, 112, 97, 114, 97, 32, 111, 99, 117, 108, 116, 195, 161, 45,
+108, 97, 32, 100, 101, 115, 116, 101, 32, 66, 114, 111, 119, 115, 101, 114, 34, 10, 34, 72, 105, 100, 100, 101,
+110, 58, 32, 116, 105, 99, 107, 32, 116, 111, 32, 115, 104, 111, 119, 32, 105, 116, 34, 32, 61, 32, 34, 79,
+99, 117, 108, 116, 97, 58, 32, 109, 97, 114, 113, 117, 101, 32, 112, 97, 114, 97, 32, 109, 111, 115, 116, 114,
+195, 161, 45, 108, 97, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 116, 104, 105, 115, 32, 102, 111, 108, 100,
+101, 114, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 66, 114, 111, 119, 115, 101, 114, 115, 32, 40, 116, 104,
+101, 32, 102, 111, 108, 100, 101, 114, 32, 105, 116, 115, 101, 108, 102, 32, 115, 116, 97, 121, 115, 32, 111, 110,
+32, 116, 104, 101, 32, 100, 105, 115, 107, 41, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 101,
+115, 116, 97, 32, 112, 97, 115, 116, 97, 32, 100, 111, 115, 32, 66, 114, 111, 119, 115, 101, 114, 115, 32, 40,
+97, 32, 112, 97, 115, 116, 97, 32, 99, 111, 110, 116, 105, 110, 117, 97, 32, 110, 111, 32, 100, 105, 115, 99,
+111, 41, 34, 10, 34, 40, 121, 111, 117, 114, 32, 102, 111, 108, 100, 101, 114, 41, 34, 32, 61, 32, 34, 40,
+115, 117, 97, 32, 112, 97, 115, 116, 97, 41, 34, 10, 34, 110, 111, 116, 104, 105, 110, 103, 32, 116, 111, 32,
+108, 105, 115, 116, 32, 117, 110, 100, 101, 114, 32, 116, 104, 101, 32, 102, 105, 108, 116, 101, 114, 34, 32, 61,
+32, 34, 110, 97, 100, 97, 32, 112, 97, 114, 97, 32, 108, 105, 115, 116, 97, 114, 32, 99, 111, 109, 32, 111,
+32, 102, 105, 108, 116, 114, 111, 34, 10, 34, 116, 104, 101, 32, 112, 114, 111, 106, 101, 99, 116, 39, 115, 32,
+112, 97, 116, 116, 101, 114, 110, 115, 44, 32, 99, 104, 97, 110, 110, 101, 108, 115, 44, 32, 115, 97, 109, 112,
+108, 101, 115, 32, 97, 110, 100, 32, 104, 105, 115, 116, 111, 114, 121, 34, 32, 61, 32, 34, 112, 97, 116, 116,
+101, 114, 110, 115, 44, 32, 99, 97, 110, 97, 105, 115, 44, 32, 115, 97, 109, 112, 108, 101, 115, 32, 101, 32,
+104, 105, 115, 116, 195, 179, 114, 105, 99, 111, 32, 100, 111, 32, 112, 114, 111, 106, 101, 116, 111, 34, 10, 34,
+76, 89, 78, 88, 39, 115, 44, 32, 70, 76, 39, 115, 32, 97, 110, 100, 32, 121, 111, 117, 114, 32, 105, 110,
+115, 116, 97, 108, 108, 101, 100, 32, 112, 108, 117, 103, 105, 110, 115, 34, 32, 61, 32, 34, 112, 108, 117, 103,
+105, 110, 115, 32, 100, 111, 32, 76, 89, 78, 88, 44, 32, 100, 111, 32, 70, 76, 32, 101, 32, 111, 115, 32,
+113, 117, 101, 32, 118, 111, 99, 195, 170, 32, 105, 110, 115, 116, 97, 108, 111, 117, 34, 10, 34, 83, 97, 109,
+112, 108, 101, 32, 98, 114, 111, 119, 115, 101, 114, 32, 102, 111, 108, 100, 101, 114, 115, 34, 32, 61, 32, 34,
+80, 97, 115, 116, 97, 115, 32, 100, 111, 32, 66, 114, 111, 119, 115, 101, 114, 32, 100, 101, 32, 115, 97, 109,
+112, 108, 101, 115, 34, 10,
 };
 } // namespace lynx::i18n::data

+ 1 - 1
src/ui/MainComponent.cpp

@@ -990,7 +990,7 @@ void MainComponent::showCustomizeToolbar()
     };
 
     juce::DialogWindow::LaunchOptions options;
-    options.content.setOwned (panel.release());
+    options.content.setOwned (fitContentToScreen (std::move (panel)).release());
     options.dialogTitle = tr ("Customize toolbar");
     options.dialogBackgroundColour = theme::colour::bg2;
     options.useNativeTitleBar = true;

+ 43 - 3
src/ui/MixerComponent.cpp

@@ -1956,6 +1956,18 @@ void EffectsPanel::timerCallback()
 
     if (changed && isShowing())
         repaint (inputBoxBounds());
+
+    // another effect selected (its controls need another height): fold / unfold the EQ, scroll (round 164)
+    if (const auto* s = slots(); s != nullptr && isShowing())
+    {
+        const auto kind = selectedSlot >= 0 && selectedSlot < (int) s->size() ? (int) (*s)[(std::size_t) selectedSlot].kind : -1;
+        if (selectedSlot != fittedSlot || kind != fittedKind)
+        {
+            fittedSlot = selectedSlot;
+            fittedKind = kind;
+            refit();
+        }
+    }
 }
 
 void EffectsPanel::setTrack (int t)
@@ -2074,10 +2086,12 @@ juce::Rectangle<int> EffectsPanel::eqFoldBounds() const
 
 int EffectsPanel::neededHeight (bool folded) const
 {
-    // the slots and the effect's title row under them always fit; the knobs below may be cut by the EQ
-    return slotsTop + maxEffectSlots * slotHeight + 64 + 6 + belowHeight (folded);
+    // the slots and the selected effect's controls (round 164: its knobs and their names and values too, they were
+    // cut by the EQ at medium heights): when they don't fit with the EQ open, it folds; then the panel scrolls
+    return selectedEffectBottom() + 6 + belowHeight (folded);
 }
 
+
 void EffectsPanel::fitToView (int w, int h, int scrollBar)
 {
     viewWidth = w;
@@ -2581,6 +2595,11 @@ int shownParams (const EffectSlot& slot)
 } // namespace
 
 juce::Rectangle<int> EffectsPanel::knobBounds (int param) const
+{
+    return knobBoundsIn (param, bottomTop());
+}
+
+juce::Rectangle<int> EffectsPanel::knobBoundsIn (int param, int areaBottom) const
 {
     auto top = slotsTop + maxEffectSlots * slotHeight + 40;
     // many parameters (Effector: 12): 4 columns and shorter rows to fit the height
@@ -2590,7 +2609,7 @@ juce::Rectangle<int> EffectsPanel::knobBounds (int param) const
     const auto columns = count > 9 ? 4 : 3;
     const auto w = (getWidth() - 16) / columns;
     const auto rows = juce::jmax (1, (count + columns - 1) / columns);
-    const auto rowHeight = count > 9 ? juce::jlimit (64, 86, (bottomTop() - top - 4) / rows) : 86;
+    const auto rowHeight = count > 9 ? juce::jlimit (64, 86, (areaBottom - top - 4) / rows) : 86;
 
     // volume gate: the 32 steps are bars (gateStepsBounds); the knobs are mix/attack/release
     if (gateSelected())
@@ -2608,6 +2627,27 @@ juce::Rectangle<int> EffectsPanel::knobBounds (int param) const
     return { 8 + (param % columns) * w, top + (param / columns) * rowHeight, w, rowHeight - 4 };
 }
 
+int EffectsPanel::selectedEffectBottom() const
+{
+    const auto slotsBottom = slotsTop + maxEffectSlots * slotHeight;
+    auto bottom = slotsBottom + 64; // the effect's title row
+    const auto* s = slots();
+    if (s == nullptr || selectedSlot < 0 || selectedSlot >= (int) s->size())
+        return bottom;
+    const auto& slot = (*s)[(std::size_t) selectedSlot];
+    if (slot.kind == EffectKind::plugin || isSoundgoodizerApprox (slot))
+        return juce::jmax (bottom, pluginButtonBounds().getBottom() + 34 + 40);
+    if (slot.kind == EffectKind::parametricEq || slot.kind == EffectKind::facetEq)
+        return juce::jmax (bottom, pluginButtonBounds().getBottom() + 10 + 120);
+    if (slot.kind == EffectKind::parallel)
+        return juce::jmax (bottom, knobBoundsIn (0, 0).getY() - 28 + 20 + 22 * (int) slot.branches.size());
+    const auto count = gateSelected() ? 35 : shownParams (slot);
+    for (int p = 0; p < count; ++p)
+        if (const auto r = knobBoundsIn (p, 0); ! r.isEmpty()) // (tight grids at their shortest rows)
+            bottom = juce::jmax (bottom, r.getY() + juce::jlimit (30, 44, r.getHeight() - 30) + 32); // knob, name, value
+    return bottom;
+}
+
 bool EffectsPanel::gateSelected() const
 {
     const auto* s = slots();

+ 3 - 0
src/ui/MixerComponent.h

@@ -315,6 +315,9 @@ private:
     bool hoverOutput = false, hoverArrow = false;
     static constexpr int gateStepParam = -3; // drawing the volume gate steps
     juce::Rectangle<int> knobBounds (int param) const;
+    juce::Rectangle<int> knobBoundsIn (int param, int areaBottom) const; // laid out above areaBottom
+    int selectedEffectBottom() const; // the lowest edge of the selected effect's controls (laid out from the top)
+    int fittedSlot = -2, fittedKind = -2; // the selected effect the panel's height was fitted to
     bool gateSelected() const;
     juce::Rectangle<int> gateStepsBounds() const;
     void setGateStep (juce::Point<int> p);

+ 1 - 1
src/ui/ToolWindow.cpp

@@ -54,7 +54,7 @@ juce::DocumentWindow* openToolWindow (std::unique_ptr<juce::Component> content,
             delete old;
 
     auto* window = new ToolWindow (title, key);
-    window->setContentOwned (content.release(), true);
+    window->setContentOwned (fitContentToScreen (std::move (content)).release(), true); // (scrolls when taller than the screen)
     window->setResizable (false, false);
 
     if (auto* main = juce::TopLevelWindow::getActiveTopLevelWindow())

+ 104 - 0
src/ui/WindowOwner.cpp

@@ -9,6 +9,7 @@
 #include <cstdint>
 #include <map>
 #include <memory>
+#include <optional>
 #include <ctime>
 
 #if JUCE_WINDOWS
@@ -316,4 +317,107 @@ void fitAllWindowsOnScreen()
         if (auto* window = dynamic_cast<juce::ResizableWindow*> (desktop.getComponent (i)))
             fitWindowOnScreen (*window);
 }
+namespace
+{
+// the usable screen of the main window (or the primary one), in logical pixels
+juce::Rectangle<int> usableScreen()
+{
+    const auto& displays = juce::Desktop::getInstance().getDisplays();
+    const juce::Displays::Display* display = nullptr;
+    if (auto* main = juce::TopLevelWindow::getActiveTopLevelWindow())
+        display = displays.getDisplayForRect (main->getScreenBounds());
+    if (display == nullptr)
+        display = displays.getPrimaryDisplay();
+    return display != nullptr ? display->userArea : juce::Rectangle<int> (0, 0, 1280, 720);
+}
+
+// a window's frame (title bar and borders, logical px): this window's own once it is on the screen, else another
+// LYNX window's (the same window manager draws them), else a typical native title bar
+juce::BorderSize<int> windowFrame (juce::Component* window)
+{
+    auto frameOf = [] (juce::Component* c) -> std::optional<juce::BorderSize<int>> {
+        if (c != nullptr)
+            if (auto* peer = c->getPeer())
+                if (const auto f = peer->getFrameSizeIfPresent(); f && f->getTop() > 0)
+                    return *f;
+        return std::nullopt;
+    };
+    if (const auto own = frameOf (window))
+        return *own;
+    for (int i = 0; i < juce::TopLevelWindow::getNumTopLevelWindows(); ++i)
+        if (const auto other = frameOf (juce::TopLevelWindow::getTopLevelWindow (i)))
+            return *other;
+    return { 32, 8, 8, 8 };
+}
+
+class ScrollingContent final : public juce::Component,
+                               private juce::ComponentListener
+{
+public:
+    explicit ScrollingContent (std::unique_ptr<juce::Component> c) : content (c.release())
+    {
+        setName (content->getName());
+        viewport.setViewedComponent (content, true); // (the viewport deletes it)
+        viewport.setScrollBarThickness (12);
+        addAndMakeVisible (viewport);
+        content->addComponentListener (this);
+        fit();
+    }
+
+    ~ScrollingContent() override
+    {
+        if (content != nullptr)
+            content->removeComponentListener (this);
+    }
+
+    void resized() override { viewport.setBounds (getLocalBounds()); }
+
+    // on the screen: fitted again with the window's real frame, and the window placed so it is all on the screen
+    void parentHierarchyChanged() override
+    {
+        juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<ScrollingContent> (this)] {
+            if (safe != nullptr && safe->getPeer() != nullptr)
+                safe->fit();
+        });
+    }
+
+    void fit()
+    {
+        if (content == nullptr)
+            return;
+        const auto area = usableScreen();
+        auto* window = getTopLevelComponent() != this ? getTopLevelComponent() : nullptr;
+        const auto frame = windowFrame (window);
+        const auto f = windowfit::scrollFit (content->getWidth(), content->getHeight(), area.getWidth(), area.getHeight(), frame.getLeftAndRight(),
+                                             frame.getTopAndBottom(), viewport.getScrollBarThickness());
+        viewport.setScrollBarsShown (f.scrollsV, f.scrollsH);
+        setSize (f.w, f.h);
+        if (window != nullptr && window->isOnDesktop())
+            fitWindowOnScreen (*window);
+    }
+
+private:
+    void componentMovedOrResized (juce::Component&, bool, bool wasResized) override
+    {
+        if (wasResized)
+            fit(); // (the window follows its content's size)
+    }
+
+    juce::Component::SafePointer<juce::Component> content;
+    juce::Viewport viewport;
+};
+} // namespace
+
+std::unique_ptr<juce::Component> fitContentToScreen (std::unique_ptr<juce::Component> content)
+{
+    if (content == nullptr)
+        return content;
+    const auto area = usableScreen();
+    const auto frame = windowFrame (nullptr);
+    const auto f = windowfit::scrollFit (content->getWidth(), content->getHeight(), area.getWidth(), area.getHeight(), frame.getLeftAndRight(),
+                                         frame.getTopAndBottom(), 12);
+    if (! f.scrolls())
+        return content;
+    return std::make_unique<ScrollingContent> (std::move (content));
+}
 } // namespace lynx

+ 5 - 0
src/ui/WindowOwner.h

@@ -24,6 +24,11 @@ bool isAboveMainWindow (juce::Component& window);
 void fitWindowOnScreen (juce::Component& window);
 void fitAllWindowsOnScreen();
 
+// Round 164: the content of a fixed-size window (a tool window, a dialog) that is taller or wider than the usable
+// screen (UI zoom 150%+, a small laptop screen) goes into a scrolling viewport that fits, so its buttons stay
+// reachable; a content that fits is returned as it is. The viewport follows the content's later size changes.
+std::unique_ptr<juce::Component> fitContentToScreen (std::unique_ptr<juce::Component> content);
+
 // --windowtest only: makes `window` the foreground window even when LYNX was started in the background.
 void forceForegroundForTest (juce::Component& window);
 

+ 121 - 0
tests/ClipPitch164Tests.inc

@@ -0,0 +1,121 @@
+// --- Round 164e (misc164p): FL's audio clip / sample channel pitch as FL plays it (REA_rodada164e-clippitch) ---------
+
+namespace c164p
+{
+struct FlCase
+{
+    const char* name;
+    int type;          // 4 audio clip, 0 sampler
+    int headerCents;   // 0xDB pitch
+    int root;          // 0x87, -1 = none
+    int stretchCents;  // 0xD7 +0x64
+    int mode;          // 0xD7 +0x6C
+    int mul;           // 0xD7 +0x68
+    float time;        // 0xD7 +0x60 (1/192 beat)
+    float semitones;   // LYNX's channel pitch after the import
+    bool keepLength;
+    float beats;       // stretchBeats (0 = none)
+};
+
+lynx::Song importCase (const FlCase& k, double sampleSeconds)
+{
+    FlpBuilder b (96);
+    b.ascii (0xC7, "25.2.5.5319");
+    b.u8 (0xA9); b.u32 (7); // float stretch time
+    b.u8 (0x9C); b.u32 (86000);
+    b.u8 (0x40); b.u16 (0);
+    b.u8 (0x15); b.u8 ((std::uint8_t) k.type);
+    if (k.root >= 0)
+    {
+        b.u8 (0x87); b.u32 ((std::uint32_t) k.root);
+    }
+    b.utf16 (0xC4, u"C:\\samples\\sine440.wav");
+    std::vector<std::uint8_t> levels (24, 0);
+    const std::int32_t lv[] = { 6400, 10000, k.headerCents };
+    std::memcpy (levels.data(), lv, sizeof (lv));
+    b.data (0xDB, levels);
+    std::vector<std::uint8_t> params (168, 0);
+    std::memcpy (&params[0x60], &k.time, 4);
+    std::memcpy (&params[0x64], &k.stretchCents, 4);
+    std::memcpy (&params[0x68], &k.mul, 4);
+    std::memcpy (&params[0x6C], &k.mode, 4);
+    const double end = 1.0;
+    std::memcpy (&params[0x88], &end, 8);
+    b.data (0xD7, params);
+
+    lynx::FlpImportOptions o;
+    o.fileExists = [] (const std::string&) { return true; };
+    o.sampleSeconds = [sampleSeconds] (const std::string&) { return sampleSeconds; };
+    return lynx::importFlp (flp::parseProject (b.bytes), o);
+}
+} // namespace c164p
+
+TEST (c164p_fl_clip_and_sampler_pitch_import)
+{
+    // every row was rendered by FL 2026 (FL64.exe /R) from a 2 s 440 Hz sine at 86 BPM and measured (pitch, length)
+    using c164p::FlCase;
+    const FlCase cases[] = {
+        { "clip base", 4, 0, -1, 0, 0, 0, 0.0f, 0.0f, false, 0.0f },                    // 440 Hz, 2.000 s
+        { "clip header +400", 4, 400, -1, 0, 0, 0, 0.0f, 4.0f, false, 0.0f },          // +400.0 c, 1.587 s
+        { "clip header -300", 4, -300, -1, 0, 0, 0, 0.0f, -3.0f, false, 0.0f },        // -300.0 c, 2.378 s
+        { "clip root 48", 4, 0, 48, 0, 0, 0, 0.0f, 12.0f, false, 0.0f },               // +1200 c, 1.000 s
+        { "clip root 67", 4, 0, 67, 0, 0, 0, 0.0f, -7.0f, false, 0.0f },               // -700 c, 2.996 s
+        { "clip stretch pitch, resample", 4, 0, -1, 700, 0, 0, 0.0f, 0.0f, false, 0.0f }, // ignored: 0 c, 2.000 s
+        { "clip stretch pitch, stretch", 4, 0, -1, 700, -1, 0, 0.0f, 7.0f, true, 0.0f },  // +698 c, 2.000 s
+        { "clip stretch pitch, e3", 4, 0, -1, 700, 1, 0, 0.0f, 7.0f, true, 0.0f },        // +700 c, 2.000 s
+        { "clip stretch pitch, mode 2", 4, 0, -1, 700, 2, 0, 0.0f, 7.0f, true, 0.0f },    // +695 c, 1.999 s
+        { "clip stretch pitch, auto", 4, 0, -1, 700, 5, 0, 0.0f, 7.0f, true, 0.0f },      // +700 c, 2.000 s
+        { "clip header +400, stretch", 4, 400, -1, 0, -1, 0, 0.0f, 4.0f, true, 0.0f },    // +398 c, 2.000 s
+        { "clip header + stretch pitch", 4, 400, -1, 700, -1, 0, 0.0f, 11.0f, true, 0.0f }, // +1100 c, 2.004 s
+        { "clip header + stretch pitch, resample", 4, 400, -1, 700, 0, 0, 0.0f, 4.0f, false, 0.0f }, // +400 c, 1.587 s
+        { "clip root 67, stretch", 4, 0, 67, 0, -1, 0, 0.0f, -7.0f, true, 0.0f },         // -701 c, 2.001 s
+        { "clip time 1 beat, resample", 4, 0, -1, 0, 0, 0, 192.0f, 0.0f, false, 1.0f },   // +1823 c, 0.698 s
+        { "clip time 1 beat, stretch +700", 4, 0, -1, 700, -1, 0, 192.0f, 7.0f, true, 1.0f }, // +697 c, 0.692 s
+        { "clip mul x2, resample", 4, 0, -1, 0, 0, 10000, 0.0f, 0.0f, false, 2.0f * 2.0f * 86.0f / 60.0f },   // -1200 c, 4.000 s
+        { "clip mul x2, stretch", 4, 0, -1, 0, -1, 10000, 0.0f, 0.0f, true, 2.0f * 2.0f * 86.0f / 60.0f },    // -0.5 c, 4.004 s
+        { "sampler stretch pitch, resample", 0, 0, -1, 700, 0, 0, 0.0f, 0.0f, false, 0.0f },  // 0 c, 2.000 s
+        { "sampler stretch pitch, stretch", 0, 0, -1, 700, -1, 0, 0.0f, 7.0f, true, 0.0f },   // +698 c, 2.000 s
+        { "sampler header +400, stretch", 0, 400, -1, 0, -1, 0, 0.0f, 4.0f, true, 0.0f },     // +398 c, 2.000 s
+        { "sampler mul x2, resample", 0, 0, -1, 0, 0, 10000, 0.0f, 0.0f, false, 2.0f * 2.0f * 86.0f / 60.0f }, // -1200 c, 4.000 s
+    };
+
+    for (const auto& k : cases)
+    {
+        const auto song = c164p::importCase (k, 2.0);
+        const bool ok = song.channels.size() == 1;
+        CHECK (ok);
+        if (! ok)
+            continue;
+        const auto& s = song.channels[0].sampler;
+        const bool match = std::abs (s.pitch - k.semitones) < 1e-4f && s.keepPitch == k.keepLength && std::abs (s.stretchBeats - k.beats) < 1e-3f;
+        if (! match)
+            std::fprintf (stderr, "  %s: pitch %.3f keep %d beats %.4f\n", k.name, (double) s.pitch, (int) s.keepPitch, (double) s.stretchBeats);
+        CHECK (match);
+        CHECK (song.channels[0].instrument == (k.type == 4 ? lynx::InstrumentKind::audioClip : lynx::InstrumentKind::sampler));
+    }
+
+    // the stretch pitch is read from the file
+    const c164p::FlCase raw { "raw", 4, 0, -1, -1200, 2, 0, 0.0f, 0.0f, false, 0.0f };
+    const auto song = c164p::importCase (raw, 2.0);
+    CHECK (song.channels.size() == 1 && std::abs (song.channels[0].sampler.pitch + 12.0f) < 1e-4f && song.channels[0].sampler.keepPitch);
+}
+
+TEST (c164p_stretch_panel_rules)
+{
+    using namespace lynx;
+    SamplerSettings s;
+    applyFlStretchPanel (s, 0, 700, 0, 0.0f, 2.0, 120.0); // Resample: nothing changes
+    CHECK (s.pitch == 0.0f && ! s.keepPitch && s.stretchBeats == 0.0f);
+    applyFlStretchPanel (s, 0, 0, -10000, 0.0f, 2.0, 120.0); // MUL x0.5: 1 s = 2 beats at 120 BPM
+    CHECK (std::abs (s.stretchBeats - 2.0f) < 1e-5f && ! s.keepPitch);
+    SamplerSettings t;
+    t.pitch = 20.0f;
+    applyFlStretchPanel (t, 5, 1200, 0, 0.0f, 0.0, 120.0); // clamped to LYNX's ±24 semitones
+    CHECK (t.pitch == 24.0f && t.keepPitch);
+    SamplerSettings u;
+    applyFlStretchPanel (u, -1, 0, 5000, 384.0f, 2.0, 120.0); // with a TIME the MUL belongs to it (set by the caller)
+    CHECK (u.stretchBeats == 0.0f && u.keepPitch);
+    SamplerSettings v;
+    applyFlStretchPanel (v, -1, 0, 5000, 0.0f, 0.0, 120.0); // unknown sample length: no stretch
+    CHECK (v.stretchBeats == 0.0f);
+}

+ 98 - 0
tests/Misc164Tests.inc

@@ -0,0 +1,98 @@
+// Round 164 (misc164): the Browser's content filter leaves out folders with nothing to list (from the search index).
+
+#include "core/BrowserView.h"
+#include "core/SearchIndex.h"
+
+TEST (misc164_browser_filter_hides_empty_folders)
+{
+    using lynx::search::FolderMatches;
+    struct F { std::int64_t time; std::vector<std::string> files, subs; };
+    std::map<std::string, F> disk { { "/lib", { 1, { "song.flp" }, { "Drums", "Presets", "Empty", "Deep" } } },
+                                    { "/lib/Drums", { 1, { "kick.wav" }, {} } },
+                                    { "/lib/Presets", { 1, { "lead.fst" }, {} } },
+                                    { "/lib/Empty", { 1, {}, {} } },
+                                    { "/lib/Deep", { 1, {}, { "A" } } },
+                                    { "/lib/Deep/A", { 1, { "pad.sf2" }, {} } } };
+    lynx::search::FileSystem fs;
+    fs.folderTime = [&] (const std::string& f) { auto i = disk.find (f); return i == disk.end() ? (std::int64_t) -1 : i->second.time; };
+    fs.list = [&] (const std::string& f) {
+        lynx::search::FolderListing l;
+        if (auto i = disk.find (f); i != disk.end())
+            l.exists = true, l.time = i->second.time, l.files = i->second.files, l.subfolders = i->second.subs;
+        return l;
+    };
+    auto accept = [] (lynx::browserview::ContentFilter filter) {
+        return [filter] (const std::string& name) { return lynx::browserview::listed (name, filter); };
+    };
+
+    lynx::search::Index index;
+    index.refresh ("/lib", fs);
+    // not walked to the end yet: nothing is known to be empty (the Browser keeps listing those folders)
+    auto m = index.folderMatches (accept (lynx::browserview::ContentFilter::audio));
+    CHECK (m.of ("/lib/Drums") == FolderMatches::Contents::some && m.of ("/lib") == FolderMatches::Contents::some);
+    CHECK (m.of ("/lib/Presets") == FolderMatches::Contents::unknown && m.of ("/elsewhere") == FolderMatches::Contents::unknown);
+
+    const auto before = index.generation();
+    index.markComplete ("/lib");
+    CHECK (index.generation() != before);
+    m = index.folderMatches (accept (lynx::browserview::ContentFilter::audio));
+    CHECK (m.generation == index.generation());
+    CHECK (m.of ("/lib/Presets") == FolderMatches::Contents::none && m.of ("/lib/Empty") == FolderMatches::Contents::none);
+    CHECK (m.of ("/lib/Deep") == FolderMatches::Contents::none && m.of ("/lib/Deep/A") == FolderMatches::Contents::none);
+
+    // a SoundFont deep down keeps every folder above it under "Samples and SoundFonts"
+    m = index.folderMatches (accept (lynx::browserview::ContentFilter::samples));
+    CHECK (m.of ("/lib/Deep") == FolderMatches::Contents::some && m.of ("/lib/Deep/A") == FolderMatches::Contents::some);
+    CHECK (m.of ("/lib/Presets") == FolderMatches::Contents::none);
+    m = index.folderMatches (accept (lynx::browserview::ContentFilter::presets));
+    CHECK (m.of ("/lib/Presets") == FolderMatches::Contents::some && m.of ("/lib/Drums") == FolderMatches::Contents::none);
+    m = index.folderMatches (accept (lynx::browserview::ContentFilter::projects));
+    CHECK (m.of ("/lib") == FolderMatches::Contents::some && m.of ("/lib/Drums") == FolderMatches::Contents::none);
+
+    // a file arrives in Empty: the index changes, and so does the answer
+    disk["/lib/Empty"] = { 2, { "hat.wav" }, {} };
+    const auto gen = index.generation();
+    CHECK (index.refresh ("/lib", fs) == 1 && index.generation() != gen);
+    m = index.folderMatches (accept (lynx::browserview::ContentFilter::audio));
+    CHECK (m.of ("/lib/Empty") == FolderMatches::Contents::some);
+    // nothing changed on disk: same generation (the Browser's cache is kept)
+    const auto still = index.generation();
+    CHECK (index.refresh ("/lib", fs) == 0 && index.generation() == still);
+
+    // Windows paths: a drive root keeps its separator
+    lynx::search::Index win;
+    std::map<std::string, F> wdisk { { "D:\\", { 1, {}, { "Samples" } } }, { "D:\\Samples", { 1, { "a.wav" }, {} } } };
+    fs.separator = '\\';
+    fs.folderTime = [&] (const std::string& f) { auto i = wdisk.find (f); return i == wdisk.end() ? (std::int64_t) -1 : i->second.time; };
+    fs.list = [&] (const std::string& f) {
+        lynx::search::FolderListing l;
+        if (auto i = wdisk.find (f); i != wdisk.end())
+            l.exists = true, l.time = i->second.time, l.files = i->second.files, l.subfolders = i->second.subs;
+        return l;
+    };
+    win.refresh ("D:\\", fs);
+    win.markComplete ("D:\\");
+    m = win.folderMatches (accept (lynx::browserview::ContentFilter::audio));
+    CHECK (m.of ("D:\\Samples") == FolderMatches::Contents::some && m.of ("D:\\") == FolderMatches::Contents::some);
+}
+
+#include "core/WindowFit.h"
+
+TEST (misc164_fixed_window_scrolls_when_taller_than_the_screen)
+{
+    using lynx::windowfit::scrollFit;
+    // fits: kept as it is
+    auto f = scrollFit (700, 540, 1280, 690, 16, 40, 12);
+    CHECK (! f.scrolls() && f.w == 700 && f.h == 540);
+    // 150% zoom of a 1080p screen (1280 x ~690 logical): a 760 px tall settings page scrolls, the bar beside it
+    f = scrollFit (700, 760, 1280, 690, 16, 40, 12);
+    CHECK (f.scrollsV && ! f.scrollsH && f.h == 650 && f.w == 712);
+    // too wide as well: both ways, never larger than the screen
+    f = scrollFit (1400, 900, 1280, 690, 16, 40, 12);
+    CHECK (f.scrollsV && f.scrollsH && f.w == 1264 && f.h == 650);
+    // only too wide: the horizontal bar may push it over the height
+    f = scrollFit (1400, 645, 1280, 690, 16, 40, 12);
+    CHECK (f.scrollsH && f.scrollsV && f.h == 650);
+    f = scrollFit (1400, 300, 1280, 690, 16, 40, 12);
+    CHECK (f.scrollsH && ! f.scrollsV && f.h == 312 && f.w == 1264);
+}

+ 107 - 0
tests/Misc164mTests.inc

@@ -0,0 +1,107 @@
+// Round 164e (misc164m): the mod wheel and aftertouch on native instruments (docs/analise/REA_rodada164e-modwheel.md)
+
+namespace misc164m
+{
+// records the live controllers it receives
+struct Spy final : lynx::Instrument
+{
+    int messages = 0, lastStatus = 0, lastData1 = -1, controls = 0, lastCc = -1;
+    float bend = 0.0f, lastValue = -1.0f;
+    void prepare (double) noexcept override {}
+    void noteOn (int, float) noexcept override {}
+    void noteOff (int) noexcept override {}
+    void allNotesOff() noexcept override {}
+    void render (float*, float*, int, float, float) noexcept override {}
+    void midiMessage (const std::uint8_t* bytes, int size) noexcept override
+    {
+        ++messages;
+        lastStatus = size > 0 ? bytes[0] : 0;
+        lastData1 = size > 1 ? bytes[1] : -1;
+    }
+    void pitchBend (float semitones) noexcept override { bend = semitones; }
+    void controlChange (int cc, float value) noexcept override
+    {
+        ++controls;
+        lastCc = cc;
+        lastValue = value;
+    }
+};
+} // namespace misc164m
+
+TEST (misc164m_patcher_passes_live_controllers_to_its_instruments)
+{
+    // FL's Patcher takes MIDI input (its TFruityPlug MIDIIn is implemented, unlike FL's native generators) and passes
+    // it to the plugins cabled to "From FL Studio": the mod wheel / CCs / pressure / bend reach a plugin inside it
+    using namespace patcher162;
+    lynx::ChannelDef channel;
+    channel.instrument = lynx::InstrumentKind::patcher;
+    channel.patcher.nodes = { generatorNode (lynx::InstrumentKind::synth), generatorNode (lynx::InstrumentKind::synth) };
+    channel.patcher.wires = { midi (lynx::patchFromHost, 0, 0, 0), patcher141::audio (0, lynx::patchToHost), patcher141::audio (1, lynx::patchToHost) };
+    std::vector<std::shared_ptr<misc164m::Spy>> spies;
+    auto f = lynx::patcher::builtInFactories (48000.0);
+    f.instrument = [&spies] (const lynx::ChannelDef&) {
+        spies.push_back (std::make_shared<misc164m::Spy>());
+        return std::shared_ptr<lynx::Instrument> (spies.back());
+    };
+    auto i = lynx::patcher::makeInstrument (channel, 48000.0, f);
+    CHECK (spies.size() == 2u);
+    if (spies.size() != 2u)
+        return;
+    const std::uint8_t wheel[3] { 0xB0, 1, 100 }, pressure[2] { 0xD0, 90 };
+    i->midiMessage (wheel, 3);
+    i->controlChange (1, 100.0f / 127.0f);
+    i->midiMessage (pressure, 2);
+    i->pitchBend (-1.5f);
+    const auto& cabled = *spies[0];
+    CHECK (cabled.messages == 2 && cabled.lastStatus == 0xD0 && cabled.lastData1 == 90);
+    CHECK (cabled.controls == 1 && cabled.lastCc == 1 && std::abs (cabled.lastValue - 100.0f / 127.0f) < 1e-6f);
+    CHECK (cabled.bend == -1.5f);
+    // a generator not cabled to the notes gets none of it, like its notes
+    CHECK (spies[1]->messages == 0 && spies[1]->controls == 0 && spies[1]->bend == 0.0f);
+}
+
+TEST (misc164m_native_engines_keep_ignoring_the_mod_wheel_like_fl)
+{
+    // [EXEC] FL's native generators never ask for MIDI input (no FHD_WantMIDIInput at creation; PoiZone, Sakura, 3x Osc…
+    // leave MIDIIn abstract) and MiniSynth / GMS / Morphine / Toxic Biohazard leave their CC table at 0 even when MIDIIn
+    // is called directly: CC 1 does nothing until it is linked. Sakura's engine has a "mod wheel" matrix source (fed only
+    // by its VST host): routed to the level (10^(2·m)·0.05) it stays at 0 in FL, so the note plays at 0.05 with or
+    // without the wheel (a wheel at 127 would make it 100 times louder).
+    auto channel = [] {
+        lynx::ChannelDef c;
+        c.instrument = lynx::InstrumentKind::sakura;
+        c.modelParams.assign (146, 0.0f);
+        const std::pair<int, float> values[] { { 0, 0.375f }, { 1, 0.5f }, { 3, 0.5f }, { 4, 1.0f }, { 6, 0.95f }, { 9, 0.3f },
+                                               { 11, 0.95f }, { 14, 0.3f }, { 18, 0.5f }, { 19, 0.5f }, { 27, 0.5f }, { 28, 1.0f },
+                                               { 29, 0.7f }, { 31, 1.0f }, { 32, 0.5f } };
+        for (const auto& [i, v] : values)
+            c.modelParams[(std::size_t) i] = v;
+        return c;
+    };
+    auto render = [&] (bool routed, bool wheel) {
+        auto c = channel();
+        if (routed)
+            c.modelParams[79] = 3.0f, c.modelParams[80] = 1.0f, c.modelParams[82] = 1.0f; // slot 1: mod wheel → level
+        auto inst = lynx::makeInstrument (lynx::InstrumentKind::sakura);
+        inst->prepare (48000.0);
+        inst->configure (c, 120.0);
+        if (wheel)
+        {
+            const std::uint8_t m[3] { 0xB0, 1, 127 };
+            inst->midiMessage (m, 3);
+            inst->controlChange (1, 1.0f);
+        }
+        inst->noteOn (60, 0.8f);
+        std::vector<float> l (9600), r (9600);
+        for (int s = 0; s < 9600; s += 256)
+            inst->render (l.data() + s, r.data() + s, std::min (256, 9600 - s), 1.0f, 1.0f);
+        double e = 0.0;
+        for (const auto v : l)
+            e += (double) v * v;
+        return e;
+    };
+    CHECK (render (false, false) > 1e-3);                 // the patch sounds
+    CHECK (render (false, true) == render (false, false)); // the wheel changes nothing
+    const auto routed = render (true, false);
+    CHECK (routed > 0.0 && routed < render (false, false) && render (true, true) == routed); // routed: the wheel stays 0
+}

+ 4 - 0
tests/tests.cpp

@@ -16035,6 +16035,8 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "CrashReport159Tests.inc"
 #include "Sampler162Tests.inc"
 #include "Workflow163cTests.inc"
+#include "ClipPitch164Tests.inc"
+#include "Misc164mTests.inc"
 #include "Theme162Tests.inc"
 #include "PluginPresets162Tests.inc"
 #include "Look162Tests.inc"
@@ -16046,3 +16048,5 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Rec163Tests.inc"
 #include "Ui163Tests.inc"
 #include "HwInsert164Tests.inc"
+
+#include "Misc164Tests.inc"