Debian Codegraph @

orch/kvar.xml

raw symbols SCIP
1
2 <section id="OrchKvar">
3 <title>Types, Constants and Variables</title>
4
5 <para>
6 <emphasis>Constants</emphasis>
7 are floating point numbers, such as 1, 3.14159, or -73.45. They are
8 available continuously and do not change in value.
9 </para>
10
11 <para>
12 <emphasis>Variables</emphasis> are named cells containing numbers. They are available continuously and may be updated at one of the four update rates (setup only, i-rate, k-rate, or a-rate). i- and k-rate variables are scalars (i.e. they take on only one value at any given time) and are primarily used to store and recall controlling data, that is, data that changes at the note rate (for i-rate variables) or at the control rate (for k-rate variables). i- and k-variables are therefore useful for storing note parameter values, pitches, durations, slow-moving frequencies, vibratos, etc. a-rate variables, on the other hand, are arrays or vectors of information. Though renewed on the same perf-time control pass as k-rate variables, these array cells represent a finer resolution of time by dividing the control period into sample periods (see <link linkend="ksmps"><citetitle>ksmps</citetitle></link>). a-rate variables are used to store and recall data changing at the audio sampling rate (e.g. output signals of oscillators, filters, etc.).
13 </para>
14 <para>
15 Some types of variables can be thought of as signals. For example
16 a-rate and k-rate variables are signals that have a constant
17 update frequency (see <link
18 linkend="kr"><citetitle>kr</citetitle></link> and <link
19 linkend="sr"><citetitle>sr</citetitle></link>). This abstraction
20 is generally quite useful, but be aware that a-rate signals are
21 actually vectors which are processed at k-rate, i.e. Csound works
22 at k-rate internally but processes <link
23 linkend="ksmps"><citetitle>ksmps</citetitle></link> number samples for
24 each a-rate variable on every control pass.
25 </para>
26 <para>
27 There are other types of signals that require rates that don't
28 match <link linkend="kr"><citetitle>kr</citetitle></link> or <link
29 linkend="sr"><citetitle>sr</citetitle></link>. f-rate and w-rate
30 signals are used for spectral processing and their rate is
31 determined by the window size and overlap factor.
32 </para>
33
34
35 <para>
36 A further distinction is that between local and global variables. <emphasis>local</emphasis> variables are private to a particular instrument, and cannot be read from or written into by any other instrument. Their values are preserved, and they may carry information from pass to pass (e.g. from initialization time to performance time) within a single instrument. Local variable names begin with the letter <emphasis>p, i, k</emphasis>, or <emphasis>a</emphasis>. The same local variable name may appear in two or more different instrument blocks without conflict.
37 </para>
38
39 <para id="GlobalVariables">
40 <emphasis>Global</emphasis> variables are cells that are accessible by all instruments. The names are either like local names preceded by the letter <emphasis>g</emphasis>, or are special reserved symbols. Global variables are used for broadcasting general values, for communicating between instruments (semaphores), or for sending sound from one instrument to another (e.g. mixing prior to reverberation).
41 </para>
42
43 <para>
44 Given these distinctions, there are nine forms of local and global variables:
45 </para>
46
47 <para>
48 <table id="VariableTypes" frame="all">
49 <title>Types of Variables</title>
50 <tgroup cols="4" colsep="1" rowsep="1">
51 <thead>
52 <row>
53 <entry>Type</entry>
54 <entry>When Renewable</entry>
55 <entry>Local</entry>
56 <entry>Global</entry>
57 </row>
58 </thead>
59
60 <tbody>
61 <row>
62 <entry>reserved symbols</entry>
63 <entry>permanent</entry>
64 <entry> -- </entry>
65 <entry>rsymbol</entry>
66 </row>
67
68 <row>
69 <entry>score pfields</entry>
70 <entry>i-time</entry>
71 <entry>p number</entry>
72 <entry> -- </entry>
73 </row>
74
75 <row>
76 <entry>init variables</entry>
77 <entry>i-time</entry>
78 <entry>i name</entry>
79 <entry>gi name </entry>
80 </row>
81
82 <row>
83 <entry>control signals</entry>
84 <entry>p-time, k-rate</entry>
85 <entry>k name</entry>
86 <entry>gk name</entry>
87 </row>
88
89 <row>
90 <entry>audio signals</entry>
91 <entry>p-time, k-rate (all audio samples in a k-pass)</entry>
92 <entry>a name</entry>
93 <entry>ga name</entry>
94 </row>
95
96 <row>
97 <entry>spectral data types</entry>
98 <entry>k-rate</entry>
99 <entry>w name</entry>
100 <entry> -- </entry>
101 </row>
102
103 <row>
104 <entry>streaming spectral data types</entry>
105 <entry>k-rate</entry>
106 <entry>f name</entry>
107 <entry>gf name</entry>
108 </row>
109
110 <row>
111 <entry>string variables</entry>
112 <entry>i-time and optionally k-rate</entry>
113 <entry>S name</entry>
114 <entry>gS name</entry>
115 </row>
116
117 <row>
118 <entry>vector variables</entry>
119 <entry>k-rate</entry>
120 <entry>t name</entry>
121 </row>
122 </tbody>
123 </tgroup>
124 </table>
125 </para>
126
127 <para>
128 Where <emphasis>rsymbol</emphasis> is a special reserved symbol (e.g. <emphasis>sr, kr</emphasis>), <emphasis>number</emphasis> is a positive integer referring to a score pfield or sequence number, and <emphasis>name</emphasis> is a string of letters, the underscore character, and/or digits with local or global meaning. As might be apparent, score parameters are local i-rate variables whose values are copied from the invoking score statement just prior to the init pass through an instrument, while MIDI controllers are variables which can be updated asynchronously from a MIDI file or MIDI device.
129 </para>
130 <section id="OrchVarinit">
131 <title>Variable Initialization</title>
132
133 <para>
134 Opcodes that let one initialize variables are:
135 <itemizedlist>
136 <listitem>
137 <para><link linkend="assign"><citetitle>assign</citetitle></link></para>
138 </listitem>
139 <listitem>
140 <para><link linkend="divz"><citetitle>divz</citetitle></link></para>
141 </listitem>
142 <listitem>
143 <para><link linkend="init"><citetitle>init</citetitle></link></para>
144 </listitem>
145 <listitem>
146 <para><link linkend="tival"><citetitle>tival</citetitle></link></para>
147 </listitem>
148 </itemizedlist>
149 </para>
150 <simplesect id="Predefined Constants">
151 <title>Predefined Math Constant Macros</title>
152 <para>Csound defines several important math constants as <link linkend="OrchMacros"><citetitle>Macros</citetitle></link>. You can see the full list <link linkend="opcodesDefineMathConstMacros"><citetitle>here</citetitle></link>.</para>
153 </simplesect>
154 </section>
155 </section>