-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax of Muselang
Warning: This is a Draft
Every Muselang script contains of "music units" - that can be notes, phrases, loops, chords etc
Every music unit has a syntax associated with it. For example, C# quater 100
means "Note C# of quarter duration with 100% velocity".
Muselang interpreter reads script file from top to bottom, creating MIDI sequence containing all music units written in the script, and then plays that sequence or save it to a file (depending on the command given to the Muselang)
Muselang has support of comments (comments are any text, that is ignored by interpreter and is intended for programer). Any text starting with //
is treated as comment:
// This is a comment
C D E // This is a comment too
phrase test { // Probably description of the phrase
// Another comment
}
(Note: In code, "notes" are abstract pitches associated with name like "D#", while "notes with duration and velocity" are called "score note" meaning "note written in a score")
Syntax: <Note Name> [<Duration> [<Volume (Velocity)>]]
Meaning:
When Muselang meets this syntax element in code, it just plays the given note for a given duration with a given velocity (volume).
Note Name can be note letter, note letter with sharp (#
), note letter with octave number or note letter sharp and octave number. Default octave is 5th.
Example of note names:
C
same as C5
, meaning "C of 5th octave"
D
same as D5
, meaning "D of 5th octave"
C#
same as C#5
, meaning "C# of 5th octave"
C#3
, meaning "C# of 3th octave"
D1
,
E6
,
etc..
Note: E#
or B#
is not valid note names.
Duration or/and Volume can be omitted (see they are in []
brackets, this means that this part of syntax can be omitted).
Duration can be an integer like 1, 2, 4, 8, 16 etc (meaning 1/1, 1/2, 1/4, 1/8, 1/16 note durations respectively).
Also Duration can be written as a word or letter, possible values:
half
or h
same as 2
,
quarter
or q
same as 4
,
eight
or e
same as 8
,
sixteenth
or st
same as 16
,
If Duration is omitted, default value of 4 is assumed. (So all notes where you omit the duration are quarter notes)
Volume is an integer from 0 to 100, where 0 is no volume and 100 is max volume. If the Volume is omitted, the default value of 100 is assumed.
Example of Notes:
C quarter 100
,
C
,
C5
,
C5 eight 54
same as C5 8 54
,
D#3 2 90
same as D#3 half 90
,
etc
Syntax: repeat <Times> { <Body> }
Meaning:
When you want to repeat some melody part few times, you have several ways to do it. First one is "copy-pasting" of that melody (not a true way), and the second way is using the repeat
operator.
repeat
plays the melody written between { and } (it can be any valid melody, it may even contain more "repeats", which may have "repeats" too etc) several times.
is how many times to repeat the . It can be any integer greater or equal to 1 (so you can write
repeat 1 {
C
D
E
}
to play C D E
once)
Example of repeat usage:
repeat 3 { C }
plays C C C
,
repeat 3 { C D# }
plays C D# C D# C D#
,
repeat 100 {
C eighth 100
D
E
F
G
A
B
}
Syntax: (<Note1>[, <Note2>[, <Note3>, [...]]])
Meaning:
Muselang also supports playing more than 1 note simultaneously. When notes are written between ( and ), they are played at the same time. Note, that simultaneous notes (also called chords in Muselang) can have different durations.
Chord can contain as many notes as you want (but at least 1).
Example of chords:
(C, D# eighth 50, E)
- C, D# and E are played simultaneosly.
Syntax:
phrase <PhraseName> {
<Body>
}
Meaning:
You can "group" notes in phrases and then play all this group by just writing name of the phrase.
For example:
phrase hello_world {
C h 100
repeat 3 {
D
E
}
}
hello_world
hello_world
will play C h 100 D E D E D E C h 100 D E D E D E
(notes C h 100 D E D E D E
are given name "hello_world", so when we write hello_world
- that notes play)
Phrase name must start with english letter (either capital or not) or _
and contain any english letters, or digits or _
sign.