فهرست منبع

Round 190tk checks: FL's automation timing (tests/AutoTime190tkTests.inc, --round190tktest / --selftest "round190tk")

- Core tests: the value held is the clip at the tick's end, changes on FL's tick starts (96 / 960 PPQ, 97 / 173 BPM and
  FL's ties, a clip at bar 2, a tempo change), the same samples whatever the device block, cuts only where a value
  changes (a held clip, a Hold jump), LYNX projects keep LYNX's timing, the .flp import keeps the PPQ, and the NewTick fix
  (Right Night feeling's "Sin Synth", with FL's demo).
- App check: FL 2026's own /R renders of round 190tk's DC probes (every change sample and held value checked), the PPQ
  through the .flp import and the LYNX project file.
- tools/testplugin/lynx_test_param_vst3.cpp: LYNX_TEST_PARAM_LOGBLOCKS logs every process call and setParamNormalized.

(cherry picked from commit 6109852e7ca38f5e3634918e1f2bc7cc100abe36)
Ka1-S 4 روز پیش
والد
کامیت
b656a0fbcb
5فایلهای تغییر یافته به همراه539 افزوده شده و 1 حذف شده
  1. 18 1
      src/Main.cpp
  2. 144 0
      src/Round190tkCheck.inc
  3. 348 0
      tests/AutoTime190tkTests.inc
  4. 1 0
      tests/tests.cpp
  5. 28 0
      tools/testplugin/lynx_test_param_vst3.cpp

+ 18 - 1
src/Main.cpp

@@ -2440,6 +2440,18 @@ public:
             quit();
             return;
         }
