fix(audio): apply receive-side NR to stereo mic streams
The per-listener noise-reduction toggle (vc_set_remote_stream) did nothing on Windows/macOS/iOS. The decode loop gated the RNNoise pass on dec_channels == 1 as a proxy for "this stream is voice" (assuming stereo => screen-share). The stereo-mic capture commit broke that: a stereo mic with send-side NR off transmits stereo Opus, so the receiver decoded two channels and skipped NR entirely. gain/mute have no channel guard, which is why only NR appeared broken. Thread the stream kind through init_recv_stream into RemoteStream::is_voice (set from si.kind() == STREAM_MIC), gate receive NR on is_voice instead of channel count, and fold a stereo voice frame to mono -> denoise -> duplicate back across both channels in place (symmetric with the send-side downmix; RNNoise is mono-only). Screen-audio shares are never denoised. New test test_recv_noise_reduction drives AudioEngine and asserts a stereo voice stream's noise floor collapses with NR on (RMS 1046 -> 0.1) while a screen-audio share stays unchanged. ctest --preset dev green 29/29. Docs: voice.md section 10. Shared-core fix; clients need only a rebuild. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -237,4 +237,14 @@ if(VOICECAT_USE_VCPKG_DEPS)
|
||||
target_compile_features(test_noise_suppression PRIVATE cxx_std_20)
|
||||
target_include_directories(test_noise_suppression PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
|
||||
add_test(NAME noise_suppression COMMAND test_noise_suppression)
|
||||
|
||||
# Receive-side NR through the decode loop: a stereo VOICE stream is actually denoised
|
||||
# (regression for the stereo-mic bypass), and a screen-audio share is left untouched.
|
||||
# White-box AudioEngine test; paced realtime feed, so it needs a generous timeout.
|
||||
add_executable(test_recv_noise_reduction test_recv_noise_reduction.cpp)
|
||||
target_link_libraries(test_recv_noise_reduction PRIVATE voicecat::voicecat)
|
||||
target_compile_features(test_recv_noise_reduction PRIVATE cxx_std_20)
|
||||
target_include_directories(test_recv_noise_reduction PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
|
||||
add_test(NAME recv_noise_reduction COMMAND test_recv_noise_reduction)
|
||||
set_tests_properties(recv_noise_reduction PROPERTIES TIMEOUT 90)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user