diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 75d5e4fa2..1524f22a6 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 ARMixTenChannelLiveControlTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixShowSchemaTests 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 ARMixDedicatedAuxBusTests ARMixTenChannelLiveControlTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixShowSchemaTests 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/CMakeLists.txt b/CMakeLists.txt index b2d019f1c..db809b05c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ juce_add_gui_app(ARMixConsole juce_add_binary_data(ARMixAssets SOURCES web/index.html web/styles.css web/app.js web/bridge.js web/monitor.js) -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/PreparedMixerBlock.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) target_compile_definitions(ARMixConsole PRIVATE JUCE_WEB_BROWSER=1 JUCE_USE_WIN_WEBVIEW2=1 @@ -72,6 +72,9 @@ if(BUILD_TESTING) add_executable(ARMixTenChannelLiveControlTests tests/realtime_ten_channel_controls_test.cpp) target_compile_features(ARMixTenChannelLiveControlTests PRIVATE cxx_std_20) add_test(NAME P1ITenChannelLiveFaderPanMuteSoloAndStableFx COMMAND ARMixTenChannelLiveControlTests) + add_executable(ARMixDedicatedAuxBusTests tests/dedicated_aux_bus_test.cpp) + target_compile_features(ARMixDedicatedAuxBusTests PRIVATE cxx_std_20) + add_test(NAME P1KTenIndependentInputsAndFourDedicatedAuxReturns COMMAND ARMixDedicatedAuxBusTests) 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/P1K_TEN_INPUTS_FOUR_DEDICATED_AUX_20261029.md b/docs/P1K_TEN_INPUTS_FOUR_DEDICATED_AUX_20261029.md new file mode 100644 index 000000000..c49173a75 --- /dev/null +++ b/docs/P1K_TEN_INPUTS_FOUR_DEDICATED_AUX_20261029.md @@ -0,0 +1,28 @@ +# P1K — Ten permanently available INPUT lanes + FOUR dedicated AUX/FX RETURNS +**Base** `main@faee66f475cced8e97bb4e4726b153aa49b10607`: P1J stable vendor processor ownership, P1I realtime 10CH mixer GUI, P4 native ShowV2 wire validation, latest P0 GUI, full native port/epoch fences. The separate GUI optimization PR #133 is intentionally untouched. **This extends the existing live routing DSP**, not a new audio device thread or parallel mixer. + +## Meaningful behavior +The previous P1G/H routing compiled exactly 10 total strips: a reverb BUS occupied physical CH10 or another input. P1K adds **four dedicated AUX returns, indexed AUX1..AUX4, outside physical CH1..10**, each stereo with enable, gain, mute, MAIN output control, optional *independent* zero-latency stereo VST3 processor, and a realtime peak meter. All ten source strip inputs may still be assigned while all four AUX returns are active. This is an actual native callback path, not UI-preview. + +The existing `PreparedRenderGraph`, `PreparedMixerBlock`, `LiveChannelFxGraph`, `RealtimeRoutePublisher`, `LiveDryRoutingLab` and `NativeDryRouteCommand` remain the **single** engine. No code duplicates or resets Orbit, CH1 production VST host, 10CH real faders, P0 hardware testing, backup or GUIs. Existing internal channel→channel (legacy BUS) sends remain compatible for saved running sessions. New destinations 10–13 identify AUX1–AUX4 distinctly. New compiler validates enabled AUX, gain 0..4, explicit PRE/POST, source CH1..10, bounded send count, no duplicate tap edge, and each bus's valid identity before ACK. AUX cannot send back to INPUT/AUX, so no self-feedback or cycles by construction. + +DSP order each block: verified physical input(s) → channel-specific VST3 → PRE SEND (including dedicated AUX destinations) → realtime fader/PAN/mute/solo ramp → channel POST SEND → 4 dedicated AUX buffers → independent AUX stereo VST3 → AUX gain/mute/Master → MASTER. The P1J shared-internal ownership/graph revision remains unchanged: a selected AUX VST3 with same stable AUX slot + native catalog ID + hardware epoch/quantum is reused across route edits, not re-instantiated. Distinct AUX FX lifecycle is prepared off RT and plugin retirements occur only after reader leases. No new locks, callback allocations, or device reopen. AUX scratch is allocated only when an AUX is enabled (up to 8 * 8192 floats in addition to 10 strips), and all send coefficients / sorting / validation are compiled off RT. + +In `SIGNAL FLOW → OPEN ROUTING MATRIX`, a new **DEDICATED AUX / FX RETURNS** subsection allows choosing AUX enable, output MAIN, volume, plugin from trusted catalog. Send destination dropdown distinguishes CH 1..10 from AUX 1..4. Native accepted-route SSOT now includes `auxes` and the ACK carries `auxCount`, `auxSendCount`, `auxFxNames` and `auxPeaks`. Route editor reopens from accepted configuration + current live faders, never stale WebView UI state. The premium MAIN mixer strip layout, colors, Orbit button, FX rack and LCD are not touched. + +## FAT at real hardware +1. Use approved DIRECT ASIO/WASAPI, verified input mask, no independent clock. Explicitly MUTE OUTPUT and disable legacy CH1 VST chain before starting LAB. Never assume that JUCE opened ten capture ports simply because ten logical inputs exist. +2. `SIGNAL FLOW → OPEN ROUTING MATRIX`. Assign physical IN1…IN10 to CH1–CH10 *only if those ports are actually enabled in AUDIO SETUP*. Enable AUX1 for vocal reverb and AUX2 for another return. The CH1–CH10 assignments remain selectable at the same time. +3. Choose independent zero-latency stereo VST3 reverb on AUX1 and another plugin on AUX2 (or test dry first). Route CH1 PRE→AUX1, CH3 POST→AUX2. APPLY WHILE MUTED. Require native ACK `auxCount=2`, `auxSendCount=2`, `fxCount` matching selected strips/returns. +4. Unmute low-level headphones. Change fader CH1 to -inf: its PRE send remains audible but dry source silences. The POST send from CH3 must follow its fader. AUX volume/mute and MAIN toggle must affect only its independent return, not a source input. +5. MUTE, edit only a send and APPLY: native `fxReused` must include the unchanged AUX VST3. Trigger invalid destination (AUX disabled, unknown VST3, stale epoch, invalid gain or duplicate send): existing native topology remains active, no alternate input fallback. +6. Perform independent #15 zero-FX hardware crackle/clock test; no software CTest can establish zero dropouts at an actual DAC. + +## Deterministic test / acceptance +- Device-independent native CTest uses all ten actual physical sample arrays and two simultaneous AUX returns; verifies analytic sample multiplication through PRE/POST, output/master sums, aux mute and return FX taps, no RT allocations, invalid destinations, duplicate send, disabled AUX, rollback, and old no-AUX compatibility. +- JUCE native CTest executes **real `AudioProcessor::processBlock`** on a physical source and on a dedicated AUX with P1J stable shared FX instance through graph replacement (no prepare/release or state loss). +- Native command test validates `juce::var` JSON decoding/physical assignment, true bus id 10, invalid disabled AUX and rollback. +- Existing Windows CMake + same CI workflow test target `ARMixDedicatedAuxBusTests` and Node native GUI contract. Never merge until the exact PR SHA has green Windows full app/CTest/ZIP and Chromium. Reconcile changes from parallel UI PR #133 before merge. + +## Outstanding architecture gates — not misrepresented +This is **operator-opt-in** 10-input+4-AUX live Routing LAB, not fully integrated DAW-style production FX rack. Each strip and AUX has one stereo-compatible VST3, no multichannel plugin state snapshot restore or PDC, no AUX-to-AUX routing and **no dedicated physical AUX output** yet (all enabled AUX return to stereo MAIN). User still must MUTE while applying structural changes. Existing legacy BUS return within ten strip grid is retained for backward compatibility, but new dedicated AUX should be used instead. A full Studio One/Audition-style production console requires multi-insert rack per strip, AUX/CUE output patching, full Scene recall and hardware #15 qualification. Avoid merging outdated #115/#117 wholesale. diff --git a/engine/core/AuxBusPlan.h b/engine/core/AuxBusPlan.h new file mode 100644 index 000000000..627938b97 --- /dev/null +++ b/engine/core/AuxBusPlan.h @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "ChannelSendPlan.h" +#include +#include +#include +#include + +// P1K: additional, dedicated stereo AUX/FX returns. These are NOT strips. +// The original 10 INPUT strips and their P1G internal channel-channel sends +// remain unchanged. AUX receives only from input strips (never an AUX), then +// returns only to MASTER. This one-way topology makes feedback impossible by +// construction. Everything validates/compiles on CONTROL, zero RT allocations. +namespace armix::mixer { +inline constexpr int auxBusCount=4; +inline constexpr int maxAuxSends=32; +struct AuxBusDefinition final { + bool enabled=false, toMaster=true, mute=false; + float gain=1.f; // linear 0..4, post AUX insert +}; +struct AuxSendDefinition final { + int source=-1; // INPUT 0..9, including existing internal returns + int destination=-1; // AUX index 0..3, never an INPUT index + SendTap tap=SendTap::postFader; + float gain=.25f, pan=0.f; + bool enabled=true; +}; +struct AuxBusRequest final { + std::array buses{}; + std::array sends{}; + int count=0; +}; +enum class AuxFault : std::uint8_t { + none, invalidCount, invalidBus, invalidStrip, disabledTarget, + invalidTap, invalidGain, invalidPan, duplicateSend +}; +struct AuxError final { + AuxFault fault=AuxFault::none; + int index=-1; +}; +struct AuxBusPlan final { + struct Edge { + int bus=-1; + SendTap tap=SendTap::postFader; + float leftGain=0.f,rightGain=0.f; + }; + std::array buses{}; + std::array edges{}; + std::array offset{}; + int edgeCount=0; + bool active=false; + + static bool compile(const AuxBusRequest& requested,AuxBusPlan& out,AuxError& error) noexcept { + error={}; + if(requested.count<0||requested.count>maxAuxSends){ + error={AuxFault::invalidCount,-1};return false; + } + AuxBusPlan candidate; + candidate.buses=requested.buses; + for(int b=0;b4.f){ + error={AuxFault::invalidGain,b};return false; + } + candidate.active|=bus.enabled; + } + std::array outgoing{}; + for(int i=0;i=stripCount){ + error={AuxFault::invalidStrip,i};return false; + } + if(s.destination<0||s.destination>=auxBusCount){ + error={AuxFault::invalidBus,i};return false; + } + if(s.tap!=SendTap::preFader && s.tap!=SendTap::postFader){ + error={AuxFault::invalidTap,i};return false; + } + if(!std::isfinite(s.gain)||s.gain<0.f||s.gain>1.f){ + error={AuxFault::invalidGain,i};return false; + } + if(!std::isfinite(s.pan)||s.pan< -1.f||s.pan>1.f){ + error={AuxFault::invalidPan,i};return false; + } + if(!s.enabled)continue; + if(!requested.buses[s.destination].enabled){ + error={AuxFault::disabledTarget,i};return false; + } + for(int j=0;j0.f?1.f-s.pan:1.f), + s.gain*(s.pan<0.f?1.f+s.pan:1.f)}; + } + out=candidate; + return true; + } + + // Unconditioned block-level send accumulation: caller owns mute/solo + // source policy and supplies channel scratch AFTER PRE gate / fader. + // Every destination is a dedicated, preallocated AUX stereo buffer. + void dispatch(int source,SendTap tap,const float* left,const float* right, + float* const* auxL,float* const* auxR,int frames) const noexcept { + if(!active||source<0||source>=stripCount||frames<=0||!left||!right|| + !auxL||!auxR)return; + for(int i=offset[source];i,channels>; + using FxBank=std::array,fxSlots>; explicit LiveChannelFxGraph(const PreparedRenderGraph& plan,int frames,int pluginQuantum=512) : block_(std::make_unique(plan,frames)), @@ -89,16 +90,16 @@ class LiveChannelFxGraph final { } const juce::String& insertName(int strip) const noexcept { static const juce::String empty; - return strip>=0&&strip=0&&stripname:empty; } const juce::String& insertId(int strip) const noexcept { static const juce::String empty; - return strip>=0&&strip=0&&stripcatalogId:empty; } const Processor* instanceProcessor(int strip) const noexcept { - return strip>=0&&strip=0&&stripprocessor.get():nullptr; } @@ -107,7 +108,7 @@ class LiveChannelFxGraph final { // same device epoch, sample-rate and prepared audio quantum. bool reuse(int strip,const LiveChannelFxGraph& previous, const juce::String& catalogId) { - if(strip<0||strip>=channels||catalogId.isEmpty()|| + if(strip<0||strip>=fxSlots||catalogId.isEmpty()|| processors_[strip]||!previous.processors_[strip]|| previous.insertId(strip)!=catalogId|| previous.pluginQuantum_!=pluginQuantum_)return false; @@ -118,7 +119,7 @@ class LiveChannelFxGraph final { bool install(int strip,std::unique_ptr processor, const juce::String& name,const juce::String& catalogId={}) { - if(strip<0||strip>=channels||!processor||processors_[strip]) + if(strip<0||strip>=fxSlots||!processor||processors_[strip]) return false; processors_[strip]=std::make_shared( std::move(processor),catalogId,name); @@ -132,7 +133,7 @@ class LiveChannelFxGraph final { float* left,float* right,int frames, RenderLevels* levels=nullptr) noexcept { auto channelFx=[this](int strip,float* l,float* r,int samples) noexcept { - if(strip<0||strip>=channels)return; + if(strip<0||strip>=fxSlots)return; auto* instance=processors_[strip].get(); // no shared_ptr copy in RT if(instance)instance->render(l,r,samples); }; diff --git a/engine/core/NativeDryRouteCommand.h b/engine/core/NativeDryRouteCommand.h index fe11e2529..dbce3185f 100644 --- a/engine/core/NativeDryRouteCommand.h +++ b/engine/core/NativeDryRouteCommand.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only #pragma once #include "ChannelSendPlan.h" +#include "AuxBusPlan.h" #include #include #include @@ -12,6 +13,7 @@ namespace armix::mixer { struct NativeDryRouteCommand final { ChannelRoutingConfig channels {}; SendRequest sends {}; + AuxBusRequest aux {}; static bool decode(const juce::var& request, NativeDryRouteCommand& destination, @@ -68,6 +70,33 @@ struct NativeDryRouteCommand final { problem="Channel must be NONE, MONO, STEREO or BUS";return false; } } + // Dedicated AUX 1..4 are independent from the ten physical INPUTs. + // Old sessions without auxes remain backward compatible and silent. + const auto rawAux=request.getProperty("auxes",juce::var()); + if(!rawAux.isVoid()){ + auto* auxRows=rawAux.getArray(); + if(!auxRows||auxRows->size()!=auxBusCount){ + problem="Exactly four dedicated AUX definitions are required"; + return false; + } + for(int b=0;bgetReference(b); + if(!row.isObject()){problem="Invalid AUX return";return false;} + const auto enabled=row.getProperty("enabled",false); + const auto master=row.getProperty("main",true); + const auto mute=row.getProperty("mute",false); + const auto level=row.getProperty("gain",1.0); + if(!enabled.isBool()||!master.isBool()||!mute.isBool()|| + !(level.isDouble()||level.isInt())){ + problem="Invalid AUX enable, main, mute or level";return false; + } + const float gain=static_cast(static_cast(level)); + if(!std::isfinite(gain)||gain<0.f||gain>4.f){ + problem="AUX gain must be 0..4";return false; + } + candidate.aux.buses[b]={bool(enabled),bool(master),bool(mute),gain}; + } + } const auto rawSends=request.getProperty("sends",juce::var()); if(!rawSends.isVoid() && !rawSends.isArray()){ problem="Sends must be an array";return false; @@ -94,10 +123,12 @@ struct NativeDryRouteCommand final { problem="Send tap must be PRE or POST";return false; } const int from=static_cast(source),to=static_cast(dest); - if(from<0||from>=stripCount||to<0||to>=stripCount){ - problem="Send channel outside 1..10";return false; + if(from<0||from>=stripCount||to<0||to>=stripCount+auxBusCount){ + problem="Send requires CH1..10 source and CH/AUX destination";return false; } - if(modeNames[from]=="NONE"||modeNames[to]=="NONE"){ + if(modeNames[from]=="NONE"|| + (to=stripCount&&!candidate.aux.buses[to-stripCount].enabled)){ problem="Enable a sender and set the recipient to BUS or an assigned channel";return false; } const float sendGain=static_cast(static_cast(gain)); @@ -106,10 +137,17 @@ struct NativeDryRouteCommand final { !std::isfinite(sendPan)||sendPan< -1.f||sendPan>1.f){ problem="Send level 0..1, pan -1..1";return false; } - auto& s=candidate.sends.sends[candidate.sends.count++]; - s.source=from;s.destination=to; - s.tap=tap=="PRE"?SendTap::preFader:SendTap::postFader; - s.gain=sendGain;s.pan=sendPan;s.enabled=true; + if(to>=stripCount){ + auto& s=candidate.aux.sends[candidate.aux.count++]; + s.source=from;s.destination=to-stripCount; + s.tap=tap=="PRE"?SendTap::preFader:SendTap::postFader; + s.gain=sendGain;s.pan=sendPan;s.enabled=true; + }else{ + auto& s=candidate.sends.sends[candidate.sends.count++]; + s.source=from;s.destination=to; + s.tap=tap=="PRE"?SendTap::preFader:SendTap::postFader; + s.gain=sendGain;s.pan=sendPan;s.enabled=true; + } } } // Rejection never mutates the destination. Explicit DAG validation diff --git a/engine/core/PreparedMixerBlock.h b/engine/core/PreparedMixerBlock.h index a27c49997..cadf0460e 100644 --- a/engine/core/PreparedMixerBlock.h +++ b/engine/core/PreparedMixerBlock.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only #pragma once #include "ChannelSendPlan.h" +#include "AuxBusPlan.h" #include #include #include @@ -19,17 +20,19 @@ namespace armix::mixer { enum class RenderFault : unsigned char { - none, invalidChannelRouting, invalidSendRouting + none, invalidChannelRouting, invalidSendRouting, invalidAuxRouting }; struct RenderError final { RenderFault fault = RenderFault::none; LayoutError channel {}; SendError sends {}; + AuxError aux {}; }; struct PreparedRenderGraph final { ChannelRoutingPlan channels {}; ChannelSendPlan sends {}; + AuxBusPlan aux {}; std::array audible {}; std::array scheduled {}; std::array leftGain {}; @@ -43,7 +46,8 @@ struct PreparedRenderGraph final { std::span callbackOrderedPhysicalPorts, const SendRequest& sendsRequest, PreparedRenderGraph& destination, - RenderError& error) noexcept { + RenderError& error, + const AuxBusRequest& requestedAux={}) noexcept { error = {}; PreparedRenderGraph candidate; if (!ChannelRoutingPlan::compile(routing, callbackOrderedPhysicalPorts, @@ -55,6 +59,10 @@ struct PreparedRenderGraph final { error.fault = RenderFault::invalidSendRouting; return false; } + if (!AuxBusPlan::compile(requestedAux,candidate.aux,error.aux)){ + error.fault=RenderFault::invalidAuxRouting; + return false; + } const auto& configs = routing.stripsAndMaster.strips; std::array ancestors {}; @@ -144,6 +152,7 @@ class RealtimeStripControls final { struct RenderLevels final { std::array channelPeak {}; + std::array auxPeak {}; float masterPeakL = 0.f, masterPeakR = 0.f; }; @@ -153,12 +162,13 @@ struct RenderLevels final { class PreparedMixerBlock final { public: // The maximum is an implementation bound, NOT an OS device promise. - // Allocations are constructor-only; 20 strip lanes + 2 master lanes. + // Allocations are constructor-only; 20 strip lanes + optional 8 AUX + 2 master. static constexpr int hardFrameLimit = 8192; PreparedMixerBlock(const PreparedRenderGraph& plan, int maxFrames) : plan_(plan), capacity_(maxFrames), backing_(validCapacity(maxFrames) - ? static_cast(stripCount*2+2)*maxFrames + ? static_cast(stripCount*2+2+ + (plan.aux.active?auxBusCount*2:0))*maxFrames : 0u, 0.f) { if (!validCapacity(maxFrames)) capacity_=0; @@ -169,6 +179,13 @@ class PreparedMixerBlock final { } masterL_=backing_.data()+static_cast(stripCount*2)*capacity_; masterR_=masterL_+capacity_; + if(plan.aux.active){ + for(int b=0;b(b*2)*capacity_; + auxRight_[b]=auxLeft_[b]+capacity_; + } + } } PreparedMixerBlock(const PreparedMixerBlock&)=delete; PreparedMixerBlock& operator=(const PreparedMixerBlock&)=delete; @@ -202,6 +219,11 @@ class PreparedMixerBlock final { PreparedRenderGraph const& graph=plan_; std::fill_n(masterL_,frames,0.f); std::fill_n(masterR_,frames,0.f); + if(graph.aux.active) + for(int b=0;bchannelPeak[strip]=peak; graph.sends.dispatch(strip,SendTap::postFader,l,r, left_.data(),right_.data(),frames); + graph.aux.dispatch(strip,SendTap::postFader,l,r, + auxLeft_.data(),auxRight_.data(),frames); + } + // Dedicated AUX returns execute AFTER all ten source strips. + // Input channel count NEVER decreases when an AUX is enabled. + // AUX FX IDs are stripCount+b; -1 remains MASTER FX callback. + if(graph.aux.active)for(int b=0;bauxPeak[b]=peak; } processFx(-1,masterL_,masterR_,frames); graph.channels.base.finishMaster(masterL_,masterR_,frames); @@ -328,6 +373,7 @@ class PreparedMixerBlock final { std::vector backing_; // ALLOCATED BEFORE callback, never resized std::array left_{}; std::array right_{}; + std::array auxLeft_{},auxRight_{}; std::array preGate_{},lastGainL_{},lastGainR_{}; std::array rampPrimed_{}; float* masterL_=nullptr; diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index cf76a8fc0..f237d0e08 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -820,7 +820,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback // Explicit message-thread transaction. NO VST is processed in this LAB. juce::String applyDryRoutingLab ( const juce::var& command, - const std::array& fx) { + const std::array& fx) { if (!isOutputMuted()) return "MUTE OUTPUT before applying physical DRY LAB routing"; if (handoff_.busy()) return "A VST3 graph handoff is in progress"; if (routeReconfiguring_.load(std::memory_order_acquire)) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 816234523..838077cd4 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -33,6 +33,8 @@ class LiveDryRoutingLab final { int uid=0; }; static constexpr int count=armix::mixer::stripCount; + static constexpr int auxCount=armix::mixer::auxBusCount; + static constexpr int fxSlots=count+auxCount; struct ChannelEdit { float linear=1.f, pan=0.f; bool mute=false, solo=false, mono=false; @@ -78,18 +80,21 @@ class LiveDryRoutingLab final { topologyFault_.store(false,std::memory_order_release); sendCount_.store(0,std::memory_order_relaxed); fxCount_.store(0,std::memory_order_relaxed); + auxCountActive_.store(0,std::memory_order_relaxed); + auxSendCount_.store(0,std::memory_order_relaxed); fxReused_.store(0,std::memory_order_relaxed); // Device lifecycle callback may run off the message thread. // acceptedRoute_ is a JUCE var owned by the CONTROL thread and must // never be mutated from the device thread. Epoch gates hide stale data. for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed); + for(auto& p:auxPeaks_)p.store(0.f,std::memory_order_relaxed); peakL_.store(0.f,std::memory_order_relaxed); peakR_.store(0.f,std::memory_order_relaxed); } juce::String apply (const juce::var& command, bool directPermitted, bool independentClock, int loadedFx, - const std::array& selections, + const std::array& selections, juce::AudioPluginFormatManager& formats, double sampleRate,int deviceFrames) { // Called by the native message thread only. Not callable from RT. @@ -136,7 +141,7 @@ class LiveDryRoutingLab final { armix::mixer::RenderError error; if(!Plan::compile(topology, {physicalPorts.data(),static_cast(countNow)}, - sends,plan,error)) + sends,plan,error,decoded.aux)) return "Invalid physical routing (inactive port, format or mapping)"; const auto revision=expectedRevision+1; if(revision==0) return "Routing revision overflow"; @@ -165,11 +170,16 @@ class LiveDryRoutingLab final { // Never reuse across a device epoch or changed device quantum. const auto* prior=publisher_.controlPrepared(currentEpoch,expectedRevision); int insertCount=0,reusedCount=0; - for(int lane=0;laneprepared->reuse(lane,*prior,req.id)) { ++insertCount; ++reusedCount; @@ -179,7 +189,7 @@ class LiveDryRoutingLab final { return "Audio device sample rate or buffer size is invalid"; auto* fmt=formats.getFormat(0); if(!fmt || !fmt->fileMightContainThisPluginType(req.path)) - return "CH "+juce::String(lane+1)+": VST3 module is unavailable; rescan catalog"; + return label+": VST3 module is unavailable; rescan catalog"; juce::OwnedArray descriptions; fmt->findAllTypesForFile(descriptions,req.path); juce::PluginDescription* chosen=nullptr; @@ -187,31 +197,31 @@ class LiveDryRoutingLab final { if(item && item->uniqueId==req.uid && !item->isInstrument) {chosen=item;break;} if(!chosen) - return "CH "+juce::String(lane+1)+": selected VST3 effect identity not found (instrument plugins are unsupported)"; + return label+": selected VST3 effect identity not found (instrument plugins are unsupported)"; juce::String pluginError; auto instance=formats.createPluginInstance(*chosen,sampleRate, juce::jmax(32,deviceFrames),pluginError); if(!instance) - return "CH "+juce::String(lane+1)+": VST3 instantiation failed: "+pluginError; + return label+": VST3 instantiation failed: "+pluginError; const auto layoutError=armix::vst::prepareStereoEffectLayout(*instance); if(layoutError.isNotEmpty()) - return "CH "+juce::String(lane+1)+": "+layoutError; + return label+": "+layoutError; try { instance->prepareToPlay(sampleRate, juce::jmax(32,deviceFrames)); } catch(const std::exception& ex) { - return "CH "+juce::String(lane+1)+": plugin prepare failed: "+juce::String(ex.what()); + return label+": plugin prepare failed: "+juce::String(ex.what()); } catch(...) { - return "CH "+juce::String(lane+1)+": plugin prepare failed (unknown exception)"; + return label+": plugin prepare failed (unknown exception)"; } // Uncompensated latent inserts produce comb filtering in PRE/POST // sends. Until native PDC exists, reject instead of lying about // phase accuracy or silent extra buffer latency. if(instance->getLatencySamples()!=0) - return "CH "+juce::String(lane+1)+ + return label+ ": this VST3 reports latency; choose zero-latency mode until PDC is implemented"; if(!next->prepared->install(lane,std::move(instance),chosen->name,req.id)) - return "CH "+juce::String(lane+1)+": duplicate or invalid VST3 insert"; + return label+": duplicate or invalid VST3 insert"; ++insertCount; } const auto epochAtPublish=deviceEpoch_.load(std::memory_order_acquire); @@ -232,6 +242,14 @@ class LiveDryRoutingLab final { acceptedRoute_=command; channelEdits_=proposed; // control thread SSOT for this route revision for(int i=0;i(std::count_if(plan.aux.buses.begin(), + plan.aux.buses.end(), + [](const auto& b){return b.enabled;})), + std::memory_order_relaxed); + auxSendCount_.store(decoded.aux.count,std::memory_order_relaxed); return {}; case Publisher::Result::staleDevice: return "Device epoch changed during preparation"; @@ -284,7 +302,9 @@ class LiveDryRoutingLab final { fxCount_.store(0,std::memory_order_relaxed); fxReused_.store(0,std::memory_order_relaxed); acceptedRoute_=juce::var(); // control-thread STOP only + for(auto& n:auxFxNames_)n.clear(); for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed); + for(auto& p:auxPeaks_)p.store(0.f,std::memory_order_relaxed); } void poll() noexcept {publisher_.pollRetirement();} // message thread bool active() const noexcept {return enabled_.load(std::memory_order_acquire);} @@ -307,6 +327,7 @@ class LiveDryRoutingLab final { float masterGain,bool masterMuted) noexcept { if(!active())return false; for(auto& p:channelPeaks_)p.store(0.f,std::memory_order_relaxed); + for(auto& p:auxPeaks_)p.store(0.f,std::memory_order_relaxed); // Stale meters must never survive a failed device/epoch mapping. peakL_.store(0.f,std::memory_order_relaxed); peakR_.store(0.f,std::memory_order_relaxed); @@ -355,6 +376,7 @@ class LiveDryRoutingLab final { const int max=snapshot->prepared->maxFramesPerPlugin(); float peakL=0.f,peakR=0.f; std::array perChannelPeaks{}; + std::array perAuxPeaks{}; for(int offset=0;offsetsetProperty("peakR",peakR_.load(std::memory_order_relaxed)); out->setProperty("sendCount",sendCount_.load(std::memory_order_relaxed)); out->setProperty("fxCount",fxCount_.load(std::memory_order_relaxed)); + out->setProperty("auxCount",auxCountActive_.load(std::memory_order_relaxed)); + out->setProperty("auxSendCount",auxSendCount_.load(std::memory_order_relaxed)); + juce::Array auxNames,auxPeaks; + for(int b=0;bsetProperty("auxFxNames",juce::var(auxNames)); + out->setProperty("auxPeaks",juce::var(auxPeaks)); out->setProperty("fxReused",fxReused_.load(std::memory_order_relaxed)); // Only the message thread calls status(), never the audio callback. if(active() && ready())out->setProperty("acceptedRoute",acceptedRoute_); @@ -456,6 +491,9 @@ class LiveDryRoutingLab final { Publisher publisher_; std::array channelEdits_{}; // JUCE message thread only std::array channelFxNames_{}; // status/control thread only + std::array auxFxNames_{}; // dedicated bus FX + std::array,auxCount> auxPeaks_{}; + std::atomic auxCountActive_{0},auxSendCount_{0}; juce::var acceptedRoute_; // native ACK only, no UI preview/localStorage truth // All data shared between JUCE device lifecycle and GUI/control reads // are atomic; the callback never enumerates masks or channel names. diff --git a/src/Main.cpp b/src/Main.cpp index 7174f6f59..f4b623ac7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -935,7 +935,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // existing 1-channel VST3 production chain. Explicit Apply/Stop. if (action == "routingDryApply") { - std::array selected{}; + std::array selected{}; juce::String error; const auto rowsValue=value.getProperty("channels",juce::var()); auto* rows=rowsValue.getArray(); @@ -955,6 +955,25 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr selected[i]={entry->key(),entry->path,entry->name,entry->uid}; } } + // Dedicated AUX catalog IDs come only from the trusted native + // VST3 catalog, NEVER untrusted WebView file paths. + const auto auxValue=value.getProperty("auxes",juce::var()); + if(error.isEmpty() && !auxValue.isVoid()){ + auto* auxRows=auxValue.getArray(); + if(!auxRows||auxRows->size()!=LiveDryRoutingLab::auxCount) + error="Exactly four AUX returns are required"; + else for(int b=0;bgetReference(b).getProperty("fxId",{}).toString(); + if(id.isEmpty())continue; + const auto* entry=catalog_.find(id); + if(!entry){ + error="AUX "+juce::String(b+1)+": VST3 missing in catalog"; + break; + } + selected[LiveDryRoutingLab::count+b]= + {entry->key(),entry->path,entry->name,entry->uid}; + } + } if(error.isEmpty()) { try { error=engine_.applyDryRoutingLab(value,selected); diff --git a/tests/dedicated_aux_bus_test.cpp b/tests/dedicated_aux_bus_test.cpp new file mode 100644 index 000000000..1d519d926 --- /dev/null +++ b/tests/dedicated_aux_bus_test.cpp @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/PreparedMixerBlock.h" +#if defined(NDEBUG) +#undef NDEBUG +#endif +#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(void* p=std::malloc(n?n:1))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)<.0003f;} +int main(){ + static_assert(stripCount==10 && auxBusCount==4); + constexpr int frames=8; + ChannelRoutingConfig cfg; + std::array activePorts{}; + for(int ch=0;ch,stripCount> signal{}; + std::array input{}; + for(int ch=0;ch outL{},outR{}; + RenderLevels meters; + std::array fxInvocations{}; + auto effects=[&](int strip,float* l,float* r,int n) noexcept { + if(strip>=stripCount&&strip(plan,32,32); + auto dry=std::make_unique(2.f); + auto wet=std::make_unique(3.f); + dry->prepareToPlay(48000,32); + wet->prepareToPlay(48000,32); + assert(fx->install(0,std::move(dry),"CH1","source-vst3")); + assert(fx->install(stripCount,std::move(wet),"AUX1","aux-vst3")); + assert(fx->activeInserts()==2); + const auto* originalBus=fx->instanceProcessor(stripCount); + RenderLevels levels; + const auto before=heapCalls.load(std::memory_order_relaxed); + assert(fx->process(phys,3,l.data(),r.data(),4,&levels)); + assert(heapCalls.load(std::memory_order_relaxed)==before); + assert(near(l[0],1.2f)&&near(r[0],1.2f)); + assert(near(levels.auxPeak[0],1.2f)); + auto second=std::make_unique(plan,32,32); + assert(second->reuse(0,*fx,"source-vst3")); + assert(second->reuse(stripCount,*fx,"aux-vst3")); + assert(second->instanceProcessor(stripCount)==originalBus); + assert(!second->reuse(stripCount,*fx,"wrong-id")); + const int oldPrepared=GainFx::prepared,oldReleased=GainFx::released; + fx.reset(); // AUX processor must remain live in second graph + assert(GainFx::released==oldReleased); + assert(second->process(phys,3,l.data(),r.data(),4,&levels)); + assert(near(l[0],1.2f)); + assert(GainFx::prepared==oldPrepared); + second.reset(); + assert(GainFx::released==oldReleased+2); + assert(GainFx::living==0); + } // Tests above use a real JUCE AudioProcessor processing seam. Vendor // VST3 formats and sound quality require separate Windows hardware FAT. } diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index 6904dee78..3e0709be5 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -82,13 +82,14 @@ test("P1G is real native BUS/send, not a cosmetic routing picker",()=>{ assert.match(ui,/arAddSend/); assert.match(ui,/data-send-tap/); assert.match(ui,/sends:draftSends\.map/); - assert.match(ui,/result\.sendCount/); + assert.match(ui,/result\.auxSendCount/); + assert.match(ui,/d\.sendCount/); assert.match(ui,/data-route-peak/); }); test("P1H independently instantiates and processes real JUCE FX in 10 native lanes",()=>{ const fx=readFileSync(new URL("../engine/core/LiveChannelFxGraph.h",import.meta.url),"utf8"); - assert.match(fx,/std::array,channels>/); + assert.match(fx,/std::array,fxSlots>/); assert.match(fx,/processor->processBlock\(buffer,midi\)/); assert.match(fx,/processor->releaseResources\(\)/); assert.match(lab,/std::make_unique\(plan/); @@ -148,3 +149,29 @@ test("P1J keeps real per-strip VST3 identity and tails across routing-only APPLY assert.match(app,/Independent VST3/); assert.match(ui,/NATIVE ACK:.*preserved/); }); + +test("P1K truly keeps ten physical INPUT strips and adds four independent native AUX/FX returns",()=>{ + const aux=readFileSync(new URL("../engine/core/AuxBusPlan.h",import.meta.url),"utf8"); + const block=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 command=readFileSync(new URL("../engine/core/NativeDryRouteCommand.h",import.meta.url),"utf8"); + const app=readFileSync(new URL("../web/monitor.js",import.meta.url),"utf8"); + assert.match(aux,/auxBusCount=4/); + assert.match(aux,/source<0\|\|s\.source>=stripCount/); + assert.match(aux,/destination<0\|\|s\.destination>=auxBusCount/); + assert.match(block,/processFx\(stripCount\+b,l,r,frames\)/); + assert.match(block,/graph\.aux\.dispatch\(strip,SendTap::preFader/); + assert.match(block,/graph\.aux\.dispatch\(strip,SendTap::postFader/); + assert.match(fx,/fxSlots=stripCount\+auxBusCount/); + assert.match(lab,/decoded\.aux/); + assert.match(lab,/auxSendCount_/); + assert.match(main,/LiveDryRoutingLab::auxCount/); + assert.match(command,/to>=stripCount/); + assert.match(app,/data-aux-row/); + assert.match(app,/auxes:draftAux\.map/); + assert.match(app,/data-aux-fx/); + const cmake=readFileSync(new URL("../CMakeLists.txt",import.meta.url),"utf8"); + const workflow=readFileSync(new URL("../.github/workflows/p1-windows.yml",import.meta.url),"utf8"); + assert.match(cmake,/P1KTenIndependentInputsAndFourDedicatedAuxReturns/); + assert.match(workflow,/ARMixDedicatedAuxBusTests/); +}); diff --git a/tests/native_dry_route_command_test.cpp b/tests/native_dry_route_command_test.cpp index f53837bbe..ea86b85d1 100644 --- a/tests/native_dry_route_command_test.cpp +++ b/tests/native_dry_route_command_test.cpp @@ -64,6 +64,40 @@ int main(){ invalid=juce::JSON::parse(json.replace("\"gain\":0.5","\"gain\":999")); assert(!NativeDryRouteCommand::decode(invalid,decoded,error)); assert(decoded.sends.count==2); + // P1K native JSON: AUX1 is an additional stereo return (index 10), + // not one of the 10 physical/BUS channel rows. Resolve by native index. + auto dedicated=juce::JSON::parse(json); + juce::Array auxRows; + for(int b=0;b(); + bus->setProperty("enabled",b==0); + bus->setProperty("main",true); + bus->setProperty("mute",false); + bus->setProperty("gain",1.0); + auxRows.add(juce::var(bus.release())); + } + dedicated.getDynamicObject()->setProperty("auxes",juce::var(auxRows)); + const auto rawSends=dedicated.getProperty("sends",juce::var()); + assert(rawSends.isArray()); + rawSends.getArray()->getReference(0).getDynamicObject()->setProperty("to",10); + assert(NativeDryRouteCommand::decode(dedicated,decoded,error)); + assert(decoded.aux.count==1&&decoded.sends.count==1); + assert(decoded.aux.sends[0].destination==0); + assert(decoded.aux.sends[0].tap==SendTap::preFader); + assert(PreparedRenderGraph::compile( + decoded.channels,ports,decoded.sends,graph,fault,decoded.aux)); + PreparedMixerBlock dedicatedBlock(graph,64); + assert(dedicatedBlock.process(inputs,3,l.data(),r.data(),2,noFx)); + assert(near(l[0],.5f)&&near(r[0],.5f)); // AUX PRE audible at CH1 -inf + // Invalid destination or disabled AUX must fail with unchanged result. + auxRows.getReference(0).getDynamicObject()->setProperty("enabled",false); + assert(!NativeDryRouteCommand::decode(dedicated,decoded,error)); + assert(decoded.aux.count==1); + auxRows.getReference(0).getDynamicObject()->setProperty("enabled",true); + rawSends.getArray()->getReference(0).getDynamicObject()->setProperty("to",14); + assert(!NativeDryRouteCommand::decode(dedicated,decoded,error)); + assert(decoded.aux.count==1); + // Older native commands still decode; AUX remains off by default. // Legacy command without "sends" remains backwards compatible. auto legacy=juce::JSON::parse(json.upToFirstOccurrenceOf(",\"sends\"",false,false)+"}"); assert(NativeDryRouteCommand::decode(legacy,decoded,error)); diff --git a/web/monitor.js b/web/monitor.js index 04e869cc4..ba1cf8ece 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -35,7 +35,8 @@ "#arRouteRows{overflow-x:auto}.arRouteRow{min-width:590px}#arRouteSends{margin-top:12px}#arRouteSends h3{font-size:12px;margin:8px 0;color:#b1d4dd}.arSendRow{display:grid;grid-template-columns:1fr 1fr 76px 83px 32px;gap:6px;margin-bottom:5px}.arSendRow select{width:100%;min-width:0;padding:6px;color:#e1eef5;background:#0d202b;border:1px solid #4d6879;border-radius:4px}.arSendRow button{border:1px solid #9a6060;background:#442930;color:#f3dadd;border-radius:4px}#arAddSend{font-size:10px;padding:6px 8px}" + ".arRouteFoot{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end;margin-top:12px}.arRouteFoot button,.arRouteClose{color:#f0f7fa;background:#24475a;border:1px solid #587f91;border-radius:4px;padding:8px 12px;cursor:pointer}" + "#arRouteApply{background:#237566;border-color:#4ba48d}#arRouteStop{background:#50343c;border-color:#a8717c}" + - "#arRouteFeedback{font-size:11px;min-height:18px;color:#8bdec1;margin-top:10px}"; + "#arRouteFeedback{font-size:11px;min-height:18px;color:#8bdec1;margin-top:10px}" + + ".arAuxRow{display:grid;grid-template-columns:64px 52px 90px 70px 1fr;align-items:center;gap:7px;padding:7px;background:#0c202b;border-bottom:1px solid #36515f;font-size:11px}.arAuxRow label{display:flex;gap:4px;align-items:center}.arAuxRow select{min-width:0;width:100%;background:#0c202b;color:#dcecf3;border:1px solid #496b7a;padding:6px;border-radius:4px}#arAuxReturns h3{font-size:12px;color:#b1d4dd;margin:14px 0 8px}#arAuxReturns p{color:#90afbc;font-size:10px;margin:4px 0 7px}"; document.head.appendChild(css); // Signal Check is declared in the permanent toolbar; footer holds status only. const overlay = document.createElement("div"); @@ -71,11 +72,12 @@ '

ArSonMix · Live Input Routing LAB

Reading actual device ports...
' + '

Real hardware routing test: independent stereo-compatible VST3 insert per channel, PRE/POST sends, and BUS returns. No portable route recall. Use headphones at LOW volume. ' + 'The normal CH1 VST3 host resumes after STOP. Every port shown is from the device active input mask.

' + - '

INTERNAL SENDS · PRE / POST FADER (MAX 32)

' + + '

4 DEDICATED AUX / FX RETURNS · INPUT CH1–10 REMAIN AVAILABLE

Each AUX has a separate stereo return, VST3, level and MASTER routing. PRE/POST sends may target AUX1–4 without consuming CH strips.

INTERNAL SENDS · PRE / POST FADER (MAX 32)

' + '
Select 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,pan:0,main:true,mute:false,solo:false,fxId:""})); + const draftAux=Array.from({length:4},()=>({enabled:false,gain:1,main:true,mute:false,fxId:""})); const draftSends=[]; let draftEpoch=0; // identity of the hardware used to draw these selectors function invalidateDraftForNewDevice(nextEpoch){ @@ -85,6 +87,7 @@ 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=""; } + for(const b of draftAux){b.enabled=false;b.gain=1;b.main=true;b.mute=false;b.fxId="";} draftSends.length=0; return true; } @@ -125,6 +128,9 @@ if(Object.prototype.hasOwnProperty.call(source,key)) draftRoutes[i][key]=source[key]; } + if(Array.isArray(saved.auxes)&&saved.auxes.length===4) + for(let b=0;b<4;b++)for(const key of ["enabled","gain","main","mute","fxId"]) + if(Object.prototype.hasOwnProperty.call(saved.auxes[b]||{},key))draftAux[b][key]=saved.auxes[b][key]; draftSends.length=0; if(Array.isArray(saved.sends)) for(const send of saved.sends.slice(0,32)) @@ -187,9 +193,27 @@ row.querySelector('[data-route-fx]').addEventListener('change',e=>{model.fxId=e.target.value;}); refreshMode(row); }); + drawAux(); drawSends(); updateRouteLabIdentity(); } + function drawAux(){ + const parent=document.getElementById("arAuxRows"); + parent.innerHTML=draftAux.map((bus,i)=>'
'+ + 'AUX '+(i+1)+''+ + ''+ + ''+ + ''+ + ''+ + '
').join(''); + parent.querySelectorAll('[data-aux-row]').forEach(row=>{ + const bus=draftAux[Number(row.dataset.auxRow)]; + row.querySelector('[data-aux-enable]').addEventListener('change',e=>{bus.enabled=e.target.checked;}); + row.querySelector('[data-aux-gain]').addEventListener('change',e=>{bus.gain=Number(e.target.value);}); + row.querySelector('[data-aux-main]').addEventListener('change',e=>{bus.main=e.target.checked;}); + row.querySelector('[data-aux-fx]').addEventListener('change',e=>{bus.fxId=e.target.value;}); + }); + } function refreshMode(row){ const type=row.querySelector('[data-route-mode]').value; row.querySelector('[data-route-left]').disabled=type==="NONE"||type==="BUS"; @@ -198,11 +222,12 @@ function drawSends(){ const el=document.getElementById("arSendRows"); const channels=Array.from({length:10},(_,i)=>''); - const channelSelect=(value)=>channels.map((option,i)=>option.replace(''')); + const listSelect=(options,value)=>options.map((option,i)=>option.replace(' '
'+ - ''+ - ''+ + ''+ + ''+ ''+ ''+ @@ -229,7 +254,7 @@ if(!label)return; setTextIfChanged(label,(d.active ? (d.ready?"DRY LAB ACTIVE":"DRY LAB STALE — SILENT, REAPPLY"):"DRY LAB OFF")+ " · device epoch "+(d.epoch||0)+" · rev "+(d.revision||0)+ - " · "+(d.ports?.length||0)+" enabled inputs · "+(d.outputPorts?.length||0)+" outputs · "+(d.sendCount||0)+" live sends"); + " · "+(d.ports?.length||0)+" enabled inputs · "+(d.outputPorts?.length||0)+" outputs · "+(d.sendCount||0)+" channel sends · "+(d.auxSendCount||0)+" AUX sends · "+(d.auxCount||0)+" AUX"); } function openRoutingLab(){ hydrateAcceptedRoute(); @@ -259,6 +284,7 @@ api.emitEvent("arMixAction",{action:"routingDryApply",value:{ deviceEpoch:draftEpoch,revision:Number(d.revision)||0, channels:draftRoutes.map(c=>({...c})), + auxes:draftAux.map(b=>({...b})), sends:draftSends.map(s=>({...s})) }}); }); @@ -268,7 +294,7 @@ if(result && typeof result==="object" && "epoch" in result)state.dryRoutingLab=result; document.getElementById("arRouteFeedback").textContent= reply?.ok===false?("REJECTED · "+(reply.error||"Invalid route")): - result.active?"NATIVE ACK: "+(result.fxCount||0)+" VST3 ("+(result.fxReused||0)+" preserved) · "+(result.sendCount||0)+" SENDS · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety"; + result.active?"NATIVE ACK: "+(result.fxCount||0)+" VST3 ("+(result.fxReused||0)+" preserved) · "+(result.auxCount||0)+" dedicated AUX · "+(result.auxSendCount||0)+" AUX sends · UNMUTE OUTPUT in SIGNAL CHECK":"NATIVE ACK: STOPPED · output remains MUTED for safety"; updateRouteLabIdentity(); });