I have played music for a long time, but it’s only within the last year or so that I have learned how to read standard notation. Reading music is awesome! This got me thinking about how we use the computer to notate music and how we share it online

In this document I will describe a new format for notating music. The format uses only ASCII characters, it is readable by humans, parsable by computers. It is small and easy to learn.

First I’ll discuss how we currently notate and share written music, then I’ll introduce you to the actual format: Plain Music

Discussion & Introduction

To understand were we’re coming from, we should first examine which formats are currently used. Some of the major players are:

  • MIDI
  • Music XML
  • PDF
  • Images (jpg, png, svg, etc.)
  • Proprietary formats
  • ABC notation

MIDI is an old, widespread way of exchanging digitally notated music . It was conceived in the early 1980’s by Dave Smith, and was first used as a means of communication between music hardware.

My main issue with MIDI is that it is a binary format. To edit or view a MIDI file you will need a special program. This makes cumbersome to use and share.

Another problem with MIDI is that it is too general. With automation, channels , and arbitrary note rhythms it captures a complete performance, rather than just a musical idea.

The redeeming factor of MIDI is how much it is used. You should be able to find a MIDI version of pretty much any song you look for.

MusicXML™ is an XML based format developed by Make Music Inc., and is used in their Finale music notating software. According to Wikipedia it is supported by over 210 notation programs - fairly widespread it seems.

The fact that it is based on XML is both a strength and a weakness. XML is nice because it is widely supported – all major programming languages has tools for handling XML content.

XML is bad because it is verbose and hard to read by humans (IMO). Take a look at the example in the Wikipedia article: 848 characters and 37 lines of XML is required to make a stave with one note.

Sheet music in PDF format can be of very high quality, but it is not editable after the fact – PDF an opaque and heavy format. The same goes image formats.

ABC notation is a bit more unknown, but still popular , especially in the traditional/folk music scene. It was invented in the late 1970’s and was primarily intended for reading by humans, as opposed to parsing by computers.

Though ABC is a nice plain text based format, it suffers from some quirkiness. It has some weird edge cases and shortcuts, some of which are:

  • It has the hornpipe notation D>G which means 1/8 dotted D and 1/16 G.
  • It uses accidentals like standard notation.
  • It supports repeats, which can be notated several different ways.
  • It has several kinds of bar lines that mean the same thing.
  • Tune headers have non-obvious single letter names.

These quirks reduces human readability and severely complicates computer parsing. However, in my opinion, it is still the best format we have discussed so far.

Plain Music takes a lot of inspiration from ABC, but eliminates some of the quirks. A more regular format should make the music easier to read for humans as well as computers.

Plain Music Notation

Let us jump right in and write some music:

{c}

This is a C4 1/4-note at 120bmp. A note is the smallest possible part of a piece of music. A note has a pitch (in this case C4) and a duration (1/4 by default) at a specific tempo (120bpm by default).

Pitch

The pitch of a note is indicated by it’s letter. c was C4. Likewise g is G4. We can write the full fourth octave like:

c d e f g a b

Accidentals

If we want to make the pitch of a note sharp of flat we append s or l. I wanted to use # and b, but since b is also the name of a note I decided on s for sharp and l for “low”. So if we want to write a C-minor scale it looks like:

c d el f g al bl

Unlike standard notation, accidentals do not persist. If you write cs c is means C#4 C4, where it would mean C#4 C#4 in standard notation.

Octaves

Of course we want more octaves than just the fourth one. By appending ^ we transpose the pitch up an octave, so c^ is C5. By appending _ we transpose down an octave, so c_ is C3. Lets write some octaves:

c_ d_ e_ f_ g_ a_ b_ c d e f g a b c^ d^ e^ f^ g^ a^ b^ c^^

A note can be transposed as many times as you’d like. So cl__ is Cb2, c^^ is C6, and c_____^^^^^ is C4.

The octave mark should come after accidentals, so cs^ is valid, but c^s is not.

Duration & Rhythm

The default duration of a note is 1/4, which is why c is a 1/4-note. You can double the duration by appending +, so c+ is a 2/4-note, and c++ is a 4/4-note. You can halve the duration by appending -, so c- is an 1/8-note, c-- is a 1/16-note.

