Build experiment with replayable audio stimuli and slider responses

Hi all,

Please be gentle, as I have no coding experience and am attempting to build an experiment on psychopy builder in which participants will hear 256 audio stimuli and respond to seven different questions with a slider. The sticking point is that I want participants to be able to replay the audio (from a wav file) for each stimulus as many times as they like by pressing a certain key and to move onto the next stimulus with another.
Questions are: 1. Can anyone explain whether and how I can do this in builder or point me to a tutorial.
2. Can I do this using one looped routine?

Thanks in advance,
Tim

OS : MacOS Mojave
PsychoPy version : v3.2.4
Standard Standalone? (y/n) Y
What are you trying to achieve?: build an experiment with audio stimuli that participants are able to replay by pressing a key.

**What did you try to make it work?: I have looked at youtube online tutorials but have not seen one yet that addresses this particular area.

You need to have two loops surrounding your routine, one nested inside the other.

  • The outer loop is connected to your conditions file and is probably what you already have in place - it will iterate once per trial.
  • The inner loop is not connected to a conditions file. Instead, it is just set to have an nReps value that is much higher than the number of times you think someone might repeat a stimulus (say, 100). It will iterate once per presentation of the audio stimulus, so somewhere between once and many times per trial.

What you then need to do is control when the inner loop terminates, so that the next iteration of the outer loop will proceed (i.e. go on to the next trial). Otherwise, it will just keep repeating the routine. To do this, insert a code component (from the “custom” component panel). In the “end routine” tab of that component, put something like this (changing to use your actual names):

if 'right' in your_keyboard_component.keys:
    your_inner_loop_name.finished = True

i.e. imagine you set your keyboard component to accept only two keys, the 'left' and 'right' arrow keys. The component is set to force the end of the routine if either is pushed. If the user pushed 'right', then exit the inner loop so the next trial can proceed. We don’t need to do anything about the 'left' key being pushed, as the inner loop will just automatically keep running until we tell it to stop.

If you have your task split across two or more routines (the first to play the sound, and subsequent ones to gather ratings), the inner loop will only surround the audio routine.