• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
2#
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.
7#
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.
12#
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.
16
17# These tests are nowhere near comprehensive.
18
19printf ("    Running Octave tests                     : ") ;
20fflush (stdout) ;
21
22filename = "whatever" ;
23srate_out = 32000 ;
24fmt_out = "wav-float" ;
25
26t = (2 * pi / srate_out * (0:srate_out-1))' ;
27data_out = sin (440.0 * t) ;
28
29# Write out a file.
30sfwrite (filename, data_out, srate_out, fmt_out) ;
31
32# Read it back in again.
33[ data_in, srate_in, fmt_in ] = sfread (filename) ;
34
35if (srate_in != srate_out)
36	error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ;
37	endif
38
39# Octave strcmp return 1 for the same.
40if (strcmp (fmt_in, fmt_out) != 1)
41	error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ;
42	endif
43
44err = max (abs (data_out - data_in)) ;
45
46if (err > 1e-7)
47	error ("err : %g\n", err) ;
48	endif
49
50printf ("ok") ;
51
52unlink (filename) ;
53