feat(audio): stereo mic capture on Windows & macOS desktop clients
Both desktop mics were hard-mono: the core defaults capture_channels=1 and neither client ever called vc_set_capture_channels (only iOS did). Add a persisted "Stereo microphone" toggle to each client's Audio settings, applied when the mic stream starts and live via vc_set_capture_channels + vc_audio_restart. Expose both ABI calls in the Windows interop; the macOS wrapper already had them. Core fix: encode_and_send_frame now folds a stereo mic frame to mono on a mono channel - previously the channels==2 branch encoded interleaved L/R directly even on a mono channel, feeding a mono opus_encode 2x its samples (wrong pitch/garbage). Real stereo still only reaches the wire on a stereo channel; on a mono channel the mic is cleanly downmixed. Test: test_stereo_mic_mono_channel. ctest --preset dev green (28/28). Docs: voice.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -224,9 +224,20 @@ Each receiver keeps an **adaptive jitter buffer per ssrc** with **bounded-depth
|
||||
- Capture and playback run on miniaudio's real-time callbacks (WASAPI / CoreAudio / ALSA).
|
||||
Playback is genuinely stereo end-to-end. **Mic capture** is mono by default; **stereo mic
|
||||
capture** is supported via `vc_set_capture_channels(stream_id, 2)` — when enabled, the
|
||||
capture device opens in stereo (interleaved L/R) and the encoder receives real stereo PCM
|
||||
(no upmix). A mono mic frame on a stereo channel is upmixed L=R before encoding so the Opus
|
||||
bitstream is still spec-correct stereo. **Screen-audio (`SCREEN_AUDIO`) loopback** captures
|
||||
capture device opens in stereo (interleaved L/R). All native clients expose this as a
|
||||
per-user toggle (iOS in Settings; the Windows and macOS desktop clients via a "Stereo
|
||||
microphone" checkbox in Audio settings — a live toggle there restarts the capture device via
|
||||
`vc_audio_restart` so it takes effect immediately). Whether stereo actually reaches the wire
|
||||
depends on the **channel's** Opus mode, which decides the encoder's channel count — the mic's
|
||||
channel count and the channel's mode are independent knobs:
|
||||
- **stereo mic + stereo channel** → real interleaved L/R is encoded directly (no upmix).
|
||||
- **mono mic + stereo channel** → the mono frame is upmixed L=R so the Opus bitstream is
|
||||
still spec-correct stereo.
|
||||
- **stereo mic + mono channel** → the interleaved L/R is folded to mono before the mono
|
||||
encoder. (Handing interleaved pairs straight to a mono `opus_encode` would make it read 2×
|
||||
the samples it should — wrong pitch / garbage — so the fold keeps the toggle safe on any
|
||||
channel.)
|
||||
**Screen-audio (`SCREEN_AUDIO`) loopback** captures
|
||||
in the channel's mode — stereo when the channel is stereo (real interleaved L/R, no
|
||||
downmix), mono when the channel is mono — so a stereo music/screen-share channel gets
|
||||
genuine stereo end-to-end. See §9 for the platform-specific loopback mechanism.
|
||||
|
||||
Reference in New Issue
Block a user