Sound output with low latency and high timing precision via PsychPortAudio


For many studies in the area of audio perception and audio-visual integration it is important to be able to play back sound signals with a low onset latency and/or at precisely defined points in time, e.g., in exact synchrony to the onset of a visual or tactile stimulus.

Standard sound drivers and output functions as provided by Matlab (e.g., sound, soundsc, wavplay, audioplayer, SND) as well as the sound drivers of many other psychophysics toolkits are not really well suited for low latency sound playback with high timing precision, because they don't provide mechanisms for timed sound onset, timing control or low latency operation. Their sole purpose is to make it simple to playback a sound, without any special emphasis on high efficiency or precise timing. Apart from that, Matlabs sound drivers have been the cause of many sound playback problems and crashes due to some significant bugs and design flaws in their implementation.

PTB-3's new sound driver PsychPortAudio tries to address this issues and to provide a sound driver specifically designed for the needs of psychophysics. Currently the driver can play back multi-channel sound (on multi-channel sound hardware), and it supports audio recording and simultaneous recording and playback (full duplex mode), also from multiple channels on multi-channel hardware.

The current driver (as shipped with PTB-3 beta) supports Microsoft Windows 2000 and XP (likely also Vista - but this is untested by the developers) and MacOS/X (tested with Tiger 10.4.9 to 10.4.11 on IntelMac and PowerPC), as well as GNU/Linux (tested with Ubuntu 7.1 on a MacBookPro with the ALSA sound system).

The current driver provides two different classes of sound output, normal playback mode and low-latency, high precision mode. Normal mode is the default mode of operation. It should allow for reliable, glitch free sound playback with low processor load on the widest possible variety of sound hardware. Low latency, high precision mode is optimized for low sound onset latencies and high precision of sound onset at requested times, prioritizing that goals over any other goals (e.g., low system load). While this high precision mode works very well out of the box on standard Macintosh computers with OS/X, as well as on standard PC's under GNU/Linux, it needs special hardware drivers on the Windows platform, so called ASIO drivers to get similar performance on that operating system.

MS-Windows built-in sound subsystems are pretty much incapable by design of providing well defined timing in the auditory domain and are sub-standard in many other areas as well. As a way around that limitation, the German company Steinberg, vendor of well-known professional sound applications and equipment for Windows PC's, designed an alternative sound subsystem called ASIO ("Audio streaming input output") specifically for the needs of professional sound production. Today, all high end soundcards ship with special ASIO drivers - device drivers that implement that interface in addition to the standard sound interfaces of MS-Windows, and professional level sound applications do use that ASIO interface to control sound hardware, bypassing the Windows sound system entirely.
Our PsychPortAudio driver can take advantage of ASIO. If you have Psychtoolbox version 3.0.9 or later, this works out of the box with the driver that comes with that Psychtoolbox version.

Users that want to stick to older versions of Psychtoolbox need to manually download and install the required ASIO DLL library from this link:

Click this link to download the special ASIO enabled windows sound driver

For Psychtoolbox 3.0.8 and earlier, we can not provide this DLL as part of the standard PTB distribution due to incompatibilities between the ASIO license, and PTB's former GPL license (Disclaimer: "ASIO is a trademark and software of Steinberg Media Technologies GmbH."). Therefore, if you download the linked zip file, you'll find a License file inside the zip file, which grants you a non-exclusive, royalty free right to copy and use the included DLL file for the purpose of using it with our PsychPortAudio driver on Microsoft Windows operating systems, directly given to you by Mario Kleiner, the copyright holder of that zip file, as long as you comply to the license terms. The zip file also contains a Readme file with specific installation and usage instructions, a list of tested sound cards and other interesting bits of information, in other words: It's a mandatory read!

The following sections provide you with information about how to use low-latency, high precision mode efficiently. Use of the normal mode is straightforward and demonstrated for sound output in the BasicSoundOutputDemo.m which is part of your PTB-3 distribution and BasicSoundInputDemo.m for basic sound recording/capture.

... to be continued, stay tuned ...

Tested configurations of OS & Sound hardware: Optimal parameter settings with measured results

Operating System Sound card and Driver ASIO type ASIO settings PsychPortAudio('Open') parameters Onset latency (ms) Onset accuracy (stddev from mean in ms) Misc comments Who?
OS/X 10.4.9 Intel MacBookPro 2.33Ghz, Intel HDA onboard sound Not needed - Pa('Open', [], [], 2, 96000, 2 [, 64]) 5.49 ms 0.022 ms Just works :-) Massimilliano di Luca and Mario Kleiner
WinXP-SP2 Dell computer with M-Audio Delta 1010-LT multichannel card native - ('Open', [], [], 2, 96000, 2 [, 64]) 5.87 ms 0.018 ms Just works :-) Massimilliano di Luca and Mario Kleiner
WinXP-SP2 Computer with Creative Labs Audigy 4 card native - ('Open', [], [], 2, 96000, 2 [, 64]) 4 ms better than 0.1 ms 1 ms bias without latency bias set Ken Roberts - Duke univ.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki