A short psychophysics experiment comparing Pyo vs. Pygame for sound delay

267 views
Skip to first unread message

Patrick Bissett

unread,
Jun 4, 2015, 1:32:10 PM6/4/15
to psychop...@googlegroups.com
I was interested in presenting auditory stimuli in PsychoPy, but I found posts on these forums suggesting that auditory stimuli can have large delays when comparing the timestamp that PsychoPy claims the auditory stimulus was presented to the actually time the sound was output. Some suggested that this may differ based upon the audio package used (Pyo vs. Pygame). I did not have easy access to an Oscilloscope to do proper testing in my environment, but instead did a quick psychophysics experiment to try to gain some insight.

In order to test this in our lab setup (brand new high end iMacs), I ran 8 subjects on simple RT tasks that required responding as quickly as possible to the onset of a visual or auditory stimulus. The literature shows that simple RT to auditory stimuli should be ~30ms faster than simple RT to visual stimuli. Because simple RT is such a simple cognitive process, variability within subjects is relatively small, so even with a small number of trials I should be able to get an accurate estimate of the . I took this 30ms as ground truth assuming no delay in visual or auditory presentation. I ran a within-subject design where the subjects responded in one block (of 100 trials) to visual stimuli (which should not be influenced by any sound card or sound package delay) and the other block to auditory stimuli (which may be influenced by sound card or sound package delay). 4 subjects did the auditory task with the pygame python package, and the other 4 with the pyo python package. 

What I found in this sample is that auditory simple RT with the pygame package was ~20ms slower than visual simple RT (and all 4 subjects had slower auditory than visual RT), but auditory simple RT with the pyo package was ~35ms faster than visual simple RT (and all four subjects had faster auditory than visual RT). This suggests that the pygame package introduces an ~50ms delay in sound presentation in PsychoPy, and the Pyo package seemingly completely eliminates any sound card or sound package delay (as our 35ms faster auditory RT with pyo is very similar to the 30ms others have shown in the literature when using presentation software that ensures no sound card delay). Therefore, running PsychoPy with Pyo appears to eliminate all or virtually all sound card delay in my lab setup. 

I don't know how well this result generalizes to other lab setups, but I hope that this will be a useful starting point for others (1) trying to quantify any auditory delay in their PsychoPy setup or (2) trying to decide between using pyo or pygame

Michael MacAskill

unread,
Jun 4, 2015, 5:32:47 PM6/4/15
to psychop...@googlegroups.com
Hi Patrick,

Nice results to (indirectly) probe this.

I think objective measurements of pyo performance in PsychoPy have found latencies of under 10 ms and variability of ~1 ms:
<https://groups.google.com/forum/#!msg/psychopy-users/Hqx5GBE141k/CVNyeMxD2p0J>, so not quite "completely eliminates any sound card or sound package delay" but good enough for most purposes.

Pygame definitely has a longer mean latency (can't find anything on that, but my rough recollection was something of the order of up to 70 ms, so roughly consistent with your mean results). But additionally I think it has a considerable trial-by-trial variability, which is something that can't easily be captured by these sorts of behavioural assessments.

We have a longitudinal study which uses audio cues in a couple of key tasks: unfortunately we can't upgrade to pyo unless we were to deliberately add a variable lag to keep new data consistent with the old…

Regards,

Michael
Reply all
Reply to author
Forward
0 new messages