[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Glitch-free presentations with Windows 7 and Matlab
Just a quick note on this... I have found that this truncation, at least
with ASIO-based playback functions such as my asioWavPlay and also
pa_wavplay, may be related to the fact that the connection to the
soundcard is opened and closed each time the function is called. A more
robust solution would be to expose separate functions for opening the
soundcard connection via ASIO, playing back either audio files or
buffers, and closing the ASIO connection. In this way, the ASIO
connection could remain open across repeated presentations and avoid
truncation issues. If there was sufficient interest, I would be willing
to try to find some time to develop a solution along these lines.
If anyone is also interested in working on this, you can find the
complete code for asioWavPlay here:
Direct code download link:
On 18/10/2011 16:52, Trevor Agus wrote:
I've found it surprisingly difficult to present glitch-free sounds with
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
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
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.
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?
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.
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
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+.
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.
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.