| 1 |
|
| 2 |
<chapter id="OrchTop"> |
| 3 |
<title>Syntax of the Orchestra</title> |
| 4 |
<para> |
| 5 |
The Csound orchestra (.orc) or the <emphasis><CsInstruments></emphasis> section of a csd file, contains: |
| 6 |
<itemizedlist> |
| 7 |
<listitem> |
| 8 |
<para>A <link linkend="OrchHeader"><citetitle>header section</citetitle></link>, which specifies global options for instrument performance</para> |
| 9 |
</listitem> |
| 10 |
<listitem> |
| 11 |
<para>A list of <link linkend="OrchUDO"><citetitle>User defined opcodes</citetitle></link> and <link linkend="OrchIblock"><citetitle>instrument blocks</citetitle></link> containing UDO and instrument definitions.</para> |
| 12 |
</listitem> |
| 13 |
</itemizedlist> |
| 14 |
</para> |
| 15 |
<para> |
| 16 |
The orchestra header, instrument blocks, and UDOs contain <emphasis>Orchestra statements</emphasis>. An <emphasis>orchestra statement</emphasis> in Csound has the format: |
| 17 |
|
| 18 |
<synopsis> |
| 19 |
label: <returnvalue>result</returnvalue> <function>opcode</function> <parameter>argument1</parameter>, <parameter>argument2</parameter>, <parameter>...</parameter> ;comments |
| 20 |
</synopsis> |
| 21 |
</para> |
| 22 |
|
| 23 |
<para> |
| 24 |
The label is optional and identifies the basic statement that follows as the potential target of a go-to operation (see <link linkend="ControlPgmctl"><citetitle>Program Flow Control</citetitle></link>). A label has no effect on the statement per se. |
| 25 |
</para> |
| 26 |
<para> |
| 27 |
Depending on their function, some opcodes produce no output, so they have no result value. Others take no arguments and only produce a result. |
| 28 |
</para> |
| 29 |
<para> |
| 30 |
Every orchestra statement must be on a single line, however long lines can be wrapped to a new line using the '\' character. This character indicates that the next line is part of the current one, this way you can split a line for easier reading, like this: |
| 31 |
<programlisting> |
| 32 |
a2 <emphasis role="opc">oscbnk</emphasis> kcps, 1.0, kfmd1, 0.0, 40, 203, 0.1, 0.2, kamfr, kamfr2, 148, \ |
| 33 |
0, 0, 0, 0, 0, 0, -1, \ |
| 34 |
kfnum, 3, 4</programlisting> |
| 35 |
</para> |
| 36 |
|
| 37 |
<para> |
| 38 |
Comments are optional and are for the purpose of letting the user |
| 39 |
document his orchestra code. Comments begin with a semicolon (;) |
| 40 |
or // and extend to the end of the line. Comments can optionally be in C-style, spanning multiple lines like this: |
| 41 |
<programlisting> |
| 42 |
<emphasis role="comment">/* Anything in here -------- |
| 43 |
is a comment which can span |
| 44 |
several lines --------- */</emphasis></programlisting> |
| 45 |
</para> |
| 46 |
|
| 47 |
<para> |
| 48 |
The remainder (result, opcode, and arguments) form the basic statement. This also is optional, i.e. a line may have only a label or comment or be entirely blank. If present, the basic statement must be complete on one line, and is terminated by a carriage return and line feed. |
| 49 |
</para> |
| 50 |
|
| 51 |
<para> |
| 52 |
The opcode determines the operation to be performed; it usually takes some number of input values (or arguments, with a maximum value of about 800); and it usually has a result field variable to which it sends output values at some fixed rate. There are four possible rates: |
| 53 |
<orderedlist numeration="arabic"> |
| 54 |
<listitem> |
| 55 |
<para>once only, at orchestra setup time (effectively a permanent assignment)</para> |
| 56 |
</listitem> |
| 57 |
|
| 58 |
<listitem> |
| 59 |
<para>once at the beginning of each note (at initialization (init) time: i-rate)</para> |
| 60 |
</listitem> |
| 61 |
|
| 62 |
<listitem> |
| 63 |
<para>once every performance-time control loop (perf-time control rate, or k-rate)</para> |
| 64 |
</listitem> |
| 65 |
|
| 66 |
<listitem> |
| 67 |
<para>once each sound sample of every control loop (perf-time audio rate, or a-rate)</para> |
| 68 |
</listitem> |
| 69 |
</orderedlist> |
| 70 |
</para> |
| 71 |
|
| 72 |
&orchheader; |
| 73 |
&orchiblock; |
| 74 |
&orchstatemnt; |
| 75 |
&orchkvar; |
| 76 |
&orchexpress; |
| 77 |
&orchdirfiles; |
| 78 |
&orchnomen; |
| 79 |
&orchmacros; |
| 80 |
|
| 81 |
&orchnamedinstruments; |
| 82 |
&orchUDO; |
| 83 |
&orchtab; |
| 84 |
&oviewfunctional; |
| 85 |
&oviewserver; |
| 86 |
</chapter> |