shithub: libsamplerate

Download patch

ref: a2236768b3430b83754d178eca0646b11edc2fe8
parent: 6328b63d047f6451ca616d97bc930a0443cedc84
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Wed Jul 2 09:43:40 EDT 2008

Add new test tests/downsample_test.c and hook into build.

--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
 noinst_PROGRAMS = misc_test termination_test simple_test callback_test \
 					reset_test multi_channel_test snr_bw_test \
 					float_short_test varispeed_test callback_hang_test \
-					src-evaluate throughput_test
+					src-evaluate throughput_test downsample_test
 
 SAMPLRATEDIR =../src
 INCLUDES = -I$(srcdir)/$(SAMPLRATEDIR)
@@ -39,6 +39,9 @@
 float_short_test_SOURCES = float_short_test.c util.c util.h
 float_short_test_LDADD = $(SAMPLRATEDIR)/libsamplerate.la
 
+downsample_test_SOURCES = downsample_test.c util.c util.h
+downsample_test_LDADD = $(SAMPLRATEDIR)/libsamplerate.la
+
 varispeed_test_SOURCES = varispeed_test.c util.c util.h calc_snr.c
 varispeed_test_CFLAGS = @FFTW3_CFLAGS@
 varispeed_test_LDADD = $(SAMPLRATEDIR)/libsamplerate.la $(FFTW3_LIBS)
@@ -61,6 +64,7 @@
 	./misc_test
 	./termination_test
 	./callback_hang_test
+	./downsample_test
 	./simple_test
 	./callback_test
 	./reset_test
--- /dev/null
+++ b/tests/downsample_test.c
@@ -1,0 +1,57 @@
+/*
+** Copyright (C) 2008 Erik de Castro Lopo <erikd@mega-nerd.com>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <samplerate.h>
+
+#include "util.h"
+
+static void
+downsample_test (int converter)
+{	static float in [1000], out[10] ;
+	SRC_DATA data ;
+
+    printf ("        downsample_test     (%-28s) ....... ", src_get_name (converter)) ;
+	fflush (stdout) ;
+
+	data.src_ratio = 1.0 / 255.0 ;
+	data.input_frames = ARRAY_LEN (in) ;
+	data.output_frames = ARRAY_LEN (out) ;
+	data.data_in = in ;
+	data.data_out = out ;
+
+	src_simple (&data, converter, 1) ;
+
+	puts ("ok") ;
+} /* downsample_test */
+
+int
+main (void)
+{
+	puts ("") ;
+
+	downsample_test (SRC_ZERO_ORDER_HOLD) ;
+	downsample_test (SRC_LINEAR) ;
+	downsample_test (SRC_SINC_FASTEST) ;
+	downsample_test (SRC_SINC_MEDIUM_QUALITY) ;
+	downsample_test (SRC_SINC_BEST_QUALITY) ;
+
+	puts ("") ;
+
+	return 0 ;
+} /* main */