annotate src/libsndfile-1.0.27/Octave/sndfile_play.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_play (@var{data, fs})
Chris@40 19 ## Play @var{data} at sample rate @var{fs} using the sndfile-play
Chris@40 20 ## program.
Chris@40 21 ## @end deftypefn
Chris@40 22
Chris@40 23 ## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@40 24 ## Description: Play the given data as a sound file
Chris@40 25
Chris@40 26 function sndfile_play (data, fs)
Chris@40 27
Chris@40 28 if nargin != 2,
Chris@40 29 error ("Need two input arguments: data and fs.") ;
Chris@40 30 endif
Chris@40 31
Chris@40 32 if (max (size (fs)) > 1),
Chris@40 33 error ("Second parameter fs must be a single value.") ;
Chris@40 34 endif
Chris@40 35
Chris@40 36 [nr nc] = size (data) ;
Chris@40 37
Chris@40 38 if (nr > nc),
Chris@40 39 data = data' ;
Chris@40 40 endif
Chris@40 41
Chris@40 42 samplerate = fs ;
Chris@40 43 wavedata = data ;
Chris@40 44
Chris@40 45 filename = tmpnam () ;
Chris@40 46
Chris@40 47 cmd = sprintf ("save -mat-binary %s fs data", filename) ;
Chris@40 48
Chris@40 49 eval (cmd) ;
Chris@40 50
Chris@40 51 cmd = sprintf ("sndfile-play %s", filename) ;
Chris@40 52
Chris@40 53 [output, status] = system (cmd) ;
Chris@40 54
Chris@40 55 if (status),
Chris@40 56 disp (outout) ;
Chris@40 57 endif
Chris@40 58
Chris@40 59 endfunction