Previous topic

Random Number Generation

Next topic

Latching a Switch

This Page

Bypassing with Switches

Add an example without onChange first and then explain the difference.

switch Gate {
        default:        off
        reset:          MasterReset
        meta:           "On, when analog in 1 is greater than or equal to 5"
}

ControlIn[1]
>> OnChange(
        bypass: off
)
>> Compare (
        value:          0.5
        operator:       'GreaterOrEqual'
)
>> Gate;

AudioIn[1]
>> Level (
        gainType:       'Linear'
        gain:           0.0
        offset:         0.0
        bypass:         Gate
)
>> AudioOut[1];

AudioIn[2]
>> Level (
        gainType:       'Linear'
        gain:           0.0
        offset:         0.0
        bypass:         not Gate
)
>> AudioOut[2];

The last two stream expression in the previous example can be written as follows:

AudioIn[1:2]
>> Level (
        gainType:       [ 'Linear', 'Linear']
        gain:           [ 0.0, 0.0 ]
        offset:         [ 0.0, 0.0 ]
        bypass:         [ Gate, not Gate]
)
>> AudioOut[1:2];

The following code is also equivalent:

AudioIn[1:2]
>> Level (
        gainType:       'Linear'
        gain:           0.0
        offset:         0.0
        bypass:         [ Gate, not Gate]
)
>> AudioOut[1:2];