trill

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'."