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
+17
View File
@@ -117,6 +117,23 @@ public partial class LayoutStore : IDisposable
return int.TryParse(value, out var ms) ? Math.Clamp(ms, -500, 500) : 0;
}
/// <summary>The shipped default for the microphone-only delay. The creator's measurement for a
/// C920 pipeline (asked for +150..+200 ms); a camera with less latency wants less.</summary>
public const int DefaultMicSyncOffsetMs = 175;
/// <summary>Microphone-only sync delay (0..500 ms), so the voice can wait for the camera's picture
/// without moving desktop or alert audio. Absent means the shipped default.</summary>
public int LoadMicSyncOffsetMs()
{
var value = GetSetting("Audio.MicSyncOffsetMs");
return int.TryParse(value, out var ms)
? Math.Clamp(ms, 0, 500)
: DefaultMicSyncOffsetMs;
}
public void SaveMicSyncOffsetMs(int ms)
=> UpsertSetting("Audio.MicSyncOffsetMs", Math.Clamp(ms, 0, 500).ToString());
public void SaveAudioSyncOffsetMs(int ms)
{
UpsertSetting("Audio.SyncOffsetMs", Math.Clamp(ms, -500, 500).ToString());