Howdy, Stranger!

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

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.



  • 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?


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

  • 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.