Skip to content

Commit

Permalink
Audio: Google RTC audio processing: Mix all channels in mockup
Browse files Browse the repository at this point in the history
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.

If any of the buffers is with less channels the output channels
are mixed to minimum channels count of all streams.

The mixed samples are saturated to avoid nasty sounding overflows.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu committed Sep 27, 2023
1 parent b1ddf19 commit b06b356
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/audio/google/google_rtc_audio_processing_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <string.h>
#include <stdint.h>

#include <sof/audio/format.h>
#include <sof/math/numbers.h>
#include <rtos/alloc.h>
#include "ipc/topology.h"

Expand Down Expand Up @@ -145,11 +147,17 @@ int GoogleRtcAudioProcessingProcessCapture_int16(GoogleRtcAudioProcessingState *
int16_t *ref = state->aec_reference;
int16_t *mic = (int16_t *) src;
int16_t *out = dest;
int n;
int channels;
int n, m;

channels = MIN(state->num_capture_channels, state->num_aec_reference_channels);
channels = MIN(state->num_output_channels, channels);

memset(dest, 0, sizeof(int16_t) * state->num_output_channels * state->num_frames);
for (n = 0; n < state->num_frames; ++n) {
*out = *mic + *ref;
for (m = 0; m < channels; m++)
out[m] = sat_int16((int32_t)mic[m] + ref[m]);

ref += state->num_aec_reference_channels;
out += state->num_output_channels;
mic += state->num_capture_channels;
Expand Down

0 comments on commit b06b356

Please sign in to comment.