Răsfoiți Sursa

Offline render again on the same engine: from the song's start, not where the last render stopped (round 190ou)

AudioEngine::renderOffline left the transport at the render's end position, with the tempo the song's tempo
automation had reached, and the rack never saw the stop (no block after stop()). A second render on the same engine
started there: past a song's notes it came out silent (round 190op: peaks 0.233 / 0 / 0 over three renders), in a
looping pattern or song it was another part of it. A render now starts at tick 0 at the song's tempo, as on a new
engine; after it one discarded stopped block lets the rack release its notes and reset its note tools, and the
engine's own position and tempo come back.

The user flows render with a new engine each time (ExportJob, StemPass, sessionpack, the clip renders), so their
files do not change: gold renders of Thief, Song For You, Secret Agent and Exoplanet identical to the base.

Regression test engine/RenderAgainTest.cpp (--renderagaintest report.txt, and --selftest renderagain190ou): the same
engine three times in Pattern and Song mode and after a long render, 190op's song longer than the render, export
twice, export then play (and an offline render on the playing engine leaves its playhead), stems with the mix then
the mixdown, the Online-session stand-in renders and the bounce of a time selection twice, Render to audio clip
twice. Without the fix 11 of its checks fail (190op's case: RMS 0 on the second and third render).
Ka1-S 2 săptămâni în urmă
părinte
comite
cf7ecae311

+ 1 - 0
CMakeLists.txt

@@ -566,6 +566,7 @@ if(LYNX_BUILD_APP)
         src/engine/SandboxWorker.cpp
         src/engine/Bridge32Test.cpp
         src/engine/ClapTeardownTest.cpp
+        src/engine/RenderAgainTest.cpp
         src/engine/HostingTests.cpp
         src/engine/Exporter.cpp
         # M4A export through the system's AAC encoder (owner decision D5): each file compiles on its own platform only

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

@@ -290,6 +290,7 @@ APP_SOURCES+=(src/engine/DeviceChangeTest.cpp src/engine/ShortExportTest.cpp)
 APP_SOURCES+=(src/engine/ExportParityTest.cpp src/engine/MidiHotplugTest.cpp src/engine/MidiOutPortTest.cpp src/engine/PadRecordTest.cpp src/engine/ShareMemoryTest.cpp)
 # round 190az: a CLAP plugin deleted on another thread while the message thread is blocked
 APP_SOURCES+=(src/engine/ClapTeardownTest.cpp)
+APP_SOURCES+=(src/engine/RenderAgainTest.cpp) # round 190ou: offline renders made again (--renderagaintest, --selftest)
 APP_SOURCES+=(src/engine/HostingTests.cpp) # (round 190jg: --sandboxgrouptest, --sandboxbench, --clapext, --automationtimingtest)
 # LYNX substitutes for missing third-party plugins (round 98)
 APP_SOURCES+=(src/core/PluginSubstitutes.cpp)

+ 16 - 0
src/Main.cpp

@@ -125,6 +125,7 @@
 #include "engine/Bridge32Test.h"
 #include "engine/ClapFormat.h"
 #include "engine/ClapTeardownTest.h"
+#include "engine/RenderAgainTest.h"
 #include "engine/HostingTests.h"
 #include "core/EdisonFx.h"
 #include "engine/ProjectFile.h"
@@ -1911,6 +1912,18 @@ public:
             return;
         }
 
