Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Recording multiple keypresses during audio

Hello,
I am working on an experiment where the participant listens to audio files and needs to hit the spacebar every time the language or speaker changes. There should be many keypresses during each 40-60 second audio file, but the exact number will be different for each participant/audio file. I don't care about the duration of the keypress, but the number of keypresses and exact timing of each of them (relative to the beginning of the audio file) are important. I've looked through previous discussions asking similar questions to try to incorporate those suggestions, but this is my first time using OpenSesame and I am a beginner programmer, so I'm stuck and having trouble implementing what I've seen. Can anybody offer some suggestions on ways to do this?
Thanks! --Erika

Comments

  • Hi Erika,

    You could make the sound playback be followed by a loop which only contains a keyboard item and a logger. So every time a key is pressed, the response is logged and the keyboard waits for the next trial. The only tricky part is to exit the loop once the sound file finished playing.

    Alternatively, you can implement the sample principle in an inline_script, with a while loop routine. Here the pseudo code:

    1) Prepare and start playing the sound
    2) Start a while loop that runs as long as the sound is supposed to play
    3) Repeatedly wait for a key press and log the keypress if it occurred

    The function necessary to run this, you can find here:

    Does that make sense?

    Eduard

  • Eduard -- Thank you for the advice, that solution worked perfectly for me!

    -Erika

Sign In or Register to comment.