Howdy, Stranger!

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

Supported by

[open] Counting variable

DanDan
edited August 2015 in OpenSesame

Dear all,
based on a very simple script, we use a loop to generate a sound ("synth") with random variation between two defined frequencies (220 and 440 Hz). Via "feedback", we would like to print the number of each of the two sounds, so that the screen permanently shows the number of high/low tones which had been generated so far. Unfortunately, the standard variable "count__synth220" counts ALL tones, although synth220 is only executed in about 50%. Is there another way to count such Events (like "n=n+1")?
Thanks!
Dan

Comments

  • edited 4:26AM

    Hi Dan,

    You have the right idea. Before you enter the sequence, in which you select the sounds, you have to initialize two counters, for each sound one. You can do it from within an inline_script.

    two20 = 0
    four40 = 0
    

    Later, in the sequence of sound selection, you can place another inline_script after sound selection and increment the counter by one, depending on which sound was chosen.

    if played_sound == 220:
        two20 += 1
    elif played_sound == 220:
        four40 += 1 
    

    Does this do what you want?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.