Howdy, Stranger!

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

Supported by

random sounds during visual illusion

ANRANR
edited April 2016 in OpenSesame

Hey guys,
I am trying to randomly pick sounds from a file pool and play them at randomly picked time intervals while showing a visual illusion (which is implemented in a while-loop which flickers between two versions of the stimulus until a certain time passed).
I thought I could just use the sampler item, but ran into two problems:

1) all sounds are being played at the same time at the beginning of the instructions (implemented as sketchpad).

2) both, the self.sleep and the core.wait, functions that I tried to use to make the sounds play at random intervals also pause the visual stimulus, which makes it pretty much useless.

Is there maybe a way to create two windows (one for the visual and one for the sound) that are called at the same time?

I am very inexperienced in using openSesame, so hopefully one of you has an idea how to fix this!

Comments

  • edited 2:58AM

    Hi,

    Could it be that the commands that play your sounds are placed in the prepare phase of an inline_script? Prepare phases are run before everything else, so that could explain why you hear your sounds right away..

    And yes, the self.sleep() command really let's the whole experiment sleep, so you can't use it for only a single object. The solution would be to keep track of time in a separate variable, for instance as such:

     start_time = self.time()
    

    and then in the while loop:

     current_time = self.time() - start_time
     if current_time = your_randomly_chosen_time_interval:
            your_sound.play()
    

    Does this help?

    Cheers,

    Josh

  • ANRANR
    edited 2:58AM

    Yes! I had the sampler items in the sequence, which made them all play at the same time after the script was done. Deleting those got rid of that.
    And the timing also works now with a new variable, thanks a bunch!

  • edited 2:58AM

    Hi Josh, I'm running a somewhat similar experiment to ANR and seem to be having trouble with the code. At the moment it's randomising the playback time that's giving me trouble. I used your method above but when I print the current_time variable I'm getting 0. I'm assuming the problem is that the start_time variable is constantly updating and so the values of current_time and start_time are always equal. Any help you could offer would be greatly appreciated. My code is below.

    time = range(0, 1000)
    play_time = random.choice(time)
    print play_time

    start_time = self.time()
    current_time = self.time() - start_time
    print current_time
    if current_time == play_time:
    deviant.play()

  • edited 2:58AM

    I have solved the issue myself. Very new to programming and didn't realise that I would need to set up a while loop to have the current_time constantly update.

Sign In or Register to comment.