An esoteric programming language based on musical notation.
To build the amuse executable, do the following:
$ cabal configure
$ cabal build
The built executable can be found in dist/build/amuse/
or,
alternatively, installed to $HOME/.cabal/bin/
with:
$ cabal install
Amuse works by reading in MIDI files and executing commands based on the note parsed. The following table shows what command corresponds to what note.
Note | Command | Alternate |
---|---|---|
C | Succ | Pred |
C# | InChar | InNum |
D | Swap | NOP |
D# | LoopBegin | Continue |
E | Dup | Over |
F | Drop | NOP |
F# | LoopEnd | Break |
G | Add | Sub |
G# | CompareEQ | CompareGT |
A | Mult | Div |
A# | Alternate | NOP |
B | PrintNum |
The commands are explained below.
Adds the top two elements of the stack and pushes the result to the stack.
E.g. [2, 3, 4] -> [5, 4]
Alternate specifies that the following command should execute its alternate form.
E.g. Alternate + Note C -> Pred
Breaks out of a loop and continues execution past the next LoopEnd.
CompareEQ checks if the top two stack elements are equal. If true, execution continues normally. Otherwise, execution skips the next instruction.
CompareGT checks if the second element of the stack is greater than the top element of the stack. If true,execution continues normally. Otherwise, execution skips the next instruction.
E.g. [2, 3, 4] -> true
Continue automatically jumps back to the previous LoopBegin.
Div - Divide - Divides the second element of the stack from the first element of the stack.
E.g. [2, 3, 4] -> [3/2, 4]
Drops the top element of the stack.
E.g. [2, 3, 4] -> [3, 4]
Dup - Duplicate - duplicates the top element of the stack.
E.g. [2, 3, 4] -> [2, 2, 3, 4]
InChar - Input Character - awaits user input for a character and pushes it onto the stack.
InNum - Input Number - awaits user input for a number and pushes it onto the stack.
LoopBegin signals the beginning of a loop.
LoopEnd signals the end of a loop. Always loops back to the last LoopBegin.
Mult - Multiply - Multiplies the top two elements of the stack and pushes the result to the top of the stack.
E.g. [2, 3, 4] -> [6, 4]
NOP - No Operation - does nothing. Might be reserved for more functionality.
Over pushes a opy of the second element of the stack onto the stack.
E.g. [2, 3, 4] -> [3, 2, 3, 4]
Pred - Predecessor - decrements the value of the top of the stack
Print outputs all of the values in the stack until the NULL
character: '\0'
.
PrintNum - Print Number - prints the raw value of the top element of the stack.
Sub - Subtract - subtracts the top two numbers (first from the second) and pushes the result to the top of the stack.
E.g. [2, 3, 4] -> [1, 4
Succ - Successor - increments the value of the top of the stack]
Swap swaps the top two elements of the stack.
E.g. [2, 3, 4] -> [3, 2, 4]
The following program echoes back any number and exits when 0 is entered.
- Implement track switching for sub-program functionality.
- Better error handling.
- Clean up codebase.
- Add more examples.
- Change note bindings based on frequency of use and interval.
- Allow printing without newline
- Change the stack to use numbers instead of characters.