From 795cb264d9f5fbc315842b434fd86efe841d2f3c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:37:04 +0700 Subject: [PATCH 01/53] O1 native PCM: add lock-free post-fader physical taps and prepared PDC per source --- engine/core/DynamicPreparedMixerBlock.h | 145 +++++++++++++++++++++++- 1 file changed, 139 insertions(+), 6 deletions(-) diff --git a/engine/core/DynamicPreparedMixerBlock.h b/engine/core/DynamicPreparedMixerBlock.h index e7a482544..495354f3f 100644 --- a/engine/core/DynamicPreparedMixerBlock.h +++ b/engine/core/DynamicPreparedMixerBlock.h @@ -123,6 +123,24 @@ class DynamicPreparedMixerBlock final { std::atomic gain{1.f}; armix::dsp::RealtimeSlew64 applied{}; }; + // O1: immutable lane roster + one lock-free control target per lane. + // The callback owns the transition state; a physical tap is NOT a WIRE. + struct ExternalFade final { + std::uint32_t current=0xffffffffu,next=0xffffffffu; + int remaining=0; + }; + static constexpr std::uint32_t noExternal=0xffffffffu; + static constexpr std::uint32_t encodeExternal(int l,int r) noexcept { + return l<0 ? noExternal : + static_cast(l) | + (static_cast(r)<<16); + } + static constexpr int externalLeft(std::uint32_t pair) noexcept { + return pair==noExternal?-1:static_cast(pair&0xffffu); + } + static constexpr int externalRight(std::uint32_t pair) noexcept { + return pair==noExternal?-1:static_cast(pair>>16); + } static constexpr std::size_t notScheduled=std::numeric_limits::max(); public: DynamicPreparedMixerBlock()=default; @@ -237,6 +255,30 @@ class DynamicPreparedMixerBlock final { std::find(renderOrder_.begin(),renderOrder_.end(),found->second)!=renderOrder_.end(); } + // CONTROL only: the caller has already verified the ASIO device epoch, + // sparse physical pins, exclusive MAIN/MONITOR ownership and graph revision. + // Target is a callback ordinal, NEVER a physical port number. + bool setExternalOutput(ChannelId id,int left,int right,int outputCount) noexcept { + const auto it=controlIndex_.find(id.value); + if(it==controlIndex_.end() || outputCount<2 || outputCount>256 || + (left<0 ? right!=-1 : + (right<0 || left>=outputCount || right>=outputCount || + left==right)) || !channelScheduled(id))return false; + const auto role=lanes_[it->second].role; + if(role!=ChannelRole::input && role!=ChannelRole::group && + role!=ChannelRole::fxReturn)return false; + externalTargets_[it->second].store( + encodeExternal(left,right),std::memory_order_release); + return true; + } + // Independent installed CONTROL readback. No UI draft can claim LIVE. + std::pair externalOutput(ChannelId id) const noexcept { + const auto it=controlIndex_.find(id.value); + if(it==controlIndex_.end())return {-1,-1}; + const auto pair=externalTargets_[it->second].load(std::memory_order_acquire); + return {externalLeft(pair),externalRight(pair)}; + } + // CONTROL-only DAG PDC. Every fan-in receives sample-aligned PCM, // including a destination's own hardware capture and PRE-fader sends. // A failure discards the unpublished candidate; the old graph stays live. @@ -245,7 +287,7 @@ class DynamicPreparedMixerBlock final { std::vector arrival(lanes_.size(),0),output(lanes_.size(),0); std::size_t bytes=scratch_.size()*sizeof(float); edgeDelays_.resize(edges_.size());physicalDelays_.resize(lanes_.size()); - sinkDelays_.resize(lanes_.size()); + sinkDelays_.resize(lanes_.size());externalDelays_.resize(lanes_.size()); const auto allocate=[&](armix::dsp::StereoLatencyDelay& delay,int samples) { if(samples<0||samples>armix::dsp::StereoLatencyDelay::maximumSamples)return false; const auto need=static_cast(samples)*2*sizeof(float); @@ -267,8 +309,14 @@ class DynamicPreparedMixerBlock final { for(std::size_t e=lanes_[i].first;e=0 || lane.playerDeckId!=0) && @@ -282,6 +330,14 @@ class DynamicPreparedMixerBlock final { if((i==main_||i==monitor_)&&!allocate(sinkDelays_[i],terminal-output[i])) { error={DynamicGraphFault::scratchBudget,lane.id};return false; } + // All potential direct taps are prepared on CONTROL so changing + // an output never allocates or rebuilds a VST rack on AUDIO. + if((lane.role==ChannelRole::input || + lane.role==ChannelRole::group || + lane.role==ChannelRole::fxReturn) && + !allocate(externalDelays_[i],externalTerminal-output[i])) { + error={DynamicGraphFault::scratchBudget,lane.id};return false; + } } latencySamples_=terminal;return true; } @@ -518,6 +574,10 @@ class DynamicPreparedMixerBlock final { target.appliedR.reset(next.lanes_[i].gainR); target.gate.reset(next.initialAudible_[i]?1.f:0.f); } + next.externalTargets_=std::make_unique[]>(rows.size()); + next.externalFades_=std::make_unique(rows.size()); + for(std::size_t i=0;i(next.edges_.size()); for(std::size_t e=0;e channelPeaksL={}, std::span channelPeaksR={}, - std::span playerPcm={}) noexcept { + std::span playerPcm={}, + float* const* hardwareOutputs=nullptr, + int hardwareOutputCount=0) noexcept { if(frames<=0 || !outputL || !outputR)return false; // The physical 10CH/4AUX callback requests only the stable // legacy prefix of an expanded ChannelId roster. Dynamic extra @@ -551,7 +613,9 @@ class DynamicPreparedMixerBlock final { std::fill_n(channelPeaksL.data(),channelPeaksL.size(),0.f); std::fill_n(channelPeaksR.data(),channelPeaksR.size(),0.f); } - if(outputL==outputR || + if(outputL==outputR || hardwareOutputCount<0 || + hardwareOutputCount>256 || + (hardwareOutputCount!=0 && !hardwareOutputs) || (monitorL==nullptr)!=(monitorR==nullptr) || (monitor_!=notScheduled && !monitorL) || (monitorL && (monitorL==monitorR || monitorL==outputL || @@ -765,6 +829,73 @@ class DynamicPreparedMixerBlock final { } } if(monitorL)copySink(monitor_,monitorL,monitorR); + // External hardware taps consume the SAME post-FX/post-fader scratch. + // All input reads and native plugin calls are already complete. The + // host must not clear these dedicated output buffers a second time. + if(hardwareOutputs && hardwareOutputCount) { + for(int c=0;c=hardwareOutputCount || r>=hardwareOutputCount || + l==r || !hardwareOutputs[l] || !hardwareOutputs[r] || + hardwareOutputs[l]==hardwareOutputs[r] || + hardwareOutputs[l]==outputL || hardwareOutputs[l]==outputR || + hardwareOutputs[r]==outputL || hardwareOutputs[r]==outputR || + hardwareOutputs[l]==monitorL || hardwareOutputs[l]==monitorR || + hardwareOutputs[r]==monitorL || hardwareOutputs[r]==monitorR) + return false; + } + } + // External tap delay advances even while the tap is disconnected, + // so reconnect cannot spill a stale FX tail into a new amplifier. + for(const auto i:renderOrder_) { + const auto& lane=lanes_[i]; + if(lane.role!=ChannelRole::input && + lane.role!=ChannelRole::group && + lane.role!=ChannelRole::fxReturn)continue; + auto& fade=externalFades_[i]; + const auto wanted=externalTargets_[i].load(std::memory_order_acquire); + if(fade.remaining==0 && fade.current!=wanted) { + fade.next=wanted; + fade.remaining=armix::dsp::RealtimeSlew64::samples; + } + const auto slot=lane.slot; + const float* src=scratch_.data()+slot*2*block; + const float* srcR=src+block; + for(int f=0;f0) { + nextWeight=1.f-static_cast(fade.remaining-1)/ + static_cast(armix::dsp::RealtimeSlew64::samples); + oldWeight=1.f-nextWeight; + if(--fade.remaining==0)fade.current=fade.next; + } + if(fade.remaining>0 && fade.current!=noExternal) { + hardwareOutputs[externalLeft(fade.current)][f]+=l*oldWeight; + hardwareOutputs[externalRight(fade.current)][f]+=r*oldWeight; + } + const auto active=fade.remaining>0?fade.next:fade.current; + if(active!=noExternal) { + hardwareOutputs[externalLeft(active)][f]+=l*nextWeight; + hardwareOutputs[externalRight(active)][f]+=r*nextWeight; + } + } + } + } return true; } private: @@ -775,12 +906,14 @@ class DynamicPreparedMixerBlock final { std::vector initialAudible_,soloAncestors_,soloDescendants_; std::vector blockTargets_; // all allocated before RT std::vector scratch_; - std::vector edgeDelays_,physicalDelays_,sinkDelays_; + std::vector edgeDelays_,physicalDelays_,sinkDelays_,externalDelays_; int latencySamples_=0; std::unique_ptr channelTargets_; std::unique_ptr[]> sourceTargets_; std::unique_ptr sourceFades_; std::unique_ptr sendTargets_; + std::unique_ptr[]> externalTargets_; + std::unique_ptr externalFades_; std::size_t main_=notScheduled,monitor_=notScheduled; bool mainMonoAfterFx_=false; int capacity_=0,physicalInputs_=0; From 61ca9caacde4beb14c7afcd1bd47d30746bfc853 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:37:52 +0700 Subject: [PATCH 02/53] O1 publisher: pass hardware taps through authoritative PCM callback --- engine/core/DynamicNativeSessionPublisher.h | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/engine/core/DynamicNativeSessionPublisher.h b/engine/core/DynamicNativeSessionPublisher.h index 18ef3d10c..df3453813 100644 --- a/engine/core/DynamicNativeSessionPublisher.h +++ b/engine/core/DynamicNativeSessionPublisher.h @@ -166,7 +166,9 @@ class DynamicNativeSessionPublisher final { float* monitorL=nullptr,float* monitorR=nullptr, std::span channelPeaksL={}, std::span channelPeaksR={}, - std::span playerPcm={}) noexcept { + std::span playerPcm={}, + float* const* hardwareOutputs=nullptr, + int hardwareOutputCount=0) noexcept { static_assert(std::is_nothrow_invocable_v, "Realtime VST dispatch must be noexcept"); const auto clearOutputs=[&]() noexcept { @@ -225,7 +227,8 @@ class DynamicNativeSessionPublisher final { }; const bool ok=snap->prepared->graph.process( physical,physicalCount,mainL,mainR,frames, - dispatch,monitorL,monitorR,channelPeaksL,channelPeaksR,playerPcm); + dispatch,monitorL,monitorR,channelPeaksL,channelPeaksR,playerPcm, + hardwareOutputs,hardwareOutputCount); if(!ok)clearOutputs(); return ok; } @@ -258,6 +261,21 @@ class DynamicNativeSessionPublisher final { return current?¤t->routing:nullptr; } + // O1 CONTROL only: one epoch/revision-guarded target in the same PCM graph. + // Caller validates actual driver pins and MAIN/MONITOR collision first. + bool setExternalOutput(std::uint64_t epoch,std::uint64_t revision, + ChannelId id,int left,int right,int outputCount) noexcept { + return publisher_.updateActiveControl(epoch,revision, + [&](Prepared& active) noexcept { + return active.graph.setExternalOutput(id,left,right,outputCount); + }); + } + std::pair externalOutput(std::uint64_t epoch, + std::uint64_t revision,ChannelId id) const noexcept { + const auto* p=publisher_.controlPrepared(epoch,revision); + return p?p->graph.externalOutput(id):std::pair{-1,-1}; + } + // M3C realtime parameters on the accepted ChannelId graph ONLY. // Caller must propagate the real device epoch and native ACK revision. // Rejected/stale edits leave the last accepted PCM unchanged. From 4a79987b5329ce9cd94c9db2de695bb4c0f0b58f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:39:48 +0700 Subject: [PATCH 03/53] O1 device: attest exact labeled ASIO output pin inventory --- engine/device/JuceActivePortSnapshot.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/device/JuceActivePortSnapshot.h b/engine/device/JuceActivePortSnapshot.h index feb8c1745..5d6e97f9a 100644 --- a/engine/device/JuceActivePortSnapshot.h +++ b/engine/device/JuceActivePortSnapshot.h @@ -25,6 +25,7 @@ struct JuceActivePortSnapshot final { int outputCount=0; std::uint64_t epoch=0; juce::String deviceName, typeName; + juce::StringArray outputNames; // physical pin indices, not packed callback ordinals // Accept a frozen copy of masks to exercise sparse numbering and real // output-only devices with zero capture pins. No fake input is created. @@ -83,6 +84,12 @@ struct JuceActivePortSnapshot final { } candidate.deviceName=device->getName(); candidate.typeName=device->getTypeName(); + candidate.outputNames=device->getOutputChannelNames(); + if(candidate.outputNames!=device->getOutputChannelNames() || + in!=device->getActiveInputChannels() || + out!=device->getActiveOutputChannels()) { + error=Fault::deviceChangedDuringRead;return false; + } destination=std::move(candidate); return true; } From 2e863fd3140dc684ec6be538351a213f6c9350ea Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:40:37 +0700 Subject: [PATCH 04/53] O1 .smix: persist validated stable-ChannelId physical output intent additively --- src/NativeMixerSessionDocument.h | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/NativeMixerSessionDocument.h b/src/NativeMixerSessionDocument.h index b19517128..cd75edc58 100644 --- a/src/NativeMixerSessionDocument.h +++ b/src/NativeMixerSessionDocument.h @@ -34,6 +34,13 @@ struct WaitingAsioInput final { int left=-1,right=-1; // physical pin indices, for legacy files without labels juce::String leftName,rightName; }; +// Physical pin identity is durable intent only. Never serialize callback +// ordinals, a LIVE flag, an armed amplifier or a native processor pointer. +struct StoredExternalOutput final { + ChannelId channel{}; + int left=-1,right=-1; // actual 0-based driver physical pins + juce::String leftName,rightName; +}; struct StoredInsert final { ChannelId channel{}; std::size_t slot=0; @@ -55,6 +62,7 @@ struct MixerSessionDocument final { VerifiedNativeOutputs outputs{}; HardwareBinding binding{}; std::vector waitingAsioInputs; + std::vector externalOutputs; std::vector inserts; std::vector rackBypassed; // Logical-only per-slot bypass intentions; no fabricated FX processor @@ -455,6 +463,18 @@ class Codec final { set(output,"monitorR",d.outputs.monitorR); set(output,"monitorEnabled",d.outputs.monitorEnabled); set(root,"outputs",output); + if(!d.externalOutputs.empty()) { + juce::Array assignments; + for(const auto& patch:d.externalOutputs) { + auto row=object(); + set(row,"channelId",decimal(patch.channel.value)); + set(row,"left",patch.left);set(row,"right",patch.right); + set(row,"leftName",patch.leftName); + set(row,"rightName",patch.rightName); + assignments.add(juce::var(row.release())); + } + set(root,"externalOutputs",juce::var(assignments)); + } auto master=object(); set(master,"gain",d.masterGain);set(master,"mute",d.masterMute); set(master,"mono",d.masterMono);set(root,"master",master); @@ -644,6 +664,29 @@ class Codec final { entries.push_back(std::move(row)); } if(!doc.roster.restoreExact(doc.acceptedRevision,entries))return false; + // O1 additive intent, never implicit hardware admission on Open. + const auto external=get(root,"externalOutputs"); + if(!external.isVoid()) { + const auto* assignments=external.getArray(); + if(!assignments || assignments->size()>channels->size())return false; + std::set seen; + for(const auto& item:*assignments) { + StoredExternalOutput patch; + if(!parseDecimal(get(item,"channelId"),patch.channel.value) || + !seen.insert(patch.channel.value).second || + !integral(get(item,"left"),patch.left,0,255) || + !integral(get(item,"right"),patch.right,0,255) || + patch.left%2!=0 || patch.right!=patch.left+1 || + !textField(get(item,"leftName"),patch.leftName,256) || + !textField(get(item,"rightName"),patch.rightName,256)) + return false; + const auto* owner=doc.roster.find(patch.channel); + if(!owner || (owner->role!=ChannelRole::input && + owner->role!=ChannelRole::group && + owner->role!=ChannelRole::fxReturn))return false; + doc.externalOutputs.push_back(std::move(patch)); + } + } // Optional additive H1 field. Old .smix sessions decode unchanged. // Exact ChannelId ownership prevents rename/reorder/strip replacement // from silently retargeting an operator's global shortcut. From 0db4ca36b060c5d0af486e19365c3717822288f0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:42:04 +0700 Subject: [PATCH 05/53] O1 native control: validate sparse labeled ASIO pairs, preserve WIRE, publish live output readback --- src/LiveDryRoutingLab.h | 122 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 0a380dc99..9b0de0429 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -2295,6 +2295,92 @@ class LiveDryRoutingLab final { } catch(...) {return "Native graph/VST3 state capture failed";} } + // O1 CONTROL: true ASIO physical pin identity -> packed callback ordinal. + // No OUT reconfiguration is allowed to steal MAIN or MONITOR. Every edit + // preserves the existing internal WIRE graph and FX lease. + juce::String setExternalOutput( + armix::mixer::ChannelId channel,std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,int physicalLeft,int physicalRight, + bool confirmed,const armix::device::JuceActivePortSnapshot& pins) { + using namespace armix::mixer; + if(!channelIdPhysicalPcmActive() || !ready() || + !nativeAccepted_.matches(nativePublisher_,expectedEpoch,expectedRevision) || + !matchesSessionDevice(pins) || pins.epoch!=expectedEpoch || + pins.typeName!="ASIO") + return "EXTERNAL OUT: stale ASIO device, epoch or PCM revision"; + const auto* row=nativeAccepted_.graph.roster.find(channel); + if(!row || (row->role!=ChannelRole::input && + row->role!=ChannelRole::group && + row->role!=ChannelRole::fxReturn)) + return "EXTERNAL OUT: select a live INPUT, GROUP or FX RETURN"; + const bool none=physicalLeft==-1 && physicalRight==-1; + int left=-1,right=-1; + armix::session::StoredExternalOutput candidate; + candidate.channel=channel; + if(!none) { + if(physicalLeft<0 || physicalLeft%2!=0 || + physicalRight!=physicalLeft+1 || + physicalRight>=pins.outputNames.size() || + pins.outputNames[physicalLeft].isEmpty() || + pins.outputNames[physicalRight].isEmpty()) + return "EXTERNAL OUT: invalid or unnamed stereo physical pins"; + for(int i=0;isetProperty("mainOutputs",juce::var(liveMain)); out->setProperty("monitorOutputs",juce::var(liveMonitor)); out->setProperty("monitorSends",juce::var(liveMonitorSends)); + juce::Array external; + for(const auto& patch:externalOutputAssignments_) { + auto row=std::make_unique(); + row->setProperty("channelId",juce::String(std::to_string(patch.channel.value))); + row->setProperty("physicalLeft",patch.left); + row->setProperty("physicalRight",patch.right); + row->setProperty("leftName",patch.leftName); + row->setProperty("rightName",patch.rightName); + const auto live=nativePublisher_.externalOutput( + nativeAccepted_.deviceEpoch,nativeAccepted_.pcmRevision,patch.channel); + const bool installed=nativePcm && externalOutputEpoch_==epoch() && + live.first>=0 && live.second>=0 && + live.firstsetProperty("status",installed?"LIVE":"NEEDS_REMAP"); + external.add(juce::var(row.release())); + } + out->setProperty("externalOutputs",juce::var(external)); out->setProperty("note","Native 10CH+4AUX production mixer; unpatched startup is SILENT. Explicit input assignment/ACK required. Hardware FAT unqualified."); return juce::var(out.release()); } private: std::vector waitingAsioInputs_; + std::vector externalOutputAssignments_; + std::uint64_t externalOutputEpoch_=0; // CONTROL only, never callback state // Four 9-bit callback indices (0 means absent) and the prepared quantum. // One atomic read gives AUDIO a coherent destination/quantum contract. std::atomic nativeHardware_{0}; From 50bbf4d763a117065b11c37d0c4e2d05d734791b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:43:01 +0700 Subject: [PATCH 06/53] O1 JUCE callback: render and retain independent output PCM on real ASIO channel buffers --- src/LiveDryRoutingLab.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 9b0de0429..91c4fd193 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -1341,6 +1341,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.roster=std::move(next); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeStructureLive_=true; // M4 Show cannot represent new inserts. nativeMeterEpoch_.store(0,std::memory_order_release); out.accepted=true;out.error=""; @@ -1380,7 +1381,8 @@ class LiveDryRoutingLab final { revision,ep,epoch(),false,std::move(fx),false,true); if(!committed.ok()){reply.error="NATIVE_FX_RACK_PCM_COMMIT_REJECTED";return reply;} nativeAccepted_.graph.roster=std::move(roster);nativeAccepted_.fxOwners=std::move(owner); - nativeAccepted_.pcmRevision=committed.revision;nativeStructureLive_=true; + nativeAccepted_.pcmRevision=committed.revision; + reapplyExternalOutputsSameEpoch();nativeStructureLive_=true; nativeMeterEpoch_.store(0,std::memory_order_release); reply.accepted=true;reply.error="";reply.pcmRevision=committed.revision; reply.rosterRevision=nativeAccepted_.graph.roster.revision();return reply; @@ -1535,6 +1537,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.roster=std::move(next); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); // From now on original fixed M4 cannot express the extra BUS. // The native publisher remains the authoritative PCM, and a // failed scalar mirror MUST fault silent rather than reselect @@ -1629,6 +1632,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.roster=std::move(roster); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeStructureLive_=true; // never restore stale M4 width nativeMeterEpoch_.store(0,std::memory_order_release); reply.accepted=true;reply.error=""; @@ -1792,6 +1796,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.request=std::move(request); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeStructureLive_=true; // M4 can no longer represent CH11+ reply.accepted=true;reply.error=""; reply.created=created.createdIds.front(); @@ -1867,6 +1872,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.request=std::move(request); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); std::erase_if(waitingAsioInputs_,[id](const auto& pin){return pin.id==id;}); nativeStructureLive_=true; nativeMeterEpoch_.store(0,std::memory_order_release); @@ -1954,6 +1960,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.request=std::move(request); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); std::erase_if(waitingAsioInputs_,[channel](const auto& pin){return pin.id==channel;}); nativeStructureLive_=true; // M4 source roster no longer authoritative nativeMeterEpoch_.store(0,std::memory_order_release); @@ -2027,6 +2034,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.roster=std::move(roster); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeMeterEpoch_.store(0,std::memory_order_release); r.accepted=true;r.error=""; r.pcmRevision=published.revision; @@ -2101,6 +2109,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.roster=std::move(roster); nativeAccepted_.fxOwners=std::move(owner); nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeStructureLive_=true; // never fall back to incompatible M4 nativeMeterEpoch_.store(0,std::memory_order_release); r.accepted=true;r.error=""; @@ -2254,6 +2263,7 @@ class LiveDryRoutingLab final { draft.outputs=nativeAccepted_.hardware; draft.request=nativeAccepted_.graph.request; draft.waitingAsioInputs=waitingAsioInputs_; + draft.externalOutputs=externalOutputAssignments_; std::vector staged; std::set hashes; juce::int64 total=0; @@ -2486,6 +2496,7 @@ class LiveDryRoutingLab final { nativeAccepted_.fxOwners=std::move(bank); nativeAccepted_.deviceEpoch=generation; nativeAccepted_.pcmRevision=published.revision; + reapplyExternalOutputsSameEpoch(); nativeStructureLive_=true; nativeControlDirty_=true; publishedEpoch_.store(0,std::memory_order_release); @@ -2807,6 +2818,7 @@ class LiveDryRoutingLab final { nativeAccepted_.graph.request=std::move(request); nativeAccepted_.deviceEpoch=newEpoch; nativeAccepted_.pcmRevision=applied.revision; + reapplyExternalOutputsSameEpoch(); nativeAccepted_.fxOwners=std::move(owner); nativeControlDirty_=true; installNativeHardware(newEpoch,hardware,nativeAccepted_.graph.request.maxFrames); @@ -3001,6 +3013,7 @@ class LiveDryRoutingLab final { // Large/variable JUCE quantum is chunked using stack pointer views; // no heap allocation or new processing object inside callback. std::array shifted{}; + std::array outputSlices{}; int max=channelIdRender?static_cast(native>>36): std::min(snapshot->prepared->maxFramesPerPlugin(), reboundQuantum_.load(std::memory_order_acquire)); @@ -3026,6 +3039,9 @@ class LiveDryRoutingLab final { const int n=std::min(max,frames-offset); for(int c=0;c( - slice.data(),playerPcm.size())); + slice.data(),playerPcm.size()), + meterOnly?nullptr:outputSlices.data(), + meterOnly?0:outputCount); if(processed) { for(std::size_t ch=0;ch Date: Wed, 11 Nov 2026 09:43:30 +0700 Subject: [PATCH 07/53] fix(o1): store JUCE var output assignment without invalid pointer release --- src/NativeMixerSessionDocument.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NativeMixerSessionDocument.h b/src/NativeMixerSessionDocument.h index cd75edc58..d1444514b 100644 --- a/src/NativeMixerSessionDocument.h +++ b/src/NativeMixerSessionDocument.h @@ -471,7 +471,7 @@ class Codec final { set(row,"left",patch.left);set(row,"right",patch.right); set(row,"leftName",patch.leftName); set(row,"rightName",patch.rightName); - assignments.add(juce::var(row.release())); + assignments.add(row); } set(root,"externalOutputs",juce::var(assignments)); } From 38b5abee360d6a03a1f789ba2a3ad7754b0f2479 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:44:01 +0700 Subject: [PATCH 08/53] O1 engine host: verify exact ASIO device and dispatch external PCM target on control --- src/LiveAudioEngine.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 8411366b6..bae125d6c 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -1473,6 +1473,31 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return "SOURCE: native prepare failed; prior audio kept"; } } + // O1 physical External OUT: solely CONTROL, on the already-approved + // single ASIO/ChannelId PCM callback. Hardware pin masks and labels + // are read atomically with the current device lifecycle generation. + juce::String setPhysicalExternalOutput(armix::mixer::ChannelId channel, + std::uint64_t expectedEpoch,std::uint64_t expectedRevision, + int physicalLeft,int physicalRight,bool confirmed) { + if(independent_.active() || !directFence_.permitted() || + routeReconfiguring_.load(std::memory_order_acquire) || + handoff_.busy() || savedDirectSetup_ || savedLiveSetup_ || + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal) + return "EXTERNAL OUT: DIRECT ASIO output is not available"; + if(deviceManager_.getCurrentAudioDeviceType()!="ASIO") + return "EXTERNAL OUT: active audio backend must be ASIO"; + auto* device=deviceManager_.getCurrentAudioDevice(); + armix::device::JuceActivePortSnapshot pins; + armix::device::JuceActivePortSnapshot::Fault fault{}; + if(!armix::device::JuceActivePortSnapshot::capture( + device,expectedEpoch,pins,fault) || + !device || !device->isOpen()) + return "EXTERNAL OUT: device pin inventory not verified"; + return dryRoutingLab_.setExternalOutput(channel,expectedEpoch, + expectedRevision,physicalLeft,physicalRight,confirmed,pins); + } + // Direct compact OUT / MONO-STEREO operator edits. One existing M4 // prepared graph is republished; original VST3 instances/Orbit remain // owned by the same native callback. Never touched on RT. From d8f3a3ffb336bfecd5d30eec401a4ba2fb3a3d0a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:44:35 +0700 Subject: [PATCH 09/53] O1 native intent: validated external output transaction ACK and independent readback --- src/Main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index 7c086f64e..ec4b2ed22 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1697,6 +1697,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(auto* obj=accepted.getDynamicObject()) { obj->setProperty("channelAppearance",channelAppearance_.snapshot(accepted.getProperty("graph",{}))); obj->setProperty("waitingAsioInputs",live.getProperty("waitingAsioInputs",0)); + obj->setProperty("externalOutputs", + live.getProperty("dryRoutingLab",{}).getProperty("externalOutputs",{})); } return accepted; } @@ -4450,6 +4452,49 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // ACK is not PCM proof; the bridge requires a LATER snapshot. return; } + // O1: native CONTROL intent, exact verified ASIO physical pair. + // Never reinterpret an external destination as internal WIRE/M4 OUT. + if(action=="routingExternalOutput") { + const auto requestId=args.getProperty("requestId",{}).toString(); + const auto channelText=args.getProperty("channelId",{}).toString(); + const auto ep=args.getProperty("deviceEpoch",{}); + const auto rv=args.getProperty("revision",{}); + const auto confirmed=args.getProperty("confirmed",{}); + const int left=static_cast(args.getProperty("left",-2)); + const int right=static_cast(args.getProperty("right",-2)); + const auto nativeStatus=engine_.status().getProperty("dryRoutingLab",{}); + const auto bus=nativeStatus.getProperty("nativeBus",{}); + const bool tokens= + armix::console::nativeSessionTokenMatches( + ep,nativeStatus.getProperty("epoch",{})) && + armix::console::nativeSessionTokenMatches( + rv,bus.getProperty("graphRevision",{})); + std::uint64_t rawId=0; + const bool idOk=armix::session::parseDecimal(juce::var(channelText),rawId); + juce::String error="EXTERNAL OUT: invalid or stale native request"; + if(requestId.startsWith("out-o-") && requestId.length()<=64 && + tokens && idOk && confirmed.isBool() && + ((left==-1 && right==-1) || (left>=0 && right>=0)) && + !nativeShowBusy_ && !studioBackupBusy_) + error=engine_.setPhysicalExternalOutput( + armix::mixer::ChannelId{rawId}, + armix::console::nativeSessionTokenValue(ep), + armix::console::nativeSessionTokenValue(rv), + left,right,static_cast(confirmed)); + auto ack=std::make_unique(); + ack->setProperty("requestId",requestId); + ack->setProperty("channelId",channelText); + ack->setProperty("ok",error.isEmpty()); + ack->setProperty("error",error); + ack->setProperty("deviceEpoch",ep); + ack->setProperty("graphRevision",rv); + if(browser_.loaded) + browser_.emitEventIfBrowserIsVisible( + "arMixExternalOutputAck",juce::var(ack.release())); + if(error.isNotEmpty())emitNotice(error,true); + else emitApprovedNativeSnapshot(); // next independent subscription verifies LIVE + return; + } // A visible /preview/ channel OUT changes this same installed M4 // topology. Only actual MAIN / NONE semantics are supported here. if(action=="routingChannelPatch"){ From e786aaf4a2fea5839e719d79da1f08a184e44b0f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:48:57 +0700 Subject: [PATCH 10/53] O1 approved /preview/: separate compact internal WIRE and physical External OUT selectors --- site/preview-v2/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index 8d6bf0221..c94db2a17 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -263,6 +263,7 @@ [splitSourceLabel(x.id,'PRE'),splitSourceLabel(x.id,'POST')])] :['None']; if(type==='output')return t.kind==='master'?['Default Output','Output 1 + 2','Speakers (Realtek)','Virtual Cable']:[...(t.kind==='audio'?['SOURCE ONLY (No Main)']:[]),master.name,...tracks.filter(x=>x.kind==='bus'&&x.id!==t.id).map(x=>x.name),'Output 1 + 2']; + if(type==='external')return ['None']; // physical output is native-only return ['None',...tracks.filter(x=>(x.kind==='bus'||x.kind==='fx')&&x.id!==t.id).map(x=>x.name)]; }; /* V53: demo-only insert identity, one reversible transaction per real move. @@ -691,7 +692,10 @@ if(t.kind==='audio')code+='
IN
'; else if(t.kind==='bus'||t.kind==='fx')code+='
IN'+(t.kind==='bus'?'GROUP':'FX RETURN')+'
'; else code+='
INSUM BUS
'; - code+='
OUT
'; + code+='
OUT
'; + if(t.kind!=='master') + code+='
EXT
'; + code+=''; code+=sectionFx(t)+sectionSend(t); code+='
PAN'+panLabel(t.pan)+'
'; From 15ca613768c59d6a859bf9040c3c2468702e310d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:49:12 +0700 Subject: [PATCH 11/53] O1 strip geometry: compact third output row with pending and remap visibility --- site/preview-v2/assets/mixer-section-layout.css | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/site/preview-v2/assets/mixer-section-layout.css b/site/preview-v2/assets/mixer-section-layout.css index 638312ccd..918f956d5 100644 --- a/site/preview-v2/assets/mixer-section-layout.css +++ b/site/preview-v2/assets/mixer-section-layout.css @@ -28,8 +28,8 @@ .console-body{ --strip-w:150px;--master-w:152px; } -.console-body[data-density="standard"]{--strip-w:125px;--master-w:132px;--switch-h:39px;--pan-h:36px;--trim-h:27px;--route-h:70px} -.console-body[data-density="compact"]{--strip-w:105px;--master-w:116px;--switch-h:32px;--route-h:58px;--pan-h:30px;--trim-h:23px} +.console-body[data-density="standard"]{--strip-w:125px;--master-w:132px;--switch-h:39px;--pan-h:36px;--trim-h:27px;--route-h:91px} +.console-body[data-density="compact"]{--strip-w:105px;--master-w:116px;--switch-h:32px;--route-h:81px;--pan-h:30px;--trim-h:23px} .console-body .strip,.console-body.narrow .strip:not(.master){ width:var(--strip-w);min-width:var(--strip-w);flex:0 0 var(--strip-w); @@ -143,3 +143,11 @@ .console-body .switch:focus-visible,.console-body .route-select:focus-visible{outline:2px solid #7ecae3;outline-offset:0} .console-body .rail-cell.fader{min-height:118px} @media(max-height:610px){.console-body .rail-cell.fader{min-height:86px}} + +/* O1 physical OUT: same official strip, one extra compact native pair row. */ +.console-body:not([data-density="standard"]):not([data-density="compact"]){--route-h:94px} +.console-body .external-out-field .route-caption{color:#a8d0dd} +.console-body .external-out-field .route-select{border-color:#547685;background-color:#192a32} +.console-body .external-out-field .route-select[aria-busy="true"]{border-color:#ddb576} +.console-body .external-out-field .route-select[data-status="NEEDS_REMAP"]{color:#d5aa8b} +.console-body[data-density="compact"] .external-out-field .route-caption{font-size:9px} From c31c6efdf918825523b704b987925cdb7818860f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:49:36 +0700 Subject: [PATCH 12/53] O1 approved native GUI assembly: wire EXTERNAL selector to same live native hooks --- scripts/build_approved_native_gui.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index 9fe40a1ba..c75af0d8e 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -94,6 +94,8 @@ def accepted_pages_html() -> str: # Public /preview/ continues to show its labeled simulated reference. ("const channelOptions=(t,type)=>{\n", "const channelOptions=(t,type)=>{\n" + " if(type==='external'&&window.__JUCE__?.backend)\n" + " return window.__ARMIX_NATIVE_M2__?.externalChoices?.(t)||['None'];\n" " if(type==='input'&&window.__JUCE__?.backend)\n" " return window.__ARMIX_NATIVE_M2__?.inputChoices?.(t)||['None'];\n" " if(type==='output'&&window.__JUCE__?.backend)\n" From 0662005baf9625f06ab2e170d1fab2e5a7489354 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:51:03 +0700 Subject: [PATCH 13/53] O1 readback: expose accepted native graph revision and reserved hardware pair pins --- src/Main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index ec4b2ed22..876078f3f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1699,6 +1699,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr obj->setProperty("waitingAsioInputs",live.getProperty("waitingAsioInputs",0)); obj->setProperty("externalOutputs", live.getProperty("dryRoutingLab",{}).getProperty("externalOutputs",{})); + obj->setProperty("externalRevision", + live.getProperty("dryRoutingLab",{}).getProperty("nativeBus",{}) + .getProperty("graphRevision",{})); + obj->setProperty("physicalMainOutputs", + live.getProperty("dryRoutingLab",{}).getProperty("mainOutputs",{})); + obj->setProperty("physicalMonitorOutputs", + live.getProperty("dryRoutingLab",{}).getProperty("monitorOutputs",{})); } return accepted; } From d375305f85da7f12c8b68879906e900b3b3d52c2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:51:33 +0700 Subject: [PATCH 14/53] O1 approved native GUI: ASIO physical pair options and installed LIVE/Needs Remap readback --- web/approved-native-bridge.js | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 7497dc6ed..561c95a04 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -514,6 +514,12 @@ const target=out&&nativeOutputTargets(t,accepted.channels).find(x=>x.id===out.id); if(ch.role!=="MAIN")t.output=out?.role==="MAIN"?"Master": (target?.label||"SOURCE ONLY (No Main)"); + const direct=Array.isArray(native.raw?.externalOutputs)? + native.raw.externalOutputs.find(x=>x.channelId===ch.id):null; + const pair=direct && hardwareOutputPairs().find(p=> + p.left===direct.physicalLeft&&p.right===direct.physicalRight); + t.externalOutput=direct?(direct.status==="LIVE"&&pair? + pair.label:"Needs Remap · OUT "+(direct.physicalLeft+1)+"/"+(direct.physicalRight+1)):"None"; t.selected=previous.get(t.id)?.selected || false; if(typeof ch.fxRackBypassed==="boolean")t.fxOn=!ch.fxRackBypassed; if (Array.isArray(ch.inserts)) { @@ -631,6 +637,7 @@ next.graph.edges.map(e=>[e.edgeId,e.from,e.to,e.tap,e.enabled,e.primaryOutput])]); if(structure!==lastNativeTopologySignature){ if(!projection(next))return false; + paintExternalReadback(next); lastNativeTopologySignature=structure; return true; } @@ -725,6 +732,7 @@ // user selects REAL JUCE active pin -> explicitly patches CH1 -> arms output. // No auto-arm, demo PCM, guessed physical port or second GUI. let hardware=null, inputSelect=null, routeBtn=null, armBtn=null, muteBtn=null; + let externalSerial=0,pendingExternal=null; let hardwareNote=null, pendingSourceId=0, sourceSerial=100; const safeNativeCounter=x=>{ if(typeof x!=="string" || !/^[1-9]\d*$/.test(x))return null; @@ -751,6 +759,72 @@ const NEEDS_REMAP="Audio connection lost"; const monoLabel=p=>"Mono · "+p.label+" [IN "+(p.port+1)+"]"; const stereoLabel=(a,b)=>"Stereo · IN "+(a.port+1)+" + "+(b.port+1); + // Only driver-verified even/odd physical pin pairs (not packed ordinals). + // MAIN and MONITOR retain exclusive ownership of their actual pins. + const hardwareOutputPairs=()=>{ + const d=hardware?.device,choices=[{label:"None",left:-1,right:-1}]; + if(d?.backend!=="ASIO" || !Array.isArray(d.outputEndpoints) || + !Array.isArray(d.enabledOutputs))return choices; + const map=new Map(d.outputEndpoints.filter(p=> + p.active===true&&Number.isInteger(p.port)&& + d.enabledOutputs.includes(p.port)&& + typeof p.label==="string"&&p.label.length>0).map(p=>[p.port,p])); + const main=Array.isArray(hardware?.raw?.physicalMainOutputs)? + hardware.raw.physicalMainOutputs:[]; + const monitor=Array.isArray(hardware?.raw?.physicalMonitorOutputs)? + hardware.raw.physicalMonitorOutputs:[]; + for(const [left,a] of map) { + if(left%2!==0 || !map.has(left+1))continue; + const b=map.get(left+1); + if(main.includes(left)||main.includes(left+1)|| + monitor.includes(left)||monitor.includes(left+1))continue; + choices.push({label:"OUT "+(left+1)+"/"+(left+2)+" · "+ + a.label+" + "+b.label,left,right:left+1}); + } + return choices; + }; + const paintExternalReadback=(next)=>{ + const assignments=Array.isArray(next?.raw?.externalOutputs)? + next.raw.externalOutputs:[]; + const choices=hardwareOutputPairs(); + for(const t of scope?.tracks||[]) { + const id=nativeIdFor(t); + const row=assignments.find(p=>p.channelId===id); + const match=row&&choices.find(p=>p.left===row.physicalLeft && + p.right===row.physicalRight); + const state=row?.status==="LIVE"&&match?"LIVE": + row?"NEEDS_REMAP":"NONE"; + const value=row?(state==="LIVE"?match.label: + "Needs Remap · OUT "+(row.physicalLeft+1)+"/"+(row.physicalRight+1)):"None"; + t.externalOutput=value; + const select=document.querySelector('.strip[data-id="'+t.id+ + '"] select[data-field="external"]'); + if(!select)continue; + const labels=choices.map(p=>p.label); + if(!labels.includes(value))labels.push(value); + const signature=labels.join("|"); + if(select.dataset.choices!==signature){ + select.replaceChildren(...labels.map(s=>{ + const op=document.createElement("option"); + op.value=op.textContent=s;return op; + })); + select.dataset.choices=signature; + } + if(select.value!==value)select.value=value; + select.dataset.status=state; + select.title=state==="NEEDS_REMAP"? + "Saved physical output disarmed; choose a verified ASIO pair": + state==="LIVE"?"LIVE · independent native post-fader PCM": + "None · internal WIRE remains unchanged"; + if(pendingExternal?.channelId===id && pendingExternal.acked && + ((state==="LIVE" && row.physicalLeft===pendingExternal.left && + row.physicalRight===pendingExternal.right) || + (pendingExternal.left===-1 && !row))){ + pendingExternal=null;select.removeAttribute("aria-busy"); + status("EXTERNAL OUT verified · "+t.name+" → "+value); + } + } + }; const inputChoicesFor=()=>{ const pins=hardwarePins(),entries=[{label:"None",mode:"NONE",left:-1,right:-1}]; for(const p of pins)entries.push({ @@ -2454,6 +2528,7 @@ scope?.syncNativeWireGains?.([]); // flush accepted paint after pointer release appearanceFromNative(next); updateHardwarePanel(next); + paintExternalReadback(next); // The installed native SessionSnapshot selects exactly one UI authority. const session=next?.raw?.mixerSession; const offline=next?.raw?.logicalMixer; @@ -2975,6 +3050,13 @@ if(t.input===INTERNAL_BUS)choices.push(INTERNAL_BUS); return choices; }, + externalChoices(t) { + if(t?.kind==="master")return ["None"]; + const labels=hardwareOutputPairs().map(p=>p.label); + if(t?.externalOutput && !labels.includes(t.externalOutput)) + labels.push(t.externalOutput); + return labels; + }, outputChoices(t) { if(logicalView&&t?.kind==="master")return ["Choose audio output"]; if(t?.kind==="master") From 988b66f3240d77d3698f8c1e85b716d1225410ae Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:51:52 +0700 Subject: [PATCH 15/53] O1 approved native EXTERNAL OUT: typed gesture, amplifier confirmation, ACK then readback --- web/approved-native-bridge.js | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 561c95a04..dfd3632bf 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -2410,6 +2410,16 @@ } }); + backend.addEventListener("arMixExternalOutputAck",ack=>{ + if(!pendingExternal || pendingExternal.requestId!==ack?.requestId)return; + if(ack.ok!==true){ + const error=String(ack.error||"Physical output assignment rejected"); + pendingExternal=null; + nativeToast(error);status(error);controller?.subscribe();return; + } + pendingExternal.acked=true; + controller?.subscribe(); // Native ACK does NOT establish LIVE readback + }); backend.addEventListener("arMixNativeSessionAck",ack=>{ const save=ack?.operation==="SAVE"; if(!save&&ack?.operation!=="OPEN")return; @@ -3137,6 +3147,45 @@ else dispatchQueuedSource(); return true; } + if(field==="external"){ + if(event.type!=="change")return true; + const previous=t.externalOutput||"None"; + const id=nativeIdFor(t),ch=controller?.state()?.current?.graph?.channels + ?.find(row=>row.id===id),d=hardware?.device; + const pair=hardwareOutputPairs().find(row=>row.label===el.value); + const revision=hardware?.raw?.externalRevision; + const epoch=hardware?.device?.epoch; + if(pendingExternal||!pair||!ch || + !["INPUT","GROUP","FX_RETURN"].includes(ch.role) || + !controller?.state()?.current?.admitted || + d?.backend!=="ASIO" || safeNativeCounter(epoch)===null || + safeNativeCounter(revision)===null){ + el.value=previous; + nativeToast("EXTERNAL OUT unavailable · check ASIO, graph and pins"); + return true; + } + if(pair.label===previous){el.value=previous;return true;} + const confirmed=pair.left<0 || window.confirm( + "Enable ASIO OUT "+(pair.left+1)+"/"+(pair.right+1)+ + " for "+t.name+"? Verify the amplifier/speakers first. "+ + "INTERNAL OUT will stay unchanged."); + if(!confirmed){el.value=previous;return true;} + const requestId="out-o-"+(++externalSerial); + pendingExternal={requestId,channelId:id,left:pair.left,right:pair.right, + epoch,revision,acked:false}; + el.value=previous;el.setAttribute("aria-busy","true"); + backend.emitEvent("arMixAction",{action:"routingExternalOutput", + requestId,channelId:id,deviceEpoch:epoch,revision, + left:pair.left,right:pair.right,confirmed:true}); + window.setTimeout(()=>{ + if(pendingExternal?.requestId!==requestId)return; + pendingExternal=null;el.removeAttribute("aria-busy"); + nativeToast("EXTERNAL OUT timed out · last PCM retained"); + controller?.subscribe(); + },8000); + status("EXTERNAL OUT pending · native validation and readback"); + return true; + } if(field==="output"){ if(event.type!=="change")return true; if(t.kind==="master"){ From 709ab634d29bb99d19baf0d6f868b185fbb59047 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:53:34 +0700 Subject: [PATCH 16/53] O2 deterministic PCM tests: isolated BUS outputs, source only, native FX-once and stale edits --- tests/physical_external_output_pcm_test.cpp | 152 ++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/physical_external_output_pcm_test.cpp diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp new file mode 100644 index 000000000..36f586bf2 --- /dev/null +++ b/tests/physical_external_output_pcm_test.cpp @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// O1: deterministic buffer-level proof. This does not certify physical FAT. +#include "../engine/core/DynamicNativeSessionPublisher.h" +#include +#include +#include +#include +#include +#if defined(NDEBUG) +#undef NDEBUG +#endif +using namespace armix::mixer; + +static bool near(float a,float b,float eps=0.0001f) { + return std::abs(a-b),4> input{}; + std::array,8> output{}; + std::array inputPointers{}; + std::array outputPointers{}; + int callsA=0,callsB=0; + std::uint64_t epoch=9157,revision=1; + + Harness(bool sourceOnly=false) { + const std::array create{ + add(0,ChannelRole::input,"VOICE"), + add(1,ChannelRole::input,"MUSIC"), + add(2,ChannelRole::group,"BUS A"), + add(3,ChannelRole::group,"BUS B"), + add(4,ChannelRole::main,"MAIN") + }; + auto result=roster.edit(0,create); + assert(result.ok()&&result.createdIds.size()==5); + voice=result.createdIds[0];music=result.createdIds[1]; + busA=result.createdIds[2];busB=result.createdIds[3]; + main=result.createdIds[4]; + if(!sourceOnly) { + const std::array links{ + out(voice,busA),out(music,busB), + out(busA,main),out(busB,main) + }; + result=roster.edit(1,links);assert(result.ok()); + } + request.physicalInputs=4;request.maxFrames=frames; + request.sources={{voice,0,1,true},{music,2,3,true}}; + for(int s=0;s Date: Wed, 11 Nov 2026 09:53:52 +0700 Subject: [PATCH 17/53] O2 CI: include deterministic physical output CTest in existing Windows FAT build --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b866ca05b..eaa57d21d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,13 @@ if(BUILD_TESTING) # all CTests. Make its native session regression a build dependency so the # new executable is actually present (without editing the CI target list). add_dependencies(ARMixMixerRoutingTests ARMixDynamicAcceptedSessionTests) + # O1/O2: integrated deterministic PCM on the existing Windows FAT CTest. + # No additional workflow job or duplicate native build. + add_executable(ARMixPhysicalExternalOutputTests tests/physical_external_output_pcm_test.cpp) + target_compile_features(ARMixPhysicalExternalOutputTests PRIVATE cxx_std_20) + add_test(NAME O1PhysicalExternalOutputNativePcmAndFailClosedRouting + COMMAND ARMixPhysicalExternalOutputTests) + add_dependencies(ARMixMixerRoutingTests ARMixPhysicalExternalOutputTests) # Integration-only producer/consumer: accepted ChannelId readback + real # offline PCM with CH07/CH02, GROUP, wet FX RETURN and MONITOR. No new host. add_executable(ARMixConsoleBridgeV6Tests tests/console_native_integration_test.cpp From 4c96dcec129e122b75f14f5de80f83f82afa1e55 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:55:36 +0700 Subject: [PATCH 18/53] fix(o1): optional DOM dataset in lightweight native contract harness --- web/approved-native-bridge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index dfd3632bf..641a82385 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -799,7 +799,7 @@ t.externalOutput=value; const select=document.querySelector('.strip[data-id="'+t.id+ '"] select[data-field="external"]'); - if(!select)continue; + if(!select?.dataset)continue; // headless contract mocks may omit DOM dataset const labels=choices.map(p=>p.label); if(!labels.includes(value))labels.push(value); const signature=labels.join("|"); From 6bfe734e0853c52e3db07681744c26c4efebe518 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:57:14 +0700 Subject: [PATCH 19/53] O1: preserve immutable public Pages/V28 UI; insert native-only EXT controls in approved assembler --- site/preview-v2/index.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index c94db2a17..8d6bf0221 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -263,7 +263,6 @@ [splitSourceLabel(x.id,'PRE'),splitSourceLabel(x.id,'POST')])] :['None']; if(type==='output')return t.kind==='master'?['Default Output','Output 1 + 2','Speakers (Realtek)','Virtual Cable']:[...(t.kind==='audio'?['SOURCE ONLY (No Main)']:[]),master.name,...tracks.filter(x=>x.kind==='bus'&&x.id!==t.id).map(x=>x.name),'Output 1 + 2']; - if(type==='external')return ['None']; // physical output is native-only return ['None',...tracks.filter(x=>(x.kind==='bus'||x.kind==='fx')&&x.id!==t.id).map(x=>x.name)]; }; /* V53: demo-only insert identity, one reversible transaction per real move. @@ -692,10 +691,7 @@ if(t.kind==='audio')code+='
IN
'; else if(t.kind==='bus'||t.kind==='fx')code+='
IN'+(t.kind==='bus'?'GROUP':'FX RETURN')+'
'; else code+='
INSUM BUS
'; - code+='
OUT
'; - if(t.kind!=='master') - code+='
EXT
'; - code+=''; + code+='
OUT
'; code+=sectionFx(t)+sectionSend(t); code+='
PAN'+panLabel(t.pan)+'
'; From 7d7b6a24181967fe953a3b1d4675c2df6b915492 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:57:17 +0700 Subject: [PATCH 20/53] O1: preserve immutable public Pages/V28 UI; insert native-only EXT controls in approved assembler --- site/preview-v2/assets/mixer-section-layout.css | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/site/preview-v2/assets/mixer-section-layout.css b/site/preview-v2/assets/mixer-section-layout.css index 918f956d5..638312ccd 100644 --- a/site/preview-v2/assets/mixer-section-layout.css +++ b/site/preview-v2/assets/mixer-section-layout.css @@ -28,8 +28,8 @@ .console-body{ --strip-w:150px;--master-w:152px; } -.console-body[data-density="standard"]{--strip-w:125px;--master-w:132px;--switch-h:39px;--pan-h:36px;--trim-h:27px;--route-h:91px} -.console-body[data-density="compact"]{--strip-w:105px;--master-w:116px;--switch-h:32px;--route-h:81px;--pan-h:30px;--trim-h:23px} +.console-body[data-density="standard"]{--strip-w:125px;--master-w:132px;--switch-h:39px;--pan-h:36px;--trim-h:27px;--route-h:70px} +.console-body[data-density="compact"]{--strip-w:105px;--master-w:116px;--switch-h:32px;--route-h:58px;--pan-h:30px;--trim-h:23px} .console-body .strip,.console-body.narrow .strip:not(.master){ width:var(--strip-w);min-width:var(--strip-w);flex:0 0 var(--strip-w); @@ -143,11 +143,3 @@ .console-body .switch:focus-visible,.console-body .route-select:focus-visible{outline:2px solid #7ecae3;outline-offset:0} .console-body .rail-cell.fader{min-height:118px} @media(max-height:610px){.console-body .rail-cell.fader{min-height:86px}} - -/* O1 physical OUT: same official strip, one extra compact native pair row. */ -.console-body:not([data-density="standard"]):not([data-density="compact"]){--route-h:94px} -.console-body .external-out-field .route-caption{color:#a8d0dd} -.console-body .external-out-field .route-select{border-color:#547685;background-color:#192a32} -.console-body .external-out-field .route-select[aria-busy="true"]{border-color:#ddb576} -.console-body .external-out-field .route-select[data-status="NEEDS_REMAP"]{color:#d5aa8b} -.console-body[data-density="compact"] .external-out-field .route-caption{font-size:9px} From 8e96a7e3c60f9d66bdd0656219b454c6b762c4e6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:57:49 +0700 Subject: [PATCH 21/53] O1 native-only approved Pages assembly: compact EXT row without public V28 HTML/CSS drift --- scripts/build_approved_native_gui.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index c75af0d8e..1ef79e92e 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -23,7 +23,16 @@ NATIVE_ADAPTER = ROOT / "web" / "approved-native-bridge.js" ADAPTER_MARKER = ('\n' '\n' - '') + '\n' + '') SCHEMA = "arsonmix.approved-native-pages-bundle.v2" @@ -100,6 +109,15 @@ def accepted_pages_html() -> str: " return window.__ARMIX_NATIVE_M2__?.inputChoices?.(t)||['None'];\n" " if(type==='output'&&window.__JUCE__?.backend)\n" " return window.__ARMIX_NATIVE_M2__?.outputChoices?.(t)||[t.output];\n"), + (" code+=sectionFx(t)+sectionSend(t);\n", + " if(t.kind!=='master'){\n" + " if(!code.endsWith(''))throw Error('Native O1 route anchor drift');\n" + " const extRow='
EXT'+\n" + " '
';\n" + " code=code.slice(0,-6)+extRow+'';\n" + " }\n" + " code+=sectionFx(t)+sectionSend(t);\n"), ("function wireGraphCommit(ops,{record=true}={}){\n", "function wireGraphCommit(ops,{record=true}={}){\n" " if(window.__JUCE__?.backend){window.__ARMIX_NATIVE_M2__?.consumeWire?.(ops);return false;}\n"), From 539ee0d65ffa8705f3d596245ab8c032878e43ed Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:58:37 +0700 Subject: [PATCH 22/53] O1 DSP: align all physical buses in PDC and publish callback-applied output identity --- engine/core/DynamicPreparedMixerBlock.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/engine/core/DynamicPreparedMixerBlock.h b/engine/core/DynamicPreparedMixerBlock.h index 495354f3f..5329ae325 100644 --- a/engine/core/DynamicPreparedMixerBlock.h +++ b/engine/core/DynamicPreparedMixerBlock.h @@ -279,6 +279,16 @@ class DynamicPreparedMixerBlock final { return {externalLeft(pair),externalRight(pair)}; } + // Independent audio-callback proof: APPLIED differs from merely + // requested until the existing hardware render finishes its transition. + std::pair appliedExternalOutput(ChannelId id) const noexcept { + const auto it=controlIndex_.find(id.value); + if(it==controlIndex_.end())return {-1,-1}; + const auto pair=externalAppliedTargets_[it->second].load( + std::memory_order_acquire); + return {externalLeft(pair),externalRight(pair)}; + } + // CONTROL-only DAG PDC. Every fan-in receives sample-aligned PCM, // including a destination's own hardware capture and PRE-fader sends. // A failure discards the unpublished candidate; the old graph stays live. @@ -317,6 +327,9 @@ class DynamicPreparedMixerBlock final { lanes_[i].role==ChannelRole::fxReturn) externalTerminal=std::max(externalTerminal,output[i]); } + // Across independent physical buses, PDC shares a single target. + terminal=std::max(terminal,externalTerminal); + externalTerminal=terminal; for(const auto i:renderOrder_) { const auto& lane=lanes_[i]; if((lane.inputL>=0 || lane.playerDeckId!=0) && @@ -575,9 +588,12 @@ class DynamicPreparedMixerBlock final { target.gate.reset(next.initialAudible_[i]?1.f:0.f); } next.externalTargets_=std::make_unique[]>(rows.size()); + next.externalAppliedTargets_=std::make_unique[]>(rows.size()); next.externalFades_=std::make_unique(rows.size()); - for(std::size_t i=0;i(next.edges_.size()); for(std::size_t e=0;e sourceFades_; std::unique_ptr sendTargets_; std::unique_ptr[]> externalTargets_; + std::unique_ptr[]> externalAppliedTargets_; std::unique_ptr externalFades_; std::size_t main_=notScheduled,monitor_=notScheduled; bool mainMonoAfterFx_=false; From 2b92dfa2b3b6222499878a304eb835d149d59077 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:58:45 +0700 Subject: [PATCH 23/53] O1 publisher: return physical tap identity actually applied by audio callback --- engine/core/DynamicNativeSessionPublisher.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/core/DynamicNativeSessionPublisher.h b/engine/core/DynamicNativeSessionPublisher.h index df3453813..5e6336481 100644 --- a/engine/core/DynamicNativeSessionPublisher.h +++ b/engine/core/DynamicNativeSessionPublisher.h @@ -276,6 +276,12 @@ class DynamicNativeSessionPublisher final { return p?p->graph.externalOutput(id):std::pair{-1,-1}; } + std::pair appliedExternalOutput(std::uint64_t epoch, + std::uint64_t revision,ChannelId id) const noexcept { + const auto* p=publisher_.controlPrepared(epoch,revision); + return p?p->graph.appliedExternalOutput(id):std::pair{-1,-1}; + } + // M3C realtime parameters on the accepted ChannelId graph ONLY. // Caller must propagate the real device epoch and native ACK revision. // Rejected/stale edits leave the last accepted PCM unchanged. From e71ce610bf8738926a721f3043a59996cd746dde Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:58:57 +0700 Subject: [PATCH 24/53] O1 native readback: LIVE only after real PCM callback applied external target --- src/LiveDryRoutingLab.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 91c4fd193..f4aa8544b 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -3341,13 +3341,18 @@ class LiveDryRoutingLab final { row->setProperty("rightName",patch.rightName); const auto live=nativePublisher_.externalOutput( nativeAccepted_.deviceEpoch,nativeAccepted_.pcmRevision,patch.channel); + const auto applied=nativePublisher_.appliedExternalOutput( + nativeAccepted_.deviceEpoch,nativeAccepted_.pcmRevision,patch.channel); const bool installed=nativePcm && externalOutputEpoch_==epoch() && live.first>=0 && live.second>=0 && + applied==live && live.firstsetProperty("status",installed?"LIVE":"NEEDS_REMAP"); + row->setProperty("status",installed?"LIVE": + (nativePcm && externalOutputEpoch_==epoch() && live.first>=0 && + live.second>=0)?"PENDING":"NEEDS_REMAP"); external.add(juce::var(row.release())); } out->setProperty("externalOutputs",juce::var(external)); From 8036aa44ec0e5b98c2257da73a8fc4a892b3b899 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 09:59:12 +0700 Subject: [PATCH 25/53] O1 native UI: distinguish pending callback PCM from stale hardware NEEDS_REMAP --- web/approved-native-bridge.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 641a82385..0c4ffd8c0 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -518,8 +518,9 @@ native.raw.externalOutputs.find(x=>x.channelId===ch.id):null; const pair=direct && hardwareOutputPairs().find(p=> p.left===direct.physicalLeft&&p.right===direct.physicalRight); - t.externalOutput=direct?(direct.status==="LIVE"&&pair? - pair.label:"Needs Remap · OUT "+(direct.physicalLeft+1)+"/"+(direct.physicalRight+1)):"None"; + t.externalOutput=direct?(direct.status==="LIVE"&&pair?pair.label: + (direct.status==="PENDING"?"Pending · ":"Needs Remap · ")+ + "OUT "+(direct.physicalLeft+1)+"/"+(direct.physicalRight+1)):"None"; t.selected=previous.get(t.id)?.selected || false; if(typeof ch.fxRackBypassed==="boolean")t.fxOn=!ch.fxRackBypassed; if (Array.isArray(ch.inserts)) { @@ -793,9 +794,11 @@ const match=row&&choices.find(p=>p.left===row.physicalLeft && p.right===row.physicalRight); const state=row?.status==="LIVE"&&match?"LIVE": + row?.status==="PENDING"&&match?"PENDING": row?"NEEDS_REMAP":"NONE"; const value=row?(state==="LIVE"?match.label: - "Needs Remap · OUT "+(row.physicalLeft+1)+"/"+(row.physicalRight+1)):"None"; + (state==="PENDING"?"Pending · ":"Needs Remap · ")+ + "OUT "+(row.physicalLeft+1)+"/"+(row.physicalRight+1)):"None"; t.externalOutput=value; const select=document.querySelector('.strip[data-id="'+t.id+ '"] select[data-field="external"]'); @@ -812,7 +815,8 @@ } if(select.value!==value)select.value=value; select.dataset.status=state; - select.title=state==="NEEDS_REMAP"? + select.title=state==="PENDING"?"Native PCM pending · wait for audio callback": + state==="NEEDS_REMAP"? "Saved physical output disarmed; choose a verified ASIO pair": state==="LIVE"?"LIVE · independent native post-fader PCM": "None · internal WIRE remains unchanged"; From 069d57c8cfe671d5dc1baff74b57fdeb8301da0b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:02:46 +0700 Subject: [PATCH 26/53] O1 realtime safety: latch and validate each external tap target exactly once per block --- engine/core/DynamicPreparedMixerBlock.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/core/DynamicPreparedMixerBlock.h b/engine/core/DynamicPreparedMixerBlock.h index 5329ae325..3aae8befe 100644 --- a/engine/core/DynamicPreparedMixerBlock.h +++ b/engine/core/DynamicPreparedMixerBlock.h @@ -590,6 +590,7 @@ class DynamicPreparedMixerBlock final { next.externalTargets_=std::make_unique[]>(rows.size()); next.externalAppliedTargets_=std::make_unique[]>(rows.size()); next.externalFades_=std::make_unique(rows.size()); + next.externalBlockTargets_.assign(rows.size(),noExternal); for(std::size_t i=0;i blockTargets_; // all allocated before RT std::vector scratch_; std::vector edgeDelays_,physicalDelays_,sinkDelays_,externalDelays_; + std::vector externalBlockTargets_; // preallocated, AUDIO-only writes int latencySamples_=0; std::unique_ptr channelTargets_; std::unique_ptr[]> sourceTargets_; From fa47696f7e4c017d10b85df1bfbfe531d0d8845d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:03:54 +0700 Subject: [PATCH 27/53] O2 .smix regression: physical output ChannelId round-trip, legacy decode and malicious mappings --- tests/native_mixer_session_store_test.cpp | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/native_mixer_session_store_test.cpp b/tests/native_mixer_session_store_test.cpp index d791bed18..a450ae836 100644 --- a/tests/native_mixer_session_store_test.cpp +++ b/tests/native_mixer_session_store_test.cpp @@ -1162,6 +1162,40 @@ static void verifyHotkeyDocumentIdentityAndMigration() { assert(!Codec::decode(juce::JSON::toString(unsafe,false),decoded)); } +static void verifyExternalOutputPortableIntent() { + auto doc=makeSession(); + // Two additional amplifier pairs are physical intent, not armed state. + doc.binding.outputMask="ff"; + doc.binding.outputNames={"ASIO OUT 1","ASIO OUT 2", + "ASIO OUT 3","ASIO OUT 4","ASIO OUT 5","ASIO OUT 6", + "ASIO OUT 7","ASIO OUT 8"}; + doc.outputs.activeOutputChannels=8; + doc.externalOutputs.push_back({{16},2,3,"ASIO OUT 3","ASIO OUT 4"}); + doc.externalOutputs.push_back({{12},4,5,"ASIO OUT 5","ASIO OUT 6"}); + const auto encoded=Codec::encode(doc); + MixerSessionDocument loaded; + assert(Codec::decode(encoded,loaded)); + assert(loaded.externalOutputs.size()==2); + assert(loaded.externalOutputs[0].channel.value==16); + assert(loaded.externalOutputs[0].left==2); + assert(loaded.externalOutputs[0].right==3); + assert(loaded.externalOutputs[0].leftName=="ASIO OUT 3"); + assert(loaded.externalOutputs[1].channel.value==12); + // Legacy sessions without the optional field retain their native mixer. + doc.externalOutputs.clear(); + assert(Codec::decode(Codec::encode(doc),loaded)); + assert(loaded.externalOutputs.empty()); + // Corrupted pair, duplicate ChannelId or missing pin name fail closed. + doc.externalOutputs.push_back({{16},3,4,"ASIO OUT 4","ASIO OUT 5"}); + assert(!Codec::decode(Codec::encode(doc),loaded)); + doc.externalOutputs[0]={ {16},2,3,"ASIO OUT 3","ASIO OUT 4" }; + doc.externalOutputs.push_back(doc.externalOutputs[0]); + assert(!Codec::decode(Codec::encode(doc),loaded)); + doc.externalOutputs.pop_back(); + doc.externalOutputs[0].leftName.clear(); + assert(!Codec::decode(Codec::encode(doc),loaded)); +} + int main(){ verifyDurableNativeFxPowerIdentity(); verifyHotkeyDocumentIdentityAndMigration(); @@ -1189,6 +1223,7 @@ int main(){ warmVst3Discovery(); nativeDeviceRecovery(); auto d=makeSession(); + verifyExternalOutputPortableIntent(); const auto before=Codec::encode(d); MixerSessionDocument restored; assert(Codec::decode(before,restored)); From 2d8e0d86556f6c30da68fbf4f7d6f272934dd95b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:05:03 +0700 Subject: [PATCH 28/53] O1 safety: per-channel amplifier authorization and no stale output re-arm after device swap --- src/LiveDryRoutingLab.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index f4aa8544b..8493e6381 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -2359,10 +2359,17 @@ class LiveDryRoutingLab final { amended.erase(std::remove_if(amended.begin(),amended.end(), [channel](const auto& p){return p.channel==channel;}),amended.end()); if(!none)amended.push_back(candidate); + // Per-ChannelId authorization: remapping ONE channel on a new device + // never re-arms other saved amplifiers at matching old port numbers. + auto verified=externalOutputEpoch_==expectedEpoch? + externalOutputVerified_:std::vector{}; + std::erase(verified,channel.value); + if(!none)verified.push_back(channel.value); if(!nativePublisher_.setExternalOutput(expectedEpoch,expectedRevision, channel,left,right,pins.outputCount)) return "EXTERNAL OUT: native graph rejected; previous sound retained"; externalOutputAssignments_=std::move(amended); + externalOutputVerified_=std::move(verified); externalOutputEpoch_=expectedEpoch; return {}; } @@ -2371,8 +2378,18 @@ class LiveDryRoutingLab final { // verified epoch. Reinstall only existing known pins: never auto-arm // stale destinations after a device restart or a different ASIO device. void reapplyExternalOutputsSameEpoch() noexcept { + // Remove deleted ChannelIds BEFORE saving an updated .smix. + std::erase_if(externalOutputAssignments_,[&](const auto& p){ + return nativeAccepted_.graph.roster.find(p.channel)==nullptr; + }); + std::erase_if(externalOutputVerified_,[&](const auto id){ + return nativeAccepted_.graph.roster.find(armix::mixer::ChannelId{id})==nullptr; + }); if(externalOutputEpoch_!=nativeAccepted_.deviceEpoch)return; for(const auto& p:externalOutputAssignments_) { + if(std::find(externalOutputVerified_.begin(), + externalOutputVerified_.end(),p.channel.value)== + externalOutputVerified_.end())continue; int left=-1,right=-1; const int count=callbackOutputCount_.load(std::memory_order_acquire); for(int i=0;i waitingAsioInputs_; std::vector externalOutputAssignments_; + std::vector externalOutputVerified_; // per amplifier, CONTROL only std::uint64_t externalOutputEpoch_=0; // CONTROL only, never callback state // Four 9-bit callback indices (0 means absent) and the prepared quantum. // One atomic read gives AUDIO a coherent destination/quantum contract. From d0ccd611e6ad59d0870cce9941102cd750ce0e0c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:31:24 +0700 Subject: [PATCH 29/53] O2 tests: assert 4/8-output PCM isolation and callback-applied readback --- tests/physical_external_output_pcm_test.cpp | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index 36f586bf2..d90afb20b 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -125,6 +125,42 @@ static void verifySourceOnlyAndSharedSums() { assert(near(h.output[3][63],.04f)); assert(h.publisher.externalOutput(h.epoch,1,h.voice).first==-1); } +// Full eight-pin fixture: each destination receives a distinct accepted +// ChannelId post-FX PCM signal. This is NOT a physical-device FAT. +static void verifyEightPinIsolationAndAppliedReadback() { + Harness h; + assert(h.publisher.setExternalOutput(h.epoch,1,h.busA,2,3,8)); + assert(h.publisher.setExternalOutput(h.epoch,1,h.busB,4,5,8)); + assert(h.publisher.setExternalOutput(h.epoch,1,h.voice,6,7,8)); + // A CONTROL target is not evidence that the callback has installed PCM. + assert(h.publisher.appliedExternalOutput(h.epoch,1,h.busA).first==-1); + assert(h.render(8)); + assert(h.callsA==1 && h.callsB==1); + assert(near(h.output[0][63],.71f)); + assert(near(h.output[1][63],.32f)); + assert(near(h.output[2][63],.50f)); + assert(near(h.output[3][63],.20f)); + assert(near(h.output[4][63],.21f)); + assert(near(h.output[5][63],.12f)); + assert(near(h.output[6][63],.25f)); + assert(near(h.output[7][63],.10f)); + const auto applied=h.publisher.appliedExternalOutput(h.epoch,1,h.busA); + assert(applied.first==2 && applied.second==3); + // Only physically supplied callback destinations may be targeted. + assert(!h.publisher.setExternalOutput(h.epoch,1,h.busB,6,7,4)); + assert(h.render(8)); + assert(near(h.output[4][63],.21f)); +} +static void verifyFourPinMainAndOneBus() { + Harness h; + assert(h.publisher.setExternalOutput(h.epoch,1,h.busA,2,3,4)); + assert(!h.publisher.setExternalOutput(h.epoch,1,h.busB,4,5,4)); + assert(h.render(4)); + assert(h.callsA==1 && h.callsB==1); + assert(near(h.output[0][63],.71f)); + assert(near(h.output[2][63],.50f)); + assert(near(h.output[3][63],.20f)); +} static void verifyLiveFaderMuteAnd2PortBounds() { Harness h; // A 2-output device has no third/fourth callback ordinal. A driver-level @@ -145,6 +181,8 @@ static void verifyLiveFaderMuteAnd2PortBounds() { } int main() { verifyIndependentBusPcmAndOncePerFx(); + verifyEightPinIsolationAndAppliedReadback(); + verifyFourPinMainAndOneBus(); verifySourceOnlyAndSharedSums(); verifyLiveFaderMuteAnd2PortBounds(); std::puts("O1 physical external OUT: independent PCM, SRC ONLY, gain/mute, shared sum and stale target PASS"); From f70a0aa716e91fd1f4810e6a7027be2c45be6ce5 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:43:46 +0700 Subject: [PATCH 30/53] O1 safety: clear all physical ASIO taps on muted or rejected native callback --- engine/core/DynamicNativeSessionPublisher.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/engine/core/DynamicNativeSessionPublisher.h b/engine/core/DynamicNativeSessionPublisher.h index 5e6336481..4d96f8ce6 100644 --- a/engine/core/DynamicNativeSessionPublisher.h +++ b/engine/core/DynamicNativeSessionPublisher.h @@ -172,11 +172,18 @@ class DynamicNativeSessionPublisher final { static_assert(std::is_nothrow_invocable_v, "Realtime VST dispatch must be noexcept"); const auto clearOutputs=[&]() noexcept { - if(frames>0 && mainL)std::fill_n(mainL,frames,0.f); - if(frames>0 && mainR && mainR!=mainL)std::fill_n(mainR,frames,0.f); - if(frames>0 && monitorL)std::fill_n(monitorL,frames,0.f); - if(frames>0 && monitorR && monitorR!=monitorL) - std::fill_n(monitorR,frames,0.f); + // A rejected/stale/muted native render must silence *every* + // ASIO destination, not only MAIN/MONITOR. Otherwise a previous + // external tap can remain in a driver-provided output buffer. + // Bounded callback-ordinal traversal; no allocations or locks. + if(frames<=0 || frames>8192)return; + if(hardwareOutputs && hardwareOutputCount>0 && hardwareOutputCount<=256) + for(int c=0;c8192 || !mainL || !mainR || mainL==mainR || physicalCount<0 || physicalCount>256 || From 2eb4c1a61a0292bb564ba6bcca2fe57fcb588d17 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:44:00 +0700 Subject: [PATCH 31/53] O2 regression: stale epoch and mute silence all eight physical output buffers --- tests/physical_external_output_pcm_test.cpp | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index d90afb20b..749730604 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -161,6 +161,28 @@ static void verifyFourPinMainAndOneBus() { assert(near(h.output[2][63],.50f)); assert(near(h.output[3][63],.20f)); } +// A failed/revoked render must silence ALL ASIO callback pins. Previously +// only MAIN/MONITOR were cleared, leaving potentially stale amplifier PCM. +static void verifyFailClosedAllPhysicalOutputBuffers() { + Harness h; + assert(h.publisher.setExternalOutput(h.epoch,1,h.busA,2,3,8)); + assert(h.render(8)); + const auto fx=[](ChannelId,float*,float*,int) noexcept {}; + for(auto& output:h.output)output.fill(.875f); + assert(!h.publisher.render(h.epoch,h.inputPointers.data(),4, + h.output[0].data(),h.output[1].data(),Harness::frames,true,fx, + nullptr,nullptr,{},{},{},h.outputPointers.data(),8)); + for(const auto& output:h.output) + for(float sample:output)assert(near(sample,0.f)); + // An epoch mismatch also revokes the physical taps, without leaking + // the last render or invoking any hosted plug-in. + for(auto& output:h.output)output.fill(.875f); + assert(!h.publisher.render(h.epoch+1,h.inputPointers.data(),4, + h.output[0].data(),h.output[1].data(),Harness::frames,false,fx, + nullptr,nullptr,{},{},{},h.outputPointers.data(),8)); + for(const auto& output:h.output) + for(float sample:output)assert(near(sample,0.f)); +} static void verifyLiveFaderMuteAnd2PortBounds() { Harness h; // A 2-output device has no third/fourth callback ordinal. A driver-level @@ -183,6 +205,7 @@ int main() { verifyIndependentBusPcmAndOncePerFx(); verifyEightPinIsolationAndAppliedReadback(); verifyFourPinMainAndOneBus(); + verifyFailClosedAllPhysicalOutputBuffers(); verifySourceOnlyAndSharedSums(); verifyLiveFaderMuteAnd2PortBounds(); std::puts("O1 physical external OUT: independent PCM, SRC ONLY, gain/mute, shared sum and stale target PASS"); From f2b8fc5b003a123d2af05f94d480ea8162014b8b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:48:18 +0700 Subject: [PATCH 32/53] O2: qualify sparse ASIO output ordinals and aliased callback fail-closed PCM --- tests/juce_active_port_snapshot_test.cpp | 14 ++++++++++++++ tests/physical_external_output_pcm_test.cpp | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/juce_active_port_snapshot_test.cpp b/tests/juce_active_port_snapshot_test.cpp index 06fd698b7..246245971 100644 --- a/tests/juce_active_port_snapshot_test.cpp +++ b/tests/juce_active_port_snapshot_test.cpp @@ -49,6 +49,20 @@ int main(){ assert(!JuceActivePortSnapshot::fromMasks(13,in,out,snap,fault)); assert(fault==JuceActivePortSnapshot::Fault::emptyOutput); assert(snap.inputs.callbackIndex(9)==-1); // failed 0-OUT preserves accepted zero-input snapshot + // Sparse ASIO mask: physical OUT 5/6 are callback ordinals 2/3. + juce::BigInteger sparse; + for(const int pin: {0,1,4,5})sparse.setBit(pin); + assert(JuceActivePortSnapshot::fromMasks(14,in,sparse,snap,fault)); + assert(snap.outputCount==4); + assert(snap.outputPhysicalPort(0)==0); + assert(snap.outputPhysicalPort(1)==1); + assert(snap.outputPhysicalPort(2)==4); + assert(snap.outputPhysicalPort(3)==5); + assert(snap.matchesCallback(14,0,4)); + sparse.clearBit(5); // no fabricated partner for physical OUT 5 + assert(JuceActivePortSnapshot::fromMasks(15,in,sparse,snap,fault)); + assert(snap.outputCount==3 && snap.outputPhysicalPort(2)==4); + assert(snap.outputPhysicalPort(3)==-1); assert(!JuceActivePortSnapshot::capture(nullptr,12,snap,fault)); assert(fault==JuceActivePortSnapshot::Fault::nullDevice); } diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index 749730604..237712be6 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -183,6 +183,17 @@ static void verifyFailClosedAllPhysicalOutputBuffers() { for(const auto& output:h.output) for(float sample:output)assert(near(sample,0.f)); } +// Invalid ASIO callback alias must not borrow a MAIN or MONITOR pin. +// All physical buffers are cleared on the failed render. +static void verifyAliasedCallbackPinFailsClosed() { + Harness h; + assert(h.publisher.setExternalOutput(h.epoch,1,h.busA,2,3,8)); + h.outputPointers[2]=h.output[0].data(); // same buffer at another ordinal + for(auto& output:h.output)output.fill(.625f); + assert(!h.render(8)); + for(const auto& output:h.output) + for(float sample:output)assert(near(sample,0.f)); +} static void verifyLiveFaderMuteAnd2PortBounds() { Harness h; // A 2-output device has no third/fourth callback ordinal. A driver-level @@ -206,6 +217,7 @@ int main() { verifyEightPinIsolationAndAppliedReadback(); verifyFourPinMainAndOneBus(); verifyFailClosedAllPhysicalOutputBuffers(); + verifyAliasedCallbackPinFailsClosed(); verifySourceOnlyAndSharedSums(); verifyLiveFaderMuteAnd2PortBounds(); std::puts("O1 physical external OUT: independent PCM, SRC ONLY, gain/mute, shared sum and stale target PASS"); From 29670b376a05a36a89871628367cdefc5c593c5f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 10:48:39 +0700 Subject: [PATCH 33/53] O2 fixture: assert only driver-exposed buffers on alias rejection --- tests/physical_external_output_pcm_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index 237712be6..69e97d1a8 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -191,8 +191,11 @@ static void verifyAliasedCallbackPinFailsClosed() { h.outputPointers[2]=h.output[0].data(); // same buffer at another ordinal for(auto& output:h.output)output.fill(.625f); assert(!h.render(8)); - for(const auto& output:h.output) - for(float sample:output)assert(near(sample,0.f)); + // Verify only the eight buffers actually exported by this callback. + // output[2] has been deliberately detached and must not be counted. + for(int c=0;c<8;++c) + for(int frame=0;frame Date: Wed, 11 Nov 2026 10:50:02 +0700 Subject: [PATCH 34/53] O2: enforce real CTest PCM and sparse mask assertions in MSVC Release --- tests/juce_active_port_snapshot_test.cpp | 2 +- tests/physical_external_output_pcm_test.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/juce_active_port_snapshot_test.cpp b/tests/juce_active_port_snapshot_test.cpp index 246245971..f6ee57979 100644 --- a/tests/juce_active_port_snapshot_test.cpp +++ b/tests/juce_active_port_snapshot_test.cpp @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-only -#include "../engine/device/JuceActivePortSnapshot.h" #if defined(NDEBUG) #undef NDEBUG #endif +#include "../engine/device/JuceActivePortSnapshot.h" #include #include using namespace armix::device; diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index 69e97d1a8..e4f2be7b6 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -1,4 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only +#if defined(NDEBUG) +#undef NDEBUG +#endif // O1: deterministic buffer-level proof. This does not certify physical FAT. #include "../engine/core/DynamicNativeSessionPublisher.h" #include @@ -6,9 +9,6 @@ #include #include #include -#if defined(NDEBUG) -#undef NDEBUG -#endif using namespace armix::mixer; static bool near(float a,float b,float eps=0.0001f) { From 42a0342e0c46a0581f40b065e70cc7e77a6281bc Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:08:16 +0700 Subject: [PATCH 35/53] O2: native MAIN-only mute does not disarm separate ASIO taps --- engine/core/LiveOutputRouteGate.h | 18 ++++++++++++++++-- src/LiveDryRoutingLab.h | 13 ++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/engine/core/LiveOutputRouteGate.h b/engine/core/LiveOutputRouteGate.h index 1bb5f2bfa..b5c693bd4 100644 --- a/engine/core/LiveOutputRouteGate.h +++ b/engine/core/LiveOutputRouteGate.h @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-only #pragma once +#include namespace armix::mixer { // One mixer graph, two independent routing destinations. The direct output // is preferred for minimal latency; any optional secondary playback device @@ -8,11 +9,24 @@ struct LiveOutputRouteGate final { struct State {bool renderMain=false, hardware=false, secondary=false;}; static constexpr State evaluate(bool routeAccepted,bool directAuthorized, bool normal,bool stable,bool masterUnmuted, - bool hardwareArmed,bool secondaryArmed) noexcept { + bool hardwareArmed,bool secondaryArmed, + bool nativeMainOnlyMute=false) noexcept { + // Native MAIN mute controls MAIN PCM, not physical BUS/EXT authorization. + // Actual global/device/epoch revocation still stops ALL outputs. const bool eligible=routeAccepted && directAuthorized && normal && - stable && masterUnmuted; + stable && (masterUnmuted || nativeMainOnlyMute); return {eligible&&(hardwareArmed||secondaryArmed), eligible&&hardwareArmed,eligible&&secondaryArmed}; } }; +// No extra graph, lock or FX pass: smooth just the MAIN output amplitude. +struct MainOnlyMuteSlew final { + float gain=1.f; + void reset(bool muted) noexcept {gain=muted?0.f:1.f;} + float next(bool muted) noexcept { + constexpr float step=1.f/64.f; + gain=muted?std::max(0.f,gain-step):std::min(1.f,gain+step); + return gain; + } +}; } diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 8493e6381..24b976249 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -18,6 +18,7 @@ #include "../engine/core/RealtimeRoutePublisher.h" #include "../engine/core/RealtimeRenderPermit.h" #include "../engine/core/ProductionRenderAudit.h" +#include "../engine/core/LiveOutputRouteGate.h" #include "../engine/device/LiveInputPortRegistry.h" #include #include @@ -2904,7 +2905,8 @@ class LiveDryRoutingLab final { std::array* actualOutputPair=nullptr, std::array* actualMonitorPair=nullptr, bool allowMutedMetering=false, - std::span playerPcm={}) noexcept { + std::span playerPcm={}, + bool mainOnlyMuted=false) noexcept { if(actualOutputPair)*actualOutputPair={{-1,-1}}; if(actualMonitorPair)*actualMonitorPair={{-1,-1}}; if(!active())return false; @@ -3024,6 +3026,8 @@ class LiveDryRoutingLab final { // Muted native metering uses scratch and keeps the output ramp at zero. const bool meterOnly=masterMuted && allowMutedMetering && channelIdRender; if(masterMuted) { + // True device disarm primes the next MAIN state without output blips. + mainOnlyMuteSlew_.reset(mainOnlyMuted); masterMonoPolicy_.primeWhileMuted(masterMono); fadeRemaining_=rampFrames; fadeFromL_=fadeFromR_=0.f; @@ -3147,6 +3151,12 @@ class LiveDryRoutingLab final { r=fadeFromR_+(r-fadeFromR_)*busRamp; --fadeRemaining_; } + // Mute only MAIN: BUS/EXTERNAL PCM remains live post-FX. + if(channelIdRender) { + const float mainGain=mainOnlyMuteSlew_.next(mainOnlyMuted); + l*=mainGain; + r*=mainGain; + } // Sample-smoothed, zero-heap dual-mono MASTER output policy. masterMonoPolicy_.process(masterMono,l,r); mainL[offset+i]=l; @@ -3457,4 +3467,5 @@ class LiveDryRoutingLab final { std::uint64_t audioRevision_=0,audioEpoch_=0; float fadeFromL_=0.f,fadeFromR_=0.f; float lastOutputL_=0.f,lastOutputR_=0.f; + armix::mixer::MainOnlyMuteSlew mainOnlyMuteSlew_{}; }; From 2709a7df6ee6b825e088b03f78eb213439fcaafc Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:10:24 +0700 Subject: [PATCH 36/53] O2: route MAIN-only mute through authoritative callback and fade all ASIO outputs --- engine/core/NativeOutputTransition.h | 32 ++++++++++++++++++++++++++ src/LiveAudioEngine.h | 34 ++++++++++------------------ 2 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 engine/core/NativeOutputTransition.h diff --git a/engine/core/NativeOutputTransition.h b/engine/core/NativeOutputTransition.h new file mode 100644 index 000000000..68f04a6db --- /dev/null +++ b/engine/core/NativeOutputTransition.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "FxMoveRamp.h" +#include +#include +namespace armix::mixer { +// One output-only de-click sweep after the authoritative native PCM graph. +// Covers MAIN, MONITOR and each EXTERNAL ASIO output. Constant-space AUDIO. +struct NativeOutputTransition final { + static void apply(float* const* outputs,int count,int frames, + int moveStage,bool fadeOut,bool fadeIn, + const float* mainL,const float* mainR, + float& mainPeakL,float& mainPeakR) noexcept { + mainPeakL=mainPeakR=0.f; + if(!outputs || count<=0 || frames<=0)return; + const float step=frames>1?1.f/static_cast(frames-1):0.f; + for(int c=0;c(i)*step; + const float graphGain=fadeOut?1.f-phase:fadeIn?phase:1.f; + pcm[i]*=graphGain*armix::dsp::FxMoveRamp::gain(moveStage,i,frames); + peak=std::max(peak,std::abs(pcm[i])); + } + if(pcm==mainL)mainPeakL=peak; + if(pcm==mainR)mainPeakR=peak; + } + } +}; +} // namespace armix::mixer diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index bae125d6c..978afdf3a 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -19,6 +19,7 @@ #include "../engine/device/JuceIndependentClockDevice.h" #include "../engine/device/LiveSecondaryOutputDevice.h" #include "../engine/core/LiveOutputRouteGate.h" +#include "../engine/core/NativeOutputTransition.h" #include "../engine/core/NativeRenderAuthority.h" #include "../engine/device/AsioPriorityDeviceManager.h" #include "../engine/device/AsioRegistryIdentityProbe.h" @@ -3144,6 +3145,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback if (renderOwner == armix::mixer::NativeRenderOwner::acceptedM4Session) { + const bool nativePcm=dryRoutingLab_.channelIdPhysicalPcmActive(); + const bool mainOnlyMuted=nativePcm && + masterMute_.load(std::memory_order_relaxed); const auto outputGate=armix::mixer::LiveOutputRouteGate::evaluate( dryRoutingLab_.active(), directFence_.permitted() && !independent_.active(), @@ -3152,7 +3156,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback !masterMute_.load(std::memory_order_relaxed), monitor_.load(std::memory_order_relaxed) && !topologyPublicationMute_.load(std::memory_order_acquire), - secondaryOutput_.armed()); + secondaryOutput_.armed(),nativePcm); const bool outputPermitted=outputGate.renderMain; // Native input PCM must remain observable even with safe output MUTE. // Scan bounded verified callback channels, no allocation or lock. @@ -3190,7 +3194,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback !routeReconfiguring_.load(std::memory_order_acquire) && !topologyPublicationMute_.load(std::memory_order_acquire), std::span( - deckBlocks.data(),deckCount)); + deckBlocks.data(),deckCount),mainOnlyMuted); // Constant-time, callback-local physical PCM tap. Nothing is // reconfigured or acquired from another graph generation. const auto nativeMain=armix::mixer::NativeOutputPairTap::select( @@ -3215,26 +3219,12 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback // Apply a single output de-click gain per sample, AFTER graph DSP, // without touching third-party plugin lifecycle on the callback. if(routedFxMove!=0 || cycle.fadeOut || cycle.fadeIn) { - const float step=samples>1?1.f/static_cast(samples-1):0.f; - // Fade both INDEPENDENT physical buses on FX MOVE or graph - // handoff, not only MAIN. Same callback, no second DSP pass. - for(int c=0;c<4;++c) { - auto* const out=c<2?nativeMain[static_cast(c)] - :nativeMonitor[static_cast(c-2)]; - if(!out)continue; - float peak=0.f; - for(int i=0;i(i)*step; - const float graphGain=cycle.fadeOut?1.f-phase: - cycle.fadeIn?phase:1.f; - const float moveGain=armix::dsp::FxMoveRamp::gain( - routedFxMove,i,samples); - out[i]*=graphGain*moveGain; - peak=juce::jmax(peak,std::abs(out[i])); - } - if(c==0)movedPeakL=peak; - else if(c==1)movedPeakR=peak; - } + // ONE post-FX envelope for MAIN, MONITOR and ALL physical + // ASIO taps. No second render, user ARM or blocking gate. + armix::mixer::NativeOutputTransition::apply( + outputs,outputChannels,samples,routedFxMove, + cycle.fadeOut,cycle.fadeIn, + nativeMain[0],nativeMain[1],movedPeakL,movedPeakR); if(routedFxMove==1 && cycle.graph) { cycle.graph->orderPacked.store( fxMovePendingOrder_.load(std::memory_order_acquire), From 02e5bdb546ed452bd9ee056afa21322b5eabaa78 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:11:10 +0700 Subject: [PATCH 37/53] O2 PCM: prove MAIN-only mute preserves 3 external taps and 8-pin FX handoff fade --- tests/physical_external_output_pcm_test.cpp | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/physical_external_output_pcm_test.cpp b/tests/physical_external_output_pcm_test.cpp index e4f2be7b6..b4afd357d 100644 --- a/tests/physical_external_output_pcm_test.cpp +++ b/tests/physical_external_output_pcm_test.cpp @@ -4,6 +4,8 @@ #endif // O1: deterministic buffer-level proof. This does not certify physical FAT. #include "../engine/core/DynamicNativeSessionPublisher.h" +#include "../engine/core/LiveOutputRouteGate.h" +#include "../engine/core/NativeOutputTransition.h" #include #include #include @@ -197,6 +199,58 @@ static void verifyAliasedCallbackPinFailsClosed() { for(int frame=0;frame(f+1)/64.f)); + mute.reset(true); // global disarm primes 0, preventing restart bleed + assert(near(mute.next(true),0.f)); + assert(h.render(8)); + float mainPeakL=0.f,mainPeakR=0.f; + armix::mixer::NativeOutputTransition::apply(h.outputPointers.data(),8, + Harness::frames,1,false,false,h.output[0].data(), + h.output[1].data(),mainPeakL,mainPeakR); + assert(mainPeakL>0.f&&mainPeakR>0.f); + for(const auto& pair:h.output) + assert(near(pair[63],0.f)); // ALL physical pins fade out + assert(h.callsA==2&&h.callsB==2); // effects executed ONCE per render + assert(h.render(8)); + armix::mixer::NativeOutputTransition::apply(h.outputPointers.data(),8, + Harness::frames,2,false,false,h.output[0].data(), + h.output[1].data(),mainPeakL,mainPeakR); + assert(near(h.output[2][0],0.f)&&near(h.output[2][63],.50f)); + assert(near(h.output[4][63],.21f)&&near(h.output[6][63],.25f)); + assert(h.callsA==3&&h.callsB==3); + // Global graph handoff declick also reaches every independent physical pin. + assert(h.render(8)); + armix::mixer::NativeOutputTransition::apply(h.outputPointers.data(),8, + Harness::frames,0,true,false,h.output[0].data(), + h.output[1].data(),mainPeakL,mainPeakR); + for(const auto& pair:h.output)assert(near(pair[63],0.f)); + assert(h.callsA==4&&h.callsB==4); +} static void verifyLiveFaderMuteAnd2PortBounds() { Harness h; // A 2-output device has no third/fourth callback ordinal. A driver-level @@ -221,6 +275,7 @@ int main() { verifyFourPinMainAndOneBus(); verifyFailClosedAllPhysicalOutputBuffers(); verifyAliasedCallbackPinFailsClosed(); + verifyMainOnlyMuteAndAllOutputFxTransitions(); verifySourceOnlyAndSharedSums(); verifyLiveFaderMuteAnd2PortBounds(); std::puts("O1 physical external OUT: independent PCM, SRC ONLY, gain/mute, shared sum and stale target PASS"); From 7118d79a902cc6cf1d9bcf74fa2306c7ce506a3a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:13:29 +0700 Subject: [PATCH 38/53] Update FX MOVE contract to verify shared eight-pin output de-click helper --- tests/live_graph_contract_test.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index dad4468c4..c2165769d 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -4,6 +4,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import {readFileSync} from 'node:fs'; const e=readFileSync('src/LiveAudioEngine.h','utf8'); +const externalTransition=readFileSync('engine/core/NativeOutputTransition.h','utf8'); const h=readFileSync('src/LiveGraphHandoff.h','utf8'); const m=readFileSync('src/Main.cpp','utf8'); const b=readFileSync('web/bridge.js','utf8'); @@ -87,11 +88,16 @@ test('R0B CH1 MOVE inside routed 10CH graph uses the same callback-boundary de-c const begin=e.indexOf('if (renderOwner ==',e.indexOf('callbackCount_.fetch_add')); const end=e.indexOf('const bool enabled = monitor_',begin); const routed=e.slice(begin,end); - assert.match(routed,/FxMoveRamp::gain\(\s*routedFxMove,i,samples\)/); + // The same FX MOVE envelope now runs across ALL native physical ASIO pins, + // in a shared output-only helper after the single authoritative DSP pass. + assert.match(routed,/NativeOutputTransition::apply\(/); + assert.match(routed,/outputs,outputChannels,samples,routedFxMove/); + assert.match(externalTransition,/for\(int c=0;corderPacked\.store/); - assert.ok(routed.indexOf('FxMoveRamp::gain') Date: Wed, 11 Nov 2026 13:17:18 +0700 Subject: [PATCH 39/53] O2: per-channel nonblocking EXT transactions, shared output warning and live state --- scripts/build_approved_native_gui.py | 6 ++- tests/approved_native_m2_contract.test.cjs | 14 +++++ web/approved-native-bridge.js | 61 +++++++++++++++------- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index 1ef79e92e..7c7935504 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -32,6 +32,10 @@ '.armix-native-desktop .external-out-field .route-select{border-color:#547685;background:#192a32}\n' '.armix-native-desktop .external-out-field .route-select[aria-busy="true"]{border-color:#ddb576}\n' '.armix-native-desktop .external-out-field .route-select[data-status="NEEDS_REMAP"]{color:#d5aa8b}\n' + '.armix-native-desktop .external-out-state{font:500 9px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#aabdc3}\\n' + '.armix-native-desktop .external-out-state[data-status="LIVE"]{color:#9bd3b8}\\n' + '.armix-native-desktop .external-out-state[data-status="PENDING"]{color:#e7c081}\\n' + '.armix-native-desktop .external-out-state[data-status="NEEDS_REMAP"]{color:#e0a18b}\\n' '') SCHEMA = "arsonmix.approved-native-pages-bundle.v2" @@ -114,7 +118,7 @@ def accepted_pages_html() -> str: " if(!code.endsWith(''))throw Error('Native O1 route anchor drift');\n" " const extRow='
EXT'+\n" " '
';\n" + " option(channelOptions(t,'external'),t.externalOutput||'None')+'';\n" " code=code.slice(0,-6)+extRow+'';\n" " }\n" " code+=sectionFx(t)+sectionSend(t);\n"), diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 32ff146a9..0d174f076 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1780,3 +1780,17 @@ test("M5 logical-only editor proves the exact ACK revision and full FX/WIRE effe assert.match(bridge,/beforeInsertCatalogs:/); assert.match(bridge,/beforeEdges:/); }); + +test("O2 independent per-track external ASIO transactions and clear rejected ACK",()=>{ + const src=read("web/approved-native-bridge.js"); + const builder=read("scripts/build_approved_native_gui.py"); + assert.match(src,/const pendingExternal=new Map\(\)/); + assert.match(src,/pendingExternal\.has\(id\)/); + assert.match(src,/pendingExternal\.set\(id,/); + assert.match(src,/pendingExternal\.delete\(id\)/); + assert.match(src,/select\?\.removeAttribute\("aria-busy"\)/); + assert.match(src,/if\(!pendingExternal\.has\(id\)\)select\.removeAttribute/); + assert.match(src,/SHARED with /); + assert.match(src,/signals SUM/); + assert.match(builder,/external-out-state/); +}); diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index cb9d8da06..93f9e45f4 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -709,7 +709,8 @@ // user selects REAL JUCE active pin -> explicitly patches CH1 -> arms output. // No auto-arm, demo PCM, guessed physical port or second GUI. let hardware=null, inputSelect=null, routeBtn=null, armBtn=null, muteBtn=null; - let externalSerial=0,pendingExternal=null; + let externalSerial=0; + const pendingExternal=new Map(); // each ChannelId independent; no mixer-wide lock let hardwareNote=null, pendingSourceId=0, sourceSerial=100; const safeNativeCounter=x=>{ if(typeof x!=="string" || !/^[1-9]\d*$/.test(x))return null; @@ -755,8 +756,12 @@ const b=map.get(left+1); if(main.includes(left)||main.includes(left+1)|| monitor.includes(left)||monitor.includes(left+1))continue; + const shared=Array.isArray(hardware?.raw?.externalOutputs)? + hardware.raw.externalOutputs.filter(row=> + row.physicalLeft===left && row.physicalRight===left+1).length:0; choices.push({label:"OUT "+(left+1)+"/"+(left+2)+" · "+ - a.label+" + "+b.label,left,right:left+1}); + a.label+" + "+b.label+(shared?" · SHARED "+shared:""), + left,right:left+1}); } return choices; }; @@ -791,18 +796,27 @@ } if(select.value!==value)select.value=value; select.dataset.status=state; + const marker=select.parentElement?.querySelector(".external-out-state"); + if(marker){ + marker.textContent=state==="NONE"?"":state==="NEEDS_REMAP"?"REMAP":state; + marker.dataset.status=state; + } select.title=state==="PENDING"?"Native PCM pending · wait for audio callback": state==="NEEDS_REMAP"? "Saved physical output disarmed; choose a verified ASIO pair": state==="LIVE"?"LIVE · independent native post-fader PCM": "None · internal WIRE remains unchanged"; - if(pendingExternal?.channelId===id && pendingExternal.acked && - ((state==="LIVE" && row.physicalLeft===pendingExternal.left && - row.physicalRight===pendingExternal.right) || - (pendingExternal.left===-1 && !row))){ - pendingExternal=null;select.removeAttribute("aria-busy"); + const pending=pendingExternal.get(id); + if(pending && next?.device?.epoch && next.device.epoch!==pending.epoch) + pendingExternal.delete(id); // stale device: release only this strip + else if(pending?.acked && + ((state==="LIVE" && row.physicalLeft===pending.left && + row.physicalRight===pending.right) || + (pending.left===-1 && !row))){ + pendingExternal.delete(id); status("EXTERNAL OUT verified · "+t.name+" → "+value); } + if(!pendingExternal.has(id))select.removeAttribute("aria-busy"); } }; const inputChoicesFor=()=>{ @@ -2391,14 +2405,20 @@ }); backend.addEventListener("arMixExternalOutputAck",ack=>{ - if(!pendingExternal || pendingExternal.requestId!==ack?.requestId)return; + const found=[...pendingExternal].find(([,p])=>p.requestId===ack?.requestId); + if(!found)return; + const [id,transaction]=found; if(ack.ok!==true){ const error=String(ack.error||"Physical output assignment rejected"); - pendingExternal=null; + pendingExternal.delete(id); + const track=(scope?.tracks||[]).find(t=>nativeIdFor(t)===id); + const select=track&&document.querySelector('.strip[data-id="'+track.id+ + '"] select[data-field="external"]'); + select?.removeAttribute("aria-busy"); nativeToast(error);status(error);controller?.subscribe();return; } - pendingExternal.acked=true; - controller?.subscribe(); // Native ACK does NOT establish LIVE readback + transaction.acked=true; + controller?.subscribe(); // ACK alone cannot claim LIVE audio }); backend.addEventListener("arMixNativeSessionAck",ack=>{ const save=ack?.operation==="SAVE"; @@ -3136,7 +3156,7 @@ const pair=hardwareOutputPairs().find(row=>row.label===el.value); const revision=hardware?.raw?.externalRevision; const epoch=hardware?.device?.epoch; - if(pendingExternal||!pair||!ch || + if(pendingExternal.has(id)||!pair||!ch || !["INPUT","GROUP","FX_RETURN"].includes(ch.role) || !controller?.state()?.current?.admitted || d?.backend!=="ASIO" || safeNativeCounter(epoch)===null || @@ -3146,21 +3166,26 @@ return true; } if(pair.label===previous){el.value=previous;return true;} + const occupied=(Array.isArray(hardware?.raw?.externalOutputs)? + hardware.raw.externalOutputs:[]).filter(p=>p.physicalLeft===pair.left && + p.physicalRight===pair.right && p.channelId!==id); + const sharedNote=occupied.length? + " SHARED with "+occupied.length+" other source(s); signals SUM. Check gains.":""; const confirmed=pair.left<0 || window.confirm( "Enable ASIO OUT "+(pair.left+1)+"/"+(pair.right+1)+ - " for "+t.name+"? Verify the amplifier/speakers first. "+ - "INTERNAL OUT will stay unchanged."); + " for "+t.name+"?"+sharedNote+" Check amplifier/speakers. "+ + "INTERNAL OUT stays unchanged."); if(!confirmed){el.value=previous;return true;} const requestId="out-o-"+(++externalSerial); - pendingExternal={requestId,channelId:id,left:pair.left,right:pair.right, - epoch,revision,acked:false}; + pendingExternal.set(id,{requestId,channelId:id,left:pair.left,right:pair.right, + epoch,revision,acked:false}); el.value=previous;el.setAttribute("aria-busy","true"); backend.emitEvent("arMixAction",{action:"routingExternalOutput", requestId,channelId:id,deviceEpoch:epoch,revision, left:pair.left,right:pair.right,confirmed:true}); window.setTimeout(()=>{ - if(pendingExternal?.requestId!==requestId)return; - pendingExternal=null;el.removeAttribute("aria-busy"); + if(pendingExternal.get(id)?.requestId!==requestId)return; + pendingExternal.delete(id);el.removeAttribute("aria-busy"); nativeToast("EXTERNAL OUT timed out · last PCM retained"); controller?.subscribe(); },8000); From 50b0be1058be2e947a4c733e564057a82aaf6623 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:18:14 +0700 Subject: [PATCH 40/53] O2 UI: correct external state CSS newline escaping --- scripts/build_approved_native_gui.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index 7c7935504..fb2bb4623 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -32,10 +32,10 @@ '.armix-native-desktop .external-out-field .route-select{border-color:#547685;background:#192a32}\n' '.armix-native-desktop .external-out-field .route-select[aria-busy="true"]{border-color:#ddb576}\n' '.armix-native-desktop .external-out-field .route-select[data-status="NEEDS_REMAP"]{color:#d5aa8b}\n' - '.armix-native-desktop .external-out-state{font:500 9px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#aabdc3}\\n' - '.armix-native-desktop .external-out-state[data-status="LIVE"]{color:#9bd3b8}\\n' - '.armix-native-desktop .external-out-state[data-status="PENDING"]{color:#e7c081}\\n' - '.armix-native-desktop .external-out-state[data-status="NEEDS_REMAP"]{color:#e0a18b}\\n' + '.armix-native-desktop .external-out-state{font:500 9px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#aabdc3}\n' + '.armix-native-desktop .external-out-state[data-status="LIVE"]{color:#9bd3b8}\n' + '.armix-native-desktop .external-out-state[data-status="PENDING"]{color:#e7c081}\n' + '.armix-native-desktop .external-out-state[data-status="NEEDS_REMAP"]{color:#e0a18b}\n' '') SCHEMA = "arsonmix.approved-native-pages-bundle.v2" From b70e8b9465985e0d49c94791a7ece886305173e0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:41:58 +0700 Subject: [PATCH 41/53] O2: auto-start verified ASIO external outputs for SOURCE ONLY, honor manual mute --- src/LiveAudioEngine.h | 5 +++++ src/LiveDryRoutingLab.h | 14 ++++++++++++++ src/Main.cpp | 22 ++++++++++++++++++++-- tests/approved_native_m2_contract.test.cjs | 21 ++++++++++++++++++++- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 978afdf3a..50670cdf7 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -2335,6 +2335,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } bool dryRoutingLabActive() const noexcept {return dryRoutingLab_.active();} bool hasBoundMixerRoute() const noexcept {return dryRoutingLab_.hasExplicitRoute();} + // Existing verified ASIO external-pair intent is a valid output user + // selection even with SOURCE ONLY / PLAYER A and no microphone INPUT. + bool hasVerifiedExternalOutputIntent() const noexcept { + return dryRoutingLab_.hasVerifiedExternalOutputIntent(); + } void pollDryRoutingLab() noexcept {dryRoutingLab_.poll();} juce::var status() diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 24b976249..20ea148fd 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -2877,6 +2877,20 @@ class LiveDryRoutingLab final { bool hasExplicitRoute() const noexcept { return channelIdPhysicalPcmActive() || (ready() && acceptedRoute_.isObject()); } + // CONTROL thread: authorization intent for at least one external ASIO + // pair on THIS device epoch. Do not demand applied PCM here: the first + // callback/readback needs output enabled before it can prove LIVE. + bool hasVerifiedExternalOutputIntent() const noexcept { + if(!channelIdPhysicalPcmActive() || + externalOutputEpoch_!=epoch() || externalOutputVerified_.empty()) + return false; + return std::any_of(externalOutputAssignments_.begin(), + externalOutputAssignments_.end(),[this](const auto& patch) { + return std::find(externalOutputVerified_.begin(), + externalOutputVerified_.end(),patch.channel.value) + !=externalOutputVerified_.end(); + }); + } std::uint64_t epoch() const noexcept { return deviceEpoch_.load(std::memory_order_acquire); } diff --git a/src/Main.cpp b/src/Main.cpp index 10bcee536..1fdcf6488 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2001,9 +2001,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // patch. A later device epoch or a user MUTE cancels the pending arm. std::uint64_t autoMainEpoch_=0; bool autoMainRequiresInput_=true; + // Operator's explicit OUTPUT MUTE must survive later input/FX/EXT edits. + // This control-thread intent is NOT a new callback gate or device lock. + bool operatorOutputMuted_=false; std::optional autoMainCheckedRevision_; void serviceAutomaticMain() { if(autoMainEpoch_==0)return; + if(operatorOutputMuted_){autoMainEpoch_=0;return;} if(autoMainEpoch_!=engine_.dryRoutingLabEpoch() || engine_.isMonitorEnabled()) { autoMainEpoch_=0; @@ -2017,7 +2021,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // A transient native graph/FX ACK must not permanently consume // the only automatic MAIN attempt for this control revision. // Retry only the cheap CONTROL preflight until it is genuinely safe. - if(engine_.liveOutputArmFault(autoMainRequiresInput_).isNotEmpty())return; + // SOURCE ONLY/PLAYER -> confirmed EXTERNAL OUT is a complete hardware + // route. Requiring a microphone as well would strand it at MONITOR OFF. + // Only same-epoch, driver-verified pins qualify (not stale .smix text). + const bool requireInput=autoMainRequiresInput_ && + !engine_.hasVerifiedExternalOutputIntent(); + if(engine_.liveOutputArmFault(requireInput).isNotEmpty())return; autoMainCheckedRevision_=revision; engine_.setMonitorEnabled(true); autoMainEpoch_=0; @@ -2025,6 +2034,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } void requestAutomaticMain(bool requireInput=true) { + if(operatorOutputMuted_){autoMainEpoch_=0;return;} autoMainRequiresInput_=requireInput; autoMainEpoch_=engine_.dryRoutingLabEpoch(); autoMainCheckedRevision_.reset(); @@ -4460,7 +4470,14 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr browser_.emitEventIfBrowserIsVisible( "arMixExternalOutputAck",juce::var(ack.release())); if(error.isNotEmpty())emitNotice(error,true); - else emitApprovedNativeSnapshot(); // next independent subscription verifies LIVE + else { + // The operator has already confirmed this exact ASIO pair. + // Complete first-sound automatically; never force MONITOR/ARM + // again, and never override a deliberate OUTPUT MUTE. + if(left>=0 && !operatorOutputMuted_ && !engine_.isMonitorEnabled()) + requestAutomaticMain(false); + emitApprovedNativeSnapshot(); // callback readback proves LIVE + } return; } // A visible /preview/ channel OUT changes this same installed M4 @@ -6134,6 +6151,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr engine_.diagnosticRoute()==armix::diagnostics::Route::normal) fault=engine_.liveOutputArmFault(); if (fault.isEmpty()) { + operatorOutputMuted_=!arm; // an explicit user control, not setup mute autoMainEpoch_=0; if(!arm)engine_.cancelAsioResetMonitorIntent(); engine_.setMonitorEnabled(arm); diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index a46fbaa71..952e22c06 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -801,7 +801,8 @@ test("P0 same-VB-Cable feedback is blocked before native MAIN arm",()=>{ assert.match(engine,/MONITOR OFF: VB-Cable capture\/playback self-loop/); assert.match(bridge,/const virtualCableFeedbackPair=/); const native=read("src/Main.cpp"); - assert.match(native,/if\(engine_\.liveOutputArmFault\(autoMainRequiresInput_\)\.isNotEmpty\(\)\)return;/); + assert.match(native,/const bool requireInput=autoMainRequiresInput_ &&\s*!engine_\.hasVerifiedExternalOutputIntent\(\)/); + assert.match(native,/if\(engine_\.liveOutputArmFault\(requireInput\)\.isNotEmpty\(\)\)return;/); assert.match(native,/autoMainEpoch_!=engine_\.dryRoutingLabEpoch\(\)/); }); test("single /preview/ GUI: channel IN, actual OUT and correlated device safety ACK",()=>{ @@ -1850,3 +1851,21 @@ test("O2 independent per-track external ASIO transactions and clear rejected ACK assert.match(src,/signals SUM/); assert.match(builder,/external-out-state/); }); + +test("O2 SOURCE ONLY confirmed ASIO EXTERNAL OUT auto-arms without a second Monitor click",()=>{ + const native=read("src/Main.cpp"),engine=read("src/LiveAudioEngine.h"); + const routing=read("src/LiveDryRoutingLab.h"); + const control=native.slice(native.indexOf('if(action==="routingExternalOutput")'), + native.indexOf('if(action==="routingChannelPatch")')); + assert.match(control,/error=engine_\.setPhysicalExternalOutput/); + assert.match(control,/if\(left>=0 && !operatorOutputMuted_ && !engine_\.isMonitorEnabled\(\)\)\s*requestAutomaticMain\(false\)/); + assert.match(control,/emitApprovedNativeSnapshot\(\); \/\/ callback readback proves LIVE/); + assert.match(native,/operatorOutputMuted_=!arm; \/\/ an explicit user control/); + assert.match(native,/if\(operatorOutputMuted_\)\{autoMainEpoch_=0;return;\}/); + assert.match(native,/autoMainRequiresInput_ &&\s*!engine_\.hasVerifiedExternalOutputIntent\(\)/); + assert.match(engine,/bool hasVerifiedExternalOutputIntent\(\) const noexcept/); + assert.match(routing,/externalOutputEpoch_!=epoch\(\)/); + assert.match(routing,/externalOutputVerified_\.empty\(\)/); + assert.doesNotMatch(control,/setMonitorEnabled\(true\)|setOutputMuted\(false\)/, + "Control delegates one-shot automatic output acceptance, not blind arm"); +}); From b789b34fe8807339fea66ee6fec95d168553a391 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:43:01 +0700 Subject: [PATCH 42/53] Test O2 auto-start against actual C++ dispatcher equality syntax --- tests/approved_native_m2_contract.test.cjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 952e22c06..d0d04d962 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1855,8 +1855,10 @@ test("O2 independent per-track external ASIO transactions and clear rejected ACK test("O2 SOURCE ONLY confirmed ASIO EXTERNAL OUT auto-arms without a second Monitor click",()=>{ const native=read("src/Main.cpp"),engine=read("src/LiveAudioEngine.h"); const routing=read("src/LiveDryRoutingLab.h"); - const control=native.slice(native.indexOf('if(action==="routingExternalOutput")'), - native.indexOf('if(action==="routingChannelPatch")')); + const start=native.indexOf('if(action=="routingExternalOutput")'); + const end=native.indexOf('if(action=="routingChannelPatch")',start); + assert.ok(start>=0&&end>start,"real native external-output action is present"); + const control=native.slice(start,end); assert.match(control,/error=engine_\.setPhysicalExternalOutput/); assert.match(control,/if\(left>=0 && !operatorOutputMuted_ && !engine_\.isMonitorEnabled\(\)\)\s*requestAutomaticMain\(false\)/); assert.match(control,/emitApprovedNativeSnapshot\(\); \/\/ callback readback proves LIVE/); From 6f83d9c1468ffaafcaed033ad0197835ead1eeef Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:45:22 +0700 Subject: [PATCH 43/53] O2: truthful external PCM LIVE vs hardware MUTED readback, release pending ACK --- scripts/build_approved_native_gui.py | 1 + tests/approved_native_m2_contract.test.cjs | 11 +++++++++++ web/approved-native-bridge.js | 14 ++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index fb2bb4623..b020f236a 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -35,6 +35,7 @@ '.armix-native-desktop .external-out-state{font:500 9px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#aabdc3}\n' '.armix-native-desktop .external-out-state[data-status="LIVE"]{color:#9bd3b8}\n' '.armix-native-desktop .external-out-state[data-status="PENDING"]{color:#e7c081}\n' + '.armix-native-desktop .external-out-state[data-status="MUTED"]{color:#abbcc2}\n' '.armix-native-desktop .external-out-state[data-status="NEEDS_REMAP"]{color:#e0a18b}\n' '') SCHEMA = "arsonmix.approved-native-pages-bundle.v2" diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index d0d04d962..7f409f3e1 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1871,3 +1871,14 @@ test("O2 SOURCE ONLY confirmed ASIO EXTERNAL OUT auto-arms without a second Moni assert.doesNotMatch(control,/setMonitorEnabled\(true\)|setOutputMuted\(false\)/, "Control delegates one-shot automatic output acceptance, not blind arm"); }); + +test("O2 external OUT never reports LIVE while driver output is muted",()=>{ + const bridge=read("web/approved-native-bridge.js"); + const css=read("scripts/build_approved_native_gui.py"); + assert.match(bridge,/const pcmInstalled=row\?\.status==="LIVE"&&match/); + assert.match(bridge,/next\?\.device\?\.outputArmed===true\?"LIVE":"MUTED"/); + assert.match(bridge,/state==="MUTED"\?"ASIO pair connected/); + assert.match(bridge,/state==="LIVE"\|\|state==="MUTED"/); + assert.match(bridge,/EXTERNAL OUT patched · hardware output muted/); + assert.match(css,/external-out-state\[data-status="MUTED"\]/); +}); diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 09169514b..0f7eb2080 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -737,10 +737,13 @@ const row=assignments.find(p=>p.channelId===id); const match=row&&choices.find(p=>p.left===row.physicalLeft && p.right===row.physicalRight); - const state=row?.status==="LIVE"&&match?"LIVE": + // Control ACK/applied graph is not audible LIVE while the verified + // hardware output is MUTED. Keep patch identity without ghost meters. + const pcmInstalled=row?.status==="LIVE"&&match; + const state=pcmInstalled?(next?.device?.outputArmed===true?"LIVE":"MUTED"): row?.status==="PENDING"&&match?"PENDING": row?"NEEDS_REMAP":"NONE"; - const value=row?(state==="LIVE"?match.label: + const value=row?((state==="LIVE"||state==="MUTED")?match.label: (state==="PENDING"?"Pending · ":"Needs Remap · ")+ "OUT "+(row.physicalLeft+1)+"/"+(row.physicalRight+1)):"None"; t.externalOutput=value; @@ -767,17 +770,20 @@ select.title=state==="PENDING"?"Native PCM pending · wait for audio callback": state==="NEEDS_REMAP"? "Saved physical output disarmed; choose a verified ASIO pair": + state==="MUTED"?"ASIO pair connected · output muted, settings retained": state==="LIVE"?"LIVE · independent native post-fader PCM": "None · internal WIRE remains unchanged"; const pending=pendingExternal.get(id); if(pending && next?.device?.epoch && next.device.epoch!==pending.epoch) pendingExternal.delete(id); // stale device: release only this strip else if(pending?.acked && - ((state==="LIVE" && row.physicalLeft===pending.left && + (((state==="LIVE"||state==="MUTED") && + row.physicalLeft===pending.left && row.physicalRight===pending.right) || (pending.left===-1 && !row))){ pendingExternal.delete(id); - status("EXTERNAL OUT verified · "+t.name+" → "+value); + status(state==="MUTED"?"EXTERNAL OUT patched · hardware output muted": + "EXTERNAL OUT verified · "+t.name+" → "+value); } if(!pendingExternal.has(id))select.removeAttribute("aria-busy"); } From a2cc06c2945993a93f0239ac7d70fcd44ae4b18c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:51:18 +0700 Subject: [PATCH 44/53] O2: show SHARED physical output only for multiple feeding ChannelIds --- web/approved-native-bridge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 0f7eb2080..948b0838d 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -723,7 +723,7 @@ hardware.raw.externalOutputs.filter(row=> row.physicalLeft===left && row.physicalRight===left+1).length:0; choices.push({label:"OUT "+(left+1)+"/"+(left+2)+" · "+ - a.label+" + "+b.label+(shared?" · SHARED "+shared:""), + a.label+" + "+b.label+(shared>1?" · SHARED "+shared+" SOURCES":""), left,right:left+1}); } return choices; From 78f78137e4eb8de940545b6b63b7e987fb035095 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 13:51:32 +0700 Subject: [PATCH 45/53] Test: ASIO output pair displays SHARED only when multiple sources sum --- tests/approved_native_m2_contract.test.cjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 7f409f3e1..e082b7ab9 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1882,3 +1882,10 @@ test("O2 external OUT never reports LIVE while driver output is muted",()=>{ assert.match(bridge,/EXTERNAL OUT patched · hardware output muted/); assert.match(css,/external-out-state\[data-status="MUTED"\]/); }); + +test("O2 SHARED output means two or more ChannelIds, not one",()=>{ + const bridge=read("web/approved-native-bridge.js"); + assert.match(bridge,/shared>1\?" · SHARED "\+shared\+" SOURCES"/); + assert.match(bridge,/const shared=Array\.isArray\(hardware\?\.raw\?\.externalOutputs\)/); + assert.doesNotMatch(bridge,/shared\?" · SHARED "\+shared/); +}); From 0c8458fbac9d0e3fde3908b0435a86a6ce25736d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 14:21:21 +0700 Subject: [PATCH 46/53] O3: read-only verified ASIO OUTPUTS matrix with callback-status regression --- tests/approved_native_m2_contract.test.cjs | 64 +++++++++++++++++++ web/approved-native-bridge.js | 53 ++++++++++++++++ web/approved-native-contract.js | 74 +++++++++++++++++++++- 3 files changed, 190 insertions(+), 1 deletion(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index e082b7ab9..13ec6fbc1 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1889,3 +1889,67 @@ test("O2 SHARED output means two or more ChannelIds, not one",()=>{ assert.match(bridge,/const shared=Array\.isArray\(hardware\?\.raw\?\.externalOutputs\)/); assert.doesNotMatch(bridge,/shared\?" · SHARED "\+shared/); }); + +test("O3 OUTPUTS overview reflects real ASIO 8-pin ownership and callback status",()=>{ + const state=acceptedFixture(),voice=state.graph.channels[0].id; + state.device.backend="ASIO"; + state.device.outputArmed=true; + state.device.enabledOutputs=[0,1,2,3,4,5,6,7]; + state.device.outputEndpoints=state.device.enabledOutputs.map(n=>({ + id:"out:"+n,port:n,callback:n,label:"ASIO "+(n+1),active:true + })); + const group=(id,name)=>({id,name,role:"GROUP",processingFormat:"STEREO", + controls:{faderDb:0,pan:0,mute:false,solo:false},inserts:[],sends:[]}); + state.graph.channels.splice(1,0,group("9007199254740994","Music Bus"), + group("9007199254740995","Monitor Bus")); + state.physicalMainOutputs=[0,1]; + state.physicalMonitorOutputs=[2,3]; + state.externalOutputs=[ + {channelId:voice,physicalLeft:4,physicalRight:5,status:"LIVE"}, + {channelId:"9007199254740994",physicalLeft:6,physicalRight:7,status:"LIVE"}, + {channelId:"9007199254740995",physicalLeft:6,physicalRight:7,status:"LIVE"} + ]; + const read=()=>protocol.physicalOutputOverview(protocol.normalizeSnapshot(state)); + let out=read(); + assert.equal(out.length,4); + assert.deepEqual(out.map(row=>row.pair),["OUT 1/2","OUT 3/4","OUT 5/6","OUT 7/8"]); + assert.equal(out[0].role,"MAIN"); + assert.equal(out[1].role,"MONITOR"); + assert.equal(out[2].status,"LIVE"); + assert.equal(out[2].owners,"Vocal"); + assert.equal(out[2].shared,1,"single source must never be called SHARED"); + assert.equal(out[3].status,"LIVE"); + assert.equal(out[3].shared,2); + assert.match(out[3].owners,/Music Bus \+ Monitor Bus/); + state.device.outputArmed=false; + out=read(); + assert.equal(out[0].status,"MUTED"); + assert.equal(out[2].status,"MUTED"); + assert.equal(out[3].status,"MUTED"); + assert.equal(out[3].shared,2,"verified patch ownership persists through mute"); + state.device.outputArmed=true; + state.externalOutputs[2].status="PENDING"; + out=read(); + assert.equal(out[3].shared,1,"pending patch is not already installed PCM"); + state.externalOutputs[1].status="NEEDS_REMAP"; + out=read(); + assert.equal(out[3].status,"PENDING"); + assert.equal(out[3].shared,0); + state.device.outputEndpoints[7].active=false; + out=read(); + assert.equal(out.find(row=>row.role==="EXTERNAL"&&row.pair==="OUT 7/8").status, + "NEEDS_REMAP","disabled physical pin can never be LIVE"); + state.device.backend="WASAPI"; + assert.deepEqual(read(),[],"ASIO patch view must not invent WASAPI pairs"); +}); + +test("O3 OUTPUTS stays in one existing Audio I/O with safe, read-only DOM",()=>{ + const bridge=read("web/approved-native-bridge.js"); + assert.match(bridge,/protocol\.physicalOutputOverview\(next\)/); + assert.match(bridge,/paintPhysicalOutputs\(next\)/); + assert.match(bridge,/paintPhysicalOutputs\(hardware\)/); + assert.match(bridge,/data-audio-output-overview open/); + assert.match(bridge,/data-audio-output-matrix role="list"/); + assert.match(bridge,/owner\.textContent=patch\.role/); + assert.doesNotMatch(bridge,/owner\.innerHTML=patch/); +}); diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 948b0838d..a0fb7e6b3 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -1725,6 +1725,39 @@ monitorButton.dataset.armed=String(!!d?.outputArmed); } } + // Output patching is rendered from physical native readback, never a + // second routing state. Repainting only on changes avoids 12 Hz DOM churn. + function paintPhysicalOutputs(next) { + const view=devicePanel?.querySelector?.("[data-audio-output-matrix]"); + if(!view || devicePanel.hidden)return; + const patches=protocol.physicalOutputOverview(next); + const signature=JSON.stringify(patches); + if(devicePanel.dataset.outputSignature===signature)return; + devicePanel.dataset.outputSignature=signature; + const summary=devicePanel.querySelector("[data-audio-output-overview] summary"); + if(summary)summary.textContent="OUTPUTS · "+patches.length+" physical patches"; + view.replaceChildren(); + if(!patches.length){ + view.textContent="No verified ASIO output pins · choose an ASIO device."; + return; + } + for(const patch of patches){ + const line=document.createElement("div"); + line.className="armix-output-row";line.setAttribute("role","listitem"); + const dest=document.createElement("span"); + dest.className="armix-output-pair";dest.textContent=patch.pair; + const owner=document.createElement("span"); + owner.className="armix-output-owner"; + owner.textContent=patch.role+" · "+patch.pins+" · "+patch.owners; + const state=document.createElement("span"); + state.className="armix-output-status"; + state.dataset.state=patch.status; + state.textContent=patch.status.replace("_"," ")+ + (patch.shared>1?" · SHARED "+patch.shared:""); + line.append(dest,owner,state); + view.appendChild(line); + } + } function updateHardwarePanel(next) { hardware=next || null; refreshRealM4Inputs(next); @@ -1735,6 +1768,7 @@ const playback=String(d?.playbackDevice||"unknown output"); const virtualOut=/VB-Audio Virtual Cable|CABLE Input/i.test(playback); syncMonitorButton(d); + paintPhysicalOutputs(next); const mainOutput=next?.retained?NEEDS_REMAP:deviceOpen?playback:null; if(scope?.master && mainOutput && scope.master.output!==mainOutput){ scope.master.output=mainOutput; @@ -1854,6 +1888,19 @@ .armix-device-progress span{display:block;margin-top:2px;color:#f2e0bf} .armix-audio-dialog details{border-top:1px solid #345666;padding-top:8px} .armix-audio-dialog summary{cursor:pointer;color:#c5e1ed} + .armix-audio-dialog{max-height:90vh;overflow:auto} + .armix-output-matrix{max-height:175px;overflow:auto;display:grid;gap:3px;margin:7px 0} + .armix-output-row{display:grid;grid-template-columns:64px minmax(0,1fr) auto; + align-items:center;gap:8px;padding:5px 7px;border-radius:4px;background:#0c202b; + font-size:11px;min-height:28px} + .armix-output-pair{color:#b9dce8;font-variant-numeric:tabular-nums} + .armix-output-owner{overflow:hidden;text-overflow:ellipsis;white-space:nowrap; + color:#ccdce3} + .armix-output-status{font-size:10px;color:#b6c9d1;white-space:nowrap} + .armix-output-status[data-state="LIVE"], + .armix-output-status[data-state="ENABLED"]{color:#9bd3b8} + .armix-output-status[data-state="PENDING"]{color:#e5c17d} + .armix-output-status[data-state="NEEDS_REMAP"]{color:#e0a18b} .armix-audio-pins{display:grid;grid-template-columns:1fr 1fr;gap:8px; max-height:135px;overflow:auto;padding:5px 0} .armix-audio-pins label{display:flex;align-items:center;gap:5px;font-size:11px} @@ -1892,6 +1939,11 @@
Applying audio device… Waiting for driver and mixer verification.
+
+ OUTPUTS · physical routing +
+
Native callback/readback only · speaker listening not verified
+
Advanced · rate, buffer and channel pins -
- OUTPUTS · physical routing +
+
OUTPUTS · physical routing
Native callback/readback only · speaker listening not verified
-
+
Advanced · rate, buffer and channel pins