annotate src/libsndfile-1.0.27/Octave/sndfile_load.m @ 84:08ae793730bd

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