Song File Format

From IPRE Wiki
Jump to: navigation, search

A Myro song is composed of lines like:


where [] means optional. Each of these notes/chords is composed on its own line, or separated by semicolons where:

    NOTE1 is either a frequency or a NOTENAME
    NOTE2 is the same, and optional. Use for Chords.
    WHOLEPART is a number representing how much of
              a whole note to play.

NOTENAMES are case-insensitive strings. Here is an entire scale of NOTENAMES:

C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B C

This is the default octave. It is also the 5th octave, which can also be written like:

C5 C#5/Db5 D5 D#5/Eb5 E5 F5 F#5/Gb5 G5 G#5/Ab5 A5 A#5/Bb5 B5 C5

The Myro Song Format replicates the keys on the piano, and so goes from A0 to C8. The middle octave on a keyboard is number 4, but we use 5 as the default octave. See for additional details. Here is a scale:

"C 1; C# 1; D 1; D# 1; E 1; F 1; F# 1; G 1; G# 1; A 1; A# 1; B 1; C 1;"

and the scale one octave lower, and played as a polka:

"C4 1; C#4 1/2; D4 1/2; D#4 1; E4 1/2; F4 1/2; F#4 1; G4 1/2; G#4 1/2; A4 1; A#4 1/2; B4 1/2; C4 1;"

There are also a few other special note names, including PAUSE, REST, you can leave the octave number off of the default octave notes if you wish. Use "#" for sharp, and "b" for flat.

WHOLEPART can either be a decimal notation, or division. For example:

Ab2 .125


Ab2 1/8

represents the A flat in the second octave (two below middle).

As an example, the beginning of Jingle Bells looks like:

C .125
C .125
D F .25
REST .25
C .25
F .25

You may leave blank lines, and comments should begin with a # sign. Lines can also be separated with a semicolon.

Using a song

Now that you have a song, you probably will want to play it. If your song is in a file, you can read it:

s = readSong(filename)

and play it


You can also use makeSong(text) to make a song. For example:

s = makeSong("c 1; d 1; e 1; f 1; g 1; a 1; b 1; c7 1;")

and then play it as above.

If you want to make it play faster or slower, you could change all of the WHOLENOTE numbers. But, if we just want to change the tempo, there is an easier way:

robot.playSong(s, .75)

The second argument to playSong is the duration of a whole note in seconds. Standard tempo plays a whole note in about .5 seconds. Larger numbers will play slower, and smaller numbers play faster.


robot.playSong(song) - have robot play a song

saveSong(song, append = 1) - save a song to a file

readSong(filename) - read in a song file

song2text(song) - convert a song to text format

makeSong(text) - convert text format to a song

text2song(text) - same as above