BasicSoundOutputDemo not ending

I’m having difficulty with the BasicSoundOutpoutDemo. The version won’t exit once it has finished playing the script, essentially stuck in the while loop that begins on line 115. I’ve tried holding down keys to exit and this doesn’t work either. I just want it to play the number of repetitions specified and then close.

I’m using PTB 3.0.14 on Mac OSX in Matlab R2018b.

I’d be grateful for any help resolving this issue.

Please update to the latest PTB version

1 Like

I experience the same issue with PTB version 3.0.17

Ok, so it seems PTB does not have access to the keyboard and thus does not register any keypresses. Can you run one of the keyboard demos to check that? In that case, search the forum for this problem, its come up recently a few times. I am not a mac user myself and don’t what to do exactly in the security center (or how its called) to give ptb/matlab access to the keyboard, but try see if that is what it is. Also let us know what version of OSX you’re on.

1 Like

Thanks for the response. PTB is accessing the keyboard in other demos. Besides, even without a keypress BasicSoundOutputDemo(1) should stop after playing funk.wav once, but instead keeps going. The issue isn’t just that it doesn’t end with a keypress, it basically stays stuck in the while loop even when the sound clip has ended and there’s nothing further to play. I’m on OSX Big Sur (11.2.3).

The script won’t exit the while loop unless a keypress is detected, just sound playback stops after one repetition, the way you called it. If KbCheck works otherwise, it must be something like running a script beforehand that restricted keyboard input to specific keys. A clear all should get rid of that. Or one of the other Apple macOS keyboard bugs already discussed on the forum, although then it should fail consistently also in other scripts. Or some new Apple induced stupidity.

Note that macOS 11 is not officially supported or tested with current PTB for the time being. Rumor has it, it is even a worse trainwreck than Apples trainwrecks of the macOS 10 series.

-mario

Thank you for the help! Adding in a timer to time out the loop worked for me.