From 799fdf4636bbca2eba38e57e87a85cae55e8b956 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 28 Oct 2026 06:04:08 +0700 Subject: [PATCH 1/8] feat(P1C): bounded DAG channel-send scheduler with pre/post fader taps and static zero-alloc dispatch --- engine/core/ChannelSendPlan.h | 169 ++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 engine/core/ChannelSendPlan.h diff --git a/engine/core/ChannelSendPlan.h b/engine/core/ChannelSendPlan.h new file mode 100644 index 000000000..1e22b9c1f --- /dev/null +++ b/engine/core/ChannelSendPlan.h @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "ChannelRoutingContract.h" +#include +#include +#include +#include +#include + +// P1C: bounded, allocation-free compile-only bus/send scheduler. +// This is NOT installed on the live JUCE audio thread. Publishing a Plan +// later requires device/graph epoch validation and a quiescent handoff. +// In a future callback, process channels in topologicalOrder, take POST-FX +// buffers for preFader sends, and take POST-FADER/POST-MUTE buffers for +// postFader sends. Pre-fader send mute/solo policy belongs to caller. +namespace armix::mixer { + +constexpr int maxChannelSends = 32; + +enum class SendTap : std::uint8_t { preFader, postFader }; +struct SendDefinition final { + int source = -1; + int destination = -1; + SendTap tap = SendTap::postFader; + float gain = 1.f; + float pan = 0.f; // stereo BALANCE, not mono equal-power panning + bool enabled = true; +}; +struct SendRequest final { + std::array toMaster {}; + std::array sends {}; + int count = 0; + SendRequest() noexcept { toMaster.fill(true); } +}; +enum class SendFault : std::uint8_t { + none, tooManySends, invalidCount, invalidStrip, selfFeedback, + invalidTap, invalidGain, invalidPan, duplicateSend, cycleDetected +}; +struct SendError final { + SendFault fault = SendFault::none; + int sendIndex = -1; + int strip = -1; +}; + +// Entire plan is immutable once published to a callback. No heap or +// dynamically sized vectors. All floating-point coefficient calculation, +// validation, and Kahn topological sorting occur on control thread ONLY. +struct ChannelSendPlan final { + struct Edge { + int destination = -1; + SendTap tap = SendTap::postFader; + float leftGain = 0.f, rightGain = 0.f; + }; + std::array orderedEdges {}; + std::array outgoingOffset {}; + std::array topologicalOrder {}; + std::array orderRank {}; + std::array toMaster {}; + int edgeCount = 0; + + static bool compile(const SendRequest& requested, + ChannelSendPlan& destination, + SendError& error) noexcept { + error = {}; + if (requested.count < 0) { + error.fault = SendFault::invalidCount; return false; + } + if (requested.count > maxChannelSends) { + error.fault = SendFault::tooManySends; return false; + } + ChannelSendPlan candidate; + candidate.toMaster = requested.toMaster; + std::array outgoingCount {}; + std::array indegree {}; + for (int i=0;i=stripCount || + s.destination<0 || s.destination>=stripCount) { + error={SendFault::invalidStrip,i,s.source};return false; + } + if (s.source==s.destination) { + error={SendFault::selfFeedback,i,s.source};return false; + } + if (s.tap!=SendTap::preFader && s.tap!=SendTap::postFader) { + error={SendFault::invalidTap,i,s.source};return false; + } + if (!std::isfinite(s.gain)||s.gain<0.f||s.gain>4.f) { + error={SendFault::invalidGain,i,s.source};return false; + } + if (!std::isfinite(s.pan)||s.pan< -1.f||s.pan>1.f) { + error={SendFault::invalidPan,i,s.source};return false; + } + // One edge per source/destination/tap. Different tap types may + // coexist, but identical duplicates would double the signal. + for (int j=0;j0.f?1.f-s.pan:1.f); + e.rightGain=s.gain*(s.pan<0.f?1.f+s.pan:1.f); + } + // Kahn's algorithm; deterministic ascending tie-break between strips. + std::array emitted {}; + for (int k=0;k=stripCount||frames<=0||!sourceLeft||!sourceRight|| + !inputLeft||!inputRight)return; + for(int e=outgoingOffset[source];e=0&&strip=0&&source=0&& + destination Date: Wed, 28 Oct 2026 06:05:02 +0700 Subject: [PATCH 2/8] test(P1C): verify 10-channel acyclic sends, pre/post taps, fan-in, pan, feedback rejection and release asserts --- tests/channel_send_plan_test.cpp | 104 +++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 tests/channel_send_plan_test.cpp diff --git a/tests/channel_send_plan_test.cpp b/tests/channel_send_plan_test.cpp new file mode 100644 index 000000000..7c74f8e23 --- /dev/null +++ b/tests/channel_send_plan_test.cpp @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/ChannelSendPlan.h" +#if defined(NDEBUG) +#undef NDEBUG // Windows Release must execute every acceptance assertion. +#endif +#include +#include +#include +#include +using namespace armix::mixer; +static bool close(float x,float y) { return std::abs(x-y)<1.e-6f; } + +int main() { + ChannelSendPlan plan; + SendRequest cfg; + SendError err; + assert(ChannelSendPlan::compile(cfg,plan,err)); + assert(plan.edgeCount==0); + for(int i=0;i CH2 pre-fader, CH1 -> CH4 post-fader, + // CH2 -> CH4 post-fader, CH3 -> CH4 pre-fader. + cfg.toMaster[0]=false; // sends-only source avoids accidental dry duplication + cfg.sends[0]={0,1,SendTap::preFader,.5f,0.f,true}; + cfg.sends[1]={0,3,SendTap::postFader,.4f,1.f,true}; + cfg.sends[2]={1,3,SendTap::postFader,1.f,0.f,true}; + cfg.sends[3]={2,3,SendTap::preFader,1.f,0.f,true}; + cfg.count=4; + assert(ChannelSendPlan::compile(cfg,plan,err)); + assert(plan.edgeCount==4); + assert(!plan.masterEnabled(0)&&plan.masterEnabled(1)); + assert(plan.upstreamOf(0,1)); + assert(plan.upstreamOf(1,3)); + assert(plan.upstreamOf(2,3)); + const std::array one {1.f,-.25f,.75f}; + const std::array two {.5f,.25f,-.5f}; + std::array,stripCount> l{},r{}; + std::array lp{},rp{}; + for(int i=0;i(77); + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::invalidTap); + cfg.sends[4].tap=SendTap::postFader; + cfg.sends[4].gain=std::numeric_limits::infinity(); + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::invalidGain); + cfg.sends[4].gain=.5f; + cfg.sends[4].pan=std::numeric_limits::quiet_NaN(); + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::invalidPan); + cfg.sends[4].pan=0.f; + cfg.sends[4].destination=stripCount; + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::invalidStrip); + cfg.sends[4].destination=1; + cfg.sends[4].enabled=false; + assert(ChannelSendPlan::compile(cfg,plan,err)); + assert(plan.edgeCount==4); // disabled edge never processed + cfg.count=maxChannelSends+1; + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::tooManySends); + cfg.count=-1; + assert(!ChannelSendPlan::compile(cfg,plan,err)&&err.fault==SendFault::invalidCount); + // Fails closed on missing input/output pointers and invalid channel id. + std::array sampleLeft {3.f,3.f,3.f},sampleRight {2.f,2.f,2.f}; + plan.dispatch(-1,SendTap::postFader,sampleLeft.data(),sampleRight.data(),lp.data(),rp.data(),3); + plan.dispatch(99,SendTap::postFader,sampleLeft.data(),sampleRight.data(),lp.data(),rp.data(),3); + plan.dispatch(0,SendTap::preFader,nullptr,sampleRight.data(),lp.data(),rp.data(),3); + + // Full 10-strip forward sends graph; source is processed before target. + cfg=SendRequest{}; + cfg.count=stripCount-1; + for(int i=0;i Date: Wed, 28 Oct 2026 06:05:37 +0700 Subject: [PATCH 3/8] ci(P1C): gate bounded send DAG DSP test in existing Windows CTest workflow --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f282d79a..e567f723f 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/ChannelSendPlan.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(ARMixChannelSendTests tests/channel_send_plan_test.cpp) + target_compile_features(ARMixChannelSendTests PRIVATE cxx_std_20) + add_test(NAME TenChannelAcyclicPrePostSends COMMAND ARMixChannelSendTests) add_executable(ARMixOrbitPhaseTests tests/orbit_phase_test.cpp) target_compile_features(ARMixOrbitPhaseTests PRIVATE cxx_std_20) add_test(NAME VstAzimuthOrbitRamp COMMAND ARMixOrbitPhaseTests) From c41a50b5849293360547c26623ddb3396034d37a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 28 Oct 2026 06:05:43 +0700 Subject: [PATCH 4/8] ci(P1C): gate bounded send DAG DSP test in existing Windows CTest workflow --- .github/workflows/p1-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index dd5c96876..864bd0da5 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 ARMixChannelSendTests 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 From 9b4169b9e7954941ad1cd2124ee02f3c47ea8823 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 28 Oct 2026 06:06:56 +0700 Subject: [PATCH 5/8] docs(P1C): deterministic sends, anti-feedback DAG, pre/post signal semantics and merge/hardware gates --- docs/P1C_INTERNAL_SENDS_DAG_20261028.md | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/P1C_INTERNAL_SENDS_DAG_20261028.md diff --git a/docs/P1C_INTERNAL_SENDS_DAG_20261028.md b/docs/P1C_INTERNAL_SENDS_DAG_20261028.md new file mode 100644 index 000000000..f2fa5f407 --- /dev/null +++ b/docs/P1C_INTERNAL_SENDS_DAG_20261028.md @@ -0,0 +1,49 @@ +# ArSonMix P1C — Acyclic per-channel sends and internal bus routing core + +**Date:** 2026-10-28 +**Base:** P1B stacked PR #110 (which depends on P1A PR #108) +**Status:** Prepared DSP core + deterministic native C++ tests. **NOT wired to live JUCE audio device or VST3.** +**Related:** #109 track routing, #95 channel FX, #15 hardware 0-FX crackles, #85 portable workspaces. + +## Native audio topology contract + +One physical input may fan out to multiple strips by explicit selection. Each strip independently processes its input FX, post-FX/pre-fader signal, its gain/mute/pan stage, and sends to another strip. P1C compiles **up to 32 sends** between ten strips (bounded, deterministic). No arbitrary 32-channel hardware restriction is implied: 32 is the temporary explicit capacity for *send edges*, not devices or input channels. + +`engine/core/ChannelSendPlan.h` provides: + +- One `SendDefinition`: source strip, destination strip, pre/post-fader tap, linear send gain, stereo balance and enabled flag. +- `SendRequest::toMaster[channel]`: independent default main-out control (true by default). A sends-only channel can turn off its direct MASTER path, avoiding unwanted double-feed. +- **Cycle detector:** reject CH1→CH2→CH1 and longer loops and self-feedback before activation. A deterministic Kahn topological sort prepares the actual processing order. Enabling a rejected edge leaves the previous plan unchanged. +- **Signal correctness:** pre-fader send comes from the *post-FX pre-fader* source buffer; post-fader send comes from *post-fader/post-mute* source buffer, provided by the future host integration. Different tap choices are not silently interchanged. Pre-fader sends intentionally do not follow fader attenuation; final policy for how solo/mute affects pre sends must be explicit in the native mixer host. +- **No implicit feedback or implicit master sends:** MASTER remains downstream of all strips. A MASTER-to-channel return requires a separate latency/feedback-safe graph contract and is deliberately unavailable at P1C. +- Direct send routing is additive to the channel's main output; `toMaster=false` is the way to construct an explicit sends-only source. The actual output stage must respect this flag before the feature is enabled. +- Sends support per-edge stereo balance; they do not currently perform an automatic stereo-to-mono conversion. The independent format contract of P1B must select channel DSP width, and insert-plugin layout negotiation remains a separate requirement. + +## Realtime performance model + +All validation, float finite checks, duplicate checks, cycle sorting, output offsets and send gain/pan coefficients are computed **off realtime** by `ChannelSendPlan::compile`. Plan publication is **not** implemented yet. `dispatch` loops only over the active source's outgoing edges and the host-provided fixed sample count, accumulating into preallocated, already-cleared destination buffers. No heap, locks, sample-loop trigonometry, topology scans, telemetry string allocations, graph destruction or plugin creation in this primitive. + +The future RT integration must provide correctly scoped scratch buffers: +1. Mix device input and incoming internal sends for the target strip into preallocated stereo scratch, following the compiled topological order. +2. Run that strip's VST3 instances exactly once on its own buffer; capture its post-FX/pre-fader tap. +3. Apply fader/mute/solo/pan and capture a distinct post-fader tap; deliver those outputs through the compiled edges. +4. Mix only explicitly MASTER-enabled strips to MASTER; run its FX chain and main output controls once, then submit to device. +5. The routing plan, channel VST instances, plugin editors, Orbit references and negotiated device source identity must be changed through a single safe graph epoch/handoff/ACK protocol. Never process the same VST3 instance concurrently in old/new graphs. + +Input device masks, hotplug and callback port indices are owned by P1B + forthcoming device registry. P1C cannot prove stable hardware timing and must not be enabled on top of a failing zero-VST hardware FAT (#15). + +## Tests / boundaries + +`tests/channel_send_plan_test.cpp` verifies: zero-send defaults, deterministic 10-strip order, pre vs post taps, send pan and gain, fan-out, fan-in, main-out disable, cycle/self-loop rejection, duplicate edge prevention, invalid indices, gain, pan and tap, disabled edges, over-capacity, transaction rollback and invalid buffer guard. Windows Release `assert` is kept enabled even under `NDEBUG` so CTest is meaningful. No redundant GitHub Action matrix. + +The planned GUI should offer a compact SOURCE chooser and channel Sends inspector. Only show a real send selection when both source and destination are native connected buses; all routed requests use native ACK/reject. No full DOM redraw on pointer movements and no fake meter. + +## Delivery sequencing + +1. P1A #108 exact-head green, then merge it after verifying current `main` and unrelated PR ownership. +2. P1B #110 exact-head green, retarget after parent merge; merge with no conflict and no regression. +3. P1C this stacked PR exact-head green; retarget after P1B merge. +4. Real device registry (stable endpoint/port IDs), immutable graph/device epoch lifetime, and true per-channel plugin bus negotiation. +5. Only after issue #15 clean 0-FX physical FAT: staged live 2-channel, 4-channel, then 10-channel hardware acceptance with sends, recall, Orbit, all FX operations, and measured xrun/callback deadlines. + +**No claim of full live 10-channel FX, click-free sends or hardware performance certification is made by this milestone.** From 7b07d86bf95adfb90e79585ec5002f29cf54278e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 28 Oct 2026 06:08:34 +0700 Subject: [PATCH 6/8] fix(P1C): distinguish internal bus-return activity from presence of physical input --- engine/core/ChannelSendPlan.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/core/ChannelSendPlan.h b/engine/core/ChannelSendPlan.h index 1e22b9c1f..d5e986450 100644 --- a/engine/core/ChannelSendPlan.h +++ b/engine/core/ChannelSendPlan.h @@ -56,6 +56,9 @@ struct ChannelSendPlan final { std::array topologicalOrder {}; std::array orderRank {}; std::array toMaster {}; + // A strip can be a BUS RETURN even without any physical input; do not + // gate these strips on ChannelRoutingPlan::Strip::active (physical only). + std::array receivesInternal {}; int edgeCount = 0; static bool compile(const SendRequest& requested, @@ -102,6 +105,7 @@ struct ChannelSendPlan final { if (!s.enabled) continue; ++outgoingCount[s.source]; ++indegree[s.destination]; + candidate.receivesInternal[s.destination]=true; ++candidate.edgeCount; } candidate.outgoingOffset[0]=0; @@ -158,6 +162,9 @@ struct ChannelSendPlan final { } } } + bool receivesInternalAudio(int strip) const noexcept { + return strip>=0&&strip=0&&strip Date: Wed, 28 Oct 2026 06:08:51 +0700 Subject: [PATCH 7/8] test(P1C): ensure FX Return active from internal sends with no physical port --- tests/channel_send_plan_test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/channel_send_plan_test.cpp b/tests/channel_send_plan_test.cpp index 7c74f8e23..5c4b46a37 100644 --- a/tests/channel_send_plan_test.cpp +++ b/tests/channel_send_plan_test.cpp @@ -16,6 +16,7 @@ int main() { SendError err; assert(ChannelSendPlan::compile(cfg,plan,err)); assert(plan.edgeCount==0); + assert(!plan.receivesInternalAudio(3)); for(int i=0;i Date: Wed, 28 Oct 2026 06:09:21 +0700 Subject: [PATCH 8/8] docs(P1C): preserve send buffers and standalone FX Returns when source is disconnected --- docs/P1C_INTERNAL_SENDS_DAG_20261028.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/P1C_INTERNAL_SENDS_DAG_20261028.md b/docs/P1C_INTERNAL_SENDS_DAG_20261028.md index f2fa5f407..4a25de65c 100644 --- a/docs/P1C_INTERNAL_SENDS_DAG_20261028.md +++ b/docs/P1C_INTERNAL_SENDS_DAG_20261028.md @@ -24,17 +24,18 @@ One physical input may fan out to multiple strips by explicit selection. Each st All validation, float finite checks, duplicate checks, cycle sorting, output offsets and send gain/pan coefficients are computed **off realtime** by `ChannelSendPlan::compile`. Plan publication is **not** implemented yet. `dispatch` loops only over the active source's outgoing edges and the host-provided fixed sample count, accumulating into preallocated, already-cleared destination buffers. No heap, locks, sample-loop trigonometry, topology scans, telemetry string allocations, graph destruction or plugin creation in this primitive. The future RT integration must provide correctly scoped scratch buffers: -1. Mix device input and incoming internal sends for the target strip into preallocated stereo scratch, following the compiled topological order. -2. Run that strip's VST3 instances exactly once on its own buffer; capture its post-FX/pre-fader tap. -3. Apply fader/mute/solo/pan and capture a distinct post-fader tap; deliver those outputs through the compiled edges. -4. Mix only explicitly MASTER-enabled strips to MASTER; run its FX chain and main output controls once, then submit to device. -5. The routing plan, channel VST instances, plugin editors, Orbit references and negotiated device source identity must be changed through a single safe graph epoch/handoff/ACK protocol. Never process the same VST3 instance concurrently in old/new graphs. +1. At the start of **each audio block**, clear **every** per-strip destination/incoming-send accumulator exactly once; also prepare each strip's physical input scratch. Use `ChannelRoutingPlan::extract` **before** any internal-send dispatch, because `extract` overwrites scratch. Never clear the destination after an upstream send has already written to it. +2. Walk `topologicalOrder` once, combining that strip's prepared physical input and previously accumulated upstream sends into its *own* preallocated input buffer, then run its VST3 chain exactly once. Capture its post-FX/pre-fader tap. +3. Apply fader/mute/solo/pan to a distinct scratch output, capture its post-fader tap, and dispatch each configured pre/post tap only from the correct buffer. Do not reuse a destination accumulator as a source. +4. `receivesInternalAudio(strip)` is true for any bus-return recipient, **even if its hardware SourceMode is disconnected**. The future host must not skip a return merely because P1A/P1B's physical-only `Strip::active` is false. The return's effective gain/mute/solo state must be applied separately, without processing an invented physical input. +5. Mix only `toMaster=true` strips to MASTER; run MASTER FX and final output controls once, then send to the selected driver output. `toMaster=false` prevents duplicate dry+send output. +6. The routing plan, channel VST instances, plugin editors, Orbit references and negotiated device source identity must be changed through a single safe graph epoch/handoff/ACK protocol. Never process the same VST3 instance concurrently in old/new graphs. Input device masks, hotplug and callback port indices are owned by P1B + forthcoming device registry. P1C cannot prove stable hardware timing and must not be enabled on top of a failing zero-VST hardware FAT (#15). ## Tests / boundaries -`tests/channel_send_plan_test.cpp` verifies: zero-send defaults, deterministic 10-strip order, pre vs post taps, send pan and gain, fan-out, fan-in, main-out disable, cycle/self-loop rejection, duplicate edge prevention, invalid indices, gain, pan and tap, disabled edges, over-capacity, transaction rollback and invalid buffer guard. Windows Release `assert` is kept enabled even under `NDEBUG` so CTest is meaningful. No redundant GitHub Action matrix. +`tests/channel_send_plan_test.cpp` verifies: zero-send defaults, deterministic 10-strip order, pre vs post taps, send pan and gain, fan-out, fan-in, main-out disable, cycle/self-loop rejection, duplicate edge prevention, invalid indices, gain, pan and tap, disabled edges, over-capacity, transaction rollback and invalid buffer guard, plus audio-return activity with no physical port. Windows Release `assert` is kept enabled even under `NDEBUG` so CTest is meaningful. No redundant GitHub Action matrix. The planned GUI should offer a compact SOURCE chooser and channel Sends inspector. Only show a real send selection when both source and destination are native connected buses; all routed requests use native ACK/reject. No full DOM redraw on pointer movements and no fake meter.