Updated TODO.
[ahxm.git] / doc / ahs_overview_ii.txt
blob3eefe55714a2b3f9a80b5d9bf22cd57a5d599afc
1 Ann Hell Scripting - II: Extended Commands
2 ==========================================
4  Angel Ortega <angel@triptico.com>
6 Overview
7 --------
9 Those directives that are not pure music instructions or are specific to a
10 given output mode are called extended commands. They are expressed as
11 curly bracket-enclosed blocks of keywords directly followed by their
12 optional, respective arguments. As for the basic commands, formatting and
13 indentation is free-form.
15 Extended commands are interleaved with basic commands, they are inserted
16 exactly where found and can be enclosed in blocks or group structures as
17 well.
19 Software synthesizer commands
20 -----------------------------
22 wav
23 ~~~
25  wav "file.wav" <base>
26  wav "file.wav" <base> <min> <max>
27  wav "file.wav" <base> <min> <max> <loop start> <loop end>
28  wav "file.wav" <base> <min> <max> <loop start> <loop end> <first ch> <skip ch>
30 Loads a file containing a PCM wave as a layer for the current instrument.
31 If just the `base' note is specified, a layer will be created for that
32 note only. If `min' and `max' are specified, they conform the range of notes.
33 If `loop start' and `loop end' are not specified, the layer will be accepted
34 as an un-looped one (so the sound will immediately stop when reaching the end).
35 This non-looping behaviour can be simulated by setting a `loop start' of -1.
36 If `loop end' is negative, it's assumed as the end of the sample (so a loop
37 from 0 to -1 selects the full PCM wave for looping).
39 By default, all wav's channels are mapped sequentially to all channels of the
40 instrument, so that a mono wav file will be spread to all channels, a stereo one
41 to alternating odd/even channels, etc. The `first ch' and `skip ch' arguments
42 can be used to change this. `first ch' specify the first channel the wav will
43 start spreading into (default is 0, the first one), and `skip ch' is the number
44 of channels to skip before spreading to the next (default is 0, don't skip any
45 channel).
47 (New in 1.0.10) If the filename starts with the | (pipe) symbol, it's assumed
48 as a command to be executed. This command should include a %s mark where a
49 temporary file name will be inserted. The command should generate a wav file
50 in that temporary file.
52 Supported formats are: .wav (natively), .flac and .mp3 (via external
53 converters).
55 Examples:
57  /* a simple wav with no loop and no range (just on note D1) */
58  { wav "snare1.wav" d1 }
60  /* a wav to be playing in the C3-C4 range, tuned to G4, unlooped */
61  { wav "glockenspiel-g4.wav" g4 c3 c4 }
63  /* another one, but using MIDI note numbers instead of note-octave notation */
64  { wav "xilophone.wav" c5 1 127 }
66  /* a looped one */
67  { wav "pad10.wav" f4 f1 b9 150 154056 }
69  /* another one, with a loop to fill the full wave */
70  { wav "hiphop-drumline.wav" c1 c1 c1 0 -1 }
72  /* another way of expressing the first example */
73  { wav "snare1.wav" d1 d1 d1 -1 -1 }
75  /* two looped waves for the same note, but from different wave files;
76     the 'L' one will be on channels 0, 2, 4... and the 'R' one on 1, 3, 5... */
77  { wav "piano1-L.wav" c2 c1 g2 150 146578 0 1 }
78  { wav "piano1-R.wav" c2 c1 g2 175 143254 1 1 }
80  /* this command will call the 'sox' program to generate a temporary
81     filename (replacing the %s mark) and set it to play on C5 */
82  { wav "|sox orig_file.wav %s stretch 6" c5 }
84 pat
85 ~~~
87  pat "file.pat"
89 Loads a GUS compatible sound patch. All layers defined in it will be
90 added to the current instrument.
92 sustain
93 ~~~~~~~
95  sustain <time>
97 Sets the sustain for subsequent notes to be the specified `time'. Sustain
98 is the time a digital sound will be sounding after being released.
100 attack
101 ~~~~~~
103  attack <time>
105 (New in 1.0.9). Sets the attack time for the subsequent notes to be the
106 specified `time'. This is the time that takes a sound to fade-in from
107 silence to full volume. By default, it's zero (sounds start immediately
108 at full volume).
110 vibrato
111 ~~~~~~~
113  vibrato <depth> <frequency>
115 Sets the vibrato for the subsequent notes.
117 Example:
119  /* good depth values range from 0.45 to 0.68 */
120  /* good frequency values are 6hz to 10hz */
121  { vibrato 0.45ms 6 }
123 portamento
124 ~~~~~~~~~~
126  portamento <factor>
128 (New in 1.0.8). Sets the portamento for subsequent notes. If `factor' is
129 negative, the notes will slide down, or up if positive. Bigger values
130 generate more portamento. The final result depends on the frequency of each
131 note: lower notes will be more affected than higher ones for equal values
132 of `factor'. A `factor' of 0 disables portamento.
134 channel
135 ~~~~~~~
137  channel <channel #> <volume>
139 Sets the `volume' for the specified `channel #'. Usually it's a real number
140 ranging from 0 (total silence) to 1 (full volume), but any value is accepted;
141 numbers bigger than 1 will make the sound to be amplified (though with a
142 risk of saturating), and negative values will negate the amplitude of the
143 sound. By default, only channels 0 and 1 exist (the usual stereo ones);
144 setting a volume for a channel will create it automatically.
146 The 'vol' directive allows volumes for many channels to be specified at a time.
151  vol <volume>
152  vol <volume> <volume>
153  vol <volume> <volume> <volume>
154  vol <volume> <volume> <volume> <volume>
155  vol <volume> <volume> <volume> <volume> <volume> <volume>
157 Sets the volumes for a group of channels at a time. 1, 2, 3, 4 and 6 channels
158 can be specified, corresponding with the following well-known audio systems:
160  * mono: all in one channel
161  * stereo: left and right
162  * 3 channel: left, right and center
163  * quad: front left, front right, rear left and rear right
164  * 4 channel: left, center, right and surround
165  * 6 channel: left center, left, center, right center, right and surround
167 pitch_stretch
168 ~~~~~~~~~~~~~
170  pitch_stretch <note> <length> <volume>
172 Starts playing a special note that will last exactly `length' whole notes,
173 changing its pitch if necessary. The `note' is just specified to locate the
174 desired layer and not as a pitch. This is mainly used to match rhythm loops
175 (that don't have a significative pitch) to the current tempo.
177 Example:
179  /* store three loops in the notes c1, d1 and e1 */
180  { wav "loop1.wav" c1 }
181  { wav "loop2.wav" d1 }
182  { wav "loop3.wav" e1 }
184  /* start loop2.wav lasting two measures */
185  { pitch_stretch d1 2 0.8 }
187 time_stretch
188 ~~~~~~~~~~~~
190  time_stretch <note> <length> <volume>
192 This command is NOT IMPLEMENTED.
194 print_wave_tempo
195 ~~~~~~~~~~~~~~~~
197  print_wave_tempo <note> <number>
199 Prints the optimal tempo for the sample stored in `note' to last exactly
200 `number' whole notes. It does nothing to the output.
203 Digital effect commands
204 -----------------------
206 delay
207 ~~~~~
209  delay <channel> <time>
211 Creates a phase delay in `channel'. Sample output will be delayed by
212 the `time' specification. No further filtering is done.
214 Example:
216  /* add a phase delay of 20 milliseconds in the right channel */
217  { delay 1 20ms }
219 echo
220 ~~~~
222  echo <channel> <time> <gain>
224 Creates an echo effect in `channel'. Sample output will be pass as is,
225 but mixed with the original signal phased by `time' and amplified by
226 `gain'.
228 Example:
230  /* add an 50% echo after 15 milliseconds */
231  { echo 0 15ms 0.5 }
233 comb
234 ~~~~
236  comb <channel> <time> <gain>
238 Creates a comb filter in `channel'. Comb filters are used for implementing
239 reverbs.
241 Example:
243  /* comb filter */
244  { comb 0 1ms 0.4 }
246 allpass
247 ~~~~~~~
249  allpass <channel> <time> <gain>
251 Creates an allpass filter in `channel'. Allpass filters are used for
252 implementing reverbs (see the built-in reverb command).
254 Example:
256  /* allpass filter */
257  { allpass 0 20ms 0.9 }
259 flanger
260 ~~~~~~~
262  flanger <channel> <time> <gain> <depth> <freq> <phase>
264 Creates a flanger effect in `channel'.
266 Example:
268  /* good stereo flanger */
269  { flanger 0 1s 0.9 3.40ms 0.1 0
270    flanger 1 1s 0.9 3.40ms 0.1 0.25 }
272 wobble
273 ~~~~~~
275  wobble <channel> <freq> <phase>
276  wobble <channel> <freq> <phase> <gain>
278 Creates a wobble effect in `channel'. Amplitude will have a sine wave
279 applied with a frequency of `freq', so volume will effectively go from
280 full amplitude to silence twice a period. The initial value for the
281 phase is set in `phase'. The wobble effect can be used to implement
282 tremolos with short frequencies and pan effects with long ones.
284 If `gain' is set, it's the ratio of wobbled / unmodified signal, ranging
285 from 1 (full wobbled) to 0 (no effect). If not set, `gain' has a default
286 value of 0.8. This behaviour is new in 1.0.9; previous versions didn't
287 accept the 4th argument and acted as if a gain of 1.0 was given.
289 Examples:
291  /* tremolo (10Hz frequency) */
292  { wobble 0 10 0 }
294  /* long stereo panning: one complete cycle
295     in 4 seconds (0.25Hz), with a 1/4 period
296     phase difference between both channels */
297  { wobble 0 0.25 0
298    wobble 1 0.25 0.25 }
300 square_wobble
301 ~~~~~~~~~~~~~
303  square_wobble <channel> <freq> <phase>
305 Creates a square wobble effect in `channel'. Its behaviour is the same
306 as the wobble command, but applying a square wave instead, so volume
307 will abruptly change from full amplitude to absolute silence twice a
308 period.
310 half_wobble
311 ~~~~~~~~~~~
313  half_wobble <channel> <freq> <phase>
315 (New in 1.0.8). Creates a half wobble effect in `channel'. Its behaviour is
316 the same as the wobble command, but the sine wave is applied to the
317 amplitude only the first half the period and silence the other half.
319 fader
320 ~~~~~
322  fader <channel> <time> <initial volume> <final volume>
324 Creates a fader effect in `channel'. `Time' is the length that will take
325 the channel volume to change from `initial volume' to `final volume'.
326 After `time' is passed, volume will be filtered to `final volume' until
327 the effect is destroyed.
329 Example:
331  /* a 5 seconds fade-in in left channel */
332  { fader 0 5s 0.0 1.0 }
334 reverb
335 ~~~~~~
337  reverb <channel>
339 Creates simple reverb in `channel'. This reverb is defined as
341  { allpass 0 20ms 0.9
342    allpass 0 36ms 0.9
343    allpass 0 39ms 0.9 }
345 foldback
346 ~~~~~~~~
348  foldback <channel> <threshold>
350 (New in 1.0.8). Creates a simple distortion waveshaper where each amplitude
351 above `threshold' (range from -1 to 1) is folded back using the following
352 formula:
354         if(input > threshold)
355                 output = threshold - (input - threshold);
356         else
357         if(input < -threshold)
358                 output = -threshold + (-threshold - input);
360 See http://www.musicdsp.org/archive.php?classid=4#203 for more
361 information.
363 atan
364 ~~~~
366  atan <channel> <gain>
368 (New in 1.0.9). Creates a simple distortion waveshaper that applies an
369 atan() function to each input sample. `gain' must be greater than 1.
370 The output from this filter is slightly distorted but a bit quieter.
372 See http://www.musicdsp.org/showArchiveComment.php?ArchiveID=104 for
373 more information.
375 distort
376 ~~~~~~~
378  distort <channel> <gain>
380 (New in 1.0.9). Creates a simple distortion waveshaper that applies a
381 simple formula to each input sample. `gain' must be greater than 1.
383 See http://www.musicdsp.org/showArchiveComment.php?ArchiveID=86 for more
384 information.
386 overdrive
387 ~~~~~~~~~
389  overdrive <channel> <gain>
391 (New in 1.0.9). Creates a simple distortion waveshaper that applies a
392 simple formula to each input sample. `gain' must be greater than 1. The
393 output from this filter is slightly distorted but a bit louder (it's not
394 a real overdrive, but for same waves it sounds similar).
396 See http://www.musicdsp.org/archive.php?classid=4#41 for more
397 information.
402  off <channel>
404 This command resets the digital effect chain for `channel', destroying
405 all possible effects in it. Samples will then pass unmodified.
407 MIDI commands
408 -------------
410 midi_channel
411 ~~~~~~~~~~~~
413  midi_channel <channel #>
415 Sets the MIDI channel for the current track. The `channel #' value must range
416 from 1 to 16.
418 midi_program
419 ~~~~~~~~~~~~
421  midi_program <program #>
423 Adds a MIDI program change event. The `program #' value ranges from 0 to 127.
425 Miscellaneous commands
426 ----------------------
428 song_info
429 ~~~~~~~~~
431  song_info "Song Author" "Song Name"
433 (New in 1.0.4). This directive is used to set the author and name of the song.
434 These metadata can be used to generate .cue files.
436 ----
437 Angel Ortega - http://www.triptico.com