Troubleshooting sound distortion issues

I am having an issue with a sound based experiment at the moment. I would appreciate any suggestions for things to try and either fix or diagnose the issue.

At a random point during the task the sounds will sometimes move from a complex combination of frequencies to a distorted/white noise sound. There are 18 sounds in total being played in a random order and they all sound good to start with, but end up all sounding distorted.

The issue is transient. That is we’ve tried multiple solutions, tested it and it seems to work well. Then later testing - or worse recruited participants report distortion in the sounds part way through the task.

The code was originally created using the Builder, and then adapted. The 18 sounds are created once and then played multiple times, and while there is a display at the same time, it is only set up once at the start of each block and is then not changed.

We are testing on Windows 10 Professional, PsychoPy 2021.1.4 with the Psychtoolbox portaudio engine.

While I originally tested with other backends, this particular task needs the low latency provided by PTB, so that is not really a viable option. Things we have tried:

  • Disconnect from the network, turn off some background services (performed by another technician). The thinking was that perhaps some background process (possibly network related) was impacting on the process? Originally seemed to help, but has not been stable since.
  • The code has been checked, and while some edits improved latency and jitter of the sounds, they did not affect the transient distortion.
  • Based on other topics on this site and elsewhere I checked the sound sample rate, and regenerated the sounds to all be 48000Hz (2 channels, 16 bits per sample). This seemed to fix the issue initially - but recent testing with participants showed us that the problem is not resolved.

Does anyone have any suggestions on possible fixes, or where I could look for more assistance or any logging I can turn on to try and resolve this issue?