Re: Glitch-free presentations with Windows 7 and Matlab (Martin Hansen )

Subject: Re: Glitch-free presentations with Windows 7 and Matlab
From:    Martin Hansen  <martin.hansen@xxxxxxxx>
Date:    Mon, 24 Oct 2011 12:16:04 +0200

Hi all, Trevor has mentioned PortAudio as one solution (and so has Matlab themselves told to a colleague of mine in a recent email). Already some years before this Matlab-2011 problem popped up, we have used PortAudio to create our "msound" tool, which is a wrapper for PortAudio for block-wise audio input and ouput, for unlimited duration (in principle). You can download it freely from here: It is written as a mex file and published under the free LGPL license. It contains the precompiled mex-files "msound" for windows (dll, mexw32) and linux and also some example functions, e.g. one called "msound_play_record.m" which does simultaneous output and input to and from your soundcard for as long as your output lasts. This functions also handles all intialization automatically for you. Another function, called "msound_play.m", does what it is named after. We have had msound running for several years now, and a large number of our students have used it successfully for their assignments, projects and theses as well. which Best regards, Martin -- Prof. Dr. Martin Hansen Jade Hochschule Wilhelmshaven/Oldenburg/Elsfleth Studiendekan Hörtechnik und Audiologie Ofener Str. 16/19 D-26121 Oldenburg Tel. (+49) 441 7708-3725 Fax -3777 On 18.10.2011 19:29, David Magezi wrote: > Many thanks for that review Trevor. > > Am not sure, if the following has been mentioned: There appears to be a matlab-ASIO interface from University of Birmingham (UK), using ActiveX. > > > > > I would also be keen to hear of other solutions found, > > D > > > *************************************************** > David Magezi > > *************************************************** > > > ________________________________ > From: Trevor Agus <Trevor.Agus@xxxxxxxx> > To: AUDITORY@xxxxxxxx > Sent: Tuesday, October 18, 2011 5:52 PM > Subject: [AUDITORY] Glitch-free presentations with Windows 7 and Matlab > > I've found it surprisingly difficult to present glitch-free sounds with > Windows 7. > > The short answer is that Padraig Kitterick's "asioWavPlay" seems to be the > simplest reliable method (remembering to buffer the waveforms with 256 samples > of silence to avoid truncation issues). For those with more complex needs, > perhaps soundmexpro or PsychToolbox would be better. I'd value any second > opinions and double-checking, so a review of the options follows, with all the > gory details. > > I've been using a relatively old version of Matlab (R2007b) with a Fireface UC > soundcard. If the problems are fixed in another version or soundcard, I'd love > to know about it. > > ===Matlab's native functions (sound, wavplay, audioplayer) > Large, unpredictable truncations were the least of our problems. We also often > got mid-sound glitches, ranging from sporadic (just a few subtle glitches per > minute) to frequent (making the sound barely recognisable). The magic formula > for eliminating the glitches seemed to be to keep the soundcard turned off > until > the desktop was ready, with all background programs loaded. (Restarting either > the soundcard or the computer alone guaranteed some glitches.) So this formula > seems to work, but it's a bit too Harry Potter for my liking, and the spell > might change with the next Windows update. I think I read that Fireface were > no longer supporting Microsoft's vagaries, and they recommended using ASIO. I'm > not sure if other high-end soundcard manufacturers are any different. Since > Matlab's native functions don't support ASIO (unless the new versions do?), > I think we're forced to look at the ASIO options. > > ===playrec > This seems to be potentially the most flexible method of presenting sounds but > I've hit a brick wall compiling it for Windows 7. I think its author stopped > providing support for it a few years ago. Has anyone had more success than me? > > ===asioWavPlay > This simply presents a .wav file using ASIO. It's a little annoying that you > have to save your sound to disk before presenting it, but as Joachim pointed > out, it's not too difficult to automate this process. While doing that, I add > 256 samples of silence to the end to work around the truncation problem. > > ===pa_wavplay > This is nearly the perfect solution except (1) the number of samples truncated > from the end is slightly unpredictable and (2) it prints a message on the > screen after every sound ("Playing on device 0"). For these two reasons, I > prefer asioWavPlay. > > ===soundmexpro > This might be best choice for the high-end user (I've just had a quick look at > the demo version today). It's easy to install and there are good tutorials, but > it involves initialising sound objects, etc. -- it's not just a replacement for > Matlab's "sound" command. Also it looks like it's €500+. > > ===PsychToolbox > Originally designed for visual experiments, PsychToolbox has now got quite > extensive low-latency sound functions, including realtime continuous > playing/recording. It's also free. However, it's slightly challenging to > install Like soundmexpro, it's object-oriented -- so don't expect to play a > sound with a simple one-liner. > > ===PortAudio > Most of above programs are based on this C library. If you're an experienced > programmer, perhaps you'd prefer to go direct the source? And while you're > there, perhaps you could write the perfect Matlab-ASIO interfaces for the rest > of us? (Please!) > > Has anyone found a simpler solution? I'd be glad to hear it. > > Trevor

This message came from the mail archive
maintained by:
DAn Ellis <>
Electrical Engineering Dept., Columbia University