diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 815234477..38099bd00 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -92,7 +92,7 @@ jobs: -DBUILD_TESTING=ON -DJUCE_WEBVIEW2_PACKAGE_LOCATION="${{ github.workspace }}/.deps" - name: Build executable and native RT tests - run: cmake --build build --config Release --target ARMixConsole ARMixFxOrderTests ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixChannelSendTests ARMixPreparedMixerBlockTests ARMixLiveRoutingEpochTests ARMixJucePortMaskTests ARMixNativeMixerSessionTests ARMixNativeDrySendTests ARMixLiveChannelFxTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2 + run: cmake --build build --config Release --target ARMixConsole ARMixFxOrderTests ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixChannelSendTests ARMixPreparedMixerBlockTests ARMixLiveRoutingEpochTests ARMixJucePortMaskTests ARMixNativeMixerSessionTests ARMixNativeDrySendTests ARMixLiveChannelFxTests ARMixTenChannelLiveControlTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2 - name: Test realtime control primitives run: ctest --test-dir build -C Release --output-on-failure - name: Package verified JUCE GUI for hardware FAT diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index bf82a6389..489273af5 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1531,6 +1531,11 @@ function flushUiParams(){uiFlushScheduled=false;const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)for(const event of pendingUiParams.values())bridge.emitEvent('arMixParameter',event);pendingUiParams.clear()} function send(param,value,ch=currentChannel){ const event={channel:ch+1,parameter:param,value}; + // P1I: native routing token rejects UI gestures from stale device graphs. + const liveToken=window.__armixRouteToken; + if(ch>=0&&ch<10&&liveToken?.epoch>0&&liveToken?.revision>0){ + event.routeEpoch=liveToken.epoch;event.routeRevision=liveToken.revision; + } if(['faderDb','pan','trimDb','phonesDb','masterGain'].includes(param)){ pendingUiParams.set(`${ch}:${param}`,event); if(!uiFlushScheduled){uiFlushScheduled=true;requestAnimationFrame(flushUiParams)} diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a203506a..a21f3c2d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,9 @@ if(BUILD_TESTING) target_link_libraries(ARMixNativeMixerSessionTests PRIVATE juce::juce_audio_devices juce::juce_recommended_config_flags) target_compile_features(ARMixNativeMixerSessionTests PRIVATE cxx_std_20) add_test(NAME P1FPhysicalPortToNativeMasterAndEpochGuard COMMAND ARMixNativeMixerSessionTests) + add_executable(ARMixTenChannelLiveControlTests tests/realtime_ten_channel_controls_test.cpp) + target_compile_features(ARMixTenChannelLiveControlTests PRIVATE cxx_std_20) + add_test(NAME P1ITenChannelLiveFaderPanMuteSoloAndStableFx COMMAND ARMixTenChannelLiveControlTests) juce_add_console_app(ARMixLiveChannelFxTests PRODUCT_NAME "ArSonMix P1H Independent Channel FX Tests") target_sources(ARMixLiveChannelFxTests PRIVATE tests/live_channel_fx_graph_test.cpp engine/core/LiveChannelFxGraph.h) target_link_libraries(ARMixLiveChannelFxTests PRIVATE juce::juce_audio_processors juce::juce_recommended_config_flags) diff --git a/docs/P1I_UNIFIED_10CH_REALTIME_CONSOLE_20261028.md b/docs/P1I_UNIFIED_10CH_REALTIME_CONSOLE_20261028.md new file mode 100644 index 000000000..c5a271a95 --- /dev/null +++ b/docs/P1I_UNIFIED_10CH_REALTIME_CONSOLE_20261028.md @@ -0,0 +1,24 @@ +# P1I — Premium 10-Channel Console → REAL Native Realtime DSP + +Baseline: `main@758ec23e959305115d7fc4e23f7c9f73ddad43c8` (P1H, merged native multichannel VST3, GUI v0.8). This extends the existing `PreparedMixerBlock + LiveChannelFxGraph + RealtimeRoutePublisher` without a new audio callback, second engine, or redundant GUI layout. This is a major UI-to-engine correction, **not** full Studio One feature parity. + +## Delivered + +1. **10 real channel faders/PAN/MUTE/SOLO on the existing premium console** while the native Routing LAB is active and its real device graph has been approved. `web/app.js` passes the native route epoch+revision in control events; `Main.cpp` dispatches all channel IDs 1–10, rejecting old-token updates; `LiveDryRoutingLab` updates atomic per-strip controls of the *same* published graph. Legacy CH1 controls remain unchanged when LAB is stopped. Physical source selection, BUS layout and one stereo-compatible VST3 insert per channel still require the LAB structural APPLY. +2. **No VST3 re-instantiation or device restart for parameter-only edits.** Fader/PAN coefficient calculation occurs in control thread. Audio callback loads atomics once per block; per-channel 64-sample gain ramp suppresses zipper clicks. Independent PRE-send mute/solo gate also ramps, so MUTE suppresses sends without abruptly dropping all buses. Routing DAG, activated hardware port masks, published revision and actual vendor instances stay unchanged. SOLO uses precompiled DAG reachability to keep soloed lane's upstream/downstream path; unrelated channels become silent. No callback heap, JSON, locks, driver I/O or plugin lifecycle operation added. +3. **Truthful premium GUI telemetry.** When the 10CH graph is active, all ten strips display actual native post-fader peak data. CH2–10 no longer pretend to be disconnected, while any empty VST slot is labelled DRY/ROUTE instead of a fake running plugin. FX Rack displays the actual selected per-channel native FX name and opens the same Routing LAB for structural changes. Master FX remain explicitly unavailable; no invented bus or fake editor. +4. **Output safety preserved:** stale epoch/revision event rejected; device topology fault latches silence until explicit remap; structural edits still require OUTPUT MUTE, avoid other thread's independent clock driver, build new graph off RT and preserve CH1 original VST3 + Orbit + preset + GUI. Only param edits bypass structural compile. +5. **Native synthetic acceptance:** `tests/realtime_ten_channel_controls_test.cpp` checks sample-level PRE-fader send at fader=0, SOLO DAG closure, mute-on-PRE, stereo PAN, bus fader, no callback allocation and stale epoch/revision control rejection. Existing JUCE vendor-instance test continues to execute and requires same VST3 identity/lifecycle semantics. One existing Windows workflow reused; no extra CI matrix. + +## How to use on real device + +- Select and validate a DIRECT ASIO or WASAPI audio device with correct enabled physical input/output masks; configure Routing LAB while **MUTE OUTPUT** is ON and CH1 production FX temporarily removed. For multichannel, enable required inputs in native AUDIO SETUP; JUCE initial 1IN/2OUT requested minimum does not enable every physical input automatically. +- Inside Routing LAB, set CH1–10 physical Mono/Stereo inputs, optional BUS destination, PRE/POST sends, and independent stereo-compatible VST3 effect IDs. Click APPLY while muted. Check native ACK with exact device epoch/revision; unmute carefully at low headphone volume. +- Close LAB panel; use the **normal MIX console** faders, PAN, MUTE, SOLO for all ten strips. Observe actual DSP levels in the strip meters and FX Rack. These parameter movements do not need APPLY and do not recreate VST3. Structural edits remain through Routing LAB and require muting; STOP LAB safely restores previous CH1 host with output held muted. +- Deliberately change hardware device/mask; verify stale UI gestures are rejected, previous channel cannot accidentally route into a newly selected device. Control status re-syncs from native every 12 Hz; preview sessions in browser storage do not supersede native state. + +## Limitations / next architecture gates + +Still **opt-in LAB**, not full production DAW. BUS uses the same fixed 10 strip slots, not separate AUX pool; only one stereo-compatible VST3/strip in LAB; no full multichannel plug-in editor, portable route state, PDC, hardware CUE/output patchbay or MONO bus layout negotiation. Structural routing APPLY still recreates even unchanged VST3 instances and interrupts tails; that is the NEXT architecture debt. Native strip MUTE/SOLO and PAN have 64-sample interpolation; vendor processors may still allocate/block internally and hardware timing is not validated. The serious #15 0-FX hardware crackle remains open; MSVC+CTest PASS is not hardware proof. + +**Next major milestone:** separate 10 physical input strips from aux/subgroup/FX buses and implement stable FX instance ownership through graph changes, one native MixSession/patchbay SSOT. No bulk-merging overlapping stale #115/#117; preserve current approved GUI lightweight/onboard GPU performance. Gate every new iteration with exact-head Windows native + Chromium + physically recorded dry-through FAT. diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index cef8638e2..2076c0c88 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -22,7 +22,11 @@ class LiveChannelFxGraph final { explicit LiveChannelFxGraph(const PreparedRenderGraph& plan,int frames,int pluginQuantum=512) : block_(std::make_unique(plan,frames)), - pluginQuantum_(std::clamp(pluginQuantum,32,PreparedMixerBlock::hardFrameLimit)) {} + pluginQuantum_(std::clamp(pluginQuantum,32,PreparedMixerBlock::hardFrameLimit)) { + // P1H callers without live edits retain original compiled faders. + for(int i=0;icapacity():0;} int maxFramesPerPlugin() const noexcept {return pluginQuantum_;} int activeInserts() const noexcept{return activeInserts_;} + bool setStripControl(int channel,float gain,float pan, + bool mono,bool mute,bool solo) noexcept { + return controls_.set(channel,gain,pan,mono,mute,solo); + } const juce::String& insertName(int strip) const noexcept { static const juce::String empty; return strip>=0&&stripprocessBlock(buffer,midi); }; - return block_->process(physical,inputs,left,right,frames,channelFx,levels); + return block_->process(physical,inputs,left,right,frames,channelFx,levels,&controls_); } private: std::unique_ptr block_; + RealtimeStripControls controls_ {}; FxBank processors_ {}; std::array midi_ {}; std::array names_ {}; diff --git a/engine/core/NativeDryRouteCommand.h b/engine/core/NativeDryRouteCommand.h index 8f50cdf16..fe11e2529 100644 --- a/engine/core/NativeDryRouteCommand.h +++ b/engine/core/NativeDryRouteCommand.h @@ -45,9 +45,9 @@ struct NativeDryRouteCommand final { } const float level=static_cast(static_cast(gain)); const float balance=static_cast(static_cast(pan)); - if(!std::isfinite(level)||level<0.f||level>1.f|| + if(!std::isfinite(level)||level<0.f||level>4.f|| !std::isfinite(balance)||balance< -1.f||balance>1.f) { - problem="Channel level must be 0..1 and pan -1..1";return false; + problem="Channel linear gain must be 0..4 and pan -1..1";return false; } auto& c=candidate.channels.stripsAndMaster.strips[i]; c.faderLinear=level;c.pan=balance; diff --git a/engine/core/PreparedMixerBlock.h b/engine/core/PreparedMixerBlock.h index 127978f37..a27c49997 100644 --- a/engine/core/PreparedMixerBlock.h +++ b/engine/core/PreparedMixerBlock.h @@ -2,6 +2,7 @@ #pragma once #include "ChannelSendPlan.h" #include +#include #include #include #include @@ -107,6 +108,40 @@ struct PreparedRenderGraph final { } }; +// P1I: A single native parameter plane, updated only by the control thread. +// All coefficients are calculated on control thread. Callback reads atomics +// once per block and interpolates into fixed strip scratch buffers. The +// immutable topology (DAG/physical ports/FX ownership) is never rebuilt for +// ordinary fader, pan, MUTE, or SOLO changes. +class RealtimeStripControls final { +public: + struct Target { + std::atomic left{1.f},right{1.f}; + std::atomic mute{false},solo{false}; + }; + bool set(int strip,float gain,float pan,bool mono,bool mute,bool solo) noexcept { + if(strip<0||strip>=stripCount||!std::isfinite(gain)||gain<0.f||gain>4.f|| + !std::isfinite(pan)||pan< -1.f||pan>1.f)return false; + const float left=mono?gain*std::sqrt(0.5f*(1.f-pan)): + gain*(pan>0.f?1.f-pan:1.f); + const float right=mono?gain*std::sqrt(0.5f*(1.f+pan)): + gain*(pan<0.f?1.f+pan:1.f); + auto& c=targets_[strip]; + c.left.store(left,std::memory_order_relaxed); + c.right.store(right,std::memory_order_relaxed); + c.mute.store(mute,std::memory_order_relaxed); + c.solo.store(solo,std::memory_order_relaxed); + return true; + } + void setPreparedCoefficients(int strip,float left,float right) noexcept { + targets_[strip].left.store(left,std::memory_order_relaxed); + targets_[strip].right.store(right,std::memory_order_relaxed); + } + const Target& at(int strip) const noexcept{return targets_[strip];} +private: + std::array targets_{}; +}; + struct RenderLevels final { std::array channelPeak {}; float masterPeakL = 0.f, masterPeakR = 0.f; @@ -150,7 +185,8 @@ class PreparedMixerBlock final { template bool process(const float* const* physical, int callbackInputCount, float* outputL, float* outputR, int frames, Fx&& processFx, - RenderLevels* observed=nullptr) noexcept { + RenderLevels* observed=nullptr, + const RealtimeStripControls* live=nullptr) noexcept { static_assert(std::is_nothrow_invocable_v, "DSP hook must be noexcept and realtime bounded"); if (observed) *observed={}; @@ -167,6 +203,10 @@ class PreparedMixerBlock final { std::fill_n(masterL_,frames,0.f); std::fill_n(masterR_,frames,0.f); + bool anySolo=false; + if(live)for(int strip=0;stripat(strip).solo.load(std::memory_order_relaxed) && + !live->at(strip).mute.load(std::memory_order_relaxed); for(int k=0;kat(strip); + routeAudible=!target.mute.load(std::memory_order_relaxed); + if(routeAudible&&anySolo) { + routeAudible=false; + for(int j=0;jat(j); + if(s.solo.load(std::memory_order_relaxed) && + !s.mute.load(std::memory_order_relaxed) && + (j==strip||graph.sends.upstreamOf(strip,j)|| + graph.sends.upstreamOf(j,strip))) { + routeAudible=true;break; + } + } + } + gl=target.left.load(std::memory_order_relaxed); + gr=target.right.load(std::memory_order_relaxed); + // A MUTE or SOLO transition must also silence PRE sends. + // Smooth the pre-send source gate over <=64 samples; it does + // not create/restart FX, drivers, nodes or send topology. + const float targetGate=routeAudible?1.f:0.f; + if(!rampPrimed_[strip]) { + preGate_[strip]=targetGate; + lastGainL_[strip]=gl; + lastGainR_[strip]=gr; + rampPrimed_[strip]=true; + } + const int ramp=std::min(frames,64); + const float dGate=(targetGate-preGate_[strip])/ramp; + float gate=preGate_[strip]; + for(int f=0;f backing_; // ALLOCATED BEFORE callback, never resized std::array left_{}; std::array right_{}; + std::array preGate_{},lastGainL_{},lastGainR_{}; + std::array rampPrimed_{}; float* masterL_=nullptr; float* masterR_=nullptr; }; diff --git a/engine/core/RealtimeRoutePublisher.h b/engine/core/RealtimeRoutePublisher.h index 2e2c7cc4f..c9781ad0e 100644 --- a/engine/core/RealtimeRoutePublisher.h +++ b/engine/core/RealtimeRoutePublisher.h @@ -119,6 +119,17 @@ class RealtimeRoutePublisher final { retiredCount_=0; return true; } + // Only the single control-thread writer calls this. The editor MUST + // mutate atomic runtime parameters, never processor lifetime or topology. + // The owned snapshot is stable on the writer thread; RT reads atomics. + template + bool updateActiveControl(std::uint64_t epoch,std::uint64_t expectedRevision, + Update&& update) noexcept { + if(!owned_||!owned_->prepared||owned_->deviceEpoch!=epoch|| + owned_->graphRevision!=expectedRevision||revision_!=expectedRevision) + return false; + return update(*owned_->prepared); + } [[nodiscard]] ReadLease acquire() noexcept {return ReadLease(*this);} std::uint64_t lastRevision() const noexcept {return revision_;} // CONTROL std::size_t pendingRetirements() const noexcept {return retiredCount_;} // CONTROL diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 6eac9b80d..cf76a8fc0 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -841,6 +841,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback setOutputMuted(true); // never expose CH1 unexpectedly on STOP dryRoutingLab_.disable(); } + bool setDryRoutingLabParameter(int strip,std::uint64_t epoch, + std::uint64_t revision,const juce::String& parameter, + float value) noexcept { + return dryRoutingLab_.setChannelParameter(strip,epoch,revision,parameter,value); + } bool dryRoutingLabActive() const noexcept {return dryRoutingLab_.active();} void pollDryRoutingLab() noexcept {dryRoutingLab_.poll();} diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index ce596d18b..23b867547 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -33,6 +33,10 @@ class LiveDryRoutingLab final { int uid=0; }; static constexpr int count=armix::mixer::stripCount; + struct ChannelEdit { + float linear=1.f, pan=0.f; + bool mute=false, solo=false, mono=false; + }; // JUCE calls aboutToStart after configuring the input/output device. // One device session gets a new epoch; stored route cannot survive it. @@ -116,9 +120,17 @@ class LiveDryRoutingLab final { command,decoded,validationError))return validationError; const auto& cfg=decoded.channels; const auto& sends=decoded.sends; + // All physical and BUS nodes stay scheduled for realtime SOLO/MUTE; + // only the runtime parameter plane controls audibility thereafter. + // This prevents re-instantiating VST3 when a musician moves a fader. + auto topology=cfg; + for(auto& strip:topology.stripsAndMaster.strips) { + strip.mute=false; + strip.solo=false; + } Plan plan; armix::mixer::RenderError error; - if(!Plan::compile(cfg, + if(!Plan::compile(topology, {physicalPorts.data(),static_cast(countNow)}, sends,plan,error)) return "Invalid physical routing (inactive port, format or mapping)"; @@ -131,6 +143,16 @@ class LiveDryRoutingLab final { juce::jlimit(32,Block::hardFrameLimit,deviceFrames)); if(!next->prepared || next->prepared->capacity()==0) return "Cannot allocate routing workspace"; + std::array proposed{}; + for(int i=0;iprepared->setStripControl(i,proposed[i].linear, + proposed[i].pan,proposed[i].mono, + proposed[i].mute,proposed[i].solo)) + return "Cannot prepare native channel controls"; + } // Every VST3 is instantiated and prepared on the control thread. // A graph has private processor instances: a retiring snapshot can // NEVER share a processBlock call with a newly published snapshot. @@ -190,6 +212,8 @@ class LiveDryRoutingLab final { enabled_.store(true,std::memory_order_release); sendCount_.store(sends.count,std::memory_order_relaxed); fxCount_.store(insertCount,std::memory_order_relaxed); + channelEdits_=proposed; // control thread SSOT for this route revision + for(int i=0;i=count || !ready() || + expectedEpoch!=epoch() || expectedRevision!=revision())return false; + auto updated=channelEdits_[strip]; + if(name=="faderDb") { + if(!std::isfinite(value)||value< -60.f||value>10.f)return false; + updated.linear=value<= -60.f?0.f:std::pow(10.f,value/20.f); + }else if(name=="pan") { + if(!std::isfinite(value)||value< -100.f||value>100.f)return false; + updated.pan=value*.01f; + }else if(name=="mute"||name=="solo") { + if(value!=0.f && value!=1.f)return false; + if(name=="mute")updated.mute=value>0.5f; + else updated.solo=value>0.5f; + }else return false; + if(!publisher_.updateActiveControl(expectedEpoch,expectedRevision, + [&](FxGraph& fx) noexcept { + return fx.setStripControl(strip,updated.linear,updated.pan, + updated.mono,updated.mute,updated.solo); + }))return false; + channelEdits_[strip]=updated; + return true; + } + void disable() noexcept { enabled_.store(false,std::memory_order_release); publishedEpoch_.store(0,std::memory_order_release); @@ -328,6 +382,19 @@ class LiveDryRoutingLab final { out->setProperty("peakR",peakR_.load(std::memory_order_relaxed)); out->setProperty("sendCount",sendCount_.load(std::memory_order_relaxed)); out->setProperty("fxCount",fxCount_.load(std::memory_order_relaxed)); + juce::Array controls,fxNames; + for(int i=0;i(); + obj->setProperty("db",st.linear>0.f?20.f*std::log10(st.linear):-60.f); + obj->setProperty("pan",st.pan*100.f); + obj->setProperty("mute",st.mute); + obj->setProperty("solo",st.solo); + controls.add(juce::var(obj.release())); + fxNames.add(channelFxNames_[i]); + } + out->setProperty("channelControls",juce::var(controls)); + out->setProperty("channelFxNames",juce::var(fxNames)); juce::Array levels; for(const auto& p:channelPeaks_)levels.add(p.load(std::memory_order_relaxed)); out->setProperty("channelPeaks",juce::var(levels)); @@ -364,6 +431,8 @@ class LiveDryRoutingLab final { } private: Publisher publisher_; + std::array channelEdits_{}; // JUCE message thread only + std::array channelFxNames_{}; // status/control thread only // All data shared between JUCE device lifecycle and GUI/control reads // are atomic; the callback never enumerates masks or channel names. std::array,armix::device::LiveInputPortRegistry::limit> enabledPorts_{}; diff --git a/src/Main.cpp b/src/Main.cpp index 946d9f50e..d22804a39 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -616,6 +616,23 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr const int channel = static_cast (args.getProperty ("channel", -2)); const auto value = args.getProperty ("value", {}); const auto valueNumber = static_cast (static_cast (value)); + // P1I: exact acknowledged epoch+revision fences all live strip edits. + if(engine_.dryRoutingLabActive() && channel>=1 && + channel<=LiveDryRoutingLab::count && + (name=="faderDb"||name=="pan"||name=="mute"||name=="solo")) { + const auto ep=args.getProperty("routeEpoch",juce::var()); + const auto rev=args.getProperty("routeRevision",juce::var()); + if(!ep.isVoid()&&!rev.isVoid() && + ((name=="mute"||name=="solo")?value.isBool(): + (value.isDouble()||value.isInt()))) { + const auto epoch=static_cast(static_cast(ep)); + const auto revision=static_cast(static_cast(rev)); + const float liveValue=value.isBool()?(bool(value)?1.f:0.f):valueNumber; + (void)engine_.setDryRoutingLabParameter(channel-1,epoch,revision, + name,liveValue); + } + return; + } if (name == "masterGain" && (value.isDouble() || value.isInt())) engine_.setMasterGainDb (valueNumber); // The app.js bridge converts strip index 0 to channel ID 1. diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index ae80dac5f..bf606ef54 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -102,3 +102,24 @@ test("P1H independently instantiates and processes real JUCE FX in 10 native lan assert.match(ui,/fxChoices\(v\.fxId\)/); assert.match(ui,/result\.fxCount/); }); + +test("P1I binds premium 10CH console to REAL native RT graph without FX restart",()=>{ + const app=readFileSync(new URL("../web/app.js",import.meta.url),"utf8"); + const core=readFileSync(new URL("../engine/core/PreparedMixerBlock.h",import.meta.url),"utf8"); + const fx=readFileSync(new URL("../engine/core/LiveChannelFxGraph.h",import.meta.url),"utf8"); + const publisher=readFileSync(new URL("../engine/core/RealtimeRoutePublisher.h",import.meta.url),"utf8"); + assert.match(app,/routeEpoch=liveToken\.epoch/); + assert.match(app,/routeRevision=liveToken\.revision/); + assert.match(main,/setDryRoutingLabParameter/); + assert.match(lab,/setChannelParameter/); + assert.match(lab,/publisher_\.updateActiveControl/); + assert.match(lab,/channelControls/); + assert.match(lab,/channelFxNames/); + assert.match(core,/class RealtimeStripControls/); + assert.match(core,/graph\.sends\.upstreamOf/); + assert.match(fx,/&controls_/); + assert.match(publisher,/updateActiveControl/); + assert.match(bridge,/window\.__armixRouteToken/); + assert.match(bridge,/lab\.channelPeaks/); + assert.match(bridge,/data-native-routing-lab/); +}); diff --git a/tests/realtime_ten_channel_controls_test.cpp b/tests/realtime_ten_channel_controls_test.cpp new file mode 100644 index 000000000..570406194 --- /dev/null +++ b/tests/realtime_ten_channel_controls_test.cpp @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/PreparedMixerBlock.h" +#include "../engine/core/RealtimeRoutePublisher.h" +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include +#include +#include +#include +#include +#include +#include +#include +using namespace armix::mixer; +static std::atomic allocations{0}; +void* operator new(std::size_t n) { + allocations.fetch_add(1,std::memory_order_relaxed); + if(auto* p=std::malloc(n==0?1:n))return p; + throw std::bad_alloc(); +} +void operator delete(void* p) noexcept {std::free(p);} +void operator delete(void* p,std::size_t) noexcept {std::free(p);} +static bool near(float a,float b) {return std::abs(a-b)<.0002f;} +int main() { + constexpr std::array physical{2,5,9}; + ChannelRoutingConfig cfg; + cfg.stripsAndMaster.strips[0]={SourceMode::mono,2,-1,1.f,0.f,false,false}; + cfg.stripsAndMaster.strips[1]={SourceMode::disconnected,-1,-1,1.f,0.f,false,false}; + cfg.stripsAndMaster.strips[2]={SourceMode::stereo,5,9,1.f,0.f,false,false}; + cfg.formats[1]=ChannelFormat::stereo; + SendRequest send; + send.toMaster[0]=false; + send.count=1; + send.sends[0]={0,1,SendTap::preFader,.5f,0.f,true}; + PreparedRenderGraph plan;RenderError error; + assert(PreparedRenderGraph::compile(cfg,physical,send,plan,error)); + assert(plan.scheduled[0]&&plan.scheduled[1]&&plan.scheduled[2]); + PreparedMixerBlock block(plan,128); + RealtimeStripControls controls; + assert(controls.set(0,1.f,0.f,true,false,false)); + assert(controls.set(1,1.f,0.f,false,false,false)); + assert(controls.set(2,1.f,0.f,false,false,false)); + assert(!controls.set(10,1.f,0.f,false,false,false)); + assert(!controls.set(1,1.f,20.f,false,false,false)); + const std::array inA=[] {std::arraya{};a.fill(.8f);return a;}(); + const std::array inB=[] {std::arraya{};a.fill(.2f);return a;}(); + const std::array inC=[] {std::arraya{};a.fill(.3f);return a;}(); + const float* inputs[]={inA.data(),inB.data(),inC.data()}; + std::array left{},right{}; + const auto noFx=[](int,float*,float*,int) noexcept {}; + auto run=[&] { + const auto before=allocations.load(std::memory_order_relaxed); + assert(block.process(inputs,3,left.data(),right.data(),128,noFx,nullptr,&controls)); + assert(allocations.load(std::memory_order_relaxed)==before); + return std::pair{left[127],right[127]}; + }; + auto [l,r]=run(); + // CH1 FX PRE .8*.5=.4, plus independent stereo CH3 .2/.3 + assert(near(l,.6f)&&near(r,.7f)); + assert(controls.set(0,0.f,0.f,true,false,false)); + std::tie(l,r)=run(); + assert(near(l,.6f)&&near(r,.7f)); // fader 0 does NOT kill PRE + assert(controls.set(0,0.f,0.f,true,true,false)); + std::tie(l,r)=run(); + assert(near(l,.2f)&&near(r,.3f)); // MUTE does kill PRE + assert(controls.set(0,0.f,0.f,true,false,true)); + std::tie(l,r)=run(); + assert(near(l,.4f)&&near(r,.4f)); // SOLO keeps CH1 and BUS descendant + assert(controls.set(0,0.f,0.f,true,false,false)); + assert(controls.set(2,1.f,-1.f,false,false,false)); + std::tie(l,r)=run(); + assert(near(l,.6f)&&near(r,.4f)); // stereo left balance only + assert(controls.set(1,0.f,0.f,false,false,false)); + std::tie(l,r)=run(); + assert(near(l,.2f)&&near(r,0.f)); // bus fader updates without graph build + assert(controls.set(1,1.f,0.f,false,false,false)); + std::tie(l,r)=run(); + assert(near(l,.6f)&&near(r,.4f)); + + // Revision/epoch-fenced control editing leaves unchanged topology and + // the same instance intact (one writer, no plugin publication/recreate). + struct LiveNode {RealtimeStripControls params;int identity=42;}; + using Pub=armix::rt::RealtimeRoutePublisher; + Pub publisher; + auto snap=std::make_unique(); + snap->deviceEpoch=4;snap->graphRevision=1; + snap->prepared=std::make_unique(); + assert(publisher.publish(std::move(snap),0,4)==Pub::Result::applied); + const auto update=[](LiveNode& x) noexcept { + return x.params.set(3,.5f,.2f,false,false,false); + }; + assert(!publisher.updateActiveControl(3,1,update)); // old device + assert(!publisher.updateActiveControl(4,0,update)); // old revision + assert(publisher.updateActiveControl(4,1,update)); + { + auto lease=publisher.acquire(); + assert(lease.get(4)&&lease.get(4)->prepared->identity==42); + assert(near(lease.get(4)->prepared->params.at(3).left.load(),.4f)); // stereo pan +20% reduces LEFT + assert(near(lease.get(4)->prepared->params.at(3).right.load(),.5f)); + } + publisher.unpublish(); + assert(!publisher.updateActiveControl(4,1,update)); + assert(publisher.pollRetirement()); +} diff --git a/web/app.js b/web/app.js index 3584f3ded..bfd3e04d1 100644 --- a/web/app.js +++ b/web/app.js @@ -199,6 +199,11 @@ function updateMeterVisual(key,level,now){ function flushUiParams(){uiFlushScheduled=false;const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)for(const event of pendingUiParams.values())bridge.emitEvent('arMixParameter',event);pendingUiParams.clear()} function send(param,value,ch=currentChannel){ const event={channel:ch+1,parameter:param,value}; + // P1I: native routing token rejects UI gestures from stale device graphs. + const liveToken=window.__armixRouteToken; + if(ch>=0&&ch<10&&liveToken?.epoch>0&&liveToken?.revision>0){ + event.routeEpoch=liveToken.epoch;event.routeRevision=liveToken.revision; + } if(['faderDb','pan','trimDb','phonesDb','masterGain'].includes(param)){ pendingUiParams.set(`${ch}:${param}`,event); if(!uiFlushScheduled){uiFlushScheduled=true;requestAnimationFrame(flushUiParams)} diff --git a/web/bridge.js b/web/bridge.js index b66f828aa..f5df81da9 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -198,6 +198,22 @@ } function renderRack(){ if(!workspace || currentTab()!=="FX RACK") return; + const lab=state.device?.dryRoutingLab; + if(lab?.active) { + const selected=typeof currentChannel==="number"?currentChannel:0; + const isMaster=typeof masterSelected!=="undefined"&&masterSelected; + const name=isMaster?"MASTER":(channels[selected]?.name||("CH "+(selected+1))); + const fx=isMaster?"":(lab.channelFxNames?.[selected]||""); + workspace.innerHTML='
'+ + cardHeader("Native FX · "+name,"One LIVE routing graph · one source of truth")+ + '

REAL VST3 PROCESSING

'+ + '

'+(isMaster?"MASTER inserts are not available in this mode": + fx?escapeHtml(fx)+" · independent native VST3 instance": + "DRY · no FX selected for this channel")+'

'+ + ''+ + '

Fader, PAN, MUTE and SOLO now change LIVE DSP without rebuilding VST3. Structural changes stay in Routing LAB.

'; + return; + } const selected=typeof currentChannel==="number"?currentChannel:0; const isMaster=typeof masterSelected!=="undefined"&&masterSelected; if(isMaster||selected!==0){ @@ -684,6 +700,21 @@ } const rack=track.querySelector(".rack"); if(!rack)return; + const lab=state.device?.dryRoutingLab; + if(lab?.active){ + const fx=lab.channelFxNames?.[i]||""; + const signature="live-lab-"+fx; + if(rack.dataset.nativeSig!==signature){ + rack.dataset.nativeSig=signature; + rack.innerHTML='
'; + } + track.removeAttribute("data-preview"); + rack.removeAttribute("data-preview"); + track.title="LIVE native routing · channel "+(i+1)+" · FX: "+(fx||"DRY"); + return; + } if(i!==0){ if(rack.dataset.nativeSig!=="empty-nonlive"){ rack.dataset.nativeSig="empty-nonlive"; @@ -739,6 +770,12 @@ // renderMaster() replaces descendants without replacing the mixer root. // Reapply the disabled native-only controls after each Master redraw. new MutationObserver(()=>syncView()).observe(mixer,{childList:true,subtree:true}); + // Opens the existing native Routing LAB, not a second mixer/editor. + document.addEventListener("click",event=>{ + if(!event.target.closest("[data-native-routing-lab]"))return; + event.preventDefault();event.stopImmediatePropagation(); + document.getElementById("arOpenRoutingLab")?.click(); + },true); const repaint=()=>{ if(currentTab()==="FX RACK") renderRack(); patchMixer(); @@ -1221,6 +1258,39 @@ // A restored GUI-only snapshot must not masquerade as a live native setting. function syncNativeMixerControls(d){ if(typeof channels==="undefined" || !channels[0])return; + const lab=d.dryRoutingLab; + if(lab?.active&&lab.ready&&Array.isArray(lab.channelControls)){ + const editing=Date.now().05){ + ch.fader=db;changed=true; + const f=document.querySelector('[data-fader="'+i+'"]'); + if(f){f.querySelector(".cap")?.style.setProperty("--pos",levelToTop(db)+"%");f.setAttribute("aria-valuenow",db.toFixed(1));} + const read=document.querySelector('[data-read="'+i+'"]'); + if(read)read.textContent=fmt(db); + } + if(!editing&&Number.isFinite(pan)&&ch.pan!==pan){ + ch.pan=pan;changed=true; + const p=document.querySelector('[data-pan="'+i+'"]'); + if(p){p.style.setProperty("--pan-frac",(pan+100)/200);p.style.setProperty("--pan-left",Math.min(.5,(pan+100)/200));p.style.setProperty("--pan-span",Math.abs(pan)/200);p.setAttribute("aria-valuenow",String(pan));} + const read=document.querySelector('[data-pan-read="'+i+'"]'); + if(read)read.textContent=panText(pan); + } + for(const key of ["mute","solo"])if(ch[key]!==!!st[key]){ + ch[key]=!!st[key];changed=true; + const b=document.querySelector('[data-'+key+'="'+i+'"]'); + if(b){b.classList.toggle("active",ch[key]);b.setAttribute("aria-pressed",String(ch[key]));} + } + } + if(changed)patchMixer(); + return; + } const channelDb=Number(d.channelDb), masterDb=Number(d.masterDb); const channelPan=Math.round(Number(d.channelPan)*100); if(!Number.isFinite(channelDb)||!Number.isFinite(masterDb)||!Number.isFinite(channelPan))return; @@ -1271,9 +1341,16 @@ if(changed)patchMixer(); } backend.addEventListener("arMixStatus",d=>{ + const labWasActive=!!state.device?.dryRoutingLab?.active; state.device=d; state.monitor=!!d.monitor; + const lab=d.dryRoutingLab; + window.__armixRouteToken=lab?.active&&lab.ready? + {epoch:Number(lab.epoch),revision:Number(lab.revision)}:null; syncNativeMixerControls(d); + // UI can switch between CH1 production and 10CH DSP without replacing + // premium mixer geometry or rebuilding VST3 instances. + if(labWasActive!==!!lab?.active)repaint(); const b=document.querySelector('[data-native-action="monitor"]'); if(b){ const label=state.monitor?"MUTE OUTPUT":"UNMUTE OUTPUT"; @@ -1288,7 +1365,11 @@ // No fixed "-5 per telemetry callback" smoothing: its speed changed // with source cadence and fought the shared elapsed-time ballistics. // UI animation is capped at 29.4fps; native peaks remain unmodified. - paintMeter(document.querySelector('[data-meter="0"]'),percent(d.inputPeak)); + if(lab?.active&&lab.ready&&Array.isArray(lab.channelPeaks)){ + for(let i=0;iSelect channels, BUS returns and sends; APPLY is a native graph transaction.' + '
'; document.body.appendChild(routeOverlay); - const draftRoutes=Array.from({length:10},()=>({mode:"NONE",left:-1,right:-1,gain:0.25,main:true,mute:false,solo:false,fxId:""})); + const draftRoutes=Array.from({length:10},()=>({mode:"NONE",left:-1,right:-1,gain:0.25,pan:0,main:true,mute:false,solo:false,fxId:""})); const draftSends=[]; let draftEpoch=0; // identity of the hardware used to draw these selectors function invalidateDraftForNewDevice(nextEpoch){ if(draftEpoch===nextEpoch)return false; draftEpoch=nextEpoch; for(const route of draftRoutes) { - route.mode="NONE";route.left=-1;route.right=-1;route.gain=0.25; + route.mode="NONE";route.left=-1;route.right=-1;route.gain=0.25;route.pan=0; route.main=true;route.mute=false;route.solo=false;route.fxId=""; } draftSends.length=0; @@ -109,6 +109,29 @@ catalogItems=items.filter(p=>p&&typeof p.id==="string"); if(routeOverlay.classList.contains("open"))drawRoutes(); }); + function syncNativeLevelsToRouteDraft(){ + const d=state.dryRoutingLab||{}; + if(!d.active||!d.ready||!Array.isArray(d.channelControls))return; + // Changes performed on the main mixer must survive the next STRUCTURAL + // APPLY; never roll back a musician's fader/PAN when editing a send. + for(let i=0;iMath.abs(v-current)<.00001); + if(!matched&&Number.isFinite(current)&¤t>=0&¤t<=4) + base.push([current,(current<=0?'−∞':(20*Math.log10(current)).toFixed(1))+' dB · LIVE']); + return base.map(([v,label])=> + '').join(''); + } function drawRoutes(){ // An identical numbered input on another ASIO device is NOT the same // microphone. Clear all prior user intent if device epoch changed. @@ -123,8 +146,7 @@ ''+ ''+ ''+ + routeGainChoices(v.gain)+''+ '
'+ ''+ ''+ @@ -188,6 +210,7 @@ " · "+(d.ports?.length||0)+" enabled inputs · "+(d.outputPorts?.length||0)+" outputs · "+(d.sendCount||0)+" live sends"); } document.getElementById("arOpenRoutingLab").addEventListener("click",()=>{ + syncNativeLevelsToRouteDraft(); drawRoutes(); routeOverlay.classList.add("open"); overlay.classList.remove("open");