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