prezjordan/Melopy — Issue #33: Syntax for writing music using Melopy
Author: prezjordan
Created: 2012-01-03 04:50:28+00:00
State: open

## So an idea I've had for a while...

I now want to bring to life. The main purpose of Melopy was too allow me to write **melo**dies with **py**thon code. This looks great with Melopy's functions, but I'm looking to add something cool to `utility` - a parser for a new syntax used for writing music.

## Goal

It started with the idea of Mary Had a Little Lamb.

4|EDCDEEE-DDD-EGG-EDCDEEEEDDEDC

What does this do? First it read's the octave. 4. Then a pipe - then some notes. The letters will correspond to notes in the pre-defined octave, and dashes represent rests. From here I decided to conjure up a sort of syntax.

## Basics

From here I decided that each new line could be read as a change in octave. For instance, if we were to play the C major scale...

4|CDEFGAB
5|C

We would need to jump to the 5th octave. We do this by going to the next line, defining the octave again, and continuing to write our notes.

So what kind of notes are these? Well, like music - I wanted the "default" so-to-speak to be quarter notes. From here, we could shorten them, or make them longer. As follows.

* nothing - a quarter note `example: ABC`
* () - half the time. `meaning A(BC) is a quarter note A followed by two eighth notes, B and C`
* (()) - one quarter the time. `we can have various levels of parenthesis to make faster notes.`
* [ ] - double the time. `[A] becomes a half-note A and [[D]] becomes a whole note D`
* Both apply to rests. `((-)) is a sixteenth rest and [-] is a half rest.`
* { } - grouped notes become a chord. `{DF#A} would correspond to D major`
* || - double pipe allows you to change octave without entering a new line
* `4|{A||5|E}||4| ...` corresponds to A major (see how we had to jump an octave? (and come back)

## Future

That's all I have for now as far as syntax goes. We need to add things that allow you to define the waveform, title, etc before the actual notes. This is a design decision that needs to be made. We also need syntax for ties.

The important thing is to be very thorough in your documentation.

As far as a file goes, I believe this should be placed in utility.py as the method `parse()`