psychopy.org | Reference | Downloads | Github

Sound component not playing on some trials

OS (e.g. Win10): Mac
PsychoPy version (e.g. 1.84.x): 3.2.4
Standard Standalone? (y/n) If not then what?: y

I would like a particular sound (a wave file) to start playing at 1.0 second on every trial of my experiment. This is what the sound component looks like currently:

The trials run through the visual stimuli with no problems coming up in the shell. However, the sound plays only on some trials - for the majority of the trials, the sound simply doesn’t play at all. Each trial is longer than 1 second, so that should not be the issue.

These are my experiment sound settings:

If you have any insight, please let me know. Thanks in advance.

Try setting the sound and volume to constant rather than set every repeat.

Hi there, I did that and it still isn’t working on every trial. Do you have any other suggestions?

I had this issue once. Changing the audio library to ‘PTB’ did the trick for me.

Thanks for this suggestion. I tried changing it to PTB, and the sound did not sound how it’s supposed to (super static-y). I’m wondering if there’s a better way to go about using sound in my experiment. It requires precise timing of this sound, so from what I’ve read online, PTB should be ideal to use, but it seems that I would need to add a code component to use it properly. However, translating that code into Javascript will become an issue. Any suggestions/insight?

Apologies, I’m very much a novice at coding. So you can’t create a basic sound component using Python code (because PTB would be able to work well with that I assume)? Then maybe you could try defining the onset and duration of your sound in terms of frames (this would be a start frame of 60 if you have a 60 Hz monitor)? I honestly have very little idea I’m afraid.

You’re wanting a sound that will play for only 50 ms. If there is any latency in starting it, it might get stopped before it is has actually started to play. Bear in mind that the code to check on things like onset and offset of stimuli runs only once per screen refresh, which is once every 16.666 ms on a 60 Hz screen. So controlling such a short duration of audio in software can get tricky. Although the ptb sound library has improved things markedly, we don’t get the kind of hardware feedback that we do for visual stimuli to be as confident of timing.

So since the sound file is a constant, can’t you just edit it in something like Audacity to make it exactly 50 ms in duration? Then the only source of variability left is the onset of the sound.

Thanks Michael and Don. I have now edited the sound to be 50ms and put this new sound into the exact same spots the other sound was. Now, however, Psychopy won’t even run my program - after the initial dialogue box, it crashes. When I use the old sound file, it runs. What could be going on? They are both .wav files. There is no error message.

JUST SOLVED THIS. Changed audio library to “sounddevice” and the start for the sound to be in frames, at 60, as suggested by Don. Works perfectly.