Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Repeating Audio Stimulus within the same trial

sadeksadek Posts: 8
edited December 2017 in OpenSesame

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

  • sebastiaansebastiaan Posts: 2,950

    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], where replay_response is a variable that defines the replay response, if that makes sense.

    Like so:

    What do you think?

    Cheers,
    Sebastiaan

    image.png 90.4K

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • sadeksadek Posts: 8

    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

  • eduardeduard Posts: 1,115

    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 . and python. 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

  • sebastiaansebastiaan Posts: 2,950

    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 a mouse_response item. (So you don't really need a touch_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

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.