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

sampler duration: sound/keypress the first


I have an experiment with auditory instractions as well as writen.
When I press a key to move to the next slide, if the sound did not finish, it's continue playing the two slides simultaneously.

How can I tell the sampler to stop when keypress?
Right now, I wrote keypress in the duration, and it moves to the next slide without stoping the audio.



  • eduardeduard Posts: 1,170

    Hi Nachshon,

    I recommend you don't use the sampler function to play back the sounds, but an inline_script. The procedure is quite straight forward. Put an inline_script before your instruction slide and put this code into the prepare phase of it:

    src = pool['sound.ogg'] #whatever your soundrecording is
    my_sampler = sampler(src, volume=.5)

    and then another inline_script after respective instruction slide with the single line my_sampler.stop() in the run phase.

    Does that make sense?


    Thanked by 1Korem N
  • Korem NKorem N Posts: 6

    Yes, but I have 10 a lot of instractions slides as it is... The experiment is for children.

  • eduardeduard Posts: 1,170

    Well, then, you have to do that 10 times. If you wrap everything into a loop/sequence, you have to write the code only once. In that case you would formulate your instruction as text in the loop table.


Sign In or Register to comment.