From dddb6cda235233cff7917b802f4818fa1d752e27 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:07:42 +0700 Subject: [PATCH 01/13] feat(P1J): stable native VST3 ownership across routing revisions; zero-lock RT processing and deferred retirement --- engine/core/LiveChannelFxGraph.h | 118 +++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 31 deletions(-) diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 2076c0c88..e4a50e5cd 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -4,37 +4,78 @@ #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)processor->releaseResources(); + } + 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 +86,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 +140,6 @@ class LiveChannelFxGraph final { std::unique_ptr block_; RealtimeStripControls controls_ {}; FxBank processors_ {}; - std::array midi_ {}; - std::array names_ {}; int activeInserts_=0; int pluginQuantum_=512; }; From 9a7a7a3a1843d31852dd50acfe96cb687d39b22b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:07:51 +0700 Subject: [PATCH 02/13] feat(P1J): guarded control-thread access for retaining unchanged FX across graph publishes --- engine/core/RealtimeRoutePublisher.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 From 4528dd10cda70bbb8de342998d9b2e95ba150565 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:08:16 +0700 Subject: [PATCH 03/13] feat(P1J): preserve unchanged native VST3 and route SSOT across structural APPLY; report reuse in ACK --- src/LiveDryRoutingLab.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 23b867547..2ef87b55a 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -78,6 +78,8 @@ 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); + acceptedRoute_=juce::var(); 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 +155,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 +208,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 +223,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 +468,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. From 1450e7b956a5832cca5c656a909bff89eaca8f9b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:09:00 +0700 Subject: [PATCH 04/13] feat(P1J GUI): hydrate routing editor from authoritative native ACK and expose editor through Signal Flow --- web/monitor.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) 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(); }); From 42cab30b7b359a76eb88b7ca8ffc330b28980983 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:09:24 +0700 Subject: [PATCH 05/13] feat(P1J GUI): real SIGNAL FLOW page opens native routing instead of showing conceptual preview --- web/app.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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.

