Repeating Audio Stimulus within the same trial
Hello. I have a touchscreen-based task that presents an image stimulus with an audio stimulus. Participants need to tap on the correct image so that the word is properly matched with the image, then the next trial appears. I wanted to include an option so that the audio stimulus can be played again if the participant wanted to hear it a second time (or third or fourth etc.). I’ve been trying to find a way to figure this out, but it has a been a bit challenging. I basically want participants to have the option to press 'spacebar' in order to repeat the audio stimulus. Is there a way to do that?
I've tried including this in line script but then participants have to press spacebar to move to the next trial (the touch response won't be registered unless space was hit), so that didn't work. There may be a completely different way of doing this, but this is what I've tried..
kb = keyboard()
key,time = kb.get_key(keylist = ['space'], timeout = None)
if key == 'space':
my_sampler = sampler("path" + str(var.stimulus_sound), volume = 1)
my_sampler.play()
I have attached a simple experiment file (with image attachments, couldn't upload the recordings, but you could use any audio I suppose).
Any help would be appreciated.
Sadek
Comments
Hi Sadek,
Collecting touch (=mouse) and keyboard input at the same time is possible, but it will require either some inline scripting, or coroutines.
However, isn't it easier in your case to reserve part of the display so that participants can tap on it to play the sound again? And then you embed the sound and the touch response in a loop that breaks when the participant does not touch on the part of the display that corresponds to the replay button; that is, the break-if statement could be
[response] != [replay_response]
, wherereplay_response
is a variable that defines the replay response, if that makes sense.Like so:
What do you think?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thanks for this suggestion, it looks like it could really work. I was thinking about how I would reserve a part of the display so participants can tap on to play the sound again, and I'm not sure how I would go about doing that. If I have the touch_response item to 2 X 2, then there would only be those four quadrant coordinates on the screen that will allow for a touch response to be made in. If I were to include a separate replay button, what would it consist of and how would I initialize it as a touch response icon that is separate from the four quadrants that are essentially one of the four responses the participant can make?
Also, a completely different question. How did you create the python interface for the script in my first comment? I only knew how to paste it in, but the box and format is much clearer and nicer.
I appreciate your help on all of this.
Sadek
Hi Sadek,
These interfaces are based on markdown. It makes it easy to write nicely structured text. For the code example in particular.
you have to include three tildes
~
+ a dot.
andpython
. On the next line you begin writing your code, and when your finished. you add three more tildes. (or just look it up on wikipedia).Good luck,
Edaurd
Hi Sadek,
The next version of OpenSesame (3.2) has a new feature that does exactly what you need: You can give names to the elements of a
sketchpad
, and then use these element names as regions of interest in amouse_response
item. (So you don't really need atouch_response
anymore.)See:
My recommendation would be to download the prerelease of 3.2, and use this functionality, which will make life much easier. OpenSesame 3.2 is not tagged stable yet, but it's close enough for me to recommend it at this point.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!