Ver código fonte

Merge origin/main into feature/parity144b

Ka1-S 1 mês atrás
pai
commit
9bfcaf1a3f

+ 2 - 0
CMakeLists.txt

@@ -128,6 +128,7 @@ add_library(lynx_core STATIC
     src/core/MidiControls.cpp
     src/core/FormulaController.cpp
     src/core/VoiceShift.cpp
+    src/core/NativeEngines.cpp
     src/core/FabFilterStates.cpp
     src/core/FlResampler.cpp
     src/core/FlKeys.cpp
@@ -279,6 +280,7 @@ if(LYNX_BUILD_APP)
         src/ui/ExportDialog.cpp
         src/ui/AutomationUi.cpp
         src/ui/ControllerEditors.cpp
+        src/ui/NewtoneEditor.cpp
         src/ui/ChannelSettings.cpp
         src/ui/BrowserComponent.cpp
         src/ui/Theme.cpp

+ 104 - 0
docs/analise/REA_rodada142.md

@@ -0,0 +1,104 @@
+# Round 142 — issue #5: FL-only engines usable in native LYNX projects
+
+Issue #5 (alltern): "Allow the plugins that only exist from flps to be used outside of FLP's or in native projects.
+Like allow the use of Newtone outside of FLP projects." LYNX reproduces many FL engines (rounds 28–73), but until
+now most of them only appeared when an `.flp` was imported: they were not in the mixer's Add menu, the quick-add
+palette, the Patcher or the Channel Rack's "+" menu, and a fresh instance had no usable state.
+
+Evidence markers: **[TEST]** LYNX's tests (`tests/Natives142Tests.inc`, build-local with the FL Data dir),
+**[EXEC]** LYNX.exe `--selftest` / `--snapshot` on Windows with FL Studio 2026 installed, **[DATA]** the files of the
+user's FL installation (read at run time, never copied into LYNX), **[HYP]** inference.
+
+---
+
+## 1. How a fresh FL engine gets its state (`core/NativeEngines.h`)
+
+Most of these engines run on the plugin's own saved state (`ChannelDef::pluginState`, `EffectSlot::state`) and many
+read data files of the FL installation (DLL tables, wave folders, impulses). A new instance therefore starts from the
+plugin's **Default preset of the user's own FL installation**
+(`<Data>\Patches\Plugin presets\<Generators|Effects>\<plugin>\Default.fst`), imported exactly like an `.flp` channel
+or mixer slot (`importFlp` / `effectFromFl` with the installation's data reader). Nothing of FL is stored in LYNX —
+the same contract as an imported project.
+
+- Some engines don't read every version of their plugin's state: Harmor's and Ogun's `Default.fst` are such
+  states (88 of 325 Harmor presets and 95 of 229 Ogun presets fall back to the conversion) **[DATA][TEST]**. The
+  candidates are therefore `Default.*` first, then the folder's presets in order; the first one the exact engine
+  reads is used (at most 60 tries).
+- Presets that are the plugin's raw file (GMS `.gmsynth`, Morphine `.mrp`, Toxic Biohazard `.tbio`) are wrapped as
+  FL saves them: `"SSLF"` + size + the file **[DATA]** (the same wrapper the browser's GMS preset conversion used).
+- BooBass has no preset folder: a new one is its three knobs at their default 0.5 (REA_rodada29 §4) over the
+  multisample of the user's `BooBass_Eng_x64.dll`.
+- FL Keys: FL 2026 ships no `Piano.wti`, which every FL Keys preset names. The folder's `default.wti` says
+  `[default] file=mda piano.wti`; LYNX now loads that wavetable when the named one is missing (also fixes `.flp`
+  imports of FL Keys on FL 2026) **[DATA][TEST]**.
+- Engines that play from an empty state need no FL: 3x Osc, Harmless, SimSynth, Fruity DX10, Plucked!, and the
+  effects Pitch Shifter, Vintage Phaser, Fruity Squeeze, the rhythmic envelope, Newtone and Newtime. With FL
+  installed they still start from FL's Default preset.
+- Without FL (or without the needed data files) an engine is shown **disabled with "(requires FL Studio)"** in the
+  menus and is left out of the quick-add palette and the Browser's Plugin database.
+- Partly reproduced engines carry **"(beta)"**: Harmor, Kepler, Fruity Granulizer, Newtone, Newtime.
+
+| Engine | New instance on this PC | Sound of a note / signal | Notes |
+|---|---|---|---|
+| 3x Osc, Sytrus, Harmless, PoiZone, SimSynth, Fruity DX10, Plucked!, Fruit Kick, Drumpad | Default.fst | ✅ | |
+| Harmor (beta), Ogun | first preset the engine reads | ✅ | Default.fst not readable by the engine |
+| GMS, Morphine | first `.gmsynth` / `.mrp` | ✅ | no Default preset in FL |
+| Toxic Biohazard | `Default.tbio` + the DLL's spectra | ✅ | |
+| Kepler (beta), Transistor Bass, Sawer, MiniSynth, FL Slayer, BassDrum, BooBass | Default + the FL data file | ✅ | |
+| Sakura, BeepMap, Drumaxx | Default.fst | ✅ | (Drumaxx: pads on the drum keys) |
+| FL Keys | Default.fst + `default.wti` fallback | ✅ (zones from the installation) | |
+| Fruity Granulizer (beta) | Default.fst | silent until a sample is given | drop an audio file on its row; it keeps its engine |
+| Maximus, Vocodex, EQUO, Distructor, Love Philter, Gross Beat, Fruity Convolver | Default.fst (+ impulses / install data) | ✅ | |
+| Pitch Shifter, Vintage Phaser, Fruity Squeeze, rhythmic envelope | Default.fst / LYNX defaults | ✅ | |
+| Newtone (beta), Newtime (beta) | LYNX's own project (§3) | ✅ | |
+
+All 26 instruments and 13 effects are made, survive `.lynx` save / load and the instruments play through the rack
+(`native_engines=OK (39 made)` in the selftest) **[EXEC][TEST]**.
+
+Not offered: Fruity DrumSynth Live (FL's Default/Extra presets are version-1 24-patch kits, which the engine does
+not read), Wasp / Wasp XT and Fruity Dance (FL 2026's placeholders make no sound), Autogun and DirectWave (no
+preset to start from; DirectWave as a plain sampler is LYNX's Sampler). They still import from `.flp`.
+
+## 2. Where they appear
+
+- **Mixer** slot menu (Add / Replace with), **quick-add palette** (effects and instruments), **Patcher** editor
+  (Add effect; Add instrument › FL engines), **Channel Rack** "+" menu › FL engines (the channel's editor opens),
+  and a new **Browser › Plugin database** (FL's, interpreted): Generators and Effects, each with LYNX, FL engines and
+  Installed (the scanned VST3 / CLAP plugins); double-click adds it (a generator = new channel, an effect = into the
+  selected insert); the folders remember being open.
+- The native-editor fuzz of the selftest now opens the FL effects with their fresh state, as the menus make them.
+
+## 3. Newtone and Newtime in a native project (`core/NewtoneFx.h`, `ui/NewtoneEditor.cpp`)
+
+FL's Newtone / Newtime are editors around zplane's engines; LYNX only played back an imported Newtone's edits
+(REA_rodada73/95). For native slots LYNX now has its own project format and editors:
+
+- **Newtone**: `analyseNotes` (YIN pitch track, frames below −34 dB of the loudest ignored, a new note when the
+  smoothed pitch moves > 0.7 semitone for 3 frames, notes ≥ 60 ms, median pitch) → notes; the edits are rendered by
+  LYNX's Newtone engine (TD-PSOLA, round 95). State `"LXNT"` v1: frames, global formant, the notes' fields.
+  Editor: notes on a pitch grid with the sung pitch inside them; drag = pitch (snapped to semitones; Alt free),
+  Ctrl+drag = time, double-click = snap, right-click = snap / reset / mute / volume; Up/Down move the selected one,
+  Delete mutes it; "Snap all to notes", "Reset edits", "Analyse", Preview, "Save as WAV...", "Play with the song"
+  (the plugin's slave mode). An imported FL Newtone opens with its notes; editing saves it in LYNX's format.
+- **Newtime**: warp markers (source → output sample); between markers the source is time-stretched with pitch kept
+  (`timeStretch`, WSOLA); after the last marker its slope goes on; the first marker added also pins the end, so a
+  marker drag stretches one side and squeezes the other. State `"LXNW"` v1. Editor: the warped waveform with the
+  song's beats; double-click adds a marker, drag moves it, right-click removes it; "Length..." = 50–200 % or 1–16
+  bars at the song's tempo.
+- A synthetic sung line (A3 B3 C4 · E4) analyses to 4 notes within 0.1 semitone; moving B3 +2 renders C#4
+  (60.96); unedited notes return the source unchanged; markers map both ways exactly **[TEST]**.
+- Snapshots: `--snapshot` writes `-newtone.png`, `-newtime.png`, `-browser-plugins.png` **[EXEC]**.
+
+## 4. Tests
+
+`tests/Natives142Tests.inc`: lists and no-FL behaviour; FL Keys `default.wti`; every engine from the real FL
+installation (made, right kind, renders > −60 dBFS RMS, effects finite and not silent, state-based ones carry FL's
+state); Newtone / Newtime native projects. Selftest: `native_engines`.
+
+## Where I stopped
+
+- Newtone: no formant / vibrato / drift controls in the editor yet (the engine and state support them), no note
+  split / merge, no multi-select. Newtime: no transient detection for automatic markers.
+- No drag-and-drop from the Plugin database onto the Channel Rack / Mixer (double-click and the menu add).
+- Engines without a preset to start from (DrumSynth Live v1 kits, Autogun, DirectWave) are not offered.
+- On Linux / macOS (no FL installation) only the engines with LYNX defaults are offered.

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

@@ -3701,3 +3701,32 @@ countries: br
 "Dynamic phase: the crossovers' phase only where a band works; linear phase: no phase change (more latency); minimum phase: the classic crossover sum" = "Fase dinâmica: a fase dos crossovers só onde uma banda atua; fase linear: sem mudança de fase (mais latência); fase mínima: a soma clássica dos crossovers"
 "Resolution" = "Resolução"
 "What each band's pan balances: left / right, or mid / side" = "O que o pan de cada banda equilibra: esquerda / direita, ou meio / lados"
+
+# Round 142: FL engines in native projects, Newtone / Newtime editors
+"FL engines" = "Motores do FL"
+"{0} (beta)" = "{0} (beta)"
+"{0} (requires FL Studio)" = "{0} (requer o FL Studio)"
+"built-in FL engine" = "motor do FL embutido"
+"This engine needs the data files of an FL Studio installation, which were not found or could not be read." = "Este motor precisa dos arquivos de dados de uma instalação do FL Studio, que não foram encontrados ou não puderam ser lidos."
+"(beta) LYNX's own analysis and pitch / time engines; FL's own edits are not reproduced exactly" = "(beta) análise e motores de afinação / tempo do próprio LYNX; as edições do FL não são reproduzidas exatamente"
+"Analyse" = "Analisar"
+"Choose the audio file to edit (WAV, AIFF, FLAC, OGG, MP3)" = "Escolha o arquivo de áudio para editar (WAV, AIFF, FLAC, OGG, MP3)"
+"Find the notes of the sample again (discards the note edits)" = "Encontrar as notas do sample de novo (descarta as edições das notas)"
+"Length..." = "Duração..."
+"Load a sample to edit it (Load sample... or drop an audio file here)" = "Carregue um sample para editá-lo (Carregar sample... ou solte um arquivo de áudio aqui)"
+"Play with the song" = "Tocar com a música"
+"Reset edits" = "Desfazer edições"
+"Reset this note" = "Restaurar esta nota"
+"Save the edited audio" = "Salvar o áudio editado"
+"Slave to host playback: while the song plays, the edited sample plays from the song's start" = "Seguir a reprodução do host: enquanto a música toca, o sample editado toca a partir do início da música"
+"Snap all to notes" = "Ajustar tudo às notas"
+"Snap to the nearest note" = "Ajustar à nota mais próxima"
+"This slot no longer holds this plugin" = "Este slot não contém mais este plugin"
+"{0} bar(s) at {1} BPM" = "{0} compasso(s) a {1} BPM"
+"{0} notes. Drag: pitch (Alt: free), Ctrl+drag: time, double-click: snap, right-click: menu" = "{0} notas. Arrastar: afinação (Alt: livre), Ctrl+arrastar: tempo, duplo clique: ajustar, botão direito: menu"
+"{0} warp markers. Double-click: add a marker, drag it to move that point, right-click: remove" = "{0} marcadores de warp. Duplo clique: adicionar um marcador, arrastar: mover esse ponto, botão direito: remover"
+"Plugin database" = "Banco de plugins"
+"Installed" = "Instalados"
+"Plugin database: LYNX's built-in generators and effects, FL's engines and the installed plugins" = "Banco de plugins: geradores e efeitos embutidos do LYNX, motores do FL e os plugins instalados"
+"[double-click] add it (generators: a new channel; effects: into the selected insert)" = "[duplo clique] adicionar (geradores: um novo canal; efeitos: no insert selecionado)"
+"Linear|Dynamic|Minimum" = "Linear|Dinâmica|Mínima"

+ 2 - 0
scripts/build-local.sh

@@ -59,6 +59,8 @@ CORE="$CORE src/core/VoiceTools.cpp"
 # MIDI CC automation of hosted plugins, Formula Controller (round 133, issue #3)
 CORE="$CORE src/core/MidiControls.cpp src/core/FormulaController.cpp"
 CORE="$CORE src/core/VoiceShift.cpp"
+# FL engines usable in native projects (round 142, issue #5)
+CORE="$CORE src/core/NativeEngines.cpp"
 # WavPack decoder (C)
 if [[ -z "${CC:-}" ]]; then
     case "$CXX" in

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

@@ -122,6 +122,8 @@ APP_SOURCES+=(src/core/VoiceTools.cpp)
 # MIDI CC automation of hosted plugins, Formula Controller (round 133, issue #3)
 APP_SOURCES+=(src/core/MidiControls.cpp src/core/FormulaController.cpp src/ui/ControllerEditors.cpp)
 APP_SOURCES+=(src/core/VoiceShift.cpp)
+# FL engines usable in native projects (round 142, issue #5)
+APP_SOURCES+=(src/core/NativeEngines.cpp src/ui/NewtoneEditor.cpp)
 # FL's DirectWave (REA round 72)
 APP_SOURCES+=(src/core/DirectWave.cpp)
 # Ogg Vorbis decoding as FL does (REA round 77)

+ 130 - 2
src/Main.cpp

@@ -32,6 +32,8 @@
 #include "ui/PluginSkin.h"
 #include "ui/ChannelSettings.h"
 #include "ui/ControllerEditors.h"
+#include "ui/NewtoneEditor.h"
+#include "core/NewtoneFx.h"
 #include "core/FormulaController.h"
 #include "core/MidiControls.h"
 #include "core/FlSynths.h"
@@ -1103,7 +1105,71 @@ private:
                         && back->channels.back().patcher.wires == ch.patcher.wires;
         }
 
-        const auto ok = audioOk && projectOk && richOk && substituteOk && patcherOk && undoOk && recordOk && recordUndoOk && midiOk && packageOk
+        // FL engines in a native project (round 142, issue #5): every engine this PC can make survives save / load and
+        // the instruments play through the rack
+        juce::String nativesResult = "OK";
+        int nativesMade = 0, nativesSilent = 0;
+        {
+            auto song = lynx::Song::makeDefault();
+            song.channels.clear();
+            song.patterns[0].notes.clear();
+            song.mixer.resize (3);
+            const auto& fl = lynx::flStudioAccess();
+            for (const auto& e : lynx::natives::instrumentEngines())
+                if (lynx::natives::available (e, fl))
+                    if (auto c = lynx::natives::makeChannel (e.kind, fl))
+                    {
+                        c->mixerTrack = 1;
+                        song.channels.push_back (*c);
+                    }
+            for (const auto& e : lynx::natives::effectEngines())
+                if (auto fx = lynx::natives::makeSlot (e.kind, fl))
+                    song.mixer[2].effects.push_back (*fx);
+            nativesMade = (int) (song.channels.size() + song.mixer[2].effects.size());
+            const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
+            auto same = back && back->channels.size() == song.channels.size() && back->mixer.size() >= 3
+                        && back->mixer[2].effects.size() == song.mixer[2].effects.size();
+            for (std::size_t i = 0; same && i < song.channels.size(); ++i)
+            {
+                const auto& a = song.channels[i];
+                const auto& b = back->channels[i];
+                same = a.instrument == b.instrument && a.pluginState == b.pluginState && a.samplePath == b.samplePath && a.zones.size() == b.zones.size()
+                       && a.modelParams.size() == b.modelParams.size();
+                if (! same)
+                    nativesResult = "ERROR channel " + juce::String::fromUTF8 (a.name.c_str());
+            }
+            for (std::size_t i = 0; same && i < song.mixer[2].effects.size(); ++i)
+            {
+                const auto& a = song.mixer[2].effects[i];
+                const auto& b = back->mixer[2].effects[i];
+                same = a.kind == b.kind && a.state == b.state;
+                for (std::size_t p = 0; same && p < a.params.size(); ++p)
+                    same = std::abs (a.params[p] - b.params[p]) < 1.0e-3f;
+                if (! same)
+                    nativesResult = juce::String ("ERROR effect ") + lynx::effectInfo (a.kind).name;
+            }
+            if (! back)
+                nativesResult = "ERROR " + error;
+            // each instrument plays a note alone (the granulizer needs a sample: it is silent here)
+            for (std::size_t i = 0; same && i < song.channels.size(); ++i)
+            {
+                auto one = song;
+                one.channels = { song.channels[i] };
+                one.channels[0].mixerTrack = 1;
+                one.mixer[2].effects.clear();
+                one.patterns[0].notes = { { 0, 1920, 0, song.channels[i].instrument == lynx::InstrumentKind::drumaxx ? 48 : 60, 0.8f } };
+                lynx::AudioEngine player (false);
+                player.setSong (std::move (one));
+                player.dispatchPendingMessages();
+                if (! (player.renderOffline (1.0, 48000.0) > 1.0e-4f) && song.channels[i].instrument != lynx::InstrumentKind::granulizer)
+                    ++nativesSilent;
+            }
+            if (nativesSilent > 0 && nativesResult == "OK")
+                nativesResult = "SILENT " + juce::String (nativesSilent);
+        }
+        const auto nativesOk = nativesResult == "OK";
+
+        const auto ok = audioOk && projectOk && richOk && substituteOk && patcherOk && nativesOk && undoOk && recordOk && recordUndoOk && midiOk && packageOk
                         && wavpack != "ERROR" && effectsOk;
 
         juce::String report;
@@ -1113,6 +1179,7 @@ private:
                << "project_features=" << (richOk ? "OK" : "ERROR") << "\n"
                << "plugin_substitutes=" << (substituteOk ? "OK" : "ERROR") << "\n"
                << "patcher=" << (patcherOk ? "OK" : "ERROR") << "\n"
+               << "native_engines=" << nativesResult << " (" << nativesMade << " made)\n"
                << "undo=" << (undoOk ? "OK" : "ERROR") << "\n"
                << "recording=" << (recordOk && recordUndoOk ? "OK" : "ERROR") << "\n"
                << "midi=" << (midiOk ? "OK" : "ERROR") << "\n"
@@ -1149,7 +1216,8 @@ private:
                     continue;
                 const auto before = lynx::RackRenderer::nonFiniteEffectBlocks();
                 const auto& info = lynx::effectInfo (kind);
-                auto fx = lynx::makeEffectSlot (kind);
+                // (FL engines: a fresh instance as the menus make it, from the user's FL installation; round 142)
+                auto fx = lynx::natives::newEffect (kind, lynx::flStudioAccess()).value_or (lynx::makeEffectSlot (kind));
                 int dragged = 0; // parameter changes made by the mouse drags
 
                 for (int round = 0; round < rounds; ++round)
@@ -3146,6 +3214,63 @@ private:
                 saveWindow (lynx::makePluginMonitorPanel (offline), "-plugin-monitor.png");
                 saveWindow (lynx::makeTouchKeyboardPanel (offline), "-touch-keyboard.png");
             }
+            {
+                // round 142: the Newtone / Newtime editors on a synthetic sung line (A3 B3 C4 · E4), one note moved
+                const auto wav = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-snapshot-newtone.wav");
+                {
+                    juce::AudioBuffer<float> line (1, 44100 * 2);
+                    const double hz[] = { 220.0, 246.94, 261.63, 0.0, 329.63 };
+                    double ph = 0.0;
+                    for (int i = 0; i < line.getNumSamples(); ++i)
+                    {
+                        const auto f0 = hz[std::min (4, i / 17640)];
+                        ph += 2.0 * juce::MathConstants<double>::pi * f0 * (1.0 + 0.004 * std::sin (2.0 * juce::MathConstants<double>::pi * 5.5 * i / 44100.0)) / 44100.0;
+                        float v = 0.0f;
+                        for (int h = 1; f0 > 0.0 && h < 8; ++h)
+                            v += (float) (0.3 / h * std::sin (h * ph));
+                        line.setSample (0, i, v);
+                    }
+                    wav.deleteFile();
+                    juce::WavAudioFormat format;
+                    std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
+                    if (auto* w = out != nullptr ? format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0) : nullptr)
+                    {
+                        out.release();
+                        std::unique_ptr<juce::AudioFormatWriter> writer (w);
+                        writer->writeFromAudioSampleBuffer (line, 0, line.getNumSamples());
+                    }
+                }
+                if (const auto sample = offline.getSampleLibrary().load (wav.getFullPathName()))
+                {
+                    auto notes = lynx::newtonefx::analyseNotes (*sample);
+                    if (notes.pitches.size() > 1)
+                        notes.pitches[1].shift = 2.0;
+                    lynx::newtonefx::WarpMap warp;
+                    warp.frames = (std::int64_t) sample->frames();
+                    warp.markers = { { 22050, 33075 } };
+                    int at = 0;
+                    offline.editSong ([&] (lynx::Song& song) {
+                        if (song.mixer.size() < 2)
+                            song.mixer.resize (2);
+                        auto& fx = song.mixer[1].effects;
+                        auto tone = lynx::makeEffectSlot (lynx::EffectKind::newtone);
+                        tone.samplePath = wav.getFullPathName().toStdString();
+                        tone.state = lynx::newtonefx::writeNative (notes);
+                        auto time = lynx::makeEffectSlot (lynx::EffectKind::newtime);
+                        time.samplePath = tone.samplePath;
+                        time.state = lynx::newtonefx::writeWarp (warp);
+                        at = (int) fx.size();
+                        fx.push_back (tone);
+                        fx.push_back (time);
+                    }, false);
+                    saveWindow (lynx::makeNewtoneEditor (offline, 1, at), "-newtone.png");
+                    saveWindow (lynx::makeNewtoneEditor (offline, 1, at + 1), "-newtime.png");
+                    offline.editSong ([at] (lynx::Song& song) {
+                        auto& fx = song.mixer[1].effects;
+                        fx.erase (fx.begin() + at, fx.begin() + at + 2);
+                    }, false);
+                }
+            }
 
             if (! offline.getSong().automations.empty())
             {
@@ -3361,6 +3486,9 @@ private:
             ui.getBrowserForSnapshot().showProjectForSnapshot();
             offline.dispatchPendingMessages();
             saveSnapshot (ui, prefix + "-browser-project.png");
+            ui.getBrowserForSnapshot().showPluginDatabaseForSnapshot(); // round 142: the Plugin database's FL engines
+            offline.dispatchPendingMessages();
+            saveSnapshot (ui, prefix + "-browser-plugins.png");
             ui.getBrowserForSnapshot().setTab (lynx::BrowserComponent::allTab);
 
             // the undo history after a few edits

+ 14 - 1
src/core/FlKeys.cpp

@@ -353,7 +353,20 @@ bool importChannel (ChannelDef& def, const std::vector<std::uint8_t>& state, con
     const auto s = parseState (state);
     if (! s || s->wavetable.empty() || s->wavetable.find_first_of ("\\/:") != std::string::npos || ! readFile || ! existing)
         return false;
-    const auto wtiBytes = readFile (wavetables + "\\" + s->wavetable + ".wti");
+    auto wtiBytes = readFile (wavetables + "\\" + s->wavetable + ".wti");
+    if (wtiBytes.empty())
+    {
+        // a wavetable this installation doesn't ship (FL 2026 has no "Piano"): the folder's default.wti names the
+        // wavetable FL Keys loads instead ("[default] file=mda piano.wti", round 142)
+        const auto def = readFile (wavetables + "\\default.wti");
+        const std::string text (def.begin(), def.end());
+        if (const auto at = text.find ("file="); at != std::string::npos)
+        {
+            auto name = text.substr (at + 5, text.find_first_of ("\r\n", at) - at - 5);
+            if (! name.empty() && name.find_first_of ("\\/:") == std::string::npos)
+                wtiBytes = readFile (wavetables + "\\" + name);
+        }
+    }
     std::vector<std::string> names;
     auto table = parseWti (std::string (wtiBytes.begin(), wtiBytes.end()), names);
     if (! table)

+ 319 - 0
src/core/NativeEngines.cpp

@@ -0,0 +1,319 @@
+#include "core/NativeEngines.h"
+
+#include <algorithm>
+
+#include "core/Effects.h"
+#include "core/FlEffects.h"
+#include "core/GrossBeat.h"
+#include "core/PhysicalModels.h"
+#include "flp/Flp.h"
+
+namespace lynx::natives
+{
+namespace
+{
+constexpr auto fl = Needs::flStudio;
+constexpr auto own = Needs::nothing;
+
+std::string lower (std::string s)
+{
+    std::transform (s.begin(), s.end(), s.begin(), [] (unsigned char c) { return (char) std::tolower (c); });
+    return s;
+}
+
+bool endsWith (const std::string& s, const std::string& tail)
+{
+    return s.size() >= tail.size() && lower (s.substr (s.size() - tail.size())) == tail;
+}
+
+// The plugin's name as FL's import knows it (event 0xC9 of a channel / slot)
+const char* flPluginName (InstrumentKind kind)
+{
+    switch (kind)
+    {
+        case InstrumentKind::toxic: return "Toxic Biohazard";
+        case InstrumentKind::gms: return "GMS";
+        case InstrumentKind::morphine: return "Morphine";
+        default: return "";
+    }
+}
+
+std::vector<std::uint8_t> readPreset (const std::string& path, const FlAccess& access)
+{
+    if (path.empty() || ! access.readFile)
+        return {};
+    return access.readFile (path);
+}
+
+FlpImportOptions importOptions (const FlAccess& access)
+{
+    FlpImportOptions options;
+    options.roots = access.roots;
+    options.fileExists = access.fileExists;
+    options.readFile = access.readFile;
+    options.saveEmbedded = access.saveEmbedded;
+    return options;
+}
+
+std::optional<ChannelDef> channelFromPreset (InstrumentKind kind, const InstrumentEngine& engine, const std::string& path, const FlAccess& access)
+{
+    const auto bytes = readPreset (path, access);
+    if (bytes.empty())
+        return std::nullopt;
+    try
+    {
+        flp::Project project;
+        if (! endsWith (path, ".fst")) // Toxic Biohazard's .tbio, GMS' .gmsynth, Morphine's .mrp
+        {
+            flp::Channel c;
+            c.pluginName = flPluginName (kind);
+            // the state FL saves is "SSLF" + size + the preset file
+            c.pluginState = { 'S', 'S', 'L', 'F' };
+            for (int i = 0; i < 4; ++i)
+                c.pluginState.push_back ((std::uint8_t) (bytes.size() >> (8 * i)));
+            c.pluginState.insert (c.pluginState.end(), bytes.begin(), bytes.end());
+            project.channels.push_back (c);
+        }
+        else
+            project = flp::parseProject (bytes, true);
+
+        if (project.channels.empty())
+            return std::nullopt;
+        auto& c = project.channels.front();
+        c.name = engine.name;
+        if (c.type == flp::ChannelType::unknown)
+            c.type = flp::ChannelType::instrument;
+        c.mixerTrack = -1;
+        const auto song = importFlp (project, importOptions (access));
+        if (song.channels.empty() || song.channels.front().instrument != kind)
+            return std::nullopt;
+        auto def = song.channels.front();
+        def.name = engine.name;
+        def.mixerTrack = 0;
+        return def;
+    }
+    catch (const flp::Error&)
+    {
+        return std::nullopt;
+    }
+}
+} // namespace
+
+const std::vector<InstrumentEngine>& instrumentEngines()
+{
+    // name, preset folder (Generators), needs, beta. Engines that play from an empty state (LYNX's own defaults) need
+    // nothing; the rest start from the user's FL "Default" preset (with its data files: DLL tables, wave folders...).
+    static const std::vector<InstrumentEngine> list = {
+        { InstrumentKind::threeosc, "3x Osc", "3x Osc", own, false },
+        { InstrumentKind::sytrus, "Sytrus", "Sytrus", fl, false },
+        { InstrumentKind::harmor, "Harmor", "Harmor", fl, true },
+        { InstrumentKind::harmless, "Harmless", "Harmless", own, false },
+        { InstrumentKind::gms, "GMS", "GMS", fl, false },
+        { InstrumentKind::morphine, "Morphine", "Morphine", fl, false },
+        { InstrumentKind::ogun, "Ogun", "Ogun", fl, false },
+        { InstrumentKind::toxic, "Toxic Biohazard", "Toxic Biohazard", fl, false },
+        { InstrumentKind::poizone, "PoiZone", "PoiZone", fl, false },
+        { InstrumentKind::sakura, "Sakura", "Sakura", fl, false },
+        { InstrumentKind::kepler, "Kepler", "Kepler", fl, true },
+        { InstrumentKind::transistorbass, "Transistor Bass", "Transistor Bass", fl, false },
+        { InstrumentKind::boobass, "BooBass", "", fl, false }, // (its multisample: the user's BooBass_Eng_x64.dll)
+        { InstrumentKind::simsynth, "SimSynth", "SimSynth", own, false },
+        { InstrumentKind::minisynth, "MiniSynth", "MiniSynth", fl, false },
+        { InstrumentKind::dx10, "Fruity DX10", "Fruity DX10", own, false },
+        { InstrumentKind::plucked, "Plucked!", "Plucked!", own, false },
+        { InstrumentKind::sawer, "Sawer", "Sawer", fl, false },
+        { InstrumentKind::beepmap, "BeepMap", "BeepMap", fl, false },
+        { InstrumentKind::flkeys, "FL Keys", "FL Keys", fl, false },
+        { InstrumentKind::slayer, "FL Slayer", "FL Slayer", fl, false },
+        { InstrumentKind::granulizer, "Fruity Granulizer", "Fruity Granulizer", fl, true },
+        { InstrumentKind::drumaxx, "Drumaxx", "Drumaxx", fl, false },
+        { InstrumentKind::drumpad, "Drumpad", "Drumpad", fl, false },
+        { InstrumentKind::fruitkick, "Fruit Kick", "Fruit Kick", fl, false },
+        { InstrumentKind::bassdrum, "BassDrum", "BassDrum", fl, false },
+    };
+    return list;
+}
+
+const std::vector<EffectEngine>& effectEngines()
+{
+    static const std::vector<EffectEngine> list = {
+        { EffectKind::maximus, "Maximus", fl, false },
+        { EffectKind::vocodex, "Vocodex", fl, false },
+        { EffectKind::equo, "EQUO", fl, false },
+        { EffectKind::distructor, "Distructor", fl, false },
+        { EffectKind::lovePhilter, "Fruity Love Philter", fl, false },
+        { EffectKind::grossBeat, "Gross Beat", fl, false },
+        { EffectKind::convolver, "Fruity Convolver", fl, false },
+        { EffectKind::flPitchShifter, "Pitch Shifter", own, false },
+        { EffectKind::vintagePhaser, "Vintage Phaser", own, false },
+        { EffectKind::squeeze, "Fruity Squeeze", own, false },
+        { EffectKind::rhythmGain, "", own, false },
+        { EffectKind::newtone, "", own, true },
+        { EffectKind::newtime, "", own, true },
+    };
+    return list;
+}
+
+const InstrumentEngine* instrumentEngine (InstrumentKind kind)
+{
+    for (const auto& e : instrumentEngines())
+        if (e.kind == kind)
+            return &e;
+    return nullptr;
+}
+
+const EffectEngine* effectEngine (EffectKind kind)
+{
+    for (const auto& e : effectEngines())
+        if (e.kind == kind)
+            return &e;
+    return nullptr;
+}
+
+std::vector<std::string> presetCandidates (const std::string& presetFolder, bool generator, const FlAccess& access)
+{
+    std::vector<std::string> out;
+    if (presetFolder.empty() || access.roots.data.empty())
+        return out;
+    const auto folder = std::string ("%FLStudioData%\\Patches\\Plugin presets\\") + (generator ? "Generators\\" : "Effects\\") + presetFolder;
+    const auto exists = [&access] (const std::string& p) { return ! p.empty() && access.fileExists && access.fileExists (p); };
+
+    for (const auto* name : { "Default.fst", "Default.tbio", "Default\\Default.tbio" })
+        if (const auto path = resolveFlPath (folder + "\\" + name, access.roots); exists (path))
+            out.push_back (path);
+
+    if (access.listPresets)
+        for (const auto& path : access.listPresets (resolveFlPath (folder, access.roots)))
+            if ((endsWith (path, ".fst") || endsWith (path, ".tbio") || endsWith (path, ".gmsynth") || endsWith (path, ".mrp"))
+                && std::find (out.begin(), out.end(), path) == out.end())
+                out.push_back (path);
+    return out;
+}
+
+std::string defaultPresetPath (const std::string& presetFolder, bool generator, const FlAccess& access)
+{
+    const auto c = presetCandidates (presetFolder, generator, access);
+    return c.empty() ? std::string() : c.front();
+}
+
+namespace
+{
+// BooBass has no preset folder: a new one is its three knobs at their defaults (0.5, REA_rodada29 §4) over the
+// multisample of the user's own engine DLL
+std::string booBassDll (const FlAccess& access)
+{
+    const auto dll = resolveFlPath ("%FLStudioFactoryData%\\Plugins\\Fruity\\Generators\\BooBass\\BooBass_Eng_x64.dll", access.roots);
+    return ! dll.empty() && access.fileExists && access.fileExists (dll) ? dll : std::string();
+}
+} // namespace
+
+bool available (const InstrumentEngine& e, const FlAccess& access)
+{
+    if (e.kind == InstrumentKind::boobass)
+        return ! booBassDll (access).empty();
+    return e.needs == Needs::nothing || ! defaultPresetPath (e.presetFolder, true, access).empty();
+}
+
+bool available (const EffectEngine& e, const FlAccess& access)
+{
+    return e.needs == Needs::nothing || ! defaultPresetPath (e.presetFolder, false, access).empty();
+}
+
+std::optional<ChannelDef> makeChannel (InstrumentKind kind, const FlAccess& access)
+{
+    const auto* engine = instrumentEngine (kind);
+    if (engine == nullptr)
+        return std::nullopt;
+
+    if (kind == InstrumentKind::boobass)
+    {
+        const auto dll = booBassDll (access);
+        if (dll.empty() || ! booBassDllUsable (dll))
+            return std::nullopt;
+        ChannelDef def;
+        def.name = engine->name;
+        def.instrument = kind;
+        def.samplePath = dll;
+        def.modelParams = { 32768.0f, 32768.0f, 32768.0f };
+        return def;
+    }
+
+    // the user's FL default preset, imported like an .flp channel (the exact engine with its data files)
+    int tries = 0;
+    for (const auto& path : presetCandidates (engine->presetFolder, true, access))
+    {
+        if (++tries > 60)
+            break;
+        if (auto def = channelFromPreset (kind, *engine, path, access))
+            return def;
+    }
+
+    if (engine->needs != Needs::nothing)
+        return std::nullopt;
+
+    ChannelDef def; // LYNX's own default: the engine plays from an empty state
+    def.name = engine->name;
+    def.instrument = kind;
+    return def;
+}
+
+std::optional<EffectSlot> makeSlot (EffectKind kind, const FlAccess& access, double bpm)
+{
+    const auto* engine = effectEngine (kind);
+    if (engine == nullptr)
+        return std::nullopt;
+
+    if (const auto path = defaultPresetPath (engine->presetFolder, false, access); ! path.empty())
+    {
+        const auto bytes = readPreset (path, access);
+        try
+        {
+            const auto project = flp::parseProject (bytes, true);
+            if (! project.channels.empty() && ! project.channels.front().pluginState.empty())
+            {
+                const FlDataReader data = [&access] (const std::string& relative) -> std::vector<std::uint8_t> {
+                    const auto p = resolveFlPath ("%FLStudioFactoryData%\\" + relative, access.roots);
+                    if (p.empty() || ! access.readFile || (access.fileExists && ! access.fileExists (p)))
+                        return {};
+                    return access.readFile (p);
+                };
+                auto slot = effectFromFl (project.channels.front().pluginName.empty() ? engine->presetFolder : project.channels.front().pluginName,
+                                          project.channels.front().pluginState, bpm, data);
+                if (slot && slot->kind == kind)
+                {
+                    if (kind == EffectKind::grossBeat)
+                        grossbeat::setPpq (slot->state, 96);
+                    return slot;
+                }
+            }
+        }
+        catch (const flp::Error&)
+        {
+        }
+    }
+
+    if (engine->needs != Needs::nothing)
+        return std::nullopt;
+    return makeEffectSlot (kind);
+}
+
+std::optional<EffectSlot> newEffect (EffectKind kind, const FlAccess& access, double bpm)
+{
+    if (effectEngine (kind) != nullptr)
+        return makeSlot (kind, access, bpm);
+    return makeEffectSlot (kind);
+}
+
+std::string effectMenuName (EffectKind kind)
+{
+    std::string name = effectInfo (kind).name;
+    if (const auto* e = effectEngine (kind); e != nullptr && e->beta)
+        name += " (beta)";
+    return name;
+}
+
+std::string instrumentMenuName (const InstrumentEngine& e)
+{
+    return std::string (e.name) + (e.beta ? " (beta)" : "");
+}
+} // namespace lynx::natives

+ 85 - 0
src/core/NativeEngines.h

@@ -0,0 +1,85 @@
+#pragma once
+
+// FL Studio engines that LYNX reproduces, as instruments and effects a user adds to a native LYNX project (round 142,
+// issue #5) instead of only meeting them inside an imported .flp. docs/analise/REA_rodada142.md.
+//
+// Most of these engines run on the plugin's own saved state (ChannelDef::pluginState / EffectSlot::state), and many
+// also read data files of the user's FL installation at run time (wave tables, multisamples, impulses). A new instance
+// therefore starts from the plugin's "Default" preset of the user's own FL installation (Data\Patches\Plugin presets),
+// imported exactly like an .flp channel or mixer slot: nothing of FL is stored in LYNX. Engines that need no FL data
+// start from LYNX's own defaults; the others say "requires FL Studio" in the menus when FL is not installed.
+
+#include <functional>
+#include <optional>
+#include <string>
+#include <vector>
+
+#include "core/FlpImport.h"
+#include "core/Song.h"
+
+namespace lynx::natives
+{
+enum class Needs
+{
+    nothing,   // LYNX's own default state: always available
+    flStudio   // the Default preset (and data files) of the user's FL installation
+};
+
+struct InstrumentEngine
+{
+    InstrumentKind kind;
+    const char* name;          // English name (the channel's name)
+    const char* presetFolder;  // folder under Data\Patches\Plugin presets\Generators ("" = none)
+    Needs needs;
+    bool beta;                 // partly reproduced: shown with a "(beta)" tag
+};
+
+struct EffectEngine
+{
+    EffectKind kind;
+    const char* presetFolder;  // folder under Data\Patches\Plugin presets\Effects ("" = none)
+    Needs needs;
+    bool beta;
+};
+
+// Every FL instrument engine a native project can add (the Channel Rack's "+" menu, the quick-add palette, the
+// Patcher, the Browser's plugin database), in menu order
+const std::vector<InstrumentEngine>& instrumentEngines();
+// The FL effect engines that are not in the plain effect list (makeEffectSlot alone is not a usable instance)
+const std::vector<EffectEngine>& effectEngines();
+const InstrumentEngine* instrumentEngine (InstrumentKind kind);
+const EffectEngine* effectEngine (EffectKind kind);
+
+// How the engines reach the user's FL installation (the app: findFlStudioRoots + the file system; tests: a folder)
+struct FlAccess
+{
+    FlPathRoots roots;
+    std::function<bool (const std::string&)> fileExists;
+    std::function<std::vector<std::uint8_t> (const std::string&)> readFile;
+    std::function<std::vector<std::string> (const std::string& folder)> listPresets; // the preset files under a folder, sorted
+    std::function<std::string (const std::vector<std::uint8_t>& wav, const std::string& name)> saveEmbedded; // (FL Keys' raw tables)
+};
+
+// The presets a new instance may start from, in order: Default.fst in <Data>\Patches\Plugin presets\<Generators|Effects>\<folder>,
+// then the folder's other presets (the first one LYNX's engine reads exactly is used: some engines don't
+// read every version of their plugin's state); empty = FL not installed, or no preset for this plugin
+std::vector<std::string> presetCandidates (const std::string& presetFolder, bool generator, const FlAccess& fl);
+std::string defaultPresetPath (const std::string& presetFolder, bool generator, const FlAccess& fl);
+
+// Whether a new instance can be made on this PC
+bool available (const InstrumentEngine& e, const FlAccess& fl);
+bool available (const EffectEngine& e, const FlAccess& fl);
+
+// A new channel / slot of that engine, or nullopt when it can't be made here (FL not installed, preset unreadable,
+// the engine's data files missing). The channel keeps its default name; mixerTrack is left to the caller.
+std::optional<ChannelDef> makeChannel (InstrumentKind kind, const FlAccess& fl);
+std::optional<EffectSlot> makeSlot (EffectKind kind, const FlAccess& fl, double bpm = 120.0);
+
+// Any effect kind: the FL engines through makeSlot, the others makeEffectSlot (nullopt only for an FL engine that
+// can't be made here)
+std::optional<EffectSlot> newEffect (EffectKind kind, const FlAccess& fl, double bpm = 120.0);
+
+// The effect's name in the menus, with " (beta)" for partly reproduced engines
+std::string effectMenuName (EffectKind kind);
+std::string instrumentMenuName (const InstrumentEngine& e);
+} // namespace lynx::natives

+ 342 - 5
src/core/NewtoneFx.cpp

@@ -647,10 +647,347 @@ std::unique_ptr<Effect> make (std::shared_ptr<const SampleData> source)
 
 std::unique_ptr<Effect> make (std::shared_ptr<const SampleData> source, const std::vector<std::uint8_t>& state)
 {
-    if (source != nullptr)
-        if (const auto s = parse (state); s && ! s->tracks.empty() && ! s->tracks.front().timeWarp)
-            if (auto edited = renderEdits (*source, s->tracks.front()))
-                return std::make_unique<Engine> (std::move (edited));
-    return make (std::move (source));
+    return make (renderedSource (std::move (source), state));
+}
+
+// ------------------------------------------------------------------------------------------------- LYNX's projects
+namespace
+{
+template <typename T>
+void put (std::vector<std::uint8_t>& out, T v)
+{
+    const auto* p = reinterpret_cast<const std::uint8_t*> (&v);
+    out.insert (out.end(), p, p + sizeof (T));
+}
+
+struct Reader
+{
+    const std::vector<std::uint8_t>& d;
+    std::size_t at = 0;
+    bool ok = true;
+    template <typename T>
+    T get()
+    {
+        T v {};
+        if (at + sizeof (T) > d.size())
+        {
+            ok = false;
+            return v;
+        }
+        std::memcpy (&v, d.data() + at, sizeof (T));
+        at += sizeof (T);
+        return v;
+    }
+};
+
+constexpr std::uint32_t nativeVersion = 1;
+
+double median (std::vector<double> v)
+{
+    if (v.empty())
+        return 0.0;
+    std::nth_element (v.begin(), v.begin() + (std::ptrdiff_t) (v.size() / 2), v.end());
+    return v[v.size() / 2];
+}
+} // namespace
+
+Track analyseNotes (const SampleData& source)
+{
+    Track t;
+    const auto n = (std::int64_t) source.frames();
+    t.frames = n;
+    if (n <= 0)
+        return t;
+    const auto fs = source.sampleRate > 0.0 ? source.sampleRate : 44100.0;
+    std::vector<float> mono (source.leftData(), source.leftData() + n);
+    if (source.isStereo())
+        for (std::int64_t i = 0; i < n; ++i)
+            mono[(std::size_t) i] = 0.5f * (mono[(std::size_t) i] + source.rightData()[i]);
+
+    const int hop = std::max (64, (int) std::lround (256.0 * fs / 44100.0));
+    const auto frames = vocal::analysePitch (mono.data(), (int) n, fs, hop, 60.0, 1000.0);
+    float loudest = 0.0f;
+    for (const auto& f : frames)
+        loudest = std::max (loudest, f.level);
+    const auto floor = loudest * 0.02f; // (−34 dB under the loudest frame: breaths and room tone are not notes)
+
+    // a frame's pitch, smoothed over its neighbours (vibrato stays inside a note)
+    std::vector<double> note (frames.size(), -1.0);
+    for (std::size_t k = 0; k < frames.size(); ++k)
+        if (frames[k].hz > 0.0 && frames[k].level >= floor)
+            note[k] = vocal::hzToNote (frames[k].hz);
+    auto smooth = [&] (std::size_t k) {
+        std::vector<double> v;
+        for (auto j = k >= 2 ? k - 2 : 0; j <= std::min (frames.size() - 1, k + 2); ++j)
+            if (note[j] >= 0.0)
+                v.push_back (note[j]);
+        return median (v);
+    };
+
+    const auto minFrames = std::max<std::size_t> (2, (std::size_t) std::lround (0.06 * fs / hop)); // notes ≥ 60 ms
+    const auto smoothTime = 0.015 * fs;
+    auto close = [&] (std::size_t a, std::size_t b) { // frames [a, b) → a note
+        if (b <= a || b - a < minFrames)
+            return;
+        std::vector<double> v;
+        for (auto k = a; k < b; ++k)
+            if (note[k] >= 0.0)
+                v.push_back (note[k]);
+        Note p;
+        p.origStart = p.curStart = std::clamp<std::int64_t> ((std::int64_t) a * hop - hop / 2, 0, n);
+        p.origEnd = p.curEnd = std::clamp<std::int64_t> ((std::int64_t) b * hop - hop / 2, p.origStart, n);
+        if (! t.pitches.empty() && p.origStart < t.pitches.back().origEnd)
+            p.origStart = p.curStart = t.pitches.back().origEnd;
+        if (p.origEnd <= p.origStart)
+            return;
+        p.origPitch = median (v);
+        p.smoothIn = p.smoothOut = smoothTime;
+        t.pitches.push_back (p);
+    };
+
+    std::size_t start = 0;
+    bool inNote = false;
+    double centre = 0.0;
+    int away = 0;
+    for (std::size_t k = 0; k <= frames.size(); ++k)
+    {
+        const auto voiced = k < frames.size() && note[k] >= 0.0;
+        if (! inNote)
+        {
+            if (voiced)
+                inNote = true, start = k, centre = note[k], away = 0;
+            continue;
+        }
+        const auto here = voiced ? smooth (k) : -1.0;
+        if (! voiced || std::abs (here - centre) > 0.7)
+        {
+            // a gap or a new pitch held for 3 frames ends the note (one-frame glitches and slides stay in it)
+            if (! voiced || ++away >= 3)
+            {
+                const auto end = voiced ? k - (std::size_t) (away - 1) : k;
+                close (start, end);
+                inNote = voiced;
+                start = end;
+                centre = voiced ? here : 0.0;
+                away = 0;
+            }
+            continue;
+        }
+        away = 0;
+        centre += 0.1 * (here - centre); // (follows a slow drift)
+    }
+    t.notes = (int) t.pitches.size();
+    return t;
+}
+
+std::vector<std::uint8_t> writeNative (const Track& track)
+{
+    std::vector<std::uint8_t> out { 'L', 'X', 'N', 'T' };
+    put (out, nativeVersion);
+    put (out, (std::int64_t) track.frames);
+    put (out, track.globalFormant);
+    put (out, (std::uint32_t) track.pitches.size());
+    for (const auto& p : track.pitches)
+    {
+        for (const auto v : { p.origStart, p.origEnd, p.curStart, p.curEnd })
+            put (out, v);
+        for (const auto v : { p.origPitch, p.shift, p.stretch, p.volume, p.formant, p.drift, p.smoothIn, p.smoothOut, p.fadeInTime, p.fadeOutTime,
+                              p.fadeInGain, p.fadeOutGain, p.vibPeriod, p.vibAmpStart, p.vibAmpEnd, p.tremAmp })
+            put (out, v);
+        put (out, (std::uint8_t) (p.enabled ? 1 : 0));
+    }
+    return out;
+}
+
+std::optional<Track> parseNative (const std::vector<std::uint8_t>& state)
+{
+    if (state.size() < 8 || std::memcmp (state.data(), "LXNT", 4) != 0)
+        return std::nullopt;
+    Reader r { state, 4 };
+    if (r.get<std::uint32_t>() != nativeVersion)
+        return std::nullopt;
+    Track t;
+    t.frames = r.get<std::int64_t>();
+    t.globalFormant = r.get<double>();
+    const auto count = r.get<std::uint32_t>();
+    if (! r.ok || count > 100000)
+        return std::nullopt;
+    for (std::uint32_t i = 0; i < count && r.ok; ++i)
+    {
+        Note p;
+        for (auto* v : { &p.origStart, &p.origEnd, &p.curStart, &p.curEnd })
+            *v = r.get<std::int64_t>();
+        for (auto* v : { &p.origPitch, &p.shift, &p.stretch, &p.volume, &p.formant, &p.drift, &p.smoothIn, &p.smoothOut, &p.fadeInTime, &p.fadeOutTime,
+                         &p.fadeInGain, &p.fadeOutGain, &p.vibPeriod, &p.vibAmpStart, &p.vibAmpEnd, &p.tremAmp })
+            *v = r.get<double>();
+        p.enabled = r.get<std::uint8_t>() != 0;
+        t.pitches.push_back (p);
+    }
+    if (! r.ok || r.at != state.size())
+        return std::nullopt;
+    t.notes = (int) t.pitches.size();
+    t.edited = std::any_of (t.pitches.begin(), t.pitches.end(), [&t] (const Note& p) { return p.edited (t.globalFormant); });
+    return t;
+}
+
+std::optional<Track> trackOf (const std::vector<std::uint8_t>& state)
+{
+    if (auto t = parseNative (state))
+        return t;
+    if (const auto s = parse (state); s && ! s->tracks.empty() && ! s->tracks.front().timeWarp)
+        return s->tracks.front();
+    return std::nullopt;
+}
+
+std::vector<std::uint8_t> writeWarp (const WarpMap& map)
+{
+    std::vector<std::uint8_t> out { 'L', 'X', 'N', 'W' };
+    put (out, nativeVersion);
+    put (out, (std::int64_t) map.frames);
+    put (out, (std::uint32_t) map.markers.size());
+    for (const auto& m : map.markers)
+    {
+        put (out, m.source);
+        put (out, m.output);
+    }
+    return out;
+}
+
+std::optional<WarpMap> parseWarp (const std::vector<std::uint8_t>& state)
+{
+    if (state.size() < 8 || std::memcmp (state.data(), "LXNW", 4) != 0)
+        return std::nullopt;
+    Reader r { state, 4 };
+    if (r.get<std::uint32_t>() != nativeVersion)
+        return std::nullopt;
+    WarpMap m;
+    m.frames = r.get<std::int64_t>();
+    const auto count = r.get<std::uint32_t>();
+    if (! r.ok || count > 100000)
+        return std::nullopt;
+    for (std::uint32_t i = 0; i < count && r.ok; ++i)
+    {
+        WarpMarker w;
+        w.source = r.get<std::int64_t>();
+        w.output = r.get<std::int64_t>();
+        // (markers must increase on both axes)
+        if (w.source <= 0 || w.output <= 0 || (! m.markers.empty() && (w.source <= m.markers.back().source || w.output <= m.markers.back().output)))
+            return std::nullopt;
+        m.markers.push_back (w);
+    }
+    if (! r.ok || r.at != state.size())
+        return std::nullopt;
+    return m;
+}
+
+namespace
+{
+// the markers with the implicit start and end ones: (source, output) points, increasing
+std::vector<std::pair<double, double>> warpPoints (const WarpMap& map, std::int64_t frames)
+{
+    std::vector<std::pair<double, double>> pts { { 0.0, 0.0 } };
+    for (const auto& m : map.markers)
+        if ((double) m.source < (double) frames)
+            pts.push_back ({ (double) m.source, (double) m.output });
+    const auto& last = pts.back();
+    const auto slope = pts.size() >= 2 ? (last.second - pts[pts.size() - 2].second) / std::max (1.0, last.first - pts[pts.size() - 2].first) : 1.0;
+    if ((double) frames > last.first)
+        pts.push_back ({ (double) frames, last.second + slope * ((double) frames - last.first) });
+    return pts;
+}
+} // namespace
+
+std::int64_t warpedLength (const WarpMap& map, std::int64_t frames)
+{
+    return (std::int64_t) std::llround (warpPoints (map, frames).back().second);
+}
+
+double warpToOutput (const WarpMap& map, std::int64_t frames, double source)
+{
+    const auto pts = warpPoints (map, frames);
+    for (std::size_t i = 1; i < pts.size(); ++i)
+        if (source <= pts[i].first || i + 1 == pts.size())
+        {
+            const auto& a = pts[i - 1];
+            const auto& b = pts[i];
+            return a.second + (source - a.first) * (b.second - a.second) / std::max (1e-9, b.first - a.first);
+        }
+    return source;
+}
+
+double warpToSource (const WarpMap& map, std::int64_t frames, double output)
+{
+    const auto pts = warpPoints (map, frames);
+    for (std::size_t i = 1; i < pts.size(); ++i)
+        if (output <= pts[i].second || i + 1 == pts.size())
+        {
+            const auto& a = pts[i - 1];
+            const auto& b = pts[i];
+            return a.first + (output - a.second) * (b.first - a.first) / std::max (1e-9, b.second - a.second);
+        }
+    return output;
+}
+
+std::shared_ptr<SampleData> renderWarp (const SampleData& source, const WarpMap& map)
+{
+    const auto n = (std::int64_t) source.frames();
+    if (n <= 0)
+        return nullptr;
+    const auto pts = warpPoints (map, n);
+    bool moved = false;
+    for (const auto& [a, b] : pts)
+        moved = moved || std::abs (a - b) > 0.5;
+    if (! moved)
+        return nullptr;
+
+    auto out = std::make_shared<SampleData>();
+    out->sampleRate = source.sampleRate;
+    const auto stereo = source.isStereo();
+    for (std::size_t i = 1; i < pts.size(); ++i)
+    {
+        const auto a = (std::int64_t) std::llround (pts[i - 1].first), b = (std::int64_t) std::llround (pts[i].first);
+        const auto wantStart = (std::int64_t) std::llround (pts[i - 1].second), wantEnd = (std::int64_t) std::llround (pts[i].second);
+        if (b <= a || wantEnd <= wantStart)
+            continue;
+        SampleData piece;
+        piece.sampleRate = source.sampleRate;
+        piece.left.assign (source.leftData() + a, source.leftData() + b);
+        if (stereo)
+            piece.right.assign (source.rightData() + a, source.rightData() + b);
+        const auto ratio = (double) (wantEnd - wantStart) / (double) (b - a);
+        std::shared_ptr<SampleData> stretched;
+        if (std::abs (ratio - 1.0) > 1e-6)
+            stretched = timeStretch (piece, ratio);
+        const auto& src = stretched != nullptr ? *stretched : piece;
+        // each piece lands exactly where its markers say (the stretcher's length is trimmed / padded)
+        const auto length = (std::size_t) (wantEnd - wantStart);
+        out->left.resize ((std::size_t) wantStart, 0.0f);
+        if (stereo)
+            out->right.resize ((std::size_t) wantStart, 0.0f);
+        for (std::size_t k = 0; k < length; ++k)
+        {
+            const auto inside = k < src.frames();
+            out->left.push_back (inside ? src.leftData()[k] : 0.0f);
+            if (stereo)
+                out->right.push_back (inside ? (src.isStereo() ? src.rightData()[k] : src.leftData()[k]) : 0.0f);
+        }
+    }
+    return out;
+}
+
+std::shared_ptr<const SampleData> renderedSource (std::shared_ptr<const SampleData> source, const std::vector<std::uint8_t>& state)
+{
+    if (source == nullptr)
+        return source;
+    if (const auto warp = parseWarp (state))
+    {
+        if (auto warped = renderWarp (*source, *warp))
+            return warped;
+        return source;
+    }
+    if (const auto t = trackOf (state))
+        if (auto edited = renderEdits (*source, *t))
+            return edited;
+    return source;
 }
 } // namespace lynx::newtonefx

+ 41 - 0
src/core/NewtoneFx.h

@@ -19,6 +19,7 @@
 #include <vector>
 
 #include "core/Effects.h"
+#include "core/TimeStretch.h"
 
 namespace lynx
 {
@@ -94,4 +95,44 @@ std::unique_ptr<Effect> make (std::shared_ptr<const SampleData> source, const st
 // disabled notes — with LYNX's own pitch analysis (YIN) and TD-PSOLA (core/VocalPitch.h). Unedited notes are copied
 // sample for sample. nullptr when nothing differs from the source.
 std::shared_ptr<SampleData> renderEdits (const SampleData& source, const Track& track);
+
+// ------------------------------------------------------------------------------------------------------------------
+// LYNX's own Newtone / Newtime projects (round 142, issue #5): a slot made in a LYNX project keeps its edits in its
+// own format in EffectSlot::state (FL's XML project is only read). The source sample is EffectSlot::samplePath.
+
+// LYNX's note analysis of a sample (YIN pitch track, core/VocalPitch.h): voiced stretches of steady pitch become
+// notes (Note.origPitch = their median pitch; nothing edited). Newtone: timeWarp = false.
+Track analyseNotes (const SampleData& source);
+
+// Newtone: the track's notes. "LXNT" + version + frames + global formant + the notes.
+std::vector<std::uint8_t> writeNative (const Track& track);
+std::optional<Track> parseNative (const std::vector<std::uint8_t>& state);
+// The track a slot's state describes: LYNX's own, or the first Newtone track of FL's state (nullopt: none)
+std::optional<Track> trackOf (const std::vector<std::uint8_t>& state);
+
+// Newtime: warp markers (source sample → output sample), in increasing order on both axes; between two markers the
+// source plays stretched (pitch kept) so that it lasts the output distance. Implicit markers at 0 → 0 and at the
+// end (the last marker's slope continued). "LXNW" + version + frames + the markers.
+struct WarpMarker
+{
+    std::int64_t source = 0, output = 0;
+    bool operator== (const WarpMarker&) const = default;
+};
+struct WarpMap
+{
+    std::int64_t frames = 0; // the source's length when the markers were placed
+    std::vector<WarpMarker> markers;
+    bool operator== (const WarpMap&) const = default;
+};
+std::vector<std::uint8_t> writeWarp (const WarpMap& map);
+std::optional<WarpMap> parseWarp (const std::vector<std::uint8_t>& state);
+// The output length of the warped source; and where a source sample lands (and back)
+std::int64_t warpedLength (const WarpMap& map, std::int64_t frames);
+double warpToOutput (const WarpMap& map, std::int64_t frames, double source);
+double warpToSource (const WarpMap& map, std::int64_t frames, double output);
+// The warped source (nullptr: no marker moves anything)
+std::shared_ptr<SampleData> renderWarp (const SampleData& source, const WarpMap& map);
+
+// What a slot plays in slave mode: the source with its edits (Newtone notes / Newtime warp; LYNX's or FL's state)
+std::shared_ptr<const SampleData> renderedSource (std::shared_ptr<const SampleData> source, const std::vector<std::uint8_t>& state);
 } // namespace lynx::newtonefx

+ 39 - 0
src/engine/AudioEngine.cpp

@@ -58,6 +58,45 @@ FlPathRoots findFlStudioRoots()
     return roots;
 }
 
+const natives::FlAccess& flStudioAccess()
+{
+    static const natives::FlAccess cached = [] {
+        natives::FlAccess access;
+        access.roots = findFlStudioRoots();
+        access.fileExists = [] (const std::string& path) { return platform::localFile (path).existsAsFile(); };
+        access.readFile = [] (const std::string& path) {
+            juce::MemoryBlock data;
+            platform::localFile (path).loadFileAsData (data);
+            const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
+            return std::vector<std::uint8_t> (bytes, bytes + data.getSize());
+        };
+        access.listPresets = [] (const std::string& folder) {
+            std::vector<std::string> out;
+            auto files = platform::localFile (folder).findChildFiles (juce::File::findFiles, true, "*.fst;*.tbio;*.gmsynth;*.mrp");
+            std::sort (files.begin(), files.end(), [] (const juce::File& a, const juce::File& b) {
+                return a.getFullPathName().compareNatural (b.getFullPathName()) < 0;
+            });
+            for (const auto& f : files)
+                out.push_back (f.getFullPathName().toStdString());
+            return out;
+        };
+        // (FL Keys' raw wavetables become WAV files of LYNX's settings folder, like an .flp's embedded samples)
+        access.saveEmbedded = [] (const std::vector<std::uint8_t>& wav, const std::string& name) -> std::string {
+            const auto folder = PluginHost::settingsFolder().getChildFile ("flp-embedded");
+            folder.createDirectory();
+            const auto hash = juce::String::toHexString ((juce::int64) juce::DefaultHashFunctions::generateHash (
+                juce::String::createStringFromData (wav.data(), (int) juce::jmin<std::size_t> (wav.size(), 65536)) + juce::String ((juce::int64) wav.size()),
+                0x7FFFFFFF));
+            const auto file = folder.getChildFile (juce::File::createLegalFileName (juce::String::fromUTF8 (name.c_str())) + "-" + hash + ".wav");
+            if (! file.existsAsFile() && ! file.replaceWithData (wav.data(), wav.size()))
+                return {};
+            return file.getFullPathName().toStdString();
+        };
+        return access;
+    }();
+    return cached;
+}
+
 namespace
 {
 // Audio workers with real-time priority (MMCSS "Pro Audio" on Windows, like the driver; QoS class on macOS; SCHED_FIFO

+ 3 - 0
src/engine/AudioEngine.h

@@ -19,6 +19,7 @@
 #include "core/RtStats.h"
 #include "core/FlpImport.h"
 #include "core/History.h"
+#include "core/NativeEngines.h"
 #include "core/SnapshotExchange.h"
 #include "core/Song.h"
 #include "engine/PluginHost.h"
@@ -36,6 +37,8 @@ namespace lynx
 // snapshot (RackState) to the audio thread.
 // Folders of the most recent FL Studio installation (empty if none).
 FlPathRoots findFlStudioRoots();
+// The user's FL installation as the native FL engines read it (round 142): its folders and this PC's file system
+const natives::FlAccess& flStudioAccess(); // (found once per session)
 
 class AudioEngine final : private juce::AudioIODeviceCallback,
                           private juce::MidiInputCallback,

+ 179 - 2
src/ui/BrowserComponent.cpp

@@ -18,6 +18,8 @@
 #include "ui/ValueControl.h"
 #include "ui/WaveformView.h"
 #include "ui/AudioEditor.h"
+#include "ui/ChannelRackComponent.h"
+#include "ui/MixerComponent.h"
 
 namespace lynx
 {
@@ -305,7 +307,9 @@ public:
         file,     // a file on disk
         project,  // "Current project"
         category, // one of its sections
-        item      // something of the project (pattern, sample, generator, effect, automation clip, undo step)
+        item,     // something of the project (pattern, sample, generator, effect, automation clip, undo step)
+        plugins,  // the Plugin database and its folders (round 142): built-in, FL engines, installed plugins
+        plugin    // one of its plugins (double-click adds it)
     };
 
     struct Node
@@ -323,6 +327,7 @@ public:
         Category category = Category::samples;
         projectcontents::Item item; // kind == item (history: item.index = the step)
         bool history = false, missing = false, current = false;
+        std::function<void()> activate; // kind == plugin: adds it
     };
 
     // tree mode: the given top-level nodes
@@ -355,6 +360,130 @@ public:
         return n;
     }
 
+    // FL's "Plugin database", interpreted (round 142, issue #5): Generators and Effects, each with LYNX's built-in ones,
+    // FL's engines (those the user's FL installation provides) and the installed VST3 / CLAP plugins
+    static std::unique_ptr<Node> makePluginDatabase (BrowserComponent& browser, const std::set<juce::String>& open)
+    {
+        auto folder = [&open] (Node* parent, const juce::String& label, Icon icon) {
+            auto n = std::make_unique<Node>();
+            n->kind = Kind::plugins;
+            n->folder = n->loaded = true;
+            n->label = label;
+            n->icon = icon;
+            n->parent = parent;
+            n->depth = parent != nullptr ? parent->depth + 1 : 0;
+            n->expanded = open.count ((parent != nullptr && parent->kind == Kind::plugins ? parent->label + "/" : juce::String()) + label) > 0;
+            return n;
+        };
+        auto entry = [] (Node& parent, const juce::String& label, const juce::String& detail, Icon icon, std::function<void()> activate) {
+            auto n = std::make_unique<Node>();
+            n->kind = Kind::plugin;
+            n->label = label;
+            n->detail = detail;
+            n->icon = icon;
+            n->parent = &parent;
+            n->depth = parent.depth + 1;
+            n->activate = std::move (activate);
+            parent.children.push_back (std::move (n));
+        };
+        auto root = folder (nullptr, tr ("Plugin database"), Icon::plugin);
+        root->colour = theme::colour::info;
+        auto safe = juce::Component::SafePointer<BrowserComponent> (&browser);
+        auto addInstrument = [safe] (ChannelDef c) {
+            if (safe != nullptr && safe->onAddInstrument)
+                safe->onAddInstrument (std::move (c));
+        };
+        auto addEffect = [safe] (EffectSlot fx) {
+            if (safe != nullptr && safe->onAddEffect)
+                safe->onAddEffect (std::move (fx));
+        };
+        const auto bpm = browser.engine.getSong().bpm;
+        const auto& fl = flStudioAccess();
+        auto types = browser.engine.getPluginHost().getKnownPlugins().getTypes();
+        std::sort (types.begin(), types.end(), [] (const auto& a, const auto& b) { return a.name.compareIgnoreCase (b.name) < 0; });
+
+        // Generators
+        {
+            auto gens = folder (root.get(), tr ("Generators"), Icon::keyboard);
+            auto lynxGens = folder (gens.get(), "LYNX", Icon::folder);
+            const std::pair<InstrumentKind, const char*> builtIn[] = { { InstrumentKind::synth, TR_NOOP ("Synth") }, { InstrumentKind::kick, TR_NOOP ("Kick") },
+                                                                       { InstrumentKind::snare, TR_NOOP ("Snare") }, { InstrumentKind::hat, TR_NOOP ("Hat") },
+                                                                       { InstrumentKind::clap, TR_NOOP ("Clap") } };
+            for (const auto& [kind, name] : builtIn)
+                entry (*lynxGens, tr (name), tr ("built-in"), Icon::keyboard, [addInstrument, kind = kind, english = std::string (name)] {
+                    ChannelDef c;
+                    c.name = english;
+                    c.instrument = kind;
+                    addInstrument (c);
+                });
+            auto flGens = folder (gens.get(), tr ("FL engines"), Icon::folder);
+            for (const auto& e : natives::instrumentEngines())
+                if (natives::available (e, fl))
+                    entry (*flGens, flEngineName (e), tr ("built-in FL engine"), Icon::keyboard, [addInstrument, kind = e.kind] {
+                        if (auto c = natives::makeChannel (kind, flStudioAccess()))
+                            addInstrument (*c);
+                    });
+            auto installed = folder (gens.get(), tr ("Installed"), Icon::folder);
+            for (const auto& t : types)
+                if (t.isInstrument)
+                    entry (*installed, t.name, t.manufacturerName + " · " + t.pluginFormatName, Icon::plugin,
+                           [addInstrument, id = t.createIdentifierString().toStdString(), name = t.name.toStdString()] {
+                               ChannelDef c;
+                               c.name = name;
+                               c.instrument = InstrumentKind::plugin;
+                               c.plugin.id = id;
+                               c.plugin.name = name;
+                               addInstrument (c);
+                           });
+            for (auto* f : { &lynxGens, &flGens, &installed })
+                if (! (*f)->children.empty())
+                    gens->children.push_back (std::move (*f));
+            root->children.push_back (std::move (gens));
+        }
+        // Effects
+        {
+            auto fxs = folder (root.get(), tr ("Effects"), Icon::mixer);
+            auto lynxFx = folder (fxs.get(), "LYNX", Icon::folder);
+            auto flFx = folder (fxs.get(), tr ("FL engines"), Icon::folder);
+            for (const auto kind : addableEffects())
+                if (addableEffectAvailable (kind))
+                {
+                    const auto flEngine = natives::effectEngine (kind) != nullptr;
+                    entry (flEngine ? *flFx : *lynxFx, addableEffectName (kind), flEngine ? tr ("built-in FL engine") : tr ("built-in"), Icon::mixer,
+                           [addEffect, kind, bpm] {
+                               if (auto fx = newAddableEffect (kind, bpm))
+                                   addEffect (*fx);
+                           });
+                }
+            auto installed = folder (fxs.get(), tr ("Installed"), Icon::folder);
+            for (const auto& t : types)
+                if (! t.isInstrument)
+                    entry (*installed, t.name, t.manufacturerName + " · " + t.pluginFormatName, Icon::plugin,
+                           [addEffect, id = t.createIdentifierString().toStdString(), name = t.name.toStdString()] {
+                               EffectSlot fx;
+                               fx.kind = EffectKind::plugin;
+                               fx.plugin.id = id;
+                               fx.plugin.name = name;
+                               addEffect (fx);
+                           });
+            for (auto* f : { &lynxFx, &flFx, &installed })
+                if (! (*f)->children.empty())
+                    fxs->children.push_back (std::move (*f));
+            root->children.push_back (std::move (fxs));
+        }
+        // (the counts, dimmed after each folder)
+        std::function<int (Node&)> count = [&count] (Node& n) {
+            int total = 0;
+            for (auto& c : n.children)
+                total += c->kind == Kind::plugin ? 1 : count (*c);
+            if (n.kind == Kind::plugins)
+                n.detail = juce::String (total);
+            return total;
+        };
+        count (*root);
+        return root;
+    }
+
     static std::unique_ptr<Node> makeProject (bool open)
     {
         auto n = std::make_unique<Node>();
@@ -709,6 +838,11 @@ public:
             itemClicked (n);
             return;
         }
+        if (n.kind == Kind::plugin)
+        {
+            select (row, false);
+            return;
+        }
 
         // a click previews, even when the file is already selected (click again: hear it again)
         select (row, true);
@@ -749,6 +883,12 @@ public:
             return;
 
         const auto& n = *rows[(std::size_t) row];
+        if (n.kind == Kind::plugin)
+        {
+            if (n.activate)
+                n.activate();
+            return;
+        }
         if (n.kind != Kind::item)
         {
             browser.openFile (n.file);
@@ -813,6 +953,15 @@ public:
                 break;
             case Kind::item:
                 return itemHint (n);
+            case Kind::plugins:
+                h.text = tr ("Plugin database: LYNX's built-in generators and effects, FL's engines and the installed plugins") + "  "
+                         + (n.expanded ? tr ("[LMB] close") : tr ("[LMB] open"));
+                h.value = n.detail;
+                return h;
+            case Kind::plugin:
+                h.text = n.label + " (" + n.detail + ")  " + tr ("[double-click] add it (generators: a new channel; effects: into the selected insert)");
+                h.hasMenu = true;
+                return h;
             case Kind::file:
                 break;
         }
@@ -1190,7 +1339,17 @@ private:
             });
         };
 
-        if (n.kind == Kind::project || n.kind == Kind::category)
+        if (n.kind == Kind::plugin)
+        {
+            menu.addSectionHeader (n.label);
+            menu.addItem (tr ("Add"), [act = n.activate] {
+                if (act)
+                    act();
+            });
+            menu.showMenuAsync (juce::PopupMenu::Options().withMousePosition());
+            return;
+        }
+        if (n.kind == Kind::project || n.kind == Kind::category || n.kind == Kind::plugins)
         {
             menu.addSectionHeader (n.label);
             expandItems();
@@ -1297,6 +1456,14 @@ private:
     {
         const auto keep = selectionKey();
         n.expanded = ! n.expanded;
+        if (n.kind == Kind::plugins) // (remembered: the database is built again with the tree)
+        {
+            const auto key = (n.parent != nullptr && n.parent->kind == Kind::plugins ? n.parent->label + "/" : juce::String()) + n.label;
+            if (n.expanded)
+                browser.openPluginFolders.insert (key);
+            else
+                browser.openPluginFolders.erase (key);
+        }
         if (n.expanded)
             load (n);
         rebuild();
@@ -1853,6 +2020,8 @@ void BrowserComponent::rebuildTree()
         return;
     }
     top.push_back (FileTree::makeProject (tab == projectTab));
+    if (tab == allTab) // FL's Plugin database, under the project (round 142)
+        top.push_back (FileTree::makePluginDatabase (*this, openPluginFolders));
 
     if (tab == allTab)
         for (int i = 0; i < roots.size(); ++i)
@@ -2086,6 +2255,14 @@ void BrowserComponent::selectFirstSampleForSnapshot()
     }
 }
 
