Variable sound (stop signal delay) in stop signal task

Hi,

I am trying to add a variable sound (stop signal delay- the gap between appearence of stimulus and beep sound, it should be 250 msec in the beginning so the sound should come after 250 msec of the appearence of stimulus for some (25% of the trials) and this gap should either increase by 50 msec when participants successfully inhibit their response when sound comes after a stimulus OR it should decrease by 50 msec after each unsuccesful response inhibition.
I managed to start (250 msec) but don’t know how to make it variable,

The code below only makes the beep sound play for one type of stimuli (1=left arrow)

if beep==1:
test_tone.play()

Hi,
I am having the same problem as you but instead of having a sound stimulus, I have a visual stimulus. Are you able to solve? How?