Programmatic music library
Go to file
2022-07-07 18:05:29 -05:00
.gitignore Initial commit 2022-07-07 17:47:24 -05:00
LICENSE Initial commit 2022-07-07 17:47:24 -05:00
README.md Write some ideas about the design and toolchain of M 2022-07-07 18:05:29 -05:00

M

A minimal and ergonomic music programming language, inspired by Lisp

Design

A M source code file has the extension .m and is basically a Scheme program with some extra spice. All lines that start with an open parenthesis, space, or tab are treated as lines of a normal Scheme program. Lines that do not start with those characters correspond to generating a music tone at a certain time. These lines have the following format:

401/2A   441/2A   471/2A

Each line consists of multiple notes separated by tab characters. You can use any Scheme variables in for these notes instead of actual numbers. It's recommended to set your tab size to 8 so the notes in different lines are aligned.

Each note consists of multiple characters:

  1. The first character is the octave.
  2. The second is the step of the scale it's on in base 12, so 0 is equivalent to the traditional A, A is equivalent to the traditional G, and B is equivlanet to the traditional G sharp.
  3. The next few characters are the length of the note. This can be a fraction.
  4. The final character is a modifier that changes some property of the note, such as its volume.

Toolchain

The M compiler mcc will first interpret the Scheme program and generate an M intermediate format file with file extension .min. This file consists of all the music tone lines that the compiler ran into while interpreting the Scheme program. This can be then played by the mplay tool or converted to formats like .mp3 with mcon.

The m wrapper tool automates this process and will compile and play an M file if no output is specified, or convert it to the desired output format if specified.