Mercurial > hg > sv-dependency-builds
annotate src/libsndfile-1.0.25/Octave/sndfile_load.m @ 0:c7265573341e
Import initial set of sources
author | Chris Cannam |
---|---|
date | Mon, 18 Mar 2013 14:12:14 +0000 |
parents | |
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_load (@var{filename}) |
Chris@0 | 19 ## Load data from the file given by @var{filename}. |
Chris@0 | 20 ## @end deftypefn |
Chris@0 | 21 |
Chris@0 | 22 ## Author: Erik de Castro Lopo <erikd@mega-nerd.com> |
Chris@0 | 23 ## Description: Load the sound data from the given file name |
Chris@0 | 24 |
Chris@0 | 25 function [data fs] = sndfile_load (filename) |
Chris@0 | 26 |
Chris@0 | 27 if (nargin != 1), |
Chris@0 | 28 error ("Need an input filename") ; |
Chris@0 | 29 endif |
Chris@0 | 30 |
Chris@0 | 31 samplerate = -1 ; |
Chris@0 | 32 samplingrate = -1 ; |
Chris@0 | 33 wavedata = -1 ; |
Chris@0 | 34 |
Chris@0 | 35 |
Chris@0 | 36 eval (sprintf ('load -f %s', filename)) ; |
Chris@0 | 37 |
Chris@0 | 38 if (samplerate > 0), |
Chris@0 | 39 fs = samplerate ; |
Chris@0 | 40 elseif (samplingrate > 0), |
Chris@0 | 41 fs = samplingrate ; |
Chris@0 | 42 else |
Chris@0 | 43 error ("Not able to find sample rate.") ; |
Chris@0 | 44 endif |
Chris@0 | 45 |
Chris@0 | 46 if (max (size (wavedata)) > 1), |
Chris@0 | 47 data = wavedata ; |
Chris@0 | 48 else |
Chris@0 | 49 error ("Not able to find waveform data.") ; |
Chris@0 | 50 endif |
Chris@0 | 51 |
Chris@0 | 52 endfunction |