[solved] Temporal Jitter in auditory stimuli presentation with pyaudio
Hello,
I'm preparing an experiment with sequences of four audio stimuli at 200ms each. So, each sequence has a duration 4x200ms = 800ms. At first I used a sampler item specifying the sound file: [sound1].wav, where "sound1" is the first column in my experiment loop. The result was fine but after reading in the documentation that is preferable to use pyaudio ("if you require very accurate temporal precision when presenting auditory stimuli you may want to write an inline_script that plays back sound using a different module, such as PyAudio.") I decided to change the implementation. So I followed the example presented here: http://people.csail.mit.edu/hubert/pyaudio/. I used the "play" example and I changed only this part to fit my experiment:
# inline_script item
OUTPUT_FILE = "/Users/test/Documents/OpenSesame/SESSION_B_2.opensesame/pool/%s.wav" % self.get('sound1')
wf = wave.open(OUTPUT_FILE, 'rb')
Once I finished the implementation and I run the experiment, there was definitely a noticeable delay in the stimuli presentation.
I chose pyaudio to avoid any temporal jitter and finally the result was worse. Is there something wrong with my implementation? Thank you very much!
Comments
Hi,
It seems like you're doing everything right, but also like you're confusing jitter and delay (or latency).
What you're noticing is, I assume, a high delay. In my experience, pyaudio generally has a lower jitter than pygame for sound playback, even though the delay may the same or higher. Does that make sense? I should also point out that this is my general experience, and may not be the case on all systems--it's really a matter of testing what works best.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you for you immediate response!
You are right delay is the appropriate term for what I notice and it is actually high. So, after trying both pygame & pyaudio I will go for the first one which works best.
I assume we can consider the issue resolved.
Cheers!