No description
| playground | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| idea.md | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| music_formula_collection.txt | ||
| README.md | ||
| run-all.sh | ||
bytebeats
Inspired by algorithmic symphonies from one line of code I completely overengineered a compiler that takes in a (binary) arithmetic expression and turns that into a program that generates sound.
And I mean overengineered:
flowchart TD
A[formula expression]
A@{ shape: text } -->B
B[Parser] -->|transform to QBE IR| C
C[QBE] -->|transform to asm| D
D[assembler] --> E
E[object file]
E@{ shape: doc } -->|extract bytes of synth fn| F
F[load synth fn] --> G
G["t in 0..n: play(synth(t))"]
Features
- Configurable duration and sample rate
- REPL
- Tested on Linux and macOS
- Wav and OGG output
Runtime requirements
(can be overriden using environment variables)
Install
cargo install --git https://git.fnordig.de/jer/bytebeats
Usage
OPTIONS:
-d, --duration <duration>
Play duration (in seconds) for every formula. Default: 3s
-s, --sample-rate <rate>
Sample rate. Default: 8000
-e, --execute <execute>
Formula to execute
-t, --tree
Show parse tree
-q, --qbe
Show QBE code
-b, --bin
Show binary code
-n, --no-sound
No sound. Don't actually play formulas.
-w, --wav <wav>
Save to wav. No sound will be played.
-g, --ogg <ogg>
Save to ogg. No sound will be played.
-h, --help
Prints help information.
Examples
bytebeat -e t
bytebeat -e t*3
bytebeat -d 15 -e 't*(42&t>>10)'
bytebeat -d 30 -e 't*(0xCA98>>(t>>9&14)&15)|t>>8' -s 44100
bytebeat -d 30 -e 't*(0xCA98>>(t>>9&14)&15)|t>>8' -s 8000 -g output.ogg
Sources
- My Experience of building bytebeat player in Zig
- Some deep analysis of one-line music programs.
- Algorithmic symphonies from one line of code -- how and why?
License
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).