From 1b8fe922c267844f08b1795682ff8ab7e2b2a40c Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 28 Feb 2022 13:10:56 -0500 Subject: Implement xas_audio_apply_gain() --- src/audio.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index bc2e04d..9caf199 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -10,6 +11,17 @@ int xas_audio_format_eq(xas_audio_format a, xas_audio_format b) { && a.sample_rate == b.sample_rate; } +void xas_audio_zero(xas_audio_format format, + void *dest, + size_t index, + size_t count) { + size_t stride = format.channels * format.sample_size; + + memset((uint8_t *)dest + stride * index, + '\0', + stride * count); +} + void xas_audio_copy(xas_audio_format format, void *dest, void *src, @@ -23,15 +35,39 @@ void xas_audio_copy(xas_audio_format format, stride * count); } -void xas_audio_zero(xas_audio_format format, - void *dest, - size_t index, - size_t count) { - size_t stride = format.channels * format.sample_size; +static inline void apply_gain_mono(int16_t *samples, + float gain, + size_t index, + size_t count) { + size_t i; - memset((uint8_t *)dest + stride * index, - '\0', - stride * count); + for (i=index; i