From 7a6fae8e11d8babc0e1d14f71630fb243841d3db Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Thu, 7 Jul 2022 18:05:29 -0500 Subject: Write some ideas about the design and toolchain of M --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ad9832..e5bc315 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,24 @@ # M -A minimal and ergonomic music programming language, inspired by Lisp \ No newline at end of file +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. -- cgit v1.2.3-70-g09d2