+void BrowserComponent::showPluginDatabaseForSnapshot()
+{
+    openPluginFolders = { tr ("Plugin database"), tr ("Plugin database") + "/" + tr ("Generators"), tr ("Generators") + "/" + tr ("FL engines"),
+                          tr ("Plugin database") + "/" + tr ("Effects"), tr ("Effects") + "/" + tr ("FL engines") };
+    setTab (allTab);
+    rebuildTree();
+}
+
 void BrowserComponent::showProjectForSnapshot()
 {
     setTab (projectTab);

+ 7 - 0
src/ui/BrowserComponent.h

@@ -1,5 +1,7 @@
 #pragma once
 
+#include <set>
+
 #include <juce_gui_basics/juce_gui_basics.h>
 
 #include "engine/AudioEngine.h"
@@ -43,6 +45,9 @@ public:
     std::function<void (int, int)> onOpenEffect; // double-click an effect (insert, slot): its editor
     std::function<void (int)> onShowInsert;      // an effect's / generator's insert in the Mixer
     std::function<void (int)> onOpenAutomation;  // double-click an automation clip: its editor
+    // The Plugin database (round 142): double-click a generator = a new channel, an effect = into the selected insert
+    std::function<void (ChannelDef)> onAddInstrument;
+    std::function<void (EffectSlot)> onAddEffect;
     std::function<void (const juce::File&)> onSendToPlaylist; // a sample's "Send to the Playlist as an audio clip"
     std::function<void()> onPreviewVolumeChanged;             // the preview volume knob moved (the main window saves it)
 
@@ -71,6 +76,7 @@ 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)
     // --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()
