1b815c7f3Sopenharmony_ci## Copyright (C) 2002-2011 Erik de Castro Lopo 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 General Public License as published by 5b815c7f3Sopenharmony_ci## the Free Software Foundation; either version 2, or (at your option) 6b815c7f3Sopenharmony_ci## any later version. 7b815c7f3Sopenharmony_ci## 8b815c7f3Sopenharmony_ci## This program is distributed in the hope that it will be useful, but 9b815c7f3Sopenharmony_ci## WITHOUT ANY WARRANTY; without even the implied warranty of 10b815c7f3Sopenharmony_ci## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11b815c7f3Sopenharmony_ci## General Public License for more details. 12b815c7f3Sopenharmony_ci## 13b815c7f3Sopenharmony_ci## You should have received a copy of the GNU General Public License 14b815c7f3Sopenharmony_ci## along with this file. If not, write to the Free Software Foundation, 15b815c7f3Sopenharmony_ci## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16b815c7f3Sopenharmony_ci 17b815c7f3Sopenharmony_ci## -*- texinfo -*- 18b815c7f3Sopenharmony_ci## @deftypefn {Function File} {} sndfile_load (@var{filename}) 19b815c7f3Sopenharmony_ci## Load data from the file given by @var{filename}. 20b815c7f3Sopenharmony_ci## @end deftypefn 21b815c7f3Sopenharmony_ci 22b815c7f3Sopenharmony_ci## Author: Erik de Castro Lopo <erikd@mega-nerd.com> 23b815c7f3Sopenharmony_ci## Description: Load the sound data from the given file name 24b815c7f3Sopenharmony_ci 25b815c7f3Sopenharmony_cifunction [data fs] = sndfile_load (filename) 26b815c7f3Sopenharmony_ci 27b815c7f3Sopenharmony_ciif (nargin != 1), 28b815c7f3Sopenharmony_ci error ("Need an input filename") ; 29b815c7f3Sopenharmony_ci endif 30b815c7f3Sopenharmony_ci 31b815c7f3Sopenharmony_cisamplerate = -1 ; 32b815c7f3Sopenharmony_cisamplingrate = -1 ; 33b815c7f3Sopenharmony_ciwavedata = -1 ; 34b815c7f3Sopenharmony_ci 35b815c7f3Sopenharmony_ci 36b815c7f3Sopenharmony_cieval (sprintf ('load -f %s', filename)) ; 37b815c7f3Sopenharmony_ci 38b815c7f3Sopenharmony_ciif (samplerate > 0), 39b815c7f3Sopenharmony_ci fs = samplerate ; 40b815c7f3Sopenharmony_cielseif (samplingrate > 0), 41b815c7f3Sopenharmony_ci fs = samplingrate ; 42b815c7f3Sopenharmony_cielse 43b815c7f3Sopenharmony_ci error ("Not able to find sample rate.") ; 44b815c7f3Sopenharmony_ci endif 45b815c7f3Sopenharmony_ci 46b815c7f3Sopenharmony_ciif (max (size (wavedata)) > 1), 47b815c7f3Sopenharmony_ci data = wavedata ; 48b815c7f3Sopenharmony_cielse 49b815c7f3Sopenharmony_ci error ("Not able to find waveform data.") ; 50b815c7f3Sopenharmony_ci endif 51b815c7f3Sopenharmony_ci 52b815c7f3Sopenharmony_ciendfunction 53