+        if (args.contains ("--round190tktest"))
+        {
+            // LYNX --round190tktest report.txt (round 190tk: FL's automation timing for imported FL projects against FL's
+            // renders, the PPQ through the project file; also in --selftest): src/Round190tkCheck.inc
+            juce::String log;
+            const auto i = args.indexOf ("--round190tktest");
+            const auto result = round190tkCheck (log);
+            juce::File (args[i + 1].unquoted()).replaceWithText (log + "round190tk=" + result + "\n");
+            setApplicationReturnValue (result == "OK" ? 0 : 1);
+            quit();
+            return;
+        }
         if (args.contains ("--round190titest"))
         {
             // LYNX --round190titest report.txt [shot prefix] (round 190ti: Slicex's pitch automation paths, the Playlist's Add key
@@ -11157,6 +11169,9 @@ private:
         // round 190ti: Slicex's pitch automation paths (FL 2026's), the Playlist's Add key marker (src/Round190tiCheck.inc)
         juce::String round190tiLog;
         const auto round190tiResult = round190tiCheck (round190tiLog);
+        // round 190tk: FL's automation timing for imported FL projects (src/Round190tkCheck.inc)
+        juce::String round190tkLog;
+        const auto round190tkResult = round190tkCheck (round190tkLog);
         // round 190sr: #350, #349, QUEUE 0.1.33 items 42 / 43 (src/SmallBugs190srCheck.inc)
         juce::String smallbugs190srLog;
         const auto smallbugs190srResult = smallBugs190srCheck (smallbugs190srLog);
@@ -12626,7 +12641,7 @@ private:
                         && sidechainResult == "OK" && lanesResult == "OK" && arrange190cgResult == "OK" && livescr190drResult == "OK" && livewf190efResult == "OK" && livewf190emResult == "OK" && trackclips190neResult == "OK" && tracker190nwResult == "OK" && tracker190obResult == "OK" && rackauto190ooResult == "OK" && tracker190omResult == "OK" && rackauto190owResult == "OK" && versionsResult == "OK" && pluginsOffResult == "OK" && missingFilesResult == "OK"
                         && midigen190fmResult == "OK" && clipenv190giResult == "OK" && beatslaw190gxResult == "OK" && warplaw190ikResult == "OK" && editorScale190heResult == "OK" && sfModBase190heResult == "OK" && trackauto190gzResult == "OK" && community190hqResult == "OK" && rollup030Result == "OK" && rollup031Result == "OK" && rollup031s2Result == "OK"
                         && keys190nuResult == "OK" && rollup031s3Result == "OK"
-                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && flParity190tcResult == "OK" && q1a190rwResult == "OK" && iox190rmResult == "OK" && issues190rtResult == "OK" && perf190rnResult == "OK" && perf190sbResult == "OK" && cachecheck190tgResult == "OK" && undo190spResult == "OK" && menuwindows190skResult == "OK" && issues330skResult == "OK" && audioedit190stResult == "OK" && drumsynth190syResult == "OK" && smallbugs190srResult == "OK" && quickwins190srResult == "OK" && batch292_190swResult == "OK" && round190teResult == "OK" && yannik190sqResult == "OK" && rea190taResult == "OK" && round190tiResult == "OK" && batch334svResult == "OK" && details190tdResult == "OK" && qa190rbResult == "OK" && bugs190rvResult == "OK" && q6190saResult == "OK" && issue325Result == "OK" && keysheet190sjResult == "OK" && details190tbResult == "OK" && notes190tjResult == "OK" && children190thResult == "OK" && stab190rpResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && playlistview190soResult == "OK" && custom190ssResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && nofl190rhResult == "OK" && downgrade0132Result == "OK" && autolinks190ovResult == "OK"
+                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && flParity190tcResult == "OK" && q1a190rwResult == "OK" && iox190rmResult == "OK" && issues190rtResult == "OK" && perf190rnResult == "OK" && perf190sbResult == "OK" && cachecheck190tgResult == "OK" && undo190spResult == "OK" && menuwindows190skResult == "OK" && issues330skResult == "OK" && audioedit190stResult == "OK" && drumsynth190syResult == "OK" && smallbugs190srResult == "OK" && quickwins190srResult == "OK" && batch292_190swResult == "OK" && round190teResult == "OK" && yannik190sqResult == "OK" && rea190taResult == "OK" && round190tiResult == "OK" && round190tkResult == "OK" && batch334svResult == "OK" && details190tdResult == "OK" && qa190rbResult == "OK" && bugs190rvResult == "OK" && q6190saResult == "OK" && issue325Result == "OK" && keysheet190sjResult == "OK" && details190tbResult == "OK" && notes190tjResult == "OK" && children190thResult == "OK" && stab190rpResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && playlistview190soResult == "OK" && custom190ssResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && nofl190rhResult == "OK" && downgrade0132Result == "OK" && autolinks190ovResult == "OK"
                         && trackstates190opResult == "OK" && rollup031s6Result == "OK" // (round 190op's item, reported but not counted in its branch: rollup 0.1.31 step 6)
                         && rollup031s7Result == "OK" && rollup031s8Result == "OK" && rollup032Result == "OK" && headerGearResult == "OK" && perTab259Result == "OK" && slots260Result == "OK" && hotfixPlacesResult == "OK" && startPageScrollResult.startsWith ("OK") // (round 190qf: slots260) (rollup 0.1.31 step 7, round 190pw; and the three rounds' items its branches reported but did not count:)
                         && slides190piResult == "OK" && automodes190paResult == "OK" && heldSteps190ozResult == "OK"
@@ -12768,6 +12783,7 @@ private:
                << "rea190ta=" << rea190taResult << (rea190taResult == "OK" ? juce::String() : " | " + rea190taLog.replace ("\n", "; ")) << "\n"
                << "details190td=" << details190tdResult << (details190tdResult == "OK" ? juce::String() : " | " + details190tdLog.replace ("\n", "; ")) << "\n"
                << "round190ti=" << round190tiResult << (round190tiResult == "OK" ? juce::String() : " | " + round190tiLog.replace ("\n", "; ")) << "\n"
+               << "round190tk=" << round190tkResult << (round190tkResult == "OK" ? juce::String() : " | " + round190tkLog.replace ("\n", "; ")) << "\n"
                << "smallbugs190sr=" << smallbugs190srResult << (smallbugs190srResult == "OK" ? juce::String() : " | " + smallbugs190srLog.replace ("\n", "; ")) << "\n"
                << "quickwins190sr=" << quickwins190srResult << (quickwins190srResult == "OK" ? juce::String() : " | " + quickwins190srLog.replace ("\n", "; ")) << "\n"
                << "audioedit190st=" << audioedit190stResult << (audioedit190stResult == "OK" ? juce::String() : " | " + audioedit190stLog.replace ("\n", "; ")) << "\n"
@@ -23232,6 +23248,7 @@ private:
 #include "Rea190taCheck.inc" // round 190ta: the 0.1.33 REA gap-hunt's small FL-exact fixes
 #include "Details190tdCheck.inc" // round 190td: undo names per layout (D2), Esc clears the selection first (D1), items 73-78
 #include "Round190tiCheck.inc" // round 190ti: Slicex's pitch automation paths, the Playlist's Add key marker
+#include "Round190tkCheck.inc" // round 190tk: FL's automation timing for imported FL projects
 #include "SmallBugs190srCheck.inc" // round 190sr: #350, #349, QUEUE 0.1.33 items 42 / 43
 #include "QuickWins190srCheck.inc" // round 190sr: the quick wins (#318 ...)
 #include "Batch292Check190sw.inc" // round 190sw: #292 routing cables, #322 macOS's menu bar, #289 the hardware outputs export

+ 144 - 0
src/Round190tkCheck.inc

@@ -0,0 +1,144 @@
+    // Round 190tk (QUEUE 0.1.33 item 92): FL's automation timing for imported FL projects (docs/analise/REA_rodada190tk.md).
+    // (1) The rack against FL 2026's own /R renders of round 190tk's probes (LYNX Test Param, a VST3 that outputs its
+    // parameter as DC): the samples where the value changed and the value held (the clip one FL tick on). (2) The PPQ an
+    // .flp import keeps, through the LYNX project file and back; a LYNX project without the key keeps LYNX's timing.
+    // No window, no message loop. Included in the app class of Main.cpp; --round190tktest <report> and --selftest
+    // "round190tk".
+    juce::String round190tkCheck (juce::String& log)
+    {
+        using namespace lynx;
+        juce::String result = "OK";
+        const auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
+            log << (ok ? "ok   " : "FAIL ") << what << (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()) << "\n";
+            if (! ok && result == "OK")
+                result = "ERROR " + what;
+        };
+        // a Master fader automated by a ramp 0 → 1 over four bars from `clipBeat` (FL's probes: the plugin's parameter)
+        const auto probe = [] (int flPpq, double bpm, double clipBeat) {
+            auto song = Song::makeDefault();
+            song.mode = PlayMode::song;
+            song.bpm = bpm;
+            song.flAutomationPpq = flPpq;
+            song.channels.clear();
+            song.channels.emplace_back().name = "Probe";
+            song.playlist.clear();
+            song.patterns.clear();
+            song.automations.clear();
+            song.mixer = Song::defaultMixer (2);
+            Automation a;
+            a.name = "Ramp";
+            a.target = { AutomationTargetKind::mixerVolume, 0 };
+            a.points = { { 0, 0.0f, 0.0f }, { 16 * ppq, 1.0f, 0.0f } };
+            song.automations.push_back (a);
+            Clip c;
+            c.kind = ClipKind::automation;
+            c.automation = 0;
+            c.track = 1;
+            c.start = (std::int64_t) std::llround (clipBeat * ppq);
+            c.length = 16 * ppq;
+            song.playlist.push_back (c);
+            song.patterns.emplace_back().lengthTicks = 4 * ppq;
+            Clip pad;
+            pad.kind = ClipKind::pattern;
+            pad.pattern = 0;
+            pad.track = 3;
+            pad.length = 256 * ppq;
+            song.playlist.push_back (pad);
+            return song;
+        };
+        // the value at each sample from the song's start (blocks of one sample), as the export plays it
+        const auto play = [] (const Song& song, int samples) {
+            auto state = RackState::build (song, nullptr, 44100.0);
+            RackRenderer renderer;
+            renderer.prepare (44100.0, 64);
+            float l = 0.0f, r = 0.0f;
+            std::vector<float> out;
+            out.reserve ((std::size_t) samples);
+            auto tick = 0.0;
+            for (int s = 0; s < samples; ++s)
+            {
+                renderer.process (state.get(), true, tick, 1, &l, &r);
+                out.push_back (renderer.automationValueForCheck (0));
+                tick += ticksPerSample (song.bpm, 44100.0);
+            }
+            return out;
+        };
+        const auto changesOf = [] (const std::vector<float>& v) {
+            std::vector<int> c;
+            for (std::size_t i = 1; i < v.size(); ++i)
+                if (! (v[i] == v[i - 1]) && ! (std::isnan (v[i]) && std::isnan (v[i - 1])))
+                    c.push_back ((int) i);
+            return c;
+        };
+        const auto list = [] (const std::vector<int>& c, std::size_t n) {
+            juce::String s;
+            for (std::size_t i = 0; i < std::min (n, c.size()); ++i)
+                s << (i > 0 ? " " : "") << c[i];
+            return s;
+        };
+        // FL's renders (round 190tk, ana/ramps.txt): the first eight changes, a tie FL's running sum decides, and the value
+        // held after the first change (the clip at the end of FL's second tick)
+        struct Case
+        {
+            const char* name;
+            int ppq;
+            double bpm, clipBeat;
+            int samples;
+            std::vector<int> firstChanges;
+            int tieSample; // a change FL made on this sample (0: none checked)
+        };
+        const std::vector<Case> cases {
+            { "120 BPM, 96 PPQ", 96, 120.0, 0.0, 2000, { 230, 459, 689, 919, 1148, 1378, 1608, 1838 }, 1838 },
+            { "97 BPM, 96 PPQ", 96, 97.0, 0.0, 28000, { 284, 568, 852, 1137, 1421, 1705, 1989, 2273 }, 27563 },
+            { "173 BPM, 96 PPQ", 96, 173.0, 0.0, 2000, { 159, 319, 478, 637, 797, 956, 1115, 1275 }, 0 },
+            { "120 BPM, 960 PPQ", 960, 120.0, 0.0, 400, { 23, 46, 69, 92, 115, 138, 161, 184 }, 0 },
+            { "60 BPM, 960 PPQ", 960, 60.0, 0.0, 800, { 46, 92, 138, 184, 230, 276, 322, 368 }, 0 },
+            { "clip at bar 2, 120 BPM, 96 PPQ", 96, 120.0, 4.0, 89000, { 88200, 88430, 88659, 88889 }, 0 },
+        };
+        for (const auto& c : cases)
+        {
+            const auto v = play (probe (c.ppq, c.bpm, c.clipBeat), c.samples);
+            const auto ch = changesOf (v);
+            const auto first = ch.size() >= c.firstChanges.size() && std::equal (c.firstChanges.begin(), c.firstChanges.end(), ch.begin());
+            check (juce::String ("FL's change samples, ") + c.name, first, list (ch, c.firstChanges.size()));
+            if (c.tieSample > 0)
+                check (juce::String ("FL's tie, ") + c.name, std::find (ch.begin(), ch.end(), c.tieSample) != ch.end()
+                                                                && std::find (ch.begin(), ch.end(), c.tieSample - 1) == ch.end(), juce::String (c.tieSample));
+            // the value held from the first change: the clip at the end of the clip's second FL tick (2 ticks of 16 beats)
+            const auto T = (double) ppq / c.ppq;
+            const auto held = ch.empty() ? -1.0f : v[(std::size_t) ch[0]];
+            const auto want = (float) ((c.clipBeat > 0.0 ? 1.0 : 2.0) * T / (16.0 * ppq));
+            check (juce::String ("FL's held value, ") + c.name, std::abs (held - want) < 1.0e-6f, juce::String (held, 7) + " / " + juce::String (want, 7));
+        }
+        // a LYNX project (no key): LYNX's own timing, a value per 128-sample piece
+        {
+            const auto v = play (probe (0, 120.0, 0.0), 1000);
+            const auto ch = changesOf (v);
+            check ("a LYNX project keeps LYNX's timing", ! ch.empty() && ch.front() == 128 && ch.size() > 1 && ch[1] == 256, list (ch, 4));
+        }
+
+        // (2) the PPQ through an .flp import and the LYNX project file
+        {
+            flpexport::Options o;
+            o.ppq = 960;
+            flpexport::Report report;
+            const auto bytes = flpexport::exportFlp (probe (0, 120.0, 0.0), o, report);
+            FlpImportOptions io;
+            io.fileExists = [] (const std::string&) { return false; };
+            const auto imported = importFlp (flp::parseProject (bytes), io);
+            check ("an .flp import keeps its PPQ", imported.flAutomationPpq == 960, juce::String (imported.flAutomationPpq));
+            juce::String error;
+            const auto json = ProjectFile::toJson (imported);
+            const auto back = ProjectFile::fromJson (json, error);
+            check ("the LYNX project file keeps it", back.has_value() && back->flAutomationPpq == 960 && json.contains ("\"flAutomationPpq\""), error);
+            const auto own = ProjectFile::toJson (Song::makeDefault());
+            const auto ownBack = ProjectFile::fromJson (own, error);
+            check ("a LYNX project writes no key and loads LYNX's timing", ! own.contains ("flAutomationPpq") && ownBack.has_value()
+                                                                              && ownBack->flAutomationPpq == 0);
+            auto seventyTwo = imported;
+            seventyTwo.flAutomationPpq = 72;
+            const auto back72 = ProjectFile::fromJson (ProjectFile::toJson (seventyTwo), error);
+            check ("a 72-PPQ project keeps 72", back72.has_value() && back72->flAutomationPpq == 72);
+        }
+        return result;
+    }