Like standard notation, notes can be dotted. This is done by appending ., so c. is a 3/8-note, and c-. is a 3/16-note.

Rests

To indicate rests, or “no pitch”, we use r as the pitch character. The duration a rest is the same as a normal note, so r is a 1/4-rest, r-. is a 3/16-rest, and r++ is a 4/4-rest.

Chords & Harmonies

If we want to write chords or harmonies we enclose the notes in <and >. We can then write a CM chord as <ceg>. Octave marks and accidentals can appear both inside and after the harmony, so <celg>_+ is a C minor chord in the third octave. Duration marks can only appear after a harmony, not inside it, for example the harmony <ce-g> is not allowed.

Grouping

Sometimes you want to use many of the same modifiers in a row. It could, for example, be a line of eight notes:

c- e- g- c- e- g- c- e- g-

To avoid repeating -, we can group the notes using ( and ), so instead we can write:

(ceg ceg ceg)-

Like harmonies, modifiers can appear both inside and after the group. Unlike harmonies, duration marks are allowed inside groups, for example (ce-g)+ is perfectly valid.

Tuplets

Tuplets (triplets, quituplets, etc.) are kind of weird; they way we write them in standard notation carry some implicit knowledge. If we write the 3 over some notes for a triplet, we actually mean 3:2, read as three for two.

To express tuplets in Plain Music we add for example /3:2 after a group of notes to get a triplet. To get a quituplet we would add /5:4 after the group. For example:

{ (ccc)-/3:2 (ccc)-/3:2 (ccccc)-/5:4 | c++ }

This notation makes the tuplet explicit and allows for any kind of tuplet. If we wanted to, we could make weird tuplets like /21:16 or /1:100.

Voices & Staves

In standard notation some instruments, such as piano, requires two staves. Sometimes a single stave can have multiple voices; sometimes we want to write a piece for multiple instruments. For this we use stave and voice notation.

A stave is notated starting with { and ending with }, so a short piece could be:

{r c e g}

We can another stave to that:

{r c e g}
{<ceg>_++}

You can have as many staves as you like.

Voices are notated as staves inside staves – also with { and }. We can use this to add a second voice to our first stave:

{ {r c e g} {f_ f_ a_ c} }
{<ceg>_++}

We can also add bar lines to our stave. Bar lines doesn’t effect the music in any way – they are included only for the sake of readability. Bar lines are notated with |, for example:

{ r c e g | r d g b | r f a c^ | r g b d^ | c^++ }

Articulation

Articulation is how a specific note should be played. In Plain Music there are three kinds of articulation marks: accents, slurs and staccato marks.

Accents are notated by adding ! after a note, signalling that it should receive special emphasis. For example:

{ r c e g | c++! }

Slur lines are used to signal that notes should be played legato – without breaks between the notes. For this append ~ to the note note, which can be read as “play legato with the next note”. An example:

{r c~ e~ g }

This is equivalent to drawing a slur line above C E G in standard notation. If a slur is used between notes of the same pitch, it is effectively a tie. This can simplify rhythmic notation, and tie notes across bar lines:

{ r g e c~ | c++ }

To indicate that a note should be play staccato, you add * after the note. For example:

{ r c* e* g* }

Instructions

If the standard articulation marks aren’t expressive enough, you can add instructions to the music. The is done by writing 'instruction' in text.

For example if we wanted the music to be played with a lot of emotion we could add the instruction:

{ 'Tres expressif' c e g c^ }

Instructions can also be used to show chord changes, for example:

{ 'C' c e g c^ | 'F' c f a c^ }

Commands

With what we’ve covered so far, you should be able to write pretty much any piece of western music. However, some pieces may be hard to notate and maybe you want to provide some additional context to the music. To do that we use commands.

Commands can provide meta data or modify the way the music is interpreted. Commands follow the form:

[command-name: value]

Commands can be specific to the implementation of Plain Music you are using, but there are some standard ones, which are described here.

Meta Data Commands

Meta data commands doesn’t affect the music, but provide some extra information. The standard ones are: author, title, and date. Example:

[author: Pelle Juul]
[title: Example Music]
[date: 2017-03-09]
{ r g e c~ | c++ }

