1
Fork 0
No description
Find a file
2025-11-25 21:48:37 +01:00
playground move files to subdir 2025-11-13 21:26:03 +01:00
src Make play interruptible 2025-11-25 21:48:37 +01:00
.gitignore Write ogg output 2025-11-16 15:39:00 +01:00
Cargo.lock Make play interruptible 2025-11-25 21:48:37 +01:00
Cargo.toml Make play interruptible 2025-11-25 21:48:37 +01:00
idea.md mark things as done 2025-11-13 21:27:24 +01:00
LICENSE-APACHE License and expand readme 2025-11-16 22:24:42 +01:00
LICENSE-MIT License and expand readme 2025-11-16 22:24:42 +01:00
music_formula_collection.txt Move bytebat to toplevel 2025-11-13 21:26:29 +01:00
README.md name it bytebeats 2025-11-16 23:14:24 +01:00
run-all.sh one more should parse now 2025-11-20 23:37:35 +01:00

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)

  • QBE (override: QBE)
  • FFmpeg (override: FFMPEG)
  • as, GNU or Clang works (override: AS)

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

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0).