Background noise after using PsychPortAudio

Hi!

I am using PsychPortAudio to play some sounds. Sometimes, after running my code, I got background noise in any sound I am playing on my computer (not only in MATLAB). Why could this be? I don’t get any error messages from MATLAB and it does not happen every time I run it. I wonder if, somehow, sometimes, the channel I create remains open. However, I use the function “PsychPortAudio(‘Close’)” and I did not get any warning, so I assume it is working correctly. I play several sounds in several loops, but the general structure of my code regarding sounds looks as follows:

**%Initializing**
InitializePsychSound;
pahandle=PsychPortAudio('Open',[],1,[],[],1,[],0.015);
**%Play the sound (at several points of my code)**
PsychPortAudio('FillBuffer',pahandle,mytone);
start_time=PsychPortAudio('Start',pahandle,1,0,0);
**%After playing all the sounds**
PsychPortAudio ('Stop', pahandle);
PsychPortAudio ('Close');

I managed to solve it through the sounds settings of my computer, but I would like to prevent this from happening again. Which could be the cause?
I am using the 3.0.16 version of Psychtoolbox in a Windows 10 Home, using MATLAB R2019a.

Thank you very much in advance!

PsychPortAudio ('Close'); would perform a full driver shutdown from our side, so if anything survives past that point on Windows, it would be likely an operating-system/audio device driver bug.

Maybe the OS makes some hw configuration change stick past its welcome, and that causes some unwanted noise.

Btw. start_time=PsychPortAudio('Start',pahandle,1,0,0); probably doesn’t make sense, given that one of your 0 flags asks to not wait for start of actual audio and makes start_time invalid, iirc.

This was free advice. Future advice from my side would require your lab to buy a community membership with priority support.

best,
-mario

1 Like