Program crashes or does not stop while using Sound

I am trying to generate a sound (bleep) using the following code:

from psychopy import prefs
prefs.general['audioLib'] = ['pyo']
from psychopy import sound, core
import numpy as np

val = 10*np.ones(2200)

song = sound.Sound(value=val, secs=0.05, octave=8, stereo=True, volume=1.0, loops=0, sampleRate=44100, hamming=False)
core.wait(1.0)
song.play()
core.wait(1.0)
song.stop(log=True)

However, every time I run the code either PsychoPy crashes or it doesn’t stop and I have to manually stop the program.

I have also used string notes instead of the array of ones, but the problem still persists.

I am new to PsychoPy and this is my first PyschoPy code. Could you please help me figure out how I could resolve the issue?

Thank you,
Abhishek

1 Like

pyo is playing up at the moment (since I switched to the 64bit version) and I haven’t worked out why yet.

Does it work for you setting the sound lib to be ‘pysoundcard’?

I just have two audio library options: ‘pyo’ and ‘pygame’. How do I use ‘pysoundcard’?

In your code (setting the option at runtime) you could simply replace pyo with pysoundcard.

In preferences you could add this as an option in the list of audio libs. They get tried in order and if pysoundcard doesn’t exist then one of the others will be used instead

3 Likes

I’ve just been checking and this definitely looks like a bug in the recent version of pyo but only for the ‘coreaudio’ audio driver, not the ‘portaudio’ dirver (which is another preference you can control in PsychoPy).

I’ll let the authors of pro know, but for now you should be able to use either pysoundcard or pyo with portaudio

1 Like

Thank you for your reply.

I tried using pyo with portaudio. It works without crashing and stops after the sound is played. However, I get this warning: > “2016-08-15 08:54:42.255 python[1165:12130] 08:54:42.255 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API’s in AudioComponent.h.”

Don’t worry about that warning. It’s irrelevant and the people that write portaudio aleady know about it. They’ve said they don’t intend to change anything for now but they’ll monitor any change by Apple on this.

Hi Jon,

Did you compile PYO 64-bit yourself?

Cheers,
Fintan

No I didn’t compile my own