Previous topic

Frequency Modulation

Next topic

Remote Control

This Page

Control Flow with Select()

switch PositiveLimitSwitch {
        default:        off
        reset:          MasterReset
        meta:           'Is ON when positive limit is crossed'
}

switch NegativeLimitSwitch {
        default:        off
        reset:          MasterReset
        meta:           'Is ON when negative limit is crossed'
}

signal SineWave {
        default:        0.0
        rate:           AudioRate
        reset:          MasterReset
        meta:           'Sine wave at 10 Hz amplitude at 1.2'
}

signal ClippedSineWave {
        default:        0.0
        rate:           AudioRate
        reset:          MasterReset
        meta:           'Sine wave at 10 Hz clipped at 1.0'
}

Oscillator (
        type:           'Sine'
        amplitude:      1.2
        frequency:      10.0
        phase:          0.0
        reset:          off
)
>> SineWave;

SineWave
>> Compare (
        value:          [ 1.0, -1.0 ]
        operator:       [ 'Greater', 'Less' ]
)
>> [ PositiveLimitSwitch, NegativeLimitSwitch ]
>> DigitalOut[1:2];

PositiveLimitSwitch
>> Select (
        whenOn:         1.0
        whenOff:        SineWave
)
ClippedSineWave;

NegativeLimitSwitch
>> Select (
        whenOn:         -1.0
        whenOff:        ClippedSineWave;
)
>> AudioOut[1:2];