From d5338f641daeecfe8ce17d8502c23e8742387625 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 5 May 2022 19:38:36 +0200 Subject: [PATCH 1/2] Use speex_resampler_process_interleaved_float in the testresample2 --- libspeexdsp/testresample2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libspeexdsp/testresample2.c b/libspeexdsp/testresample2.c index 99a830da..db865556 100644 --- a/libspeexdsp/testresample2.c +++ b/libspeexdsp/testresample2.c @@ -68,7 +68,7 @@ int main() fprintf (stderr, "%d %d %d %d -> ", rate, off, in_len, out_len); - speex_resampler_process_float(st, 0, fin + off, &in_len, fout, &out_len); + speex_resampler_process_interleaved_float(st, fin + off, &in_len, fout, &out_len); fprintf (stderr, "%d %d\n", in_len, out_len); off += in_len; From f426f7f9c9328630eaccafd0b3e9b9e56068b73c Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 5 May 2022 19:40:57 +0200 Subject: [PATCH 2/2] 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..b2e5015e 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)