Glitch Machine’s editor allows 16 lines of “code,” and each line can contain up to 16 operators and/or numbers. The separate lines just make editing easier, and also allow you to use the line-muting feature (tap/click a line of code to mute/unmute it).
It doesn’t matter how much or how little code goes on each line… the whole expression behaves as one line of code.
t 2 * t 5 >> |
Is the same as this:
t 2 * t 5 >> |
Which is the same as this:
t 2 * t 5 >> |
The expression is simply calculated left to right, top to bottom, once per time tick (t).
With RPN you enter the numbers first, and then the operator, unlike typical “infix” mathematical notation. So:
1 + 2 * 3
Looks like this in RPN:
1 2 + 3 *
The numbers are placed on a “stack,” which in Glitch Machine has a limit of 256 values. You push numbers onto the stack simply by entering them in the editor:
1 2 3 4 5
This puts five values on the stack. They are pushed onto the stack in order from left to right; 1 is on the bottom of the stack, and 5 is on top. Doing the following:
…adds the top two values on the stack, which in this case results in 9. Thus, the stack now contains the values [1 2 3 9].
Typing in the following will give you 15 as a result:
1 2 3 4 5 + + + +
Here is another way to express the same calculation:
5 4 + 3 + 2 + 1 +
At the end of your expression, Glitch Machine takes the top value of the stack and converts it to audio output. If the status at the top of the screen says “stack:1” then there is one number on the stack, which is enough for Glitch Machine to make sound. Any value for the stack greater than 0 will produce output.
It is OK to leave more than 1 value on the stack, but only the top value will be used. These extra stack values may be used to create a sequence of notes, or read in a future sample update (using PICK) as a form of audio feedback.
If the stack value reports 0, or a negative number, then this is a stack underflow; no sound will be produced.
Some of operators are “bitwise” operators, meaning they operate on the digital representation of the numbers themselves, which are formed from strings of binary “bits” or 1’s and 0’s. Wikipedia’s entry on Bitwise operation.
Glitch Machine uses the following bitwise operators:
>> (shift right)
<< (shift left) The | operator is especially useful for mixing different elements of your expression together. The >> operator is often used to create timed beats and note sequences. For example:
t 4 >>
…shifts the ‘t’ value to the right by 4 bits, which effectively divides it by 16 (right-shifting by 1 bit divides the input value by 2). This creates a sawtooth waveform with a frequency of ~1.95Hz. Now, mix this with a simple sawtooth note (t 2 *), using the | operator:
t 4 >> t 2 * |
Multiple beats can be mixed for more a complex pattern:
t 4 >> t 5 >> | t 2 * |
This tutorial is a work in progress. If you have specific questions you’d like answered in the tutorial, then leave a comment below!