Skip to content

P0 realtime audio: zero-copy healthy WASAPI capture + bounded discontinuity de-click - #251

Closed
masarray wants to merge 3 commits into
mainfrom
fix/p0-wasapi-capture-click-guard-20261031
Closed

masarray wants to merge 3 commits into
mainfrom
fix/p0-wasapi-capture-click-guard-20261031

Conversation

@masarray

@masarray masarray commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Updated acceptance after risk audit (2026-10-31)

Production default is now OFF. The earlier proposal automatically repaired heuristic zero-head PCM, which could also be legitimate digital silence. That is not safe to enable indiscriminately. Latest commit adds SIGNAL CHECK CAPTURE DE-CLICK: OFF / ON (BETA), explicit control only while MAIN output is muted on verified DIRECT Windows Audio, disables on device restart/epoch, no Show persistence, and clear A/B diagnostic counters. ASIO, independent-clock, isolated diagnostic paths and untouched healthy PCM remain unchanged. This is a field A/B candidate, not a certified crackle fix. Native path stays one callback; no rearm/mute bypass. See docs/P0_WASAPI_CAPTURE_DECLICK_EXPERIMENT_20261031.md.

Fix based on physical 0-FX evidence

User heard crackle on WASAPI shared VB-Cable capture → Maono render, 48k/480 frames, 0 VST3, 113 capture discontinuity flags despite 8,126 callbacks and worst DSP 375us / 10,000us, zero over-budget host callbacks. PR #247's single-pass raw PCM continuity evidence has merged; this change uses its existing counters, no duplicate scan and no second graph.

Actual native PCM mitigation (not merely counters): only for native 2-input Windows Audio DIRECT, only when a previous PCM tail plus exact zero-filled block head is detected by the existing evidence scanner, perform a 64-frame or shorter boundary fade-out/fade-in. Conditional preallocated stereo scratch copy avoids injecting hard jumps at the silent head and restart. Malformed NaN/Inf input is sanitized on the same exceptional path before entering FX/Master. The common healthy PCM path continues untouched, zero-copy, no additional buffering or output delay. All processing is on the same existing mixer callback with no heap, I/O, locks, worker, OS calls, plugin creation, device reopen, or UI animations.

Safety: ASIO and other non-WASAPI backends untouched. For unexpected channel counts/big callback frames, bypass and preserve direct routing. No auto-unmute, clock change, graph reconfiguration, or preexisting SOURCE/AUX/M3 changes. One O(1) tail record per healthy block; exceptional copy bounded by existing 8192-frame scratch. Expose separate captureDeClickBlocks, captureDeClickFrames, captureSanitizedSamples, and explicit provenance in the diagnostic report; never call this driver xrun, clock drift correction, recovery of missing audio, or guaranteed crackle fix.

Tests: extend existing capture-boundary native CTest with exact 64-sample gap, healthy zero-copy, immutable source, legitimate full-block silence, partial channel silence, nonfinite sanitization, new generation reset, 100k healthy block soak; add JS integration contract. Reuse existing Windows CI target and avoid duplicate test target or heavy new toolchains.

Acceptance gates: exact-head Windows MSVC/CTest/package PASS, Chromium regressions, then user physical A/B comparing original and updated build at identical dry routing and playback level. Verify whether the capture-zero-head counters and actual de-click counter increase near audible marks. A persistent crackle with zero repair events requires pinned JUCE WASAPI source/clock path work, not arbitrary longer buffer. Hardware #15 stays OPEN until 30min clean 0 FX and render underrun proof.

Supersedes no product features; protects current 10CH mixer and ChannelId session from concurrent M3 work.

Coordination #397 — workstream ownership

WASAPI click mitigation remains valuable, but is parked for sole ENGINE #266 owner to reconcile before editing the same callback source.


2026-11-08 reconciliation: ARCHIVED, NOT MERGED

This was explicitly a manual opt-in WASAPI de-click A/B experiment, default OFF, not a universally safe fix. It is not being promoted or silently merged into the current native callback. Preserve investigations and device discontinuity follow-up in #15; branch remains available for a future evidence-backed scoped implementation.

Current authority: main, #418. Historical branch retained; hardware FAT not inferred.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T15:41:53.311527Z 0f36a41 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Owner Author

2026-11-01 reconciliation: EXPERIMENT / NO RELEASE. WASAPI capture de-click remains opt-in, DEFAULT OFF, and cannot be used to claim issue #15 fixed. This PR is parked pending comparable physical ASIO/WASAPI capture + speaker discontinuity data, 30-min 0FX/1FX FAT and real device epoch acceptance. No automatic heuristic repair of legitimate silence. Change to draft so it is not accidentally merged during M-U1/GUI integration.

masarray commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Coordination #397 — parked WASAPI fix pending ENGINE ownership. Your capture/discontinuity de-click work remains potentially valuable; it is not deleted or rejected. ENGINE sole callback owner #266 must compare the exact code/test differences and cherry-pick or recreate only qualified fixes into the canonical audio path. No parallel edits to src/LiveAudioEngine.h or src/Main.cpp while #266 producer is active.

masarray commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

ENGINE coordination: sole production engine owner remains #266. Your WASAPI fix PR #251 should be selectively reconciled by the ENGINE owner from latest main, with native clock/capture A/B tests. Avoid parallel edits to LiveAudioEngine/driver or assuming the physical #15 crackle is solved without 0FX hardware FAT. Shared ownership plan at #397.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant