[solved] "Cancel" sampler playback on keypress?
Hi there!
I am just trying to build up an experiment in which subjects have to respond to an audio stimulus as quickly as they can, with a maximum of 1000ms after the audio playback is finished to respond. However, I'd like them to be able to respond even while the file is still playing. Now I've managed to do that on the surface in a sequence of sketchpad->sampler->keyboard_response->logger, but I have to either live with having the sampler play out and then waiting for the keyboard_response to collect a response that was given while playing, which makes me unsure of how to deal with the response time, or I manage to skip from sampler with finish on keypress and timeout set to the files duration for the sampler, but then the sampler keeps playing into the next stimulus. So, I guess my question essentially is whether it is possible to somehow "stop" or "cancel" all samplers that are currently playing audio at the end of my sequence?
Thanks, Florian.
Comments
Hi Florian,
Yes, sure. You can achieve this with (something like) the following sequence.
This directly accesses the PyGame mixer. You can find out more about this here: http://www.pygame.org/docs/ref/mixer.html
Does this work for you and/ or answer your question?
Cheers and happy Easter!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you Sebastian, that works a treat!
I've also added an inline script to the beginning of the loop, setting the variable response_timeout to the duration of my cue (which I have extracted before and inserted into the loop's table) + 1000, and then set the timeout in the keyboard_response to [response_timeout] to give the 1s timeout after playback is finished.
cue_duration = self.get("cue_duration")self.experiment.set("response_timeout", cue_duration+1000)
Just in case anybody diggs this up in the future :-)
And a happy Easter to you too! Florian
Hi All,
I am building a Stroop experiment (words) where during the trial the participant has to listen to some music (to test its effects on Stroop performance), I have built the experiment and all is working as expected, except one thing:
I have the following
The problem is, because the 'sampler' is in a 'sequence', after every stimulus (word + keyboard press) the music is repeating itself and gets all scrambled.
I just want the music to play once continuously during the trials, and then end, (the end section works fine), I just cant figure out to stop the music repeating itself during the loop of trials.
Help, I am so close to finishing this experiment, just need to nail this final bit.
Thanks
Paul
Hi Paul,
If I understand correctly, the only thing you need to do is to put the sampler with the music at the start of the experiment sequence, rather than in the trial sequence. That way it will start once, and keep playing in the background while the experiment continues.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!