Skip to content
Merged
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 @@ -226,7 +226,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
19 changes: 19 additions & 0 deletions docs/P4_NATIVE_DRY_SHOW_BROWSE_RECALL_20261029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# P4 Stage 4 — Native DRY Show Browse & Recall (2026-10-29)

## Product milestone
ArSonMix now has one actual portable Studio/Shows lifecycle for **verified DRY routing snapshots**: SAVE (previous milestone), BROWSE current stored generations, SELECT immutable Show UUID, and RECALL a real device-bound 10 INPUT + 4 AUX + PRE/POST prepared graph. The UI is not localStorage or a fake preview. BROWSE scans at most 256 directories and displays the newest 64 metadata entries. No disk paths are exposed to the WebView. On RECALL the existing worker hashes/loads the complete immutable stored Show generation away from the audio callback and JUCE paint.

After disk IO, the control thread rechecks **device epoch and native route revision** taken before dispatch; changed devices, CLEAR PATCH, concurrent routing APPLY, invalid physical input ports, stereo duplicates, unsupported master state, stale session or third-party VST3 all reject before publication. `NativeDryShowRecall::prepare` is pure control-plane and does not mutate caller command on validation failure. Only the original `LiveAudioEngine::applyDryRoutingLab` can apply the prepared graph with DIRECT and OUTPUT MUTE gates, publisher CAS and RT-safe retirement. On success native MASTER linear gain (including true exact-zero), mute and mono are restored; physical output **remains MUTED** and must be checked by the operator before manually arming.

The existing native 10CH/4AUX processing callback implements MASTER mono with a 64-sample ramp and immediate muted-state priming. No callback allocation, lock, I/O, VST instance creation, graph duplication, per-frame JS repaint or WebView AudioWorklet. The existing CH1 borrowed VST3/Orbit graph is protected; DRY recall rejects any active CH1 FX rack, and stored vendor strip/AUX FX remain unsupported for state/identity safety. It makes **no claim** of port-number equivalence across different computers or audio interfaces.

## Acceptance / anti-regression
- Native CTest exercises actual on-disk Save→load→decode→prepare, exact 10CH sparse physical indices, BUS/NONE, linear zero, CH and AUX sends, PRE/POST, MASTER mono/gain, and failure rollback for unmuted output, lost port, stale native routing, CH1/AUX VST3.
- Chromium smoke covers bounded native browse, rejecting invalid IDs, intentionally selected UUID recall with device READY, no automatic unmute, and visible negative ACK.
- Output-unmute is blocked while Studio/Shows IO runs; panic MUTE remains immediate.
- The same native IO worker serializes SAVE/BROWSE/RECALL, no redundant background threads or CI workflows.
- All merged B3 #160 changes take precedence; port on current main after its exact-head CI, never overwrite the new unpatched production session with an old operator LAB.
- P0 physical 0-VST crackle #15 remains unresolved and requires actual wired ASIO/WASAPI hardware FAT. This DRY functionality is **not** full VST-equipped Show state/portable licensing compatibility, PDC or hardware AUX OUTPUT patching.

## Scope and provenance
Extracted carefully from the older #141 concept, **not bulk merged**. All main/JUCE routing adapters, current approved WebView UI, R2 AUX send matrix, FX shared picker and native graph lifecycle remain source-of-truth. Future full FX-equipped Show recall needs snapshot-safe vendor state capture/restore, instance lifetime, plugin affinity and PDC qualification on hardware.
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 @@ -533,6 +533,12 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
{
if (std::isfinite (value)) masterGain_.store (juce::Decibels::decibelsToGain (juce::jlimit (-60.f, 10.f, value)));
}
// Restored Show snapshots preserve exact linear zero, unlike a dB
// conversion clamped at -60 dB. Message thread, atomic publish only.
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 @@ -1565,7 +1571,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
const bool routed=dryRoutingLab_.process(inputs,inputChannels,outputs,
outputChannels,samples,
masterGain_.load(std::memory_order_relaxed),
!outputPermitted,&ch1Lease,&processLegacyChannelOne);
!outputPermitted,&ch1Lease,&processLegacyChannelOne,
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 @@ -383,7 +384,8 @@ class LiveDryRoutingLab final {
float* const* outputs,int outputCount,int frames,
float masterGain,bool masterMuted,
void* externalContext=nullptr,
FxGraph::ExternalStripFx externalFx=nullptr) noexcept {
FxGraph::ExternalStripFx externalFx=nullptr,
bool masterMono=false) 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 @@ -436,6 +438,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);
fadeRemaining_=rampFrames;
fadeFromL_=fadeFromR_=0.f;
lastOutputL_=lastOutputR_=0.f;
Expand Down Expand Up @@ -472,6 +475,8 @@ class LiveDryRoutingLab final {
r=fadeFromR_+(r-fadeFromR_)*t;
--fadeRemaining_;
}
// Sample-smoothed, zero-heap dual-mono MASTER output policy.
masterMonoPolicy_.process(masterMono,l,r);
outputs[0][offset+i]=l;
outputs[1][offset+i]=r;
lastOutputL_=l;
Expand Down Expand Up @@ -563,6 +568,7 @@ class LiveDryRoutingLab final {
}
private:
Publisher publisher_;
armix::dsp::MasterOutputMonoPolicy masterMonoPolicy_; // audio thread 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