Skip to content

Commit fc95621

Browse files
singalsucujomalainey
authored andcommitted
Audio: Google RTC audio processing: Mix all channels in mockup
With this change e.g. in all 2ch case all output channels are mixed with matching microphone and reference channels. It helps with testing to hear and see that the mockup works. The mix is done for matching microphone, reference and output channels indices. With e.g. less reference channels, the remaining output channels are passed directly from microphone. The mixed samples are saturated to avoid nasty sounding overflows. Signed-off-by: Lionel Koenig <lionelk@google.com> Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 763ed6d commit fc95621

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/audio/google/google_rtc_audio_processing_mock.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <string.h>
1111
#include <stdint.h>
1212

13+
#include <sof/audio/format.h>
14+
#include <sof/math/numbers.h>
1315
#include <rtos/alloc.h>
1416
#include "ipc/topology.h"
1517

@@ -145,11 +147,23 @@ int GoogleRtcAudioProcessingProcessCapture_int16(GoogleRtcAudioProcessingState *
145147
int16_t *ref = state->aec_reference;
146148
int16_t *mic = (int16_t *) src;
147149
int16_t *out = dest;
148-
int n;
150+
int n, io, im, ir;
149151

152+
/* Mix input and reference channels to output. The matching channels numbers
153+
* are mixed. If e.g. microphone and output channels count is 4, and reference
154+
* has 2 channels, output channels 3 and 4 are copy of microphone channels 3 and 4,
155+
* and output channels 1 and 2 are sum of microphone and reference.
156+
*/
150157
memset(dest, 0, sizeof(int16_t) * state->num_output_channels * state->num_frames);
151158
for (n = 0; n < state->num_frames; ++n) {
152-
*out = *mic + *ref;
159+
im = 0;
160+
ir = 0;
161+
for (io = 0; io < state->num_output_channels; io++) {
162+
out[io] = sat_int16(
163+
(im < state->num_capture_channels ? (int32_t)mic[im++] : 0) +
164+
(ir < state->num_aec_reference_channels ? (int32_t)ref[ir++] : 0));
165+
}
166+
153167
ref += state->num_aec_reference_channels;
154168
out += state->num_output_channels;
155169
mic += state->num_capture_channels;

0 commit comments

Comments
 (0)