psychopy.org | Reference | Downloads | Github

Audio stimuli being cut short in trials

Hi all,

I am having a very frustrating bug: when your audio stimuli have different durations, PsychoPy takes the duration of the first random item in a loop and takes it as “maximum”, cutting short all subsequent files that are longer than that. It seems that this issue has been known for years now (Audio sample cut off + Audio stimuli cut short during trials, etc). Is there really still no solution? I must add that nothing that people have suggested so far works for me: changing the library to Pygame, adding static screen before to let the stimuli to buffer properly, or adding a column $duration which specifies all audio durations. The only solution I have in mind is displaying the longest audio track first and then randomizing the rest, but I don’t know how to code that. Can anyone offer any help?

What version of psychopy are you using? OS?

The latest one (3.0.0b7), Windows 10. I will be further using it online integrated with Pavlovia.

Ah, okay. I’m having a similar issue, but on a Mac with version 2020.2.4… so it seems that it is bigger than our systems/versions. I’m still trying to get pygame to play nice with me to see if that helps.

Out of curiosity, when you add the duration column, do you then use that variable somewhere?

Well, I tried using it in the duration column in the Audio component ($duration), but it still doesn’t work. I honestly got very frustrated with this bug and wrote entirely custom code which would play my longest item first and then randomize the rest of stimuli. This way no audio gets cut short afterwards. I really hope though that the developers would fix it soon, because this is a crucial feature and I am puzzled why it is still bugged.

1 Like

Okay, sorry I can’t help you for now! I’ll keep you posted if I find a workaround.
Also linking the other threads that might have similar issues, just in case you missed one:

maybe @dvbridges or @wakecarter have some insights?

My insights are mostly for online where I’ve put on my cribsheet.

DON’T Use Stop durations for audio
Sounds should either be edited to correct length or use sound.stop() in a code component.

For local experiments I usually end up changing the sound library to pygame.

Thanks @wakecarter! Can you point me to the right place to install the pygame library if I don’t have it?

Thanks, @wakecarter. Unfortunately, it didn’t work to change my library to pygame even for local experiments. Some other libraries change the pitch, others just crash (including pygame). Only sounddevice works for me, but this is the one that cuts audio short.
@aisa2 File > Preferences > Hardware > audio library and you can do it there :wink:

Thanks; I tried that before and it threw an error, but this time it seems to have worked. Doesn’t solve the problem though. Even with pygame the audio gets cut.

I actually found a solution (it only works on Pavlovia, though, not locally in Python, but that’s what I needed anyway):
you need to use name_of_your_sound_object.stop(); in the End Routine tab (js). Works like a charm!

Yes, online it works fine, that’s true. I’d still like to have it work on builder though!

I went with specifying the stop condition as $listenAudioFile.status == FINISHED:

image

Okay, so, a really sad update: despite using the stop() function AND having the longest (way longer than the rest) item played first in a sequential order, some items are still randomly cut short prematurely. This is just so frustrating and infuriating. I probably am not gonna use software which cannot perform at a basic level ever again.

1 Like

Hi,

I’m having the same issue and still no solution. Did you manage it at last?
Thanks!
Hadeel