Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(fix) Duplicated tracks keep their plug-ins; plug-ins are prepared for 4096-sample blocks (#468)

Chris Laupama8098bd00a3de
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0ab26e8..f8acdb62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -247,6 +247,15 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
returns, then the master.
### Fixed
+- **Duplicating a track keeps its plug-ins** (#454): Duplicate track, a copied and pasted
+ plug-in effect and a copied rack now bring their VST3 plug-ins along, with every setting.
+ The copy used to come back without them, because a running plug-in describes itself by the
+ file inside its bundle, which can't be loaded again; the copy now loads the plug-in the way
+ the browser does.
+- **Plug-ins that cap their block size load** (#447): sfizz and other plug-ins with a maximum
+ block size stopped Nota when added, because every plug-in was prepared for 16384-sample
+ blocks. Plug-ins are now prepared for at most 4096; a longer block (an export, a large audio
+ buffer) is played to them in pieces, each with its own notes and transport position.
- **The loop region is saved with the project** (#455): its start and end, and whether the
loop is on, come back when you open the project again. A new project starts without one.
- **The Mixer's volume reaches −∞** (#453): a fader pulled all the way down, a dB value dragged
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginCommon.cpp b/src/native/nota.engine/pluginhost/hosting/PluginCommon.cpp
index 7ee17447..5abbbf86 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginCommon.cpp
+++ b/src/native/nota.engine/pluginhost/hosting/PluginCommon.cpp
@@ -118,6 +118,35 @@ std::unique_ptr<juce::AudioPluginInstance> createInstance(
return scanner::sharedFormatManager().createPluginInstance(desc, sr, maxBlock, err);
}
+void advanceTransport(nota::TransportInfo& ti, int32_t frames, double sr) {
+ if (!ti.isPlaying || frames <= 0 || sr <= 0.0) return;
+ const double secs = frames / sr;
+ ti.timeInSamples += frames;
+ ti.timeInSeconds += secs;
+ ti.ppqPosition += secs * ti.bpm / 60.0;
+ const double loopLen = ti.ppqLoopEnd - ti.ppqLoopStart;
+ if (ti.isLooping && loopLen > 0.0 && ti.ppqPosition >= ti.ppqLoopEnd) ti.ppqPosition -= loopLen;
+}
+
+std::unique_ptr<juce::AudioPluginInstance> cloneInstance(juce::AudioPluginInstance& src, double sr, int maxBlock) {
+ // A running instance describes itself by its binary (a VST3 on Linux names the .so inside
+ // its bundle), which no format can load again (#454). The catalog entry it came from is the
+ // description that loaded it: take that, matched by format, name and id, and fall back to the
+ // instance's own only for a plug-in the catalog no longer lists.
+ const juce::PluginDescription own = src.getPluginDescription();
+ juce::PluginDescription desc = own;
+ auto& catalog = scanner::PluginCatalog::instance();
+ catalog.loadOnce();
+ const bool listed = catalog.typeOfId(own.createIdentifierString().toRawUTF8(), desc);
+ auto inst = createInstance(desc, sr, maxBlock);
+ if (!inst && listed) inst = createInstance(own, sr, maxBlock);
+ if (!inst) return nullptr;
+ juce::MemoryBlock mb;
+ src.getStateInformation(mb);
+ if (mb.getSize() > 0) inst->setStateInformation(mb.getData(), (int)mb.getSize());
+ return inst;
+}
+
std::unique_ptr<juce::AudioPluginInstance> instantiateCatalog(
int catalogIndex, double sr, int maxBlock, bool instrumentOnly) {
auto& catalog = scanner::PluginCatalog::instance();
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginCommon.h b/src/native/nota.engine/pluginhost/hosting/PluginCommon.h
index e0770c71..7309e416 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginCommon.h
+++ b/src/native/nota.engine/pluginhost/hosting/PluginCommon.h
@@ -15,6 +15,8 @@
#include <juce_audio_processors/juce_audio_processors.h>
+#include "engine/TransportInfo.h"
+
namespace juce {
class PluginDescription;
} // namespace juce
@@ -79,6 +81,15 @@ float paramGetImpl(juce::AudioPluginInstance* p, int32_t i);
void paramSetImpl(juce::AudioPluginInstance* p, int32_t i, float v);
int32_t paramIndexOfIdImpl(juce::AudioPluginInstance* p, const std::string& id);
+// The largest block a hosted plug-in is prepared for and handed (#447). The engine's own
+// buffers go to 16384 frames, but plug-ins cap theirs (sfizz asserts above 8192, others
+// size their scratch from it), so a longer host block is played to them in pieces.
+constexpr int kPluginMaxBlock = 4096;
+
+// The transport `frames` samples later, for the next piece of a split block: the position
+// moves on while playing and wraps at the loop end.
+void advanceTransport(nota::TransportInfo& ti, int32_t frames, double sr);
+
// Instantiate a full description in-process (message thread). Null on failure.
std::unique_ptr<juce::AudioPluginInstance> createInstance(const juce::PluginDescription& desc, double sr, int maxBlock);
@@ -88,5 +99,9 @@ std::unique_ptr<juce::AudioPluginInstance> createInstance(const juce::PluginDesc
std::unique_ptr<juce::AudioPluginInstance> instantiateCatalog(
int catalogIndex, double sr, int maxBlock, bool instrumentOnly);
+// A second instance of `src`'s plug-in with `src`'s state (Duplicate track, device copy, rack
+// copy; message thread). Null when it can't be made.
+std::unique_ptr<juce::AudioPluginInstance> cloneInstance(juce::AudioPluginInstance& src, double sr, int maxBlock);
+
} // namespace hosting
} // namespace nota
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginEffect.cpp b/src/native/nota.engine/pluginhost/hosting/PluginEffect.cpp
index bd7e1a9f..f17b1dbe 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginEffect.cpp
+++ b/src/native/nota.engine/pluginhost/hosting/PluginEffect.cpp
@@ -29,7 +29,7 @@ PluginEffect::~PluginEffect() {
}
void PluginEffect::setSampleRate(double sr, int32_t maxBlock) {
- maxBlock_ = maxBlock;
+ maxBlock_ = juce::jmin(maxBlock, kPluginMaxBlock); // #447: a longer block is played in pieces
// Prefer stereo main I/O plus a sidechain input bus if the plugin exposes
// one (input bus index 1, Phase C). Fall back to plain stereo I/O.
hasSidechain_ = false;
@@ -74,7 +74,25 @@ int32_t PluginEffect::latencySamples() const {
}
void PluginEffect::process(float* buf, int32_t frames) {
- if (frames <= 0 || frames > maxBlock_ || plugin_ == nullptr) return;
+ if (frames <= 0 || plugin_ == nullptr) return;
+ const float* sc = scBuf_;
+ const int32_t scFrames = scFrames_;
+ scBuf_ = nullptr; // consume once; the engine re-hands it each block if a source is set
+ if (frames <= maxBlock_) {
+ processPiece(buf, frames, sc, scFrames);
+ return;
+ }
+ // Longer than the plug-in was prepared for (#447): in pieces, the key and the transport
+ // moving along with them.
+ const double sr = plugin_->getSampleRate();
+ for (int32_t off = 0; off < frames; off += maxBlock_) {
+ const int32_t n = juce::jmin(frames - off, maxBlock_);
+ processPiece(buf + (size_t)off * 2, n, sc != nullptr ? sc + (size_t)off * 2 : nullptr, scFrames - off);
+ advanceTransport(playHead_.info, n, sr);
+ }
+}
+
+void PluginEffect::processPiece(float* buf, int32_t frames, const float* scBuf, int32_t scFrames) {
const int nc = juce::jmin(storage_.getNumChannels(), kMaxChans);
storage_.clear(0, frames); // only what this block uses: a multi-out plug-in has many channels
float* l = storage_.getWritePointer(0);
@@ -83,21 +101,20 @@ void PluginEffect::process(float* buf, int32_t frames) {
// Feed the sidechain input bus (Phase C) if the engine handed us a source
// this block; otherwise it stays silent (cleared above).
- if (hasSidechain_ && scBuf_ != nullptr && scFrames_ >= frames && scChanOffset_ >= 0) {
+ if (hasSidechain_ && scBuf != nullptr && scFrames >= frames && scChanOffset_ >= 0) {
const float scGain = fast_math::dbToLin(sidechainGainDb()); // Phase D (was std::pow)
if (scNumChans_ >= 2 && scChanOffset_ + 1 < nc) {
float* sl = storage_.getWritePointer(scChanOffset_);
float* sr = storage_.getWritePointer(scChanOffset_ + 1);
for (int i = 0; i < frames; ++i) {
- sl[i] = scBuf_[i * 2] * scGain;
- sr[i] = scBuf_[i * 2 + 1] * scGain;
+ sl[i] = scBuf[i * 2] * scGain;
+ sr[i] = scBuf[i * 2 + 1] * scGain;
}
} else if (scNumChans_ == 1 && scChanOffset_ < nc) {
float* sm = storage_.getWritePointer(scChanOffset_);
- for (int i = 0; i < frames; ++i) sm[i] = 0.5f * (scBuf_[i * 2] + scBuf_[i * 2 + 1]) * scGain;
+ for (int i = 0; i < frames; ++i) sm[i] = 0.5f * (scBuf[i * 2] + scBuf[i * 2 + 1]) * scGain;
}
}
- scBuf_ = nullptr; // consume once; the engine re-hands it each block if a source is set
float* ptrs[kMaxChans];
juce::AudioBuffer<float> block(
@@ -185,11 +202,8 @@ void PluginEffect::setSidechain(const float* interleaved, int32_t frames) {
std::shared_ptr<nota::Device> PluginEffect::clone() const {
if (!plugin_) return nullptr;
double sr = plugin_->getSampleRate() > 0 ? plugin_->getSampleRate() : 44100.0;
- auto inst = createInstance(plugin_->getPluginDescription(), sr, maxBlock_);
+ auto inst = cloneInstance(*plugin_, sr, maxBlock_);
if (!inst) return nullptr;
- juce::MemoryBlock mb;
- plugin_->getStateInformation(mb);
- inst->setStateInformation(mb.getData(), (int)mb.getSize());
auto d = std::make_shared<PluginEffect>(std::move(inst), sr, maxBlock_);
d->setSidechainSourceTrackId(scTrackId_.load(std::memory_order_relaxed));
return d;
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginEffect.h b/src/native/nota.engine/pluginhost/hosting/PluginEffect.h
index b4020fb7..911c1095 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginEffect.h
+++ b/src/native/nota.engine/pluginhost/hosting/PluginEffect.h
@@ -80,6 +80,8 @@ class PluginEffect : public nota::Device, private juce::AudioProcessorListener {
void audioProcessorParameterChangeGestureEnd(juce::AudioProcessor*, int index) override;
void audioProcessorChanged(juce::AudioProcessor*, const juce::AudioProcessorListener::ChangeDetails&) override {}
+ void processPiece(float* buf, int32_t frames, const float* scBuf, int32_t scFrames); // frames <= maxBlock_
+
NotaPlayHead playHead_; // declared first: outlives plugin_ (which points at it)
std::unique_ptr<juce::AudioPluginInstance> plugin_;
std::string name_;
@@ -95,7 +97,7 @@ class PluginEffect : public nota::Device, private juce::AudioProcessorListener {
int chanFloor_ = 0; // pluginChannelPtrs floor (see minProcessChannels)
juce::MidiBuffer empty_;
WorkgroupLink workgroup_; // the device workgroup for the plug-in's own threads (#436)
- int maxBlock_ = 0;
+ int maxBlock_ = 0; // what the plug-in was prepared for: at most kPluginMaxBlock (#447)
bool stereoIn_ = true, stereoOut_ = true; // main buses have a channel 1 (see setSampleRate)
EditorHost editor_; // declared last: destroyed before plugin_
};
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginInstrument.cpp b/src/native/nota.engine/pluginhost/hosting/PluginInstrument.cpp
index 0f32d8a1..abed0c4a 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginInstrument.cpp
+++ b/src/native/nota.engine/pluginhost/hosting/PluginInstrument.cpp
@@ -14,8 +14,9 @@ namespace nota {
namespace hosting {
PluginInstrument::PluginInstrument(std::unique_ptr<juce::AudioPluginInstance> p, double sr, int maxBlock)
- : plugin_(std::move(p)), maxBlock_(maxBlock) {
+ : plugin_(std::move(p)), maxBlock_(juce::jmin(maxBlock, kPluginMaxBlock)) {
pending_.ensureSize(8192);
+ piece_.ensureSize(8192);
if (plugin_) name_ = plugin_->getName().toStdString(); // cache for displayName()
prepare(sr);
if (plugin_) plugin_->addListener(this); // "Learn" (M9-B3)
@@ -61,19 +62,40 @@ void PluginInstrument::controller(int32_t ctl, float value) {
}
void PluginInstrument::render(float* out, int32_t frames) {
- if (frames <= 0 || frames > maxBlock_ || plugin_ == nullptr) return;
+ if (frames <= 0 || plugin_ == nullptr) return;
// Drain computer-keyboard notes from the editor window (message thread) into
// this block's MIDI buffer — audio thread only touches pending_ here.
for (GuiNote g; guiNotes_.pop(g);)
pending_.addEvent(
g.on ? juce::MidiMessage::noteOn(1, g.pitch, g.velocity) : juce::MidiMessage::noteOff(1, g.pitch), 0);
+ if (frames <= maxBlock_) {
+ renderPiece(out, frames, pending_);
+ } else {
+ // Longer than the plug-in was prepared for (#447): in pieces, each with its own events
+ // (moved to the piece's start) and the transport where the piece begins.
+ const double sr = plugin_->getSampleRate();
+ for (int32_t off = 0; off < frames; off += maxBlock_) {
+ const int32_t n = juce::jmin(frames - off, maxBlock_);
+ const bool last = off + n >= frames;
+ piece_.clear();
+ for (const auto m : pending_) {
+ const int pos = juce::jmax(0, m.samplePosition);
+ if (pos >= off && (pos < off + n || last)) piece_.addEvent(m.data, m.numBytes, juce::jmin(pos - off, n - 1));
+ }
+ renderPiece(out + (size_t)off * 2, n, piece_);
+ advanceTransport(playHead_.info, n, sr);
+ }
+ }
+ pending_.clear();
+}
+
+void PluginInstrument::renderPiece(float* out, int32_t frames, juce::MidiBuffer& midi) {
storage_.clear(0, frames); // only what this block uses: a multi-out plug-in has many channels
float* ptrs[kMaxChans];
juce::AudioBuffer<float> block(
ptrs, pluginChannelPtrs(*plugin_, storage_, spare_.data(), frames, chanFloor_, ptrs), frames);
workgroup_.update();
- plugin_->processBlock(block, pending_);
- pending_.clear();
+ plugin_->processBlock(block, midi);
const float* l = block.getReadPointer(0);
const float* r = stereoOut_ ? block.getReadPointer(1) : l; // channel 1 of a mono main is another bus
simd_audio::interleaveStereoAdd(out, l, r, frames);
@@ -144,11 +166,8 @@ int32_t PluginInstrument::takePluginGestureEnd() {
std::shared_ptr<nota::Instrument> PluginInstrument::clone() const {
if (!plugin_) return nullptr;
double sr = plugin_->getSampleRate() > 0 ? plugin_->getSampleRate() : 44100.0;
- auto inst = createInstance(plugin_->getPluginDescription(), sr, maxBlock_);
+ auto inst = cloneInstance(*plugin_, sr, maxBlock_);
if (!inst) return nullptr;
- juce::MemoryBlock mb;
- plugin_->getStateInformation(mb);
- inst->setStateInformation(mb.getData(), (int)mb.getSize());
return std::make_shared<PluginInstrument>(std::move(inst), sr, maxBlock_);
}
diff --git a/src/native/nota.engine/pluginhost/hosting/PluginInstrument.h b/src/native/nota.engine/pluginhost/hosting/PluginInstrument.h
index 9110e61a..60a0cf91 100644
--- a/src/native/nota.engine/pluginhost/hosting/PluginInstrument.h
+++ b/src/native/nota.engine/pluginhost/hosting/PluginInstrument.h
@@ -86,6 +86,7 @@ class PluginInstrument : public nota::Instrument, private juce::AudioProcessorLi
void audioProcessorChanged(juce::AudioProcessor*, const juce::AudioProcessorListener::ChangeDetails&) override {}
void prepare(double sr);
+ void renderPiece(float* out, int32_t frames, juce::MidiBuffer& midi); // frames <= maxBlock_
NotaPlayHead playHead_; // declared first: outlives plugin_ (which points at it)
std::unique_ptr<juce::AudioPluginInstance> plugin_;
@@ -93,8 +94,9 @@ class PluginInstrument : public nota::Instrument, private juce::AudioProcessorLi
std::vector<float> spare_; // the channels past storage_ (see pluginChannelPtrs)
int chanFloor_ = 0; // pluginChannelPtrs floor (see minProcessChannels)
juce::MidiBuffer pending_;
+ juce::MidiBuffer piece_; // one piece's events when a block is split (#447)
WorkgroupLink workgroup_; // the device workgroup for the plug-in's own threads (#436)
- int maxBlock_;
+ int maxBlock_; // what the plug-in was prepared for: at most kPluginMaxBlock (#447)
bool stereoOut_ = true; // main output bus has a channel 1 (see prepare)
std::string name_; // cached plugin name for displayName()
std::atomic<int32_t> lastTouched_{-1}; // "Learn" (M9-B3)
diff --git a/src/native/nota.engine/pluginhost/scanner/PluginCatalog.cpp b/src/native/nota.engine/pluginhost/scanner/PluginCatalog.cpp
index d0e983ad..fb32c5a1 100644
--- a/src/native/nota.engine/pluginhost/scanner/PluginCatalog.cpp
+++ b/src/native/nota.engine/pluginhost/scanner/PluginCatalog.cpp
@@ -105,9 +105,21 @@ std::string PluginCatalog::idAt(int32_t index) const {
}
int32_t PluginCatalog::indexOfId(const char* identifier) const {
+ std::shared_lock lock(mutex_);
+ return indexOfIdLocked(identifier);
+}
+
+bool PluginCatalog::typeOfId(const char* identifier, juce::PluginDescription& out) const {
+ std::shared_lock lock(mutex_);
+ const int32_t i = indexOfIdLocked(identifier);
+ if (i < 0) return false;
+ out = impl_->types[static_cast<size_t>(i)];
+ return true;
+}
+
+int32_t PluginCatalog::indexOfIdLocked(const char* identifier) const {
if (identifier == nullptr) return -1;
const juce::String want{juce::CharPointer_UTF8(identifier)};
- std::shared_lock lock(mutex_);
const auto& types = impl_->types;
const int n = static_cast<int>(types.size());
for (int i = 0; i < n; ++i)
diff --git a/src/native/nota.engine/pluginhost/scanner/PluginCatalog.h b/src/native/nota.engine/pluginhost/scanner/PluginCatalog.h
index c41ae00e..cfc35a9e 100644
--- a/src/native/nota.engine/pluginhost/scanner/PluginCatalog.h
+++ b/src/native/nota.engine/pluginhost/scanner/PluginCatalog.h
@@ -72,6 +72,9 @@ class PluginCatalog {
// under one lock so the index and the entry can't drift apart mid-scan. False
// when `index` is out of range.
bool typeAt(int32_t index, juce::PluginDescription& out) const;
+ // The same for the entry indexOfId(identifier) finds, looked up and copied under one
+ // lock (a scan between the two steps could move the index onto another plug-in).
+ bool typeOfId(const char* identifier, juce::PluginDescription& out) const;
// Persistence (message/background threads only — file I/O, never RT).
void loadOnce();
@@ -89,6 +92,7 @@ class PluginCatalog {
PluginCatalog();
~PluginCatalog();
struct Impl;
+ int32_t indexOfIdLocked(const char* identifier) const; // caller holds mutex_
std::unique_ptr<Impl> impl_;
mutable std::shared_mutex mutex_;
bool catalogLoaded_ = false;
diff --git a/tests/Nota.SmokeTest/HostedPluginTests.cs b/tests/Nota.SmokeTest/HostedPluginTests.cs
new file mode 100644
index 00000000..c33613e1
--- /dev/null
+++ b/tests/Nota.SmokeTest/HostedPluginTests.cs
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Hosted plug-ins, with a real VST3 (the Nota Pentad build, -DNOTA_BUILD_PENTAD_VST3=ON):
+// - Duplicate track and device copy make a second instance with the source's state (#454: the
+// copy came back empty, the instance's own description naming a binary no format loads).
+// - A host block longer than the plug-in was prepared for plays in pieces (#447: plug-ins were
+// prepared for 16384 frames, which sfizz refuses), each piece with its own notes, so one
+// 16384-frame block renders the same as the same span in 512-frame blocks.
+// Opt-in, since it needs the plug-in built and scanned:
+// dotnet Nota.SmokeTest.dll --hosted-plugin <folder holding "Nota Pentad.vst3"> <nota-scanworker>
+
+using Nota.Infrastructure;
+
+namespace Nota.SmokeTest;
+
+internal static class HostedPluginTests
+{
+ public static IEnumerable<(bool ok, string label)> Run(string vst3Dir, string scanWorker)
+ {
+ NotaEngine.AddScanPath(vst3Dir);
+ int n = NotaEngine.ScanPlugins(scanWorker, vst3Dir, true);
+ int idx = -1;
+ for (int i = 0; i < n; i++)
+ if (NotaEngine.PluginDescription(i)?.StartsWith("Nota Pentad", StringComparison.Ordinal) == true) idx = i;
+ yield return (idx >= 0, $"the Nota Pentad VST3 is in the catalog ({n} plug-ins)");
+ if (idx < 0) yield break;
+
+ foreach (var r in Copies(idx)) yield return r;
+ foreach (var r in LongBlocks(idx)) yield return r;
+ }
+
+ private static IEnumerable<(bool ok, string label)> Copies(int idx)
+ {
+ using var e = new NotaEngine();
+ int t = e.AddPluginInstrumentTrack(idx);
+ int fx = e.AddTrackEffectPlugin(t, idx);
+ e.PluginParamSet(t, -1, 3, 0.123f);
+ e.PluginParamSet(t, fx, 5, 0.321f);
+ string id = e.TrackInstrumentPluginId(t);
+
+ int[] dup = e.DuplicateTracks(new[] { t });
+ int d = dup.Length == 1 ? dup[0] : -1;
+ yield return (d > 0 && e.TrackInstrumentPluginId(d) == id,
+ $"duplicate track copies the plug-in instrument (got '{(d > 0 ? e.TrackInstrumentPluginId(d) : "")}')");
+ yield return (d > 0 && Math.Abs(e.PluginParamGet(d, -1, 3) - 0.123f) < 1e-4,
+ "…with its state");
+ yield return (d > 0 && e.TrackDevicePluginId(d, 0) == id && Math.Abs(e.PluginParamGet(d, 0, 5) - 0.321f) < 1e-4,
+ "…and its plug-in effect, with its state");
+
+ bool copied = e.CopyDevice(t, fx);
+ int at = copied ? e.PasteDevice(t, 1) : -1;
+ yield return (at >= 0 && e.TrackDevicePluginId(t, at) == id && Math.Abs(e.PluginParamGet(t, at, 5) - 0.321f) < 1e-4,
+ "copy + paste of a plug-in effect makes a second instance with its state");
+ }
+
+ private static IEnumerable<(bool ok, string label)> LongBlocks(int idx)
+ {
+ float[] Render(int block)
+ {
+ using var e = new NotaEngine();
+ e.SetBpm(120);
+ int t = e.AddPluginInstrumentTrack(idx);
+ e.AddMidiClip(t, 0.0, 4.0);
+ // Notes starting inside the long block's later pieces (beat 0.5 = 11025 frames).
+ e.SetClipNotes(t, 0, new[] { new NotaNote(60, 0.0, 1.0, 0.8f), new NotaNote(67, 0.2, 0.6, 0.7f), new NotaNote(72, 0.5, 0.5, 0.9f) });
+ const int N = 32768;
+ var outv = new float[N * 2];
+ var tmp = new float[block * 2];
+ e.Seek(0.0);
+ e.Play();
+ for (int done = 0; done < N;)
+ {
+ int m = Math.Min(block, N - done);
+ e.RenderOffline(tmp, m);
+ Array.Copy(tmp, 0, outv, done * 2, m * 2);
+ done += m;
+ }
+ e.StopTransport();
+ return outv;
+ }
+
+ var big = Render(16384);
+ var small = Render(512);
+ double diff = 0, sq = 0;
+ for (int i = 0; i < big.Length; i++)
+ {
+ diff = Math.Max(diff, Math.Abs(big[i] - small[i]));
+ sq += small[i] * (double)small[i];
+ }
+ double rms = Math.Sqrt(sq / big.Length);
+ // The later notes must sound in the second half of the first 16384 frames.
+ double late = 0;
+ for (int i = 11025 * 2; i < 16384 * 2; i++) late = Math.Max(late, Math.Abs(big[i]));
+ yield return (rms > 1e-3 && late > 1e-3 && diff < 1e-5,
+ $"a 16384-frame block plays in pieces like 512-frame blocks, notes in place (maxdiff {diff:G3}, rms {rms:F4})");
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 12d7839f..9e46658c 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -543,6 +543,15 @@ if (args.Length >= 1 && args[0] == "--instrument-chain")
return failures == 0 ? 0 : 1;
}
// Drum Rack one-shot pads, pad audition, warp off/on alone: `--pad-warp`. Also part of the full run.
+// Opt-in (needs a VST3 built and scanned): `--hosted-plugin <vst3 folder> <nota-scanworker>`.
+if (args.Length >= 3 && args[0] == "--hosted-plugin")
+{
+ Console.WriteLine("-- hosted plug-ins: copies + long blocks --");
+ foreach (var (ok, label) in HostedPluginTests.Run(args[1], args[2])) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "HOSTED PLUGIN PASSED" : $"HOSTED PLUGIN FAILED ({failures})");
+ return failures == 0 ? 0 : 1;
+}
+
if (args.Length >= 1 && args[0] == "--pad-warp")
{
Console.WriteLine("-- pads + warp toggle --");