Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/R0_UNIFIED_CH1_LANE_MILESTONE_20261029.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 12 additions & 2 deletions engine/core/LiveChannelFxGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand Down
73 changes: 72 additions & 1 deletion src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;i<graphOwned_->count;++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(),
Expand Down Expand Up @@ -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<LegacyChannelOneLease*>(token);
auto* const host=lease.host;
auto* const graph=lease.graph;
if(!host || !graph || graph->count<=0)return;
float* channels[]{left,right};
juce::AudioBuffer<float> buffer(channels,2,frames);
juce::MidiBuffer midi;
const auto order=graph->orderPacked.load(std::memory_order_acquire);
for(int logical=0;logical<graph->count;++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;i<frames;++i)
{
const auto gains=bypass.next();
left[i]=gains.wet*left[i]+gains.dry*dryL[i];
right[i]=gains.wet*right[i]+gains.dry*dryR[i];
}
}
midi.clear();
}
}

void audioDeviceIOCallbackWithContext (
const float* const* inputs, int inputChannels, float* const* outputs,
int outputChannels, int samples, const juce::AudioIODeviceCallbackContext&) override
Expand Down Expand Up @@ -1329,10 +1396,14 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
&& !masterMute_.load(std::memory_order_relaxed)
&& activeDiagnosticRoute == armix::diagnostics::Route::normal
&& !independent_.active();
// Both native 10CH routing and the existing CH1 vendor FX chain
// execute in ONE stereo output render pass. Never mix a parallel
// CH1 output on top or copy vendor processors into another graph.
LegacyChannelOneLease ch1Lease{this,cycle.graph};
const bool routed=dryRoutingLab_.process(inputs,inputChannels,outputs,
outputChannels,samples,
masterGain_.load(std::memory_order_relaxed),
!outputPermitted);
!outputPermitted,&ch1Lease,&processLegacyChannelOne);
// STOP can race after the outer active() check. Never leave a
// callback's output untouched, and NEVER fall through into CH1.
if(!routed) {
Expand Down
14 changes: 10 additions & 4 deletions src/LiveDryRoutingLab.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ class LiveDryRoutingLab final {
// Called by the native message thread only. Not callable from RT.
if(!directPermitted || independentClock)
return "Dry Routing LAB requires one verified DIRECT audio device";
if(loadedFx>0)
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";
Comment thread
masarray marked this conversation as resolved.
Resolved
if(!command.isObject()) return "Invalid Dry Routing configuration";
const auto currentEpoch=deviceEpoch_.load(std::memory_order_acquire);
if(!registryValid_.load(std::memory_order_acquire))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<count;++ch)
perChannelPeaks[ch]=std::max(perChannelPeaks[ch],level.channelPeak[ch]);
Expand Down
3 changes: 2 additions & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
"Native 10-channel Routing LAB active: "+
juce::String(static_cast<int>(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")
{
Expand Down
5 changes: 5 additions & 0 deletions src/NativeLiveShowCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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;
Expand Down
26 changes: 26 additions & 0 deletions tests/live_channel_fx_graph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ static std::unique_ptr<LiveChannelFxGraph> 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<float,4> input{.4f,.4f,.4f,.4f};
std::array<float,4> silent{};
const float* pins[]{input.data(),silent.data(),silent.data()};
std::array<float,4> l{},r{};
int legacyCalls=0;
const auto external=+[](void* context,int strip,float* left,float* right,int count) noexcept {
assert(strip==0);
++*static_cast<int*>(context);
for(int n=0;n<count;++n) {left[n]*=2.f;right[n]*=2.f;}
};
const auto before=heapCalls.load(std::memory_order_relaxed);
assert(fx->process(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<LiveChannelFxGraph>;
Expand Down
8 changes: 8 additions & 0 deletions tests/native_live_show_capture_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<juce::var> ports;auto p=obj();set(p,"port",3);ports.add(p);
set(lab,"ports",juce::var(ports));
Expand Down
Loading
Loading