annotate src/libsndfile-1.0.27/Octave/sndfile_play.m @ 168:ceec0dd9ec9c

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