# Background noise after using PsychPortAudio

**URL:** <https://psychtoolbox.discourse.group/t/background-noise-after-using-psychportaudio/3607>\
**Category:** Bugs & Features\
**Tags:** windows, audio\
**Created:** [January 7, 2021, 3:31pm UTC](https://psychtoolbox.discourse.group/t/background-noise-after-using-psychportaudio/3607 "2021-01-07T15:31:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laura1](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@Laura1](https://psychtoolbox.discourse.group/u/Laura1)\
**Post date:** [January 7, 2021, 3:31pm UTC](https://psychtoolbox.discourse.group/t/background-noise-after-using-psychportaudio/3607/1 "2021-01-07T15:31:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [January 7, 2021, 6:38pm UTC](https://psychtoolbox.discourse.group/t/background-noise-after-using-psychportaudio/3607/2 "2021-01-07T18:38:09Z")

</div>

`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