+ 348 - 0
tests/AutoTime190tkTests.inc

@@ -0,0 +1,348 @@
+// Round 190tk (QUEUE 0.1.33 item 92, owner decision: imported FL projects): FL's automation timing
+// (docs/analise/REA_rodada190tk.md). FL cuts its blocks at every tick of the project's PPQ (tick k starts at sample
+// rint(Σ samples per tick)) and, at a tick's start, reads each playing clip one tick on: the target holds the clip's
+// value at the END of the tick for the whole tick. A song with Song::flAutomationPpq > 0 (an imported .flp) plays so;
+// LYNX's own projects (0) keep LYNX's timing. The FL render cases (FL 2026 /R renders of DC probes) are in the app's
+// --selftest "round190tk" (src/Round190tkCheck.inc) too.
+
+#include <filesystem>
+#include <fstream>
+
+#include "core/FlpExport.h"
+#include "core/ThreeOsc.h"
+
+namespace at190tk
+{
+// A Master fader automated by automation 0 (slot 0 shows what it plays): a clip from `clipBeat` with `points`, a long
+// empty pattern clip so the song never wraps
+struct Rig
+{
+    lynx::Song song;
+    Rig (int flPpq, double bpm, std::vector<lynx::AutomationPoint> points, double clipBeat = 0.0, double clipBeats = 16.0)
+    {
+        song = lynx::Song::makeDefault();
+        song.mode = lynx::PlayMode::song;
+        song.bpm = bpm;
+        song.flAutomationPpq = flPpq;
+        song.channels.clear();
+        song.channels.emplace_back().name = "Tone";
+        song.playlist.clear();
+        song.automations.clear();
+        song.patterns.clear();
+        song.mixer = lynx::Song::defaultMixer (2);
+        lynx::Automation a;
+        a.name = "Ramp";
+        a.target = { lynx::AutomationTargetKind::mixerVolume, 0 };
+        a.points = points;
+        song.automations.push_back (a);
+        lynx::Clip c;
+        c.kind = lynx::ClipKind::automation;
+        c.automation = 0;
+        c.track = 1;
+        c.start = (std::int64_t) std::llround (clipBeat * lynx::ppq);
+        c.length = (std::int64_t) std::llround (clipBeats * lynx::ppq);
+        song.playlist.push_back (c);
+        song.patterns.emplace_back().lengthTicks = 4 * lynx::ppq;
+        lynx::Clip pad;
+        pad.kind = lynx::ClipKind::pattern;
+        pad.pattern = 0;
+        pad.track = 3;
+        pad.length = 256 * lynx::ppq;
+        song.playlist.push_back (pad);
+    }
+    // slot 0's value at each of the first `samples` samples, played from the song's start in blocks of `block` samples:
+    // with blocks of more than one sample, the value of each block's last sample (the last piece's) stands for the block
+    std::vector<float> play (int samples, int block = 1, bool followTempo = false) const
+    {
+        auto state = lynx::RackState::build (song, nullptr, 44100.0);
+        lynx::RackRenderer renderer;
+        renderer.prepare (44100.0, std::max (64, block));
+        std::vector<float> l ((std::size_t) block), r ((std::size_t) block), out;
+        out.reserve ((std::size_t) samples);
+        double tick = 0.0;
+        for (int done = 0; done < samples; done += block)
+        {
+            const auto n = std::min (block, samples - done);
+            renderer.process (state.get(), true, tick, n, l.data(), r.data());
+            for (int i = 0; i < n; ++i)
+                out.push_back (i == n - 1 ? renderer.automationValueForCheck (0) : std::numeric_limits<float>::quiet_NaN());
+            tick += n * lynx::ticksPerSample (followTempo ? renderer.currentBpm() : song.bpm, 44100.0);
+        }
+        return out;
+    }
+};
+
+// FL's tick starts: rint (to even) of the running sum of samples per tick
+std::vector<std::int64_t> flStarts (double bpm, int flPpq, int count)
+{
+    std::vector<std::int64_t> s;
+    const auto spt = 44100.0 * 60.0 / (bpm * flPpq);
+    auto acc = 0.0;
+    for (int k = 0; k < count; ++k)
+    {
+        s.push_back (std::llrint (acc));
+        acc += spt;
+    }
+    return s;
+}
+
+std::vector<int> changes (const std::vector<float>& v)
+{
+    std::vector<int> c;
+    for (std::size_t i = 1; i < v.size(); ++i)
+        if (! (v[i] == v[i - 1]) && ! (std::isnan (v[i]) && std::isnan (v[i - 1])))
+            c.push_back ((int) i);
+    return c;
+}
+
+// every sample holds the clip's value at the end of its FL tick (FL's tick starts from flStarts); NaN before the clip
+bool holdsTickEnds (const std::vector<float>& v, double bpm, int flPpq, double clipBeat, double clipBeats)
+{
+    const auto T = (double) lynx::ppq / flPpq;
+    const auto starts = flStarts (bpm, flPpq, (int) (v.size() / (44100.0 * 60.0 / (bpm * flPpq))) + 4);
+    std::size_t k = 0;
+    const auto clipStart = clipBeat * lynx::ppq, len = clipBeats * lynx::ppq;
+    for (std::size_t s = 0; s < v.size(); ++s)
+    {
+        while (k + 1 < starts.size() && starts[k + 1] <= (std::int64_t) s)
+            ++k;
+        const auto selected = (double) k * T >= clipStart - 1.0e-6;
+        const auto expected = selected ? (float) std::clamp (((double) (k + 1) * T - clipStart) / len, 0.0, 1.0) : std::numeric_limits<float>::quiet_NaN();
+        if (selected ? std::abs (v[s] - expected) > 1.0e-5f : ! std::isnan (v[s]))
+            return false;
+    }
+    return true;
+}
+
+// a blocked play (each block's last sample) agrees with the sample-by-sample one
+bool sameAtBlockEnds (const std::vector<float>& bySample, const std::vector<float>& blocked, int block)
+{
+    for (std::size_t s = (std::size_t) block - 1; s < blocked.size(); s += (std::size_t) block)
+        if (! (bySample[s] == blocked[s]) && ! (std::isnan (bySample[s]) && std::isnan (blocked[s])))
+            return false;
+    return true;
+}
+
+const std::vector<lynx::AutomationPoint> ramp { { 0, 0.0f, 0.0f }, { 16 * lynx::ppq, 1.0f, 0.0f } };
+} // namespace at190tk
+
+// The value FL hands during a tick is the clip's at the tick's end, from the tick's first sample (96 PPQ, 120 BPM: FL's
+// render changed at samples 230, 459, 689, 919, 1148, 1378, 1608, 1838 — 1837.5 rounded to even — and so on)
+TEST (autotime190tk_value_is_the_clip_at_the_tick_end_96_ppq)
+{
+    using namespace at190tk;
+    const Rig rig (96, 120.0, ramp);
+    const auto v = rig.play (6000);
+    CHECK (holdsTickEnds (v, 120.0, 96, 0.0, 16.0));
+    const auto c = changes (v);
+    const std::vector<int> fl { 230, 459, 689, 919, 1148, 1378, 1608, 1838 };
+    CHECK (c.size() > fl.size() && std::equal (fl.begin(), fl.end(), c.begin()));
+    CHECK (std::abs (v[0] - 10.0f / (16.0f * lynx::ppq)) < 1.0e-6f); // (tick 0 already holds the clip one tick on)
+    // the same samples whatever the device block (the export grid)
+    CHECK (sameAtBlockEnds (v, rig.play (6000, 333), 333) && sameAtBlockEnds (v, rig.play (6000, 64), 64));
+}
+
+TEST (autotime190tk_value_is_the_clip_at_the_tick_end_960_ppq)
+{
+    using namespace at190tk;
+    const Rig rig (960, 120.0, ramp);
+    const auto v = rig.play (3000);
+    CHECK (holdsTickEnds (v, 120.0, 960, 0.0, 16.0));
+    const auto c = changes (v);
+    const std::vector<int> fl { 23, 46, 69, 92, 115, 138, 161, 184 }; // (FL's render, 960 PPQ)
+    CHECK (c.size() > fl.size() && std::equal (fl.begin(), fl.end(), c.begin()));
+}
+
+// Other tempos: FL's running sum decides the ties (97 BPM: tick 97 at 27562.5 → FL's 27563)
+TEST (autotime190tk_tempos_and_fl_tick_ties)
+{
+    using namespace at190tk;
+    {
+        const Rig rig (96, 97.0, ramp);
+        const auto v = rig.play (28000, 1);
+        CHECK (holdsTickEnds (v, 97.0, 96, 0.0, 16.0));
+        const auto c = changes (v);
+        const std::vector<int> fl { 284, 568, 852, 1137, 1421, 1705, 1989, 2273 };
+        CHECK (c.size() > fl.size() && std::equal (fl.begin(), fl.end(), c.begin()));
+        CHECK (std::find (c.begin(), c.end(), 27563) != c.end() && std::find (c.begin(), c.end(), 27562) == c.end());
+    }
+    {
+        const Rig rig (96, 173.0, ramp);
+        const auto v = rig.play (4000);
+        CHECK (holdsTickEnds (v, 173.0, 96, 0.0, 16.0) && sameAtBlockEnds (v, rig.play (4000, 7), 7));
+        const std::vector<int> fl { 159, 319, 478, 637, 797, 956, 1115, 1275 };
+        const auto c = changes (v);
+        CHECK (c.size() > fl.size() && std::equal (fl.begin(), fl.end(), c.begin()));
+    }
+    // a clip that starts at bar 2: nothing before (the control's own value), FL's first change at sample 88200 = tick 384
+    {
+        const Rig rig (96, 120.0, ramp, 4.0);
+        const auto v = rig.play (89000);
+        CHECK (std::isnan (v[88199]) && std::abs (v[88200] - 10.0f / (16.0f * lynx::ppq)) < 1.0e-6f);
+        CHECK (holdsTickEnds (v, 120.0, 96, 4.0, 16.0) && sameAtBlockEnds (v, rig.play (89000, 256), 256));
+    }
+}
+
+// A tempo that moves (a tempo map): the value still changes on FL's ticks of the song position (the sample nearest
+// each tick) and holds the clip at the tick's end
+TEST (autotime190tk_tempo_change)
+{
+    using namespace at190tk;
+    Rig rig (96, 120.0, ramp);
+    lynx::Automation tempo;
+    tempo.name = "Tempo";
+    tempo.target = { lynx::AutomationTargetKind::tempo, 0 };
+    tempo.points = { { 0, lynx::valueFromTempo (120.0), 0.0f }, { 2 * lynx::ppq, lynx::valueFromTempo (120.0), 0.0f },
+                     { 2 * lynx::ppq, lynx::valueFromTempo (150.0), 0.0f }, { 16 * lynx::ppq, lynx::valueFromTempo (150.0), 0.0f } };
+    rig.song.automations.push_back (tempo);
+    lynx::Clip c;
+    c.kind = lynx::ClipKind::automation;
+    c.automation = 1;
+    c.track = 2;
+    c.length = 16 * lynx::ppq;
+    rig.song.playlist.push_back (c);
+    // the transport, sample by sample as the engine moves it: each sample's song position, then its FL tick
+    auto renderState = lynx::RackState::build (rig.song, nullptr, 44100.0);
+    CHECK (renderState->tempoMap);
+    lynx::RackRenderer renderer;
+    renderer.prepare (44100.0, 64);
+    std::vector<float> l (16), r (16);
+    double tick = 0.0;
+    auto ok = true, faster = false;
+    for (int sample = 0; sample < 200000 && ok; ++sample)
+    {
+        renderer.process (renderState.get(), true, tick, 1, l.data(), r.data());
+        const auto tps = lynx::ticksPerSample (renderer.currentBpm(), 44100.0); // (the block's tempo)
+        const auto k = std::floor ((tick + 0.5 * tps) / 10.0 + 1.0e-9);
+        const auto expected = (float) std::clamp ((k + 1.0) * 10.0 / (16.0 * lynx::ppq), 0.0, 1.0);
+        ok = std::abs (renderer.automationValueForCheck (0) - expected) < 1.0e-5f;
+        faster = faster || renderer.currentBpm() > 140.0;
+        tick += tps;
+        if (tick > 3 * lynx::ppq)
+            break;
+    }
+    CHECK (ok && faster);
+}
+
+// Cuts only where a value may change: a held clip cuts at its start and end alone; a LYNX project has no FL ticks
+TEST (autotime190tk_cuts_only_where_a_value_changes)
+{
+    using namespace at190tk;
+    {
+        const Rig held (96, 120.0, { { 0, 0.3f, 0.0f }, { 16 * lynx::ppq, 0.3f, 0.0f } }, 2.0, 4.0);
+        const auto state = lynx::RackState::build (held.song, nullptr, 44100.0);
+        CHECK (state->flTick == 10.0 && state->flPpq == 96);
+        // clip from tick 1920 to 5760 = FL ticks 192 … 576
+        const std::vector<std::pair<std::int64_t, std::int64_t>> want { { 191, 193 }, { 575, 577 } };
+        CHECK (state->flChangeTicks == want);
+        const auto v = held.play (90000);
+        CHECK (changes (v).size() == 1 && changes (v)[0] == 44100); // (NaN → 0.3 at the clip's first tick, then nothing)
+    }
+    {
+        // a Hold segment: only its jump (FL tick 384) between the clip's start and end
+        lynx::AutomationPoint first { 0, 0.2f, 0.0f };
+        first.mode = lynx::flcurve::hold;
+        const Rig stepped (96, 120.0, { first, { 4 * lynx::ppq, 0.8f, 0.0f }, { 8 * lynx::ppq, 0.8f, 0.0f } }, 0.0, 8.0);
+        const auto state = lynx::RackState::build (stepped.song, nullptr, 44100.0);
+        const std::vector<std::pair<std::int64_t, std::int64_t>> want { { -1, 1 }, { 383, 385 }, { 767, 769 } };
+        CHECK (state->flChangeTicks == want);
+        const auto v = stepped.play (95000);
+        const auto c = changes (v);
+        // FL: tick 383 holds the clip read at tick 384 (the jump's 0.8), from sample rint(383 · 229.6875) = 87970
+        CHECK (c.size() == 1 && c[0] == 87970 && std::abs (v[0] - 0.2f) < 1.0e-6f && std::abs (v[87970] - 0.8f) < 1.0e-6f);
+    }
+    {
+        const Rig ramped (96, 120.0, ramp, 0.0, 4.0);
+        const auto state = lynx::RackState::build (ramped.song, nullptr, 44100.0);
+        CHECK (! state->flChangeTicks.empty() && state->flChangeTicks.front().first <= 0 && state->flChangeTicks.back().second >= 384);
+    }
+    {
+        const Rig lynxOwn (0, 120.0, ramp);
+        const auto state = lynx::RackState::build (lynxOwn.song, nullptr, 44100.0);
+        CHECK (state->flTick == 0.0 && state->flChangeTicks.empty());
+    }
+}
+
+// LYNX's own projects keep LYNX's timing: the clip at each 128-sample piece's first sample
+TEST (autotime190tk_lynx_projects_keep_lynx_timing)
+{
+    using namespace at190tk;
+    const Rig rig (0, 120.0, ramp);
+    const auto v = rig.play (1024);
+    const auto c = changes (v);
+    CHECK (! c.empty() && c.front() == 128 && v[0] < 1.0e-6f);
+    for (const auto s : c)
+        CHECK (s % 128 == 0);
+}
+
+// The .flp import keeps the file's PPQ for the timing; the legacy 16 is FL's default (96)
+TEST (autotime190tk_flp_import_keeps_the_ppq)
+{
+    using namespace lynx;
+    const at190tk::Rig rig (0, 120.0, at190tk::ramp);
+    for (const int p : { 96, 960 })
+    {
+        flpexport::Options o;
+        o.ppq = p;
+        flpexport::Report report;
+        const auto bytes = flpexport::exportFlp (rig.song, o, report);
+        FlpImportOptions io;
+        io.fileExists = [] (const std::string&) { return false; };
+        const auto back = importFlp (flp::parseProject (bytes), io);
+        CHECK (back.flAutomationPpq == p);
+    }
+}
+
+// The engines that run FL's ticks themselves (3x Osc, DX10, BeepMap, Granulizer): a render call that starts on the
+// sample right after a tick it never reached runs that tick's NewTick. Before, calls cut on FL's ticks lost every tick:
+// a released voice never ended (Right Night feeling's "Sin Synth", 72 PPQ: still sounding after 2960 such calls; now
+// silent after 21, as after 29 plain calls). With FL's demo (when the FL folder is given).
+TEST (autotime190tk_engines_run_the_tick_a_call_starts_just_after)
+{
+    using namespace lynx;
+    if (realFlpDir.empty())
+        return;
+    const auto demos = std::filesystem::path (realFlpDir) / "Data" / "Demo projects";
+    const auto dir = std::filesystem::exists (demos) ? demos : std::filesystem::path (realFlpDir) / "Demo projects";
+    const auto path = dir / "Demo songs" / "Atthar Feat Mehran Abbasi & Elise Chantelle - Right Night feeling.flp";
+    if (! std::filesystem::exists (path))
+        return;
+    std::ifstream in (path, std::ios::binary);
+    const auto song = importFlp (flp::parseProject (std::vector<std::uint8_t> ((std::istreambuf_iterator<char> (in)), {})));
+    const ChannelDef* sin = nullptr;
+    for (const auto& c : song.channels)
+        if (c.name == "Sin Synth" && c.instrument == InstrumentKind::threeosc)
+            sin = &c;
+    CHECK (sin != nullptr && song.flAutomationPpq == 72);
+    if (sin == nullptr)
+        return;
+    // calls of 300 samples (an FL tick is 350 at 105 BPM, 72 PPQ), each starting 0.3 samples after a tick (`onTicks`), or
+    // plain calls of 256: how many calls after the note's end until the voice has ended (3000: never)
+    const auto release = [sin] (bool onTicks) {
+        auto inst = makeThreeOscInstrument();
+        inst->prepare (44100.0);
+        inst->configure (*sin, 105.0);
+        std::vector<float> l (512), r (512);
+        const auto tps = ticksPerSample (105.0, 44100.0);
+        const auto T = 960.0 / 72.0;
+        auto t = 0.0;
+        const auto call = [&] (int k) {
+            inst->setSongPosition (onTicks ? k * T + 0.3 * tps : t);
+            inst->render (l.data(), r.data(), onTicks ? 300 : 256, 1.0f, 1.0f);
+            t += 256 * tps;
+        };
+        call (0);
+        inst->noteOn (71, 0.8f);
+        for (int k = 1; k < 40; ++k)
+            call (k);
+        if (inst->idle())
+            return -1;
+        inst->noteOff (71);
+        int k = 40;
+        for (; k < 3040 && ! inst->idle(); ++k)
+            call (k);
+        return k - 40;
+    };
+    const auto onTicks = release (true), plain = release (false);
+    CHECK (onTicks > 0 && onTicks < 100 && plain > 0 && plain < 100);
+}

