a bytebeat interpreter
keyboard required (the typing kind) {.is-info}
this script is still a work-in-progress. expect bugs and usability issues {.is-danger}
;install https://github.com/midouest/bitebeet
this script installs a custom ugen and engine. A reboot will be required the first time the script is launched. {.is-info}
Enter bytebeat expressions by typing on a connected keyboard. text will wrap automatically when the screen extents are reached.
scrolling is not yet implemented. The window can currently fit roughly 8 rows of 16 characters with the current font settings (128 characters). {.is-warning}
ENTER
= evaluate expressionESC
= reset t
variable to 0
BACKSPACE
= delete previous characterARROW KEYS
= navigationThe interpreter supports a subset of the C programming language expression syntax.
example: (the so called crowd bytebeat):
((t<<1)^((t<<1)+(t>>7)&t>>12))|t>>(4-(1^7&(t>>19)))|t>>7
spaces are treated as whitespace and ignored {.is-info}
Expressions may contain a single variable, t
The
t
variable is automatically incremented at 8khz. {.is-info}
variable assignment is not supported {.is-warning}
constants come in two forms: integers and strings.
integers may be positive or negative
example: 42
, 0
, -8
strings are enclosed in double-quotes
example: "hello, world!"
integers may be provided in decimal or hexadecimal format. hexadecimal integers must be preceeded with
0x
. example:0x1000
,0xdeadbeef
{.is-info}
+
(add)-
(subtract)*
(multiply)/
(divide)%
(modulo)syntax: <left-operand> <operator> <right-operand>
example: (t+1)*(t+2)
Each operand of an operator must be an integer constant, the variable
t
, or an expression that evaluates to an integer. {.is-info}
Operators follow c operator precedence rules. expressions can be wrapped in parenthesis to control evaluation order {.is-info}
division or modulo by 0 produces an internal “undefined” value. The undefined value propagates through the bytebeat expression and appears as silence in the final output. {.is-warning}
&
(and)|
(or)^
(xor)<<
(shift left)>>
(shift right)~
(invert)example: (t>>8)^t
same rules apply as for mathematical operators {.is-info}
<
(less than)>
(greater than)<=
(less than or equal)>=
(greater than or equal)==
(equal)!=
(not equal)!
(not)same rules apply as for mathematical operators {.is-info}
boolean (true/false) values produced by relational operators will be converted to integers using c conversion rules.
true
will become1
,false
will become0
, and vice versa. {.is-info}
syntax: <conditional> ? <if-true> : <if-false>
example: t%32<16?t>>4:t>>2
integers will be converted to booleans using c conversion rules (see above). {.is-info}
the branches of an if expression can produce strings or integers {.is-info}
syntax: "<string>"[<expression>]
example: "<3 norns"[(t>>12)%8]*t>>3&t>>4
the result of the array subscript operation will be an 8-bit character. This character will be converted to an integer according to its ascii representation {.is-info}
the interpreter performs bounds-checking when indexing string values. accessing out-of-bounds indices produces the internal undefined value (see above). It is recommended to limit index expressions to the length of the string being indexed using the modulo operator:
"<string>"[(<expression>)%<length>]
{.is-warning}
(0, 255)
8-bit output is converted linearly to (-1.0, 1.0)
for audio output