Problem with audio loop

Hello everyone.

I’m new to Python so I’m a bit lost in this, but got to a lab where they use Psychopy and let me a protocol I’m still not familiar to, so while I get to develop my skills, I elevate a question to you, in case you can help me faster!

The code, to post it simplified is something like this:


for trial in range(ntrials):
		
		trial_clock.reset()

		if trial not in probe_trials:
			metronome_sound.play()

So the experiment should make a beep, wait a bit, and then beep again, which obviously does not happen.

Maybe I’m missing something?

Thanks in advance

Ok, I have been digging in the cound, and the metronome_sound.play() is actually a dependency of sound.Sound(“A”, secs).

The thing is, the loop is working, as I can print the number of the trial and it works properly, but sounds is only heard the first time.

I’m using the PTB import, and the person who let me the code says he fixed it by downgrading the version of everything.

Does somebody know if there is some bug that might be playing me?

I’ve encountered issues with generated tones where they only play once for some reason, but I’ve actually had better luck with that on newer versions using PTB than on older ones. You could try reverting to something like sounddevice or pyo audio libraries (which are now plugins I believe) and see if those work better than PTB.

It might also be OS-specific. Windows or mac?

Might this advice help?

First of all, thanks for answering.

Well, the problem appeared both in Mac & Win11, so I don’t think the OS was the main thing. Notwithstanding, it actually solved downgrading to 2021.2.3 I think, so I assume it was actually the version. Maybe I can report it?

Thanks for answering. I solved it downgrading, but might actually try and use that in a newer version. Will update with results to share the experience!