Debian Codegraph @

orch/namedInstruments.xml

raw symbols SCIP
1
2 <section id="OrchNamedInstruments">
3 <title>Named Instruments</title>
4
5 <para>
6 As a recent addition to the orchestra syntax, instruments can be defined
7 with string names. Such named instruments are callable from the score, and
8 are supported by a number of opcodes.
9 </para>
10
11 <simplesect>
12 <title>Syntax</title>
13
14 <para>A named instrument is declared as shown below:</para>
15
16 <programlisting>
17 <emphasis role="oblock">instr</emphasis> Name[, Name2[, Name3[, ...]]]
18
19 [...]
20
21 <emphasis role="oblock">endin</emphasis></programlisting>
22
23
24 <para>
25 A single instrument can have any number of names, and any of these names can
26 be used to call the instrument. Additionally, it is possible to use numbers
27 as name, denoting a standard numbered instrument, so the following
28 declaration is also valid:
29 </para>
30
31 <programlisting>
32 <emphasis role="oblock">instr</emphasis> 100, Name1, 99, Name2, 1, 2, 3</programlisting>
33
34 <para>
35 An instrument name may consist of any number of letters, digits, and the
36 underscore (_) character, however, the first character must not be a digit.
37 Optionally, the instrument name may be prefixed with the '+' character (see
38 below), for example:
39 </para>
40
41 <programlisting>
42 <emphasis role="oblock">instr</emphasis> +Reverb</programlisting>
43
44 <para>
45 For all instrument names, a number is automatically assigned (note: if the
46 message level (-m) is not zero, these numbers are printed to the console
47 during orchestra compilation), following these rules:
48 </para>
49
50 <itemizedlist>
51 <listitem>
52 <para>
53 any unused instrument numbers are taken up in ascending order, starting
54 from 1
55 </para>
56 </listitem>
57
58 <listitem>
59 <para>
60 the numbers are assigned in the order of instrument name definition, so
61 named instruments that are defined later will always have a higher
62 number (except if the '+' modifier is used)
63 </para>
64 </listitem>
65
66 <listitem>
67 <para>
68 if the instrument name was prefixed with '+', the assigned number will
69 be higher than that of any of the (both numbered and named) other
70 instruments without '+'. If there are multiple '+' instruments, the
71 numbering of these will follow the order of definition, according to the
72 above rule.
73 </para>
74 <para>
75 Using '+' is mainly useful for global output or effect instruments, that
76 must be performed after the other instruments.
77 </para>
78 </listitem>
79 </itemizedlist>
80
81 <para>An example for instrument numbers:</para>
82
83 <programlisting>
84 <emphasis role="oblock">instr</emphasis> 1, 2
85 <emphasis role="oblock">endin</emphasis>
86
87 <emphasis role="oblock">instr</emphasis> Instr1
88 <emphasis role="oblock">endin</emphasis>
89
90 <emphasis role="oblock">instr</emphasis> +Effect1, Instr2
91 <emphasis role="oblock">endin</emphasis>
92
93 <emphasis role="oblock">instr</emphasis> 100, Instr3, +Effect2, Instr4, 5
94 <emphasis role="oblock">endin</emphasis></programlisting>
95
96 <para>
97 In this example, the instrument numbers are assigned as follows:
98 </para>
99
100 <programlisting>
101 Instr1: 3
102 Effect1: 101
103 Instr2: 4
104 Instr3: 6
105 Effect2: 102
106 Instr4: 7</programlisting>
107
108 </simplesect>
109
110 <simplesect>
111 <title>Using Named Instruments</title>
112
113 <para>
114 Named instruments can be called by using the name in double quotes as the
115 instrument number (note: the '+' character should be omitted). Currently
116 (as of Csound 4.22.4), named instruments are supported by:
117 </para>
118
119 <itemizedlist>
120
121 <listitem>
122 <para>'i' and 'q' score events</para>
123
124 <note>
125 <title>Notes</title>
126
127 <orderedlist>
128 <listitem>
129 <para>
130 in score files, unmatched quotes, and spaces or other invalid
131 characters in the strings should be avoided, otherwise (at least
132 with current version) unpredictable behavior may occur (this
133 problem does not exist for -L line events). However, there is
134 checking for undefined instruments, and in such cases, the event
135 is simply ignored with a warning.
136 </para>
137 </listitem>
138
139 <listitem>
140 <para>
141 Stand-alone utilities (score sort and extract) do not support
142 named instruments. It is still possible to sort such scores by
143 using the -t0 option of the main Csound executable)
144 </para>
145 </listitem>
146 </orderedlist>
147
148 </note>
149 </listitem>
150
151 <listitem>
152 <para>real-time line events (-L)</para>
153 </listitem>
154
155 <listitem>
156 <para>event, schedkwhen, subinstr, and subinstrinit opcodes</para>
157 </listitem>
158
159 <listitem>
160 <para>massign, pgmassign, prealloc, and mute opcodes</para>
161 </listitem>
162
163 </itemizedlist>
164
165 <para>
166 Additionaly, there is a new opcode (nstrnum) that returns the number of a
167 named instrument:
168 </para>
169
170 <programlisting>
171 insno <emphasis role="opc">nstrnum</emphasis> "name"</programlisting>
172
173 <para>
174 With the above example, nstrnum "Effect1" would return 101. If an
175 instrument with the specified name does not exist, an init error occurs,
176 and -1 is returned.
177 </para>
178
179 </simplesect>
180
181 <simplesect>
182 <title>Example</title>
183
184 <programlisting>
185 <emphasis role="comment">; ---- orchestra ----</emphasis>
186
187 <emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 44100
188 <emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 10
189 <emphasis role="ohdr">nchnls</emphasis> <emphasis role="op">=</emphasis> 1
190
191 <emphasis role="ohdr">prealloc</emphasis> "SineWave", 20
192 <emphasis role="ohdr">prealloc</emphasis> "MIDISineWave", 20
193
194 <emphasis role="ohdr">massign</emphasis> 1, "MIDISineWave"
195
196 gaOutSend <emphasis role="opc">init</emphasis> 0
197
198 <emphasis role="oblock">instr</emphasis> +OutputInstr
199
200 <emphasis role="opc">out</emphasis> gaOutSend
201 <emphasis role="opc">clear</emphasis> gaOutSend
202
203 <emphasis role="oblock">endin</emphasis>
204
205 <emphasis role="oblock">instr</emphasis> SineWave
206
207 a1 <emphasis role="opc">oscils</emphasis> p4, p5, 0
208 <emphasis role="opc">vincr</emphasis> gaOutSend, a1
209
210 <emphasis role="oblock">endin</emphasis>
211
212 <emphasis role="oblock">instr</emphasis> MIDISineWave
213
214 iamp <emphasis role="opc">veloc</emphasis>
215 inote <emphasis role="opc">notnum</emphasis>
216 icps <emphasis role="op">=</emphasis> <emphasis role="opc">cpsoct</emphasis>(inote <emphasis role="op">/</emphasis> 12 <emphasis role="op">+</emphasis> 3)
217 a1 <emphasis role="opc">oscils</emphasis> iamp <emphasis role="op">*</emphasis> 100, icps, 0
218 <emphasis role="opc">vincr</emphasis> gaOutSend, a1
219
220 <emphasis role="oblock">endin</emphasis>
221
222 <emphasis role="comment">; ---- score ----</emphasis>
223
224 <emphasis role="stamnt">i</emphasis> "SineWave" 0 2 12000 440
225 <emphasis role="stamnt">i</emphasis> "OutputInstr" 0 3
226 <emphasis role="stamnt">e</emphasis></programlisting>
227
228 </simplesect>
229
230 <simplesect>
231 <title>Author</title>
232 <para>Istvan Varga</para>
233 <para>2002</para>
234 </simplesect>
235
236
237 </section>