diff --git a/docs/R0_UNIFIED_CH1_LANE_MILESTONE_20261029.md b/docs/R0_UNIFIED_CH1_LANE_MILESTONE_20261029.md new file mode 100644 index 000000000..e834184c7 --- /dev/null +++ b/docs/R0_UNIFIED_CH1_LANE_MILESTONE_20261029.md @@ -0,0 +1,22 @@ +# R0A — Execute existing CH1 vendor FX inside 10CH native routing render + +Baseline `81c892f39996689c63b5704dcc060a9c42f0339d`; owner production mandate: [#143](https://github.com/masarray/arsonmix/issues/143). + +## Delivered (native integration, not a cosmetic LAB rename) + +- `LiveChannelFxGraph` now has a strictly optional, callback-scoped, non-owning **CH1 external insert lane**. The host supplies its existing `LiveGraphHandoff::Cycle` lease while rendering native 10CH+4AUX: no second output mix, no second host, no VST instance copy, no new realtime allocation/lock. +- The CH1 multi-insert rack is run in the same CH1 PRE/POST send/master topology, with exactly the original processor addresses and Orbit parameter ownership. Pre-existing vendor settings/tails are not reinitialized on route apply. Existing per-insert bypass envelopes execute in this lane. +- Native apply refuses duplicate CH1 inserts and any latency-reporting CH1 processor (including bypassed) until PDC exists. Re-enabling latent plugins during active routing is independently rejected. +- DRY-only Show capture now checks the borrowed legacy CH1 FX count, not only the separate Routing LAB `fxCount`; missing count also fails closed. GUI SAVE gate and native regression test enforce this. Existing physical device/epoch, muted structural APPLY, graph revision, no active independent clock and real-port gates remain authoritative. +- The old `LiveDryRoutingLab` / native UI action names remain as **internal compatibility** at this stage. Preserving controls and safety until R0B/R1 avoids presenting a broken main-window GUI. +- New core regression asserts genuine CH1 external DSP inside a prepared 10-channel graph, one invocation per audio block, no RT allocation, no duplicate plugin instance, dry fallback identity. Existing graph and UI tests stay intact. + +## Still outstanding before R0 is DONE + +- **R0B production activation:** replace two mutually exclusive control workflows with a single startup native mixer session, and migrate/orchestrate CH1 FX ADD/REMOVE/MOVE/preset/Orbit operations without detached callback or device epoch invalidation. Current CH1 structural edit while routing active is explicitly blocked; do not claim full performance-mode lifecycle or remove STOP yet. This is a safety gate, not a cosmetic UI milestone. +- Do not show unassigned CH2..10 as live; connect physically via ACK. Product-level ROUTING/PATCH UI (matrix) follows as R1 after native R0B. The current LAB name persists in old UI until the real operational split is removed; no dishonest label-only change. +- Hardware #15 crackle, proper PDC, vendor crash isolation, continuous scene/VST3 state recall, physical output patches and full hardware FAT are separate gates. + +## Validation + +The extended `ARMixLiveChannelFxTests` executes a simulated real JUCE channel processor and verifies no allocation on the native callback loop; Windows MSVC CTest and Chromium UI smoke should be required on this PR before merge. CI alone does **not** validate audio hardware. diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 5eb6a07f6..f9ecb7154 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -129,13 +129,23 @@ class LiveChannelFxGraph final { // One actual physical -> FX -> PRE send -> fader -> POST send -> BUS -> // master path. FX lifetimes are external to the immutable routing plan. + // R0: an existing multi-insert CH1 rack is invoked from the SAME native + // routing render graph. Its callback-scoped lifetime is separately pinned + // by the host's LiveGraphHandoff cycle. Never allocate/copy/retain it here. + // No duplicate CH1 native insert may execute at the same time. + using ExternalStripFx=void(*)(void*,int,float*,float*,int) noexcept; 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 { + RenderLevels* levels=nullptr, + void* externalContext=nullptr, + ExternalStripFx externalFx=nullptr) noexcept { + auto channelFx=[this,externalContext,externalFx] + (int strip,float* l,float* r,int samples) noexcept { if(strip<0||strip>=fxSlots)return; auto* instance=processors_[strip].get(); // no shared_ptr copy in RT if(instance)instance->render(l,r,samples); + else if(strip==0 && externalFx) + externalFx(externalContext,strip,l,r,samples); }; return block_->process(physical,inputs,left,right,frames,channelFx,levels,&controls_); } diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 1fe032ef1..cb6148e97 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -763,6 +763,10 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback if (index < 0 || index >= graphOwned_->count) return false; // Message-thread metadata and an atomic value consumed by the audio thread. const int physical = Graph::physicalAt (visibleFxOrder(), index); + // No PDC: a bypassed latent CH1 processor must not be re-enabled + // after routing was ACKed (otherwise parallel sends misalign). + if(dryRoutingLab_.active() && !value && + graphOwned_->slots[physical].latency!=0)return false; graphOwned_->slots[physical].bypass = value; graphOwned_->bypassFlags[physical].store (value, std::memory_order_release); // Recompute the advertised steady-state graph latency on the control @@ -833,6 +837,13 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return "Restore the full DIRECT audio device before routing LAB"; auto* device=deviceManager_.getCurrentAudioDevice(); if(!device)return "Select a verified DIRECT audio device first"; + // Without PDC, do not mix a latent CH1 chain with uncompensated + // PRE/POST channel/AUX sends. Preserve existing rack and reject safely. + // Include bypassed slots too: enabling them later must not introduce + // uncompensated latency into CH1 -> BUS/AUX signal paths. + for(int i=0;icount;++i) + if(graphOwned_->slots[i].latency!=0) + return "CH1 rack contains a latent VST3: zero-latency settings are required for native multi-channel sends"; return dryRoutingLab_.apply(command,directFence_.permitted(), independent_.active(),graphOwned_->count,fx,formats_, device->getCurrentSampleRate(), @@ -1267,6 +1278,62 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback outputPeak_.store (0.f); } + // R0 bridge: existing CH1 multi-insert vendor state/Orbit stays owned by + // the live FX handoff. The audio callback holds its Cycle lease throughout + // this render pass, so an old plugin graph cannot retire in mid-block. + // This is a temporary ownership adapter until all inserts are represented + // by the same native multi-lane graph; not a second rendering engine. + struct LegacyChannelOneLease final { LiveAudioEngine* host; Graph* graph; }; + static void processLegacyChannelOne(void* token,int lane,float* left, + float* right,int frames) noexcept + { + if(lane!=0 || !token || !left || !right || frames<=0 || frames>maxFrames)return; + const auto& lease=*static_cast(token); + auto* const host=lease.host; + auto* const graph=lease.graph; + if(!host || !graph || graph->count<=0)return; + float* channels[]{left,right}; + juce::AudioBuffer buffer(channels,2,frames); + juce::MidiBuffer midi; + const auto order=graph->orderPacked.load(std::memory_order_acquire); + for(int logical=0;logicalcount;++logical) + { + const int physical=Graph::physicalAt(order,logical); + auto& slot=graph->slots[physical]; + if(!slot.processor)continue; + auto& bypass=graph->bypassEnvelope[physical]; + bypass.request(graph->bypassFlags[physical].load(std::memory_order_acquire)); + const bool blend=bypass.transitioning(); + if(blend) + { + juce::FloatVectorOperations::copy(host->dryScratch_.getWritePointer(0),left,frames); + juce::FloatVectorOperations::copy(host->dryScratch_.getWritePointer(1),right,frames); + } + if(bypass.shouldProcessWet()) + { + try {slot.processor->processBlock(buffer,midi);} + catch(...) + { + juce::FloatVectorOperations::clear(left,frames); + juce::FloatVectorOperations::clear(right,frames); + return; // vendor exception must not unwind JUCE callback + } + } + if(blend) + { + const float* dryL=host->dryScratch_.getReadPointer(0); + const float* dryR=host->dryScratch_.getReadPointer(1); + for(int i=0;i0) - return "Disable/remove Channel 1 VST3 before DRY Routing LAB (no plugin state is touched)"; + // Keep the existing multi-insert CH1 rack and vendor Orbit alive. + // Native CH1 insert and legacy CH1 rack are mutually exclusive; + // running both would process plugins twice and corrupt user sound. + if(loadedFx>0 && !selections[0].id.isEmpty()) + return "CH1 has a live FX rack: remove the duplicate CH1 insert from this route"; if(!command.isObject()) return "Invalid Dry Routing configuration"; const auto currentEpoch=deviceEpoch_.load(std::memory_order_acquire); if(!registryValid_.load(std::memory_order_acquire)) @@ -324,7 +327,9 @@ class LiveDryRoutingLab final { // A failed run never falls through to an unrelated microphone/plugin path. bool process(const float* const* inputs,int inputCount, float* const* outputs,int outputCount,int frames, - float masterGain,bool masterMuted) noexcept { + float masterGain,bool masterMuted, + void* externalContext=nullptr, + FxGraph::ExternalStripFx externalFx=nullptr) noexcept { if(!active())return false; for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed); for(auto& p:auxPeaks_)p.store(0.f,std::memory_order_relaxed); @@ -383,7 +388,8 @@ class LiveDryRoutingLab final { shifted[c]=inputs&&inputs[c]?inputs[c]+offset:nullptr; armix::mixer::RenderLevels level; if(!snapshot->prepared->process(shifted.data(),inputCount, - outputs[0]+offset,outputs[1]+offset,n,&level)) + outputs[0]+offset,outputs[1]+offset,n,&level, + externalContext,externalFx)) return true; for(int ch=0;ch(status.getProperty("fxCount",0)))+ " independent VST3 inserts, real PRE/POST sends. " - "Use low headphone volume; STOP LAB before normal CH1 VST3."); + "Existing CH1 FX Rack and Orbit stay bound to their original processors. " + "Structural CH1 FX changes remain gated until the next production lifecycle milestone."); } if (action == "routingDryShowSave") { diff --git a/src/NativeLiveShowCapture.h b/src/NativeLiveShowCapture.h index 3d64b136d..16859a873 100644 --- a/src/NativeLiveShowCapture.h +++ b/src/NativeLiveShowCapture.h @@ -41,6 +41,11 @@ class NativeLiveShowCapture final { return "Mute native output and use a single DIRECT device before SAVE"; if(nativeStatus.getProperty("diagnosticRoute",{}).toString()!="NORMAL") return "Return diagnostic audio to NORMAL before SAVE"; + // R0 CH1 borrowed processors live outside Routing LAB fxCount. + // Reject any vendor FX (and absent/invalid count) for DRY-only saves. + const auto borrowed=nativeStatus.getProperty("chainCount",{}); + if(!borrowed.isInt() || static_cast(borrowed)!=0) + return "CH1 FX Rack has VST3 state: cannot SAVE as a DRY-only Show"; const auto lab=nativeStatus.getProperty("dryRoutingLab",{}); if(!lab.isObject())return "Native Routing LAB has no published session"; bool active=false,ready=false; diff --git a/tests/live_channel_fx_graph_test.cpp b/tests/live_channel_fx_graph_test.cpp index 9645389a7..0516e7b24 100644 --- a/tests/live_channel_fx_graph_test.cpp +++ b/tests/live_channel_fx_graph_test.cpp @@ -80,6 +80,32 @@ static std::unique_ptr makeGraph(float firstFx,float returnF return graph; } int main() { + // R0: existing CH1 FX chain may be rendered inside the SAME prepared + // ten-channel routing pass, without creating a second plugin or copying + // a processor. Verify exactly one call and zero callback heap allocation. + { + auto fx=makeGraph(2.f,1.f,false); + std::array input{.4f,.4f,.4f,.4f}; + std::array silent{}; + const float* pins[]{input.data(),silent.data(),silent.data()}; + std::array l{},r{}; + int legacyCalls=0; + const auto external=+[](void* context,int strip,float* left,float* right,int count) noexcept { + assert(strip==0); + ++*static_cast(context); + for(int n=0;nprocess(pins,3,l.data(),r.data(),4,nullptr,&legacyCalls,external)); + assert(heapCalls.load(std::memory_order_relaxed)==before); + assert(legacyCalls==1); + // Input .4 * externally owned CH1 FX 2 * PRE send .5 = .4. + assert(near(l[0],.4f)&&near(r[0],.4f)); + assert(fx->activeInserts()==0); + // Without the external lease the unmodified route remains dry. + assert(fx->process(pins,3,l.data(),r.data(),4)); + assert(near(l[0],.2f)&&near(r[0],.2f)); + } // This test executes actual JUCE AudioProcessor::processBlock for // DIFFERENT strip instances and a BUS return, no VST3 vendor binaries. using Publication=armix::rt::RealtimeRoutePublisher; diff --git a/tests/native_live_show_capture_test.cpp b/tests/native_live_show_capture_test.cpp index 5bfcb112e..4e7d76a78 100644 --- a/tests/native_live_show_capture_test.cpp +++ b/tests/native_live_show_capture_test.cpp @@ -65,6 +65,7 @@ juce::var setup(){ auto root=obj(); set(root,"monitor",false);set(root,"adaptiveClockActive",false); set(root,"diagnosticRoute","NORMAL"); + set(root,"chainCount",0); // independently owned CH1 vendor processor count set(root,"masterLinear",0.55); set(root,"masterMute",false);set(root,"masterMono",true); set(root,"dryRoutingLab",lab); @@ -109,6 +110,13 @@ int main() { lab=plugin.getProperty("dryRoutingLab",{}); set(lab,"fxCount",1); assert(NativeLiveShowCapture::captureDry(plugin,"Dry Routing Test",captured).isNotEmpty()); + auto legacy=setup();set(legacy,"chainCount",2); + assert(NativeLiveShowCapture::captureDry(legacy,"Dry Routing Test",captured).isNotEmpty()); + assert(Codec::encode(captured)==prior); + auto missing=setup(); + missing.getDynamicObject()->removeProperty(juce::Identifier("chainCount")); + assert(NativeLiveShowCapture::captureDry(missing,"Dry Routing Test",captured).isNotEmpty()); + assert(Codec::encode(captured)==prior); auto portsLost=setup();lab=portsLost.getProperty("dryRoutingLab",{}); juce::Array ports;auto p=obj();set(p,"port",3);ports.add(p); set(lab,"ports",juce::var(ports)); diff --git a/web/monitor.js b/web/monitor.js index 2512d2d7c..349133b09 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -71,7 +71,7 @@ routeOverlay.innerHTML=''; @@ -292,7 +292,7 @@ document.getElementById("arRouteSaveDry").addEventListener("click",()=>{ const d=state.dryRoutingLab||{}; if(!d.ready || !d.active || !d.acceptedRoute || state.monitor || - Number(d.fxCount)!==0){ + Number(d.fxCount)!==0 || Number(state.chainCount)!==0){ document.getElementById("arRouteFeedback").textContent= "SAVE DRY SHOW requires an ACKnowledged native route, MUTED OUTPUT and zero VST3; no changes saved."; return; @@ -311,7 +311,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)+" VST3 ("+(result.fxReused||0)+" preserved) · "+(result.auxCount||0)+" dedicated AUX · "+(result.auxSendCount||0)+" AUX sends · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety"; + result.active?"NATIVE ACK: "+(Number(result.fxCount||0)+Number(state.chainCount||0))+" VST3 total (CH1 rack retained · "+(result.fxReused||0)+" native inserts preserved) · "+(result.auxCount||0)+" AUX · "+(result.auxSendCount||0)+" AUX sends · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety"; updateRouteLabIdentity(); });