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
6 changes: 3 additions & 3 deletions .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
@@ -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, fix/p2-native-output-monitor-diagnostics ]
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, fix/p2-realtime-glitch-telemetry-latest-gui ]
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -51,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-Output-Diagnostic.exe"
Copy-Item $exe.FullName "dist/ArSonMix-Realtime-Diagnostics.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-Output-Diagnostic-Windows-x64
name: ArSonMix-RealTime-Diagnostics-Windows-x64
path: dist/
if-no-files-found: error
retention-days: 14
2 changes: 1 addition & 1 deletion 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/PluginCatalog.h)
target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h)
target_compile_definitions(ARMixConsole PRIVATE
JUCE_WEB_BROWSER=1
JUCE_USE_WIN_WEBVIEW2=1
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ All remaining UI preview channels and factory vocal presets are still visual; do
## P2 DAW UX improvement

Use MIX → Channel 1 ADD FX to select a real indexed VST3; PLUGINS opens Plugin Manager for scan/import only. Audio Setup now reports loading status and reuses the native selector window. Scan uses real candidate counters and indeterminate discovery stage. See [P2 DAW workflow guide](docs/P2_DAW_WORKFLOW.md).

## P2.2 Realtime Reliability + latest ArSonMix GUI

- The live signal is routed automatically on a valid JUCE device; no extra enable gate. Emergency output mute stays in SIGNAL CHECK.
- Real-time health counters: callback processing time, worst processing time, callbacks over 80% or 100% of buffer period, timing gaps, and worst VST3 processing time.
- Persistent bounded rotating log in user app data `AR-MIX-Studio/diagnostics/audio-diagnostics.log`, using a dedicated logger worker (never audio callback).
- Device XML saved upon device change, **not** on a repeating 3-second UI timer.
- Uses current `fix/fader-thumb-symmetry-polish` GUI (ArSonMix, metal controls, horizontal PAN sliders). Audio host code stays isolated.
- Press SIGNAL CHECK → OPEN DIAGNOSTIC LOG to inspect or share diagnostic evidence after reproducing audio stutter.
- Read [P2.2 reliability guide](docs/P2_REALTIME_RELIABILITY.md).
43 changes: 43 additions & 0 deletions docs/P2_REALTIME_RELIABILITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# ArSonMix P2.2 — Investigating recurring audio dropouts

**Status:** Experimental Windows diagnostic build. Performance counters are evidence, not a concluded root cause.

## Current evidence from the user's PC
- VST3 host produces audio when output is enabled, thus at least one valid input→VST→master→Windows Audio output path exists.
- Displayed device: Windows Audio, 48 kHz, 480-sample buffer = 10 ms nominal buffer period.
- The VST3 chain advertised 960 samples processing latency = 20 ms at 48 kHz. This is plugin latency **not** measured system round-trip latency.
- Reported audio pauses every few seconds. Source inspection found an old 3-second synchronous device XML state poll on the message thread. That was unnecessary and is now removed, but it is a candidate cause, **not a proven diagnosis**.
- Other candidates include WASAPI scheduling irregularity, slow VST3 processBlock, input/output endpoint contention, and device stop/restart events.

## Implemented changes
1. **Auto-routing:** with a valid duplex device selected, the output is active without an extra arm button. A user-accessible emergency MUTE OUTPUT in SIGNAL CHECK remains available; use headphones at low volume to prevent feedback.
2. **Event-driven settings:** AudioDeviceManager ChangeListener marks device XML dirty. It is no longer repeatedly serialized and written on a 36-tick / 3-second timer.
3. **Realtime measurements:** atomic counters are updated inside the audio callback, with no file I/O, locks, heap allocations in host callback logic, or GUI calls. Measures callback duration, worst duration, processing beyond 80% of available callback period, over-budget callbacks, long callback scheduling gaps and slow plugin time.
4. **Background diagnostics:** a bounded 128-record SPSC UI→worker queue writes 1 Hz health snapshots and event markers to a rotating 2 MB log (plus previous). The plugin/audio callback only publishes numeric counters, not file records.
5. **Visual diagnostics:** SIGNAL CHECK shows live input/post-FX/output meters plus deadline timing; OPEN DIAGNOSTIC LOG reveals the local file.
6. **Current GUI:** imported current source (ArSonMix brand, metallic faders, horizontal PAN slider, tactile buttons) from GUI branch `fix/fader-thumb-symmetry-polish`. Maintains working native VST3 plugin picker/catalog.
7. **Live FX structural operations:** add/remove/reorder may still briefly detach callbacks. Do not perform them during a performance until graph hot swap is engineered.

## Reproduction / engineering triage

1. Choose the same selected input and headphone output. Start with 48 kHz / 480 samples to reproduce reported problem, keep output/headphone volume low.
2. In SIGNAL CHECK, note worst callback duration, over-budget count, callback-gap count and plugin time. Keep recording for at least 2–3 minutes through the intermittent symptom.
3. First test with **DRY TEST ON** (all VST3 skipped, same audio device). Observe and record if dropout remains. Then turn DRY TEST OFF and test each plugin in isolation.
4. Try ASIO on one full-duplex interface, initially 128–256 samples if supported; separately compare Windows Audio/WASAPI. Driver and endpoint selection must be changed through Audio Setup.
5. Use OPEN DIAGNOSTIC LOG. Copy the latest log around the timestamps of audible stutters, with device and plugin names sanitized if sharing publicly.
6. Interpret cautiously:
- Slow callback/over-budget jumps near a dropout suggest a DSP deadline miss (plugin processing or callback).
- Slow plugin increments suggest one or more VST3 calls are consuming most of the deadline. This release logs each VST3 slot's last and worst processing time to help identify a slow insert. Compare slot timings and use DRY TEST to confirm causality.
- A callback scheduling gap jump with low process time suggests driver/OS scheduling or device discontinuity.
- Flat counters despite audible loss suggest an endpoint, physical device, external virtual cable, or a discontinuity not captured by this timing probe.
7. Success criterion: sustained uninterrupted mic→dry→master output and then mic→VST3→master output; no observed dropout on the actual physical interface.

## Engineering limits / follow-up
- These are **timing indicators, not driver-confirmed xrun counts**. Device-specific ASIO/WASAPI dropout callback telemetry is still missing.
- Third-party VST3 plugin code may allocate or block; the host cannot enforce its RT safety.
- No complete plugin crash sandbox or seamless FX graph swap yet.
- Real output to streaming apps is separate from the output endpoint in the JUCE device selector. UI “Record/Streaming” output buttons remain previews until real routing is implemented.
- The log may contain local device/plugin names; treat it as diagnostic user data.

## Additional telemetry
Audio-device start and stop callback counts are recorded, together with per-VST3 slot last/worst process duration (microseconds). A rise in device stop/start around stutters indicates a device lifecycle event; a rise in one slot's processing duration indicates a potentially expensive effect. Time counters alone do not prove that a device underrun occurred.
95 changes: 95 additions & 0 deletions src/DiagnosticsRecorder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <juce_core/juce_core.h>
#include <array>
#include <atomic>
#include <cstring>

// Bounded UI-thread -> file-thread telemetry queue (SPSC).
// Audio callback NEVER interacts with this class. The UI samples atomics
// at 1 Hz and enqueues a compact record; file I/O occurs only on worker.
class DiagnosticsRecorder final : private juce::Thread
{
public:
explicit DiagnosticsRecorder (const juce::File& directory)
: juce::Thread ("AR MIX Diagnostic Writer"),
folder_ (directory), logfile_ (directory.getChildFile ("audio-diagnostics.log"))
{
folder_.createDirectory();
startThread();
record ("SESSION", "started");
}

~DiagnosticsRecorder() override
{
record ("SESSION", "closing");
signalThreadShouldExit();
notify();
stopThread (5000);
}

// Producer: JUCE message thread only; may allocate, never RT.
void record (const juce::String& kind, const juce::String& details)
{
const auto head = producer_.load (std::memory_order_relaxed);
const auto next = (head + 1) % capacity;
if (next == consumer_.load (std::memory_order_acquire))
{
lost_.fetch_add (1, std::memory_order_relaxed);
return;
}
const auto timestamp = juce::Time::getCurrentTime().toISO8601 (true);
juce::String message = timestamp + " | " + kind + " | " +
details.replaceCharacters ("\r\n", " ");
const auto utf8 = message.toRawUTF8();
auto& slot = queue_[head];
const auto count = juce::jmin (static_cast<size_t> (sizeof (slot.data) - 1),
std::strlen (utf8));
std::memcpy (slot.data, utf8, count);
slot.data[count] = 0;
producer_.store (next, std::memory_order_release);
notify();
}

juce::File getLogFile() const { return logfile_; }
std::uint64_t lostRecords() const noexcept { return lost_.load(); }

private:
static constexpr unsigned capacity = 128;
struct Record { char data[512] {}; };
std::array<Record,capacity> queue_ {};
std::atomic<unsigned> producer_ { 0 }, consumer_ { 0 };
std::atomic<std::uint64_t> lost_ { 0 };
juce::File folder_, logfile_;

void run() override
{
// One write per drain batch, never from the UI or audio callback.
for (;;)
{
juce::String batch;
unsigned tail = consumer_.load (std::memory_order_relaxed);
const auto head = producer_.load (std::memory_order_acquire);
while (tail != head)
{
batch += juce::String::fromUTF8 (queue_[tail].data);
batch += "\n";
tail = (tail + 1) % capacity;
}
consumer_.store (tail, std::memory_order_release);
if (batch.isNotEmpty())
{
if (logfile_.getSize() > 2 * 1024 * 1024)
{
auto rotated = folder_.getChildFile ("audio-diagnostics.previous.log");
rotated.deleteFile();
logfile_.moveFileTo (rotated);
}
logfile_.appendText (batch, false, false, "\n");
}
if (threadShouldExit() && tail == producer_.load (std::memory_order_acquire))
break;
wait (350);
}
}
};
Loading
Loading