+        if (args.contains ("--renderagaintest"))
+        {
+            // LYNX --renderagaintest report.txt (round 190ou, engine/RenderAgainTest.cpp): offline renders made again
+            const auto i = args.indexOf ("--renderagaintest");
+            juce::String lines;
+            const auto result = lynx::renderagain::check ([&lines] (const juce::String& line) { lines << line << "\n"; });
+            juce::File (args[i + 1].unquoted()).replaceWithText (lines + "renderagain190ou=" + result + "\n");
+            setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
+            quit();
+            return;
+        }
+
         if (args.contains ("--clapteardowntest"))
         {
             // LYNX.exe --clapteardowntest "LYNX Test Restart.clap" report.txt (round 190az, engine/ClapTeardownTest.cpp)
@@ -9043,6 +9056,7 @@ private:
         const auto faultResult = faultReportSelfTest();
         const auto stemsResult = stemsSinglePassSelfTest(); // round 190gj
         const auto exportFormatsResult = lynx::shortexport::formatsCheck(); // AIFF and M4A (owner decision D5)
+        const auto renderAgainResult = lynx::renderagain::check(); // round 190ou: offline renders made again
         juce::LookAndFeel::setDefaultLookAndFeel (&lookBefore);
         const auto ok = editorsResult.startsWith ("OK") && ! faultResult.startsWith ("ERROR") && stemsResult == "OK" && exportFormatsResult.startsWith ("OK")
                         && mixerBasics == "OK" && fontsResult == "OK" && paintCachesResult.startsWith ("OK") && picturesResult == "OK" && audioOk && projectOk && trackModes122Ok && richOk && hwOutOk && hostKeysOk && pluginLevelsOk && flp168jOk && clipFades180dOk && blocksOk && takeoverOk && compOk && polyOk && latencyOk && preSendOk && lowLatencyOk && previewInTimeOk && substituteOk && patcherOk && rackResult == "OK" && nativesOk && undoOk && projectSaveOk && recordOk && recordUndoOk && cancelRecordOk && midiOk && packageOk
@@ -9052,6 +9066,7 @@ private:
                         && 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"
+                        && renderAgainResult.startsWith ("OK")
                         && remoteHistoryResult.startsWith ("OK") && hostedStateLockResult.startsWith ("OK")
                         && hostedStateContentionResult.startsWith ("OK")
                         && generatorSmartResult.startsWith ("OK")
@@ -9145,6 +9160,7 @@ private:
                << "rollup031s4_copy_for_0130=" << rollup031s4Result << "\n"
                << "rollup031s5_copy_for_0130=" << rollup031s5Result << "\n"
                << "sections190ol=" << sections190olResult << "\n"
+               << "renderagain190ou=" << renderAgainResult << "\n"
                << "metronome=" << metronomeResult << " (FL sounds " << metronomeFlSounds << "/" << lynx::metronome::soundCount
                << ", downbeat peak " << juce::String (metronomeMaster, 4) << ")\n";
 

+ 15 - 0
src/engine/AudioEngine.cpp

@@ -826,6 +826,11 @@ float AudioEngine::renderOffline (const RenderOptions& options)
     setHqForAllPlugins (options.hqAllPlugins);
     setPluginsRenderMode (true); // and hosted plugins are told an export is running (FL: "notify about rendering mode")
     transport.sampleRate.store (sampleRate);
+    // Round 190ou: a render plays from the song's start at the song's tempo, as on a new engine. A second render on the
+    // same engine started where the first had stopped (the transport kept its end position, past a pattern's end: a
+    // silent file) and at the tempo the song's tempo automation had reached. The engine's position comes back after.
+    const auto positionBefore = transport.positionTicks.exchange (0.0);
+    transport.bpm.store (song.bpm);
     // round 164c: JUCE's graph builds its render sequence on the message thread. Prepared from the Export window's
     // thread it rebuilt later (asynchronously) and rendered silence until then: the first ~0.05–2 s of the song were
     // lost (the transport kept moving). It is prepared on the message thread, and the render waits for that.
@@ -946,6 +951,16 @@ float AudioEngine::renderOffline (const RenderOptions& options)
 
     stop();
     vfx::script::setSongEnded (false);
+    // Round 190ou: the rack sees the stop, as playback's next block shows it (the notes released, the note tools reset):
+    // a render after this one starts playing from a stopped transport, as on a new engine (one discarded block)
+    {
+        juce::AudioBuffer<float> view (buffer.getArrayOfWritePointers(), 2, blockSize);
+        view.clear();
+        midi.clear();
+        graph.processBlock (view, midi);
+    }
+    transport.positionTicks.store (positionBefore);
+    transport.bpm.store (song.bpm);
 
     if (rackProcessor != nullptr)
     {

+ 361 - 0
src/engine/RenderAgainTest.cpp

@@ -0,0 +1,361 @@
+#include "engine/RenderAgainTest.h"
+
+#include <algorithm>
+#include <cmath>
+#include <memory>
+#include <vector>
+
+#include <juce_audio_formats/juce_audio_formats.h>
+
+#include "core/QuickRender.h"
+#include "engine/AudioEngine.h"
+#include "engine/Exporter.h"
+#include "engine/SessionPack.h"
+
+namespace lynx::renderagain
+{
+namespace
+{
+constexpr double rate = 48000.0;
+
+struct Audio
+{
+    std::vector<float> left, right;
+
+    double rms() const
+    {
+        double sum = 0.0;
+        for (std::size_t i = 0; i < left.size(); ++i)
+            sum += (double) left[i] * left[i] + (double) right[i] * right[i];
+        return left.empty() ? 0.0 : std::sqrt (sum / (2.0 * (double) left.size()));
+    }
+    bool audible() const { return rms() > 1.0e-3; }
+    // the largest difference to `o` (their lengths must match)
+    double diff (const Audio& o) const
+    {
+        if (o.left.size() != left.size())
+            return 1.0e9;
+        double d = 0.0;
+        for (std::size_t i = 0; i < left.size(); ++i)
+            d = std::max (d, (double) std::max (std::abs (left[i] - o.left[i]), std::abs (right[i] - o.right[i])));
+        return d;
+    }
+    juce::String describe() const { return juce::String ((int) left.size()) + " frames, RMS " + juce::String (rms(), 5); }
+};
+
+// The default song (Pattern mode). `exact`: without the Clap and the Hat (their noise goes on from one play to the next:
+// only a new engine plays them the same) and with a synth line, so that every render of it is the same bit for bit
+Song testSong (bool exact)
+{
+    auto s = Song::makeDefault();
+    if (exact)
+    {
+        auto& notes = s.patterns[0].notes;
+        notes.erase (std::remove_if (notes.begin(), notes.end(), [] (const Note& n) { return n.channel == 1 || n.channel == 2; }), notes.end());
+        for (int k = 0; k < 4; ++k)
+        {
+            Note n;
+            n.channel = 4;
+            n.start = k * ppq;
+            n.length = ppq / 2;
+            n.key = 60 + 3 * k;
+            notes.push_back (n);
+        }
+    }
+    return s;
+}
+
+// ... in Song mode: its pattern twice on track 1
+Song songModeSong (bool exact = false)
+{
+    auto s = testSong (exact);
+    s.playlist.clear();
+    for (int bar = 0; bar < 2; ++bar)
+        s.playlist.push_back ({ 0, 0, bar * 4 * ppq, 4 * ppq, 0 });
+    s.mode = PlayMode::song;
+    return s;
+}
+
+Audio renderOn (AudioEngine& engine, double seconds)
+{
+    Audio a;
+    AudioEngine::RenderOptions o;
+    o.seconds = seconds;
+    o.sampleRate = rate;
+    o.tailSeconds = 0.0;
+    o.capture = [&a] (const float* l, const float* r, int n) {
+        a.left.insert (a.left.end(), l, l + n);
+        a.right.insert (a.right.end(), r, r + n);
+    };
+    engine.renderOffline (o);
+    return a;
+}
+
+Audio readWav (const juce::File& file)
+{
+    Audio a;
+    juce::WavAudioFormat wav;
+    std::unique_ptr<juce::AudioFormatReader> reader (wav.createReaderFor (file.createInputStream().release(), true));
+    if (reader == nullptr)
+        return a;
+    juce::AudioBuffer<float> b ((int) reader->numChannels, (int) reader->lengthInSamples);
+    reader->read (&b, 0, b.getNumSamples(), 0, true, true);
+    a.left.assign (b.getReadPointer (0), b.getReadPointer (0) + b.getNumSamples());
+    const auto* r = b.getReadPointer (b.getNumChannels() > 1 ? 1 : 0);
+    a.right.assign (r, r + b.getNumSamples());
+    return a;
+}
+
+exportopts::Options exportOptions()
+{
+    exportopts::Options o;
+    o.format = exportopts::Format::wav;
+    o.wavBits = 32;
+    o.dither = exportopts::DitherMode::none;
+    o.sampleRate = rate;
+    o.maxTailSeconds = 2.0;
+    return o;
+}
+
+// An export the way the Export window makes it (an ExportJob: its own engine), here on the calling (message) thread
+Audio exportSong (const Song& song, const exportopts::Options& o, const juce::File& file, bool extraData = true)
+{
+    ExportJob job (song, o, file);
+    job.setExtraData (extraData);
+    juce::String error;
+    if (! job.run ({}, error))
+        return {};
+    return readWav (file);
+}
+
+// A stand-in device: the engine's callback is driven by hand
+struct TestDevice final : juce::AudioIODevice
+{
+    TestDevice() : juce::AudioIODevice ("renderagain", "test") {}
+    juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
+    juce::StringArray getInputChannelNames() override { return {}; }
+    juce::Array<double> getAvailableSampleRates() override { return { rate }; }
+    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 rate; }
+    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; }
+};
+
+// `samples` played from the song's start through the device callback (Play), then stopped
+Audio playOn (AudioEngine& engine, int samples)
+{
+    auto& cb = engine.deviceCallback();
+    std::vector<float> l (512), r (512);
+    float* outs[] = { l.data(), r.data() };
+    juce::AudioIODeviceCallbackContext context;
+    engine.stop();
+    engine.seek (0.0);
+    cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context); // (the seek, stopped)
+    engine.play();
+    Audio a;
+    while ((int) a.left.size() < samples)
+    {
+        cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+        a.left.insert (a.left.end(), l.begin(), l.end());
+        a.right.insert (a.right.end(), r.begin(), r.end());
+    }
+    engine.stop();
+    for (int k = 0; k < 200; ++k) // (the tails die out)
+        cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
+    a.left.resize ((std::size_t) samples);
+    a.right.resize ((std::size_t) samples);
+    return a;
+}
+} // namespace
+
+juce::String check (std::function<void (const juce::String&)> log)
+{
+    juce::StringArray problems;
+    auto say = [&log] (const juce::String& s) {
+        if (log)
+            log (s);
+    };
+    // `again` must be audible and match `first` (bit for bit: the same song through the same code)
+    auto same = [&] (const juce::String& what, const Audio& first, const Audio& again) {
+        const auto d = first.diff (again);
+        say (what + ": first " + first.describe() + ", again " + again.describe() + ", max diff " + juce::String (d, 9));
+        if (! first.audible() || ! again.audible() || d > 0.0)
+            problems.add (what + " (first " + first.describe() + ", again " + again.describe() + ", max diff " + juce::String (d, 9) + ")");
+    };
+    const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-renderagain190ou-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
+    dir.createDirectory();
+
+    // 1. the same engine, three renders (the bug: the second one started where the first had stopped: past the song's end
+    // a silent file, in a looping pattern another part of it); Pattern mode and Song mode
+    for (const auto mode : { PlayMode::pattern, PlayMode::song })
+    {
+        const auto name = juce::String ("same engine, ") + (mode == PlayMode::song ? "Song" : "Pattern") + " mode";
+        AudioEngine engine (false);
+        engine.setSong (mode == PlayMode::song ? songModeSong (true) : testSong (true));
+        const auto a = renderOn (engine, 3.0);
+        const auto b = renderOn (engine, 3.0);
+        const auto c = renderOn (engine, 3.0);
+        same (name + ", render 2", a, b);
+        same (name + ", render 3", a, c);
+        // a render past the song's end, then one from its start again (190op's silent second render)
+        AudioEngine fresh (false);
+        fresh.setSong (engine.getSong());
+        const auto first = renderOn (fresh, 3.0);
+        renderOn (engine, 30.0);
+        same (name + ", after a long render", first, renderOn (engine, 3.0));
+    }
+    // round 190op's case: a song seven bars long whose notes are all in its first bar, three renders of 2.5 s (they gave
+    // peaks 0.233 / 0 / 0: the second and third started past the notes)
+    {
+        auto s = songModeSong (true);
+        s.playlist.resize (1);
+        auto late = s.playlist[0];
+        late.track = 2;
+        late.start = 24 * ppq;
+        s.playlist.push_back (late);
+        AudioEngine engine (false);
+        engine.setSong (s);
+        const auto a = renderOn (engine, 2.5);
+        same ("same engine, a song longer than the render, render 2", a, renderOn (engine, 2.5));
+        same ("same engine, a song longer than the render, render 3", a, renderOn (engine, 2.5));
+    }
+    // the default song (its Clap and Hat play noise: another noise each time on one engine): the same loudness again
+    {
+        AudioEngine engine (false);
+        const auto a = renderOn (engine, 3.0);
+        const auto b = renderOn (engine, 3.0);
+        const auto ratio = a.rms() > 0.0 ? b.rms() / a.rms() : 0.0;
+        say ("same engine, the default song: first " + a.describe() + ", again " + b.describe());
+        if (! a.audible() || std::abs (ratio - 1.0) > 0.02)
+            problems.add ("same engine, the default song (first " + a.describe() + ", again " + b.describe() + ")");
+    }
+
+    // 2. Export twice in one session (two ExportJobs of the same song)
+    const auto song = songModeSong();
+    const auto mix = exportSong (song, exportOptions(), dir.getChildFile ("mix1.wav"));
+    same ("export twice", mix, exportSong (song, exportOptions(), dir.getChildFile ("mix2.wav")));
+
+    // 3. Export, then play: the live engine plays the same before and after an export, and after an offline render of
+    // its own (the live engine's own engine: the render's state must not stay behind)
+    {
+        AudioEngine live (true, -1, false, true); // (as the app's engine, its device not opened: the callback is driven by hand)
+        live.setSong (songModeSong (true));
+        TestDevice device;
+        live.deviceCallback().audioDeviceAboutToStart (&device);
+        const auto before = playOn (live, (int) rate * 2);
+        same ("play, then play", before, playOn (live, (int) rate * 2));
+        exportSong (live.getSong(), exportOptions(), dir.getChildFile ("mix3.wav"));
+        same ("export, then play", before, playOn (live, (int) rate * 2));
+        live.seek (4.0 * ppq); // (the playhead elsewhere: a render starts at the song's start and leaves it where it was)
+        {
+            std::vector<float> l (512), r (512);
+            float* outs[] = { l.data(), r.data() };
+            live.deviceCallback().audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, {}); // (the seek, stopped)
+        }
+        const auto at = live.getTransport().positionTicks.load();
+        AudioEngine fresh (false);
+        fresh.setSong (live.getSong());
+        same ("an offline render on the playing engine", renderOn (fresh, 2.0), renderOn (live, 2.0));
+        if (std::abs (live.getTransport().positionTicks.load() - at) > 0.5)
+            problems.add ("an offline render moved the playhead from " + juce::String (at, 1) + " to " + juce::String (live.getTransport().positionTicks.load(), 1));
+        live.deviceCallback().audioDeviceAboutToStart (&device); // (as the device restarts after a render)
+        same ("its own render, then play", before, playOn (live, (int) rate * 2));
+        live.deviceCallback().audioDeviceStopped();
+    }
+
+    // 4. Stems with the mix, then the mixdown: the mixdown is the mix made before
+    {
+        auto o = exportOptions();
+        o.stems = exportopts::Stems::mixerTracks;
+        o.stemsIncludeMaster = true;
+        const auto plan = planStemExport (song, o, dir.getChildFile ("stems").getChildFile ("song.wav"));
+        dir.getChildFile ("stems").createDirectory();
+        const auto written = runStemExport (plan, [] (std::function<void()> f) { f(); }, {}, {}, {}, {});
+        say ("stems: " + juce::String (written) + " of " + juce::String ((int) plan.items.size()) + " file(s)");
+        if (written != (int) plan.items.size() || written < 2)
+            problems.add ("stems: " + juce::String (written) + " of " + juce::String ((int) plan.items.size()) + " file(s)");
+        // (the default song's Snare and Synth channels have no notes: their inserts' stems are silent)
+        auto audible = 0;
+        for (const auto& item : plan.items)
+            audible += readWav (item.file).audible() ? 1 : 0;
+        if (audible < 4)
+            problems.add ("stems: " + juce::String (audible) + " audible file(s), the mix and the Kick, Clap and Hat inserts expected");
+        same ("stems, then the mixdown", mix, exportSong (song, exportOptions(), dir.getChildFile ("mix4.wav")));
+    }
+
+    // 5. Online session: the stand-in renders made twice (sessionpack::render, private engines), the same files
+    {
+        sessionpack::RenderItem item;
+        item.index = 2; // (the Hat channel)
+        item.timeline = true;
+        item.name = "Hat";
+        const std::vector<sessionpack::RenderItem> items { item, sessionpack::RenderItem { true, 1, true, "Kick", {} } };
+        std::vector<std::vector<sessionpack::Rendered>> runs (2);
+        for (int k = 0; k < 2; ++k)
+        {
+            const auto folder = dir.getChildFile ("standins" + juce::String (k));
+            folder.createDirectory();
+            juce::String error;
+            if (! sessionpack::render (song, items, rate, folder, "test", runs[(std::size_t) k], {}, error))
+                problems.add ("online session renders: " + error);
+        }
+        auto files = [] (const std::vector<sessionpack::Rendered>& r) {
+            std::vector<juce::File> out;
+            for (const auto& x : r)
+                for (const auto& s : x.standIns)
+                    out.push_back (juce::File (juce::String::fromUTF8 (s.path.c_str())));
+            return out;
+        };
+        const auto first = files (runs[0]), again = files (runs[1]);
+        if (first.empty() || first.size() != again.size())
+            problems.add ("online session renders: " + juce::String ((int) first.size()) + " / " + juce::String ((int) again.size()) + " stand-ins");
+        for (std::size_t i = 0; i < first.size() && i < again.size(); ++i)
+            same ("online session render " + first[i].getFileName() + " again", readWav (first[i]), readWav (again[i]));
+        // the Session's bounce of a time selection (Bounce to New Track / Consolidate), twice
+        auto selection = song;
+        selection.loopStart = 0;
+        selection.loopEnd = 4 * ppq;
+        juce::String error;
+        const auto f1 = dir.getChildFile ("bounce1.wav"), f2 = dir.getChildFile ("bounce2.wav");
+        const auto ok = sessionpack::renderSelection (selection, rate, f1, {}, error) && sessionpack::renderSelection (selection, rate, f2, {}, error);
+        if (! ok)
+            problems.add ("bounce of a time selection: " + error);
+        same ("bounce of a time selection again", readWav (f1), readWav (f2));
+    }
+
+    // 6. Render to audio clip (Consolidate this track: the plan's song, no extra chunks), twice
+    {
+        quickrender::Plan plan;
+        if (quickrender::planTrack (song, 0, false, quickrender::Start::songStart, plan) != quickrender::Result::ok)
+            problems.add ("render to audio clip: no plan");
+        else
+        {
+            const auto render = quickrender::makePlanRenderSong (song, plan);
+            auto o = exportOptions();
+            o.range = exportopts::Range::selection;
+            const auto a = exportSong (render, o, dir.getChildFile ("clip1.wav"), false);
+            same ("render to audio clip again", a, exportSong (render, o, dir.getChildFile ("clip2.wav"), false));
+        }
+    }
+
+    dir.deleteRecursively();
+    return problems.isEmpty() ? juce::String ("OK (6 flows)") : "ERROR " + problems.joinIntoString ("; ");
+}
+} // namespace lynx::renderagain

+ 13 - 0
src/engine/RenderAgainTest.h

@@ -0,0 +1,13 @@
+#pragma once
+
+// Round 190ou: an offline render made again. A second AudioEngine::renderOffline on the same engine came out silent
+// (found by round 190op); the user flows that render more than once (export twice, export then play, stems then the
+// mixdown, an Online-session bounce, Render to audio clip) are checked here too. See engine/RenderAgainTest.cpp.
+
+#include <juce_core/juce_core.h>
+
+namespace lynx::renderagain
+{
+// Synchronous, on the message thread. "OK (...)" or "ERROR ..."; `log` (optional) gets a line per check.
+juce::String check (std::function<void (const juce::String&)> log = {});
+} // namespace lynx::renderagain