Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fa3d72d
fix(win10): make VB-CABLE opt-in so first launch never silently insta…
masarray Nov 20, 2026
932f3df
test(win10): explicit optional-driver install and safe direct launch …
masarray Nov 20, 2026
a0b71b9
fix(win10): default all MSVC/JUCE libraries to matching static CRT fo…
masarray Nov 20, 2026
ed42dcd
feat(audio-setup): expose native driver input/output and DSP latency …
masarray Nov 20, 2026
7f95c2d
feat(audio-setup): compact native driver IN/OUT/FX latency and buffer…
masarray Nov 20, 2026
bed2a98
fix(win10): actionable native WebView2 recovery dialog before any aud…
masarray Nov 20, 2026
44a2269
test(win10): static CRT, optional driver and actionable WebView2 reco…
masarray Nov 20, 2026
21054d0
test(audio-setup): exact native latency math and fail-closed unavaila…
masarray Nov 20, 2026
5fe84a3
test(win10): verify actual packaged PE has no VC++ runtime DLL imports
masarray Nov 20, 2026
824e759
ci(win10): reject actual installer PE if dynamic VC++ CRT imports remain
masarray Nov 20, 2026
d233845
test(win10): require binary dependency proof, not just source flags
masarray Nov 20, 2026
44c39b9
fix(win10): persist actionable early startup error without touching a…
masarray Nov 20, 2026
c1aa28f
fix(win10): preserve actual newline and filesystem path escapes in ea…
masarray Nov 20, 2026
46b922c
build(gui): synchronize generated standalone audio setup latency with…
masarray Nov 20, 2026
e8e8e76
feat(audio-setup): one approved MVVM driver-reported latency projecti…
masarray Nov 20, 2026
8236cc0
feat(audio-setup): display latency in the one approved native Audio I…
masarray Nov 20, 2026
3dd1bc9
test(audio-setup): approved device VM/bridge native latency truth, un…
masarray Nov 20, 2026
bd13180
fix(win10): allow slow first-use WebView2 cold initialization without…
masarray Nov 20, 2026
269a870
test(audio-setup): extract complete nested latency model instead of t…
masarray Nov 20, 2026
e6d72a1
fix(P0): qualify installed startup and measure wired ASIO round-trip
masarray Nov 20, 2026
3bb29f7
test: keep crackle evidence contract in sync with shared health sample
masarray Nov 20, 2026
86142de
test: exercise wired calibration in the approved Audio I/O cold-start…
masarray Nov 20, 2026
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ if(ARMIX_SONKU_EXPERIMENTAL_P99_VOCAL_DEPTH AND
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# P0 Windows 10 fresh-install portability: the compiler's default /MD
# silently requires a machine-wide Microsoft VC++ Redistributable which is
# present on CI runners but NOT guaranteed on end-user Windows 10 PCs.
# Choose one matching static CRT across BOTH JUCE static libraries and the
# native mixer, before JUCE targets are created. Explicit downstream
# toolchain selection remains respected. Does NOT replace WebView2 Runtime.
if (MSVC AND WIN32 AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if (NOT DEFINED JUCE_ROOT)
message(FATAL_ERROR "Pass -DJUCE_ROOT=C:/path/to/JUCE (8.0.15+ required)")
Expand Down Expand Up @@ -1300,6 +1309,9 @@ if(BUILD_TESTING)
target_compile_features(ARMixProductionRenderAuditTests PRIVATE cxx_std_20)
add_test(NAME M3ActualProductionRenderPathAndFailSilentCounters COMMAND ARMixProductionRenderAuditTests)
add_dependencies(ARMixMixerRoutingTests ARMixApprovedRoutingPcmTests)
add_executable(ARMixPhysicalLoopbackTests tests/physical_loopback_test.cpp)
add_test(NAME physical_loopback_cpp COMMAND ARMixPhysicalLoopbackTests)

add_executable(ARMixLatencyCompensationTests tests/dynamic_latency_compensation_test.cpp)
target_compile_features(ARMixLatencyCompensationTests PRIVATE cxx_std_20)
add_test(NAME NativeGraphLatencyAlignedFanInAndHardwarePCM COMMAND ARMixLatencyCompensationTests)
Expand Down
44 changes: 44 additions & 0 deletions docs/INT1B_AUDIO_RELIABILITY_PROFILING_20261120.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# INT-1B — real audio-reliability evidence, no speculative DSP refactor

**Repository:** [ArSonMix](https://github.com/masarray/arsonmix) · parent [INT-1 #837](https://github.com/masarray/arsonmix/issues/837)
**Scope:** existing single-primary-ASIO native PCM/VST3 graph and approved `/preview/`. No multi-device ASIO, graphical overhaul, changed buffer or auto-tuned audio driver.

## What actually changed

1. The existing `LiveAudioEngine::status()` publishes the 13 already-accumulated `RealtimeHealthHistogram` bucket counts, with exact provenance. The audio callback keeps precisely its existing relaxed-atomic histogram update; **no allocations, locks, new timers, IO, COM, driver opens or new render graph**.
2. The existing 1 Hz `AUDIO_HEALTH` log now writes a compact, versioned **parseable JSON subset** of the status already fetched by the message thread. The earlier full status can include long FX/device arrays and exceed the 4096-byte async queue entry. The small health record avoids silent JSON truncation without reducing the original interactive SIGNAL CHECK / COPY FULL REPORT data. The log itself stays on the existing asynchronous worker, is local/private and rotates at 2 MB.
3. `scripts/audio_reliability_profile.mjs` compares **changes between consecutive 1 Hz histogram snapshots**. It outputs per-window p95/p99 **callback deadline bucket ceilings**, over-budget per 1,000 callbacks, late scheduling indicators and device-generation changes. It splits samples whenever a device/route/driver/rate/buffer/mode changes, counters reset, the callback disconnects or the recording has a gap over 5 s. It refuses a DRY/FX comparison when hardware parameters differ. Raw buckets permit real *interval* percentiles rather than a stale lifetime average.
4. Portable regression contracts cover malformed/truncated/legacy records, true 13-bucket delta percentiles, >100% deadline, **actual accepted insert/rack/global bypass classification**, matching dry vs FX, device epoch changes, counter resets and unknown hardware XRUN status. Expensive CI is only required once for the final native candidate, not for each test change.

## Operator procedure — collect once on an exact Windows build

Use the new INT-1B installer/portable **only when an exact-SHA Windows FAT artifact exists**. Save your existing `.smix` first. ASIO interface and physical output remain chosen explicitly by you. Start at low headphone volume, never auto-arm speakers.

1. In the approved native application, open **SIGNAL CHECK**, verify driver, exact input/output pins, rate and buffer. Keep the same ASIO device (for example, 48 kHz / 256 frames) and an accepted CH→MAIN routing.
2. Use the **native GLOBAL FX POWER/BYPASS control** (wait for exact accepted ACK/readback) to bypass all FX for at least **2 minutes**, without a route/device change. The old `dryTest` flag is only UI intent and is **not reliable evidence** that the accepted ChannelId DSP is bypassed. Keep the audio signal continuous. `AUDIO_HEALTH` snapshots are collected automatically at the existing 1 Hz rate without any extra GUI telemetry activity.
3. Enable GLOBAL FX POWER and verify at least one installed native FX insert is **actually processing** (accepted rack/slot/global bypass readback). Keep **identical** driver/device/rate/buffer and monitor level, and record at least **2 minutes**. Mark any audible crackle using **MARK CRACKLE**. Do not conflate manual silence with a dropout.
4. In SIGNAL CHECK choose **OPEN DIAGNOSTIC LOG**. The local `audio-diagnostics.log` contains records. It is **not uploaded** by ArSonMix. On a development machine with Node 20+ and the ArSonMix source, run:

```powershell
node scripts/audio_reliability_profile.mjs "C:\path\to\audio-diagnostics.log" --json int1b-profile.json --markdown int1b-profile.md
```

5. Review private device names or FX details before sharing the Markdown/JSON evidence. If the log rotated, analyze each part separately and compare equivalent driver/rate/buffer conditions. Only a single window with >=30 seconds and accepted physical routing is considered minimally comparable; **120 s per mode recommended** for reliability evidence. Never claim long-run stability from 30 seconds.

## How to interpret accurately

- **p95/p99** are *upper limits of coarse callback-processing deadline buckets* based on cumulative-count **deltas**, not exact processing-time percentiles or OS CPU percentage. The >100% bucket remains explicitly unknown/unbounded.
- **Over-budget** means measured callback processing time exceeded its actual block-period budget. **Late callback / gap** refers to START-to-START cadence relative to the *previous* variable JUCE quantum. Both are **indicators**, not proof of an actual render-underrun.
- `backendXrunMeaning=WASAPI_CAPTURE_DISCONTINUITIES_ONLY` is specifically **capture flags**, not DAC starvation. `DRIVER_DEFINED` has driver-dependent semantics. True render-hardware XRUN remains **UNAVAILABLE** through the currently pinned JUCE AudioIODevice API.
- `worstPluginUs` is a **cumulative maximum**, not necessarily measured inside the reported window. No automated causal plugin verdict based solely on that value.
- **Verified DRY vs FX:** DRY means effective accepted processing-insert count `0` across both ChannelId FX **and the original externally leased CH1 vendor/Orbit rack**, either by global/rack/slot bypass or no inserts. FX means effective processing-insert count >0, after native ACK/readback; the legacy `dryTest` flag cannot establish either. A non-auditable external lease is rejected rather than falsely labeled DRY. The DRY interval must immediately precede FX in the SAME app session with no more than 60 seconds of transition; never compare a prior launch or stale archive. Device generation, exact hexadecimal ASIO input/output pin masks, native graph revision, input/output names and channel counts must all match. A mere identical driver name is NOT sufficient. Compare p99 bucket ceiling, over-budget/1000, cadence and audible observations together. Only after an actual regression is observed should the responsible DSP/FX/device/GUI subsystem be optimized with a targeted patch and before/after proof.
- Profiling cannot measure acoustic round-trip latency, DPC/ISR or hard OS page faults; those require independent synchronized hardware/Windows tools. Existing [CrackleEvidenceWindow](../engine/diagnostics/CrackleEvidenceWindow.h) and [Windows GUI sampling](../scripts/collect_gui_perf_windows.ps1) remain separate instruments.

## Exit gates

- Windows MSVC Release + native CTest + quick source contracts at exact SHA, controlled release artifact installation/upgrade/uninstall **when a user-test binary is required**.
- Read `audio-diagnostics.log` from that exact user-installed binary; assert parseable profile counts, no log truncation and retained device/session/provenance.
- **Physical hardware FAT** (ASIO driver model, hardware, listening, glitch markers, loaded VST3 chain) must be reported PASS/FAIL/NOT RUN. Never infer physical FAT from CI.
- I/O #825/#830 and Graphic EQ #835 remain distinct experiments; no dual-ASIO UI claim.

**Measured source-workload win:** one existing native status read and 1 Hz asynchronous log write are reused, instead of adding a callback probe, UI polling timer or another audio thread. Without real hardware evidence this does not justify a numerical reduction in CPU, latency or XRUN.
5 changes: 5 additions & 0 deletions engine/core/DynamicChannelFxLeaseBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ class DynamicChannelFxLeaseBank final {
std::uint64_t revision() const noexcept{return revision_;}
std::size_t lanes() const noexcept{return rows_.size();}
ChannelId externalChannel() const noexcept{return external_.id;}
// Read-only CONTROL-plane visibility of the EXACT accepted external
// render lease. No refcount, mutation or render-side ownership change.
const ExternalLease* externalLeaseForControl() const noexcept {
return external_.valid() ? &external_ : nullptr;
}
std::size_t insertCount(ChannelId id) const noexcept {
const auto* p=find(id);return p?p->count:0;
}
Expand Down
202 changes: 202 additions & 0 deletions engine/diagnostics/PhysicalLoopback.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once

#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
#include <cstdint>
#include <utility>
#include <vector>

namespace armix::diagnostics {

struct PhysicalLoopback final {
static constexpr int chips = 383;
static constexpr int chipFrames = 8;
static constexpr int pulseFrames = chips * chipFrames;
static constexpr float amplitude = 0.025f; // -32 dBFS peak; line-level cable only

enum class State { idle, capturing, complete, cancelled };
static_assert(std::atomic<State>::is_always_lock_free);
struct Capture {
int rate = 0;
int guard = 0;
int maxDelay = 0;
std::array<float, pulseFrames> pulse {};
std::vector<float> received;
};
struct Result {
int frames = 0;
double confidence = 0;
const char* error = nullptr;
};

// CONTROL allocates and publishes once. The callback is the sole writer
// until complete/cancelled is released. No callback borrows a worker buffer.
bool start(int rate, int block, int input, int output, int inputs, int outputs,
std::uint64_t deviceEpoch)
{
if (state() != State::idle || rate < 44100 || rate > 192000 ||
block < 16 || block > 2048 || input < 0 || input >= inputs ||
output < 0 || output >= outputs || deviceEpoch == 0)
return false;
capture_.rate = rate;
capture_.guard = rate / 10;
capture_.maxDelay = rate / 2;
capture_.received.resize(static_cast<std::size_t>(
capture_.guard + capture_.maxDelay + pulseFrames));
std::uint32_t seed = 0x481b2a63;
for (int chip = 0; chip < chips; ++chip) {
seed ^= seed << 13;
seed ^= seed >> 17;
seed ^= seed << 5;
std::fill_n(capture_.pulse.data() + chip * chipFrames, chipFrames,
(seed & 1u) ? amplitude : -amplitude);
}
block_ = block;
input_ = input;
output_ = output;
inputs_ = inputs;
outputs_ = outputs;
deviceEpoch_ = deviceEpoch;
cursor_ = 0;
cancellationRequested_.store(false, std::memory_order_relaxed);
state_.store(State::capturing, std::memory_order_release);
return true;
}

State state() const noexcept { return state_.load(std::memory_order_acquire); }

void requestCancel() noexcept
{
cancellationRequested_.store(true, std::memory_order_release);
}

// Callback or serialized device lifecycle only.
void interrupted() noexcept
{
if (state() == State::capturing)
state_.store(State::cancelled, std::memory_order_release);
}

// Read before graph rendering: some drivers alias input/output buffers.
bool captureInput(const float* const* inputs, int count, int frames) noexcept
{
if (state() != State::capturing)
return false;
if (!inputs || count != inputs_ || frames != block_ || !inputs[input_]) {
interrupted();
return false;
}
const auto remaining = static_cast<int>(capture_.received.size()) - cursor_;
std::copy_n(inputs[input_], std::min(frames, remaining),
capture_.received.data() + cursor_);
return true;
}

// Only true when this block replaced physical output with the isolated
// probe. No graph/stream mutation, analysis, allocation, or audio rearm.
bool emitProbe(float* const* outputs,
int outputCount, int frames, std::uint64_t epoch, bool permitted,
const std::array<int, 2>& mainPair) noexcept
{
if (state() != State::capturing)
return false;
if (cancellationRequested_.load(std::memory_order_acquire) || !permitted ||
epoch != deviceEpoch_ || frames != block_ ||
outputCount != outputs_ || !outputs ||
!outputs[output_] || (output_ != mainPair[0] && output_ != mainPair[1])) {
interrupted();
return false;
}
const auto captured = static_cast<int>(capture_.received.size());
const int n = std::min(frames, captured - cursor_);
for (int channel = 0; channel < outputCount; ++channel)
if (auto* out = outputs[channel])
std::fill_n(out, frames, 0.0f);
const int begin = std::max(cursor_, capture_.guard);
const int end = std::min(cursor_ + n, capture_.guard + pulseFrames);
if (begin < end)
std::copy_n(capture_.pulse.data() + begin - capture_.guard, end - begin,
outputs[output_] + begin - cursor_);
cursor_ += n;
if (cursor_ == captured)
state_.store(State::complete, std::memory_order_release);
return true;
}

// CONTROL consumes only after the callback has stopped touching this capture.
Capture take()
{
Capture result = std::move(capture_);
state_.store(State::idle, std::memory_order_release);
return result;
}

// Worker only. Centered normalized correlation with a quiet pre-roll,
// clipping/invalid-sample checks, an ambiguity check and a noise margin.
static Result analyse(const Capture& capture)
{
const auto& received = capture.received;
double noiseEnergy = 0, noiseSum = 0, pulseSum = 0, pulseEnergy = 0;
for (std::size_t i = 0; i < received.size(); ++i) {
const double x = received[i];
if (!std::isfinite(x) || std::abs(x) >= 0.98)
return {0, 0, "Clipped or invalid line input. Lower the interface gain."};
if (i < static_cast<std::size_t>(capture.guard)) {
noiseEnergy += x*x;
noiseSum += x;
}
}
for (const double x : capture.pulse) {
pulseSum += x;
pulseEnergy += x*x;
}
pulseEnergy -= pulseSum*pulseSum / pulseFrames;
const double noiseVariance = std::max(0.0, noiseEnergy/capture.guard -
std::pow(noiseSum/capture.guard, 2));
std::vector<double> prefix(received.size() + 1);
std::vector<double> squares(received.size() + 1);
for (std::size_t i = 0; i < received.size(); ++i) {
const double x = received[i];
prefix[i + 1] = prefix[i] + x;
squares[i + 1] = squares[i] + x*x;
}
std::vector<double> scores(static_cast<std::size_t>(capture.maxDelay + 1));
int best = 0;
for (int offset = 0; offset <= capture.maxDelay; ++offset) {
const int begin = capture.guard + offset;
const int end = begin + pulseFrames;
const double sum = prefix[end] - prefix[begin];
const double energy = squares[end] - squares[begin] - sum*sum/pulseFrames;
if (energy < pulseFrames * std::max(0.00000004, 16*noiseVariance))
continue;
double dot = 0;
for (int chip = 0; chip < chips; ++chip) {
const int index = begin + chip * chipFrames;
dot += capture.pulse[chip * chipFrames] *
(prefix[index + chipFrames] - prefix[index]);
}
scores[offset] = std::min(1.0, std::abs(dot - pulseSum*sum/pulseFrames) /
std::sqrt(pulseEnergy*energy));
if (scores[offset] > scores[best])
best = offset;
}
const double confidence = scores[best];
if (confidence < 0.70 || best < 1 || best == capture.maxDelay)
return {0, confidence, "No reliable wired return. Check the cable, line input and noise."};
for (int offset = 0; offset <= capture.maxDelay; ++offset)
if (std::abs(offset - best) > chipFrames * 2 && scores[offset] >= confidence * 0.85)
return {0, confidence, "Multiple strong returns. Disable hardware monitoring or feedback."};
return {best, confidence, nullptr};
}

private:
std::atomic<State> state_ { State::idle };
std::atomic<bool> cancellationRequested_ { false };
Capture capture_;
std::uint64_t deviceEpoch_ = 0;
int input_ = -1, output_ = -1, inputs_ = 0, outputs_ = 0, block_ = 0, cursor_ = 0;
};
} // namespace armix::diagnostics
Loading
Loading