Problem with audio stimulus (PTB is bagging)

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 11
PsychoPy version (e.g. 1.84.x): v2021.2.3
What are you trying to achieve?:
I have an experiment with an audio stimulus. When the preferences are set in the following order: [sounddevice, PTB, pyo, pygame] the experiment runs but this message appears:
We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).
When I change the preferences order to the recommended one the experiment does not run at all. What should I do?

Thank you in advance for your help!

Hello,

do you need sound at all? If not, ignore the message.

Best wishes Jens

Hello Jens,

Thank you for your reply. Yes, I need sound. I have an auditory stimulus. The audio files are wav and the intensity is the same to all of them set to 75dB. The problem is that the auditory stimulus works only when the preferred audio engine is sounddevice and when I put PTB as a preferred audio engine the experiment does not run at all.

Hello,

well, if you don’t get an error message when running the experiment set to PTB, could it be that your installation is corrupt? Did sound work before?

Best wishes Jens

Hello,

The sounds works when it is set to sounddevice. But when I set PTB as preferable it does not run at all. I tried it again and the error message was this one:
Hello from the pygame community. Contribute - pygame wiki
PTB-ERROR: Failed to open audio device -1. PortAudio reports this error: Invalid device
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
Error in function Open: Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.

Hello Mavar_Mylona,

perhaps you are using a sampling rate that is incompatible with PTB and your sound-card? What sampling rate do you use for your sound-files?

Best wishes Jens

Hello JensBoelte,

perhaps you are using a sampling rate that is incompatible with PTB and your sound-card?
How can I check that?

The sampling rate must be 44100Hz, does that make sense?

Thank you very much for your help,
Mavra

Hello Mavra,

use a program such as audacity. And yes, 44100 Hz usually work.

Best wishes Jens

Hello JansBoelte,

I tried to run the experiment as it was (with PTB as a preference) online, and it worked. It still does not run locally. But since I need my experiment to run online I guess that this is not a problem, right?

Thank you,
Mavra

Hello Mavra,

well, I don’t know. I never had problems with sound.

Do you have toy-version of your experiment, one with just the relevant routine and only two or three offending stimuli? You could upload this here and one could check it out.

Best wishes Jens

Hello Jens,

Thank you. I do not have a toy-version. But I only have a couple of introductory pages and two example sessions. The first is just a demonstration of what the experiment looks like and the second one is identical to the actual experiment, with the only difference that it provides feedback. Both examples use sound, they are very similar to the actual experiment.
I have set PTB on the top of the preferences list, and the experiment does not run locally at all, but when I pilot it on pavlovia it works fine. Important here is that I need the experiment to run online.

If anyone could take a look at it, I would be grateful!
exp01222.psyexp (42.4 KB)

Mavra

Hello Mavra

the idea is make a toy-experiment (so deleted all routines welcome_page to details, and questions-routine), save this (and the relevant stimuli and excel-file) in a new folder and upload this :wink: Anyway without stimuli and your excel-file, I can’t run the experiment.

Best wishes Jens

Hi Jens,

right! I created it and I will upload now the whole folder, so you have the stimuli and the folder you need.
I uploaded it on google drive and here is the link you can use to access it. https://drive.google.com/drive/folders/1uQ1fsMa-YE1OcWF4WX0ehh3ecTp1CdrA?usp=sharing

Thank you so much,
Mavra

Hello Mavra,

well, I am sorry but your toy-experiment runs without any problems with all various sound-libraries on my computer. So, I am afraid that I can help you.

Best wishes Jens

I have often had sound issues working locally which resolve themselves when moving online. However, I use .mp3 versions for moving online; maybe this will help?

Dear Jens,

no worries. It runs online, so that’s ok for me since I need my experiment to run online. Thanks so much for your efforts and help! :slight_smile:

Best wishes,
Mavra!

Dear aisa,

that’s the case with my experiment too. There is no issue when running the experiment online. Thank you for the response!

Best wishes,
Mavra