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

Issue #258: regression checks that a cloned channel's own automation clip drives its sound (Transistor Bass, every cloned native, the app engine with render-ahead off / on; --issue258test, --selftest issue258); not reproduced, no engine change (round 190pv)

Ka1-S 1 неделя назад
Родитель
Сommit
cf4ecbfcaf
4 измененных файлов с 468 добавлено и 1 удалено
  1. 239 0
      src/Issue258Test.inc
  2. 17 1
      src/Main.cpp
  3. 211 0
      tests/Issue258_190pvTests.inc
  4. 1 0
      tests/tests.cpp

+ 239 - 0
src/Issue258Test.inc

@@ -0,0 +1,239 @@
+    // Round 190pv (issue #258, "Transistor bass duplicated instrument automation doesn't work"): the reporter's steps
+    // through the app's own engine (AudioEngine: edits published as the UI publishes them, the device callback driven by
+    // hand, the worker pool, render-ahead on or off). A channel plays a pattern; it is cloned (Channel rack › Clone: the
+    // clone right below, selected); a new pattern plays the clone; an automation clip on one of the clone's parameters
+    // ramps over the pattern; the Transistor Bass page's follow timer (ui/ChannelSettings.cpp) runs between the blocks.
+    // The clone's sound must follow its clip: the clip ramping up and ramping down must render differently, and so must
+    // the original under the same steps (the reference). Included in the app class (--issue258test, --selftest).
+    struct Issue258Case
+    {
+        juce::String name;
+        lynx::ChannelDef channel;
+        int key = 60, param = 0;
+    };
+
+    // the cases this PC can make: Transistor Bass (FL's "Empty" preset, program A6 = key 81 shown, its sequence gated)
+    // when FL Studio is here, and LYNX Synth's cutoff always
+    static std::vector<Issue258Case> issue258Cases()
+    {
+        std::vector<Issue258Case> out;
+        const auto& fl = lynx::flStudioAccess();
+        if (! fl.roots.data.empty())
+        {
+            const auto empty = juce::File (juce::String::fromUTF8 (fl.roots.data.c_str()))
+                                   .getChildFile ("Patches/Plugin presets/Generators/Transistor Bass/Empty.fst");
+            if (auto tb = lynx::natives::channelFromPresetFile (lynx::InstrumentKind::transistorbass, empty.getFullPathName().toStdString(), fl))
+            {
+                lynx::transistorBassSelectProgram (tb->pluginState, 81);
+                for (int i = 0; i < lynx::tbseq::steps; ++i)
+                    lynx::modelparams::setRawValue (*tb, lynx::tbseq::firstStep + 5 * i + 2, 1.0f);
+                out.push_back ({ "Transistor Bass cutoff", *tb, 81, 2 });
+            }
+        }
+        lynx::ChannelDef synth;
+        synth.name = "Synth";
+        synth.instrument = lynx::InstrumentKind::synth;
+        out.push_back ({ "LYNX Synth cutoff", synth, 60, lynx::synthparam::target (lynx::synthparam::cutoff) });
+        return out;
+    }
+
+    // one run of the steps: the clip on the clone (or, `onOriginal`, the same steps with the original playing the new
+    // pattern and automated), ramping `from` → `to`; the output of the new pattern's two bars (left channel)
+    static std::vector<float> issue258Run (const Issue258Case& c, bool renderAhead, bool onOriginal, float from, float to)
+    {
+        struct Device final : juce::AudioIODevice
+        {
+            Device() : juce::AudioIODevice ("issue258", "test") {}
+            juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
+            juce::StringArray getInputChannelNames() override { return {}; }
+            juce::Array<double> getAvailableSampleRates() override { return { 48000.0 }; }
+            juce::Array<int> getAvailableBufferSizes() override { return { 512 }; }
+            int getDefaultBufferSize() override { return 512; }
+            juce::String open (const juce::BigInteger&, const juce::BigInteger&, double, int) override { return {}; }
+            void close() override {}
+            bool isOpen() override { return true; }
+            void start (juce::AudioIODeviceCallback*) override {}
+            void stop() override {}
+            bool isPlaying() override { return true; }
+            juce::String getLastError() override { return {}; }
+            int getCurrentBufferSizeSamples() override { return 512; }
+            double getCurrentSampleRate() override { return 48000.0; }
+            int getCurrentBitDepth() override { return 32; }
+            juce::BigInteger getActiveOutputChannels() const override
+            {
+                juce::BigInteger b;
+                b.setRange (0, 2, true);
+                return b;
+            }
+            juce::BigInteger getActiveInputChannels() const override { return {}; }
+            int getOutputLatencyInSamples() override { return 0; }
+            int getInputLatencyInSamples() override { return 0; }
+        };
+        constexpr std::int64_t bar = 4 * lynx::ppq;
+        const auto wasAhead = lynx::renderAheadOption().load();
+        lynx::renderAheadOption().store (renderAhead);
+        Device device;
+        std::vector<float> out;
+        {
+            lynx::AudioEngine e (true, -1, false, true); // (the live engine's graph and workers; no device opened: driven by hand)
+            e.setRenderAheadAlways (renderAhead);
+            auto song = lynx::Song::makeDefault();
+            for (auto& p : song.patterns)
+                p.notes.clear();
+            song.playlist.clear();
+            song.mode = lynx::PlayMode::song;
+            auto channel = c.channel;
+            channel.mixerTrack = 1;
+            song.channels.push_back (channel);
+            const auto original = (int) song.channels.size() - 1;
+            if (song.patterns.empty())
+                song.patterns.emplace_back();
+            song.patterns[0].notes.push_back ({ 0, 2 * bar, original, c.key, 0.78f });
+            song.playlist.push_back ({ 0, 0, 0, 2 * bar, 0 }); // (pattern 1 at the start, track 1)
+            e.setSong (song);
+            e.setSelectedChannel (original);
+            auto& cb = e.deviceCallback();
+            cb.audioDeviceAboutToStart (&device);
+            std::vector<float> l (512), r (512);
+            float* outs[] = { l.data(), r.data() };
+            juce::AudioIODeviceCallbackContext context;
+            // the Transistor Bass page of the channel the clip drives, open: its 10 Hz timer follows the program the
+            // notes chose (followTransistorBassProgram)
+            int followed = original;
+            auto pageTimer = [&e, &followed] {
+                const auto& s = e.getSong();
+                if (followed < 0 || followed >= (int) s.channels.size() || s.channels[(std::size_t) followed].instrument != lynx::InstrumentKind::transistorbass)
+                    return;
+                const auto instrument = e.getChannelInstrument (followed);
+                const auto prog = lynx::transistorBassProgram (s.channels[(std::size_t) followed].pluginState);
+                const auto selected = instrument != nullptr ? instrument->selectedProgram() : -1;
+                if (selected < 0 || ! prog || prog->program == selected)
+                    return;
+                auto next = s.channels[(std::size_t) followed].pluginState;
+                if (lynx::transistorBassSelectProgram (next, selected))
+                    e.editSong ([followed, next] (lynx::Song& x) { x.channels[(std::size_t) followed].pluginState = next; }, false);
+            };
+            auto playBlocks = [&] (int blocks, std::vector<float>* into) {
+                for (int k = 0; k < blocks; ++k)
+                {
+                    cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+                    if (into != nullptr)
+                        into->insert (into->end(), l.begin(), l.end());
+                    if (k % 9 == 8) // (about 10 times a second)
+                        pageTimer();
+                    if (renderAhead && k % 2 == 0)
+                        std::this_thread::sleep_for (std::chrono::microseconds (3000)); // (the render-ahead thread gets ahead)
+                }
+            };
+            // 1. the original plays its pattern for a bar
+            e.stop();
+            e.seek (0.0);
+            cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+            e.play();
+            playBlocks (50, nullptr);
+            e.stop();
+            cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+            // 2. Clone (the Channel rack's cloneSelected: the clone right below, selected)
+            e.editSong ([original] (lynx::Song& s) { lynx::cloneChannel (s, original); });
+            const auto clone = original + 1;
+            e.setSelectedChannel (clone);
+            const auto player = onOriginal ? original : clone;
+            followed = player;
+            // 3. a new pattern whose note plays the clone (or the original), the first pattern moved later
+            e.editSong ([player, c, bar] (lynx::Song& s) {
+                s.patterns.emplace_back();
+                s.patterns.back().notes.push_back ({ 0, 2 * bar, player, c.key, 0.78f });
+                s.currentPattern = (int) s.patterns.size() - 1;
+                for (auto& clip : s.playlist)
+                    if (clip.kind == lynx::ClipKind::pattern && clip.pattern == 0)
+                        clip.start = 4 * bar;
+                lynx::Clip p;
+                p.kind = lynx::ClipKind::pattern;
+                p.pattern = (int) s.patterns.size() - 1;
+                p.track = 1;
+                p.start = 0;
+                p.length = 2 * bar;
+                s.playlist.push_back (p);
+            });
+            // (the note dragged up onto its key in the Piano roll: each key it passes is previewed on its channel)
+            for (int k = c.key - 4; k <= c.key; ++k)
+            {
+                e.sendLiveNote (player, k, 0.78f, true);
+                playBlocks (3, nullptr);
+                e.sendLiveNote (player, k, 0.0f, false);
+                playBlocks (1, nullptr);
+            }
+            playBlocks (10, nullptr);
+            // 4. right-click › Create automation clip on the knob (addAutomationClip), its points then drawn
+            e.editSong ([player, c, bar, from, to] (lynx::Song& s) {
+                lynx::Automation a;
+                a.name = "issue 258";
+                a.target = { lynx::AutomationTargetKind::channelParam, player, 0, c.param };
+                a.points = { { 0, from, 0.0f }, { 2 * bar, from, 0.0f } };
+                s.automations.push_back (a);
+                lynx::Clip clip;
+                clip.kind = lynx::ClipKind::automation;
+                clip.automation = (int) s.automations.size() - 1;
+                clip.track = 2;
+                clip.start = 0;
+                clip.length = 2 * bar;
+                s.playlist.push_back (clip);
+            });
+            e.editSong ([from, to, bar] (lynx::Song& s) {
+                s.automations.back().points = { { 0, from, 0.0f }, { bar, 0.5f * (from + to), 0.0f }, { 2 * bar, to, 0.0f } };
+            });
+            // 5. played from the start
+            e.seek (0.0);
+            cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+            e.play();
+            playBlocks ((int) (2 * 4 * 60.0 / e.getSong().bpm * 48000.0 / 512.0), &out);
+            e.stop();
+            cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+            cb.audioDeviceStopped();
+        }
+        lynx::renderAheadOption().store (wasAhead);
+        return out;
+    }
+
+    // "OK" or what failed; each case's levels go to `log`
+    static juce::String issue258Check (juce::String& log)
+    {
+        juce::String result = "OK";
+        auto peak = [] (const std::vector<float>& x) {
+            float m = 0.0f;
+            for (const auto v : x)
+                m = std::max (m, std::abs (v));
+            return m;
+        };
+        auto diff = [] (const std::vector<float>& a, const std::vector<float>& b) {
+            float m = 0.0f;
+            for (std::size_t i = 0; i < std::min (a.size(), b.size()); ++i)
+                m = std::max (m, std::abs (a[i] - b[i]));
+            return m;
+        };
+        for (const auto& c : issue258Cases())
+            for (const auto ahead : { false, true })
+            {
+                const auto cloneUp = issue258Run (c, ahead, false, 0.0f, 1.0f), cloneDown = issue258Run (c, ahead, false, 1.0f, 0.0f);
+                const auto origUp = issue258Run (c, ahead, true, 0.0f, 1.0f), origDown = issue258Run (c, ahead, true, 1.0f, 0.0f);
+                const auto cloneMoves = diff (cloneUp, cloneDown), origMoves = diff (origUp, origDown);
+                log << c.name << (ahead ? ", render ahead" : ", real time") << ": peak " << juce::String (peak (cloneUp), 4)
+                    << ", clone up vs down " << juce::String (cloneMoves, 5) << ", original up vs down " << juce::String (origMoves, 5) << "\n";
+                if (peak (cloneUp) < 1.0e-3f || peak (origUp) < 1.0e-3f)
+                    result = "ERROR " + c.name + ": silent";
+                else if (origMoves < 1.0e-3f * peak (origUp))
+                    result = "ERROR " + c.name + ": the original's automation does nothing";
+                else if (cloneMoves < 1.0e-3f * peak (cloneUp))
+                    result = "ERROR " + c.name + (ahead ? " (render ahead)" : "") + ": the clone's automation does nothing";
+            }
+        return result;
+    }
+
+    void runIssue258Test (const juce::String& reportPath)
+    {
+        juce::String log;
+        const auto result = issue258Check (log);
+        juce::File (reportPath).replaceWithText (log + "issue258=" + result + "\n");
+        setApplicationReturnValue (result == "OK" ? 0 : 1);
+        quit();
+    }

