| Reference | Downloads | Github

Problem with timing using pio's Mixer

Hi All,

I am trying to play sound using Pyo’s SfPlayer and Mixer inside PsychoPy.
I am trying to make use of the “t” variable but it doesn’t change its value.
Is it supposed to ?

I have 3 routines, where in the first I want to play one file, in the second I want to play the second file and in the third I want to show a slide.
Currently I hear only the first file and simultaneously I see the slide of the 3rd routine. The second file is never played and I don’t understand why
the slide is shown before even the first sound file is finished playing.

Does anybody know how I should use timing with both visual (slides) stimulus and sound stimulus?

Part of my current Code:

playing the first sound file

begin routine

#-----initialize asio setting----
soundtrack1=SfPlayer(firstBstring, speed=1, loop=False)
#soundtrack1=SfPlayer(‘5.wav’, speed=1, loop=False)
soundtrack2=SfPlayer(secondBstring, speed=1, loop=False)
silenceTrack=SfPlayer(‘silence_1_5sec.wav’, speed=1, loop=False)
SquareWave = SfPlayer(‘440Hz_30ms.wav’, speed=1, loop=False)


#put speech in BOTH ears, and square wave in chan 3
SoundMixer1.setAmp(0,0,1)#(input channel, output Channel , volume)
SoundMixerStatus = 0

output_p_port.status = NOT_STARTED

if SoundMixerStatus == 0:
SoundStartTime = t # underestimates by a little under one frame
#SoundMixerName.frameNStart = frameN # exact frame index
SoundMixerStatus = 1
SoundMixer1.out() # start the sound (it finishes automatically)

each frame:

print t # I do get value for t. which means that it does represent something…?

if output_p_port.status == NOT_STARTED:
output_p_port.status = STARTED
win.callOnFlip(output_p_port.setData, int(trigger))

if output_p_port.status == STARTED and t >= (0.0 + (0.2-win.monitorFramePeriod*0.75)): #most of one frame period left
output_p_port.status = STOPPED

if t>=( (SoundStartTime+Duration)): #end of first stimulus # It never gets into this if because t does not get updated

print('end of first')
print t

SoundMixerStatus = 0
#time.sleep(2*Duration) # pause
#SoundMixer1.stop() #ensure sound has stopped at end of routine
continueRoutine = False

Thank you very much in advance!