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