references
a cheat sheet for when you're writing your own songs. new to bytebeat? start with the guide first.
learn more
this page is only a short compilation. there's a lot more out there about bytebeat, so go do some research of your own! these are good places to start:
- algorithmic symphonies from one line of code viznut's 2011 blog post that started bytebeat. explains how and why it works.
- discovering novel computer music techniques the follow-up paper by viznut. goes deeper into why these formulas sound like music.
- bytebeat composer another online editor with a big library of songs other people made. good for ideas.
- mdn: bitwise and (&) how & works on bits, with examples.
- mdn: right shift (>>) how >> works on bits, with examples.
operators
t | the sample counter. goes up by 1, 8000 times a second. |
+ - * / | normal math. + also mixes two sounds together. |
% | remainder. t % 256 does the same wrap bytebeat does anyway. |
& | bitwise and. keeps only the bits both sides share. & 128 makes a square wave. |
| | bitwise or. keeps bits from either side. gives a crunchy, glitchy mix. |
^ | bitwise xor. keeps bits that are on in only one side. |
>> | shift right. >> 1 halves, >> 2 quarters, and so on. used for slow counters. |
<< | shift left. << 1 doubles. |
~ | flips every bit. ~t counts down instead of up. |
a > b | comparison. gives 1 if true, 0 if false. |
[a, b, c][i] | array. picks the item at position i (starting at 0). |
operators run in this order, from first to last:
*/%+->><<><&^|
if you're unsure, add brackets.
timing
at 8000 samples a second, each shift doubles how long a step lasts:
| counter | one step | good for |
|---|---|---|
t >> 10 | ~0.13 s | fast notes |
t >> 11 | ~0.26 s | one beat |
t >> 12 | ~0.5 s | a melody note |
t >> 13 | ~1 s | a bar |
t >> 14 | ~2 s | a chord |
t >> 16 | ~8 s | a song section |
add & 3, & 7 or & 15 to make the counter loop over 4, 8 or 16 steps.
snippets
building blocks you can copy into your song.
sawtooth
square
triangle
sine
noise
kick drum
beat pattern
things to know
- the output wraps at 256, so keep the parts you add together small.
- a line that starts with
(or[joins onto the line above. end the line above with;. - math functions work without
Math., likesin(t),random()orPI. - doubling a number moves a note up one octave. 4 : 5 : 6 is a major chord.