Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/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_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/MasterOutputMonoPolicy.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/NativeDryShowRecall.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
Expand Down Expand Up @@ -223,7 +223,7 @@ if(BUILD_TESTING)
target_compile_features(ARMixShowSchemaTests PRIVATE cxx_std_20)
add_test(NAME P4NativeShowSnapshotV2WireRoundTrip COMMAND ARMixShowSchemaTests)
juce_add_console_app(ARMixLiveShowCaptureTests PRODUCT_NAME "ArSonMix Live Native Dry Show Capture Tests")
target_sources(ARMixLiveShowCaptureTests PRIVATE tests/native_live_show_capture_test.cpp src/NativeLiveShowCapture.h src/NativeShowStore.h)
target_sources(ARMixLiveShowCaptureTests PRIVATE tests/native_live_show_capture_test.cpp src/NativeLiveShowCapture.h src/NativeDryShowRecall.h src/NativeShowStore.h)
target_link_libraries(ARMixLiveShowCaptureTests PRIVATE juce::juce_core juce::juce_cryptography juce::juce_recommended_config_flags)
target_compile_features(ARMixLiveShowCaptureTests PRIVATE cxx_std_20)
add_test(NAME P4NativeAcknowledgedDryShowCaptureAndStorage COMMAND ARMixLiveShowCaptureTests)
Expand Down
30 changes: 30 additions & 0 deletions docs/P4_NATIVE_DRY_SHOW_RECALL_STAGE4_20261029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# P4 Stage 4 — Verified native DRY Show browse & recall (2026-10-29)

**Status:** Real native recall transaction for **zero-VST3** saved Shows only, not browser scene simulation or hardware FAT qualification.

## End-to-end operator path

1. User manually opens the correct DIRECT ASIO/WASAPI device, verifies visible physical input ports in Routing LAB, APPLYs an initial zero-FX route, and MUTEs physical output. There is **no automatic hardware device selection** from saved files.
2. **BROWSE SHOWS** runs a bounded metadata walk of `Studio/Shows` on the same owned IO worker as SAVE, reading at most 256 Show directories and returning the most recent 64. No filesystem work or SHA hashing on the JUCE callback/GUI paint thread. The browser displays native IDs/names, never untrusted disk paths.
3. **RECALL SELECTED DRY** accepts a strict 36-character UUID, captures the current device epoch+graph revision token, and asks the worker to call the existing SHA-verified `NativeShowStore::load()`. Full manifest, ordered snapshots, AUX, referenced VST3 blob hashes, and bounded generation integrity are checked on read before the snapshot is returned.
4. After IO completes, on the JUCE message thread the app rereads native status and rejects stale epoch/revision, deactivated Routing LAB, unmuted output, independent clock, missing/changed physical input ports, or active VST3.
5. `NativeDryShowRecall::prepare()` decodes/revalidates schema V3, rejects any CH/AUX VST3, unsupported master pan / gain, and produces a **new** `NativeDryRouteCommand` containing actual 10 INPUT channel routing, four dedicated AUX, fader gains including exact zero, PAN/MUTE/SOLO, PRE/POST sends, BUS vs NONE, and master routing. The preflight does **not** publish, load a plugin, touch a hardware device, or mutate caller output on failure.
6. Only the existing `LiveAudioEngine::applyDryRoutingLab` can compile and publish the new immutable prepared graph. Its single-clock DIRECT gate, epoch+revision CAS, hardware sparse-mask validation, zero-VST condition, and RT snapshot retirement remain authoritative. On success, master linear gain/mute/mono apply on the control thread, with hardware output **still MUTED**. Failed preflight or publish leaves the prior route unaffected. Dedicated MASTER MONO is now honored by the native Routing LAB callback: zero-allocation 64-sample stereo-to-mono ramp while unmuted, primed to exact mono while hardware output is muted. MASTER controls are synchronized through one native bridge helper for both CH1 and LAB paths; prior LAB early return may no longer skip the master fader/MUTE/MONO state.
7. GUI shows explicit native ACK/rejection and refreshes routing draft from the *new* native acceptedRoute. **UNMUTE is disabled during any Show IO/USB backup**, preventing disk activity from racing an intentional live output unmute. User must verify input mapping at low headphone volume before explicitly unmuting.

## Architectural constraints

- One existing JUCE audio engine, no competing mixer, no callback alloc/lock/I/O/JSON, no third-party VST lifecycle calls in recall.
- Persisted physical port indexes are DEVICE-LOCAL. Existence on the newly selected device is verified, but matching numeric indexes alone are **not** proof of matching microphones: never auto-unmute, manually verify hardware identity/routing on another computer.
- VST3-equipped Shows are **fail-closed** even if all binaries/hashes exist. Correct vendor `getStateInformation` thread affinity and quiescence, cross-vendor state restore, latency/PDC, Orbit state and backup licensing remain future gates.
- The live Routing LAB remains an explicit engineering hardware mode; this milestone is not yet a production-scene playback guarantee.
- A pending Show load checks the captured epoch/revision again after IO; hotplug/STOP/another APPLY cannot publish stale recorded ports. The user may always STOP and keep output muted.

## Acceptance