+ 1 - 0
tests/tests.cpp

@@ -18251,3 +18251,4 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Latency356teTests.inc" // round 190te (0.1.33, issue #356): effect slots told the song position of their own audio (LYNX extra)
 #include "CacheCheck190tgTests.inc" // round 190tg (0.1.33, QUEUE item 85): the disk caches' integrity check (core/CacheCheck.h)
 #include "Notes358_190tjTests.inc" // round 190tj (issue #358): the Notes window's texts (core/ItemNotes.h)
+#include "AutoTime190tkTests.inc" // round 190tk (0.1.33, QUEUE item 92): FL's automation timing for imported FL projects; the NewTick fix

+ 28 - 0
tools/testplugin/lynx_test_param_vst3.cpp

@@ -3,6 +3,9 @@
 // IParamValueQueue at the point's sample offset. A host that sends a step of the automation at its sample shows the
 // step at that sample in the output; one that sends a value per block shows it at the block's start. With the
 // environment variable LYNX_TEST_PARAM_LOG = a file path it appends one line per point received ("P <offset> <value>").
+// With LYNX_TEST_PARAM_LOGBLOCKS set as well (round 190tk: how a host cuts its blocks and when it sends automation) it also
+// logs every process call ("B <numSamples> <projectTimeSamples> <projectTimeMusic> <tempo>", -1 for what the host did not
+// give) and every IEditController::setParamNormalized ("S <value>").
 // Built only against the VST3 SDK's pluginterfaces (no SDK helper classes), like lynx_test_crash_vst3.cpp:
 //   V=<JUCE>/modules/juce_audio_processors/format_types/VST3_SDK
 //   Linux:   B="LYNX Test Param.vst3/Contents/x86_64-linux"; mkdir -p "$B"
