Crackling sound with PTB and focusrite audio card

OS Win10:
PsychoPy version (3):

Hello,

I created an audio working memory experiment and I would like to use the PTB library to be able to reduce latencies as much as possible.
Everything run well but using focusrite audio card in output (Scarlett Solo), sound is crackling.
Whereas when I changed the settings to Pyo or Sounddevice, sounds play normal, and when I remove the focusrite audio card, sounds play normal as well.

Where may it come from ?

Thanks in advance.
Astrid

@stridla, we had a similiar issue with a Mac, but resolved the issue by reducing the “audio latency mode” setting in Builder Preferences > Hardware to 1) Share low-latency hardware. Might be worth a try.

Thank you @dvbridges for your help.

It did not work when I changed it in the builder preferences but it worked when I changed it in the “Experiment settings > Audio > Audio latency priority”.

However I worry about the latency. It is critical that the latency is as low as possible in the experiment. Yet on the psychopy documentation, one can read :

0 : Latency not important

For when it really doesn’t matter. Latency can easily be in the region of 300ms!

1 : Share low-latency access

Tries to use a low-latency setup in combination with other applications. Latency usually isn’t very good and in MS Windows the sound you play must be the same sample rate as any other application that is using the sound system (which means you usually get restricted to exactly 48000 instead of 44100).

2 : Exclusive mode low-latency

Takes control of the audio device you’re using and dominates it. That can cause some problems for other apps if they’re trying to play sounds at the same time.

3 : Aggressive exclusive mode

  • Mode 2 but with more aggressive settings to prioritise our use of the card over all others. *This is the recommended mode for most studies

4 : Critical mode

As Mode 3 except that, if we fail to be totally dominant, then raise an error rather than just accepting our slightly less dominant status.

Then do you think it is better to :

  • use the PTB library with a share low latency access
  • or use the Pyo library with a agressive exclusive mode ?

@stridla, good that it worked, I did not experience this issue with Windows, so good to know. The audio latency mode is specific to the PTB audio library, so will have no effect on Pyo libs. In our timing study, we used Mode 1 on the Mac because we also had crackling issues, and found that using Mode 1 with the Mac provided sub-millisecond audio onset precision and accuracy - however we tested Windows using Mode 3 - https://psyarxiv.com/d6nu5/. To be sure, you will need to run your own timing tests to ensure you have good timing - the paper also offers some guidance on this.

Thank you very much for your advices and the paper is very interesting.
One last question : I read that “the sound waveform was generated by PsychoPy” rather than loaded. Can they be easily generated using the builder ? Does it also improve the latency ?

Great, I hope it helps with your timing tests etc. Yes, using the Builder interface, you can add a sound component and describe the sound to be produced using frequency in Hz e.g., 440, or a letter giving a note name (e.g. “C”) and sharp or flat can also be added (e.g. “Csh” “Bf”) see docs. No, we did not use the sound waveform to improve performance, all stimuli were loaded before trials began so this would not affect latency. We used the software tools available to create sounds if they were available, otherwise we used a wav/mp3 file where supported.

1 Like