Bytebeat is the name of type of music made from math.
You provide a function who's only input is time t and from that write some code to generate a sound.
In this particular case t is an 8000hz timer that counts up. For example
sin(t) * 127 + 127
You can choose traditional bytebeat where the output of your function is expected to be 0 to 255 or you can choose floatbeat where the output is expected to be -1 to +1.
Here are a few sample songs
- http://goo.gl/KABRP glitch machine
- http://goo.gl/MtkP38 octo
- http://goo.gl/0UO8Kx seargeant
- http://goo.gl/TcKUSp splatterpiller
- http://goo.gl/pD3lx kb 2011-10-04
- http://goo.gl/MuQWe ryg 2011-10-10
- http://goo.gl/rFNPL blueberry 2011-10-05
- http://goo.gl/lQyDd mu6k
- http://goo.gl/6Uz0d mix 2 channels
- http://goo.gl/6cC5gK quiddit
- http://goo.gl/RG8IEk rythymgrind
- http://goo.gl/QRjRf8 robot toothbrush
- http://goo.gl/Vk6WPK number machine
- http://goo.gl/4dOPIJ starlost
- http://goo.gl/VHm5c7 guitarhead
There 2 modes
- bytebeat: Your expression is expected to generate byte values from 0 to 255
- floatbeat: Your expression is expected to generate float values from -1.0 to 1.0
- Infix: Standard expressions eg. "(t * 2) / 4"
- Postfix(rpn): Reverse Polish Notation eg "t 2 * 4 /"
- glitch: glitch format or glitch urls.
is the same as
Postfix requires that each element have at least one space between it.
t2* // BAD! t 2 * // Good!
If you're unfamiliar with postfix see below
Glitch is a format used by glitch machine for sharing. Examples
These can be prefixed with "glitch://". For example
There's a bunch more here. I have a feeling there's a bug or 2 left for full glitch support
Postfix in this case I guess can be described as forth like. It works with a stack. Each command either adds things to the stack or uses what's on the stack to do something. For example
123 // pushes 123 on the stack stack = 123 456 // pushes 456 on the stack stack = 123, 456 + // pop the stop 2 things on the stack // adds them, puts the result on the // stack stack = 569
Note the stack is only 256 elements deep. If you push 257 elements it wraps around. Similary if you use
with a large value your pick will wrap around. The stack is neither cleared nor reset on each iteration
of your function. Some postfix based bytebeat songs take advantage of this where each iteration leaves
things on the stack for the next iteration.
The postfix operators are
These take the top two things from the stack, do the comparision, then push 0xFFFFFFFF if the result
is true or 0x0 if the result is false. Think of it has follows: If the TOP thing on the stack is
the next thing on the stack then 0xFFFFFFFF else 0x0
removes the top thing from the stack
duplicates the top thing on the stack.
swaps the top 2 things on the stack
pops the top thing from the stack and duplicates one item that many items back. In other words
if the stack is
pick pops the top thing
3 and duplicates
the 3rd thing back counting from 0, which is no
4. The stack is then
Another way to look at it is
dup is the same as
sets the n'th element from the top of the stack to the current top. In other words if the stack is
1,2,3,4,5,6,7,3,100 then put will pull the top
100 and then set the
3 element back. The stack
will then be
These operators all pop the top value from the stack, apply the operator, then push the result on the stack
These operators pop the top 2 values from the stack, apply the operator, then push the result. The order is as follows
b = pop a = pop push(a op b)
In other words
4 2 / is 4 divided by 2.
Pops the top of the stack, applies the binary negate to it, pushes the result.
Comments can be both // or /* */ style
There are several extra inputs available
The mouse position is available as
sin(t * mouseX * 0.001) + cos(t * mouseY * 0.003)
The size of the window is available
The orientation of a device may be available as
(sin(t * 0.1 * tiltX) + cos(t * tiltY * 0.07)) * 0.5
Also note, using the comma operator you can write fairly arbitrary code. See this example.
For more info
Check out http://canonical.org/~kragen/bytebeat/ and be sure follow the many links.