Hi all,
First I would like to thank @mariokleiner and @Ian-Max-Andolina for providing me with different possible solutions.
I finally found a way to make sound work on Linux with Psychtoolbox and Eyelink programs. Please note that this solved my issue but might not work for you.
The idea is to separate visual output from audio output. I display my experiment stimulus on the screen but don’t emit sound from this same screen (that has built-in speakers). Instead, I plugged in to the PC jack a pair of speakers from which the sound for my experiment will be output.
Prerequisite : Know which audio port you’re manipulating
Run this in a Matlab terminal to display the indexes of each available audio port on your computer :
d = PsychPortAudio('GetDevices')
[{d.DeviceIndex}',{d.DeviceName}']
For example, port number 5 is my system default port :
{[ 5]} {'sysdefault'}
Procedure :
First, check with alsamixer
that the channel you are interested in is not muted (for me “Headphone” since I use the jack socket):
Then in a linux terminal run the following commands :
$ sudo apt install pavucontrol
$ pavucontrol
This is the PulseAudio VolUme Control configuration panel.
In “Output Devices”, select one device as your default output audio device (for me “Headphones”), then run :
$ pulseaudio -k
to apply your changes. Preferably, disconnect from your session and restart your computer. Log back into Matlab and select the audio port that corresponds to “system default” port in your programs (see Prerequisite section; for me it’s port of index 5).
Your code should run just fine. Be careful not to unplug the speakers or you would have to restart Matlab and maybe your computer (I mean, in my case this is necessary…).
Extra ways to test your audio output:
You can test the device output set as “default” on your system with this linux command :
$ speaker-test -c 2
In Matlab you can also run :
PsychPortAudioTimingTest(0,5)
That’s it for me, I hope this can help some of you.
Cheers,
Jiji