switch()

switch(test, valueIfPositive, valueIfNegative)

Category

Envelope / Control

Description

Conditional selector. It chooses between two values depending on whether the first argument is positive or negative.

Switching curve

switch switching curve

Example: switch(squa(X),saw(X),sin(X))

Arguments

Typical Values

Use moderate values first, then increase modulation depth while listening for clipping, aliasing, or excessive filter resonance.

Example

switch(sin(pos()/4000), saw(X), squa(X))

Notes

For pitched oscillator functions, X already contains the current MIDI note pitch and transpose information. Prefer saw(X), sin(X), or pwm(X, 0.4) unless you intentionally want an octave or ratio shift such as 0.5*X or 2*X.