Setting up a mic to headphones loopback

Hi,

I’m running my experiment in Psychtoolbox and using PsychPortAudio to play sounds. At the same time, I would like to feed input from the mic directly into headphones. The idea is that I want to use the mic to talk to my participant during breaks and during the instructions screens, while sitting far away (with a mask). My participant will wear the headphones from the beginning, without having to take them on/off to hear me.

I thought the best would be to do this loopback ‘outside’ my code, so I am using Pavucontrol on my Ubuntu machine to create the loopback to feed my mic into the headphones (the mic has a mute button).

However, this loopback get disabled once I run my code. I think it’s because of the ‘mode’ parameter in the PsychPortAudio(‘Open’, …) line.

Does anyone know which mode I should use? And should I use a certain ‘specialFlag’ and ‘requiredlatency’ flag as well?

My code currently does this:
" pahandle = PsychPortAudio(‘Open’, 0, 1, 1, 44100, 1);

Thank you,
Eugenie

pavucontrol only affects audio routing for applications which use the Pulseaudio desktop sound server. PsychPortAudio however suspends Pulseaudio the moment it is starting up, because we need exclusive low-level access to the soundcard for proper timing etc.

If your soundcard has loopback capabilities, and exposes those, you may be able to use the alsamixer command line tool in some way that is highly specific to the soundcard, or likely not available at all.

The PsychPortaudio builtin software way is demonstrated if you look at the code taken when calling DelayedSoundFeedbackDemo(0, 1); that approach would work if you open and close your soundcard between blocks of trials and pauses - to switch between “talk to the subject” configuration and “auditory stimulation” configuration.

The most elegant way would involve using PPA audio slave devices, and setting up for concurrent feedback mode via one slave device, and auditory stimulation via another one. You can find the principle in demos which use PsychPortAudio('OpenSlave', ...) and figure it out from there.

For more assistance i’d ask your lab to buy a community membership with priority support (help PsychPaidSupportAndServices). That’s something every lab should do anyway every year, given how affordable it is, in labs own long-term interest.

-mario

Hi Mario,
Thank you very much for the detailed reply. I will look into the slave device solution that you suggest, and we can continue using pavucontrol when we are running tasks outside Psychtoolbox.

Best regards,
Eugenie

Thank you’s are nowadays best expressed in cash, by buying the mentioned community membership once per year per lab, for a very affordable amount, to contribute to Psychtoolbox and Linux upkeep and future development.

Best,
-mario