- Native CTest covers end-to-end schema3 on-disk roundtrip, then live preflight conversion (10+4, BUS/NONE identity, sparse physical ports, hard linear zero, CH and AUX PRE/POST, master); rejects missing port, unmuted output, invalid current graph state, vendor VST3 and unsupported master gain without changing previously prepared command.
- Chromium UI smoke must pass for the new native browse/recall controls and event bridge.
- Windows MSVC must rebuild actual JUCE executable and pass all native CTest + embedded UI ZIP integrity. No CI run should be started until this bounded change is ready.
- On actual hardware require manual FAT for DIRECT ASIO/WASAPI, 1/2/10 INPUT, 4 AUX, 128/256/480 frames, STOP/replug, accidental unmute prevention, port identity, readback, zero FX and crackle #15. CI does **not** qualify real hardware.

Related: #137, merged #138 (AUX Show store), merged #139 (live SAVE), #15 zero-plugin crackle.
33 changes: 33 additions & 0 deletions engine/core/MasterOutputMonoPolicy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <algorithm>

// P4 mono master output mode is a control-plane policy with a click-safe
// fixed-sample interpolation. It owns one audio-callback-local scalar.
// No allocation, lock, timer, parameter read, or extra audio buffering.
namespace armix::dsp {
class MasterOutputMonoPolicy final {
public:
static constexpr int transitionSamples=64;
// Hardware output was already gated to silence, so prime the correct
// mono state BEFORE the first unmuted output sample.
void primeWhileMuted(bool mono) noexcept { blend_=mono?1.f:0.f; }
void process(bool mono,float& left,float& right) noexcept {
const float target=mono?1.f:0.f;
constexpr float step=1.f/static_cast<float>(transitionSamples);
if(blend_<target)blend_=std::min(target,blend_+step);
else if(blend_>target)blend_=std::max(target,blend_-step);
if(blend_==0.f)return;
const float center=(left+right)*.5f;
if(blend_==1.f) {
left=right=center; // bit-exact L/R in fully enabled MONO mode
return;
}
left+=blend_*(center-left);
right+=blend_*(center-right);
}
float blend() const noexcept {return blend_;}
private:
float blend_=0.f; // audio thread exclusively
};
} // namespace armix::dsp
9 changes: 8 additions & 1 deletion src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
{
if (std::isfinite (value)) masterGain_.store (juce::Decibels::decibelsToGain (juce::jlimit (-60.f, 10.f, value)));
}
// Validated native Show recall uses exact linear 0 (true silence),
// not a lossy dB roundtrip through -60 dB.
void setMasterGainLinear(float value) noexcept {
if(std::isfinite(value) && value>=0.f && value<=2.f)
masterGain_.store(value,std::memory_order_release);
}
void setChannelGainDb (float value) noexcept
{
if (std::isfinite (value)) channelGain_.store (juce::Decibels::decibelsToGain (juce::jlimit (-60.f, 10.f, value)));
Expand Down Expand Up @@ -1320,7 +1326,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
const bool routed=dryRoutingLab_.process(inputs,inputChannels,outputs,
outputChannels,samples,
masterGain_.load(std::memory_order_relaxed),
!outputPermitted);
!outputPermitted,
masterMono_.load(std::memory_order_relaxed));
// STOP can race after the outer active() check. Never leave a
// callback's output untouched, and NEVER fall through into CH1.
if(!routed) {
Expand Down
8 changes: 7 additions & 1 deletion src/LiveDryRoutingLab.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include "../engine/core/PreparedMixerBlock.h"
#include "../engine/core/MasterOutputMonoPolicy.h"
#include "../engine/core/LiveChannelFxGraph.h"
#include "VstBusLayout.h"
#include "../engine/core/NativeDryRouteCommand.h"
Expand Down Expand Up @@ -324,7 +325,7 @@ class LiveDryRoutingLab final {
// A failed run never falls through to an unrelated microphone/plugin path.
bool process(const float* const* inputs,int inputCount,
float* const* outputs,int outputCount,int frames,
float masterGain,bool masterMuted) noexcept {
float masterGain,bool masterMuted,bool masterMono) 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);
Expand Down Expand Up @@ -365,6 +366,7 @@ class LiveDryRoutingLab final {
// Prime a 256-sample fade FROM ZERO for the first unmuted block.
// Never interpolate any previously audible sample while muted.
if(masterMuted) {
masterMonoPolicy_.primeWhileMuted(masterMono); // RT-only; no startup stereo leak
fadeRemaining_=rampFrames;
fadeFromL_=fadeFromR_=0.f;
lastOutputL_=lastOutputR_=0.f;
Expand Down Expand Up @@ -400,6 +402,9 @@ class LiveDryRoutingLab final {
r=fadeFromR_+(r-fadeFromR_)*t;
--fadeRemaining_;
}
// 64-sample click-safe mono transition, with exact dual-mono
// L/R at blend=1. No extra device quantum or buffer latency.
masterMonoPolicy_.process(masterMono,l,r);
outputs[0][offset+i]=l;
outputs[1][offset+i]=r;
lastOutputL_=l;
Expand Down Expand Up @@ -490,6 +495,7 @@ class LiveDryRoutingLab final {
}
private:
Publisher publisher_;
armix::dsp::MasterOutputMonoPolicy masterMonoPolicy_; // audio callback only
std::array<ChannelEdit,count> channelEdits_{}; // JUCE message thread only
std::array<juce::String,count> channelFxNames_{}; // status/control thread only
std::array<juce::String,auxCount> auxFxNames_{}; // dedicated bus FX
Expand Down
Loading
Loading