feat(audio): microphone-only sync delay, on by default at 175 ms

The webcam's frames reach the compositor later than the mic's samples reach the audio
pipe, so the voice runs ahead of the lips. The existing lip-sync offset could not fix
that: it delays the WHOLE mix, which drags desktop and alert audio — neither of which
has a camera to follow — out of sync in the process.

So the delay line learned channels (mono for a source, stereo for the mix, offset always
in milliseconds so the frame count is what stays constant), and FillAndMix runs a second
line over micChunk before the mix. Slider-side: presets off / 150 / 200 in the LIP-SYNC
bay under the whole-mix control, persisted as Audio.MicSyncOffsetMs.

Default 175 ms is the creator's own number for a C920 pipeline (they asked for
+150..+200). It is a setting, not a constant, because the right figure belongs to the
camera and the machine — a faster camera wants less, no camera wants none.

Both delay lines are reconfigured every tick, so the 2026-09-12 trap still applies and is
documented at both sites: a Configure that reallocates discards the buffered voice every
10 ms.

673 pass, 0 warnings. Ear check pending: this is an audio change.
This commit is contained in:
2026-11-12 11:15:50 -08:00
parent f6fdab3bf2
commit 7f89534309
9 changed files with 135 additions and 13 deletions
+9
View File
@@ -290,6 +290,15 @@ devices, no timers).
(a one-time status dot next to it was removed 2026-09-23 per creator feedback — the slider +
numeric tooltip carry the state). Changing the delay flushes the line (a live change clicks
rather than smears).
- **Microphone-only delay (2026-11-12):** a camera's frames reach the compositor later than the mic's
samples reach the pipe, so the voice runs ahead of the lips. `AudioSyncDelay` now takes a channel
count, and `FillAndMix` runs a second line (**mono**) over `micChunk` *before* the mix — loopback and
alert audio are not tied to a camera frame and must not move with it. Seam: `Func<int> micSyncOffsetMs`
(VM `MicSyncOffsetMs`, **0..500 ms**, persisted `Audio.MicSyncOffsetMs`, shipped default **175** —
the creator's own C920 measurement, not a constant: the right number belongs to the machine).
Presets `off / 150 / 200` sit in the LIP-SYNC bay under the whole-mix slider. Both lines are
reconfigured every tick, so both carry the 2026-09-12 warning: a `Configure` that reallocates
discards the buffered audio every 10 ms.
- **TRAX — free background music (TASK 8):** `MusicPlayer` = NAudio `MediaFoundationReader`
(mp3/wav/m4a) → `VolumeWaveProvider16` at the hardcoded **0.20** bed (no slider) → `WaveOutEvent` on
the default device, **looping on any clean natural end** (`PlaybackStopped` with `e.Exception == null`