+ 17 - 1
src/Main.cpp

@@ -1955,6 +1955,15 @@ public:
             return;
         }
 
+        if (args.contains ("--issue258test"))
+        {
+            // LYNX --issue258test report.txt (round 190pv, issue #258): a cloned channel's own automation clip drives its
+            // sound, through the app's engine with render-ahead off and on (src/Issue258Test.inc; Transistor Bass needs
+            // FL Studio, LYNX_FL_INSTALL on Linux)
+            runIssue258Test (args[args.indexOf ("--issue258test") + 1].unquoted());
+            return;
+        }
+
         if (args.contains ("--hwheel254test"))
         {
             // LYNX --hwheel254test report.txt (round 190ou, issue #254): the horizontal wheel in the Playlist (three layouts),
@@ -9336,6 +9345,11 @@ private:
             lynx::windowplaces::fromVar ({});
         }
 
+        // round 190pv (issue #258): a cloned channel's own automation clip drives its sound (src/Issue258Test.inc: the app's
+        // engine, render-ahead off and on; Transistor Bass when FL Studio is here, LYNX Synth always)
+        juce::String issue258Log;
+        const auto issue258Result = issue258Check (issue258Log);
+
         // round 190ot (research190oe P5): the Simple layout's "Duck under..." and shared Echo send in .lynx (the duck's goal,
         // Amount, side input and level-0 route; the Echo send) and in the copies for 0.1.30 / 0.1.28: the same slot, side input,
         // route and sends (an ordinary Fruity Limiter there), one view line, none for a project without a duck
