Skip to content

Variables

Serge Zaitsev edited this page Apr 22, 2017 · 1 revision

Time

t

t is increased at the rate of 8000/sec. It's helpful in Bytebeat, but can also be used to advance song parts automatically.

You may create your own counters that will be increased on every frame. Glitch formula is evaluated on every frame, so you can write counter = counter+1. Relying on t might be easier because it doesn't depend on the sample rate of your sound card.

bpm

By default bpm is not set and Glitch synchronizes the playback with the formula as soon as you change it.

For live coding it's desirable to make synchronizations in the rhythm of the song. You can set bpm to a number of beats per second and the song will be synced on the next beat. To sync a song on every 4 beats put a lower bpm value, for example bpm = 120/4.

MIDI

Keyboard

Every key pressed on a MIDI keyboard appears as a k0...k9 variable in Glitch. The variables are fulfilled from k0 onward, so if you play with one finger - use k0 only, if you play 3 notes at a time - use k0, k1 and k2.

k0...k9 store the note index of a key.

v0...v9 store the velocity of the note. These values have an automatic release phase when the key is release, so there is no "clicks".

g0...g9 store "gate" signal of a key. They are similar to v0...v9, but when the key is released these variables are set to NaN immediately.

x and y

Two most common controllers - pitch bend and modulation wheel - are mapped to x and y variables respectively.

If you use Glitch with a GUI - you can also use mouse pointer to change x and y values.

Constants

Note constants

Every note in the range of nine octaves has a pre-defined variable: C0, C#0, Db0, D0, E0, ..., C4, ...A#8, B8. Use these instead of numeric constants if possible to keep you formula readable.

Drum constants

For TR808 there are some helpful constants - BD, SD, MT, MC, RS, CP, CB, OH, HH. See documentation for tr808 function for more details.

Clone this wiki locally