diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index dd5c96876..2c16952f5 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -63,7 +63,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 ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests 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 ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixPreparedBusGraphTests ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests 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/CMakeLists.txt b/CMakeLists.txt index 8f282d79a..dcd006786 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/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/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.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/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/PreparedBusGraph.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/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.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/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) target_compile_definitions(ARMixConsole PRIVATE JUCE_WEB_BROWSER=1 JUCE_USE_WIN_WEBVIEW2=1 @@ -53,6 +53,9 @@ if(BUILD_TESTING) add_executable(ARMixChannelRoutingContractTests tests/channel_routing_contract_test.cpp) target_compile_features(ARMixChannelRoutingContractTests PRIVATE cxx_std_20) add_test(NAME MonoStereoSparsePhysicalPortRouting COMMAND ARMixChannelRoutingContractTests) + add_executable(ARMixPreparedBusGraphTests tests/prepared_bus_graph_test.cpp) + target_compile_features(ARMixPreparedBusGraphTests PRIVATE cxx_std_20) + add_test(NAME P1CTenChannelTwoAuxAudioRenderAndCycleRejection COMMAND ARMixPreparedBusGraphTests) add_executable(ARMixOrbitPhaseTests tests/orbit_phase_test.cpp) target_compile_features(ARMixOrbitPhaseTests PRIVATE cxx_std_20) add_test(NAME VstAzimuthOrbitRamp COMMAND ARMixOrbitPhaseTests) diff --git a/engine/core/PreparedBusGraph.h b/engine/core/PreparedBusGraph.h new file mode 100644 index 000000000..6d9f528d4 --- /dev/null +++ b/engine/core/PreparedBusGraph.h @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "ChannelRoutingContract.h" +#include +#include +#include +#include +namespace armix::mixer { +// P1C: offline-compiled, no-alloc two-AUX processing graph. +// The physical-port mask and VST lifecycles remain separate native gates. +constexpr int auxBuses=2, routingNodes=stripCount+auxBuses, maxRouteFrames=1024; +enum class RouteKind { none, mono, stereo, strip, aux }; +struct RouteNode { + RouteKind kind=RouteKind::none; + int a=-1,b=-1,sendTo=-1; + float sendLevel=0.f,level=1.f; + bool main=true,mute=false; +}; +struct RouteSetup { + ChannelRoutingConfig channels{}; + std::array nodes{}; +}; +enum class RouteError { none,invalidSource,invalidSend,invalidGain,cycle,badDevice }; +struct RouteFault {RouteError code=RouteError::none;int node=-1;}; +struct PreparedRoutes { + ChannelRoutingPlan device{}; + std::array nodes{}; + std::array order{}; + static bool compile(const RouteSetup& src,std::span active, + PreparedRoutes& dst,RouteFault& fault) noexcept { + fault={}; + RouteSetup cfg=src; + for(int i=0;i,routingNodes> edges{}; + std::array incoming{}; + for(int n=0;n4.f){ + fault={RouteError::invalidGain,n};return false; + } + int from=-1; + if(s.kind==RouteKind::strip){if(s.a<0||s.a>=stripCount){fault={RouteError::invalidSource,n};return false;}from=s.a;} + else if(s.kind==RouteKind::aux){if(s.a<0||s.a>=auxBuses){fault={RouteError::invalidSource,n};return false;}from=stripCount+s.a;} + else if(s.kind==RouteKind::mono||s.kind==RouteKind::stereo){ + if(n>=stripCount){fault={RouteError::invalidSource,n};return false;} + }else if(s.kind!=RouteKind::none){fault={RouteError::invalidSource,n};return false;} + if(from>=0&&!edges[from][n]){edges[from][n]=true;incoming[n]++;} + if(s.sendTo!=-1){ + if(n>=stripCount||s.sendTo<0||s.sendTo>=auxBuses||!std::isfinite(s.sendLevel)||s.sendLevel<0.f||s.sendLevel>4.f){ + fault={RouteError::invalidSend,n};return false; + } + int to=stripCount+s.sendTo; + if(!edges[n][to]){edges[n][to]=true;incoming[to]++;} + } + } + PreparedRoutes p;p.device=device;p.nodes=src.nodes; + std::array done{}; + for(int k=0;k; + std::array left_{},right_{},addLeft_{},addRight_{}; + Samples masterL_{},masterR_{}; +public: + template + bool process(const PreparedRoutes& p,const float* const* inputs,int inputCount, + float* outL,float* outR,int frames,Insert&& insert) noexcept { + if(!outL||!outR||frames<=0||frames>maxRouteFrames)return false; + for(int n=0;n=0){ + int target=stripCount+x.sendTo; + for(int i=0;i +#include +#include +using namespace armix::mixer; +static bool eq(float a,float b){return std::abs(a-b)<1.e-4f;} +int main(){ + RouteSetup setup; + constexpr std::array ports{5,2,7}; + setup.nodes[0]={RouteKind::mono,2,-1,0,.25f,1.f,true,false}; + setup.nodes[1]={RouteKind::stereo,5,7}; + setup.nodes[2]={RouteKind::strip,0};setup.nodes[2].main=false; + PreparedRoutes plan;RouteFault fault; + assert(PreparedRoutes::compile(setup,ports,plan,fault)); + std::array h5{2,2,2,2},h2{1,1,1,1},h7{3,3,3,3},l{},r{}; + const float* physical[]{h5.data(),h2.data(),h7.data()}; + PreparedRouteRuntime engine; + assert(engine.process(plan,physical,3,l.data(),r.data(),4)); + assert(eq(l[0],3.25f)&&eq(r[0],4.25f)); + assert(engine.process(plan,physical,3,l.data(),r.data(),4, + [](int bus,float* a,float* b,int n) noexcept { + if(bus==stripCount)for(int i=0;i