toggle

Poly-rhythm generator

To create a poly-rhythm generator, this example chooses a division and articulates every attack point of that division. Use a metro synched to the transport to specify the divisions (or the tempo object, if preferred), and then use a counter (or a % object with the output of tempo) to specify the articulation points.

Turn files on and off

This example shows how you can turn on and off audio files with a single toggle –– as in swapping between one and the other. Since 1 is on and 0 is off, you can use a == 0 object to produce the opposite (to turn one thing off when you turn the other on and vice versa). This can be seen in action in the example on the left.

Random semitone trills

A trill can be thought of as a fast back-and-forth alternation between two pitches—or more generally as fast back-and-forth alternation between any two things or states. A back-and-forth or on-off switch can be implemented in any programming language by setting a boolean variable (a variable that's capable of having only one of two states) to its opposite state, with an expression in the form of "If it's 'X', set it to 'NOT X', otherwise, set it to 'X'."