@@ -141,6 +147,7 @@ private:
     int tab = allTab;
     bool searchPending = false, projectDirty = false;
     juce::File projectFile;
+    std::set<juce::String> openPluginFolders; // the Plugin database folders the user opened (round 142)
 
     AudioEngine& engine;
     juce::Array<juce::File> roots;

+ 35 - 2
src/ui/ChannelRackComponent.cpp

@@ -1216,6 +1216,8 @@ int ChannelRackComponent::addChannel (ChannelDef c, bool openEditor)
         openPluginWindow (index);
         openEditorRow = index;
     }
+    else if (openEditor && natives::instrumentEngine (c.instrument) != nullptr) // an FL engine: its editor (round 142)
+        openChannelSettings (engine, index);
 
     return index;
 }
@@ -1232,7 +1234,7 @@ bool ChannelRackComponent::loadSampleIntoSelected (const juce::File& file)
 
     // only channels that play a sample (or the built-in drums, which become samplers) take a file
     if (kind != InstrumentKind::sampler && kind != InstrumentKind::kick && kind != InstrumentKind::snare && kind != InstrumentKind::hat
-        && kind != InstrumentKind::clap)
+        && kind != InstrumentKind::clap && kind != InstrumentKind::granulizer)
         return false;
 
     assignSample (row, file);
