annotate src/libsndfile-1.0.25/Octave/sndfile_play.m @ 85:545efbb81310

Import initial set of sources
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 18 Mar 2013 14:12:14 +0000
parents
children
rev   line source
cannam@85 1 ## Copyright (C) 2002-2011 Erik de Castro Lopo
cannam@85 2 ##
cannam@85 3 ## This program is free software; you can redistribute it and/or modify
cannam@85 4 ## it under the terms of the GNU General Public License as published by
cannam@85 5 ## the Free Software Foundation; either version 2, or (at your option)
cannam@85 6 ## any later version.
cannam@85 7 ##
cannam@85 8 ## This program is distributed in the hope that it will be useful, but
cannam@85 9 ## WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@85 10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cannam@85 11 ## General Public License for more details.
cannam@85 12 ##
cannam@85 13 ## You should have received a copy of the GNU General Public License
cannam@85 14 ## along with this file. If not, write to the Free Software Foundation,
cannam@85 15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cannam@85 16
cannam@85 17 ## -*- texinfo -*-
cannam@85 18 ## @deftypefn {Function File} {} sndfile_play (@var{data, fs})
cannam@85 19 ## Play @var{data} at sample rate @var{fs} using the sndfile-play
cannam@85 20 ## program.
cannam@85 21 ## @end deftypefn
cannam@85 22
cannam@85 23 ## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@85 24 ## Description: Play the given data as a sound file
cannam@85 25
cannam@85 26 function sndfile_play (data, fs)
cannam@85 27
cannam@85 28 if nargin != 2,
cannam@85 29 error ("Need two input arguments: data and fs.") ;
cannam@85 30 endif
cannam@85 31
cannam@85 32 if (max (size (fs)) > 1),
cannam@85 33 error ("Second parameter fs must be a single value.") ;
cannam@85 34 endif
cannam@85 35
cannam@85 36 [nr nc] = size (data) ;
cannam@85 37
cannam@85 38 if (nr > nc),
cannam@85 39 data = data' ;
cannam@85 40 endif
cannam@85 41
cannam@85 42 samplerate = fs ;
cannam@85 43 wavedata = data ;
cannam@85 44
cannam@85 45 filename = tmpnam () ;
cannam@85 46
cannam@85 47 cmd = sprintf ("save -mat-binary %s fs data", filename) ;
cannam@85 48
cannam@85 49 eval (cmd) ;
cannam@85 50
cannam@85 51 cmd = sprintf ("sndfile-play %s", filename) ;
cannam@85 52
cannam@85 53 [output, status] = system (cmd) ;
cannam@85 54
cannam@85 55 if (status),
cannam@85 56 disp (outout) ;
cannam@85 57 endif
cannam@85 58
cannam@85 59 endfunction