Chris@0: # Copyright (C) 2007-2011 Erik de Castro Lopo Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or modify Chris@0: # it under the terms of the GNU Lesser General Public License as published by Chris@0: # the Free Software Foundation; either version 2.1 of the License, or Chris@0: # (at your option) any later version. Chris@0: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU Lesser General Public License for more details. Chris@0: # Chris@0: # You should have received a copy of the GNU Lesser General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Chris@0: Chris@0: # These tests are nowhere near comprehensive. Chris@0: Chris@0: printf (" Running Octave tests : ") ; Chris@0: fflush (stdout) ; Chris@0: Chris@0: filename = "whatever" ; Chris@0: srate_out = 32000 ; Chris@0: fmt_out = "wav-float" ; Chris@0: Chris@0: t = (2 * pi / srate_out * (0:srate_out-1))' ; Chris@0: data_out = sin (440.0 * t) ; Chris@0: Chris@0: # Write out a file. Chris@0: sfwrite (filename, data_out, srate_out, fmt_out) ; Chris@0: Chris@0: # Read it back in again. Chris@0: [ data_in, srate_in, fmt_in ] = sfread (filename) ; Chris@0: Chris@0: if (srate_in != srate_out) Chris@0: error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ; Chris@0: endif Chris@0: Chris@0: # Octave strcmp return 1 for the same. Chris@0: if (strcmp (fmt_in, fmt_out) != 1) Chris@0: error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ; Chris@0: endif Chris@0: Chris@0: err = max (abs (data_out - data_in)) ; Chris@0: Chris@0: if (err > 1e-7) Chris@0: error ("err : %g\n", err) ; Chris@0: endif Chris@0: Chris@0: printf ("ok") ; Chris@0: Chris@0: unlink (filename) ;