Syntax
File structure
Each line of a Musicline file is either empty, an event, or a comment.
An event can appear zero or more times in a file. When multiple events are present, they must be in ascending order by point value, with repeating points allowed.
The parser ignores empty lines and comments.
Event
An event is formed of a point, a voice, a type, and data for some of the types.
Horizontal whitespace is used to separate an event's parts. It may also precede and/or succeed the event.
# For simplicity, shown without horizontal whitespace.
point voice type (data)?
# With horizontal whitespace.
hws* point hws+ voice hws+ type (hws+ data)? hws*
NOTE
There's also an event short-form in which both the voice and type are omitted.
For details, see the short-form section near the end of this page.
Point
A point indicates a position in time, space, or any other numerical sequence like a collection of masses. It is left for applications to determine which measurement unit is represented by points, e.g., seconds, beats, minutes, hours, years, centimeters, meters, kilograms, etc.
A point is any nonnegative real. Leading zeros are not permitted.
# Valid points.
0
42
42.
.42
42.42
# Nonvalid points.
-42
042
042.
042.42
Voice
A voice refers to the musical voice of an event.
It consists of one or more nonnegative integers separated by underscores. Leading zeros are not permitted in any of the nonnegative integer parts.
The underscore is used to divide a voice into subvoices, subvoices into sub-subvoices, and so on to any depth. This is similar to how a flute staff in an orchestral score can be divided into various flute parts, e.g., 1
could refer to a flute staff, while 1_2
could refer to the second flute of that staff.
0
should be reserved for global information. This is useful for data that applies to all voices in the given hierarchy, e.g., a tempo change, a marker, etc. 1_0
could be used to set the tempo on a flute staff of two flutes: 1_1
and 1_2
. Note that this is optional. Any event type may be used in any voice.
# Valid voices. (Preceded by a point of 0)
0 0
0 1
0 42
0 0_1
0 42_0_1
0 42_1_0
Type and data
Musicline has six event types, some of which include associated data.
Marker
A marker labels a section, such as an intro, a coda, etc.
It must be accompanied by a piece of data composed of Unicode characters that form one or more words. This data starts with the first nonwhitespace character and ends with the last one.
# Valid markers.
0 1 marker intro
0 1 marker section I part II
0 1 marker @42
0 1 marker #4b384c
0 1 marker 😎
# Nonvalid marker.
0 1 marker
Muted
The muted type is for notes that should not be played.
Muted data is the same as note data. (see note section)
TIP
This is helpful when composing or experimenting as it allows notes to be muted without having to delete their data.
# Valid muted type.
0 1 muted run-of-the-mill note data
# Nonvalid muted type.
0 1 muted
Note
A note represents a piece of data to be played.
Like a marker, it must be accompanied by a piece of data composed of Unicode characters that form one or more words. This data also starts with the first nonwhitespace character and ends with the last one.
# Valid notes.
0 1 note ré
0 1 note F B D♯ G♯
0 1 note ᓚᘏᗢ
# Nonvalid note.
0 1 note
Rest
A moment of sweet nothingness.
A rest does not have associated data.
# Valid rest.
0 1 rest
# Nonvalid rests.
0 1 rest data
0 1 rest some data
Tail
A tail indicates the end of an event without a subsequent event. It is not required, but it is convenient for pinpointing the end of a sequence.
Imagine two consecutive notes — a C and a D — each lasting one second. C is an event at point 0
. D is an event at point 1
. While D shows when C ends, a tail is needed to show when D ends.
0 1 note C
1 1 note D
2 1 tail
A tail has no associated data.
# Valid tail.
0 1 tail
# Nonvalid tails.
0 1 tail data
0 1 tail some data
Tempo
The tempo type specifies the tempo in beats per minute (BPM).
Tempo data is a nonnegative real. Leading zeros are not permitted.
TIP
Although the unwinding speed of Musicline's events is already hard-coded in its event points when their measurement unit is seconds, tempo indications are valuable for triggering changes in other instruments, generating scores, and/or writing translations into other languages, such as Lilypond.
# Valid tempi.
0 1 tempo 0
0 1 tempo 90
0 1 tempo 90.5
# Nonvalid tempi.
0 1 tempo
0 1 tempo -60
0 1 tempo 90 120
Short-form
Musicline offers a short-form for both note and rest types.
With it, the voice defaults to 1
, and the event type is omitted. An event with data is a note; one without is a rest.
To avoid confusion between a voice and short-form note data beginning with a digit, such note data must be escaped using a backslash \
. If the short-form note data begins with a backlash, it too must be escaped using a backslash \
.
Below are short-forms coupled with their long-forms:
# Short-forms.
0
1 Euridice
2 This is a note.
3 \42Hz
4 \\42\
# Long-forms.
0 1 rest
1 1 note Euridice
2 1 note This is a note.
3 1 note 42Hz
4 1 note \42\
NOTE
Both short-form and long-form may be intermingled in the same file.
Comment
A Musicline comment is initiated with the hash character #
and continues until the end of the line. It may be indented by horizontal whitespace, but may not follow an event.
# This is a comment.
# This too is a comment.
0 # This is a note, not a comment!
0 1 note # This too is a note, not a comment!