1 ## Copyright (C) 2002-2011 Erik de Castro Lopo
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2, or (at your option)
8 ## This program is distributed in the hope that it will be useful, but
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this file. If not, write to the Free Software Foundation,
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ## @deftypefn {Function File} {} sndfile_save (@var{filename, data, fs})
19 ## Save the given @var{data} as audio data to the given at @var{fs}. Set
20 ## the sample rate to @var{fs}.
23 ## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
24 ## Description: Save data as a sound file
26 function sndfile_save (filename, data, fs)
29 error ("Need three input arguments: filename, data and fs.") ;
32 if (! isstr (filename)),
33 error ("First parameter 'filename' is must be a string.") ;
36 if (max (size (fs)) > 1),
37 error ("Second parameter 'fs' must be a single value, not an array or matrix.") ;
40 [nr nc] = size (data) ;
49 str = sprintf ("save -mat-binary %s samplerate wavedata", filename) ;