Sound Engine PTB causes sampling rate error

I created a mini project - that will become part of a bigger one - whereby a sound is presented in a loop and users are asked to press the up and down arrow to adjust the volume. Then, the same sound is presented again outside the loop with the volume level set by the user earlier in the loop.

The sound in the loop is presented just fine, but outwith the loop and with PTB sound engine enabled, I get the following error:

psychopy.exceptions.SoundFormatError: Tried to create audio stream 44100_2_128 but 48000_2_128 already exists and win32 doesn't support multiple portaudio streams

The error does not appear when in preferences in the Audio Library I use the option Use preferences.

Just to note that no other sounds exist in the exp or in the folder where the .psyexp is located.

I attach both the exp (is very minimal) and the sound. Perhaps someone can try it and advise [WARNING: sound is of someone screaming, you may want to reduce sound volume on your device first]?


button_test.psyexp (15.8 KB)

Thank you in advance.

BW
Yiannis

Hello,

the error is due to the fact that your audio-file has a sampling frequency of 44100 Hz but the sound-engine expects 48000 Hz. So either change the sampling frequency of your sound file or use another sound -engine, e.g. pyo. See here for pro and cos of the various audio-libraries.

Best wishes Jens

Thanks @JensBoelte for your reply.
Indeed it works when changing the sampling rate or the sound engine (which I did earlier). Retrospectively, I should have phrased the title of this thread differently - Why PTB allows a sound of 44100Hz sampling rate to play once but not in the second time.

Oh well, thanks again