Why are sound files periodically distorted on only some runs of experiment?

OS (e.g. Win10): OS X El Capitan (Needs to also run on Windows 7)
PsychoPy version (e.g. 1.84.x): 1.85.4

I have built 2 different auditory experiments in PsychoPy thus far: The first is an auditory oddball task where the subject must push a button to indicate when a “deviant/oddball” stimulus plays (no press on standard stims); The second experiment (let’s call is the sound similarity experiment) consists of two sounds being played (one after another) after which the subject must indicate if the sounds were the same or different. I have experienced similar issues with each as I will outline below.

I have included the conditions .xlxs file for the sound similarity experiment.
musicBeatsTest.xlsx (33.4 KB)
*Note the columns for sound durations of each sound (as they vary between files). I am using these durations to tell PsychoPy when to start and stop playing each sound. My ISI bewteen sounds 1 and 2 within the same trial is 600ms. Subjects have unlimited time to respond after each trial, and a button press advances them to the next.

Builder View looks like this:

I have been having a lot of issues with sound files playing correctly. Here are the errors I have encountered over the course of both of these experiments:

  1. The experiment runs perfectly fine up to a point, and then all sound cuts out. Everything else including scoring of answers. I think I have fixed this problem using the fix on this page: Sounddevice backend issue? (However, other problems persist.)
  2. On SOME runs of the experiment (I think the ones that begin the wave file numbered 000), my sound (.wav) files sound distorted. If the first sound of an experiment plays without distortion, then all the rest of the sounds in the whole experiment play without distortion (even sound file 000). If the first sound plays with distortion, then the rest of the sounds in that entire experimental run also play with distortion. The sound distortion seems to get worse when I add loops around routines and when visual stimuli are shown at the same time sound is played.

I thought the above might be an issue with different sample rates between sound files, but I tested them all and they are the same (48000).

Even when the experiment runs perfectly (no distortion or skipping), I still receive this error message:

File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/sounddevice/sounddevice.py”, line 1445, in callback_wrapper
buffer = _buffer(optr, frames, self._channels, self._samplesize)
TypeError: ‘NoneType’ object is not callable
From cffi callback <function callback_wrapper at 0x119bf2b90>:
Traceback (most recent call last):
File “/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/sounddevice/sounddevice.py”, line 1445, in callback_wrapper
buffer = _buffer(optr, frames, self._channels, self._samplesize)
TypeError: ‘NoneType’ object is not callable

My audio library is set as: [‘sounddevice’,‘pygame’,‘pyo’]
My audio driver is set as: [‘coreaudio’,‘portaudio’]

1 Like

I’m having the exact same problem. My code looks like this:

from psychopy import visual, core, event, sound # import some libraries from PsychoPy
import psychopy.gui
import socket



trial 1

face_2_sound_1 = sound.Sound(sound_path + “Face2_sound.wav”)
face_2_sound_1.play()

face_2_img_1.size = face_2_img_1.size*0.5
face_2_img_1.draw()

my_win.flip()
core.wait(6)

face_2_img_2.size = face_2_img_2.size*0.5
face_2_img_2.draw()

my_win.flip()
core.wait(2)

Has anyone found any solution yet?

1 Like

Getting the same error…

Could you try the latest (beta) version of PsychoPy please (3.0.0b12)? I think this is fixed.

Thanks, Jon