comparison src/libsamplerate-0.1.8/tests/downsample_test.c @ 0:c7265573341e

Import initial set of sources
author Chris Cannam
date Mon, 18 Mar 2013 14:12:14 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c7265573341e
1 /*
2 ** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <samplerate.h>
22
23 #include "util.h"
24
25 static void
26 downsample_test (int converter)
27 { static float in [1000], out [10] ;
28 SRC_DATA data ;
29
30 printf (" downsample_test (%-28s) ....... ", src_get_name (converter)) ;
31 fflush (stdout) ;
32
33 data.src_ratio = 1.0 / 255.0 ;
34 data.input_frames = ARRAY_LEN (in) ;
35 data.output_frames = ARRAY_LEN (out) ;
36 data.data_in = in ;
37 data.data_out = out ;
38
39 if (src_simple (&data, converter, 1))
40 { puts ("src_simple failed.") ;
41 exit (1) ;
42 } ;
43
44 puts ("ok") ;
45 } /* downsample_test */
46
47 int
48 main (void)
49 {
50 puts ("") ;
51
52 downsample_test (SRC_ZERO_ORDER_HOLD) ;
53 downsample_test (SRC_LINEAR) ;
54 downsample_test (SRC_SINC_FASTEST) ;
55 downsample_test (SRC_SINC_MEDIUM_QUALITY) ;
56 downsample_test (SRC_SINC_BEST_QUALITY) ;
57
58 puts ("") ;
59
60 return 0 ;
61 } /* main */