Re: Audio Glitch in Matlab (Joachim Thiemann )


Subject: Re: Audio Glitch in Matlab
From:    Joachim Thiemann  <joachim.thiemann@xxxxxxxx>
Date:    Mon, 17 Oct 2011 11:28:33 -0400
List-Archive:<http://lists.mcgill.ca/scripts/wa.exe?LIST=AUDITORY>

On Mon, Oct 17, 2011 at 09:57, Patrick Zurek <pat@xxxxxxxx> wrote: > I'm writing to notify list readers of a problem playing audio using Matlab. I don't know if the bug you're referring to is Windows-specific; but the "sound" command on Linux used to have ... issues. (possibly related to the JVM and the OSS/ALSA/whatever is used now transition) I wrote a small almost trivial workaround (see http://signalsprocessed.blogspot.com/2011/02/playing-sounds-from-matlab-on-unix.html) that would simply write the sound to disk then play it from there: function [ ] = usound( w, fs ) %USOUND Plays sound on ALSA-based linux machines or macs if nargin < 2 fs = 16000; end filename = ['/tmp/' getenv('USER') '_matplay.wav']; wavwrite( w, fs, filename ); if ismac eval(['!afplay ' filename ' &']); else eval(['!aplay ' filename ' &']); end On a modern machine, the overhead is not perceptible: /tmp should be in RAM anyways. Note this also doesn't block, so you can continue working while the sound is playing (IIRC - this code is a bit old :-) Joe. -- Joachim Thiemann :: http://www.tsp.ece.mcgill.ca/~jthiem1


This message came from the mail archive
/var/www/postings/2011/
maintained by:
DAn Ellis <dpwe@ee.columbia.edu>
Electrical Engineering Dept., Columbia University