annotate src/libsndfile-1.0.25/Octave/sndfile_save.m @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
parents c7265573341e
children
rev   line source
Chris@0 1 ## Copyright (C) 2002-2011 Erik de Castro Lopo
Chris@0 2 ##
Chris@0 3 ## This program is free software; you can redistribute it and/or modify
Chris@0 4 ## it under the terms of the GNU General Public License as published by
Chris@0 5 ## the Free Software Foundation; either version 2, or (at your option)
Chris@0 6 ## any later version.
Chris@0 7 ##
Chris@0 8 ## This program is distributed in the hope that it will be useful, but
Chris@0 9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@0 11 ## General Public License for more details.
Chris@0 12 ##
Chris@0 13 ## You should have received a copy of the GNU General Public License
Chris@0 14 ## along with this file. If not, write to the Free Software Foundation,
Chris@0 15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Chris@0 16
Chris@0 17 ## -*- texinfo -*-
Chris@0 18 ## @deftypefn {Function File} {} sndfile_save (@var{filename, data, fs})
Chris@0 19 ## Save the given @var{data} as audio data to the given at @var{fs}. Set
Chris@0 20 ## the sample rate to @var{fs}.
Chris@0 21 ## @end deftypefn
Chris@0 22
Chris@0 23 ## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@0 24 ## Description: Save data as a sound file
Chris@0 25
Chris@0 26 function sndfile_save (filename, data, fs)
Chris@0 27
Chris@0 28 if nargin != 3,
Chris@0 29 error ("Need three input arguments: filename, data and fs.") ;
Chris@0 30 endif
Chris@0 31
Chris@0 32 if (! isstr (filename)),
Chris@0 33 error ("First parameter 'filename' is must be a string.") ;
Chris@0 34 endif
Chris@0 35
Chris@0 36 if (max (size (fs)) > 1),
Chris@0 37 error ("Second parameter 'fs' must be a single value, not an array or matrix.") ;
Chris@0 38 endif
Chris@0 39
Chris@0 40 [nr nc] = size (data) ;
Chris@0 41
Chris@0 42 if (nr > nc),
Chris@0 43 data = data' ;
Chris@0 44 endif
Chris@0 45
Chris@0 46 samplerate = fs ;
Chris@0 47 wavedata = data ;
Chris@0 48
Chris@0 49 str = sprintf ("save -mat-binary %s samplerate wavedata", filename) ;
Chris@0 50
Chris@0 51 eval (str) ;
Chris@0 52
Chris@0 53 endfunction