Howdy, Stranger!

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

Supported by

[open] Help needed: sampler

edited April 2015 in OpenSesame

Dear Community,

I am entirely new to open sesame and have no experience whatsoever with programming. I'm a bit desperate at the moment because I can't figure out a probably simple element of the experiment I need to make:
A 5 minutes long sound file is supposed to be playing and whenever the mouse (or a key, that doesn't really matter) is pressed, a 5 seconds long noise is supposed to be heard. But since the experiment is run in a sequence I can't figure out how to implement the short sound into the long sound in a way that it would be played whenever the mouse (or key) is pressed.
I kind of have the same problem with a little text that is supposed to appear on the screen while the long sound is playing. I want them to start at the same time but right now the sound doesn't start but after the text has been displayed alone for a while.

Can somebody please help me with that?
I would be so grateful.

Thanks

Comments

  • edited 7:09AM

    Hi Mona,

    How to go about this depends on a couple of things. For one, do people need to be allowed to press a button (and initialize the 5 second noise) multiple times during those 5 minutes, or just once in order to move on? And secondly, does the 5minute long soundfile have to be played from beginning to end regardless of when a button is pressed (only to be interrupted for 5 seconds by the noise, for instance)?

    It may be good to know that you can set the duration of the sampler item to 'keypress' or 'mouseclick' as well; in other words, the sound would play until a button is pressed. (if you click on the sampler item, you see the 'duration' parameter at the bottom).
    In case the 5 second sound should be played multiple times with multiple button presses, the 5 second sampler item should be placed in a sequence, which in itself is placed in a loop item. This loop could then repeat the sequence for, say, 5 minutes, so that during these 5 minutes the button press and 5 second sound item can occur multiple times. If you click on the loop item, you can check a box to show advanced options, revealing a 'break-if' parameter. Here you could, for instance, insert something that makes you break out of the loop when a timer has reached 5 minutes. You would have to make a variable (in an inline_script item, placed before the loop) that keeps track of time; see http://osdoc.cogsci.nl/python/inline-script/#function-inline_scripttime ).

    Inside the sequence, you can place a keyboard_response item (and in this item, be sure to tick the button with the question balloon to learn how it works!). After the keyboard_response, you can place the 5 second sample item. Now clicking the sequence item, a window will open showing the items you put in the sequence, with the 'run-if' column set to 'always' for all items. Of course you only want to play the sound file if a button is pressed, so you would insert: =self.get('response') != 'none' (meaning the sampler would be activated if the keyboard response was NOT equal to 'none', i.e. if a button was pressed). Lastly, you would place another inline_script item in the sequence, that updates the timer variable.

    Undoubtedly you'll encounter some problems here and there - therefore it's recommended to browse through this site: http://osdoc.cogsci.nl/ , and visit some tutorials in particular.
    And of course I'm willing to answer any follow-up question you have.

    Good luck!

    Cheers,

    Josh

Sign In or Register to comment.