I have a simple set up where a different sound is played based on a slider rating. For example, a sound file with the note C is played when the slider rating is 1, and the note D is played when the slider rating is 2 etc.
The problem is that each sound file will play only once. I want the participant to be able to “play” with the slider and change their selection, and the corresponding sound file to play whenever the selection on the slider changes.
Any ideas?
Hello,
do you mind showing how you have achieved this sofar?
Best wishes Jens
I have one slider, and the sounds are set to play based on the slider.rating value:
# *slider_1* updates
if slider_1.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
slider_1.frameNStart = frameN # exact frame index
slider_1.tStart = t # local t and not account for scr refresh
slider_1.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(slider_1, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'slider_1.started')
slider_1.setAutoDraw(True)
# start/stop sound1_1
if sound1_1.status == NOT_STARTED and slider_1.rating == 1:
# keep track of start time/frame for later
sound1_1.frameNStart = frameN # exact frame index
sound1_1.tStart = t # local t and not account for scr refresh
sound1_1.tStartRefresh = tThisFlipGlobal # on global time
# add timestamp to datafile
thisExp.addData('sound1_1.started', t)
sound1_1.play() # start the sound (it finishes automatically)
# start/stop sound1_2
if sound1_2.status == NOT_STARTED and slider_1.rating == 2:
# keep track of start time/frame for later
sound1_2.frameNStart = frameN # exact frame index
sound1_2.tStart = t # local t and not account for scr refresh
sound1_2.tStartRefresh = tThisFlipGlobal # on global time
# add timestamp to datafile
thisExp.addData('sound1_2.started', tThisFlipGlobal)
sound1_2.play(when=win) # sync with win flip
Hello,
you posted this in the category Builder. Where/Wen do you execute this code?
Best wishes Jens
After playing with the builder for a while I figured I’ll have to do it with code…
I execute this code at each frame