From 49fb03d5cba69759f96974344edb625006f8b1ce Mon Sep 17 00:00:00 2001 From: Dusan Stevanovic Date: Tue, 29 Oct 2024 18:26:38 +0100 Subject: [PATCH] fix webrtc resampler in interface --- src/audio_effect/pcm_interface.cpp | 6 ++++-- src/audio_effect/wav_interface.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/audio_effect/pcm_interface.cpp b/src/audio_effect/pcm_interface.cpp index 4d1bd08bd..efce099a5 100644 --- a/src/audio_effect/pcm_interface.cpp +++ b/src/audio_effect/pcm_interface.cpp @@ -165,8 +165,6 @@ int apply_effect_to_pcm(const char* pcmIn, return -1; } - webrtc::PushResampler input_resampler(fs_hz, FS_PROC, 1); - webrtc::PushResampler output_resampler(FS_PROC, fs_hz, 1); // Setup Audio Buffer used by apm webrtc::AudioFrame near_frame; @@ -205,6 +203,10 @@ int apply_effect_to_pcm(const char* pcmIn, int16_t bufIn[L], procOut[L_proc]; //int16_t procIn[L_proc], procOut[L_proc]; size_t count; + + webrtc::PushResampler input_resampler(L, L_proc, 1); + webrtc::PushResampler output_resampler(L_proc, L, 1); + for(int i = 0; i < n_frames; i++){ count = fread(bufIn, sizeof(int16_t), diff --git a/src/audio_effect/wav_interface.cpp b/src/audio_effect/wav_interface.cpp index 478ef7232..73f1cf469 100644 --- a/src/audio_effect/wav_interface.cpp +++ b/src/audio_effect/wav_interface.cpp @@ -357,9 +357,6 @@ int apply_effect_to_wav(const char* wavIn, int progress = 0; int rem = 0; int n_samp_out = 0; - - webrtc::PushResampler input_resampler(format.sample_rate, FS_PROC, 1); - webrtc::PushResampler output_resampler(FS_PROC, format.sample_rate, 1); // Setup Audio Buffer used by apm webrtc::AudioFrame near_frame; @@ -398,6 +395,10 @@ int apply_effect_to_wav(const char* wavIn, int16_t bufIn[L]; int16_t procIn[L_proc], procOut[L_proc]; size_t count; + + webrtc::PushResampler input_resampler(L, L_proc, 1); + webrtc::PushResampler output_resampler(L_proc, L, 1); + for(int i = 0; i < N; i++){ count = fread(bufIn, sizeof(int16_t),