diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html
index 1841e7031..5e817d8d8 100644
--- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html
+++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html
@@ -1768,7 +1768,7 @@
if(b.dataset.category){activeCategory=b.dataset.category;renderPluginBrowser();return}
if(b.dataset.group!==undefined){flash('Group selection — interface placeholder');return}
if(b.dataset.side){document.querySelectorAll('[data-side]').forEach(x=>x.classList.toggle('selected',x===b));if(b.dataset.side==='fx')setView('FX RACK');else setView('MIX');return}
- switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));}
+ switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'flowRoutingButton':case'flowRoutingButtonSecondary':if(typeof window.__arMixOpenRoutingLab==="function")window.__arMixOpenRoutingLab();else flash("Routing editor is available in the native desktop app");break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));}
});
// Deliberate double-click to edit a strip. Single-click only changes selection.
document.addEventListener('dblclick',e=>{const el=e.target.closest('[data-editstrip]');if(!el)return;
@@ -2030,7 +2030,12 @@
function focusOptions(){return channels.map((c,i)=>``).join('')}
function renderRackWorkspace(){let c=channels[currentChannel];let chain=normalChain(c);$('rackWorkspace').innerHTML=`
YOUR SOUND · CORE WORKFLOW
FX Rack — ${safeText(c.name)}
Build your signature vocal sound. Add, reorder, bypass, and store your VST chain.
04 · MASTERHardware L / RDirect authorized endpoint
Routing edits still require OUTPUT MUTE. Unchanged VST3 instances now retain state and tails when a route is re-applied. CUE/AUX hardware output patching and plugin latency compensation remain future gates.
`;
+ return;
+ }
+ $('rackWorkspace').innerHTML=`
NO TECHNICAL PATCHBAY REQUIRED
Signal Flow — See where your voice goes
A beginner-first view of the real-time audio path. Select your audio device in Setup.
01 · INPUTMicrophoneAudio Interface ASIO or WASAPI
➜
02 · FX CHAINVST3 PluginsEQ · Dynamics Reverb · Delay
➜
03 · MIXERMix & MonitorFader · Pan Master · Meters
➜
04 · OUTPUTSpeakers / StreamAudio Device Streaming bridge later
⚠ In this trial the audio flow is a visual concept; no microphone is captured and no audio is sent to a livestream.
`}
function openPluginBrowser(idx,isMaster=false){if(!isMaster){currentChannel=idx;pendingMasterSlot=null}activeCategory='All';$('pluginModal').classList.remove('hidden');$('pluginTarget').textContent=isMaster?'Adding to MASTER bus · demo FX catalog':'Adding to '+channels[idx].name+' · virtual effects catalog';$('pluginSearch').value='';renderPluginBrowser();$('pluginSearch').focus()}
function closePluginBrowser(){$('pluginModal').classList.add('hidden')}
function renderPluginBrowser(){document.querySelectorAll('[data-category]').forEach(b=>b.classList.toggle('active',b.dataset.category===activeCategory));const q=$('pluginSearch').value.trim().toLowerCase();let pool=pluginCatalog.filter(p=>(activeCategory==='All'||p.type===activeCategory)&&`${p.name} ${p.type} ${p.hint}`.toLowerCase().includes(q));$('pluginResults').innerHTML=pool.map(p=>``).join('')||'
No matching demo effects.
'}
diff --git a/docs/P1J_STABLE_FX_ROUTING_SESSION_20261029.md b/docs/P1J_STABLE_FX_ROUTING_SESSION_20261029.md
new file mode 100644
index 000000000..976c23223
--- /dev/null
+++ b/docs/P1J_STABLE_FX_ROUTING_SESSION_20261029.md
@@ -0,0 +1,26 @@
+# P1J — Stable VST3 lifecycle, acknowledged routing session, real Signal Flow entry
+Baseline: reconciled `main@abcdf2b9e8ee9d58a4da116c84c5bec382346dd2` (P1G, P1H, P1I 10-channel live fader/pan/mute/solo, latest merged GUI/Audio Setup/Snapshots). The standalone CH1 production path, Orbit, FX move/bypass, portable CH1 preset, 10-channel physical port attestation and hardware safety fence are unchanged.
+
+## Problem verified from code and field screenshot
+1. 10-channel native routing is opt-in; screenshot displaying `NATIVE CH1` and `CH1 NATIVE + UI PREVIEW` represents the ordinary CH1 mode, not activated 10-channel DSP. P1I wires live strip faders only when the native routing session is ACTIVE. Signal Flow previously displayed a concept even in the Windows host.
+2. `LiveDryRoutingLab::apply` rebuilt a graph and unconditionally created another VST3 instance per selected strip, even for a send change. Vendor plugin settings and reverb tails were lost; duplicate scans/preparations loaded the message thread.
+3. WebView route editor kept an independent draft not rehydrated from accepted engine configuration on reopen. Native CH1 faders and LAB faders can diverge unless native channelControls merge is respected.
+
+## Implemented
+- `LiveChannelFxGraph`: each immutable graph holds preprepared, shared **FxInstance** objects. Shared ownership copies **only on control thread**; audio callback dereferences a stable raw pointer, with zero heap/refcount/locks, and calls the actual JUCE AudioProcessor. Each instance owns its private MIDI scratch and vendor plugin, whose releaseResources runs on the control thread only after all old/new graph snapshots are safely retired. An atomic nonblocking try-enter guards vendor processing against unexpectedly overlapping callbacks: on contention, that strip is silenced instead of concurrently invoking the same VST3. C++ exceptions are caught inside the real callback and silently fail that strip (SEH/OS crashes remain outside this guarantee).
+- `RealtimeRoutePublisher::controlPrepared` permits the single control thread to inspect the current graph only if the device epoch + expected revision match. Never call this from RT.
+- On LAB APPLY, a matching **same-channel + identical catalog ID + same epoch + same device quantum** keeps the exact prior instance and vendor state. Changed/removed FX still instantiate/retire safely; old graph remains until all RT readers release. `fxReused` telemetry confirms the number carried forward and `fxCount` actual inserts. Rejected changes never replace previously published FX or routing.
+- Native `acceptedRoute` is updated only after successful publication, included in status/ACK on the message thread. On Routing editor open, WebView hydrates physical ports/FX IDs/sends from this authoritative ACK, then overlays the current live fader/pan/mute/solo values from `channelControls`. Never replace the in-progress editor draft on periodic meter telemetry.
+- `SIGNAL FLOW` tab in the Windows host now truthfully depicts the 10-channel native routing architecture and exposes two entry buttons to the same real Routing LAB. It does not bypass the explicit OUTPUT MUTE / DIRECT/epoch fence. Standalone demo keeps its separate honest preview.
+- C++ test extends existing native processor test with same-pointer identity, no duplicate prepare, parameter-processing continuity after publish, protection against stale IDs/revisions, old reader lease and deferred release, and no allocations during RT; Node UI contract verifies SSOT and stable FX design.
+
+## Real Windows hardware FAT acceptance
+- Start output muted. Verify DIRECT single-device ASIO/WASAPI with actual active input ports (minimum 1; CH2..10 can be assigned only from actual active masks). CH1 original FX rack must be empty before enabling LAB.
+- From top `SIGNAL FLOW` click `OPEN ROUTING MATRIX`, select physical input to CH1/CH2, choose native VST3 A / B, add internal sends, APPLY. Confirm `fxCount=2, fxReused=0`. Unmute at low volume, capture a stable reference.
+- Mute output, reopen via Signal Flow. Native state (physical pins, FX choices, sends, fader adjustments) must restore exactly. Change a SEND level/destination while keeping FX identities; APPLY. Confirm `fxReused=2`, unchanged FX parameters and reverb tail history, no duplicate scanning or reprepare. Unmute. Changes through the main console 10-channel faders must remain native.
+- Change just CH2 FX: expect `fxReused=1`; previous CH2 effect released safely after callback lease retires. Test failed plugin/module, stale revision/device swap, and STOP; no sound through unverified hardware output. For actual crackle, run #15 output-only/capture-only/direct isolation separately.
+
+## Release gates (NOT solved by synthetic CI)
+No full native mixer snapshot persistence across app restart yet; acceptedRoute is runtime message-thread session only. No 10 independent physical inputs unless device enabled, still uses 10 physical/BUS slots, one stereo-compatible VST3 per strip, one MAIN stereo output, no PDC, vendor GUIs/mono-only/sidechain/multi-FX or AUX/CUE outputs. Structural APPLY still requires OUTPUT MUTE, so this is not a fully uninterrupted DAW editing workflow. Out-of-process plugin crash isolation and #15 zero-FX hardware crackle remain unqualified. Windows MSVC/CTest + Chromium success cannot substitute for real hardware FAT.
+
+Next milestones: stable per-channel multi-insert rack with state serialization, 10 fixed INPUT strips + separate AUX/BUS graph and full output patches, live structural graph edits/crossfades, PDC.
diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h
index 2076c0c88..a9a049d7f 100644
--- a/engine/core/LiveChannelFxGraph.h
+++ b/engine/core/LiveChannelFxGraph.h
@@ -4,37 +4,81 @@
#include
#include
#include
+#include
#include
#include
#include
-// P1H: One immutable prepared audio graph owns its OWN native processors.
-// Neither the original CH1 graph nor another snapshot shares a processor
-// instance; old/new graph processors cannot run concurrently on one object.
-// Construction/preparation and destruction/releaseResources happen OFF RT.
-// Only process() runs in the audio callback. No per-channel threads or heaps.
+// P1J: routing plans are replaceable; vendor FX instances are NOT routing
+// plans. Identical catalog ID + same device epoch reuses the exact instance
+// (parameters, state, reverb tail, and private MIDI scratch) across revisions.
+// All shared_ptr bookkeeping occurs on CONTROL thread. Audio callback reads
+// immutable raw pointers and does no refcounting/allocation/locking.
+// An atomic try-enter prevents concurrent processing if a backend violates
+// single-render-callback ordering. Contention FAILS CLOSED, no spinning.
namespace armix::mixer {
class LiveChannelFxGraph final {
public:
static constexpr int channels=stripCount;
using Processor=juce::AudioProcessor;
- using FxBank=std::array,channels>;
+
+ struct FxInstance final {
+ std::unique_ptr processor;
+ juce::MidiBuffer midi;
+ const juce::String catalogId;
+ const juce::String name;
+ std::atomic_flag processing=ATOMIC_FLAG_INIT;
+ std::atomic contention{0};
+ std::atomic exceptions{0};
+
+ FxInstance(std::unique_ptr p,juce::String id,juce::String label)
+ : processor(std::move(p)),catalogId(std::move(id)),name(std::move(label)) {
+ midi.ensureSize(1024); // CONTROL, before publication
+ }
+ FxInstance(const FxInstance&)=delete;
+ FxInstance& operator=(const FxInstance&)=delete;
+ ~FxInstance() noexcept {
+ // Shared by old/new immutable snapshots; last owner drops ONLY on
+ // control-thread retirement after the final RT reader exits.
+ if(processor) {
+ try { processor->releaseResources(); }
+ catch(...) { /* vendor cleanup cannot unwind graph retirement */ }
+ }
+ }
+ void render(float* left,float* right,int samples) noexcept {
+ if(processing.test_and_set(std::memory_order_acquire)) {
+ contention.fetch_add(1,std::memory_order_relaxed);
+ juce::FloatVectorOperations::clear(left,samples);
+ juce::FloatVectorOperations::clear(right,samples);
+ return;
+ }
+ try {
+ float* planar[]{left,right};
+ juce::AudioBuffer buffer(planar,2,samples);
+ midi.clear();
+ processor->processBlock(buffer,midi);
+ } catch(...) {
+ // Vendor faults must never unwind through the JUCE callback.
+ // A SEH crash still requires out-of-process isolation.
+ exceptions.fetch_add(1,std::memory_order_relaxed);
+ juce::FloatVectorOperations::clear(left,samples);
+ juce::FloatVectorOperations::clear(right,samples);
+ }
+ processing.clear(std::memory_order_release);
+ }
+ };
+ using FxBank=std::array,channels>;
explicit LiveChannelFxGraph(const PreparedRenderGraph& plan,int frames,int pluginQuantum=512)
: block_(std::make_unique(plan,frames)),
pluginQuantum_(std::clamp(pluginQuantum,32,PreparedMixerBlock::hardFrameLimit)) {
- // P1H callers without live edits retain original compiled faders.
for(int i=0;ireleaseResources();
- }
+ ~LiveChannelFxGraph() noexcept=default;
int capacity() const noexcept{return block_?block_->capacity():0;}
int maxFramesPerPlugin() const noexcept {return pluginQuantum_;}
@@ -45,35 +89,52 @@ class LiveChannelFxGraph final {
}
const juce::String& insertName(int strip) const noexcept {
static const juce::String empty;
- return strip>=0&&strip=0&&stripname:empty;
+ }
+ const juce::String& insertId(int strip) const noexcept {
+ static const juce::String empty;
+ return strip>=0&&stripcatalogId:empty;
+ }
+ const Processor* instanceProcessor(int strip) const noexcept {
+ return strip>=0&&stripprocessor.get():nullptr;
+ }
+
+ // CONTROL thread: called BEFORE publication. Only same-strip and
+ // identical catalog identity can be reused; the caller verifies the
+ // same device epoch, sample-rate and prepared audio quantum.
+ bool reuse(int strip,const LiveChannelFxGraph& previous,
+ const juce::String& catalogId) {
+ if(strip<0||strip>=channels||catalogId.isEmpty()||
+ processors_[strip]||!previous.processors_[strip]||
+ previous.insertId(strip)!=catalogId||
+ previous.pluginQuantum_!=pluginQuantum_)return false;
+ processors_[strip]=previous.processors_[strip]; // CONTROL only
+ ++activeInserts_;
+ return true;
}
- // CONTROL only. Ownership of already-negotiated, prepared processor is
- // transferred exactly once. Slot may never be replaced after publication.
bool install(int strip,std::unique_ptr processor,
- const juce::String& name) {
- if(strip<0 || strip>=channels || !processor || processors_[strip])
+ const juce::String& name,const juce::String& catalogId={}) {
+ if(strip<0||strip>=channels||!processor||processors_[strip])
return false;
- midi_[strip].ensureSize(1024); // prevent normal MIDI allocations
- names_[strip]=name;
- processors_[strip]=std::move(processor);
+ processors_[strip]=std::make_shared(
+ std::move(processor),catalogId,name);
++activeInserts_;
return true;
}
- // The exact P1D callback: physical input -> independent per-channel VST3
- // -> PRE send -> fader/pan -> POST send -> AUX BUS -> MAIN. The native FX
- // sees real samples and never changes the original CH1 plugin objects.
+ // One actual physical -> FX -> PRE send -> fader -> POST send -> BUS ->
+ // master path. FX lifetimes are external to the immutable routing plan.
bool process(const float* const* physical,int inputs,
float* left,float* right,int frames,
RenderLevels* levels=nullptr) noexcept {
auto channelFx=[this](int strip,float* l,float* r,int samples) noexcept {
- if(strip<0||strip>=channels || !processors_[strip])return;
- float* planar[2]={l,r};
- juce::AudioBuffer buffer(planar,2,samples);
- auto& midi=midi_[strip];
- midi.clear();
- processors_[strip]->processBlock(buffer,midi);
+ if(strip<0||strip>=channels)return;
+ auto* instance=processors_[strip].get(); // no shared_ptr copy in RT
+ if(instance)instance->render(l,r,samples);
};
return block_->process(physical,inputs,left,right,frames,channelFx,levels,&controls_);
}
@@ -82,8 +143,6 @@ class LiveChannelFxGraph final {
std::unique_ptr block_;
RealtimeStripControls controls_ {};
FxBank processors_ {};
- std::array midi_ {};
- std::array names_ {};
int activeInserts_=0;
int pluginQuantum_=512;
};
diff --git a/engine/core/RealtimeRoutePublisher.h b/engine/core/RealtimeRoutePublisher.h
index c9781ad0e..5c2452392 100644
--- a/engine/core/RealtimeRoutePublisher.h
+++ b/engine/core/RealtimeRoutePublisher.h
@@ -130,6 +130,16 @@ class RealtimeRoutePublisher final {
return false;
return update(*owned_->prepared);
}
+ // CONTROL thread only. The owner stays alive while compiling a candidate.
+ // NEVER cache the returned pointer in the audio callback or across a
+ // subsequent publication. Use only immutable identity/FX shared ownership.
+ const Prepared* controlPrepared(std::uint64_t epoch,
+ std::uint64_t expectedRevision) const noexcept {
+ return owned_ && owned_->prepared && revision_==expectedRevision &&
+ owned_->deviceEpoch==epoch &&
+ owned_->graphRevision==expectedRevision
+ ?owned_->prepared.get():nullptr;
+ }
[[nodiscard]] ReadLease acquire() noexcept {return ReadLease(*this);}
std::uint64_t lastRevision() const noexcept {return revision_;} // CONTROL
std::size_t pendingRetirements() const noexcept {return retiredCount_;} // CONTROL
diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h
index 23b867547..816234523 100644
--- a/src/LiveDryRoutingLab.h
+++ b/src/LiveDryRoutingLab.h
@@ -78,6 +78,10 @@ class LiveDryRoutingLab final {
topologyFault_.store(false,std::memory_order_release);
sendCount_.store(0,std::memory_order_relaxed);
fxCount_.store(0,std::memory_order_relaxed);
+ fxReused_.store(0,std::memory_order_relaxed);
+ // Device lifecycle callback may run off the message thread.
+ // acceptedRoute_ is a JUCE var owned by the CONTROL thread and must
+ // never be mutated from the device thread. Epoch gates hide stale data.
for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed);
peakL_.store(0.f,std::memory_order_relaxed);
peakR_.store(0.f,std::memory_order_relaxed);
@@ -153,15 +157,24 @@ class LiveDryRoutingLab final {
proposed[i].mute,proposed[i].solo))
return "Cannot prepare native channel controls";
}
- // Every VST3 is instantiated and prepared on the control thread.
- // A graph has private processor instances: a retiring snapshot can
- // NEVER share a processBlock call with a newly published snapshot.
- int insertCount=0;
+ // P1J: a structural APPLY owns only the new topology. Retain a
+ // same-strip/same-ID prepared VST3 from this device epoch, including
+ // its vendor parameter state and reverb/delay tail. A prior snapshot
+ // may remain leased by one callback: shared_ptr copy is CONTROL only,
+ // and FxInstance has an atomic try-enter to guard against overlap.
+ // Never reuse across a device epoch or changed device quantum.
+ const auto* prior=publisher_.controlPrepared(currentEpoch,expectedRevision);
+ int insertCount=0,reusedCount=0;
for(int lane=0;laneprepared->reuse(lane,*prior,req.id)) {
+ ++insertCount;
+ ++reusedCount;
+ continue; // NO disk scan, NO plugin prepare, NO tail/state reset
+ }
if(!(sampleRate>0.0) || deviceFrames<=0)
return "Audio device sample rate or buffer size is invalid";
auto* fmt=formats.getFormat(0);
@@ -197,7 +210,7 @@ class LiveDryRoutingLab final {
if(instance->getLatencySamples()!=0)
return "CH "+juce::String(lane+1)+
": this VST3 reports latency; choose zero-latency mode until PDC is implemented";
- if(!next->prepared->install(lane,std::move(instance),chosen->name))
+ if(!next->prepared->install(lane,std::move(instance),chosen->name,req.id))
return "CH "+juce::String(lane+1)+": duplicate or invalid VST3 insert";
++insertCount;
}
@@ -212,6 +225,11 @@ class LiveDryRoutingLab final {
enabled_.store(true,std::memory_order_release);
sendCount_.store(sends.count,std::memory_order_relaxed);
fxCount_.store(insertCount,std::memory_order_relaxed);
+ fxReused_.store(reusedCount,std::memory_order_relaxed);
+ // Native control state is the routing SSOT. The GUI only
+ // displays an acknowledged immutable copy; draft changes
+ // never update this until graph publication succeeds.
+ acceptedRoute_=command;
channelEdits_=proposed; // control thread SSOT for this route revision
for(int i=0;isetProperty("peakR",peakR_.load(std::memory_order_relaxed));
out->setProperty("sendCount",sendCount_.load(std::memory_order_relaxed));
out->setProperty("fxCount",fxCount_.load(std::memory_order_relaxed));
+ out->setProperty("fxReused",fxReused_.load(std::memory_order_relaxed));
+ // Only the message thread calls status(), never the audio callback.
+ if(active() && ready())out->setProperty("acceptedRoute",acceptedRoute_);
juce::Array controls,fxNames;
for(int i=0;i channelEdits_{}; // JUCE message thread only
std::array channelFxNames_{}; // status/control thread only
+ juce::var acceptedRoute_; // native ACK only, no UI preview/localStorage truth
// All data shared between JUCE device lifecycle and GUI/control reads
// are atomic; the callback never enumerates masks or channel names.
std::array,armix::device::LiveInputPortRegistry::limit> enabledPorts_{};
@@ -448,6 +472,7 @@ class LiveDryRoutingLab final {
std::atomic peakL_{0.f},peakR_{0.f};
std::atomic sendCount_{0};
std::atomic fxCount_{0};
+ std::atomic fxReused_{0};
std::array,count> channelPeaks_{};
// Exclusive render-producer state. Bounded fade starts from the exact
// previously output sample, preventing a topology switch discontinuity.
diff --git a/tests/live_channel_fx_graph_test.cpp b/tests/live_channel_fx_graph_test.cpp
index f994fe104..f05098fb8 100644
--- a/tests/live_channel_fx_graph_test.cpp
+++ b/tests/live_channel_fx_graph_test.cpp
@@ -53,7 +53,7 @@ class GainFx final : public juce::AudioProcessor {
float gain_;
};
static bool near(float x,float y){return std::abs(x-y)<0.0001f;}
-static std::unique_ptr makeGraph(float firstFx,float returnFx) {
+static std::unique_ptr makeGraph(float firstFx,float returnFx,bool withFx=true) {
ChannelRoutingConfig config;
config.stripsAndMaster.strips[0]={SourceMode::mono,2,-1,0.f,0.f,false,false};
config.stripsAndMaster.strips[1]={SourceMode::disconnected,-1,-1,1.f,0.f,false,false};
@@ -66,14 +66,16 @@ static std::unique_ptr makeGraph(float firstFx,float returnF
constexpr std::array ports{2,5,9};
assert(PreparedRenderGraph::compile(config,ports,sends,route,error));
auto graph=std::make_unique(route,32,8);
- auto a=std::make_unique(firstFx);
- auto b=std::make_unique(returnFx);
- a->prepareToPlay(48000,8);
- b->prepareToPlay(48000,8);
- assert(graph->install(0,std::move(a),"CH1 FX"));
- assert(graph->install(1,std::move(b),"BUS FX"));
- assert(!graph->install(1,std::make_unique(2.f),"duplicate"));
- assert(graph->activeInserts()==2);
+ if(withFx) {
+ auto a=std::make_unique(firstFx);
+ auto b=std::make_unique(returnFx);
+ a->prepareToPlay(48000,8);
+ b->prepareToPlay(48000,8);
+ assert(graph->install(0,std::move(a),"CH1 FX","vst3-ch1-id"));
+ assert(graph->install(1,std::move(b),"BUS FX","vst3-bus-id"));
+ assert(!graph->install(1,std::make_unique(2.f),"duplicate"));
+ assert(graph->activeInserts()==2);
+ }
assert(graph->maxFramesPerPlugin()==32); // clamp minimum safe plugin quantum
return graph;
}
@@ -126,6 +128,58 @@ int main() {
assert(routes.pollRetirement());
assert(GainFx::living==0);
assert(GainFx::released==4);
+ // P1J: route revision 2 reuses exact native VST3s from revision 1.
+ // No duplicate creation, prepare/release, state loss, or RT heap use.
+ // Retirement of old snapshot must NOT release shared FX still needed.
+ {
+ Publication stable;
+ auto one=std::make_unique();
+ one->deviceEpoch=71;one->graphRevision=1;
+ one->prepared=makeGraph(3.f,2.f);
+ assert(stable.publish(std::move(one),0,71)==Publication::Result::applied);
+ auto* previous=stable.controlPrepared(71,1);
+ assert(previous && previous->activeInserts()==2);
+ assert(!stable.controlPrepared(72,1));
+ assert(!stable.controlPrepared(71,3));
+ const auto* identity=previous->instanceProcessor(0);
+ const auto* busIdentity=previous->instanceProcessor(1);
+ const int livingBefore=GainFx::living;
+ const int preparedBefore=GainFx::prepared;
+ const int releasedBefore=GainFx::released;
+ auto next=std::make_unique();
+ next->deviceEpoch=71;next->graphRevision=2;
+ next->prepared=makeGraph(6.f,9.f,false);
+ assert(!next->prepared->reuse(0,*previous,"wrong-vst3"));
+ assert(next->prepared->reuse(0,*previous,"vst3-ch1-id"));
+ assert(next->prepared->reuse(1,*previous,"vst3-bus-id"));
+ assert(!next->prepared->reuse(0,*previous,"vst3-ch1-id"));
+ assert(next->prepared->activeInserts()==2);
+ assert(next->prepared->instanceProcessor(0)==identity);
+ assert(next->prepared->instanceProcessor(1)==busIdentity);
+ assert(GainFx::living==livingBefore&&GainFx::prepared==preparedBefore);
+ {
+ auto oldReader=stable.acquire();
+ assert(oldReader.get(71));
+ assert(stable.publish(std::move(next),1,71)==Publication::Result::applied);
+ assert(!stable.pollRetirement());
+ }
+ assert(stable.pollRetirement());
+ assert(GainFx::living==livingBefore);
+ assert(GainFx::released==releasedBefore);
+ {
+ auto live=stable.acquire();
+ assert(live.get(71));
+ assert(live.get(71)->prepared->instanceProcessor(0)==identity);
+ const auto allocated=heapCalls.load(std::memory_order_relaxed);
+ assert(live.get(71)->prepared->process(phys,3,l.data(),r.data(),4));
+ assert(heapCalls.load(std::memory_order_relaxed)==allocated);
+ assert(near(l[0],1.2f)); // original FX gain preserved
+ }
+ stable.unpublish();
+ assert(stable.pollRetirement());
+ assert(GainFx::living==0);
+ assert(GainFx::released==releasedBefore+2);
+ }
// Tests above use a real JUCE AudioProcessor processing seam. Vendor
// VST3 formats and sound quality require separate Windows hardware FAT.
}
diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs
index bf606ef54..6904dee78 100644
--- a/tests/live_routing_ui_contract_test.mjs
+++ b/tests/live_routing_ui_contract_test.mjs
@@ -88,8 +88,8 @@ test("P1G is real native BUS/send, not a cosmetic routing picker",()=>{
test("P1H independently instantiates and processes real JUCE FX in 10 native lanes",()=>{
const fx=readFileSync(new URL("../engine/core/LiveChannelFxGraph.h",import.meta.url),"utf8");
- assert.match(fx,/std::array,channels>/);
- assert.match(fx,/processors_\[strip\]->processBlock\(buffer,midi\)/);
+ assert.match(fx,/std::array,channels>/);
+ assert.match(fx,/processor->processBlock\(buffer,midi\)/);
assert.match(fx,/processor->releaseResources\(\)/);
assert.match(lab,/std::make_unique\(plan/);
assert.match(lab,/formats\.createPluginInstance/);
@@ -123,3 +123,28 @@ test("P1I binds premium 10CH console to REAL native RT graph without FX restart"
assert.match(bridge,/lab\.channelPeaks/);
assert.match(bridge,/data-native-routing-lab/);
});
+
+test("P1J keeps real per-strip VST3 identity and tails across routing-only APPLY",()=>{
+ const fx=readFileSync(new URL("../engine/core/LiveChannelFxGraph.h",import.meta.url),"utf8");
+ const publisher=readFileSync(new URL("../engine/core/RealtimeRoutePublisher.h",import.meta.url),"utf8");
+ const app=readFileSync(new URL("../web/app.js",import.meta.url),"utf8");
+ assert.match(fx,/struct FxInstance final/);
+ assert.match(fx,/std::shared_ptr/);
+ assert.match(fx,/processing\.test_and_set/);
+ assert.match(fx,/processing\.clear/);
+ assert.match(fx,/bool reuse\(int strip,const LiveChannelFxGraph& previous/);
+ assert.match(fx,/previous\.insertId\(strip\)!=catalogId/);
+ assert.match(publisher,/controlPrepared\(std::uint64_t epoch/);
+ assert.match(lab,/publisher_\.controlPrepared\(currentEpoch,expectedRevision\)/);
+ assert.match(lab,/next->prepared->reuse\(lane,\*prior,req\.id\)/);
+ assert.match(lab,/continue; \/\/ NO disk scan/);
+ assert.match(lab,/fxReused_\.store\(reusedCount/);
+ assert.match(lab,/acceptedRoute_=command/);
+ assert.match(lab,/setProperty\("acceptedRoute",acceptedRoute_\)/);
+ assert.match(ui,/hydrateAcceptedRoute/);
+ assert.match(ui,/saved\.deviceEpoch/);
+ assert.match(ui,/window\.__arMixOpenRoutingLab=openRoutingLab/);
+ assert.match(app,/id="flowRoutingButton"/);
+ assert.match(app,/Independent VST3/);
+ assert.match(ui,/NATIVE ACK:.*preserved/);
+});
diff --git a/web/app.js b/web/app.js
index 3bdf89fd6..834deeb6e 100644
--- a/web/app.js
+++ b/web/app.js
@@ -422,7 +422,7 @@ document.addEventListener('click',e=>{const b=e.target.closest('button,[data-cho
if(b.dataset.category){activeCategory=b.dataset.category;renderPluginBrowser();return}
if(b.dataset.group!==undefined){flash('Group selection — interface placeholder');return}
if(b.dataset.side){document.querySelectorAll('[data-side]').forEach(x=>x.classList.toggle('selected',x===b));if(b.dataset.side==='fx')setView('FX RACK');else setView('MIX');return}
- switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));}
+ switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'flowRoutingButton':case'flowRoutingButtonSecondary':if(typeof window.__arMixOpenRoutingLab==="function")window.__arMixOpenRoutingLab();else flash("Routing editor is available in the native desktop app");break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));}
});
// Deliberate double-click to edit a strip. Single-click only changes selection.
document.addEventListener('dblclick',e=>{const el=e.target.closest('[data-editstrip]');if(!el)return;
@@ -684,7 +684,12 @@ function setChain(ch,chain){ch.inserts=chain.slice(0,8);renderMixer();if(view===
function focusOptions(){return channels.map((c,i)=>``).join('')}
function renderRackWorkspace(){let c=channels[currentChannel];let chain=normalChain(c);$('rackWorkspace').innerHTML=`
YOUR SOUND · CORE WORKFLOW
FX Rack — ${safeText(c.name)}
Build your signature vocal sound. Add, reorder, bypass, and store your VST chain.
04 · MASTERHardware L / RDirect authorized endpoint
Routing edits still require OUTPUT MUTE. Unchanged VST3 instances now retain state and tails when a route is re-applied. CUE/AUX hardware output patching and plugin latency compensation remain future gates.
`;
+ return;
+ }
+ $('rackWorkspace').innerHTML=`
NO TECHNICAL PATCHBAY REQUIRED
Signal Flow — See where your voice goes
A beginner-first view of the real-time audio path. Select your audio device in Setup.
01 · INPUTMicrophoneAudio Interface ASIO or WASAPI
➜
02 · FX CHAINVST3 PluginsEQ · Dynamics Reverb · Delay
➜
03 · MIXERMix & MonitorFader · Pan Master · Meters
➜
04 · OUTPUTSpeakers / StreamAudio Device Streaming bridge later
⚠ In this trial the audio flow is a visual concept; no microphone is captured and no audio is sent to a livestream.
`}
function openPluginBrowser(idx,isMaster=false){if(!isMaster){currentChannel=idx;pendingMasterSlot=null}activeCategory='All';$('pluginModal').classList.remove('hidden');$('pluginTarget').textContent=isMaster?'Adding to MASTER bus · demo FX catalog':'Adding to '+channels[idx].name+' · virtual effects catalog';$('pluginSearch').value='';renderPluginBrowser();$('pluginSearch').focus()}
function closePluginBrowser(){$('pluginModal').classList.add('hidden')}
function renderPluginBrowser(){document.querySelectorAll('[data-category]').forEach(b=>b.classList.toggle('active',b.dataset.category===activeCategory));const q=$('pluginSearch').value.trim().toLowerCase();let pool=pluginCatalog.filter(p=>(activeCategory==='All'||p.type===activeCategory)&&`${p.name} ${p.type} ${p.hint}`.toLowerCase().includes(q));$('pluginResults').innerHTML=pool.map(p=>``).join('')||'
No matching demo effects.
'}
diff --git a/web/monitor.js b/web/monitor.js
index 52cd92594..04e869cc4 100644
--- a/web/monitor.js
+++ b/web/monitor.js
@@ -109,6 +109,28 @@
catalogItems=items.filter(p=>p&&typeof p.id==="string");
if(routeOverlay.classList.contains("open"))drawRoutes();
});
+ // Rehydrate only from the native ACK/SSOT when opening the editor.
+ // Browsing a panel or reloading the WebView must never accidentally erase
+ // an already published port/FX/send arrangement with stale UI defaults.
+ function hydrateAcceptedRoute(){
+ const d=state.dryRoutingLab||{},saved=d.acceptedRoute;
+ invalidateDraftForNewDevice(Number(d.epoch)||0);
+ if(!d.ready||!saved||Number(saved.deviceEpoch)!==Number(d.epoch)||
+ !Array.isArray(saved.channels)||saved.channels.length!==10)return false;
+ const keys=["mode","left","right","gain","pan","main","mute","solo","fxId"];
+ for(let i=0;i<10;i++){
+ const source=saved.channels[i];
+ if(!source||typeof source!=="object")return false;
+ for(const key of keys)
+ if(Object.prototype.hasOwnProperty.call(source,key))
+ draftRoutes[i][key]=source[key];
+ }
+ draftSends.length=0;
+ if(Array.isArray(saved.sends))
+ for(const send of saved.sends.slice(0,32))
+ if(send&&typeof send==="object")draftSends.push({...send});
+ return true;
+ }
function syncNativeLevelsToRouteDraft(){
const d=state.dryRoutingLab||{};
if(!d.active||!d.ready||!Array.isArray(d.channelControls))return;
@@ -209,12 +231,17 @@
" · device epoch "+(d.epoch||0)+" · rev "+(d.revision||0)+
" · "+(d.ports?.length||0)+" enabled inputs · "+(d.outputPorts?.length||0)+" outputs · "+(d.sendCount||0)+" live sends");
}
- document.getElementById("arOpenRoutingLab").addEventListener("click",()=>{
+ function openRoutingLab(){
+ hydrateAcceptedRoute();
syncNativeLevelsToRouteDraft();
drawRoutes();
routeOverlay.classList.add("open");
overlay.classList.remove("open");
- });
+ }
+ // Exposed only to the existing native SIGNAL FLOW GUI; does not publish a
+ // routing transaction or bypass the output-MUTE operator safety gate.
+ window.__arMixOpenRoutingLab=openRoutingLab;
+ document.getElementById("arOpenRoutingLab").addEventListener("click",openRoutingLab);
document.getElementById("arRouteClose").addEventListener("click",()=>routeOverlay.classList.remove("open"));
routeOverlay.addEventListener("click",e=>{if(e.target===routeOverlay)routeOverlay.classList.remove("open");});
document.getElementById("arRouteApply").addEventListener("click",()=>{
@@ -241,7 +268,7 @@
if(result && typeof result==="object" && "epoch" in result)state.dryRoutingLab=result;
document.getElementById("arRouteFeedback").textContent=
reply?.ok===false?("REJECTED · "+(reply.error||"Invalid route")):
- result.active?"NATIVE ACK: "+(result.fxCount||0)+" INDEPENDENT VST3 · "+(result.sendCount||0)+" SENDS · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety";
+ result.active?"NATIVE ACK: "+(result.fxCount||0)+" VST3 ("+(result.fxReused||0)+" preserved) · "+(result.sendCount||0)+" SENDS · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety";
updateRouteLabIdentity();
});