ソースを参照

Hosted plugins are never cut by FL cut groups (issue #143)

FL's default template puts every new channel in cut group 1, cut by 1. FL
never cuts a Fruity Wrapper channel with it (Surge XT VST3 renders the same
with and without, REA_rodada190x), but LYNX choked the plugin right after each
note on at the same sample, so Surge XT channels of projects made in FL were
silent. InstrumentKind::plugin joins FL's plugin generators that cut groups
skip.
Ka1-S 3 週間 前
親
コミット
cec79fd31d
4 ファイル変更、121 行追加、1 行削除
  1. 54 0
      docs/analise/REA_rodada190x.md
  2. 5 1
      src/core/RackRenderer.cpp
  3. 61 0
      tests/Surge190xTests.inc
  4. 1 0
      tests/tests.cpp

+ 54 - 0
docs/analise/REA_rodada190x.md

@@ -0,0 +1,54 @@
+# Round 190x — issue #143: Surge XT channels from FL projects silent in LYNX [FL render][DATA][TEST]
+
+Report: a project saved in FL Studio with Surge XT (VST3 in FL) opens in LYNX with the Surge XT channels silent, while
+other plugins of the same project play; Surge XT works in projects made in LYNX (as CLAP).
+
+## 1. What was ruled out
+
+Surge XT 1.3.4 (official portable zip, VST3 + CLAP + factory data in the standard folders), FL 2026 (study install),
+LYNX 0.1.25 release and an origin/main build. Every case below plays in LYNX (headless `--export` and the app):
+
+| project | how it was made | LYNX |
+|---|---|---|
+| Surge VST3, Acidofil patch | LYNX `--export-flp`, opened and saved in FL (Ctrl+S) | plays, same peak as the native project |
+| same, other patch picked in Surge's editor, saved with the editor open | FL | plays |
+| Surge CLAP | LYNX export, saved in FL (FL's CLAP state is `u32 0` + the plugin's own state, as REA_rodada22 §2.5 had decoded) | plays |
+| any of the above with only the CLAP known to LYNX (VST3 state dropped, default patch) | | plays |
+| separate process, fixed size buffers | | plays |
+
+FL's wrapper state for the VST3 (records 1, 3 = component with JUCE's private-data trailer, 4 = parameter slots;
+no record 2) restores correctly through `splitFlVst3State`.
+
+## 2. The cause: FL's template puts every new channel in "cut itself" [DATA]
+
+A Surge XT channel added in FL itself (ADD › More plugins › Surge XT VST3, steps entered, saved) is silent in LYNX
+(its insert's render equals the render without it). Its channel events differ from the LYNX-exported one in 0x84 =
+`0x00010001`: cut group 1, cut by 1 — the value FL's default template gives every new channel (REA_rodada170i3 §2
+found it on all channels of `g169l.flp`).
+
+`RackState::build` cut every hosted plugin by its group (VST plugins were left out of 170i3's probe). The choke is
+queued after the note on at the same sample, so `PluginInstrument::cut()` (each held key's note off, then All Notes /
+All Sound Off) ended the note that had just started: a plugin that stops at once (Surge XT) is silent; one with a
+long release still leaks its tail, which is why other plugins of the same project seemed fine.
+
+## 3. FL never cuts a wrapped plugin [FL render]
+
+Probe (`probe/cut0.flp`, `probe/cut1.flp` in /mnt/e/lynx-work/surge190x): Surge XT VST3 at its default patch, a
+4-beat note on key 48 and a short key 60 half a beat later; 0x84 = 0 vs 0x10001. Energy at 130.8 Hz and its octave
+(key 48), 0.25 s windows, dB:
+
+| render | 0–0.25 s | 0.25–0.5 | 0.5–0.75 | … 2.0 s |
+|---|---|---|---|---|
+| FL, no cut | 48.1 | 47.7 | 48.1 | 48.1 |
+| FL, cut itself | 48.1 | 47.7 | 48.1 | 48.1 |
+| LYNX before, no cut | 45.1 | 46.7 | 45.1 | 45.1 |
+| LYNX before, cut itself | −54.9 | −50.0 | −200 | −200 |
+
+FL renders both the same: its cut groups don't touch Fruity Wrapper channels, like its own plugin generators
+(170i3 §2). The wrapper is one plugin class for VST2, VST3 and CLAP; VST2 and CLAP are inferred, not probed.
+
+## 4. Change
+
+`RackState::build`: `InstrumentKind::plugin` joins FL's plugin generators that cut groups never cut (as a target, by
+its own group or another's). A plugin channel's notes still cut the Sampler / audio clip / LYNX channels of their
+group, as before (not probed). Test `s190x_cut_itself_never_chokes_a_hosted_plugin`.

+ 5 - 1
src/core/RackRenderer.cpp

@@ -740,7 +740,10 @@ std::unique_ptr<const RackState> RackState::build (Song song,
 
     // FL's cut groups cut its Sampler / audio clip channels (REA_rodada167h) but not its plugin generators: Kepler
     // keeps sounding when its group cuts it (REA_rodada165g-flbeta165k §3), and so do the 26 FL generators of
-    // REA_rodada170i3 §2 (FL's renders with and without "cut itself" are the same; Ogun's tail in 169l's project)
+    // REA_rodada170i3 §2 (FL's renders with and without "cut itself" are the same; Ogun's tail in 169l's project).
+    // Nor its wrapped third-party plugins (issue #143, REA_rodada190x): Surge XT (VST3) renders the same in FL with
+    // and without "cut itself" — the group FL's default template gives every new channel (0x84 = 0x10001) — while
+    // LYNX's choke, landing after the note on at the same sample, ended every note as it started: silent channels.
     const auto flCutsIt = [] (InstrumentKind k) {
         switch (k)
         {
@@ -755,6 +758,7 @@ std::unique_ptr<const RackState> RackState::build (Song song,
             case InstrumentKind::sawer: case InstrumentKind::flkeys: case InstrumentKind::granulizer:
             case InstrumentKind::drumaxx: case InstrumentKind::slayer: case InstrumentKind::directwave:
             case InstrumentKind::wavetraveller:
+            case InstrumentKind::plugin:
                 return false;
             default:
                 return true;

+ 61 - 0
tests/Surge190xTests.inc

@@ -0,0 +1,61 @@
+// Round 190x, issue #143: Surge XT channels of a project made in FL Studio were silent in LYNX. FL's default template
+// puts every new channel in cut group 1, cut by 1 ("cut itself", 0x84 = 0x10001); FL never cuts a wrapped plugin
+// with it (Surge XT VST3 renders the same with and without it, REA_rodada190x), but LYNX choked the plugin right after
+// each note on at the same sample, so every note ended as it started.
+namespace s190x
+{
+// a fake hosted plugin: records what the rack asks of it, in order
+struct CallSpy final : lynx::Instrument
+{
+    std::vector<std::string> calls;
+    void prepare (double) noexcept override {}
+    void noteOn (int, float) noexcept override { calls.push_back ("on"); }
+    void noteOff (int) noexcept override { calls.push_back ("off"); }
+    void allNotesOff() noexcept override { calls.push_back ("all off"); }
+    void cut() noexcept override { calls.push_back ("cut"); }
+    void render (float*, float*, int, float, float) noexcept override {}
+};
+} // namespace s190x
+
+TEST (s190x_cut_itself_never_chokes_a_hosted_plugin)
+{
+    using namespace lynx;
+    Song song;
+    song.mixer = Song::defaultMixer (2);
+    for (int k = 0; k < 2; ++k) // 0 = a hosted plugin, 1 = LYNX's synth: both "cut itself", as FL's template sets them
+    {
+        ChannelDef c;
+        c.instrument = k == 0 ? InstrumentKind::plugin : InstrumentKind::synth;
+        c.plugin.id = k == 0 ? "spy" : "";
+        c.cutGroup = c.cutBy = 1;
+        song.channels.push_back (c);
+    }
+    auto& p = song.patterns.emplace_back();
+    p.notes = { { 0, 1920, 0, 48 }, { 480, 240, 0, 60 }, { 960, 240, 1, 60 } }; // a long note, a short one over it
+
+    auto spy = std::make_shared<s190x::CallSpy>();
+    RackState::Factories f;
+    f.pluginInstruments = [spy] (const PluginRef&, double) { return std::shared_ptr<Instrument> (spy); };
+    const auto state = RackState::build (song, nullptr, 44100.0, f);
+    CHECK (state != nullptr);
+    if (state == nullptr)
+        return;
+    // the synth is still cut by its group (its own notes and the plugin's); the plugin is never a target
+    CHECK ((state->cutTargets[0] == std::vector<int> { 1 }));
+    CHECK ((state->cutTargets[1] == std::vector<int> { 1 }));
+
+    RackRenderer r;
+    r.prepare (44100.0, 256);
+    std::vector<float> l (256), rr (256);
+    const auto tps = ticksPerSample (song.bpm, 44100.0);
+    for (double tick = 0.0; tick < 1500.0; tick += 256 * tps)
+        r.process (state.get(), true, tick, 256, l.data(), rr.data());
+
+    // both notes reached the plugin, and nothing stopped them on the way (FL: the long note keeps sounding)
+    const auto& calls = spy->calls;
+    const auto first = std::find (calls.begin(), calls.end(), std::string ("on"));
+    CHECK (std::count (calls.begin(), calls.end(), std::string ("on")) == 2);
+    CHECK (std::count (first, calls.end(), std::string ("cut")) == 0);
+    CHECK (std::count (first, calls.end(), std::string ("all off")) == 0);
+    CHECK (std::count (first, calls.end(), std::string ("off")) == 1); // the short note's own end
+}

+ 1 - 0
tests/tests.cpp

@@ -17392,3 +17392,4 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Notes188gTests.inc"
 #include "Layer190bTests.inc"
 #include "Undo190bTests.inc"
+#include "Surge190xTests.inc"