@@ -2022,6 +2024,26 @@ void ChannelRackComponent::showChannelMenu (int channel)
     menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
 }
 
+juce::String flEngineName (const natives::InstrumentEngine& e)
+{
+    const auto name = juce::String::fromUTF8 (e.name);
+    if (! natives::available (e, flStudioAccess()))
+        return tr ("{0} (requires FL Studio)", { name });
+    return e.beta ? tr ("{0} (beta)", { name }) : name;
+}
+
+void addFlEngineItems (juce::PopupMenu& menu, std::function<void (ChannelDef)> add)
+{
+    for (const auto& e : natives::instrumentEngines())
+        menu.addItem (flEngineName (e), natives::available (e, flStudioAccess()), false, [kind = e.kind, add] {
+            if (auto c = natives::makeChannel (kind, flStudioAccess()))
+                add (*c);
+            else
+                juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::WarningIcon, tr ("FL engines"),
+                                                        tr ("This engine needs the data files of an FL Studio installation, which were not found or could not be read."));
+        });
+}
+
 void ChannelRackComponent::addInstrumentItems (juce::PopupMenu& menu, int insertAt)
 {
     // a new channel of `kind`, at the end (insertAt < 0) or at a row
@@ -2070,6 +2092,15 @@ void ChannelRackComponent::addInstrumentItems (juce::PopupMenu& menu, int insert
         const auto added = add (c);
         openChannelSettings (engine, added);
     });