@@ -19,6 +22,7 @@
 #include "pluginterfaces/vst/ivstcomponent.h"
 #include "pluginterfaces/vst/ivsteditcontroller.h"
 #include "pluginterfaces/vst/ivstparameterchanges.h"
+#include "pluginterfaces/vst/ivstprocesscontext.h"
 #include "pluginterfaces/gui/iplugview.h"
 
 #include <atomic>
@@ -63,6 +67,19 @@ FILE* logFile()
     return f;
 }
 
+bool logBlocks()
+{
+    static const bool on = [] {
+#if defined(_WIN32)
+        char v[8] {};
+        return GetEnvironmentVariableA ("LYNX_TEST_PARAM_LOGBLOCKS", v, sizeof (v)) > 0;
+#else
+        return std::getenv ("LYNX_TEST_PARAM_LOGBLOCKS") != nullptr;
+#endif
+    }();
+    return on;
+}
+
 class TestParam final : public IComponent, public IAudioProcessor, public IEditController
 {
 public:
@@ -160,6 +177,14 @@ public:
         int32 offsets[64];
         double values[64];
         int32 points = 0;
+        if (logBlocks())
+            if (FILE* f = logFile())
+            {
+                const auto* c = data.processContext;
+                std::fprintf (f, "B %d %lld %.6f %.3f\n", (int) data.numSamples, c != nullptr ? (long long) c->projectTimeSamples : -1LL,
+                              c != nullptr && (c->state & ProcessContext::kProjectTimeMusicValid) != 0 ? c->projectTimeMusic : -1.0,
+                              c != nullptr && (c->state & ProcessContext::kTempoValid) != 0 ? c->tempo : -1.0);
+            }
         if (auto* changes = data.inputParameterChanges)
             for (int32 i = 0; i < changes->getParameterCount(); ++i)
                 if (auto* queue = changes->getParameterData (i); queue != nullptr && queue->getParameterId() == 0)
@@ -225,6 +250,9 @@ public:
     {
         if (id == 0)
             controllerValue = v;
+        if (logBlocks())
+            if (FILE* f = logFile())
+                std::fprintf (f, "S %.6f\n", v);
         return kResultOk;
     }
     tresult PLUGIN_API setComponentHandler (IComponentHandler*) override { return kResultOk; }