The date should be in ISO8601 format.

Unrecognized commands are considered meta data, so if we included a command like [subtitle: Example 1], it would work just fine.

Rendering Commands

Rendering commands provide information used when Plain Music is performed or converted to other formats. The standard ones are: key, tempo, meter, clef, and instrument.

They key command is used for converting Plain Music to standard notation. Its value is the sharps or flats of the key. For example, if our piece is in D major, we would write:

[key: fs cs]

The tempo command specifies the tempo in beats per minute. If the tempo command is excluded the tempo defaults to 120 1/4 beats per minute.

The meter command specifies the meter of the music. So if our music is in e.g. 6/8 we write:

[meter: 6/8]

The clef command is also used for converting to standard notation. It specifies which kind of clef to draw on the stave. Supported clef values are: g, c and f. The default value is g.

The instrument command specifies which instrument the music is intended for.

Modifier commands

Modifier commands change the way the music should be read, which can make the tune more readable and writable. The modifying commands are: note-duration, and transpose.

The note-duration command changes the default note duration, which is 1/4 . So if we write [note-duration: 1/8] then c will be a 1/8 note, c- will be a 1/16 note, and so on.

The transpose command transposes the music by a number of half-steps. This is useful for writing music in low or high registers, example:

{ c__ e__ g__ c__ }

Is equivalent to

[transpose: -24] { c e g c }

How Commands Apply

Commands apply to all following staves, so if we write:

[instrument: violin]
[transpose: 12]
{ r c e g }
{ c c c c }

Then both staves are for violin and both are transposed up an octave.

The same command can be used multiple times, so that they can affect different staves. Say we wanted to write a piece for two hand piano, we would write it as:

[instrument: piano-right]
[clef: g]
{ r c e g }

[instrument: piano-left]
[clef: f]
[transpose: -12]
{ c c c c }

Commands Inside the Stave

Commands can also appear inside the stave. For example if we wanted a change of meter from 4/4 to 3/4 we would write:

[meter: 4/4]
{ r c e g | [meter: 3/4] c e g }

White Space and Style

White space and line breaks are most ignored, so the music { r c e g } could just as well be written as {rceg}. We could also write it like

{ r
                  c
e


g}

It doesn’t matter. The same goes for commands, e.g. if we had a lyrics command:

[lyrics:
  Ma - ry had a lit - tle lamb,
  li - tle lamb,
  li - tle lamb
]

For the sake of readability, you should use white space and bar lines. A nice touch is to space subdivided notes such that they add up to a 1/4-note . An example:

{ (ce gc)- g c | (cegc cegc)-- e g | c++ }

Here the ce, gc, and cegc notes all add up to 1/4.

A place where white space is note allowed is between the note and its modifiers . So something like cs^ ++ is not allowed (it should be cs^++).

Comments

Comments are added by writing # comment. Comments span from the # to the end of the line. Example:

# The follwing stave contains two bars with six notes
# Three 1/4 notes
# Two 1/8 notes
# One 4/4 note
{ r c e (gg)- | c++ } # This is the stave
# The music ends here

Intended Use and Tooling

Plain Music is intended to allow people to share and write written music in a clear, easy way, without relying on heavyweight software. Because it is terse and only uses ASCII text, it is well suited for the web.

To encourage use of Plain Music, some tools should be developed. Some essential ones are:

  • Parser and generator libraries
  • Plain Music to standard notation converter
  • MIDI to and form Plain Music converter
  • MusicXML to and form Plain Music converter

An Example

For completeness sake, we should provide a full example. Here is the Plain Music of Mary Had a Little Lamb for piano, with chords and melody:

[key: fs] # G Major
[instrument: piano-left]
# Melody in the right hand:
{ b a g a | b b b+  | a a a+  | b d^ d^+
| b a g a | b b b b | a a b a | g+ r a  }

[instrument: piano-right]
[transpose: -12]
# Chords in the left hand:
{ <gbd^>++ | <gbd^>++ | <fsad^>++| <gbd^>++
| <gbd^>++ | <gbd^>++ | <fsad^>++| <gbd^>++ }

I hope you’ve enjoyed this article on Plain Music. You can follow – and contribute to – the development of Plain Music at the GitHub repository.