So I'm trying to run a for loop in a way that a sound will be played together with an image for as long as the sound lasts. I can see the image displaying for a very short time and also I hear the sound playing. But then it all stops, I'm not able to give input in the window (I should give in 'j' or 'f') in 0.85 seconds. After this a new trial should begin, but it doesn't. Don't know if that's because of this error that I'm getting:
sound1 = sound.SoundPygame(value=stimulussound)
AttributeError: 'SoundPygame' object has no attribute 'SoundPygame'
I don't understand why I get that error since sound1 is being played the first trial. But after the sound stops, the image goes away, the fixationcross is showed on screen, but the fixationcross doesn't go away after 0.85 seconds... And also if I push J of F, it DOES save it in a variable! And it also saves a reactiontime! Anyways, here's my code, why isn't a second trial starting after the first one running great?
#showing instructions
instructions = visual.TextStim(window, text=actualinstructions)
instructions.draw()
window.flip()
#waiting for j-key before rest of experiment runs
if event.waitKeys("j"):
window.flip()
start = True
#whileloop to start experiment
while start == True:
#forloop
for i in range (0,192):
#saving the two needed pathways in a variable
stimulusimage = conditiesalles[int(i)][int(2)]
stimulussound = conditiesalles[int(i)][int(3)] #f.e. C:\Users\Ineke\Documents\Python Scripts\Project\stimuli\Sounds\Negative\6.wav
#lengthofsound: using function
sound1 = sound.SoundPygame(value=stimulussound)
lengthofsound = sound1.getDuration()
#resetting timer and making a variable that knows the time
timerClock.reset()
currentTime = timerClock.getTime()
if (currentTime <= lengthofsound):
#imagestim
showingimage = visual.ImageStim(window, image=stimulusimage)
showingimage.draw()
window.flip()
#soundPygame
sound = sound.SoundPygame(value=stimulussound)
sound.play()
if (currentTime > lengthofsound):
timerClock.reset()
window.flip()
if (currentTime <= timefixationcross):
#fixatiekruis
Fixationcross.fixationscross(window)
#getKeys j of f = inputuser
if event.getKeys('j'):
inputuser = 'j'
reactiontime = currentTime
elif event.getKeys('f'):
inputuser = 'f'
reactiontime = currentTime
else:
inputuser = "geen input of foute knop gebruikt"
reactiontime = "geen reactie"
inputsuser.append(inputuser)
reactiontimesuser.append(reactiontime)
#closing the window
start == False
window.close()