psychopy.org | Reference | Downloads | Github

How to differ stimuli onset each trial from a list of predetermined onset times and their specific order

macOS
PsychoPy v2021.2.3

I have a single routine with visual stimuli in a loop with conditions for varying those visual stimuli. I also added a sound component to the routine. Right now the sound plays at the same time each trial within the loop and each time the visual stimuli are presented they vary randomly. I am trying to figure out how to play the sound at a different time each trial in the loop using a list of predetermined times however, the onset of the sound cannot be randomized using the values in this list rather, the sound must be presented in the specific order the times appear in the list. For example:

In trial one I need the sound to be presented at 0 seconds
In trial two I need the sound to be presented at 0.6 seconds
In trial three I need the sound to be presented at 1.2 seconds
In trial four I need the sound to be presented at 1.8 seconds
In trial five I need the sound to be presented at 0.15 seconds

Here is the specific list of onset times for the sound component, in the specific order I need:
0
0.6
1.2
1.8
0.15
I don’t want any sound to play this trial
0.75
1.35
1.95
0.3
0.9
1.5
I don’t want any sound to play this trial
2.1
0.45
1.05
1.65
0

Note that these don’t necessarily follow a predictable pattern, and in some of the trials I don’t want the sound to play at all. This also all needs to be done without compromising the preexisting visual stimuli, which is where I am really stumped.

There seem to be many questions and answers on how to play sound stimuli at random from a list of predetermined times -but this is not what I am trying to do. Since I want the sound to play at a specific time which differs each loop based on the order specified by the list, I was hoping for advice on how to go about this using the builder view or its code component.