● AUDIO INPUT · ${safeText(c.name)}
↓
${chain.map((name,i)=>`
${String(i+1).padStart(2,'0')}${safeText(name)}${safeText(pluginCatalog.find(p=>p.name===name)?.hint||'VST3 plugin · mock chain state')}
↓
`).join('')}
↓
◎ OUTPUT · MASTER / STREAM
${pluginEditorIndex!==null&&pluginEditorIndex

Ready-to-use Sound

Start with a preset, then personalize your FX chain. No complex routing required.

${['Clean Vocal','Warm Karaoke','Live Broadcast'].map(s=>``).join('')}

Make it sound better

Recommended signal path:

Noise Gate → EQ → Compressor → De-Esser → Reverb

Demo status

Plugin names and bypass buttons currently change visual state only. Installed VST3 scanning and DSP are scheduled for the native engine phase.

`}`} function pluginInspector(ch,slot){const name=normalChain(channels[ch])[slot],v=getFxParams(ch,slot);return `
FX EDITOR · DEMO PARAMETERS

${safeText(name)}

These generic controls demonstrate the editing and preset workflow. The real VST3 editor will replace them when connected.

`} -function renderSignalFlow(){$('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 renderSignalFlow(){ + if(window.__JUCE__?.backend?.emitEvent){ + $('rackWorkspace').innerHTML=`
ARSONMIX · NATIVE ROUTING

Signal Flow — 10 Native Channels

Physical inputs → native VST3 → PRE/POST sends → BUS returns → MASTER. All routing changes use the same live engine and hardware epoch.

01 · DEVICEVerified ASIO/WASAPIActual enabled port mask
➜
02 · CHANNELS10 Native StripsIndependent VST3 + live controls
➜
03 · BUSPRE/POST SendsCycle-validated internal returns
➜
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.

'} From 9532bfec55333b7f2e77bb0301eaad872de7a29d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:09:46 +0700 Subject: [PATCH 06/13] build(gui): preserve offline standalone Signal Flow parity with native routing panel entry --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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.

● AUDIO INPUT · ${safeText(c.name)}
↓
${chain.map((name,i)=>`
${String(i+1).padStart(2,'0')}${safeText(name)}${safeText(pluginCatalog.find(p=>p.name===name)?.hint||'VST3 plugin · mock chain state')}
↓
`).join('')}
↓
◎ OUTPUT · MASTER / STREAM
${pluginEditorIndex!==null&&pluginEditorIndex

Ready-to-use Sound

Start with a preset, then personalize your FX chain. No complex routing required.

${['Clean Vocal','Warm Karaoke','Live Broadcast'].map(s=>``).join('')}

Make it sound better

Recommended signal path:

Noise Gate → EQ → Compressor → De-Esser → Reverb

Demo status

Plugin names and bypass buttons currently change visual state only. Installed VST3 scanning and DSP are scheduled for the native engine phase.

`}`} function pluginInspector(ch,slot){const name=normalChain(channels[ch])[slot],v=getFxParams(ch,slot);return `
FX EDITOR · DEMO PARAMETERS

${safeText(name)}

These generic controls demonstrate the editing and preset workflow. The real VST3 editor will replace them when connected.

`} -function renderSignalFlow(){$('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 renderSignalFlow(){ + if(window.__JUCE__?.backend?.emitEvent){ + $('rackWorkspace').innerHTML=`
ARSONMIX · NATIVE ROUTING

Signal Flow — 10 Native Channels

Physical inputs → native VST3 → PRE/POST sends → BUS returns → MASTER. All routing changes use the same live engine and hardware epoch.

01 · DEVICEVerified ASIO/WASAPIActual enabled port mask
➜
02 · CHANNELS10 Native StripsIndependent VST3 + live controls
➜
03 · BUSPRE/POST SendsCycle-validated internal returns
➜
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.

'} From 313f7780aa58469eee3ee23ee07ba06b84c66d9a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:10:14 +0700 Subject: [PATCH 07/13] test(P1J): real AudioProcessor identities and processing tails survive graph swap; retirement and RT remain safe --- tests/live_channel_fx_graph_test.cpp | 72 ++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 9 deletions(-) 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. } From c8f1b476fb757886e94accb165ad0952af8db692 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:10:26 +0700 Subject: [PATCH 08/13] test(P1J): contract native FX reuse, accepted route SSOT, and Signal Flow editor entry --- tests/live_routing_ui_contract_test.mjs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index bf606ef54..9c4d68b8f 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -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,/native VST3/i); + assert.match(ui,/NATIVE ACK:.*preserved/); +}); From ffaec7db7ff638855e5b8b057bc64fd348a4841b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:10:56 +0700 Subject: [PATCH 09/13] docs(P1J): native shared FX ownership, routing SSOT, real Signal Flow, precise FAT and remaining gates --- .../P1J_STABLE_FX_ROUTING_SESSION_20261029.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/P1J_STABLE_FX_ROUTING_SESSION_20261029.md 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. From 733d53ad280c8950db4e823519ec6f0b1082858d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:11:53 +0700 Subject: [PATCH 10/13] test(P1J): update legacy P1H shape contracts for stable shared FX instance ownership --- tests/live_routing_ui_contract_test.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index 9c4d68b8f..dabfac332 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -88,9 +88,9 @@ 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,/processor->releaseResources\(\)/); + assert.match(fx,/std::array,channels>/); + assert.match(fx,/processor->processBlock\(buffer,midi\)/); + assert.match(fx,/if\(processor\)processor->releaseResources\(\)/); assert.match(lab,/std::make_unique\(plan/); assert.match(lab,/formats\.createPluginInstance/); assert.match(lab,/prepareStereoEffectLayout/); @@ -145,6 +145,6 @@ test("P1J keeps real per-strip VST3 identity and tails across routing-only APPLY assert.match(ui,/saved\.deviceEpoch/); assert.match(ui,/window\.__arMixOpenRoutingLab=openRoutingLab/); assert.match(app,/id="flowRoutingButton"/); - assert.match(app,/native VST3/i); + assert.match(app,/Independent VST3/); assert.match(ui,/NATIVE ACK:.*preserved/); }); From 30ab2b608c881eb0f3cef356443d262c4b248286 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:12:54 +0700 Subject: [PATCH 11/13] safety(P1J): shield control-thread graph retirement from throwing vendor releaseResources --- engine/core/LiveChannelFxGraph.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index e4a50e5cd..a9a049d7f 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -40,7 +40,10 @@ class LiveChannelFxGraph final { ~FxInstance() noexcept { // Shared by old/new immutable snapshots; last owner drops ONLY on // control-thread retirement after the final RT reader exits. - if(processor)processor->releaseResources(); + 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)) { From 0e594e324248f0319a760c0112ddf246ccd04f3e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:14:22 +0700 Subject: [PATCH 12/13] test(P1J): contract accepts guarded vendor releaseResources cleanup during graph retirement --- tests/live_routing_ui_contract_test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index dabfac332..6904dee78 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -90,7 +90,7 @@ test("P1H independently instantiates and processes real JUCE FX in 10 native lan const fx=readFileSync(new URL("../engine/core/LiveChannelFxGraph.h",import.meta.url),"utf8"); assert.match(fx,/std::array,channels>/); assert.match(fx,/processor->processBlock\(buffer,midi\)/); - assert.match(fx,/if\(processor\)processor->releaseResources\(\)/); + assert.match(fx,/processor->releaseResources\(\)/); assert.match(lab,/std::make_unique\(plan/); assert.match(lab,/formats\.createPluginInstance/); assert.match(lab,/prepareStereoEffectLayout/); From 05d584552ef9ef0180ac70ee0addaf80f1ea1945 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:15:55 +0700 Subject: [PATCH 13/13] fix(P1J): keep non-atomic native route SSOT on message thread, never mutate juce::var in deviceStopped callback --- src/LiveDryRoutingLab.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 2ef87b55a..816234523 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -79,7 +79,9 @@ class LiveDryRoutingLab final { sendCount_.store(0,std::memory_order_relaxed); fxCount_.store(0,std::memory_order_relaxed); fxReused_.store(0,std::memory_order_relaxed); - acceptedRoute_=juce::var(); + // 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); @@ -280,6 +282,8 @@ class LiveDryRoutingLab final { peakR_.store(0.f,std::memory_order_relaxed); sendCount_.store(0,std::memory_order_relaxed); fxCount_.store(0,std::memory_order_relaxed); + fxReused_.store(0,std::memory_order_relaxed); + acceptedRoute_=juce::var(); // control-thread STOP only for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed); } void poll() noexcept {publisher_.pollRetirement();} // message thread