@@ -10563,7 +10577,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" && chordlane190pfResult == "OK" && autolinks190ovResult == "OK"
+                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && chordlane190pfResult == "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" && headerGearResult == "OK" // (rollup 0.1.31 step 7, and the three rounds' items its branches reported but did not count:)
                         && slides190piResult == "OK" && automodes190paResult == "OK" && heldSteps190ozResult == "OK"
@@ -10675,6 +10689,7 @@ private:
                << "headergear248=" << headerGearResult << "\n"
                << "simpleduck190ot=" << simpleDuck190otResult << "\n"
                << "tracks190pe=" << tracks190peResult << "\n"
+               << "issue258=" << issue258Result << "\n"
                << "autolinks190ov=" << autolinks190ovResult << "\n"
                << "sections190ol=" << sections190olResult << "\n"
                << "heldsteps190oz=" << heldSteps190ozResult << "\n"
@@ -20510,6 +20525,7 @@ private:
 #include "DetailsShot190mp.inc" // round 190mp
 #include "HWheel254Test.inc" // round 190ou: issue #254, the horizontal wheel
 #include "MultiEditor255Test.inc" // round 190ou: issue #255, several plugin editors in use
+#include "Issue258Test.inc" // round 190pv: issue #258, a cloned channel's own automation
 #include "DetailsShot190mr.inc" // round 190mr
 #include "DetailsShot190mv.inc" // round 190mv
 #include "DetailsShot190my.inc" // round 190my