+    // FL's own instrument engines (round 142, issue #5): their editor opens
+    {
+        juce::PopupMenu engines;
+        addFlEngineItems (engines, [this, add] (ChannelDef c) {
+            const auto added = add (c);
+            openChannelSettings (engine, added);
+        });
+        menu.addSubMenu (tr ("FL engines"), engines);
+    }
     // FL's Patcher as a generator (REA_rodada141): an empty graph, its editor opens
     menu.addItem (tr ("Patcher"), [this, add] {
         ChannelDef c;
@@ -2132,8 +2163,10 @@ void ChannelRackComponent::assignSample (int channel, const juce::File& file)
 
         if (isNew)
             c.mixerTrack = freeInsert;
-        c.instrument = InstrumentKind::sampler;
         c.samplePath = path;
+        if (! isNew && c.instrument == InstrumentKind::granulizer) // FL's Granulizer keeps its engine and plays the file (round 142)
+            return;
+        c.instrument = InstrumentKind::sampler;
         c.name = name;
     });
 

+ 7 - 0
src/ui/ChannelRackComponent.h

@@ -12,6 +12,13 @@
 
 namespace lynx
 {
+// The FL instrument engines a native project can add (core/NativeEngines.h, round 142, issue #5) as items of `menu`:
+// a new one starts from the plugin's Default preset of the user's FL installation; without it the item is disabled
+// and says "(requires FL Studio)". `add` receives the new channel (mixerTrack left to it).
+void addFlEngineItems (juce::PopupMenu& menu, std::function<void (ChannelDef)> add);
+// The engine's menu name ("(beta)", "(requires FL Studio)")
+juce::String flEngineName (const natives::InstrumentEngine& e);
+
 // FL-style Channel Rack: one row per channel with mute, pan, volume, mixer insert, name, selector
 // and the step grid of the current pattern.
 //  - steps: left click turns on (drag paints), right click erases

+ 115 - 1
src/ui/I18nData.h

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

+ 12 - 0
src/ui/MainComponent.cpp

@@ -118,6 +118,18 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
         mixer.selectTrack (track);
     };
     browser.onOpenAutomation = [this] (int automation) { openAutomationEditor (engine, automation); };
+    // the Browser's Plugin database (round 142): the same targets as the quick-add palette
+    browser.onAddInstrument = [this] (ChannelDef c) {
+        rack.addChannel (std::move (c), true);
+        showPanel (Panel::channelRack);
+    };
+    browser.onAddEffect = [this] (EffectSlot slot) {
+        if (! mixer.addEffectToSelected (std::move (slot)))
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Plugin database"),
+                                                    tr ("The selected insert has no free effect slot."));
+        else
+            showPanel (Panel::mixer);
+    };
     browser.onPreviewVolumeChanged = [this] { saveUiSettings(); };
     browser.onSendToPlaylist = [this] (const juce::File& file) {
         playlist.addAudioClipAtPlayhead (file);

+ 39 - 6
src/ui/MixerComponent.cpp

@@ -1531,7 +1531,12 @@ const EffectKind allEffects[] = { EffectKind::eq,     EffectKind::parametricEq,
                                       EffectKind::fruityFastDist, EffectKind::fruityFlangus, EffectKind::fruityFlanger, EffectKind::fruityPhaser, EffectKind::luxeVerb,
                                       EffectKind::fruityFastLP, EffectKind::fruityFreeFilter, EffectKind::fruityFilter,
                                       EffectKind::hardcore,
-                                      EffectKind::multibandDelay };
+                                      EffectKind::multibandDelay,
+                                      // FL engines that need more than their parameters (round 142, issue #5): a new one starts from
+                                      // the plugin's Default preset of the user's FL installation (core/NativeEngines.h)
+                                      EffectKind::maximus, EffectKind::vocodex, EffectKind::equo, EffectKind::distructor, EffectKind::lovePhilter,
+                                      EffectKind::grossBeat, EffectKind::convolver, EffectKind::flPitchShifter, EffectKind::vintagePhaser,
+                                      EffectKind::squeeze, EffectKind::rhythmGain, EffectKind::newtone, EffectKind::newtime };
 } // namespace
 
 const std::vector<EffectKind>& addableEffects()
@@ -1540,6 +1545,30 @@ const std::vector<EffectKind>& addableEffects()
     return list;
 }
 
