Howdy, Stranger!

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

Supported by

[solved] ending a synth event during another event?

edited September 2011 in OpenSesame
Hi,
I'm having a blast creating an experiment in OpenSesame, it's a very intuitive and powerful framework. In one part, I'm trying to add some noise to video stimuli, so I created a "synth" white-noise event and made the duration longer than the longest movie. The noise starts, the movie starts immediately after and so they overlap nicely, but I'd like the noise to stop as soon as the movie does (and the movies are variable in length). Is there any command I can put in at the end of the movie event (or at the start of a following sketch event) that would terminate a currently running synth event?
Thanks! OpenSesame Rocks!
Mark

Comments

  • edited September 2011

    Hi Mark,

    Glad you like it!

    Yes, that's possible, but it will take a little Python code. Very little, actually. Let's assume that your synth item is simply called "synth". You then insert an inline_script (at some point in the experiment where you want playback to stop) with the following code in the run phase:
    self.experiment.items["synth"].sampler.stop()

    There's a lot of references here, so let's go through them one by one:

    • self → the inline_script item
    • self.experiment → the experiment (is a property of all items)
    • self.experiment.items → a Python dictionary which contains all items of the experiment
    • self.experiment.items["synth"] → the synth item
    • self.experiment.items["synth"].sampler → the synth object that's being used by the synth item (the synth is just a wrapper around the sampler that generates its own sampler).

    You can find a list of all synth functions here: http://osdoc.cogsci.nl/python-inline-code/synth-functions

    Hope this helps!

    Kindest regards,
    Sebastiaan

  • edited 8:14PM

    [solved] Thanks! Works like a charm!
    Mark

Sign In or Register to comment.