Musical-X

From Esolang
Jump to: navigation, search

Musical-X is an esoteric programming language whose source code consists entirely of music, invented by User:Zzo38.

You can only play one note at a time and rests are ignored. The first note indicates what key it is written in (it must be a major key). The commands exist between every 2 adjacent notes and depend on the interval between them, compound intervals are the same as simple intervals, and they are all considered to be notes in the major key (if they aren't, both the first and second note of the command are rounded up, so that you can play minor keys as well if you prefer). Unisons or octaves (simple or compound) are ignored as if they were only a single note, rather than two equivalent notes.

There are many infinite tapes as in Brainfuck with values 0-255, each tape has a separate pointer, and each tape is named with one note. The initial tape is the note at the beginning of the program.

Commands
2nd up Increment value at pointer (mod 256).
2nd down Decrement value at pointer (mod 256).
3rd up Move tape pointer one space forward.
3rd down Move tape pointer one space backward.
4th up Input value at pointer.
4th down Output value at pointer.
5th up Select tape indicated by second note.
5th down Move to initial position of current tape.
6th up If value at pointer is non-zero, then search backward to command with a first note the same note as the second note of this command.
6th down If value at pointer is zero, then search forward to command with a first note the same note as the first note of this command.
7th up Interpret next command as in Auxiliary list #1.
7th down Change key to the second note of this command.
Auxiliary list #1
2nd up Increase value at pointer by 64 (mod 256).
2nd down Decrease value at pointer by 64 (mod 256).
3rd up Move tape pointer 64 spaces forward.
3rd down Move tape pointer 64 spaces backward.
4th up Change notes not of this key to round up instead of down.
4th down Change notes not of this key to round down instead of up.
5th up Select tape indicated by first note.
5th down Skip next command.
6th up If value at pointer is even, then search backward to command with a first note the same note as the second note of this command.
6th down If value at pointer is odd, then search forward to command with a first note the same note as the first note of this command.
7th up (RESERVED)
7th down (RESERVED)

Examples

(Note: These examples are given using the PLAY syntax in QBASIC.)

Program to copy input to output until chr(0):

"l8mlo2c16p16c16f.<a-16e-.a-16>fl32e-<e->e-<e->e-<e->e-<e->"

See also

Musical notes, another esolang based on music.