| 1 |
<!DOCTYPE html> |
| 2 |
<html><head><title>MIDI, Adagio, and Sequences</title> |
| 3 |
<link rel="stylesheet" type="text/css" href="nyquiststyle.css"> |
| 4 |
<link rel="icon" href="nyquist-icon.png" /> |
| 5 |
<link rel="shortcut icon" href="nyquist-icon.png" /> |
| 6 |
</head> |
| 7 |
<body bgcolor="ffffff"> |
| 8 |
<a href = "part11.html">Previous Section</a> | <a href = "part13.html">Next Section</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "indx.html">Index</a> | <a href = "title.html">Title Page</a> |
| 9 |
<hr> |
| 10 |
<a name = "123"><h2>MIDI, Adagio, and Sequences</h2></a><a name="index953"></a><a name="index954"></a> |
| 11 |
<p>Nyquist includes facilities to read and write MIDI files as well as an |
| 12 |
ASCII text-based score representation language, Adagio. XLISP and |
| 13 |
Nyquist can be used to generate MIDI files using compositional |
| 14 |
algorithms. (See also Section <a href = "part15.html#157">Xmusic and Algorithmic Composition</a>.) A tutorial on using |
| 15 |
the Adadio representation and MIDI can be found in |
| 16 |
<code>nyquist/lib/midi/midi_tutorial.htm</code><a name="index955"></a>. The |
| 17 |
Adagio language is described below. Adagio was originally developed as |
| 18 |
part of the CMU MIDI Toolkit, which included a program to record and |
| 19 |
play MIDI using the Adagio representation. Some of the MIDI features |
| 20 |
of Adagio may not be useful within Nyquist.</p> |
| 21 |
|
| 22 |
<p>Nyquist offers a number of different score representations, and you |
| 23 |
may find this confusing. In general, MIDI files are a common way to |
| 24 |
exchange music performance data, especially with sequencers and score |
| 25 |
notation systems. The <code>nyquist/lib/midi/midi_tutorial.htm</code> |
| 26 |
examples show how to get the most precise control when generating MIDI |
| 27 |
data. Adagio is most useful as a text-based score entry language, and |
| 28 |
it is certainly more compact than Lisp expressions for MIDI-like |
| 29 |
data. The Xmusic library (Chapter <a href = "part15.html#157">Xmusic and Algorithmic Composition</a>) is best for |
| 30 |
algorithmic generation of music and score manipulation. There are |
| 31 |
functions to convert between the Adagio, MIDI sequence data, and |
| 32 |
Xmusic score representations.</p> |
| 33 |
<a name = "124"><h3>The SEQ Type</h3></a> |
| 34 |
<p>Nyquist has a special data type to store MIDI data called a SEQ (short |
| 35 |
for "sequence"). You can create an empty SEQ object, read data into |
| 36 |
it from a MIDI or Adagio file, write a SEQ as MIDI or Adagio, and |
| 37 |
insert notes into a SEQ object. You can also convert SEQ objects into |
| 38 |
sound by providing functions to handle different MIDI messages. |
| 39 |
Further discussion and examples can be found in |
| 40 |
<code>lib/midi/midi_tutorial.htm</code><a name="index956"></a><a name="index957"></a>.</p> |
| 41 |
<dl> |
| 42 |
<dt> |
| 43 |
<code>seq-create(<a name="index958"></a><a name="index959"></a><a name="index960"></a>)</code> [SAL]<br> |
| 44 |
|
| 45 |
<code>(seq-create)</code> [LISP]</dt> |
| 46 |
<dd>Creates a SEQ data object.<br><br> |
| 47 |
<dt><code>seq-read(<a name="index961"></a><a name="index962"></a><a name="index963"></a><i>seq</i>, |
| 48 |
<i>file</i>)</code> [SAL]<br> |
| 49 |
|
| 50 |
<code>(seq-read <i>seq</i> <i>file</i>)</code> [LISP]</dt> |
| 51 |
<dd>Reads into a SEQ data |
| 52 |
object from an ASCII text file in Adagio format. The first parameter |
| 53 |
is the SEQ object to read. The <i>file</i> is a file opened for |
| 54 |
reading. It must be closed after <code>seq-read</code> returns.<br><br> |
| 55 |
<dt><code>seq-read-smf(<a name="index964"></a><a name="index965"></a><a name="index966"></a><i>seq</i>, |
| 56 |
<i>midi-file</i>)</code> [SAL]<br> |
| 57 |
|
| 58 |
<code>(seq-read <i>seq</i> <i>midi-file</i>)</code> [LISP]</dt> |
| 59 |
<dd>Reads into a SEQ data object from a Standard MIDI File. The first parameter is the SEQ object to read. The <i>midi-file</i> is a <i>binary</i> file opened <i>in binary mode</i> for reading. It must be closed after <code>seq-read-smf</code> returns.<br><br> |
| 60 |
<dt><code>seq-write(<a name="index967"></a><a name="index968"></a><a name="index969"></a><i>seq</i>, |
| 61 |
<i>file</i>, <i>absolute</i>)</code> [SAL]<br> |
| 62 |
|
| 63 |
<code>(seq-write <i>seq</i> <i>file</i> <i>absolute</i>)</code> [LISP]</dt> |
| 64 |
<dd>Writes a SEQ data object to an ASCII text file in Adagio format. The first parameter is the SEQ object to write. The <i>file</i> is a file opened for writing. It must be closed after <code>seq-read</code> returns. The <i>absolute</i> parameter should be true to write absolute times of events and false (NIL) to write relative times.<br><br> |
| 65 |
<dt><code>seq-write-smf(<a name="index970"></a><a name="index971"></a><a name="index972"></a><i>seq</i>, |
| 66 |
<i>midi-file</i>)</code> [SAL]<br> |
| 67 |
|
| 68 |
<code>(seq-write-smf <i>seq</i> <i>midi-file</i>)</code> [LISP]</dt> |
| 69 |
<dd>Writes a SEQ data object to a binary file in Standard MIDI File format. The first parameter is the SEQ object to write. The <i>midi-file</i> is a <i>binary</i> file opened for writing. The file is closed by <code>seq-write-smf</code>.<br><br> |
| 70 |
<dt><code>seq-insert-note(<a name="index973"></a><i>seq</i>, |
| 71 |
<i>time</i>, <i>line</i>, <i>chan</i>, <i>pitch</i>, <i>dur</i>, <i>loud</i></code> [SAL]<br> |
| 72 |
|
| 73 |
<code>(seq-insert_note <i>seq</i> <i>time</i> <i>line</i> <i>chan</i> |
| 74 |
<i>pitch</i> <i>dur</i> <i>loud</i>)</code> [LISP]</dt> |
| 75 |
<dd>Inserts a new note into the SEQ |
| 76 |
object <i>seq</i>. The note will be at <i>time</i> (a FIXNUM in milliseconds), |
| 77 |
with <i>chan</i> (MIDI channel) given by a FIXNUM starting at 0, |
| 78 |
duration given |
| 79 |
by <i>dur</i> (a FIXNUM in milliseconds), <i>pitch</i> (a FIXNUM with MIDI key |
| 80 |
number), and MIDI velocity given by <i>loud</i>, a FIXNUM from 1 to 127. The |
| 81 |
<i>line</i> field is intended as a source code line number for Adagio files and |
| 82 |
can be any FIXNUM.<br><br> |
| 83 |
<dt><code>seq-insert-ctrl(<a name="index974"></a><i>seq</i>, <i>time</i>, |
| 84 |
<i>line</i>, <i>ctrltype</i>, <i>chan</i>, <i>ctrlnum</i>, <i>value</i></code> [SAL]<br> |
| 85 |
|
| 86 |
<code>(seq-insert-ctrl <i>seq</i> <i>time</i> |
| 87 |
<i>line</i> <i>ctrltype</i> <i>chan</i> <i>ctrlnum</i> <i>value</i>)</code> |
| 88 |
[LISP]</dt> |
| 89 |
<dd>Inserts |
| 90 |
a new control into the SEQ object <i>seq</i>. Here, “control” refers to a |
| 91 |
variety of MIDI messages, including program change, pitch bend, and |
| 92 |
aftertouch in addition to control changes. |
| 93 |
The control will be at <i>time</i> (a FIXNUM in |
| 94 |
milliseconds). The <i>ctrltype</i> (FIXNUM) uses MIDI status bytes for |
| 95 |
convenience: <code>seq-ctrl-tag</code> (11) for a MIDI control change, |
| 96 |
<code>seq-prgm-tag</code> (12) for a MIDI program change, |
| 97 |
<code>seq-cpress-tag</code> (13) for a MIDI channel pressure change, or |
| 98 |
<code>seq-bend-tag</code> (14) for a MIDI pitch bend change. |
| 99 |
The <i>chan</i> (MIDI channel) is given by a FIXNUM starting at 0. |
| 100 |
If <i>ctrltype</i> is 11 (control change), then <i>ctrlnum</i> is the MIDI |
| 101 |
controller number, otherwise this parameter is ignored. The <i>value</i> is |
| 102 |
the MIDI data value (FIXNUM from 0 to 127). In the case of pitch bend, |
| 103 |
this value is a FIXNUM from 0 to 255 representing the upper 8 bits of |
| 104 |
the unsigned 14-bit MIDI pitch bend value. |
| 105 |
(To convert from a scale of -1 to 1, use <code>round(x * 127 + 128)</code>.) |
| 106 |
This gives about 10-cent resolution on pitch bends of plus or minus one |
| 107 |
octave, which is normally good enough, but should be better. |
| 108 |
The <i>line</i> field is intended as a source code line number for Adagio files and |
| 109 |
can be any FIXNUM. |
| 110 |
</dd></dl> |
| 111 |
<p>To read data from a sequence, you normally begin by making a shallow copy, but |
| 112 |
you can probably just call <code>seq-reset</code> to initialize the iterator. Then |
| 113 |
call <code>seq-get</code> to get the current event, and <code>seq-next</code> to advance |
| 114 |
to the next event:</p> |
| 115 |
<dl> |
| 116 |
<dt> |
| 117 |
<code>seq-copy(<a name="index975"></a><i>seq</i>)</code> [SAL]<br> |
| 118 |
|
| 119 |
<code>(seq-copy <i>seq</i>)</code> [LISP]</dt> |
| 120 |
<dd>Returns a shallow copy of <i>seq</i>. |
| 121 |
Each copy of a sequence contains an independent iterator providing sequential |
| 122 |
access to the events in the sequence.<br><br> |
| 123 |
<dt><code>seq-reset(<a name="index976"></a><i>seq</i>)</code> [SAL]<br> |
| 124 |
|
| 125 |
<code>(seq-reset <i>seq</i>)</code> [LISP]</dt> |
| 126 |
<dd>Reset the sequence iterator |
| 127 |
to the beginning of the sequence.<br><br> |
| 128 |
<dt><code>seq-get(<a name="index977"></a><i>seq</i>)</code> [SAL]<br> |
| 129 |
|
| 130 |
<code>(seq-get <i>seq</i>)</code> [LISP]</dt> |
| 131 |
<dd>Get the current event in the |
| 132 |
sequence. The returned value is a list of FIXNUMs in the form |
| 133 |
(<i>eventtype</i> <i>time</i> <i>line</i> <i>chan</i> <i>value1</i> <i>value2</i> <i>dur</i>) |
| 134 |
as follows: |
| 135 |
<ul> |
| 136 |
<li> |
| 137 |
<i>eventtype</i> - The type of event: <code>seq-done-tag</code> (0) indicates |
| 138 |
end of sequence, <code>seq-other-tag</code> (1) indicates the event is not |
| 139 |
supported in Nyquist, <code>seq-note-tag</code> (2) indicates the event is a |
| 140 |
note, <code>seq-ctrl-tag</code> (11) indicates a MIDI control change, |
| 141 |
<code>seq-prgm-tag</code> (12) indicates a MIDI program change, |
| 142 |
<code>seq-cpress-tag</code> (13) indicates a MIDI channel pressure change, and |
| 143 |
<code>seq-bend-tag</code> (14) indicates a MIDI pitch bend change.</li> |
| 144 |
<li><code>seq-ctrl-tag</code> (3) indicates the event is a MIDI control change</li> |
| 145 |
<li><i>time</i> - Time of the event in milliseconds.</li> |
| 146 |
<li><i>line</i> - The Adagio file line number for the event (may not be defined |
| 147 |
when data is imported from a MIDI file or elsewhere.</li> |
| 148 |
<li><i>chan</i> - The MIDI channel (zero-based).</li> |
| 149 |
<li><i>value1</i> - The note pitch or controller number, |
| 150 |
depending upon the event type, or zero for program change, channel pressure |
| 151 |
or pitch bend. This value is zero-based, e.g. the first controller number is 0. </li> |
| 152 |
<li><i>value2</i> - The note velocity, program number, controller value, |
| 153 |
channel pressure, or pitch bend (see <code>seq-insert-ctrl</code> above for |
| 154 |
details on pitch bend values.) Program numbers are zero based.</li> |
| 155 |
<li><i>dur</i> - The duration in milliseconds for notes. |
| 156 |
</li></ul> |
| 157 |
Functions to access events returned by <code>seq-get</code> are defined in |
| 158 |
<code>runtime/seqfnint.lsp</code>.<br><br> |
| 159 |
<dt><code>seq-next(<a name="index978"></a><i>seq</i>)</code> [SAL]<br> |
| 160 |
|
| 161 |
<code>(seq-next <i>seq</i>)</code> [LISP]</dt> |
| 162 |
<dd>Advance the sequence |
| 163 |
iterator to the next event in the sequence unless the iterator is at |
| 164 |
the last (<code>seq-done-tag</code>) event. |
| 165 |
|
| 166 |
</dd></dl><a name = "125"><h3>Adagio Score Language</h3></a> |
| 167 |
<p>Adagio <a name="index979"></a> is an easy-to-use, non-procedural notation |
| 168 |
for scores. In Adagio, text commands are used to specify each |
| 169 |
note. If you are new to Adagio, you may want to glance at the |
| 170 |
examples in Section <a href = "#139">Examples</a> starting on page |
| 171 |
<a href = "#139">Examples</a> before reading any further.</p> |
| 172 |
|
| 173 |
<p>A note is described in Adagio by a set of attributes<a name="index980"></a>, and |
| 174 |
any attribute not specified is “inherited” from the previous line. |
| 175 |
Attributes may appear in any order and must be separated by one or more |
| 176 |
blanks. An attribute may not contain any blanks. The attributes are: |
| 177 |
time<a name="index981"></a>, pitch<a name="index982"></a>, loudness<a name="index983"></a>, |
| 178 |
voice<a name="index984"></a> number, duration<a name="index985"></a>, and articulation<a name="index986"></a>.</p> |
| 179 |
|
| 180 |
<p>Adagio has been used to program a variety of hardware and software |
| 181 |
synthesizers, and the Adagio compiler can be easily adapted to new |
| 182 |
environments. Although not originally intended for MIDI, Adagio works quite |
| 183 |
well as a representation for MIDI scores. Adagio has been extended to allow MIDI controller |
| 184 |
data such as modulation wheels, pitch bend, and volume, MIDI program commands to change timbre, and System Exclusive messages.</p> |
| 185 |
|
| 186 |
<p>A note command in Adagio must be separated from other notes. Usually, |
| 187 |
notes are distinguished by writing each one on a separate line. |
| 188 |
Notes can also be separated by using a comma or semicolon as will |
| 189 |
be described below.</p> |
| 190 |
|
| 191 |
<p>Besides notes, there are several other types of commands: |
| 192 |
<ol> |
| 193 |
<li> |
| 194 |
An asterisk<a name="index987"></a> (<code>*</code>) in column one (or immediately after a comma, |
| 195 |
semicolon, or space) indicates that the rest of the line is a |
| 196 |
comment<a name="index988"></a>. The line is ignored by Adagio, and is therefore a |
| 197 |
good way to insert text to be read by people. Here are some examples: |
| 198 |
</p> |
| 199 |
<pre> |
| 200 |
* This is a comment. |
| 201 |
T150 G4 * This is a comment too! |
| 202 |
T150 G4 ;* So is this. |
| 203 |
</pre> |
| 204 |
|
| 205 |
<p></li> |
| 206 |
<li>An empty command (a blank<a name="index989"></a> line, for example) is ignored as if it |
| 207 |
were a comment<a name="index990"></a> <a href = "foot.html#foot5">(Footnote 5)</a> .</li> |
| 208 |
<li>An exclamation point<a name="index991"></a><a name="index992"></a> (!) in column one (or |
| 209 |
immediately after a comma or semicolon) indicates a special |
| 210 |
command<a name="index993"></a>. A special command does not generate a note. |
| 211 |
Special commands follow the “!” with no intervening spaces and extend to the end of the line, for example: |
| 212 |
</p> |
| 213 |
<pre> |
| 214 |
!TEMPO 100 |
| 215 |
</pre> |
| 216 |
|
| 217 |
<p></li> |
| 218 |
<li>Control change commands are used to control parameters like |
| 219 |
pitch bend, modulation, and program (timbre). Control |
| 220 |
change commands can be specified along with notes or by |
| 221 |
themselves. |
| 222 |
A command that specifies control changes without specifying |
| 223 |
a pitch will not produce a note. |
| 224 |
</li></ol></p> |
| 225 |
|
| 226 |
<p>Adagio is insensitive to case<a name="index994"></a>, |
| 227 |
thus “A” is equivalent to “a”, and you |
| 228 |
can mix upper and lower case letters freely.</p> |
| 229 |
<a name = "126"><h3>Specifying Attributes</h3></a> |
| 230 |
<p>A note is indicated by a set of attributes. Attributes are indicated by a string of characters with no intervening spaces because spaces separate attributes. The attributes are described below.</p> |
| 231 |
|
| 232 |
<p>The default unit of time is a centisecond |
| 233 |
(100<sup T>th</sup>'s), but this can be changed to a millisecond (1000<sup T>th</sup>'s) using the <code>!MSEC</code> command and reset to centiseconds with <code>!CSEC</code> (see Section <a href = "#141">Time Units and Resolution</a>). In the descriptions below, the term “time unit” will be used to mean whichever convention is currently in effect.</p> |
| 234 |
<a name = "127"><h4>Time</h4></a> |
| 235 |
<p>The time<a name="index995"></a> attribute specifies when to start the note. A time is |
| 236 |
specified by a “T<a name="index996"></a>” followed by a number representing time units |
| 237 |
or by a duration (durations are described below). Examples: |
| 238 |
</p> |
| 239 |
<pre> |
| 240 |
T150 ** 1.5 sec (or .15 sec) |
| 241 |
TQ3 ** 3 quarter note's duration |
| 242 |
</pre> |
| 243 |
|
| 244 |
<p> |
| 245 |
If no time is specified, the default time<a name="index997"></a> is the sum of |
| 246 |
the time and duration attributes of the previous note. (But see Section |
| 247 |
<a href = "#130">Next Time</a>.) Time is measured relative to the time of the |
| 248 |
most recent Tempo<a name="index998"></a> or Rate<a name="index999"></a> command. (See the |
| 249 |
examples in Section |
| 250 |
<a href = "#139">Examples</a> for some clarification of this point.)</p> |
| 251 |
<a name = "128"><h4>Pitch</h4></a> |
| 252 |
<p>The pitch<a name="index1000"></a> attribute specifies what frequency to produce. |
| 253 |
Standard scale pitches are named by name, using <code>S</code> for sharp<a name="index1001"></a>, |
| 254 |
<code>F</code> for flat<a name="index1002"></a>, |
| 255 |
and (optionally) <code>N</code> for natural<a name="index1003"></a>. |
| 256 |
For example, <code>C</code> and <code>CN</code> represent the same pitch, as do <code>FS</code> and <code>GF</code> (F sharp and G flat). Note that there are no bar lines, and accidentals to not carry forward to any other notes as in common practice notation.</p> |
| 257 |
|
| 258 |
<p>Octaves<a name="index1004"></a> are specified by |
| 259 |
number. <code>C4</code> is middle C, and <code>B3</code> is a half step lower. <code>F5</code> is the top line of |
| 260 |
the treble clef, etc. (Adagio octave numbering follows the ISO standard, but note that this is not universal. In particular, Yamaha refers to middle C as C3.) Accidentals<a name="index1005"></a><a name="index1006"></a><a name="index1007"></a> can go before or after |
| 261 |
the octave number, so <code>FS3</code> and <code>F3S</code> have the same meaning. </p> |
| 262 |
|
| 263 |
<p>An alternate |
| 264 |
notation for pitch is <code>P</code><i>n</i>, where <i>n</i> is an integer representing the pitch.<a name="index1008"></a> |
| 265 |
Middle C<a name="index1009"></a> (C4) is equivalent to <code>P60</code>, <code>CS4</code> is <code>P61</code>, etc. </p> |
| 266 |
|
| 267 |
<p>If you do not specify an octave<a name="index1010"></a>, |
| 268 |
Adagio will choose one for you. This |
| 269 |
is done by picking the octave that will make the current pitch as close |
| 270 |
to the previous pitch as possible. In the case of augmented fourths |
| 271 |
or diminished fifths, there are two equally good choices. Adagio |
| 272 |
chooses the lower octave.</p> |
| 273 |
<a name = "129"><h4>Duration</h4></a> |
| 274 |
<p>Duration<a name="index1011"></a> is specified by a letter indicating a number of |
| 275 |
beats, followed by one or several modifiers. The basic duration codes are: |
| 276 |
|
| 277 |
<blockquote> |
| 278 |
<code>W</code><a name="index1012"></a>   (whole<a name="index1013"></a>, 4 beats), <br> |
| 279 |
|
| 280 |
<code>H</code><a name="index1014"></a>   (half<a name="index1015"></a>, 2 beats), <br> |
| 281 |
|
| 282 |
<code>Q</code><a name="index1016"></a>   (quarter<a name="index1017"></a>, 1 beat), <br> |
| 283 |
|
| 284 |
<code>I</code><a name="index1018"></a>   (eighth<a name="index1019"></a>, 1/2 beat), <br> |
| 285 |
|
| 286 |
<code>S</code><a name="index1020"></a>   (sixteenth<a name="index1021"></a>, 1/4 beat), <br> |
| 287 |
|
| 288 |
<code>%</code><a name="index1022"></a>   (thirtysecond<a name="index1023"></a>, 1/8 beat), and<br> |
| 289 |
|
| 290 |
<code>^</code><a name="index1024"></a>   (sixtyfourth<a name="index1025"></a>, 1/16 beat). </blockquote> |
| 291 |
Note that <code>E</code> is a pitch, so eighth-notes use the duration code <code>I</code>. |
| 292 |
The default tempo is 100 beats per |
| 293 |
minute (see Section <a href = "#136">Tempo</a>). These codes may be followed by a <code>T</code> |
| 294 |
(triplet<a name="index1026"></a><a name="index1027"></a>), indicating a duration of 2/3 the normal. A dot<a name="index1028"></a><a name="index1029"></a> (<code>.</code>) after a |
| 295 |
duration code extends it by half to 3/2 the normal. An integer |
| 296 |
after a note multiplies its duration by the indicated value (the result is |
| 297 |
still just one note). Finally, a slash followed by an integer divides |
| 298 |
the duration by the integer. Like all attributes, duration attributes may not have embedded spaces. Examples: |
| 299 |
|
| 300 |
|
| 301 |
<blockquote> |
| 302 |
<table> |
| 303 |
<tr><td><code>Q</code></td><td> </td><td>1 beat (quarter note)</td></tr> |
| 304 |
<tr><td><code>QT</code></td><td></td><td>2/3 beat (quarter triplet)</td></tr> |
| 305 |
<tr><td><code>W.</code></td><td></td><td>6 beats(dotted whole note)</td></tr> |
| 306 |
<tr><td><code>ST6</code></td><td></td><td>1 beat (6 sixteenth triplets) </td></tr> |
| 307 |
<tr><td><code>H5</code></td><td></td><td>10 beats(5 half notes)</td></tr> |
| 308 |
<tr><td><code>Q3/7</code></td><td></td><td>3/7 beats</td></tr></table> |
| 309 |
</blockquote> |
| 310 |
|
| 311 |
A duration may be noted by <code>U</code><i>n</i><a name="index1030"></a>, where <i>n</i> is an integer |
| 312 |
indicating 100<sup T>th</sup>'s of a second |
| 313 |
(or 1000<sup T>th</sup>'s), see Section <a href = "#141">Time Units and Resolution</a>. |
| 314 |
For example, <code>U25</code> is twenty-five time units.</p> |
| 315 |
|
| 316 |
<p>Durations may be combined using a plus sign: |
| 317 |
</p> |
| 318 |
<pre> |
| 319 |
Q+IT ** a quarter tied to an eighth triplet |
| 320 |
Q/7+W+Q2/7 ** a 7th beat tied to a whole tied to 2/7th beat |
| 321 |
Q+U10 ** a quarter plus 10 time units |
| 322 |
</pre> |
| 323 |
|
| 324 |
<a name = "130"><h4>Next Time</h4></a> |
| 325 |
<p>The time of the next<a name="index1031"></a><a name="index1032"></a> command (the next command in the Adagio |
| 326 |
program text) is |
| 327 |
normally the time of the current note command |
| 328 |
plus the duration of the current note. |
| 329 |
This can be overridden by a field consisting of the letter <code>N</code> |
| 330 |
followed by a number indicating time units, or followed by a |
| 331 |
duration as described above. The next note will then start at the time of |
| 332 |
the current note plus the duration specified after <code>N</code>. If the next note |
| 333 |
has an explicit time attribute (<code>T</code>), then the specified time will override |
| 334 |
the one based on the previous note. Examples: |
| 335 |
</p> |
| 336 |
<pre> |
| 337 |
N0 ** start the next note at the same time as this one |
| 338 |
N50 ** start the next note 0.5 seconds after this one |
| 339 |
NQT ** start the next note 2/3 beat after the current one |
| 340 |
NU10+Q ** start after 0.1 seconds plus a quarter |
| 341 |
</pre> |
| 342 |
|
| 343 |
<p> |
| 344 |
A comma has an effect similar to <code>N0</code> and is explained in Section <a href = "#142">Multiple Notes Per Line</a>. Articulation effects such as <i>staccato</i> can be produced using <code>N</code>, but it is more convenient to use the articulation attribute described in Section <a href = "#132">Articulation</a>.</p> |
| 345 |
<a name = "131"><h4>Rest</h4></a> |
| 346 |
<p>Rests<a name="index1033"></a><a name="index1034"></a> are obtained by including the field <code>R</code> in a |
| 347 |
note command. The effect of an <code>R</code> field is to omit the note that would |
| 348 |
otherwise occur as the result of the current note command. In all other |
| 349 |
respects, the command is processed just like any other line. This means that |
| 350 |
attributes such as duration, loudness, and pitch can be specified, and |
| 351 |
anything specified will be inherited by the note in the next command. |
| 352 |
Normally, a rest will include just <code>R</code> and a duration. The fact that a |
| 353 |
note command specifies a rest is not inherited. For example: |
| 354 |
</p> |
| 355 |
<pre> |
| 356 |
R H ** a half (two beat) rest |
| 357 |
RH ** illegal, R must be separated from H by space(s) |
| 358 |
</pre> |
| 359 |
|
| 360 |
<p> </p> |
| 361 |
|
| 362 |
<p>Because some synthesizers (e.g. a DX7<a name="index1035"></a>) cannot change programs |
| 363 |
<a name="index1036"></a> |
| 364 |
(presets) rapidly, it may be desirable to change programs in |
| 365 |
a rest so that the synthesizer will be ready to play by |
| 366 |
the end of the rest. See Section <a href = "#135">Timbre (MIDI Program)</a> for an example.</p> |
| 367 |
<a name = "132"><h4>Articulation</h4></a> |
| 368 |
<p>Articulation<a name="index1037"></a><a name="index1038"></a><a name="index1039"></a> in Adagio refers to the |
| 369 |
percentage of time a note is on relative to the indicated duration. For |
| 370 |
example, to play a note <i>staccato</i>, you would normally play the note about |
| 371 |
half of its indicated duration. In Adagio, articulation is indicated by |
| 372 |
<code>#</code><a name="index1040"></a> followed by an integer number indicating a percentage. The |
| 373 |
articulation attribute does not affect the time of the next command. This |
| 374 |
example plays two <i>staccato</i> quarter notes: |
| 375 |
</p> |
| 376 |
<pre> |
| 377 |
C Q #50 |
| 378 |
D |
| 379 |
</pre> |
| 380 |
|
| 381 |
<p> |
| 382 |
To produce overlapping notes, the articulation may be greater than 100. </p> |
| 383 |
<small> |
| 384 |
Be aware that overlapping notes on the same pitch can be a problem for some synthesizers. The following example illustrates this potential problem: |
| 385 |
|
| 386 |
<p></p> |
| 387 |
<pre> |
| 388 |
!TEMPO 60 |
| 389 |
C Q #160 * starts at time 0, ends at 1.6 sec |
| 390 |
D I * starts at time 1, ends at 1.8 sec |
| 391 |
C Q * starts at time 1.5, ends at 3.1 sec? |
| 392 |
</pre> |
| 393 |
|
| 394 |
<p> |
| 395 |
At one beat per second (tempo 60), these three notes will start at times 0, 1, and 1.5 seconds, respectively. Since these notes have an articulation of 160, each will be on 160% of its nominal duration, so the first note (C) will remain on until 1.6 seconds. But the third note (another C) will start at time 1.5 seconds. Thus, the second C will be started before the first one ends. Depending on the synthesizer, this may cancel the first C or play a second C in unison. In either case, a note-off message will be sent at time 1.6 seconds. If this cancels the second C, its actual duration will be 0.1 rather than 1.6 seconds as intended. A final note-off will be sent at time 3.1 seconds. |
| 396 |
</p> |
| 397 |
</small> |
| 398 |
<a name = "133"><h4>Loudness</h4></a> |
| 399 |
<p>Loudness<a name="index1041"></a><a name="index1042"></a> is indicated by an <code>L</code> |
| 400 |
followed by a dynamic marking from the following: <code>PPP</code><a name="index1043"></a><a name="index1044"></a>, |
| 401 |
<code>PP</code><a name="index1045"></a><a name="index1046"></a>, <code>P</code><a name="index1047"></a><a name="index1048"></a>, <code>MP</code><a name="index1049"></a><a name="index1050"></a>, <code>MF</code><a name="index1051"></a><a name="index1052"></a>, <code>F</code><a name="index1053"></a><a name="index1054"></a>, |
| 402 |
<code>FF</code><a name="index1055"></a><a name="index1056"></a>, <code>FFF</code><a name="index1057"></a><a name="index1058"></a>. Alternatively, a number from 1 to 127 may be |
| 403 |
used. The loudness attribute is the MIDI note velocity. (Note that a MIDI velocity of 0 means “note-off,” so the minimum loudness is 1.) The |
| 404 |
dynamic<a name="index1059"></a> |
| 405 |
markings are translated into numbers as follows: |
| 406 |
|
| 407 |
<blockquote> |
| 408 |
<table> |
| 409 |
<tr><td><code>Lppp</code></td><td> </td><td>20</td> |
| 410 |
<td> </td> |
| 411 |
<td><code>Lmf</code></td><td> </td><td>58</td></tr> |
| 412 |
<tr><td><code>Lpp</code></td><td></td><td>26</td> |
| 413 |
<td></td> |
| 414 |
<td><code>Lf</code></td><td></td><td>75</td></tr> |
| 415 |
<tr><td><code>Lp</code></td><td></td><td>34</td> |
| 416 |
<td></td> |
| 417 |
<td><code>Lff</code></td><td></td><td>98</td></tr> |
| 418 |
<tr><td><code>Lmp</code></td><td></td><td>44</td> |
| 419 |
<td></td> |
| 420 |
<td><code>Lfff</code></td><td></td><td>127</td></tr> |
| 421 |
</table> |
| 422 |
</blockquote> |
| 423 |
</p> |
| 424 |
<a name = "134"><h4>Voice</h4></a> |
| 425 |
<p>The voice<a name="index1060"></a><a name="index1061"></a> attribute tells which of the 16 MIDI channels to use |
| 426 |
for the note. The voice attribute consists of a <code>V</code> followed by |
| 427 |
an integer from 1 (the default) to 16. </p> |
| 428 |
<small> |
| 429 |
There is a limit to how many notes |
| 430 |
can be played at the same time on a given voice (MIDI channel). Since the |
| 431 |
limit depends upon the synthesizer, Adagio cannot tell you when you exceed |
| 432 |
the limit. Similarly, Adagio cannot tell whether your synthesizer is set up |
| 433 |
to respond to a given channel, so there is no guarantee that what you write |
| 434 |
will actually be heard. |
| 435 |
</small> |
| 436 |
<a name = "135"><h4>Timbre (MIDI Program)</h4></a> |
| 437 |
<p>A MIDI program<a name="index1062"></a><a name="index1063"></a> (synthesizer preset<a name="index1064"></a>) can be |
| 438 |
selected using the attribute <code>Z</code><i>n</i>, where <i>n</i> |
| 439 |
is the program number (from 1 to 128). |
| 440 |
Notice that in MIDI, changing the program on a given channel will affect |
| 441 |
<i>all</i> notes on that channel and possibly others. Adagio treats MIDI program changes as a form of control change.</p> |
| 442 |
<small> |
| 443 |
For many synthesizers, you will not be |
| 444 |
able to change programs at the start of a note or during a note. Change the |
| 445 |
program during a rest instead. For example: |
| 446 |
|
| 447 |
<p></p> |
| 448 |
<pre> |
| 449 |
R I Z23 V4 ** change MIDI channel 4 to program 23 during rest |
| 450 |
A4 ** play a note on channel 4 |
| 451 |
</pre> |
| 452 |
|
| 453 |
<p> |
| 454 |
Check how your synthesizer interprets program numbers. For example, |
| 455 |
the cartridge programs on a DX7 can be accessed by adding 32 to the |
| 456 |
cartridge program number. Cartridge program number 10 |
| 457 |
is specified by <code>Z42</code>. |
| 458 |
</p> |
| 459 |
</small> |
| 460 |
|
| 461 |
<p>As in MIDI, the Adagio timbre is a property of the voice (MIDI channel), so |
| 462 |
the timbre will not be inherited by notes on a different channel; |
| 463 |
to change the timbre on multiple voices (channels), you must explicitly |
| 464 |
notate each change.</p> |
| 465 |
<a name = "136"><h4>Tempo</h4></a> |
| 466 |
<p>The length of a beat may be changed using a Tempo<a name="index1065"></a> command<a name="index1066"></a>: |
| 467 |
</p> |
| 468 |
<pre> |
| 469 |
!TEMPO <i>n</i> |
| 470 |
</pre> |
| 471 |
|
| 472 |
<p> |
| 473 |
where <i>n</i> indicates beats per minute. The exclamation mark tells Adagio that |
| 474 |
this is a special command line rather than a note definition. A special |
| 475 |
command takes the place of a note specification. |
| 476 |
No other attributes should be written on a line with a special command. |
| 477 |
The <code>!TEMPO</code> command is associated with a time, computed as if the <code>!TEMPO</code> command were a note. The time<a name="index1067"></a> attribute (<code>T</code>) of all |
| 478 |
succeeding notes is now measured relative to the time of the <code>!TEMPO</code> command. The new tempo starts at the <code>!TEMPO</code> command time and |
| 479 |
affects all succeeding notes. |
| 480 |
Durations specified in time units (for example <code>U58</code>, <code>N15</code>) are not affected by the <code>!TEMPO</code> command, and numerical times (for example <code>T851</code>) are computed relative to the time of the last <code>!TEMPO</code> command.</p> |
| 481 |
|
| 482 |
<p>The <code>!TEMPO</code> command is fairly clever about default durations<a name="index1068"></a>. If the last duration specified before the <code>!TEMPO</code> command is |
| 483 |
symbolic (using one of <code>^</code>, <code>%</code>, <code>S</code>, <code>I</code>, <code>Q</code>, <code>H</code>, or <code>W</code> ), then the default duration for the |
| 484 |
node after the <code>!TEMPO</code> command will be modified according to the tempo change. |
| 485 |
Consider the following tempo change: |
| 486 |
</p> |
| 487 |
<pre> |
| 488 |
!TEMPO 60 |
| 489 |
A4 H |
| 490 |
!TEMPO 120 |
| 491 |
G |
| 492 |
</pre> |
| 493 |
|
| 494 |
<p> |
| 495 |
In this example, the first note will last 2 seconds (2 beats at 60 |
| 496 |
beats per minute). The second note inherits the duration (H) from |
| 497 |
the first note, but at 120 beats per minute, the second note will last |
| 498 |
only 1 second. If the duration had been specified <code>U200</code> (also a |
| 499 |
duration of 2 seconds), the second note would also last 2 seconds because the <code>!TEMPO</code> command does not affect times or durations specified numerically in time units. If the duration is the sum of a symbolic and a numeric specification, the inherited duration after a <code>!TEMPO</code> command is undefined.</p> |
| 500 |
<a name = "137"><h4>Rate</h4></a> |
| 501 |
<p>The <code>!RATE</code><a name="index1069"></a><a name="index1070"></a> command scales all times including those specified in |
| 502 |
hundredths of seconds. A rate of 100 means no change, 200 means twice as |
| 503 |
fast, and 50 means half as fast. For example, to make a piece play 10% |
| 504 |
faster, you can add the following command at the beginning of the score: |
| 505 |
</p> |
| 506 |
<pre> |
| 507 |
!RATE 110 |
| 508 |
</pre> |
| 509 |
|
| 510 |
<p> |
| 511 |
<code>!RATE</code> and <code>!TEMPO</code> commands combine, so |
| 512 |
</p> |
| 513 |
<pre> |
| 514 |
!RATE 200 |
| 515 |
!TEMPO 70 |
| 516 |
</pre> |
| 517 |
|
| 518 |
<p> |
| 519 |
will play 70 beats per minute at double the normal speed, or 140 beats |
| 520 |
per minute. Like <code>!TEMPO</code>, the time of the <code>!RATE</code> command is added to the |
| 521 |
time attribute of all following notes up to the next <code>!TEMPO</code> or <code>!RATE</code> |
| 522 |
command.</p> |
| 523 |
|
| 524 |
<p>Two <code>!RATE</code> commands do not combine, so a <code>!RATE</code> command only affects the rate until the next <code>!RATE</code> command.</p> |
| 525 |
|
| 526 |
<p>Although <code>!TEMPO</code> and <code>!RATE</code> can occur in the middle of a note (using <code>N</code>, <code>T</code>, etc.) they do not affect a note already specified. This property allows multiple tempi to exist simultaneously (see Section <a href = "#144">Multiple Tempi</a>).</p> |
| 527 |
<a name = "138"><h3>Default Attributes</h3></a> |
| 528 |
<p>If an attribute is omitted, the previous one is used by |
| 529 |
default<a name="index1071"></a> (with the exception of the time attribute). The |
| 530 |
default values for the first note, which are inherited by succeeding notes |
| 531 |
until something else is specified, are given below in Adagio notation: |
| 532 |
|
| 533 |
<blockquote> |
| 534 |
<table> |
| 535 |
<tr><td>Time </td><td> </td><td><code>T0 </code></td></tr> |
| 536 |
<tr><td>Pitch </td><td> </td><td><code>C4 </code></td></tr> |
| 537 |
<tr><td>Duration </td><td> </td><td><code>Q </code></td></tr> |
| 538 |
<tr><td>Articulation</td><td> </td><td><code>#100</code></td></tr> |
| 539 |
<tr><td>Loudness </td><td> </td><td><code>LFFF</code></td></tr> |
| 540 |
<tr><td>Voice </td><td> </td><td><code>V1 </code></td></tr> |
| 541 |
<tr><td>Tempo </td><td> </td><td><code>!TEMPO 100</code></td></tr> |
| 542 |
<tr><td>Rate </td><td> </td><td><code>!RATE 100</code></td></tr></table> |
| 543 |
</blockquote> |
| 544 |
|
| 545 |
Control changes (including timbre or MIDI program, specified by <code>Z</code>) have no default value and are only sent as specified in the score.</p> |
| 546 |
<b><i>Important:</i></b> the rules for determining when a command will play a note are as follows (and this has changed slightly from previous versions): |
| 547 |
<ol> |
| 548 |
<li> |
| 549 |
If a special (<code>!</code>) command or nothing is specified, e.g. a blank line, do <i>not</i> play a note.</li> |
| 550 |
<li>If <code>R</code> (for “rest”) is specified, do <i>not</i> play a note.</li> |
| 551 |
<li>Otherwise, if a pitch is specified, <i>do</i> play a note.</li> |
| 552 |
<li>Otherwise, if no control changes (or program changes) are specified (so this is a command with non-pitch attributes and no control changes), <i>do</i> play a note. |
| 553 |
</li></ol> |
| 554 |
Another way to say this is “Special commands and commands with rests (<code>R</code>) do not play notes. Otherwise, play a note if a pitch is specified or if no control is specified.”<a name = "139"><h3>Examples</h3></a> |
| 555 |
<p>The following plays the first two bars of “Happy Birthday”. Note that |
| 556 |
Adagio knows nothing of bar lines, so the fact that the first note occurs |
| 557 |
on beat 3 or that the meter is three-four is of no consequence: |
| 558 |
</p> |
| 559 |
<pre> |
| 560 |
*Example 1 ** Happy Birthday tune (C major) |
| 561 |
!TEMPO 120 |
| 562 |
G4 I. LF |
| 563 |
G4 S |
| 564 |
A4 Q |
| 565 |
G4 |
| 566 |
C5 |
| 567 |
B4 H |
| 568 |
</pre> |
| 569 |
|
| 570 |
<p> |
| 571 |
The time attribute for the first note is zero (<code>0</code>). The second note |
| 572 |
will occur a dotted eighth later, etc. |
| 573 |
Notice that no timbre or rate was specified. |
| 574 |
Adagio will provide reasonable default |
| 575 |
values of 1 and 100, respectively.</p> |
| 576 |
|
| 577 |
<p>The following example plays the first four bars of an exercise from |
| 578 |
Bartok<a name="index1072"></a>'s Mikrokosmos<a name="index1073"></a> (Vol. 1, No. 12). |
| 579 |
An extra quarter note is inserted at the beginning of each voice in order to |
| 580 |
allow time to change MIDI programs. The right hand part is played on voice |
| 581 |
(MIDI channel) 1 and the left hand part on voice 2. Notice the |
| 582 |
specification of the time attribute to indicate that voice 2 starts at time |
| 583 |
0. Also, default octaves are used to reduce typing. |
| 584 |
</p> |
| 585 |
<pre> |
| 586 |
*Example 2 ** Bartok |
| 587 |
*voice 1, right hand |
| 588 |
R Q Z10 V1 ** extra rest for program change |
| 589 |
A4 H |
| 590 |
B Q |
| 591 |
C |
| 592 |
D H |
| 593 |
C |
| 594 |
D Q |
| 595 |
C |
| 596 |
B |
| 597 |
A |
| 598 |
B |
| 599 |
C |
| 600 |
D |
| 601 |
R |
| 602 |
</pre> |
| 603 |
|
| 604 |
<p> |
| 605 |
</p> |
| 606 |
<pre> |
| 607 |
*voice 2, left hand |
| 608 |
T0 R Q Z15 V2 ** extra rest for program change |
| 609 |
G3 H |
| 610 |
F Q |
| 611 |
E |
| 612 |
D H |
| 613 |
E |
| 614 |
D Q |
| 615 |
E |
| 616 |
F |
| 617 |
G |
| 618 |
F |
| 619 |
E |
| 620 |
D |
| 621 |
R |
| 622 |
</pre> |
| 623 |
|
| 624 |
<p></p> |
| 625 |
|
| 626 |
The next example is the same piece expressed in a different manner, |
| 627 |
illustrating the interaction |
| 628 |
between the <code>!TEMPO</code> command and the time attribute. Recall that the |
| 629 |
time attribute is measured relative to the time of the last <code>!TEMPO</code> command: |
| 630 |
|
| 631 |
<p></p> |
| 632 |
<pre> |
| 633 |
*Example 3 ** 4 measures in 2 sections |
| 634 |
!Tempo 100 |
| 635 |
*Voice 1, Measures 1 & 2 |
| 636 |
R Q Z10 V1 |
| 637 |
A4 H |
| 638 |
B Q |
| 639 |
C |
| 640 |
D H |
| 641 |
C |
| 642 |
</pre> |
| 643 |
|
| 644 |
<p> |
| 645 |
</p> |
| 646 |
<pre> |
| 647 |
*Voice 2, Measures 1 & 2 |
| 648 |
T0 R Q Z15 V2 |
| 649 |
G3 H |
| 650 |
F Q |
| 651 |
E |
| 652 |
D H |
| 653 |
E H |
| 654 |
</pre> |
| 655 |
|
| 656 |
<p> |
| 657 |
</p> |
| 658 |
<pre> |
| 659 |
!TEMPO 100 |
| 660 |
*Voice 1, Measures 3 & 4 |
| 661 |
* note that Z10 is still in effect for V1 |
| 662 |
V1 D4 Q |
| 663 |
C |
| 664 |
B |
| 665 |
A |
| 666 |
B |
| 667 |
C |
| 668 |
D |
| 669 |
R |
| 670 |
</pre> |
| 671 |
|
| 672 |
<p> |
| 673 |
</p> |
| 674 |
<pre> |
| 675 |
*Voice 2, Measures 3 & 4 |
| 676 |
T0 V2 D3 Q |
| 677 |
E |
| 678 |
F |
| 679 |
G |
| 680 |
F |
| 681 |
E |
| 682 |
D |
| 683 |
R |
| 684 |
</pre> |
| 685 |
|
| 686 |
<p></p> |
| 687 |
|
| 688 |
<p>The piece is written in 4 sections. The first |
| 689 |
plays a rest followed by two measures, starting |
| 690 |
at time 0. The next section changes the time back to |
| 691 |
zero and plays two measures of the left hand part (voice 2). |
| 692 |
The next |
| 693 |
command (!TEMPO 100) sets the tempo to 100 (it already is) |
| 694 |
<i>and</i> sets the reference time to |
| 695 |
be two measures into the piece. Therefore, the next note |
| 696 |
<code>(D4</code>) will begin measure 3. The <code>D3</code> that begins the last |
| 697 |
group of notes has a <code>T0</code> attribute, so it will also start at measure |
| 698 |
3. Notice how the <code>!TEMPO</code> command can serve to divide a piece into |
| 699 |
sections<a name="index1074"></a>.</p> |
| 700 |
|
| 701 |
<p>The last example will show yet another way to express the same piece of |
| 702 |
music using the “Next” attribute. Only the first bar of music is |
| 703 |
given. |
| 704 |
</p> |
| 705 |
<pre> |
| 706 |
*Example 4 ** use of the Next attribute |
| 707 |
!Tempo 100 |
| 708 |
R Q Z10 V1 N0 |
| 709 |
R Q Z15 V2 |
| 710 |
|
| 711 |
A4 H V1 N0 |
| 712 |
G3 V2 |
| 713 |
|
| 714 |
B4 Q V1 N0 |
| 715 |
F3 V2 |
| 716 |
|
| 717 |
C4 Q V1 N0 |
| 718 |
E3 V2 |
| 719 |
</pre> |
| 720 |
|
| 721 |
<p> |
| 722 |
Here, each pair of |
| 723 |
lines represents two simultaneous notes. The <code>N0</code> attribute |
| 724 |
forces the second line to start at the same time as the first line of each |
| 725 |
pair. Because of the large intervals, octave numbers (3 and 4) are |
| 726 |
necessary to override the default octave for these pitches.</p> |
| 727 |
<a name = "140"><h3>Advanced Features</h3></a> |
| 728 |
<p>Beyond the simple notation described above, Adagio supports a number of |
| 729 |
features. (See also the next chapter.)</p> |
| 730 |
<a name = "141"><h4>Time Units and Resolution</h4></a><a name="index1075"></a><a name="index1076"></a> |
| 731 |
<p>The default time unit is 10ms (ten milliseconds or one centisecond or |
| 732 |
100<sup T>th</sup> of a second), but it is |
| 733 |
possible to change the basic unit to 1ms, or 1000<sup T>th</sup> of a second. |
| 734 |
The time unit can be specified by: |
| 735 |
<blockquote><a name="index1077"></a> |
| 736 |
<a name="index1078"></a><table> |
| 737 |
<tr><td><code>!CSEC</code></td><td> </td><td>centisecond time units = 100<sup T>th</sup></td></tr> |
| 738 |
<tr><td><code>!MSEC</code></td><td></td><td>millisecond time units = 1000<sup T>th</sup></td></tr></table> |
| 739 |
</blockquote> |
| 740 |
The time unit remains in effect until the next <code>!CSEC</code> or <code>!MSEC</code> command.</p> |
| 741 |
<a name = "142"><h4>Multiple Notes Per Line</h4></a><a name="index1079"></a> |
| 742 |
<p>Notes can be separated by commas<a name="index1080"></a><a name="index1081"></a> or |
| 743 |
semicolons<a name="index1082"></a><a name="index1083"></a> as well as by starting a new line. A comma is |
| 744 |
equivalent to typing <code>N0</code> and starting a new line. In other words, the next note after a comma will start at the same time as the note before the comma. In general, <i>use commas to separate the notes of a chord.</i></p> |
| 745 |
|
| 746 |
<p>A semicolon is equivalent to starting a new line. In general, <i>use semicolons to group notes in a melody</i>. Here is yet another rendition of the Bartok: |
| 747 |
</p> |
| 748 |
<pre> |
| 749 |
*Example 5 ** use of semicolons |
| 750 |
!Tempo 100 |
| 751 |
R Q Z10 V1 |
| 752 |
A4 H; B Q; C; D H; C; D Q; C; B; A; B; C; D; R |
| 753 |
|
| 754 |
T0 R Q Z15 V2 |
| 755 |
G3 H; F Q; E; D H; E; D Q; E; F; G; F; E; D; R |
| 756 |
</pre> |
| 757 |
|
| 758 |
<p> |
| 759 |
This example is similar to Example 2, except semicolons are used. Note how semicolons make the two lines of music stand out. |
| 760 |
The next example is similar to Example 4, except commas are used |
| 761 |
and four bars are notated. The music below is treated as a sequence of 2-note chords, with each chord on a separate line: |
| 762 |
</p> |
| 763 |
<pre> |
| 764 |
*Example 6 ** use of commas |
| 765 |
!Tempo 100 |
| 766 |
R Q Z10 V1, R Q Z15 V2 |
| 767 |
A4 H V1, G3 V2 |
| 768 |
B4 Q V1, F3 V2 |
| 769 |
C4 V1, E3 V2 |
| 770 |
D4 H V1, D3 V2 |
| 771 |
C4 V1, E3 V2 |
| 772 |
D4 Q V1, D3 V2 |
| 773 |
C4 V1, E3 V2 |
| 774 |
B4 V1, F3 V2 |
| 775 |
A4 V1, G3 V2 |
| 776 |
B4 V1, F3 V2 |
| 777 |
C4 V1, E3 V2 |
| 778 |
D4 V1, D3 V2 |
| 779 |
R |
| 780 |
</pre> |
| 781 |
|
| 782 |
<p></p> |
| 783 |
<a name = "143"><h4>Control Change Commands</h4></a><a name="index1084"></a><a name="index1085"></a> |
| 784 |
<p>Any control change can be specified using |
| 785 |
the syntax “<tt>~<i>n</i>(<i>v</i>)</tt>”, where <i>n</i> is the controller number (0 - 127), and |
| 786 |
<i>v</i> is the value. In addition, Adagio has some special syntax for |
| 787 |
some of the commonly used control changes (note that Pitch bend, Aftertouch, and MIDI Program Change are technically not MIDI control changes but have their own |
| 788 |
special message format and status bytes): |
| 789 |
|
| 790 |
|
| 791 |
<blockquote> |
| 792 |
<table> |
| 793 |
<tr><td><code>K</code></td><a name="index1086"></a><a name="index1087"></a><td> </td><td>Portamento switch</td></tr> |
| 794 |
<tr><td><code>M</code></td><a name="index1088"></a><a name="index1089"></a><td></td><td>Modulation wheel</td></tr> |
| 795 |
<tr><td><code>O</code></td><a name="index1090"></a><a name="index1091"></a><td></td><td>Aftertouch</td></tr> |
| 796 |
<tr><td><code>X</code></td><a name="index1092"></a><a name="index1093"></a><td></td><td>Volume</td></tr> |
| 797 |
<tr><td><code>Y</code></td><a name="index1094"></a><a name="index1095"></a><td></td><td>Pitch bend</td></tr> |
| 798 |
<tr><td><code>Z</code></td><a name="index1096"></a><a name="index1097"></a><td></td><td>Program Change</td></tr></table> |
| 799 |
</blockquote> |
| 800 |
|
| 801 |
The letter listed beside each control function is the Adagio command |
| 802 |
letter. For example, <code>M23</code> is the command for setting the modulation |
| 803 |
wheel to 23. Except for pitch bend, the portamento switch, and MIDI Program Change, all |
| 804 |
values range from 0 to 127. Pitch bend is “off” or centered at |
| 805 |
128, and has a range from 0 to 255 (MIDI allows for more precision, but |
| 806 |
Adagio does not). Turn on portamento with <code>K127</code> and off with <code>K0</code>. Programs are numbered 1 to 128 to correspond to synthesizer displays.</p> |
| 807 |
<b><i>About volume:</i></b> Midi volume is just a control, and the Midi standard does not say what it means. Typically it does what the volume pedal does; that is, it scales the amplitude in a continuously changeable fashion. In contrast, Midi velocity, which is controlled by the <code>L</code> (loudness) attribute, is part of a Midi note-on command and is fixed for the duration of the note. Typically, these two ways of controlling loudness and amplitude operate independently. In some low-cost synthesizers the numbers seem to be added together internally and volume changes are ignored after the note starts.<b><i>About pitch bend:</i></b> Midi pitch bend is a number from 0 to 16383, where 8192 is the center position. To convert to Midi, Adagio simply multiplies your number by 64, giving values from 0 to 16320. Note that <code>Y128</code> translates exactly to 8192. The <i>meaning</i> of pitch bend depends upon your synthesizer and its setting. Most synthesizers let you specify a “pitch bend range.” A range of one semitone means that <code>Y255</code> will produce a bend of approximately one semitone up, and <code>Y0</code> will bend one semitone down. If the range is 12 semitones, then the same <code>Y255</code> will bend an octave. Typically, pitch bend is exponential, so each increment in the pitch bend value will bend an equal number of cents in pitch. |
| 808 |
<p>Control changes can be part of a note specification or independent. |
| 809 |
In the following example, a middle C is played with a modulation |
| 810 |
wheel setting of 50 and a pitch bend of 120. Then, at 10 unit |
| 811 |
intervals, the pitch bend is decreased by 10. The last line sets the |
| 812 |
portamento time (controller 5) to 80: |
| 813 |
</p> |
| 814 |
<pre> |
| 815 |
*Example 7 |
| 816 |
C4 LMF M50 Y120 U100 N10 |
| 817 |
Y110 N10; Y100 N10; Y90 N10; Y80 N10 |
| 818 |
Y70 N10; Y60 N10; Y50 N10 |
| 819 |
~5(80) |
| 820 |
</pre> |
| 821 |
|
| 822 |
<p></p> |
| 823 |
|
| 824 |
<p>See Section <a href = "#138">Default Attributes</a> on page <a href = "#138">Default Attributes</a> for rules on whether or not a command will play a note.</p> |
| 825 |
<a name = "144"><h4>Multiple Tempi</h4></a><a name="index1098"></a><a name="index1099"></a> |
| 826 |
<p>Writing a piece with multiple tempi requires no new commands; you |
| 827 |
just have to be clever in the use of Tempo and Time. The following |
| 828 |
plays a 7 note diatonic scale on voice 1, and a 12 note chromatic |
| 829 |
scale on voice 2: |
| 830 |
</p> |
| 831 |
<pre> |
| 832 |
*Example 8 ** multiple tempi |
| 833 |
!TEMPO 70 |
| 834 |
V1 C4; D; E; F; G; A; B |
| 835 |
T0 R N0 |
| 836 |
|
| 837 |
!TEMPO 120 |
| 838 |
V2 C4; CS; D; DS; E; F; FS; G; GS; A; AS; B |
| 839 |
|
| 840 |
!TEMPO 100 |
| 841 |
V1 C5, V2 C5 |
| 842 |
</pre> |
| 843 |
|
| 844 |
<p> |
| 845 |
The third line plays the 7-note diatonic scale on voice 1. The |
| 846 |
next line contains the tricky part: notice that the time is |
| 847 |
set back to zero, there is a rest, and a next (<code>N</code>) attribute is used |
| 848 |
to specify that the next default time will be at the same time as |
| 849 |
the current one. This is tricky because a <code>!TEMPO</code> command cannot have a time (<code>T0</code>) attribute, and a <code>T0</code> by itself would create a note with a duration. <code>T0 R N0</code> says: “go to time 0, do not play a note, and do not advance the time before the next command”. |
| 850 |
Thus, the time of the <code>!TEMPO 120</code> command is zero. |
| 851 |
After the 12 note scale, the tempo is changed to 100 and a final note |
| 852 |
is played on each voice. A little arithmetic will show that 7 notes |
| 853 |
at tempo 70 and 12 notes at tempo 120 each take 6 seconds, so the |
| 854 |
final notes (<code>C5</code>) of each scale will happen at the same time. |
| 855 |
|
| 856 |
<a name = "145"><h4>MIDI Synchronization</h4></a></p> |
| 857 |
<a name="index1100"></a><a name="index1101"></a><a name="index1102"></a><a name="index1103"></a> |
| 858 |
<p>The Adagio program (but not Nyquist) can synchronize with external devices using MIDI real time messages. Thus, Adagio has a <code>!CLOCK</code> command. This command is currently of no use to Nyquist users but is documented here for completeness (it's part of the language syntax even if it does not do anything). </p> |
| 859 |
|
| 860 |
<p>Since Adagio supports multiple tempi, and Midi clock is |
| 861 |
based on beats, it is necessary to be explicit in the score about where the |
| 862 |
clock should start and what is the duration of a quarter note. The |
| 863 |
<code>!CLOCK</code> command<a name="index1104"></a> in Adagio turns on a 24 pulse-per-quarter (PPQ) clock at |
| 864 |
the current tempo and time: |
| 865 |
</p> |
| 866 |
<pre> |
| 867 |
!TEMPO 100 |
| 868 |
!CLOCK |
| 869 |
</pre> |
| 870 |
|
| 871 |
<p> |
| 872 |
A <code>!CLOCK</code> command must also be inserted for each tempo change that is to be |
| 873 |
reflected in the Midi clock. Typically, each !TEMPO command will be followed by a !CLOCK command.</p> |
| 874 |
<small> |
| 875 |
Clock commands and thus tempo |
| 876 |
changes can take place at arbitrary times. It is assumed that tempo changes |
| 877 |
on an exact 24<sup T>th</sup> of a beat subdivision (for example, exactly on a |
| 878 |
beat). If not, the tempo change will take place on the nearest exact |
| 879 |
24<sup T>th</sup> of a beat subdivision. This may be earlier or later than the |
| 880 |
requested time. |
| 881 |
</small> |
| 882 |
<a name = "146"><h4>System Exclusive Messages</h4></a> |
| 883 |
<p>Adagio has a definition facility that makes it possible to send system |
| 884 |
exclusive parameters. Often, there are parameters on Midi |
| 885 |
synthesizers that can only be controlled by system exclusive messages. |
| 886 |
Examples include the FM ratio and LFO rate on a DX7 synthesizer. The |
| 887 |
following example defines a macro for the DX7 LFO rate and then shows how |
| 888 |
the macro is used to set the LFO rate for a B-flat whole note in the score. |
| 889 |
The macro definition is given in hexadecimal, except <tt>v</tt> is replaced by |
| 890 |
the channel (voice) and <tt>%1</tt> is replaced by the first parameter. |
| 891 |
A macro is invoked by writing “~” followed by the macro name and a |
| 892 |
list of parameters<a name="index1105"></a>: |
| 893 |
</p> |
| 894 |
<pre> |
| 895 |
!DEF LFO F0 43 0v 01 09 %1 F7 |
| 896 |
Bf5 W ~LFO(25) |
| 897 |
</pre> |
| 898 |
|
| 899 |
<p></p> |
| 900 |
|
| 901 |
<p>In general, the <tt>!DEF</tt> command can define any single MIDI message including |
| 902 |
a system exclusive |
| 903 |
message. The message must be complete (including the status byte), and each <tt>!DEF</tt> must correspond to just one message. |
| 904 |
The symbol following <tt>!DEF</tt> can be any name consisting of |
| 905 |
alphanumeric characters. Following the name is a hexadecimal string |
| 906 |
(with optional spaces), all on one line. Embedded in the string may |
| 907 |
be the following special characters: |
| 908 |
<dl> |
| 909 |
<dt> |
| 910 |
<tt>v</tt></dt> |
| 911 |
<dd>Insert the 4-bit voice (MIDI channel) number. If <tt>v</tt> occurs in the |
| 912 |
place of a high-order hexadecimal digit, replace <tt>v</tt> with <tt>0v</tt> so that |
| 913 |
the channel number is always placed in the low-order 4 bits of a data byte. In other words, <tt>v</tt> is padded if necessary to fall into the low-order bits.</p> |
| 914 |
<dt><tt>%</tt><i>n</i></dt> |
| 915 |
<dd>Insert a data byte with the low-order 7 bits of |
| 916 |
parameter number <i>n</i>. Parameters are numbered 1 through 9. |
| 917 |
If the |
| 918 |
parameter value is greater than 127, the high-order bits are discarded.<br><br> |
| 919 |
<dt><tt>^</tt><i>n</i></dt> |
| 920 |
<dd>Insert a data byte with bits 7 through 13 of parameter number |
| 921 |
<i>n</i>. In other words, shift the value right 7 places then clear all |
| 922 |
but the first 7 bits. Note that 14-bit numbers can be encoded by |
| 923 |
referencing the same parameter twice; for example, <tt>%4^4</tt> will |
| 924 |
insert the low-order followed by the high-order parts of parameter 4 |
| 925 |
into two successive data bytes. |
| 926 |
</dd></dl> |
| 927 |
<p>Parameters are separated by commas, but there may be no spaces. The |
| 928 |
maximum number of parameters allowed is 9. Here |
| 929 |
is an example of definitions to send a full-resolution pitch |
| 930 |
bend command and to send a system exclusive command to change a DX7 |
| 931 |
parameter <a href = "foot.html#foot6">(Footnote 6)</a> . </p> |
| 932 |
|
| 933 |
<p></p> |
| 934 |
<pre> |
| 935 |
* Define macro for pitch bend commands: |
| 936 |
!DEF bend Ev %1 ^1 |
| 937 |
|
| 938 |
A ~bend(8192) ** 8192 is "pitch bend off" |
| 939 |
|
| 940 |
* Change the LFO SPEED: |
| 941 |
* SYSEX = F0, Yamaha = 43, Substatus/Channel = 1v, |
| 942 |
* Group# = 01, Parameter# = 9, Data = 0-99, EOX = F7 |
| 943 |
!DEF lfospeed F0 43 1v 01 09 %1 F7 |
| 944 |
|
| 945 |
* now use the definitions: |
| 946 |
G4 ~bend(7567) N40 |
| 947 |
~lfospeed(30) N35 |
| 948 |
|
| 949 |
</pre> |
| 950 |
|
| 951 |
<p></p> |
| 952 |
<a name = "147"><h4>Control Ramps</h4></a> |
| 953 |
<p>The <tt>!RAMP</tt> command<a name="index1106"></a> can specify a smooth control change from one |
| 954 |
value to another. It consists of a specification of the starting and |
| 955 |
ending values of some control change, a duration specifying how often |
| 956 |
to send a new value, and a duration specifying the total length of the ramp. |
| 957 |
</p> |
| 958 |
<pre> |
| 959 |
!RAMP X10 X100 Q W2 |
| 960 |
!RAMP ~23(10) ~23(50) U20 W |
| 961 |
!RAMP ~lfo(15) ~lfo(35) U10 |
| 962 |
</pre> |
| 963 |
|
| 964 |
<p> |
| 965 |
The first line says to ramp the volume control (controller number 7) |
| 966 |
from 10 to 100, changing at each quarter note for the duration of two |
| 967 |
whole notes. |
| 968 |
The second line says to ramp controller number 23 from value 10 to value 50, |
| 969 |
sending a new control change message every 20 time units. The overall |
| 970 |
duration of the ramp should be equivalent to a whole note (<tt>W</tt>). |
| 971 |
As shown in the third line, even system exclusive messages controlled by |
| 972 |
parameters can be specified. If the system exclusive message has more |
| 973 |
than one parameter, only one parameter may be “ramped”; the others must |
| 974 |
remain the same. For example, the following would ramp the second parameter: |
| 975 |
</p> |
| 976 |
<pre> |
| 977 |
!RAMP ~mysysex(4,23,75) ~mysysex(4,100,75) U10 W |
| 978 |
</pre> |
| 979 |
|
| 980 |
<p> |
| 981 |
<small></p> |
| 982 |
|
| 983 |
<p>A rather curious and extreme use of macros and ramps is illustrated in the |
| 984 |
following example. The <tt>noteon</tt> macro starts a note, and <tt>noteoff</tt> ends it. Ramps can now be used to emit a series of notes with changing pitches or velocities. Since Adagio has no idea that these macros are turning on notes, it is up to the programmer to turn them off! |
| 985 |
</p> |
| 986 |
<pre> |
| 987 |
!DEF noteon 9v %1 %2 |
| 988 |
!DEF noteoff 8v %1 %2 |
| 989 |
~noteon(48,125) |
| 990 |
~noteoff(48,126) |
| 991 |
* turn on some notes |
| 992 |
!RAMP ~noteon(36,125) ~noteon(60,125) Q W NW |
| 993 |
* turn them off |
| 994 |
!RAMP ~noteoff(60,50) ~noteoff(36,50) Q W NW |
| 995 |
</pre> |
| 996 |
|
| 997 |
<p> |
| 998 |
</p> |
| 999 |
</small> |
| 1000 |
<a name = "148"><h4>The !End Command</h4></a><a name="index1107"></a><a name="index1108"></a> |
| 1001 |
<p>The special command <code>!END</code> marks the end of a score. Everything beyond that |
| 1002 |
is ignored, for example: |
| 1003 |
</p> |
| 1004 |
<pre> |
| 1005 |
* this is a score |
| 1006 |
C; D; E; F; G W |
| 1007 |
!END |
| 1008 |
since the score has ended, this text will be ignored |
| 1009 |
</pre> |
| 1010 |
|
| 1011 |
<p></p> |
| 1012 |
<a name = "149"><h4>Calling C Routines</h4></a> |
| 1013 |
<p>It is possible to call C routines from within Adagio scores when using |
| 1014 |
specially linked versions, but this feature is disabled in Nyquist. The |
| 1015 |
syntax is described here for completeness.</p> |
| 1016 |
|
| 1017 |
<p>The <code>!CALL</code> command<a name="index1109"></a><a name="index1110"></a> calls a C routine that can in turn invoke a |
| 1018 |
complex sequence of operations. Below is a call to a trill<a name="index1111"></a> routine, |
| 1019 |
which is a standard routine in Adagio. The parameters are the base |
| 1020 |
pitch of the trill, the total duration of the trill, the interval in semitones, the |
| 1021 |
duration of each note of the trill, and the loudness. Notice |
| 1022 |
that both numbers and Adagio notation can be used as parameters: |
| 1023 |
</p> |
| 1024 |
<pre> |
| 1025 |
!CALL trill(A5,W,2,S,Lmf) T278 V1 |
| 1026 |
</pre> |
| 1027 |
|
| 1028 |
<p> |
| 1029 |
<i>The parameter list should have no spaces</i>, and parameters are separated |
| 1030 |
by commas. Following the close parenthesis, you may specify other |
| 1031 |
attributes such as the starting time and voice as shown in the example above.</p> |
| 1032 |
|
| 1033 |
<p>A parameter may be an Adagio pitch specification, an Adagio duration, |
| 1034 |
an Adagio loudness, a number, or an ASCII character within single |
| 1035 |
quotes, e.g. <tt>'a'</tt> is equivalent to <tt>97</tt> because 97 is the decimal |
| 1036 |
encoding of “a” in ASCII.</p> |
| 1037 |
|
| 1038 |
<p>The <code>!CALL</code> may be followed by a limited set of attributes. These are time (<tt>T</tt>), voice (<tt>V</tt>), and next time (<tt>N</tt>). The <code>!CALL</code> is made at the current time if no time is specified, and the time of the next adagio command is the time of the <code>!CALL</code> unless a next time is specified. In other words, the default is <tt>N0</tt>.</p> |
| 1039 |
<a name = "150"><h4>Setting C Variables</h4></a> |
| 1040 |
<p>In addition to calling C routines, there is another way in which scores |
| 1041 |
can communicate with C. As with <code>!CALL</code>, specific C code must be linked before these commands can be used, and this is not supported in Nyquist. |
| 1042 |
The <code>!SETI</code> command<a name="index1112"></a><a name="index1113"></a> sets an integer variable |
| 1043 |
to a value, and the <code>!SETV</code> command<a name="index1114"></a><a name="index1115"></a> sets an element of an integer array. |
| 1044 |
For example, the next line sets the variable <tt>delay</tt> to 200 and sets |
| 1045 |
<tt>transposition[5]</tt> to -4 at time 200: |
| 1046 |
</p> |
| 1047 |
<pre> |
| 1048 |
!SETI delay 200 |
| 1049 |
!SETV transposition 5 -4 T200 |
| 1050 |
</pre> |
| 1051 |
|
| 1052 |
<p> |
| 1053 |
As with the <code>!CALL</code> command, these commands perform their operations at |
| 1054 |
particular times according to their place in the Adagio score. This makes |
| 1055 |
it very easy to implement time-varying parameters that control various |
| 1056 |
aspects of an interactive music system. </p> |
| 1057 |
|
| 1058 |
<p></p> |
| 1059 |
<hr> |
| 1060 |
<a href = "part11.html">Previous Section</a> | <a href = "part13.html">Next Section</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "indx.html">Index</a> | <a href = "title.html">Title Page</a> |
| 1061 |
</body></html> |