Sound file will not play in full after routine ends

If this template helps then use it. If not then just delete and start from scratch.

OS Win10
PsychoPy version 2023.2.3

In part of my experiment, I have a loop set up to alternate continuously between two static images to create a flicker effect. Just before the loop I have a sound file that starts and plays for 0.1s but continues to play beyond the end of the routine so that it plays over the top of this period of flicker. The sound file differs in different trials, so the sound file needs to be called from my procedure file. At the moment, I’m only getting the first ~50ms of the sound file, then it cuts out, but the flicker is still working.

All sound files are 12 second .wav files, as I say they are selected by the procedure file dependent on the trial. I have a static period whilst the fixation cross is on screen prior to the flicker loop, and the sound file is set to be selected during the static period. I have also tried just setting the sound file every repeat instead, and the same issue still occurs. The sound is set to play for 0.1 seconds, but is set not to finish with end of routine so it is triggered and then visual flicker commences immediately and the file plays for its natural duration. I am currently using ptb audio library and have latency set to critical – I have tried different combinations of libraries and latency settings, and the same effect occurs. I have tried playing through the computer’s own speakers and through headphones and the same effect occurs for both. I have also tried using constant sound files and the same effect still occurs.

We have had this experiment working previously in the lab, this issue has only recently occurred. In that time the code was not changed and no changes have been made to the system settings (the computer is a totally isolated system). I have tried rebuilding the experiment from scratch and again the same effect still occurs. My assumption was that it is taking the 0.1 second duration for the sound file literally rather than continuing to play beyond the end of the routine, but that does not make much sense given it has worked previously.

I have attached the experiment and stimulus files. WARNING – the visual stimuli we use are designed to be irritating, and because of the flicker effect they may be particularly irritating to people with heightened photosensitivity. If you feel you may be unusually affected by these I recommend replacing with alternative images.

A brief summary of the experiment file:

  • Initial loop (PGLoop) is irrelevant to the problematic section, it has been set to 0 loops but I’ve left it in to be as complete as possible
  • Flicker3 and flicker14 loops create the flicker effect
  • Threecpdbottleneck and fourteencpdbottleneck are in place because I have two different sets of visual stimuli and the frequency of flicker was more accurate when stimulus files were set as constant, one of the two is set to 0 loops on each trial
  • Flickerloop is the trials loop, in total there are 12 conditions. At the moment, the loop will take you through all 12 conditions continuously. I have taken out all routines between trials for quicker access.
  • FlickerLoop_Routine.xlsx is the procedure file for the problematic loop I have referred to in this post

Any help with resolving this issue would be much appreciated. Thank you!

ProblematicAudioCode.zip (6.1 MB)