From 1696c3ace5baaf3b9f88fcccbb1f565114d270a9 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 5 May 2022 19:40:57 +0200 Subject: [PATCH] Use multiple channels The API uses per-channel dimensions. --- libspeexdsp/testresample2.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libspeexdsp/testresample2.c b/libspeexdsp/testresample2.c index db865556..813455b4 100644 --- a/libspeexdsp/testresample2.c +++ b/libspeexdsp/testresample2.c @@ -43,20 +43,29 @@ #define INBLOCK 1024 #define RATE 48000 -int main() +int main(int argc, char **argv) { - spx_uint32_t i; - float *fin, *fout; - int rate = 1000, off = 0, avail = INBLOCK; - SpeexResamplerState *st = speex_resampler_init(1, RATE, RATE, 4, NULL); + spx_uint32_t i, j; + float *fin, *fout, val; + int rate = 1000, off = 0, avail = INBLOCK, channels = 1; + + if (argc > 1) { + channels = atoi(argv[1]); + } + + SpeexResamplerState *st = speex_resampler_init(channels, RATE, RATE, 4, NULL); speex_resampler_set_rate(st, RATE, rate); speex_resampler_skip_zeros(st); - fin = malloc(INBLOCK*2*sizeof(float)); - for (i=0; i ", rate, off, in_len, out_len); - speex_resampler_process_interleaved_float(st, fin + off, &in_len, fout, &out_len); + speex_resampler_process_interleaved_float(st, fin + off * channels, &in_len, fout, &out_len); fprintf (stderr, "%d %d\n", in_len, out_len); off += in_len; @@ -77,7 +86,7 @@ int main() if (off >= INBLOCK) off -= INBLOCK; - fwrite(fout, sizeof(float), out_len, stdout); + fwrite(fout, sizeof(float), out_len * channels, stdout); rate += 100; if (rate > 128000)