I have an odd problem with sound output in PTB, which I think is related to intermittent issues with the Eyelink toolbox that cause Matlab to crash.
First, some details of my system:
- Ubuntu 20.04.2 LTS
- Psychtoolbox 3.0.17 - Flavor: Debian package - psych toolbox-3 (220.127.116.11.dfsg1-1~nd20.04+1)
- Matlab R2021a
- AMD video card: Ellesmere (Radeon RX 580); driver = amdgpu
- ViewPixx 3D screen;
- Eyelink 1000+ tracker
I first noticed that whenever I call PsychPortAudio(‘Open’…) or Snd(‘Open’) in Matlab, the following error message is printed into the terminal from which I launched Matlab:
> Cannot connect to server socket err = No such file or directory > Cannot connect to server request channel > jack server is not running or cannot be started > JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock > JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
The PTB output into the Matlab command window was this:
PTB-INFO: Using modified PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4 PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: CX20632 Analog (hw:0,0)] as default output audio device. PTB-INFO: New audio device -1 with handle 0 opened as PortAudio stream: PTB-INFO: For 2 channels Playback: Audio subsystem is ALSA, Audio device name is HDA Intel PCH: CX20632 Analog (hw:0,0) PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 9.977324 msecs.
I did some research into what the “jack server” is and surmise that it is related to the sound card. I can start the jack server with a GUI called “qjackctl” or with this command in the terminal:
jackd -d alsa -r 44100
Once that is running, starting the sound system in PTB works better: no errors appear in the terminal that’s running Matlab, and the output in the Matlab command window looks different:
> PTB-INFO: Using modified PortAudio V19.6.0-devel, revision > 396fe4b6699ae929d3a685b3ef8a7e97396139a4 > PTB-INFO: Choosing deviceIndex 7 [jack] as default output audio device. > PTB-INFO: New audio device -1 with handle 0 opened as PortAudio stream: > PTB-INFO: For 2 channels Playback: Audio subsystem is ALSA, Audio device name is jack > PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 23.219955 msecs
So first question is:
- Does anyone know why the audio output system throws errors unless I start the “jack” server outside of Matlab? Is there any way to make it automatic?
Next, I think the sound issue was causing problems when my Matlab code communicates with the Eyelink computer to calibrate, because the calibration routine also play sounds. Occasionally the sounds would not happen, and occasionally the program would freeze and Matlab would crash. But I’m not 100% sure. Since we started running the jack server manually (as of yesterday), we haven’t had any issues.
However, I haven’t been able to simultaneously use the PsychPortAudio system and the Eyelink functions. I read the instructions about first starting PsychPortAudio, then passing Snd(‘open’) the handle to a PsychPortAudio channel or slave, but that has never worked for my on Linux systems. The Eyelink calibration system sometimes hangs, gets stuck and even crashes outright. So, I’ve relied only on “Snd” in all my experiments that also involve eye-tracking.
So my second question is: is there a better way to use PsychPortAudio and Eyelink on a Linux machine?