1 # Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU Lesser General Public License as published by
5 # the Free Software Foundation; either version 2.1 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # These tests are nowhere near comprehensive.
19 printf (" Running Octave tests : ") ;
22 filename = "whatever" ;
24 fmt_out = "wav-float" ;
26 t = (2 * pi / srate_out * (0:srate_out-1))' ;
27 data_out = sin (440.0 * t) ;
30 sfwrite (filename, data_out, srate_out, fmt_out) ;
32 # Read it back in again.
33 [ data_in, srate_in, fmt_in ] = sfread (filename) ;
35 if (srate_in != srate_out)
36 error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ;
39 # Octave strcmp return 1 for the same.
40 if (strcmp (fmt_in, fmt_out) != 1)
41 error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ;
44 err = max (abs (data_out - data_in)) ;
47 error ("err : %g\n", err) ;