Skip to content
A helper script for writing music in the form of small c programs
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A helper script for writing music in the form of small c programs

Inspired by this blog post:

There are already several online implementations of this, mostly in javascript. However, none of them allow you to download the resulting file, and using the online version requires you to be online. Since it's already so easy to do this from the command line, I figured -- why not write a helper script, in good UNIX style, to provide the means to listen to and record these experiments?


  • zsh
  • sox (with soxplay)
  • a c compiler with support for the -o flag

Usage: ./ -cc compiler -rate bitrate -duration seconds script filename.wav

If you provide an output filename, the script will produce a file with that filename, whether or not one already exists. If you do not provide an output filename, it will use sox to play the result.


./ 't&t>>8' # play the plain vanilla 'sierpinski harmony'

./ -rate 8000 '((t\*(t>>8|t>>9)&46&t>>8))^(t&t>>13|t>>6)' # play xpansive's 'Lost in Space' from

For a lot of interesting examples, try viznut's collection of notable one-line music formulas. To try to build your own more scientifically, take a look at his blog post, analysing the attributes of these formulas.

You can’t perform that action at this time.