So I have been trying to come up with a system that I can work with. The system needs to be readable and flexible like a score. Music scores use some tricks analogous to compression techniques. One example is repeat marks, but there are a few others - eg key signatures, GoTo (
The idea is to create a language representing musical notes which can be read by a human and easily interpreted. But I thought I need to stop myself here. I've never written a language before, so I'm bound to make mistakes the first time round.
The first consideration is relative note values (or duration). The main system is binary - note values being divided by two: whole note, half note, quarter note etc... Dividing by two is arbitary because a note can be divided by any integer. If you write code that says play 440 Htz for a duration of 1.4 seconds, you will have to be a superhuman-number-whizz kid to spot how all numeric values in your code relate to each other. With midi it probably looks something like this __/\_/¯¯¯|_|\/¯¯¯¯ (nice)
So my plan was to loosely follow rules of notation and use symbols with a vaguely similar appearance to notes in a score. The first thing to consider is that pitch and duration are separate values also separated visually in written music. The rhythm is indicated by a system of stems flags and note head types. The pitch is indicated by vertical note position. So my first thought was to separate the notes from their duration. I can write notes ABC etc followed by their corresponding durations.
A,B,C D1,D2,D3
The rhythm values (D1,D2,D3) need to look more like note values, so here's my visually motivated selection:
L Long (not used) o Lower case o - Open note without stem - whole note þ Thorn - Open note + stem - Half note or minim • Bullet - Closed note - Quarter note or crotchet - Minus sign - Single flag - Eighth note = Equals sign - Double flag - Sixteenth note † Sword - Tripple flag - Thirty-second note † Double Sword - Quadruple flag - Sixty-fourth Note (very rare) Relative values o þþ •••• ---- ---- ==== ==== ==== ==== †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† <= These are meant to be double swords. Forum code tags are playing up.
This is now looking a bit more like music. I can group notes and recognize them visually. An interpreter would not necessarily care about the groups or spaces unless instructed otherwise. With a few more symbols I can create strings that relay practically all standard performance instructions found in written music.
The following string represents the music for 'Happy Birthday to You' in the key of D major (2#): It includes a few other symbols such as colon representing repeat marks, triplet divisions (3) and move the octave range up or down ( ^ v ).
2#AABA¬^DCv:^EDvAA^AFDCvB^GGFDED •3-3••¬•þ:•þ•3-3••••••3-3•••þ
This is easy to write, read and parse. We can set the tempo to any value and there is more. Does anyone have any thoughts/comments on this idea? Are there any downsides that I may have overlooked, or suggestions? Thanks in advance.
Edit
Without the repeat marks the rhythm could look like this:
$strToParse = "•3 -3 • • • þ •3 -3 • • • þ •3 -3 • • • • • •3 -3 • • • þ" ;Hap py birth day to you Hap py birth day to you Hap py birth day dear La La La La La La La La
Adding bar lines gives a clearer indication of meaning:
•3-3|••¬•|þ:|•|þ•3-3|•••|•••3-3|•••|þ
Unlike a midi stream (or so I believe), the time signature does not need to be indicated. This is one of the fundamental flaws of midi files. Instead of addressing the minimum requirements and building the language up from basic principles, they started with the false premise that the language needed to conform to strict theoretical rules (mus). Not all music is like that, and it's an inflexible approach which I would like to avoid.
Edited by czardas, 12 April 2012 - 01:29 AM.






