# Audio Unit AEC Test ## Modify WebRTC source code 1. Hack `voice_processing_audio_unit.mm` 2. Add `kAUVoiceIOProperty_BypassVoiceProcessing` - `enable_aec`: 0 is enable, 1 is disable ```swift // QNAP(Chungyi): Force enable built-in AEC - 2020/06/09 UInt32 enable_aec = 0; result = AudioUnitSetProperty(vpio_unit_, kAUVoiceIOProperty_BypassVoiceProcessing, kAudioUnitScope_Global, kOutputBus, &enable_aec, sizeof(enable_aec)); if (result != noErr) { RTCLogError(@"Failed to set built-in AEC." "Error=%ld.", (long)result); } ``` - Definision in headers: ![](https://i.imgur.com/0IXzEUD.png) - Reference: [Official Doc](https://developer.apple.com/documentation/audiotoolbox/kauvoiceioproperty_bypassvoiceprocessing) > Note: > https://developer.apple.com/documentation/avfoundation/audio_track_engineering/using_voice_processing 按照這個官方的sample code: AudioEngine也有bypassing的參數,我剛剛run起來測試: 當一邊播聲音依邊路自己的聲音時,bypass有開的話:錄到的音黨會伴隨稍早自己播放的音樂 bypass關閉的話則只會有自己的聲音。 所以研判這個參數: bypass on (1): mic會錄到自己喇叭播放的聲音 bypass off (0): 背景音會被過濾掉 所以我想我們在audio unit層把 kAUVoiceIOProperty_BypassVoiceProcessing設定成0應該就是不要錄到自己喇叭播放的聲音,讓人聲比較清楚一點這樣 - - - ## Test - Two Devices: - Device A - Two KoiTalk app - non_aec - aec - Device B - KoiTalk app without aec - Methods: - Device B: - Mic off - video off - host network - volume to speaker - Device A: - Mic on - Video off - host network - Disable remote audio volume - Result: ![](https://i.imgur.com/Apwd1LP.png)