+ 211 - 0
tests/Issue258_190pvTests.inc

@@ -0,0 +1,211 @@
+// Round 190pv (issue #258, "Transistor bass duplicated instrument automation doesn't work"): a cloned channel's own
+// automation clip drives its sound, as in FL (a clone is a channel of its own)
+
+#include "core/NativeEngines.h"
+#include "core/RackOps.h"
+#include "core/SynthParams.h"
+
+namespace issue258
+{
+using namespace lynx;
+
+// a Song-mode song with `channels`: one pattern whose note plays `noteChannel` at `key` for two bars (track 0) and, when
+// `param` >= 0, an automation clip of (target channel, param) ramping from `from` to `to` over those bars (track 1)
+inline Song song (const std::vector<ChannelDef>& channels, int noteChannel, int key, int target, int param, float from, float to)
+{
+    Song s;
+    s.bpm = 140.0;
+    s.mode = PlayMode::song;
+    s.channels = channels;
+    s.patterns.resize (1);
+    Note n;
+    n.channel = noteChannel;
+    n.key = key;
+    n.start = 0;
+    n.length = 8 * ppq;
+    n.velocity = 0.78f;
+    s.patterns[0].notes.push_back (n);
+    Clip p;
+    p.kind = ClipKind::pattern;
+    p.pattern = 0;
+    p.track = 0;
+    p.start = 0;
+    p.length = 8 * ppq;
+    s.playlist.push_back (p);
+    if (param >= 0)
+    {
+        Automation a;
+        a.name = "issue 258";
+        a.target = { AutomationTargetKind::channelParam, target, 0, param };
+        a.points = { { 0, from, 0.0f }, { 8 * ppq, to, 0.0f } };
+        s.automations.push_back (a);
+        Clip c;
+        c.kind = ClipKind::automation;
+        c.automation = 0;
+        c.track = 1;
+        c.start = 0;
+        c.length = 8 * ppq;
+        s.playlist.push_back (c);
+    }
+    s.playlistTracks.resize (4);
+    s.uniqueInstances(); // (as the engine's publish: the clone gets its own instance)
+    return s;
+}
+
+// the song through the renderer, `blocks` of 512 samples at 44.1 kHz (left channel)
+inline std::vector<float> render (const Song& s, int blocks)
+{
+    auto state = RackState::build (s, nullptr, 44100.0);
+    RackRenderer renderer;
+    renderer.prepare (44100.0, 512);
+    std::vector<float> l (512), r (512), all;
+    for (int b = 0; b < blocks; ++b)
+    {
+        std::fill (l.begin(), l.end(), 0.0f);
+        std::fill (r.begin(), r.end(), 0.0f);
+        renderer.process (state.get(), true, b * 512.0 * ticksPerSample (s.bpm, 44100.0), 512, l.data(), r.data());
+        all.insert (all.end(), l.begin(), l.end());
+    }
+    return all;
+}
+
+inline double peak (const std::vector<float>& x)
+{
+    double m = 0.0;
+    for (const auto v : x)
+        m = std::max (m, (double) std::fabs (v));
+    return m;
+}
+} // namespace issue258
+
+// the reporter's steps on Transistor Bass (FL's "Empty" preset: sequencer on, the editor follows the notes): the shown
+// program's sequence gated, the channel cloned, a note on the clone at the program's key, an automation clip on the
+// clone's cutoff: the clone's sound follows the clip, and matches the original under the same clip
+TEST (issue258_cloned_transistor_bass_follows_its_automation)
+{
+    using namespace lynx;
+    using namespace issue258;
+    auto c = tb169g2::channel ("Empty.fst");
+    if (! c)
+        return;
+    for (const auto program : { 60, 81 })
+    {
+        auto tb = *c;
+        CHECK (transistorBassSelectProgram (tb.pluginState, program));
+        for (int i = 0; i < tbseq::steps; ++i)
+            CHECK (modelparams::setRawValue (tb, tbseq::firstStep + 5 * i + 2, 1.0f));
+        Song base;
+        base.channels.push_back (tb);
+        CHECK (cloneChannel (base, 0) == 1);
+        CHECK (base.channels.size() == 2 && base.channels[1].pluginState == tb.pluginState);
+        const auto blocks = 2 * 44100 * 60 / 140 * 8 / 2 / 512; // (the two bars)
+        const auto originalAuto = render (song (base.channels, 0, program, 0, 2, 0.0f, 1.0f), blocks);
+        const auto originalPlain = render (song (base.channels, 0, program, 0, -1, 0.0f, 0.0f), blocks);
+        const auto cloneAuto = render (song (base.channels, 1, program, 1, 2, 0.0f, 1.0f), blocks);
+        const auto clonePlain = render (song (base.channels, 1, program, 1, -1, 0.0f, 0.0f), blocks);
+        const auto cloneOther = render (song (base.channels, 1, program, 1, 2, 1.0f, 0.0f), blocks);
+        std::printf ("  program %d: peaks %.4f %.4f %.4f %.4f; orig auto==plain %d, clone auto==plain %d, clone==orig %d, ramps differ %d\n",
+                     program, peak (originalAuto), peak (originalPlain), peak (cloneAuto), peak (clonePlain),
+                     (int) (originalAuto == originalPlain), (int) (cloneAuto == clonePlain), (int) (cloneAuto == originalAuto),
+                     (int) (cloneAuto != cloneOther));
+        CHECK (peak (clonePlain) > 1e-3);
+        CHECK (originalAuto != originalPlain);
+        CHECK (cloneAuto != clonePlain);
+        CHECK (cloneAuto != cloneOther);
+        CHECK (cloneAuto == originalAuto);
+    }
+}
+
+namespace issue258
+{
+// the parameters a channel's automation clip can drive on a native engine, those most likely to move a held note first
+inline std::vector<int> automatableParams (const lynx::ChannelDef& c)
+{
+    using namespace lynx;
+    std::vector<int> out;
+    if (const auto* t = modelparams::tableOf (c.instrument); t != nullptr && t->params != nullptr)
+    {
+        std::vector<int> first, rest;
+        for (const auto& p : *t->params)
+        {
+            if (p.stepped || p.hasUnits())
+                continue;
+            auto name = p.name;
+            std::transform (name.begin(), name.end(), name.begin(), [] (unsigned char ch) { return (char) std::tolower (ch); });
+            const auto likely = name.find ("cut") != std::string::npos || name.find ("vol") != std::string::npos
+                                || name.find ("level") != std::string::npos || name.find ("freq") != std::string::npos
+                                || name.find ("gain") != std::string::npos || name.find ("pitch") != std::string::npos;
+            (likely ? first : rest).push_back (p.index);
+        }
+        out = first;
+        out.insert (out.end(), rest.begin(), rest.end());
+    }
+    if (c.instrument == InstrumentKind::sytrus)
+        for (const auto k : { 0, 1, 2, 18, 19 })
+            if (sytrus::automatable (k))
+                out.push_back (k);
+    if (c.instrument == InstrumentKind::harmor && c.engineRev >= 3)
+        for (const auto k : { 52, 64, 438, 450, 772, 773, 774 })
+            if (harmor::automatable (k))
+                out.push_back (k);
+    if (c.instrument == InstrumentKind::synth)
+        for (const int k : { (int) synthparam::cutoff, synthparam::oscParam (0, synthparam::level), (int) synthparam::resonance })
+            out.push_back (synthparam::target (k));
+    if (out.size() > 24)
+        out.resize (24);
+    return out;
+}
+} // namespace issue258
+
+// every native engine that takes automation, cloned: the clone's own clip moves the clone's sound exactly as the same
+// clip moves the original's (round 190pv; issue #258 reported it on Transistor Bass)
+TEST (issue258_every_cloned_native_follows_its_automation)
+{
+    using namespace lynx;
+    using namespace issue258;
+    std::vector<ChannelDef> made;
+    made.emplace_back(); // (LYNX Synth, the default channel)
+    for (const auto& e : natives::instrumentEngines())
+        if (auto c = natives::makeChannel (e.kind, natives142::flAccess()))
+            made.push_back (*c);
+    int checked = 0, none = 0;
+    for (const auto& c : made)
+    {
+        const auto params = automatableParams (c);
+        if (params.empty())
+            continue;
+        Song base;
+        base.channels.push_back (c);
+        if (cloneChannel (base, 0) != 1)
+        {
+            CHECK (false);
+            continue;
+        }
+        const int blocks = 120;
+        bool found = false;
+        for (const auto param : params)
+        {
+            const auto originalAuto = render (song (base.channels, 0, 60, 0, param, 0.0f, 1.0f), blocks);
+            const auto originalOther = render (song (base.channels, 0, 60, 0, param, 1.0f, 0.0f), blocks);
+            if (originalAuto == originalOther)
+                continue; // (this note doesn't hear that parameter: the next one)
+            const auto cloneAuto = render (song (base.channels, 1, 60, 1, param, 0.0f, 1.0f), blocks);
+            const auto cloneOther = render (song (base.channels, 1, 60, 1, param, 1.0f, 0.0f), blocks);
+            const auto ok = cloneAuto == originalAuto && cloneOther == originalOther && cloneAuto != cloneOther;
+            if (! ok)
+                std::printf ("  %s (kind %d) param %d: the clone's automation %s\n", c.name.c_str(), (int) c.instrument, param,
+                             cloneAuto == cloneOther ? "does nothing" : "plays differently from the original's");
+            CHECK (ok);
+            found = true;
+            ++checked;
+            break;
+        }
+        if (! found)
+        {
+            ++none;
+            std::printf ("  %s (kind %d): no automated parameter moved its note\n", c.name.c_str(), (int) c.instrument);
+        }
+    }
+    std::printf ("  issue258: %d cloned engines checked, %d without an audible parameter\n", checked, none);
+    CHECK (checked >= 1);
+}

+ 1 - 0
tests/tests.cpp

@@ -18106,3 +18106,4 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "AutoModes190paTests.inc" // round 190pa (0.1.31): automation write modes (P21), range edits on chosen tracks (P14)
 #include "Tracks190peTests.inc" // round 190pe (0.1.31): track versions (P20) and the import of tracks from another project (P11)
 #include "Jsfx190pjTests.inc" // round 190pj (0.1.32): JSFX support stages 1-2 (issue #241)
+#include "Issue258_190pvTests.inc" // round 190pv: issue #258, a cloned channel's own automation drives its sound