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