The old, cumbersome 'note_on_by_time' event has been renamed to the
[ahxm.git] / doc / language.txt
blob8b9b289341fd609501145a3dbddb590e5c53909e
1 Ann Hell Ex Machina Scripting - I: Basic Commands
2 =================================================
4 Overview
5 --------
7 Ann Hell Ex Machina scripts consist of a sequence of commands and their
8 possible arguments which run from the top to the bottom. Formatting and
9 indentation can be used in a free-form way.
11 At any time, comments can be inserted in C language style as in the following
12 example:
14  /* this is a C style comment,
15         that spans multiple
16         lines */
18 Whitespace separation is not mandatory and commands can be conveniently
19 joined together if they are unambiguous.
21 For example:
23  T120 M4/4 o5 c4 d8 e& f4 g8 a&16 b& c'1
25 can also be written as
27  T120M4/4o5c4d8e&f4g8a&16b&c'1
29 or, grouped by measures,
31  T120 M4/4 o5 c4d8e& f4g8a&16b& c'1
33 Includes
34 --------
36 Script files can be included from each other by enclosing filenames between
37 backticks, as in the example:
39  `path/to/file`
41 The referenced file will be inserted at that exact point.
43 Tempo
44 -----
46 Tempo is expressed in Beats Per Minute (bpm) as in the next example:
48  T120   /* sets tempo to 120 Beats Per Minute */
50 Obviously, tempo changes are global to all tracks. Though it's normally set
51 at the beginning of a song, it can be used anywhere. You can use marks to
52 be sure that tempo changes occur exactly where you want in all tracks (see
53 documentation for marks). The tempo can be a non-integer number.
55 Measure
56 -------
58 Measure is expressed as in standard music notation. For example:
60  M4/4   /* classic 4 quarter notes measure */
62 Measure settings are global to all tracks as tempo.
64 Notes
65 -----
67 Syntax:
69  pitch[length][volume]
71 pitch
72 ~~~~~
74 Syntax:
76  letter[alteration][octave]
78 Letter is any from a to g for english notation notes in the currently selected
79 octave, r for rests, or z for a zero-note, that allows setting the length
80 for subsequent notes without doing anything more.
82 The alteration is optional, and is any of # (sharp) or & (flat). If not
83 specified, natural note is assumed.
85 The octave is also optional, and is one or more ocurrencies of ' (one octave
86 higher for each one) or , (one octave lower for each one). If none is
87 specified, note is assumed to belong to the current octave.
89 Examples:
91  a#     /* A sharp */
92  g&     /* G flat */
93  a      /* normal A */
94  c'     /* C, one octave above */
95  f#,,   /* F sharp, two octaves below */
97 length
98 ~~~~~~
100 Optional, with the following syntax:
102  figure[tuplet][mult]
104 Figure is any of 1, 2, 4, 8, 16, 32, 64 measure partitions. Tuplet, if present,
105 is a / followed by a numeric divisor (3 for triplets, etc.). Currently, only 3
106 or 5 tuplets are supported. Mult, if present, can be expressed as an *
107 followed by a numeric multiplier of the figure meaning the final length is
108 that times longer, or as a more music-standard series of dots, adding each
109 one half the length.
111 If no length is present, the note length is inherited from the last one
112 previously defined.
114 Examples:
116  a4     // an A longing one beat
117  r4.    // a rest, longing one beat and a half
118  g8/3   // a G, in triplets of eighths
119  f1*6   // an F longing 6 complete 4/4 measures
120  r4*1.5 // same as r4.
121  z2     // sets note lengths to a half note (no note inserted)
123 Immediate volume
124 ~~~~~~~~~~~~~~~~
126 Optional, can be expressed as a ~ followed by a real number ranging from
127 0 (silence) to 1 (full volume).
129 If no volume is specified, the full global one is used.
131 Examples:
133  a4~0.8 // a quarter note of A at 80% of global volume
135 Measure marks
136 -------------
138 Measure marks help when writing music by asserting that measures last
139 exactly what the metric says. They are the equivalent of measure bars in
140 standard music notation and are expressed by the character |. Unlike in
141 standard music, though, they are optional. Apart from checking, these marks
142 do not modify the resulting music in any way.
144 This piece of music will trigger an error in the second mark, just before
145 the c2, because it does not fall in a measure boundary.
147  M3/4 a4 b c | c1 | c2
149 Permanent octave changes
150 ------------------------
152 Permanent octave changing can be expressed as an absolute or
153 relative change. Examples:
155  o2     /* sets octave number 2 (absolute) */
156  o+1    /* sets one octave higher (relative) */
157  o-2    /* sets two octaves lower (relative) */
159 Absolute octave numbers range from 0 to 10. Otherwise, for relative
160 changes, a signed integer number can be used.
162 A complete note trip up can be done this way, using absolute and
163 relative changes and blocks:
165  o0 z16 (cdefgab o+1)*10
167 Octaves can be out of range (the previous example will end with
168 an invalid octave number of 11), but inserting a note after it
169 will generate an error. This 'lazy error checking' is done purposely
170 to allow block repetitions like this one; just change to a valid octave
171 before inserting a new note.
173 Permanent volume changes
174 ------------------------
176 Permament volume can be expressed as an absolute or relative change.
177 Examples:
179  v0.75  /* sets global volume to 0.75 (75%) */
180  v+0.1  /* increments current volume by 0.1 */
181  v-0.3  /* decrements current volume by 0.3 */
183 Absolute volume range from 0 (silence) to 1 (full volume).
185 Transpose
186 ---------
188 Transposition is expressed as a negative or positive number of
189 semitones. By default, each track has an initial transposition
190 of 0. This is an example:
192  t5     /* transpose a fifth up */
194 Note that transpose, as octave changing, can lead to out-of-bound
195 notes. No error will be reported until an invalid note is inserted.
197 Staccato
198 --------
200 The staccato is expressed as the partial time of the total note
201 length that the note will really sound. By default, each track
202 has an initial value of 0.8 (80%). Usual values range from 0.5 (staccato)
203 to 1 (tenuto). For example:
205  s0.9   /* sets staccato to 90%: notes sound more tied together */
207 Groups
208 ------
210 To form chords or more complicated sequences of polyphonic notes,
211 groups can be used. They are enclosed by < and > and separated
212 by semicolons. The group's duration is that of the longest of the parts.
214 The simplest example is a basic chord like this one:
216  <c1 ; e& ; g>  /* a C minor chord for a whole 4/4 measure */
218 Each part of the group can contain more than one note:
220  // the classic bass drum, snare, close and open hat beat
221  <c8rrr crrr ; rrdr rrdr ; g#g#g#a# g#g#g#a#>
223 Glissando
224 ~~~~~~~~~
226 By default, each part of a group start at exactly the same time. To
227 implement strumming (as, for example, in guitar chords, where each note
228 is played slightly after the previous one), the glissando command is used,
229 with an argument expressed as a note length:
231  l16 <c;e;g> /* delay each chord note by a sixteenth */
233 Multipliers and tuplets can also be used (see the note length sections
234 for more information).
236 To disable glissando, use a glissando command with a value of 0.
238 Arpeggiator
239 -----------
241 The arpeggiator allows the programming of automatic repetitions for
242 each note, probably modifying some of its features. It's expressed
243 by the x command followed by a comma separated list of repetition
244 specifications with the following syntax:
246  offset[volume][transpose][track]
248 Offset is a length specification (see Notes) and is the delay of
249 the repetition after the start of the original note (it does NOT express
250 the length of the repeated note; each arpeggiated note last the same as
251 the original one). It can be zero for notes that sound at the same time
252 as the original note.
254 Volume, if specified, is a ~ followed by a real number (see also Notes).
255 This volume is multiplied by the original volume of the note. If none is
256 specified, the note is repeated at its original volume.
258 Transpose, if specified, is a signed number of semitones to transpose
259 the original note. If no transpose is specified, the pitch of the repeated
260 note will be the same as the original.
262 Track, if specified, is a @ followed by a track number, meaning the note
263 will be inserted in that track (and not in the current one).
265 An x command with no repetition specifications effectively disables
266 the arpeggiator.
268 Examples:
270  x4~0.6                 // repeats each note a quarter later at 60% of vol.
271  x4~0.6,2~0.4           // the same, but another repetition later at 40%
272  x8-1,4-2,8*3-3         // 3 chromatic repetitions after each eighth
273  x                      // disable arpeggiator
275 Marks
276 -----
278 To create a mark, use
280  ^name-of-the-mark
282 and, in tracks defined later, you can set the cursor at the mark by using
284  @name-of-the-mark
286 The mark name can use alphanumeric characters and hyphens. An error
287 is generated if a move to mark command is used but the current track's
288 cursor is already beyond that position (i.e. you cannot move 'backwards').
290 Marks can also be used for synchronization by using
292  !name-of-the-mark
294 if the track's cursor does not match that of the mark position, an
295 error is returned reporting the difference in measures.
297 Blocks
298 ------
300 Blocks are marked using pairs of parentheses. The closing one should
301 be followed by a character indicating the operation to do with the
302 block.
304 Repeating blocks
305 ~~~~~~~~~~~~~~~~
307 Blocks that should be repeated a defined number of times can be
308 specified as
310  (code)*times
312 Where code can be anything, from notes to track information, and
313 times the number of times the block will repeat.
315 Named blocks (patterns)
316 ~~~~~~~~~~~~~~~~~~~~~~~
318 A block can be assigned a name to be later inserted. To name it:
320  (code)=name-of-the-block
322 Where code can be anything, from notes to track information, and
323 name-of-the-block the name to be assigned. The name should not
324 contain spaces. The block is not inserted where it's defined; to
325 insert it, the following notation should be used:
327  $name-of-the-block
329 So, for example:
331  (c16defgab)=scale      // define a named block
332  $scale $scale $scale   // insert several times
333  ($scale)*8             // blocks can be nested
335 Named blocks can be redefined anytime:
337  (($drumloop)*8)=phrase         // valid even though drumloop is still undef
338  (cdcdcdcd)=drumloop $phrase    // drumloop resolved when inserting phrase
339  (cdcccdcc)=drumloop $phrase    // inserts now 8 copies of the new drumloop
341 Command reference table
342 -----------------------
344 Note commands
345 ~~~~~~~~~~~~~
347  a      Insert note A
348  b      Insert note B
349  c      Insert note C
350  d      Insert note D
351  e      Insert note E
352  f      Insert note F
353  g      Insert note G
354  r      Insert rest (silence)
355  z      Zero note (set length for future notes)
356  o      Set default octave
357  t      Set transpose
358  s      Set staccato
359  v      Set volume
361 Group commands
362 ~~~~~~~~~~~~~~
364  <      Start of group
365  ;      Group delimiter
366  >      End of group
367  l      Set glissando delay
369 Block commands
370 ~~~~~~~~~~~~~~
372  (      Start of block
373  )      End of block
374  *      Block repetition if following )
375  =      Named block assignment if following )
376  $      Named block insertion
377  `      Include script
379 Mark commands
380 ~~~~~~~~~~~~~
382  ^      Set mark
383  @      Move to mark
384  !      Mark assertion
386 Global commands
387 ~~~~~~~~~~~~~~~
389  T      Set tempo
390  M      Set measure
392 Special commands
393 ~~~~~~~~~~~~~~~~
395  |      Measure mark
396  x      Arpeggiator