From aa2c396b174fb4bc11af10b9a50ae4c045eeb00d Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Thu, 11 Sep 2008 00:51:00 -0500 Subject: Initial import of libresample 0.1.3 --- tests/compareresample.c | 183 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 tests/compareresample.c (limited to 'tests/compareresample.c') diff --git a/tests/compareresample.c b/tests/compareresample.c new file mode 100644 index 0000000..8773c9d --- /dev/null +++ b/tests/compareresample.c @@ -0,0 +1,183 @@ +/********************************************************************** + + compareresample.c + + Real-time library interface by Dominic Mazzoni + + Based on resample-1.7: + http://www-ccrma.stanford.edu/~jos/resample/ + + License: LGPL - see the file LICENSE.txt for more information + +**********************************************************************/ + +#include "../include/libresample.h" + +#include + +#include +#include +#include + +#include + +#define MIN(A, B) (A) < (B)? (A) : (B) + +void dostat(char *name, float *d1, float *d2, int len) +{ + int i; + double sum, sumsq, err, rmserr; + + sum = 0.0; + sumsq = 0.0; + for(i=0; i= 0) + out += o; + if (o < 0 || (o == 0 && srcpos == srclen)) + break; + } + resample_close(handle); + + gettimeofday(&tv1, NULL); + deltat = + (tv1.tv_sec + tv1.tv_usec * 0.000001) - + (tv0.tv_sec + tv0.tv_usec * 0.000001); + + if (o < 0) { + printf("Error: resample_process returned an error: %d\n", o); + } + + if (out <= 0) { + printf("Error: resample_process returned %d samples\n", out); + free(dst_rs); + return; + } + + printf(" resample: %.3f seconds, %d outputs\n", deltat, out); + + /* do rabbit (Erik's libsamplerate) */ + + for(i=0; i 0) + statlen = MIN(statlen, anslen); + + if (ans) { + dostat("resample ", dst_rs, ans, statlen); + dostat("rabbit ", dst_rabbit, ans, statlen); + } + dostat( "RS vs rabbit", dst_rs, dst_rabbit, statlen); + + free(dst_rs); + free(dst_rabbit); +} + +int main(int argc, char **argv) +{ + int i, srclen; + float *src, *ans; + + printf("\n*** sin wave, factor = 1.0 *** \n\n"); + srclen = 100000; + src = malloc(srclen * sizeof(float)); + for(i=0; i