+bool addableEffectAvailable (EffectKind kind)
+{
+    const auto* e = natives::effectEngine (kind);
+    return e == nullptr || natives::available (*e, flStudioAccess());
+}
+
+juce::String addableEffectName (EffectKind kind)
+{
+    const auto name = juce::String::fromUTF8 (effectInfo (kind).name);
+    if (const auto* e = natives::effectEngine (kind))
+    {
+        if (! natives::available (*e, flStudioAccess()))
+            return tr ("{0} (requires FL Studio)", { name });
+        if (e->beta)
+            return tr ("{0} (beta)", { name });
+    }
+    return name;
+}
+
+std::optional<EffectSlot> newAddableEffect (EffectKind kind, double bpm)
+{
+    return natives::newEffect (kind, flStudioAccess(), bpm);
+}
+
 EffectsPanel::EffectsPanel (AudioEngine& e)
     : engine (e)
 {
@@ -3291,11 +3320,14 @@ void EffectsPanel::showAddMenu (int)
     juce::PopupMenu menu;
 
     for (auto kind : allEffects)
-        menu.addItem (juce::String::fromUTF8 (effectInfo (kind).name), [this, kind] {
-            engine.editSong ([t = track, kind] (Song& song) {
+        menu.addItem (addableEffectName (kind), addableEffectAvailable (kind), false, [this, kind] {
+            const auto made = newAddableEffect (kind, engine.getSong().bpm);
+            if (! made)
+                return;
+            engine.editSong ([t = track, fx = *made] (Song& song) {
                 auto& effects = song.mixer[(std::size_t) t].effects;
                 if ((int) effects.size() < maxEffectSlots)
-                    effects.push_back (makeEffectSlot (kind));
+                    effects.push_back (fx);
             });
             selectedSlot = (int) slots()->size() - 1;
             repaint();
@@ -3346,8 +3378,9 @@ void EffectsPanel::showSlotMenu (int slot)
     juce::PopupMenu replace;
 
     for (auto kind : allEffects)
-        replace.addItem (juce::String::fromUTF8 (effectInfo (kind).name), [this, slot, kind] {
-            engine.editSong ([t = track, slot, kind] (Song& song) { song.mixer[(std::size_t) t].effects[(std::size_t) slot] = makeEffectSlot (kind); });
+        replace.addItem (addableEffectName (kind), addableEffectAvailable (kind), false, [this, slot, kind] {
+            if (const auto made = newAddableEffect (kind, engine.getSong().bpm))
+                engine.editSong ([t = track, slot, fx = *made] (Song& song) { song.mixer[(std::size_t) t].effects[(std::size_t) slot] = fx; });
         });
 
     const auto count = (int) slots()->size();

+ 6 - 0
src/ui/MixerComponent.h

@@ -2,6 +2,7 @@
 
 #include <functional>
 #include <map>
+#include <optional>
 #include <vector>
 
 #include <juce_gui_basics/juce_gui_basics.h>
@@ -14,6 +15,11 @@ namespace lynx
 {
 // The built-in effects offered in the slot menus and the quick-add palette, in menu order.
 const std::vector<EffectKind>& addableEffects();
+// The FL engines among them need the user's FL installation (core/NativeEngines.h, round 142): whether one can be
+// added here, its menu name ("(beta)", "(requires FL Studio)") and a new slot (nullopt = not available here)
+bool addableEffectAvailable (EffectKind kind);
+juce::String addableEffectName (EffectKind kind);
+std::optional<EffectSlot> newAddableEffect (EffectKind kind, double bpm = 120.0);
 
 // External audio input of the inserts (REA_rodada88): FL's "Audio input source" of a mixer track.
 namespace mixerinput

+ 903 - 0
src/ui/NewtoneEditor.cpp

@@ -0,0 +1,903 @@
+#include "ui/NewtoneEditor.h"
+
+#include <algorithm>
+#include <cmath>
+#include <map>
+
+#include "core/NewtoneFx.h"
+#include "core/VocalPitch.h"
+#include "engine/Text.h"
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+#include "ui/WindowOwner.h"
+
+namespace lynx
+{
+namespace
+{
+bool isNewtoneKind (EffectKind k)
+{
+    return k == EffectKind::newtone || k == EffectKind::newtime;
+}
+
+const char* const noteNames[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+
+juce::String noteName (double midi)
+{
+    const auto k = (int) std::lround (midi);
+    return juce::String (noteNames[((k % 12) + 12) % 12]) + juce::String (k / 12 - 1);
+}
+
+class NewtoneEditor final : public juce::Component,
+                            public juce::FileDragAndDropTarget,
+                            private juce::ChangeListener,
+                            private juce::Timer
+{
+public:
+    NewtoneEditor (AudioEngine& e, int t, int s) : engine (e), track (t), slot (s)
+    {
+        for (auto* b : { &load, &analyse, &snapAll, &reset, &preview, &save, &stretch })
+        {
+            addAndMakeVisible (*b);
+            b->setWantsKeyboardFocus (false);
+        }
+        addAndMakeVisible (slave);
+        addAndMakeVisible (status);
+        status.setFont (theme::font (theme::type::small));
+        status.setColour (juce::Label::textColourId, theme::colour::textSecondary);
+
+        load.setButtonText (tr ("Load sample..."));
+        analyse.setButtonText (tr ("Analyse"));
+        snapAll.setButtonText (tr ("Snap all to notes"));
+        reset.setButtonText (tr ("Reset edits"));
+        preview.setButtonText (tr ("Preview"));
+        save.setButtonText (tr ("Save as WAV..."));
+        stretch.setButtonText (tr ("Length..."));
+        slave.setButtonText (tr ("Play with the song"));
+        slave.setTooltip (tr ("Slave to host playback: while the song plays, the edited sample plays from the song's start"));
+        load.setTooltip (tr ("Choose the audio file to edit (WAV, AIFF, FLAC, OGG, MP3)"));
+        analyse.setTooltip (tr ("Find the notes of the sample again (discards the note edits)"));
+
+        load.onClick = [this] { chooseSample(); };
+        analyse.onClick = [this] { reanalyse(); };
+        snapAll.onClick = [this] {
+            for (auto& p : notes.pitches)
+                p.shift = std::round (p.origPitch + p.shift) - p.origPitch;
+            commit();
+        };
+        reset.onClick = [this] {
+            if (warpMode())
+                warp.markers.clear();
+            else
+                for (auto& p : notes.pitches)
+                {
+                    const auto origPitch = p.origPitch;
+                    const auto a = p.origStart, b = p.origEnd;
+                    const auto si = p.smoothIn, so = p.smoothOut;
+                    p = {};
+                    p.origPitch = origPitch;
+                    p.origStart = p.curStart = a;
+                    p.origEnd = p.curEnd = b;
+                    p.smoothIn = si;
+                    p.smoothOut = so;
+                }
+            commit();
+        };
+        preview.onClick = [this] { togglePreview(); };
+        save.onClick = [this] { saveWav(); };
+        stretch.onClick = [this] { showLengthMenu(); };
+        slave.onClick = [this] {
+            const auto on = slave.getToggleState();
+            engine.editSong ([this, on] (Song& song) {
+                if (auto* fx = slotIn (song))
+                    fx->params[0] = on ? 1.0f : 0.0f;
+            });
+        };
+
+        setWantsKeyboardFocus (true);
+        engine.addChangeListener (this);
+        reloadFromSong();
+        startTimerHz (30);
+        setSize (900, 460);
+    }
+
+    ~NewtoneEditor() override
+    {
+        engine.removeChangeListener (this);
+        if (previewing)
+            engine.previewSample (nullptr);
+    }
+
+    // ------------------------------------------------------------------------------------------------------------
+    void paint (juce::Graphics& g) override
+    {
+        g.fillAll (theme::colour::bg2);
+        const auto area = canvasArea();
+        g.setColour (theme::colour::bg0);
+        g.fillRect (area);
+
+        if (sample == nullptr)
+        {
+            g.setColour (theme::colour::textSecondary);
+            g.setFont (theme::font (theme::type::body));
+            g.drawText (validSlot() ? tr ("Load a sample to edit it (Load sample... or drop an audio file here)") : tr ("This slot no longer holds this plugin"),
+                        area, juce::Justification::centred);
+            return;
+        }
+
+        if (warpMode())
+            paintWarp (g, area);
+        else
+            paintNotes (g, area);
+
+        // playhead of the preview
+        if (previewing)
+            if (const auto pos = engine.getPreviewPosition(); pos >= 0.0)
+            {
+                const auto x = xOfOutput (pos);
+                g.setColour (theme::colour::playhead);
+                g.drawVerticalLine ((int) x, (float) area.getY(), (float) area.getBottom());
+            }
+    }
+
+    void resized() override
+    {
+        auto r = getLocalBounds().reduced (8);
+        auto top = r.removeFromTop (26);
+        for (auto* b : { &load, &analyse, &snapAll, &stretch, &reset, &preview, &save })
+            if (b->isVisible())
+            {
+                b->setBounds (top.removeFromLeft (juce::jmax (70, b->getBestWidthForHeight (26) + 16)));
+                top.removeFromLeft (4);
+            }
+        slave.setBounds (top.removeFromRight (170));
+        r.removeFromTop (4);
+        status.setBounds (r.removeFromBottom (18));
+    }
+
+    bool keyPressed (const juce::KeyPress& key) override
+    {
+        if (warpMode() || selected < 0 || selected >= (int) notes.pitches.size())
+            return false;
+        auto& p = notes.pitches[(std::size_t) selected];
+        if (key == juce::KeyPress::upKey || key == juce::KeyPress::downKey)
+        {
+            p.shift += key == juce::KeyPress::upKey ? 1.0 : -1.0;
+            commit();
+            return true;
+        }
+        if (key == juce::KeyPress::deleteKey || key == juce::KeyPress::backspaceKey)
+        {
+            p.enabled = ! p.enabled;
+            commit();
+            return true;
+        }
+        return false;
+    }
+
+    // ------------------------------------------------------------------------------------------------------------
+    void mouseDown (const juce::MouseEvent& e) override
+    {
+        grabKeyboardFocus();
+        if (sample == nullptr || ! canvasArea().contains (e.getPosition()))
+            return;
+        drag = {};
+        if (warpMode())
+        {
+            const auto m = markerAt (e.position.x);
+            if (e.mods.isPopupMenu())
+            {
+                if (m >= 0)
+                {
+                    warp.markers.erase (warp.markers.begin() + m);
+                    commit();
+                }
+                return;
+            }
+            drag.marker = m;
+            return;
+        }
+
+        selected = noteAt (e.position);
+        repaint();
+        if (selected < 0)
+            return;
+        if (e.mods.isPopupMenu())
+        {
+            showNoteMenu (selected);
+            return;
+        }
+        const auto& p = notes.pitches[(std::size_t) selected];
+        drag.note = selected;
+        drag.shift = p.shift;
+        drag.start = p.curStart;
+        drag.end = p.curEnd;
+        drag.time = e.mods.isCtrlDown() || e.mods.isCommandDown();
+    }
+
+    void mouseDrag (const juce::MouseEvent& e) override
+    {
+        if (warpMode())
+        {
+            if (drag.marker < 0 || drag.marker >= (int) warp.markers.size())
+                return;
+            auto& m = warp.markers[(std::size_t) drag.marker];
+            const auto lo = drag.marker > 0 ? warp.markers[(std::size_t) drag.marker - 1].output + 1 : 1;
+            const auto hi = drag.marker + 1 < (int) warp.markers.size() ? warp.markers[(std::size_t) drag.marker + 1].output - 1
+                                                                        : (std::int64_t) (4 * frames());
+            m.output = std::clamp<std::int64_t> ((std::int64_t) std::llround (outputOfX (e.position.x)), lo, std::max (lo, hi));
+            drag.moved = true;
+            repaint();
+            return;
+        }
+        if (drag.note < 0 || drag.note >= (int) notes.pitches.size())
+            return;
+        auto& p = notes.pitches[(std::size_t) drag.note];
+        if (drag.time)
+        {
+            const auto dx = (std::int64_t) std::llround ((double) e.getDistanceFromDragStartX() / pixelsPerSample());
+            const auto len = drag.end - drag.start;
+            p.curStart = std::clamp<std::int64_t> (drag.start + dx, 0, std::max<std::int64_t> (0, frames() - len));
+            p.curEnd = p.curStart + len;
+        }
+        else
+        {
+            auto s = drag.shift - (double) e.getDistanceFromDragStartY() / rowHeight();
+            if (! e.mods.isAltDown()) // snapped: the note lands on a semitone
+                s = std::round (p.origPitch + s) - p.origPitch;
+            p.shift = std::clamp (s, -24.0, 24.0);
+        }
+        drag.moved = true;
+        repaint();
+    }
+
+    void mouseUp (const juce::MouseEvent&) override
+    {
+        if (drag.moved)
+            commit();
+        drag = {};
+    }
+
+    void mouseDoubleClick (const juce::MouseEvent& e) override
+    {
+        if (sample == nullptr || ! canvasArea().contains (e.getPosition()))
+            return;
+        if (warpMode())
+        {
+            // a new marker where the sample plays now (it does not move anything until dragged)
+            const auto out = outputOfX (e.position.x);
+            const auto src = (std::int64_t) std::llround (newtonefx::warpToSource (warp, frames(), out));
+            newtonefx::WarpMarker m { src, (std::int64_t) std::llround (out) };
+            if (m.source <= 0 || m.source >= frames())
+                return;
+            auto at = std::lower_bound (warp.markers.begin(), warp.markers.end(), m, [] (const auto& a, const auto& b) { return a.source < b.source; });
+            if (at != warp.markers.end() && at->source == m.source)
+                return;
+            warp.markers.insert (at, m);
+            // the first marker also pins the sample's end where it plays now, so moving a marker stretches one side
+            // and squeezes the other instead of changing the whole length
+            if (warp.markers.back().source < frames() - 1)
+                warp.markers.push_back ({ frames() - 1, (std::int64_t) std::llround (newtonefx::warpToOutput (warp, frames(), (double) (frames() - 1))) });
+            commit();
+            return;
+        }
+        if (const auto k = noteAt (e.position); k >= 0)
+        {
+            auto& p = notes.pitches[(std::size_t) k];
+            p.shift = std::round (p.origPitch + p.shift) - p.origPitch;
+            commit();
+        }
+    }
+
+    bool isInterestedInFileDrag (const juce::StringArray& files) override
+    {
+        return validSlot() && files.size() == 1 && juce::File (files[0]).hasFileExtension ("wav;aif;aiff;flac;ogg;mp3");
+    }
+
+    void filesDropped (const juce::StringArray& files, int, int) override
+    {
+        if (isInterestedInFileDrag (files))
+            useSample (juce::File (files[0]));
+    }
+
+    void mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& w) override
+    {
+        if (sample == nullptr)
+            return;
+        if (e.mods.isCtrlDown() || e.mods.isCommandDown())
+        {
+            const auto anchor = outputOfX (e.position.x);
+            zoom = std::clamp (zoom * (w.deltaY > 0 ? 1.25 : 0.8), 1.0, 64.0);
+            scroll = anchor - (e.position.x - (float) canvasArea().getX()) / pixelsPerSample();
+        }
+        else
+            scroll -= (w.deltaY != 0.0f ? w.deltaY : w.deltaX) * 0.25 * visibleLength();
+        clampScroll();
+        repaint();
+    }
+
+private:
+    struct Drag
+    {
+        int note = -1, marker = -1;
+        double shift = 0.0;
+        std::int64_t start = 0, end = 0;
+        bool time = false, moved = false;
+    };
+
+    AudioEngine& engine;
+    int track, slot;
+    juce::TextButton load, analyse, snapAll, reset, preview, save, stretch;
+    juce::ToggleButton slave;
+    juce::Label status;
+    std::unique_ptr<juce::FileChooser> chooser;
+
+    EffectKind kind = EffectKind::newtone;
+    std::string samplePath;
+    std::vector<std::uint8_t> savedState; // the state shown (to tell our own edits from outside changes)
+    std::shared_ptr<const SampleData> sample;
+    std::vector<float> peaks;              // |sample| maxima per 256 frames
+    std::vector<double> pitchTrack;        // the sample's pitch (MIDI, < 0 unvoiced) per pitchHop frames
+    int pitchHop = 256;
+    newtonefx::Track notes;
+    newtonefx::WarpMap warp;
+    int selected = -1;
+    Drag drag;
+    double zoom = 1.0, scroll = 0.0;       // horizontal view: zoom over the whole length, first visible sample
+    bool previewing = false;
+
+    // --------------------------------------------------------------------------------------------------- the slot
+    EffectSlot* slotIn (Song& song) const
+    {
+        if (track < 0 || track >= (int) song.mixer.size() || slot < 0 || slot >= (int) song.mixer[(std::size_t) track].effects.size())
+            return nullptr;
+        auto& fx = song.mixer[(std::size_t) track].effects[(std::size_t) slot];
+        return isNewtoneKind (fx.kind) ? &fx : nullptr;
+    }
+
+    const EffectSlot* currentSlot() const
+    {
+        const auto& song = engine.getSong();
+        if (track < 0 || track >= (int) song.mixer.size() || slot < 0 || slot >= (int) song.mixer[(std::size_t) track].effects.size())
+            return nullptr;
+        const auto& fx = song.mixer[(std::size_t) track].effects[(std::size_t) slot];
+        return isNewtoneKind (fx.kind) ? &fx : nullptr;
+    }
+
+    bool validSlot() const { return currentSlot() != nullptr; }
+    bool warpMode() const { return kind == EffectKind::newtime; }
+    std::int64_t frames() const { return sample != nullptr ? (std::int64_t) sample->frames() : 0; }
+
+    void changeListenerCallback (juce::ChangeBroadcaster*) override
+    {
+        const auto* fx = currentSlot();
+        if (fx == nullptr || fx->samplePath != samplePath || fx->state != savedState || fx->kind != kind)
+            reloadFromSong();
+        else
+            slave.setToggleState (fx->params[0] >= 0.5f, juce::dontSendNotification);
+    }
+
+    void reloadFromSong()
+    {
+        const auto* fx = currentSlot();
+        if (fx == nullptr)
+        {
+            sample = nullptr;
+            updateButtons();
+            repaint();
+            return;
+        }
+        kind = fx->kind;
+        slave.setToggleState (fx->params[0] >= 0.5f, juce::dontSendNotification);
+        savedState = fx->state;
+        if (fx->samplePath != samplePath || sample == nullptr)
+        {
+            samplePath = fx->samplePath;
+            sample = samplePath.empty() ? nullptr : engine.getSampleLibrary().load (juce::String::fromUTF8 (samplePath.c_str()));
+            analyseView();
+        }
+        if (warpMode())
+        {
+            warp = newtonefx::parseWarp (fx->state).value_or (newtonefx::WarpMap {});
+            warp.frames = frames();
+        }
+        else if (auto t = newtonefx::trackOf (fx->state); t && sample != nullptr)
+            notes = *t;
+        else if (sample == nullptr)
+            notes = {};
+        else
+        {
+            // a sample without notes yet (a fresh slot, or a sample chosen from the slot menu): analyse it now
+            notes = newtonefx::analyseNotes (*sample);
+            juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<NewtoneEditor> (this)] {
+                if (safe != nullptr)
+                    safe->commit();
+            });
+        }
+        selected = std::min (selected, (int) notes.pitches.size() - 1);
+        updateButtons();
+        repaint();
+    }
+
+    // the waveform and pitch curve shown (not saved)
+    void analyseView()
+    {
+        peaks.clear();
+        pitchTrack.clear();
+        zoom = 1.0;
+        scroll = 0.0;
+        if (sample == nullptr)
+            return;
+        const auto n = (std::int64_t) sample->frames();
+        for (std::int64_t i = 0; i < n; i += 256)
+        {
+            float m = 0.0f;
+            for (auto j = i; j < std::min (n, i + 256); ++j)
+                m = std::max ({ m, std::abs (sample->leftData()[j]), sample->isStereo() ? std::abs (sample->rightData()[j]) : 0.0f });
+            peaks.push_back (m);
+        }
+        if (warpMode())
+            return;
+        std::vector<float> mono (sample->leftData(), sample->leftData() + n);
+        if (sample->isStereo())
+            for (std::int64_t i = 0; i < n; ++i)
+                mono[(std::size_t) i] = 0.5f * (mono[(std::size_t) i] + sample->rightData()[i]);
+        pitchHop = std::max (64, (int) std::lround (256.0 * sample->sampleRate / 44100.0));
+        for (const auto& f : vocal::analysePitch (mono.data(), (int) n, sample->sampleRate, pitchHop))
+            pitchTrack.push_back (f.hz > 0.0 ? vocal::hzToNote (f.hz) : -1.0);
+    }
+
+    void commit()
+    {
+        auto state = warpMode() ? newtonefx::writeWarp (warp) : newtonefx::writeNative (notes);
+        savedState = state;
+        engine.editSong ([this, state] (Song& song) {
+            if (auto* fx = slotIn (song))
+                fx->state = state;
+        });
+        if (previewing)
+            startPreview();
+        updateButtons();
+        repaint();
+    }
+
+    void reanalyse()
+    {
+        if (sample == nullptr || warpMode())
+            return;
+        notes = newtonefx::analyseNotes (*sample);
+        selected = -1;
+        commit();
+    }
+
+    void chooseSample()
+    {
+        const juce::File current (juce::String::fromUTF8 (samplePath.c_str()));
+        chooser = std::make_unique<juce::FileChooser> (tr ("Source sample"), current.existsAsFile() ? current : juce::File(), engine.getSampleLibrary().wildcard());
+        chooser->launchAsync (juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles,
+                              [safe = juce::Component::SafePointer<NewtoneEditor> (this)] (const juce::FileChooser& fc) {
+                                  if (safe != nullptr && fc.getResult().existsAsFile())
+                                      safe->useSample (fc.getResult());
+                              });
+    }
+
+    void useSample (const juce::File& file)
+    {
+        if (engine.getSampleLibrary().load (file.getFullPathName()) == nullptr)
+        {
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::WarningIcon, tr ("Sample"), tr ("Could not read {0}", { file.getFileName() }));
+            return;
+        }
+        const auto path = file.getFullPathName().toStdString();
+        sample = nullptr;
+        samplePath.clear();
+        engine.editSong ([this, path] (Song& song) {
+            if (auto* fx = slotIn (song))
+            {
+                fx->samplePath = path;
+                fx->state.clear(); // (a new sample: its own notes / no markers)
+            }
+        });
+        reloadFromSong();
+    }
+
+    void togglePreview()
+    {
+        if (previewing)
+        {
+            previewing = false;
+            engine.previewSample (nullptr);
+        }
+        else
+            startPreview();
+        updateButtons();
+    }
+
+    void startPreview()
+    {
+        const auto* fx = currentSlot();
+        if (fx == nullptr || sample == nullptr)
+            return;
+        previewing = true;
+        engine.previewSample (newtonefx::renderedSource (sample, savedState), false, 0.8f);
+    }
+
+    void saveWav()
+    {
+        if (sample == nullptr)
+            return;
+        const juce::File src (juce::String::fromUTF8 (samplePath.c_str()));
+        chooser = std::make_unique<juce::FileChooser> (tr ("Save the edited audio"), src.getSiblingFile (src.getFileNameWithoutExtension() + " (edited).wav"), "*.wav");
+        chooser->launchAsync (juce::FileBrowserComponent::saveMode | juce::FileBrowserComponent::warnAboutOverwriting,
+                              [safe = juce::Component::SafePointer<NewtoneEditor> (this)] (const juce::FileChooser& fc) {
+                                  if (safe == nullptr || fc.getResult() == juce::File())
+                                      return;
+                                  const auto out = newtonefx::renderedSource (safe->sample, safe->savedState);
+                                  const auto file = fc.getResult().withFileExtension ("wav");
+                                  file.deleteFile();
+                                  std::unique_ptr<juce::OutputStream> stream (file.createOutputStream().release());
+                                  juce::WavAudioFormat wav;
+                                  const auto channels = out->isStereo() ? 2 : 1;
+                                  std::unique_ptr<juce::AudioFormatWriter> writer (
+                                      stream != nullptr ? wav.createWriterFor (stream.get(), out->sampleRate, (unsigned int) channels, 24, {}, 0) : nullptr);
+                                  if (writer == nullptr)
+                                  {
+                                      juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::WarningIcon, tr ("Save"), tr ("Could not write {0}", { file.getFullPathName() }));
+                                      return;
+                                  }
+                                  stream.release();
+                                  const float* data[2] { out->leftData(), out->isStereo() ? out->rightData() : out->leftData() };
+                                  writer->writeFromFloatArrays (data, channels, (int) out->frames());
+                              });
+    }
+
+    void showLengthMenu()
+    {
+        if (sample == nullptr)
+            return;
+        juce::PopupMenu menu;
+        const auto bpm = engine.getSong().bpm;
+        const auto seconds = (double) frames() / sample->sampleRate;
+        // the whole sample stretched to a length (one marker at its end)
+        auto setLength = [this] (double ratio) {
+            warp.markers.clear();
+            if (std::abs (ratio - 1.0) > 1e-6)
+                warp.markers.push_back ({ frames() - 1, (std::int64_t) std::llround ((double) (frames() - 1) * ratio) });
+            commit();
+        };
+        for (const auto ratio : { 0.5, 0.75, 1.0, 1.25, 1.5, 2.0 })
+            menu.addItem (juce::String (ratio * 100.0, 0) + " %", [setLength, ratio] { setLength (ratio); });
+        menu.addSeparator();
+        // to whole bars of the song's tempo
+        const auto bar = 4.0 * 60.0 / std::max (1.0, bpm);
+        for (const auto bars : { 1, 2, 4, 8, 16 })
+            menu.addItem (tr ("{0} bar(s) at {1} BPM", { juce::String (bars), juce::String (bpm, 2) }),
+                          [setLength, ratio = bars * bar / std::max (1e-6, seconds)] { setLength (ratio); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (&stretch));
+    }
+
+    void showNoteMenu (int k)
+    {
+        juce::PopupMenu menu;
+        auto& p = notes.pitches[(std::size_t) k];
+        menu.addItem (tr ("Snap to the nearest note"), [this, k] {
+            auto& q = notes.pitches[(std::size_t) k];
+            q.shift = std::round (q.origPitch + q.shift) - q.origPitch;
+            commit();
+        });
+        menu.addItem (tr ("Reset this note"), [this, k] {
+            auto& q = notes.pitches[(std::size_t) k];
+            q.shift = 0.0;
+            q.curStart = q.origStart;
+            q.curEnd = q.origEnd;
+            q.enabled = true;
+            q.volume = 1.0;
+            commit();
+        });
+        menu.addItem (p.enabled ? tr ("Mute") : tr ("Unmute"), [this, k] {
+            notes.pitches[(std::size_t) k].enabled = ! notes.pitches[(std::size_t) k].enabled;
+            commit();
+        });
+        juce::PopupMenu volume;
+        for (const auto db : { 6.0, 3.0, 0.0, -3.0, -6.0, -12.0 })
+            volume.addItem ((db > 0 ? "+" : "") + juce::String (db, 0) + " dB", true, std::abs (20.0 * std::log10 (std::max (1e-6, p.volume)) - db) < 0.1, [this, k, db] {
+                notes.pitches[(std::size_t) k].volume = std::pow (10.0, db / 20.0);
+                commit();
+            });
+        menu.addSubMenu (tr ("Volume"), volume);
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void updateButtons()
+    {
+        const auto has = sample != nullptr && validSlot();
+        analyse.setVisible (! warpMode());
+        snapAll.setVisible (! warpMode());
+        stretch.setVisible (warpMode());
+        for (auto* b : { &analyse, &snapAll, &reset, &preview, &save, &stretch })
+            b->setEnabled (has);
+        load.setEnabled (validSlot());
+        slave.setEnabled (validSlot());
+        preview.setButtonText (previewing ? tr ("Stop") : tr ("Preview"));
+        juce::String text = tr ("(beta) LYNX's own analysis and pitch / time engines; FL's own edits are not reproduced exactly");
+        if (sample != nullptr)
+        {
+            const juce::File f (juce::String::fromUTF8 (samplePath.c_str()));
+            text = f.getFileName() + "  ·  " + juce::String ((double) frames() / sample->sampleRate, 2) + " s  ·  ";
+            text += warpMode() ? tr ("{0} warp markers. Double-click: add a marker, drag it to move that point, right-click: remove", { juce::String ((int) warp.markers.size()) })
+                               : tr ("{0} notes. Drag: pitch (Alt: free), Ctrl+drag: time, double-click: snap, right-click: menu", { juce::String ((int) notes.pitches.size()) });
+        }
+        status.setText (text, juce::dontSendNotification);
+        resized();
+    }
+
+    void timerCallback() override
+    {
+        if (previewing)
+        {
+            if (engine.getPreviewPosition() < 0.0 && ++silentTicks > 15) // the preview ended
+            {
+                previewing = false;
+                updateButtons();
+            }
+            else if (engine.getPreviewPosition() >= 0.0)
+                silentTicks = 0;
+            repaint (canvasArea());
+        }
+    }
+    int silentTicks = 0;
+
+    // -------------------------------------------------------------------------------------------------- geometry
+    juce::Rectangle<int> canvasArea() const { return getLocalBounds().reduced (8).withTrimmedTop (30).withTrimmedBottom (22); }
+
+    double totalLength() const
+    {
+        if (warpMode())
+            return (double) std::max<std::int64_t> (1, std::max (newtonefx::warpedLength (warp, frames()), frames()));
+        std::int64_t end = frames();
+        for (const auto& p : notes.pitches)
+            end = std::max (end, p.curEnd);
+        return (double) std::max<std::int64_t> (1, end);
+    }
+    double visibleLength() const { return totalLength() / zoom; }
+    double pixelsPerSample() const { return (double) canvasArea().getWidth() / visibleLength(); }
+    void clampScroll() { scroll = std::clamp (scroll, 0.0, std::max (0.0, totalLength() - visibleLength())); }
+    float xOfOutput (double s) const { return (float) canvasArea().getX() + (float) ((s - scroll) * pixelsPerSample()); }
+    double outputOfX (float x) const { return scroll + (x - (float) canvasArea().getX()) / pixelsPerSample(); }
+
+    std::pair<double, double> pitchRange() const
+    {
+        double lo = 1e9, hi = -1e9;
+        for (const auto& p : notes.pitches)
+        {
+            lo = std::min (lo, p.origPitch + p.shift);
+            hi = std::max (hi, p.origPitch + p.shift);
+        }
+        if (lo > hi)
+            lo = 55.0, hi = 70.0;
+        return { std::floor (lo) - 4.0, std::ceil (hi) + 4.0 };
+    }
+    double rowHeight() const
+    {
+        const auto [lo, hi] = pitchRange();
+        return (double) canvasArea().getHeight() / std::max (1.0, hi - lo);
+    }
+    float yOfPitch (double midi) const
+    {
+        const auto [lo, hi] = pitchRange();
+        const auto area = canvasArea();
+        return (float) area.getBottom() - (float) ((midi - lo) * (double) area.getHeight() / std::max (1.0, hi - lo));
+    }
+
+    int noteAt (juce::Point<float> pos) const
+    {
+        const auto h = (float) rowHeight();
+        for (int k = (int) notes.pitches.size() - 1; k >= 0; --k)
+        {
+            const auto& p = notes.pitches[(std::size_t) k];
+            const auto y = yOfPitch (p.origPitch + p.shift);
+            if (pos.x >= xOfOutput ((double) p.curStart) && pos.x <= xOfOutput ((double) p.curEnd) && std::abs (pos.y - y) <= std::max (5.0f, 0.5f * h))
+                return k;
+        }
+        return -1;
+    }
+
+    int markerAt (float x) const
+    {
+        for (int k = 0; k < (int) warp.markers.size(); ++k)
+            if (std::abs (xOfOutput ((double) warp.markers[(std::size_t) k].output) - x) <= 5.0f)
+                return k;
+        return -1;
+    }
+
+    // -------------------------------------------------------------------------------------------------- painting
+    void paintWave (juce::Graphics& g, juce::Rectangle<int> area, std::function<double (double)> sourceOfOutput, juce::Colour colour) const
+    {
+        if (peaks.empty())
+            return;
+        g.setColour (colour);
+        const auto mid = (float) area.getCentreY(), half = 0.48f * (float) area.getHeight();
+        for (int x = area.getX(); x < area.getRight(); ++x)
+        {
+            const auto a = sourceOfOutput (outputOfX ((float) x)), b = sourceOfOutput (outputOfX ((float) x + 1.0f));
+            if (b < 0.0 || a >= (double) frames())
+                continue;
+            float m = 0.0f;
+            for (auto i = (std::int64_t) std::max (0.0, std::min (a, b)) / 256; i <= (std::int64_t) std::max (a, b) / 256 && i < (std::int64_t) peaks.size(); ++i)
+                m = std::max (m, peaks[(std::size_t) i]);
+            g.drawVerticalLine (x, mid - m * half, mid + m * half);
+        }
+    }
+
+    void paintNotes (juce::Graphics& g, juce::Rectangle<int> area) const
+    {
+        const auto [lo, hi] = pitchRange();
+        // semitone rows (black keys darker) with C labels
+        g.setFont (theme::font (theme::type::caption));
+        for (auto m = (int) lo; m < (int) hi; ++m)
+        {
+            const auto y0 = yOfPitch (m + 0.5), y1 = yOfPitch (m - 0.5);
+            const auto black = juce::String ("010100101010").substring (((m % 12) + 12) % 12, ((m % 12) + 12) % 12 + 1) == "1";
+            g.setColour (black ? theme::colour::bg0.darker (0.2f) : theme::colour::bg0.brighter (0.03f));
+            g.fillRect ((float) area.getX(), y0, (float) area.getWidth(), y1 - y0);
+            if (((m % 12) + 12) % 12 == 0)
+            {
+                g.setColour (theme::colour::textDisabled);
+                g.drawText (noteName (m), area.getX() + 2, (int) y0, 30, (int) (y1 - y0), juce::Justification::centredLeft);
+            }
+        }
+        // the waveform, faint, at the bottom
+        paintWave (g, area.withTrimmedTop (area.getHeight() * 3 / 4), [] (double s) { return s; }, theme::colour::textDisabled.withAlpha (0.35f));
+
+        const auto h = (float) std::max (6.0, rowHeight() * 0.8);
+        for (int k = 0; k < (int) notes.pitches.size(); ++k)
+        {
+            const auto& p = notes.pitches[(std::size_t) k];
+            const auto x0 = xOfOutput ((double) p.curStart), x1 = xOfOutput ((double) p.curEnd);
+            if (x1 < (float) area.getX() || x0 > (float) area.getRight())
+                continue;
+            const auto target = p.origPitch + p.shift;
+            const auto y = yOfPitch (target);
+            const auto edited = p.edited (notes.globalFormant);
+            auto colour = ! p.enabled ? theme::colour::bg5 : edited ? theme::colour::accent : theme::colour::info;
+            g.setColour (colour.withAlpha (k == selected ? 0.75f : 0.45f));
+            g.fillRoundedRectangle (x0, y - 0.5f * h, std::max (2.0f, x1 - x0), h, 3.0f);
+            if (k == selected)
+            {
+                g.setColour (theme::colour::textPrimary);
+                g.drawRoundedRectangle (x0, y - 0.5f * h, std::max (2.0f, x1 - x0), h, 3.0f, 1.2f);
+            }
+            // the sung pitch inside the note, moved with it
+            if (! pitchTrack.empty())
+            {
+                juce::Path curve;
+                bool started = false;
+                for (auto f = std::max<std::int64_t> (0, p.origStart / pitchHop); f < std::min<std::int64_t> ((std::int64_t) pitchTrack.size(), p.origEnd / pitchHop + 1); ++f)
+                {
+                    const auto v = pitchTrack[(std::size_t) f];
+                    if (v < 0.0 || std::abs (v - p.origPitch) > 1.5 || f * pitchHop < p.origStart || f * pitchHop >= p.origEnd) // (the note's own pitch only)
+                    {
+                        started = false;
+                        continue;
+                    }
+                    const auto px = xOfOutput ((double) (p.curStart + f * pitchHop - p.origStart));
+                    const auto py = yOfPitch (v + p.shift);
+                    if (! started)
+                        curve.startNewSubPath (px, py);
+                    else
+                        curve.lineTo (px, py);
+                    started = true;
+                }
+                g.setColour (theme::colour::textPrimary.withAlpha (p.enabled ? 0.8f : 0.3f));
+                g.strokePath (curve, juce::PathStrokeType (1.2f));
+            }
+            if (x1 - x0 > 34.0f)
+            {
+                g.setColour (theme::colour::textPrimary);
+                g.drawText (noteName (target) + (std::abs (p.shift) > 0.01 ? juce::String::formatted (" %+.1f", p.shift) : juce::String()),
+                            juce::Rectangle<float> (x0 + 3.0f, y - 0.5f * h - 14.0f, std::max (40.0f, x1 - x0), 13.0f), juce::Justification::left);
+            }
+        }
+    }
+
+    void paintWarp (juce::Graphics& g, juce::Rectangle<int> area) const
+    {
+        // the warped waveform (where each part of the sample plays now)
+        paintWave (g, area, [this] (double out) { return newtonefx::warpToSource (warp, frames(), out); }, theme::colour::info.withAlpha (0.7f));
+        // bars of the song's tempo
+        const auto bpm = engine.getSong().bpm;
+        const auto beat = sample->sampleRate * 60.0 / std::max (1.0, bpm);
+        g.setColour (theme::colour::border);
+        for (double s = 0.0; s < totalLength(); s += beat)
+        {
+            const auto x = xOfOutput (s);
+            if (x >= (float) area.getX() && x <= (float) area.getRight())
+                g.drawVerticalLine ((int) x, (float) area.getY(), (float) area.getY() + 8.0f);
+        }
+        // the end of the original length, and the markers
+        g.setColour (theme::colour::textDisabled);
+        g.drawVerticalLine ((int) xOfOutput ((double) frames()), (float) area.getY(), (float) area.getBottom());
+        for (const auto& m : warp.markers)
+        {
+            const auto x = xOfOutput ((double) m.output);
+            g.setColour (theme::colour::warning);
+            g.drawVerticalLine ((int) x, (float) area.getY(), (float) area.getBottom());
+            juce::Path tri;
+            tri.addTriangle (x - 5.0f, (float) area.getY(), x + 5.0f, (float) area.getY(), x, (float) area.getY() + 8.0f);
+            g.fillPath (tri);
+        }
+    }
+};
+
+class NewtoneWindow final : public juce::DocumentWindow
+{
+public:
+    NewtoneWindow (AudioEngine& engine, int track, int slot, const juce::String& title)
+        : DocumentWindow (title, theme::colour::bg2, DocumentWindow::closeButton)
+    {
+        setUsingNativeTitleBar (true);
+        setContentOwned (new NewtoneEditor (engine, track, slot), true);
+        setResizable (true, false);
+        setResizeLimits (560, 300, 4000, 2000);
+        centreWithSize (getWidth(), getHeight());
+        setVisible (true);
+        keepAboveMainWindow (*this);
+    }
+
+    void closeButtonPressed() override;
+};
+
+std::map<std::pair<int, int>, std::unique_ptr<NewtoneWindow>>& newtoneWindows()
+{
+    static std::map<std::pair<int, int>, std::unique_ptr<NewtoneWindow>> open;
+    return open;
+}
+
+void NewtoneWindow::closeButtonPressed()
+{
+    for (auto& [key, window] : newtoneWindows())
+        if (window.get() == this)
+        {
+            juce::MessageManager::callAsync ([k = key] { newtoneWindows().erase (k); });
+            return;
+        }
+}
+} // namespace
+
+namespace NewtoneWindows
+{
+bool handles (EffectKind kind)
+{
+    return isNewtoneKind (kind);
+}
+
+void open (AudioEngine& engine, int track, int slot)
+{
+    auto& open = newtoneWindows();
+    const auto key = std::make_pair (track, slot);
+    if (auto it = open.find (key); it != open.end())
+    {
+        it->second->toFront (true);
+        return;
+    }
+    const auto& mixer = engine.getSong().mixer;
+    if (track < 0 || track >= (int) mixer.size() || slot < 0 || slot >= (int) mixer[(std::size_t) track].effects.size())
+        return;
+    const auto kind = mixer[(std::size_t) track].effects[(std::size_t) slot].kind;
+    const auto name = track == 0 ? tr ("Master") : juce::String::fromUTF8 (mixer[(std::size_t) track].name.c_str());
+    open[key] = std::make_unique<NewtoneWindow> (engine, track, slot,
+                                                 utf8 (effectInfo (kind).name) + " - " + (name.isNotEmpty() ? name : tr ("Insert {0}", { juce::String (track) }))
+                                                     + " (" + tr ("slot {0}", { juce::String (slot + 1) }) + ")");
+}
+
+void closeAll()
+{
+    newtoneWindows().clear();
+}
+} // namespace NewtoneWindows
+
+std::unique_ptr<juce::Component> makeNewtoneEditor (AudioEngine& engine, int track, int slot)
+{
+    return std::make_unique<NewtoneEditor> (engine, track, slot);
+}
+} // namespace lynx

+ 25 - 0
src/ui/NewtoneEditor.h

@@ -0,0 +1,25 @@
+#pragma once
+
+// LYNX's editors for a Newtone / Newtime mixer slot (round 142, issue #5): load a sample, analyse it, edit it, hear it.
+//  - Newtone: the sample's notes on a pitch grid (LYNX's analysis, core/NewtoneFx.h analyseNotes). Drag a note up or
+//    down to change its pitch (snapped to semitones; Alt = free), Ctrl+drag to move it in time; double-click snaps it
+//    to the nearest semitone; right-click for its menu (snap, reset, mute). Up/Down move the selected note.
+//  - Newtime: the sample's waveform with warp markers. Double-click adds a marker, dragging it moves where that point
+//    of the sample plays (the sample stretches around it, pitch kept); right-click a marker to remove it.
+// The edits are the slot's state (LYNX's own format); "Play with the song" is the plugin's slave mode, Preview plays
+// the edited sample alone. Imported FL Newtone states open with their notes; editing one saves it in LYNX's format.
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+namespace NewtoneWindows
+{
+bool handles (EffectKind kind); // newtone, newtime
+void open (AudioEngine& engine, int track, int slot);
+void closeAll();
+} // namespace NewtoneWindows
+
+// The editor alone (snapshots, tests)
+std::unique_ptr<juce::Component> makeNewtoneEditor (AudioEngine& engine, int track, int slot);
+} // namespace lynx

+ 18 - 2
src/ui/PatcherEditor.cpp

@@ -8,6 +8,7 @@
 #include "engine/PluginHost.h"
 #include "ui/I18n.h"
 #include "ui/MixerComponent.h"
+#include "ui/ChannelRackComponent.h"
 #include "ui/PluginWindow.h"
 #include "ui/Theme.h"
 #include "ui/ToolWindow.h"
@@ -720,9 +721,12 @@ private:
         juce::PopupMenu effects, instruments, pluginEffects, pluginInstruments;
         for (const auto kind : addableEffects())
             if (kind != EffectKind::patcher)
-                effects.addItem (juce::String::fromUTF8 (effectInfo (kind).name), [this, kind, at] {
+                effects.addItem (addableEffectName (kind), addableEffectAvailable (kind), false, [this, kind, at] {
+                    const auto fx = newAddableEffect (kind, engine.getSong().bpm);
+                    if (! fx)
+                        return;
                     PatchNode n;
-                    n.effect = makeEffectSlot (kind);
+                    n.effect = *fx;
                     addNode (n, at);
                 });
         for (const auto kind : { InstrumentKind::synth, InstrumentKind::kick, InstrumentKind::snare, InstrumentKind::hat, InstrumentKind::clap })
@@ -735,6 +739,18 @@ private:
                                      n.channel.name = effectNameOf (kind);
                                      addNode (n, at);
                                  });
+        {
+            // FL's own instrument engines (round 142)
+            juce::PopupMenu engines;
+            addFlEngineItems (engines, [this, at] (ChannelDef c) {
+                PatchNode n;
+                n.generator = true;
+                n.channel = c;
+                addNode (n, at);
+            });
+            instruments.addSeparator();
+            instruments.addSubMenu (tr ("FL engines"), engines);
+        }
         addPluginItems (pluginEffects, engine, false, [this, at] (PluginRef ref) {
             PatchNode n;
             n.effect.kind = EffectKind::plugin;

+ 7 - 0
src/ui/PluginEditors.cpp

@@ -1,5 +1,6 @@
 #include "ui/PatcherEditor.h"
 #include "ui/ControllerEditors.h"
+#include "ui/NewtoneEditor.h"
 #include "ui/PluginEditors.h"
 
 #include <cstring>
@@ -3586,6 +3587,11 @@ void open (AudioEngine& engine, int track, int slot)
         FormulaControllerWindows::open (engine, track, slot);
         return;
     }
+    if (NewtoneWindows::handles (kind)) // load a sample, edit its notes / warp markers, hear it (round 142)
+    {
+        NewtoneWindows::open (engine, track, slot);
+        return;
+    }
     if (kind == EffectKind::parametricEq) // its own editor (response curve with handles)
     {
         ParametricEqWindows::open (engine, track, slot);
@@ -3625,6 +3631,7 @@ void closeAll()
 {
     windows().clear();
     FormulaControllerWindows::closeAll();
+    NewtoneWindows::closeAll();
     FacetEqWindows::closeAll();
     ProEditorWindows::closeAll();
 }

+ 15 - 1
src/ui/QuickAddPalette.cpp

@@ -5,6 +5,7 @@
 #include "core/SearchQuery.h"
 #include "ui/I18n.h"
 #include "ui/MixerComponent.h"
+#include "ui/ChannelRackComponent.h"
 #include "ui/Theme.h"
 #include "ui/ToolWindow.h"
 
@@ -125,8 +126,21 @@ public:
                                             targets.addInstrument (c);
                                         } });
 
+        // FL's own instrument engines (round 142): those this PC can make (the user's FL installation)
+        for (const auto& e : natives::instrumentEngines())
+            if (natives::available (e, flStudioAccess()))
+                instruments.all.push_back ({ flEngineName (e), tr ("built-in FL engine"), [this, kind = e.kind] {
+                                                if (auto c = natives::makeChannel (kind, flStudioAccess()))
+                                                    targets.addInstrument (*c);
+                                            } });
+
         for (auto kind : addableEffects())
-            effects.all.push_back ({ juce::String::fromUTF8 (effectInfo (kind).name), tr ("built-in"), [this, kind] { targets.addEffect (makeEffectSlot (kind)); } });
+            if (addableEffectAvailable (kind)) // (FL engines without the user's FL installation are left out)
+                effects.all.push_back ({ addableEffectName (kind), natives::effectEngine (kind) != nullptr ? tr ("built-in FL engine") : tr ("built-in"),
+                                         [this, kind, bpm = engine.getSong().bpm] {
+                                             if (const auto fx = newAddableEffect (kind, bpm))
+                                                 targets.addEffect (*fx);
+                                         } });
         // LYNX equivalents of well-known third-party effects (the substitutes table): findable by the product's name
         for (const auto& entry : pluginSubstitutes())
             if (! entry.instrument)

+ 290 - 0
tests/Natives142Tests.inc

@@ -0,0 +1,290 @@
+// Round 142 (issue #5): FL engines usable in native LYNX projects (core/NativeEngines.h, REA_rodada142)
+
+#include "../tools/WavReader.h"
+#include "core/NativeEngines.h"
+#include "core/VocalPitch.h"
+
+namespace natives142
+{
+// the user's FL installation as the tests see it (WSL / POSIX): FL's backslashes become '/', names matched ignoring case
+lynx::natives::FlAccess flAccess()
+{
+    namespace fs = std::filesystem;
+    lynx::natives::FlAccess fl;
+    if (realFlpDir.empty())
+        return fl;
+    const auto local = [] (std::string p) {
+        std::replace (p.begin(), p.end(), '\\', '/');
+        return lynx::existingPathIgnoringCase (p);
+    };
+    fl.roots.data = fs::path (realFlpDir).string();
+    fl.roots.factoryData = fs::path (realFlpDir).parent_path().string();
+    fl.fileExists = [local] (const std::string& p) { return fs::is_regular_file (local (p)); };
+    fl.readFile = [local] (const std::string& p) {
+        std::ifstream f (local (p), std::ios::binary);
+        return std::vector<std::uint8_t> ((std::istreambuf_iterator<char> (f)), std::istreambuf_iterator<char>());
+    };
+    fl.listPresets = [local] (const std::string& folder) {
+        std::vector<std::string> out;
+        std::error_code ec;
+        for (const auto& e : fs::recursive_directory_iterator (local (folder), ec))
+            if (e.is_regular_file())
+                out.push_back (e.path().string());
+        std::sort (out.begin(), out.end());
+        return out;
+    };
+    fl.saveEmbedded = [] (const std::vector<std::uint8_t>& wav, const std::string& name) {
+        const auto path = (fs::temp_directory_path() / ("lynx-natives142-" + std::to_string (wav.size()) + "-" + std::to_string (name.size()) + ".wav")).string();
+        std::ofstream (path, std::ios::binary).write ((const char*) wav.data(), (std::streamsize) wav.size());
+        return path;
+    };
+    return fl;
+}
+
+// one channel alone in the rack, a note held for `seconds`: the output's RMS
+double renderChannel (const lynx::ChannelDef& channel, const lynx::natives::FlAccess& fl, int key = 60, double seconds = 1.0)
+{
+    lynx::Song s;
+    s.mixer = lynx::Song::defaultMixer (2);
+    auto c = channel;
+    c.mixerTrack = 1;
+    s.channels.push_back (c);
+    s.patterns.emplace_back();
+    auto samples = [&fl] (const std::string& path) -> std::shared_ptr<const lynx::SampleData> {
+        auto p = path;
+        std::replace (p.begin(), p.end(), '\\', '/');
+        (void) fl;
+        return lynx::tools::readWav (lynx::existingPathIgnoringCase (p));
+    };
+    auto state = lynx::RackState::build (s, nullptr, 48000.0, samples);
+    lynx::RackRenderer r;
+    r.prepare (48000.0, 512);
+    lynx::LiveEventQueue live;
+    lynx::NoteEvent on;
+    on.channel = 0;
+    on.key = key;
+    on.velocity = 0.8f;
+    live.push (on);
+    const auto n = (int) (seconds * 48000.0);
+    double sum = 0.0;
+    for (int done = 0; done < n; done += 512)
+    {
+        std::vector<float> l (512), rr (512);
+        r.process (state.get(), false, 0.0, 512, l.data(), rr.data(), &live, nullptr);
+        for (int i = 0; i < 512; ++i)
+            sum += (double) l[(std::size_t) i] * l[(std::size_t) i] + (double) rr[(std::size_t) i] * rr[(std::size_t) i];
+    }
+    return std::sqrt (sum / (2.0 * n));
+}
+} // namespace natives142
+
+TEST (natives142_lists_and_no_fl_installation)
+{
+    using namespace lynx;
+    // every engine once; the effect engines are not plain parameter effects
+    std::set<int> seen;
+    for (const auto& e : natives::instrumentEngines())
+        CHECK (seen.insert ((int) e.kind).second);
+    seen.clear();
+    for (const auto& e : natives::effectEngines())
+        CHECK (seen.insert ((int) e.kind).second);
+    CHECK (natives::instrumentEngine (InstrumentKind::sytrus) != nullptr && natives::instrumentEngine (InstrumentKind::synth) == nullptr);
+    CHECK (natives::effectEngine (EffectKind::newtone) != nullptr && natives::effectEngine (EffectKind::eq) == nullptr);
+
+    // without FL: the engines with LYNX's own defaults are made and play, the others are not available
+    natives::FlAccess none;
+    for (const auto& e : natives::instrumentEngines())
+    {
+        const auto c = natives::makeChannel (e.kind, none);
+        CHECK (natives::available (e, none) == (e.needs == natives::Needs::nothing));
+        CHECK (c.has_value() == (e.needs == natives::Needs::nothing));
+        if (c)
+        {
+            CHECK (c->instrument == e.kind && c->name == e.name);
+            CHECK (natives142::renderChannel (*c, none) > 1.0e-3);
+        }
+    }
+    for (const auto& e : natives::effectEngines())
+    {
+        const auto fx = natives::makeSlot (e.kind, none);
+        CHECK (fx.has_value() == (e.needs == natives::Needs::nothing));
+        if (fx)
+            CHECK (fx->kind == e.kind);
+    }
+    CHECK (natives::newEffect (EffectKind::eq, none).has_value()); // (a plain effect: always)
+    CHECK (natives::effectMenuName (EffectKind::newtone) == "Newtone (beta)" && natives::effectMenuName (EffectKind::maximus) == "Maximus");
+}
+
+TEST (natives142_fl_keys_default_wavetable)
+{
+    // a wavetable the installation doesn't ship: FL Keys loads the one default.wti names (FL 2026 has no "Piano")
+    std::map<std::string, std::string> files {
+        { "W\\default.wti", "[default]\r\nfile=mda piano.wti\r\n" },
+        { "W\\mda piano.wti", "[info]\r\nname=mda\r\nsamples=1\r\nfiletype=riff\r\nsamplerate=44100\r\n\r\n[velocitylayers]\r\ncount=1\r\n0=0\r\n\r\n[sample0]\r\nname=a.wav\r\nroot=60\r\nhigh=127\r\n" },
+    };
+    auto read = [&] (const std::string& p) {
+        const auto it = files.find (p);
+        return it == files.end() ? std::vector<std::uint8_t> {} : std::vector<std::uint8_t> (it->second.begin(), it->second.end());
+    };
+    auto existing = [] (const std::string& p) { return p; };
+    // FL Keys' state: its wavetable name "Piano" (REA_rodada69 §8 layout, see flkeys::parseState)
+    lynx::flkeys::State st;
+    st.wavetable = "Piano";
+    const auto state = lynx::flkeys::writeState (st);
+    lynx::ChannelDef def;
+    CHECK (lynx::flkeys::importChannel (def, state, "W", read, existing, {}));
+    CHECK (def.instrument == lynx::InstrumentKind::flkeys && def.zones.size() == 1 && def.zones[0].path == "W\\a.wav");
+    files.erase ("W\\default.wti");
+    lynx::ChannelDef none;
+    CHECK (! lynx::flkeys::importChannel (none, state, "W", read, existing, {}));
+}
+
+TEST (natives142_engines_from_the_fl_installation)
+{
+    using namespace lynx;
+    if (realFlpDir.empty())
+        return;
+    const auto fl = natives142::flAccess();
+    int made = 0;
+    for (const auto& e : natives::instrumentEngines())
+    {
+        const auto c = natives::makeChannel (e.kind, fl);
+        CHECK (c.has_value());
+        if (! c)
+        {
+            std::printf ("  not made: %s\n", e.name);
+            continue;
+        }
+        ++made;
+        CHECK (c->instrument == e.kind && c->name == e.name);
+        if (e.kind == InstrumentKind::granulizer) // (plays the channel's sample: none yet)
+            continue;
+        const auto rms = natives142::renderChannel (*c, fl, e.kind == InstrumentKind::drumaxx ? 48 : 60);
+        CHECK (rms > 1.0e-3 && std::isfinite (rms));
+        if (! (rms > 1.0e-3))
+            std::printf ("  silent: %s (%g)\n", e.name, rms);
+    }
+    CHECK (made == (int) natives::instrumentEngines().size());
+
+    for (const auto& e : natives::effectEngines())
+    {
+        const auto slot = natives::makeSlot (e.kind, fl);
+        CHECK (slot.has_value() && slot->kind == e.kind);
+        if (! slot)
+            continue;
+        auto fx = makeEffect (*slot);
+        fx->prepare (48000.0);
+        double in = 0.0, out = 0.0;
+        bool finite = true;
+        for (int b = 0; b < 94; ++b)
+        {
+            std::vector<float> l (512), r (512);
+            for (int i = 0; i < 512; ++i)
+            {
+                const auto t = (b * 512 + i) / 48000.0;
+                l[(std::size_t) i] = r[(std::size_t) i] = (float) (0.3 * std::sin (2.0 * M_PI * 220.0 * t) + 0.05 * std::sin (2.0 * M_PI * 3100.0 * t));
+                in += 2.0 * l[(std::size_t) i] * l[(std::size_t) i];
+            }
+            fx->process (l.data(), r.data(), 512, slot->params, 120.0);
+            for (int i = 0; i < 512; ++i)
+            {
+                finite = finite && std::isfinite (l[(std::size_t) i]) && std::isfinite (r[(std::size_t) i]);
+                out += (double) l[(std::size_t) i] * l[(std::size_t) i] + (double) r[(std::size_t) i] * r[(std::size_t) i];
+            }
+        }
+        CHECK (finite && out > 0.01 * in);
+    }
+    // the state-based ones carry FL's default state (not an empty one)
+    for (const auto kind : { EffectKind::maximus, EffectKind::vocodex, EffectKind::equo, EffectKind::distructor, EffectKind::lovePhilter, EffectKind::grossBeat })
+    {
+        const auto slot = natives::makeSlot (kind, fl);
+        CHECK (slot && ! slot->state.empty());
+    }
+}
+
+TEST (natives142_newtone_and_newtime_native_projects)
+{
+    using namespace lynx;
+    // a "sung" line: four notes (A3, B3, C4, rest, E4) with a light vibrato
+    SampleData s;
+    s.sampleRate = 44100.0;
+    const double hz[] = { 220.0, 246.94, 261.63, 0.0, 329.63 };
+    double ph = 0.0;
+    for (const auto f0 : hz)
+        for (int i = 0; i < 17640; ++i)
+        {
+            const auto f = f0 * (1.0 + 0.004 * std::sin (2.0 * M_PI * 5.5 * i / 44100.0));
+            ph += 2.0 * M_PI * f / 44100.0;
+            float v = 0.0f;
+            if (f0 > 0.0)
+                for (int h = 1; h < 8; ++h)
+                    v += (float) (0.3 / h * std::sin (h * ph));
+            s.left.push_back (v);
+        }
+
+    // the analysis finds the four notes at their pitches, nothing edited
+    auto t = newtonefx::analyseNotes (s);
+    CHECK (t.pitches.size() == 4 && t.frames == (std::int64_t) s.frames());
+    const double expected[] = { 57.0, 59.0, 60.0, 64.0 };
+    for (std::size_t k = 0; k < std::min<std::size_t> (4, t.pitches.size()); ++k)
+    {
+        CHECK (std::abs (t.pitches[k].origPitch - expected[k]) < 0.1);
+        CHECK (! t.pitches[k].edited (1.0) && t.pitches[k].curStart == t.pitches[k].origStart);
+    }
+    CHECK (newtonefx::renderEdits (s, t) == nullptr); // (unedited: the source plays as it is)
+
+    // LYNX's own state round-trips; trackOf reads it
+    auto state = newtonefx::writeNative (t);
+    auto back = newtonefx::parseNative (state);
+    CHECK (back && back->pitches.size() == t.pitches.size() && ! back->edited);
+    CHECK (newtonefx::trackOf (state).has_value() && ! newtonefx::parseNative ({ 1, 2, 3 }));
+    state.push_back (0);
+    CHECK (! newtonefx::parseNative (state)); // (trailing bytes: not ours)
+
+    // a note moved up two semitones sounds there; the slot plays the edited sample in slave mode
+    if (t.pitches.size() == 4)
+    {
+        t.pitches[1].shift = 2.0;
+        const auto edited = newtonefx::writeNative (t);
+        CHECK (newtonefx::parseNative (edited)->edited);
+        auto src = std::make_shared<SampleData> (s);
+        const auto rendered = newtonefx::renderedSource (src, edited);
+        CHECK (rendered != nullptr && rendered != src && rendered->frames() == s.frames());
+        const auto frames = vocal::analysePitch (rendered->leftData() + 22050, 8000, 44100.0, 512);
+        double note = 0.0;
+        for (const auto& f : frames)
+            if (f.hz > 0.0)
+            {
+                note = vocal::hzToNote (f.hz);
+                break;
+            }
+        CHECK (std::abs (note - 61.0) < 0.3);
+
+        auto slot = makeEffectSlot (EffectKind::newtone);
+        slot.params[0] = 1.0f;
+        slot.state = edited;
+        auto fx = newtonefx::make (src, slot.state);
+        fx->prepare (44100.0);
+        fx->setPlaying (true);
+        fx->setSongPosition (0.0);
+        std::vector<float> l (512, 0.0f), r (512, 0.0f);
+        fx->process (l.data(), r.data(), 512, slot.params, 120.0);
+        CHECK (std::abs (l[100] - rendered->leftData()[100]) < 1e-6f);
+    }
+
+    // Newtime: a marker stretches the first second to 1.5 s; the rest follows; the map round-trips
+    newtonefx::WarpMap m;
+    m.frames = (std::int64_t) s.frames();
+    m.markers = { { 44100, 66150 } };
+    CHECK (newtonefx::warpedLength (m, m.frames) == 66150 + (m.frames - 44100) * 3 / 2); // (the last slope goes on)
+    CHECK (std::abs (newtonefx::warpToOutput (m, m.frames, 22050.0) - 33075.0) < 1e-6);
+    CHECK (std::abs (newtonefx::warpToSource (m, m.frames, 33075.0) - 22050.0) < 1e-6);
+    const auto warped = newtonefx::renderWarp (s, m);
+    CHECK (warped != nullptr && (std::int64_t) warped->frames() == newtonefx::warpedLength (m, m.frames));
+    const auto map = newtonefx::parseWarp (newtonefx::writeWarp (m));
+    CHECK (map && *map == m);
+    newtonefx::WarpMap bad = m;
+    bad.markers.push_back ({ 40000, 70000 }); // (not increasing)
+    CHECK (! newtonefx::parseWarp (newtonefx::writeWarp (bad)));
+    CHECK (newtonefx::renderWarp (s, newtonefx::WarpMap {}) == nullptr);
+}

+ 1 - 0
tests/tests.cpp

@@ -15797,3 +15797,4 @@ TEST (plugin_layout_options_match_the_engine_values)
 #include "Parity137Tests.inc"
 #include "Parity144bTests.inc"
 #include "Patcher141Tests.inc"
+#include "Natives142Tests.inc"