I’m making the move to Linux from macOS, using a Dell Lattitude 9510 laptop running Ubuntu 18.04.5 LTS.
I’ve installed Matlab, matlab-support, PTB, GStreamer and the PTB dependencies (via sudo apt build-dep psychtoolbox-3). All the graphics stuff works fine, as does sound played in video or sounds files via GStreamer [Screen(‘PlayMovie’)].
I’m having trouble with PsychPortAudio. Any use of it (BasicSoundDemo, or my own code) causes Matlab to hang when either a) calling PsychPortAudio(‘Stop’), or b) if PsychPortAudio(‘Stop’) is omitted, upon the subsequent call to PsychPortAudio(‘Start’). When I say “hang”, I mean that the Matlab IDE still responds to mouse and KB input, but considers itself “busy”, and CTRL+C won’t interrupt it. [Edit: this occurs regardless of which sound device I tell PsychPortAudio to use]
I then found that this hang can be stopped by switching the output device between the internal speaker and headphones in the Ubuntu sound settings. As soon as a new device is chosen, the sound plays and Matlab returns to normal.
Setting PsychPortAudio(‘EngineTunables’, , , , 0) instructs PTB not to suspend the audio server during playback, and this prevents the problem from occurring. I don’t totally understand why, but perhaps someone with more Linux knowledge can explain?
One issue with this approach is that the timestamps returned by PsychPortAudio(‘Start’) are ~two hours in the future. I don’t know if this is because I’m not specifying a ‘when’ variable telling the function when to start. If I do this, then the code hangs again, and even changing audio device doesn’t release it.
As it stands, I’m happy with this approach as I can run my experiment. Hopefully this post will be helpful to someone else in the future. If anyone with a better understanding of this stuff has any insights into why this is working (or knows of a better workaround than that which I have attempted) it would be great to hear.