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