diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 7986a7b82..10e6a436f 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -1,7 +1,7 @@ name: Windows Native VST3 Host on: push: - branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress ] + branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics ] pull_request: workflow_dispatch: @@ -29,7 +29,9 @@ jobs: run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive - name: Validate native UI JavaScript shell: pwsh - run: node --check web/bridge.js + run: | + node --check web/bridge.js + node --check web/monitor.js - name: Configure Windows x64 shell: pwsh run: > @@ -49,13 +51,13 @@ jobs: Where-Object { $_.Name -like "*AR*Mix*" -and $_.FullName -match 'Release' } | Select-Object -First 1 if (-not $exe) { throw "ARMixConsole EXE not found" } - Copy-Item $exe.FullName "dist/AR-MIX-Studio-P2-DAW.exe" + Copy-Item $exe.FullName "dist/AR-MIX-Studio-P2-Output-Diagnostic.exe" Copy-Item README.md "dist/README.md" "P2 experimental: output muted until MONITOR ON; do not use during a public livestream without hardware tests." | Out-File -FilePath dist/FIRST_SOUND_README.txt -Encoding utf8 - uses: actions/upload-artifact@v4 with: - name: AR-MIX-Studio-P2-DAW-Workflow-Windows-x64 + name: AR-MIX-Studio-P2-Output-Diagnostic-Windows-x64 path: dist/ if-no-files-found: error retention-days: 14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 08286650e..a77f62688 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ juce_add_gui_app(ARMixConsole NEEDS_CURL FALSE) juce_add_binary_data(ARMixAssets SOURCES - web/index.html web/styles.css web/app.js web/bridge.js) + 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/PluginCatalog.h) target_compile_definitions(ARMixConsole PRIVATE diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index d92afaca3..a2f8e11c2 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -58,6 +58,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback void setMonitorEnabled (bool value) noexcept { monitor_.store (value); } bool isMonitorEnabled() const noexcept { return monitor_.load(); } + void setDryTestEnabled (bool value) noexcept { dryTest_.store (value); } + bool isDryTestEnabled() const noexcept { return dryTest_.load(); } void setMasterGainDb (float value) noexcept { if (std::isfinite (value)) masterGain_.store (juce::Decibels::decibelsToGain (juce::jlimit (-60.f, 10.f, value))); @@ -191,7 +193,19 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback o->setProperty ("buffer", d ? d->getCurrentBufferSizeSamples() : 0); o->setProperty ("monitor", monitor_.load()); o->setProperty ("masterMute", masterMute_.load()); + o->setProperty ("channelMute", channelMute_.load()); + o->setProperty ("dryTest", dryTest_.load()); + juce::AudioDeviceManager::AudioDeviceSetup setup; + deviceManager_.getAudioDeviceSetup (setup); + o->setProperty ("inputDevice", setup.inputDeviceName); + o->setProperty ("outputDevice", setup.outputDeviceName); + o->setProperty ("deviceInputChannels", d ? d->getActiveInputChannels().countNumberOfSetBits() : 0); + o->setProperty ("deviceOutputChannels", d ? d->getActiveOutputChannels().countNumberOfSetBits() : 0); + o->setProperty ("callbackInputChannels", callbackInputs_.load()); + o->setProperty ("callbackOutputChannels", callbackOutputs_.load()); + o->setProperty ("callbackCount", static_cast (callbackCount_.load())); o->setProperty ("inputPeak", inputPeak_.load()); + o->setProperty ("postFxPeak", postFxPeak_.load()); o->setProperty ("peak", outputPeak_.load()); o->setProperty ("latencySamples", totalLatency_.load()); o->setProperty ("chainCount", count_); @@ -208,9 +222,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::AudioBuffer scratch_; // Indexed atomic bypass flags: instant RT-safe toggles, no graph detachment. std::array, maxFx> bypassFlags_ {}; - std::atomic monitor_ { false }, channelMute_ { false }, masterMute_ { false }; + std::atomic monitor_ { false }, channelMute_ { false }, masterMute_ { false }, dryTest_ { false }; std::atomic masterGain_ { 1.f }, channelGain_ { 1.f }; - std::atomic inputPeak_ { 0.f }, outputPeak_ { 0.f }; + std::atomic inputPeak_ { 0.f }, postFxPeak_ { 0.f }, outputPeak_ { 0.f }; + std::atomic callbackInputs_ { 0 }, callbackOutputs_ { 0 }; + std::atomic callbackCount_ { 0 }; std::atomic totalLatency_ { 0 }; void detach() @@ -247,6 +263,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } totalLatency_.store (latency); inputPeak_.store (0.f); + postFxPeak_.store (0.f); outputPeak_.store (0.f); } @@ -260,12 +277,16 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback const float* const* inputs, int inputChannels, float* const* outputs, int outputChannels, int samples, const juce::AudioIODeviceCallbackContext&) override { + callbackInputs_.store (inputChannels, std::memory_order_relaxed); + callbackOutputs_.store (outputChannels, std::memory_order_relaxed); + callbackCount_.fetch_add (1, std::memory_order_relaxed); const bool enabled = monitor_.load (std::memory_order_relaxed); + const bool dry = dryTest_.load (std::memory_order_relaxed); const bool muted = channelMute_.load (std::memory_order_relaxed) || masterMute_.load (std::memory_order_relaxed); const float gain = masterGain_.load (std::memory_order_relaxed) * channelGain_.load (std::memory_order_relaxed); - float inPeak = 0.f, outPeak = 0.f; + float inPeak = 0.f, postFxPeak = 0.f, outPeak = 0.f; for (int offset = 0; offset < samples; offset += maxFrames) { const int frames = juce::jmin (maxFrames, samples - offset); @@ -284,12 +305,21 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } // MIDI capacity is empty unless the plugin itself changes it. juce::MidiBuffer midi; - for (int fx = 0; fx < count_; ++fx) + if (!dry) { - auto& slot = slots_[fx]; - if (slot.processor && ! bypassFlags_[fx].load (std::memory_order_relaxed)) - slot.processor->processBlock (scratch_, midi); - midi.clear(); + for (int fx = 0; fx < count_; ++fx) + { + auto& slot = slots_[fx]; + if (slot.processor && ! bypassFlags_[fx].load (std::memory_order_relaxed)) + slot.processor->processBlock (scratch_, midi); + midi.clear(); + } + } + for (int ch = 0; ch < 2; ++ch) + { + const float* processed = scratch_.getReadPointer (ch); + for (int i = 0; i < frames; ++i) + postFxPeak = juce::jmax (postFxPeak, std::abs (processed[i])); } for (int c = 0; c < outputChannels; ++c) { @@ -305,6 +335,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } } inputPeak_.store (juce::jmin (1.f, inPeak), std::memory_order_relaxed); + postFxPeak_.store (juce::jmin (1.f, postFxPeak), std::memory_order_relaxed); outputPeak_.store (juce::jmin (1.f, outPeak), std::memory_order_relaxed); } }; diff --git a/src/Main.cpp b/src/Main.cpp index da3f35dd7..9906f81e2 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -31,6 +31,8 @@ std::optional assetFor (const juce::String& { data = BinaryData::app_js; size = BinaryData::app_jsSize; mime = "text/javascript"; } else if (path == "/bridge.js") { data = BinaryData::bridge_js; size = BinaryData::bridge_jsSize; mime = "text/javascript"; } + else if (path == "/monitor.js") + { data = BinaryData::monitor_js; size = BinaryData::monitor_jsSize; mime = "text/javascript"; } else return std::nullopt; juce::WebBrowserComponent::Resource resource; diff --git a/web/index.html b/web/index.html index 007e3d220..4c99da086 100644 --- a/web/index.html +++ b/web/index.html @@ -35,5 +35,5 @@
UI STUDY · Audio engine disconnected · Simulated metersDrag faders & knobs • Click FX insert to open plugin browser • Ctrl+S saves sessionAR MIX v0.3 | FX HOST UI PROTOTYPE
- + diff --git a/web/monitor.js b/web/monitor.js new file mode 100644 index 000000000..0f0e1eeeb --- /dev/null +++ b/web/monitor.js @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Native output diagnostics: JS control only, never audio callback work. +(() => { + const api = window.__JUCE__?.backend; + if (!api?.emitEvent || !api?.addEventListener) return; + let state = {}; + const css = document.createElement("style"); + css.textContent = "#arSignalOverlay{display:none;position:fixed;inset:0;z-index:990;background:#020a10d9;align-items:center;justify-content:center}" + + "#arSignalOverlay.open{display:flex}.arSignalPanel{width:min(710px,93vw);padding:16px;background:linear-gradient(#263d4b,#10212c 80%);border:1px solid #6a92a5;border-radius:9px;color:#d9eaf3;box-shadow:0 15px 55px #000c}" + + ".arSignalHeader{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}.arSignalHeader h2{font-size:18px;font-weight:500;margin:0}" + + ".arSignalGrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px}.arSignalStage{padding:10px;background:#0d202b;border:1px solid #365565;border-radius:6px;min-width:0}" + + ".arSignalStage small{display:block;color:#80d4e8;font-size:10px}.arSignalStage b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;font-size:11px;margin:10px 0}" + + ".arSignalMeter{background:#041019;height:9px;border:1px solid #37576a;border-radius:4px;overflow:hidden}.arSignalMeter i{display:block;width:1%;height:100%;background:linear-gradient(90deg,#14bbaa,#b6d851,#edac38)}" + + "#arSignalReason{font-size:12px;line-height:1.6;padding:12px;background:#1c3645;border:1px solid #4d7284;border-radius:5px;margin:13px 0}" + + ".arSignalActions{display:flex;flex-wrap:wrap;gap:8px}.arSignalActions button,.arSignalHeader button{color:#e0f5ff;padding:8px 12px;border:1px solid #57849a;border-radius:4px;background:linear-gradient(#395b70,#143447);cursor:pointer}" + + "#arSignalFooter{margin-top:12px;font-size:11px;color:#9bbbbf;line-height:1.6}#arSignalBadge{color:#edbf7d;font-size:10px;margin-left:6px;white-space:nowrap}" + + "#arSignalOpen{padding:4px 7px;font-size:10px}"; + document.head.appendChild(css); + const footer = document.querySelector("#nativeP2"); + if (footer) footer.insertAdjacentHTML("beforeend", + 'OUTPUT DISARMED'); + const overlay = document.createElement("div"); + overlay.id = "arSignalOverlay"; + overlay.innerHTML = ''; + document.body.appendChild(overlay); + const el = id => document.getElementById(id); + const percent = v => Math.max(1,Math.min(100,(20*Math.log10(Math.max(1e-6,Number(v)||0))+60)*100/60)); + function diagnosis(d) { + if (d.error) return "Audio driver error: "+d.error; + if (!d.connected) return "No audio device connected. Open AUDIO SETUP."; + if (!d.deviceOutputChannels) return "No active output channels. Select a headphone/speaker output in AUDIO SETUP."; + if (!d.monitor) return "OUTPUT DISARMED: the engine intentionally writes silence until ENABLE OUTPUT is clicked. This prevents microphone feedback."; + if (d.masterMute) return "MASTER MUTED: switch off the master MUTE button."; + if (d.channelMute) return "CHANNEL 1 MUTED: switch off Lead Vocal MUTE."; + if ((d.inputPeak||0)>.006 && (d.postFxPeak||0)<.0002) return "Mic input is detected but VST3 output is silent. Enable DRY TEST to bypass all plugins."; + if ((d.postFxPeak||0)>.003 && (d.peak||0)<.0002) return "Post-FX audio exists, but hardware output is silent. Check faders, mutes and output settings."; + if ((d.peak||0)>.003) return "Samples reach the output buffer. If you cannot hear them, check your interface mixer, physical output selection and headphone volume."; + if ((d.inputPeak||0)<.0005) return "Microphone signal is low/absent. Check the selected ASIO/WASAPI input and gain."; + return "Output armed. Speak into the microphone and inspect all three meters."; + } + function repaint(d) { + el("arSignalBadge").textContent = !d.monitor ? "OUTPUT MUTED" : d.masterMute ? "MASTER MUTED" : d.channelMute ? "CH1 MUTED" : "OUTPUT ARMED"; + el("arSignalBadge").style.color = d.monitor && !d.masterMute && !d.channelMute ? "#71e9cc" : "#e9be7c"; + const monitorButton=document.querySelector('[data-native-action="monitor"]'); + if (monitorButton) monitorButton.textContent=d.monitor?"DISARM OUTPUT":"ENABLE OUTPUT"; + // The original UI shell had fixed 48 kHz / 64-sample demo badges. Show + // the REAL negotiated driver parameters instead of misleading the user. + const rateLabel=document.querySelector('.spec:not(.spec-device):not(.bpm) strong'); + if(rateLabel)rateLabel.textContent=d.rate?String(Math.round(d.rate/1000)):"—"; + const bufferLabel=document.querySelector('.spec.bpm strong'); + if(bufferLabel)bufferLabel.textContent=d.buffer?String(d.buffer):"—"; + const driverLabel=document.querySelector('.spec-device strong'); + if(driverLabel)driverLabel.textContent=d.driver||"NO DRIVER"; + const liveLabel=document.querySelector('.status > span:first-child > b'); + if(liveLabel)liveLabel.textContent="NATIVE CH1"; + const edition=document.querySelector('.status > span:last-child'); + if(edition)edition.textContent="AR MIX P2 · CH1 NATIVE + UI PREVIEW"; + if (!overlay.classList.contains("open")) return; + el("arInputName").textContent=d.inputDevice||"Input device"; + el("arFxName").textContent=d.dryTest?"DRY BYPASS":"VST3 Chain"; + el("arOutputName").textContent=d.outputDevice||"Output device"; + el("arInputBar").style.width=percent(d.inputPeak)+"%"; + el("arFxBar").style.width=percent(d.postFxPeak)+"%"; + el("arOutputBar").style.width=percent(d.peak)+"%"; + el("arSignalReason").textContent=diagnosis(d); + el("arSignalMonitor").textContent=d.monitor?"DISARM OUTPUT":"ENABLE OUTPUT"; + el("arSignalDry").textContent=d.dryTest?"DRY TEST ON":"DRY TEST OFF"; + el("arSignalFooter").textContent=(d.driver||"Audio")+" · "+(d.rate||0)+" Hz / "+(d.buffer||0)+ + " samples · "+(d.deviceInputChannels||0)+" active input / "+(d.deviceOutputChannels||0)+" active output channels · "+ + (d.latencySamples||0)+" samples plugin latency. Choose hardware output using AUDIO SETUP; Main L/R and Streaming are UI previews."; + } + api.addEventListener("arMixStatus",d=>{state=d;repaint(d);}); + el("arSignalOpen")?.addEventListener("click",()=>{overlay.classList.add("open");repaint(state);}); + el("arSignalClose").addEventListener("click",()=>overlay.classList.remove("open")); + el("arSignalMonitor").addEventListener("click",()=>api.emitEvent("arMixAction",{action:"monitor",value:!state.monitor})); + el("arSignalDry").addEventListener("click",()=>api.emitEvent("arMixAction",{action:"dryTest",value:!state.dryTest})); + el("arSignalSetup").addEventListener("click",()=>{ + overlay.classList.remove("open"); + document.querySelector('[data-native-action="audioSetup"]')?.click(); + }); + overlay.addEventListener("click",e=>{if(e.target===overlay)overlay.classList.remove("open");}); + document.addEventListener("click",e=>{ + if(!e.target.closest("[data-output],#monitorSource"))return; + e.preventDefault();e.stopImmediatePropagation(); + overlay.classList.add("open");repaint(state); + },true); +})();