Generators now process the attack.
[ahxm.git] / doc / ahs_overview_ii.txt
blobee7552ba97d8ae46edafa185934c5a62158d01de
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 Supported formats are: .wav (natively), .flac and .mp3 (via external
48 converters).
50 Examples:
52  /* a simple wav with no loop and no range (just on note D1) */
53  { wav "snare1.wav" d1 }
55  /* a wav to be playing in the C3-C4 range, tuned to G4, unlooped */
56  { wav "glockenspiel-g4.wav" g4 c3 c4 }
58  /* another one, but using MIDI note numbers instead of note-octave notation */
59  { wav "xilophone.wav" c5 1 127 }
61  /* a looped one */
62  { wav "pad10.wav" f4 f1 b9 150 154056 }
64  /* another one, with a loop to fill the full wave */
65  { wav "hiphop-drumline.wav" c1 c1 c1 0 -1 }
67  /* another way of expressing the first example */
68  { wav "snare1.wav" d1 d1 d1 -1 -1 }
70  /* two looped waves for the same note, but from different wave files;
71     the 'L' one will be on channels 0, 2, 4... and the 'R' one on 1, 3, 5... */
72  { wav "piano1-L.wav" c2 c1 g2 150 146578 0 1 }
73  { wav "piano1-R.wav" c2 c1 g2 175 143254 1 1 }
75 pat
76 ~~~
78  pat "file.pat"
80 Loads a GUS compatible sound patch. All layers defined in it will be
81 added to the current instrument.
83 sustain
84 ~~~~~~~
86  sustain <time>
88 Sets the sustain for subsequent notes to be the specified `time'. Sustain
89 is the time a digital sound will be sounding after being released.
91 vibrato
92 ~~~~~~~
94  vibrato <depth> <frequency>
96 Sets the vibrato for the subsequent notes.
98 Example:
100  /* good depth values range from 0.45 to 0.68 */
101  /* good frequency values are 6hz to 10hz */
102  { vibrato 0.45ms 6 }
104 portamento
105 ~~~~~~~~~~
107  portamento <factor>
109 (New in 1.0.8). Sets the portamento for subsequent notes. If `factor' is
110 negative, the notes will slide down, or up if positive. Bigger values
111 generate more portamento. The final result depends on the frequency of each
112 note: lower notes will be more affected than higher ones for equal values
113 of `factor'. A `factor' of 0 disables portamento.
115 channel
116 ~~~~~~~
118  channel <channel #> <volume>
120 Sets the `volume' for the specified `channel #'. Usually it's a real number
121 ranging from 0 (total silence) to 1 (full volume), but any value is accepted;
122 numbers bigger than 1 will make the sound to be amplified (though with a
123 risk of saturating), and negative values will negate the amplitude of the
124 sound. By default, only channels 0 and 1 exist (the usual stereo ones);
125 setting a volume for a channel will create it automatically.
127 The 'vol' directive allows volumes for many channels to be specified at a time.
132  vol <volume>
133  vol <volume> <volume>
134  vol <volume> <volume> <volume>
135  vol <volume> <volume> <volume> <volume>
136  vol <volume> <volume> <volume> <volume> <volume> <volume>
138 Sets the volumes for a group of channels at a time. 1, 2, 3, 4 and 6 channels
139 can be specified, corresponding with the following well-known audio systems:
141  * mono: all in one channel
142  * stereo: left and right
143  * 3 channel: left, right and center
144  * quad: front left, front right, rear left and rear right
145  * 4 channel: left, center, right and surround
146  * 6 channel: left center, left, center, right center, right and surround
148 pitch_stretch
149 ~~~~~~~~~~~~~
151  pitch_stretch <note> <length> <volume>
153 Starts playing a special note that will last exactly `length' whole notes,
154 changing its pitch if necessary. The `note' is just specified to locate the
155 desired layer and not as a pitch. This is mainly used to match rhythm loops
156 (that don't have a significative pitch) to the current tempo.
158 Example:
160  /* store three loops in the notes c1, d1 and e1 */
161  { wav "loop1.wav" c1 }
162  { wav "loop2.wav" d1 }
163  { wav "loop3.wav" e1 }
165  /* start loop2.wav lasting two measures */
166  { pitch_stretch d1 2 0.8 }
168 time_stretch
169 ~~~~~~~~~~~~
171  time_stretch <note> <length> <volume>
173 This command is NOT IMPLEMENTED.
175 print_wave_tempo
176 ~~~~~~~~~~~~~~~~
178  print_wave_tempo <note> <number>
180 Prints the optimal tempo for the sample stored in `note' to last exactly
181 `number' whole notes. It does nothing to the output.
184 Digital effect commands
185 -----------------------
187 delay
188 ~~~~~
190  delay <channel> <time>
192 Creates a phase delay in `channel'. Sample output will be delayed by
193 the `time' specification. No further filtering is done.
195 Example:
197  /* add a phase delay of 20 milliseconds in the right channel */
198  { delay 1 20ms }
200 echo
201 ~~~~
203  echo <channel> <time> <gain>
205 Creates an echo effect in `channel'. Sample output will be pass as is,
206 but mixed with the original signal phased by `time' and amplified by
207 `gain'.
209 Example:
211  /* add an 50% echo after 15 milliseconds */
212  { echo 0 15ms 0.5 }
214 comb
215 ~~~~
217  comb <channel> <time> <gain>
219 Creates a comb filter in `channel'. Comb filters are used for implementing
220 reverbs.
222 Example:
224  /* comb filter */
225  { comb 0 1ms 0.4 }
227 allpass
228 ~~~~~~~
230  allpass <channel> <time> <gain>
232 Creates an allpass filter in `channel'. Allpass filters are used for
233 implementing reverbs (see the built-in reverb command).
235 Example:
237  /* allpass filter */
238  { allpass 0 20ms 0.9 }
240 flanger
241 ~~~~~~~
243  flanger <channel> <time> <gain> <depth> <freq> <phase>
245 Creates a flanger effect in `channel'.
247 Example:
249  /* good stereo flanger */
250  { flanger 0 1s 0.9 3.40ms 0.1 0
251    flanger 1 1s 0.9 3.40ms 0.1 0.25 }
253 wobble
254 ~~~~~~
256  wobble <channel> <freq> <phase>
257  wobble <channel> <freq> <phase> <gain>
259 Creates a wobble effect in `channel'. Amplitude will have a sine wave
260 applied with a frequency of `freq', so volume will effectively go from
261 full amplitude to silence twice a period. The initial value for the
262 phase is set in `phase'. The wobble effect can be used to implement
263 tremolos with short frequencies and pan effects with long ones.
265 If `gain' is set, it's the ratio of wobbled / unmodified signal, ranging
266 from 1 (full wobbled) to 0 (no effect). If not set, `gain' has a default
267 value of 0.8. This behaviour is new in 1.0.9; previous versions didn't
268 accept the 4th argument and acted as if a gain of 1.0 was given.
270 Examples:
272  /* tremolo (10Hz frequency) */
273  { wobble 0 10 0 }
275  /* long stereo panning: one complete cycle
276     in 4 seconds (0.25Hz), with a 1/4 period
277     phase difference between both channels */
278  { wobble 0 0.25 0
279    wobble 1 0.25 0.25 }
281 square_wobble
282 ~~~~~~~~~~~~~
284  square_wobble <channel> <freq> <phase>
286 Creates a square wobble effect in `channel'. Its behaviour is the same
287 as the wobble command, but applying a square wave instead, so volume
288 will abruptly change from full amplitude to absolute silence twice a
289 period.
291 half_wobble
292 ~~~~~~~~~~~
294  half_wobble <channel> <freq> <phase>
296 (New in 1.0.8). Creates a half wobble effect in `channel'. Its behaviour is
297 the same as the wobble command, but the sine wave is applied to the
298 amplitude only the first half the period and silence the other half.
300 fader
301 ~~~~~
303  fader <channel> <time> <initial volume> <final volume>
305 Creates a fader effect in `channel'. `Time' is the length that will take
306 the channel volume to change from `initial volume' to `final volume'.
307 After `time' is passed, volume will be filtered to `final volume' until
308 the effect is destroyed.
310 Example:
312  /* a 5 seconds fade-in in left channel */
313  { fader 0 5s 0.0 1.0 }
315 reverb
316 ~~~~~~
318  reverb <channel>
320 Creates simple reverb in `channel'. This reverb is defined as
322  { allpass 0 20ms 0.9
323    allpass 0 36ms 0.9
324    allpass 0 39ms 0.9 }
326 foldback
327 ~~~~~~~~
329  foldback <channel> <threshold>
331 (New in 1.0.8). Creates a simple distortion waveshaper where each amplitude
332 above `threshold' (range from -1 to 1) is folded back using the following
333 formula:
335         if(input > threshold)
336                 output = threshold - (input - threshold);
337         else
338         if(input < -threshold)
339                 output = -threshold + (-threshold - input);
341 See http://www.musicdsp.org/archive.php?classid=4#203 for more
342 information.
347  off <channel>
349 This command resets the digital effect chain for `channel', destroying
350 all possible effects in it. Samples will then pass unmodified.
352 MIDI commands
353 -------------
355 midi_channel
356 ~~~~~~~~~~~~
358  midi_channel <channel #>
360 Sets the MIDI channel for the current track. The `channel #' value must range
361 from 1 to 16.
363 midi_program
364 ~~~~~~~~~~~~
366  midi_program <program #>
368 Adds a MIDI program change event. The `program #' value ranges from 0 to 127.
370 Miscellaneous commands
371 ----------------------
373 song_info
374 ~~~~~~~~~
376  song_info "Song Author" "Song Name"
378 (New in 1.0.4). This directive is used to set the author and name of the song.
379 These metadata can be used to generate .cue files.
381 ----
382 Angel Ortega - http://www.triptico.com