About Bytebeat
Bytebeat is a type of music, discovered in 2011, where a simple computer program is used to generate musical waveforms.
The program is typically a single line of code, a mathematical formula that takes a time variable t (an integer that increments for each sample) and returns an 8-bit value (0-255). This value is then used directly as the audio sample's amplitude.
The surprisingly complex and often chaotic sounds are a form of generative art. The short expressions can produce a wide variety of soundscapes, from glitchy noise to melodic tunes and rhythmic patterns. Experiment with the formulas above or write your own!
Bytebeat Cheat Sheet
A quick guide to common bytebeat techniques. Click on code examples to load them into the editor.
1. Pitch and Tone
The simplest way to create a tone is to multiply t by a number. The result is a sawtooth wave. Higher numbers produce higher pitches.
t * 42
Right-shifting t (t >> N) divides its frequency by powers of two, creating lower octaves.
t >> 4 * 42
2. Rhythm and Tempo
You can create rhythmic patterns by using bitwise operations on time. The expression t >> N creates a pattern that repeats every 2^N samples.
A simple kick drum sound:
(t & t >> 7) | t >> 4
A simple hi-hat sound:
(t * 5 & t >> 7) | (t * 3 & t >> 10)
You can create sequences using the modulo operator % or by accessing characters in a string.
"11112222..."[(t >> 12)%16] * t
3. Timbre and Waveform
Different operations create different waveform shapes (timbres). Mix signals with bitwise operators like | (OR), & (AND), and ^ (XOR).
Mixing two frequencies with OR:
(t * 30) | (t * 32)
Mixing with XOR for a metallic sound:
(t * 30) ^ (t * 32)
Using Math.sin() for a pure sine wave. Remember to scale the output to the 0-255 range.
Math.sin(t/100) * 127 + 128
4. Amplitude and Volume
Control volume by reducing the final amplitude. Bitwise AND (&) with a number smaller than 255, or right-shifting (>>) the entire expression, can lower the volume.
Normal volume:
t * 42
Quieter version:
(t * 42) & 127
Even quieter:
(t * 42) >> 2