Chris@0: ## Copyright (C) 2002-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 General Public License as published by Chris@0: ## the Free Software Foundation; either version 2, or (at your option) Chris@0: ## any later version. Chris@0: ## Chris@0: ## This program is distributed in the hope that it will be useful, but Chris@0: ## WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Chris@0: ## General Public License for more details. Chris@0: ## Chris@0: ## You should have received a copy of the GNU General Public License Chris@0: ## along with this file. If not, write to the Free Software Foundation, Chris@0: ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Chris@0: Chris@0: ## -*- texinfo -*- Chris@0: ## @deftypefn {Function File} {} sndfile_load (@var{filename}) Chris@0: ## Load data from the file given by @var{filename}. Chris@0: ## @end deftypefn Chris@0: Chris@0: ## Author: Erik de Castro Lopo Chris@0: ## Description: Load the sound data from the given file name Chris@0: Chris@0: function [data fs] = sndfile_load (filename) Chris@0: Chris@0: if (nargin != 1), Chris@0: error ("Need an input filename") ; Chris@0: endif Chris@0: Chris@0: samplerate = -1 ; Chris@0: samplingrate = -1 ; Chris@0: wavedata = -1 ; Chris@0: Chris@0: Chris@0: eval (sprintf ('load -f %s', filename)) ; Chris@0: Chris@0: if (samplerate > 0), Chris@0: fs = samplerate ; Chris@0: elseif (samplingrate > 0), Chris@0: fs = samplingrate ; Chris@0: else Chris@0: error ("Not able to find sample rate.") ; Chris@0: endif Chris@0: Chris@0: if (max (size (wavedata)) > 1), Chris@0: data = wavedata ; Chris@0: else Chris@0: error ("Not able to find waveform data.") ; Chris@0: endif Chris@0: Chris@0: endfunction