Debian Codegraph @

opcodes/tablew.xml

raw symbols SCIP
1
2 <refentry id="tablew">
3 <indexterm id="IndexTablew"><primary>tablew</primary></indexterm>
4 <refentryinfo><title>Table Control:Read/Write Operations</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>tablew</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>tablew</refname>
11 <refpurpose>
12 Change the contents of existing function tables.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 This opcode operates on existing function tables, changing their
20 contents. <emphasis>tablew</emphasis> is for writing at k- or at a-rates, with the table
21 number being specified at init time. Using <emphasis>tablew</emphasis> with i-rate signal
22 and index values is allowed, but the specified data will always be written to the function table
23 at k-rate, not during the initialization pass. The valid combinations of variable
24 types are shown by the first letter of the variable names.
25 </para>
26 </refsect1>
27
28 <refsect1>
29 <title>Syntax</title>
30 <synopsis><command>tablew</command> asig, andx, ifn [, ixmode] [, ixoff] [, iwgmode]</synopsis>
31
32 <synopsis><command>tablew</command> isig, indx, ifn [, ixmode] [, ixoff] [, iwgmode]</synopsis>
33
34 <synopsis><command>tablew</command> ksig, kndx, ifn [, ixmode] [, ixoff] [, iwgmode]</synopsis>
35 </refsect1>
36
37 <refsect1>
38 <title>Initialization</title>
39 <para>
40 <emphasis>asig</emphasis>, <emphasis>isig,</emphasis> <emphasis>ksig</emphasis> -- The value to be written into the table.
41 </para>
42
43 <para>
44 <emphasis>andx</emphasis>, <emphasis>indx</emphasis>, <emphasis>kndx</emphasis> -- Index into table, either a positive number range matching the table length (<emphasis>ixmode</emphasis> = 0) or a 0 to 1 range (<emphasis>ixmode</emphasis> != 0)
45 </para>
46
47 <para>
48 <emphasis>ifn</emphasis> -- Table number. Must be &gt;= 1. Floats are rounded down to an integer. If a table number does not point to a valid table, or the table has not yet been loaded (<link linkend="GEN01"><citetitle>GEN01</citetitle></link>) then an error will result and the instrument will be de-activated.
49 </para>
50
51 <para>
52 <emphasis>ixmode</emphasis> (optional, default=0) -- index mode.
53 <itemizedlist>
54 <listitem>
55 <para>
56 0 = <emphasis>xndx</emphasis> and <emphasis>ixoff</emphasis> ranges match the length of the table.
57 </para>
58 </listitem>
59
60 <listitem>
61 <para>
62 !=0 = <emphasis>xndx</emphasis> and <emphasis>ixoff</emphasis> have a 0 to 1 range.
63 </para>
64 </listitem>
65 </itemizedlist>
66 </para>
67
68 <para>
69 <emphasis>ixoff</emphasis> (optional, default=0) -- index offset.
70
71 <itemizedlist>
72 <listitem>
73 <para>
74 0 = Total index is controlled directly by <emphasis>xndx</emphasis>, i.e. the indexing starts from the start of the table.
75 </para>
76 </listitem>
77
78 <listitem>
79 <para>
80 !=0 = Start indexing from somewhere else in the table. Value must be positive and less than the table length (<emphasis>ixmode</emphasis> = 0) or less than 1 (<emphasis>ixmode</emphasis> != 0).
81 </para>
82 </listitem>
83 </itemizedlist>
84 </para>
85
86 <para>
87 <emphasis>iwgmode</emphasis> (optional, default=0) -- Wrap and guardpoint mode.
88
89 <itemizedlist>
90 <listitem>
91 <para>
92 0 = Limit mode.
93 </para>
94 </listitem>
95
96 <listitem>
97 <para>
98 1 = Wrap mode.
99 </para>
100 </listitem>
101
102 <listitem>
103 <para>
104 2 = Guardpoint mode.
105 </para>
106 </listitem>
107 </itemizedlist>
108 </para>
109 </refsect1>
110
111 <refsect1>
112 <title>Performance</title>
113
114 <refsect2>
115 <title>Limit mode (0)</title>
116 <para>
117 Limit the total index (<emphasis>ndx</emphasis> + <emphasis>ixoff</emphasis>) to between 0 and the guard point. For a table of length 5, this means that locations 0 to 3 and location 4 (the guard point) can be written. A negative total index writes to location 0.
118 </para>
119 </refsect2>
120
121 <refsect2>
122 <title>Wrap mode (1)</title>
123 <para>
124 Wrap total index value into locations 0 to E, where E is either one less than the table length or the factor of 2 number which is one less than the table length. For example, wrap into a 0 to 3 range - so that total index 6 writes to location 2.
125 </para>
126 </refsect2>
127
128 <refsect2>
129 <title>Guardpoint mode (2)</title>
130 <para>
131 The guardpoint is written at the same time as location 0 is written - with the same value.
132 </para>
133
134 <para>
135 This facilitates writing to tables which are intended to be read with interpolation for producing smooth cyclic waveforms. In addition, before it is used, the total index is incremented by half the range between one location and the next, before being rounded down to the integer address of a table location.
136 </para>
137
138 <para>
139 Normally (<emphasis>igwmode</emphasis> = 0 or 1) for a table of length 5 - which has locations 0 to 3 as the main table and location 4 as the guard point, a total index in the range of 0 to 0.999 will write to location 0. (&quot;0.999&quot; means just less than 1.0.) 1.0 to 1.999 will write to location 1 etc. A similar pattern holds for all total indexes 0 to 4.999 (<emphasis>igwmode</emphasis> = 0) or to 3.999 (<emphasis>igwmode</emphasis> = 1). <emphasis>igwmode</emphasis> = 0 enables locations 0 to 4 to be written - with the guardpoint (4) being written with a potentially different value from location 0.
140 </para>
141
142 <para>
143 With a table of length 5 and the <emphasis>iwgmode</emphasis> = 2, then when the total index is in the range 0 to 0.499, it will write to locations 0 and 4. Range 0.5 to 1.499 will write to location 1 etc. 3.5 to 4.0 will also write to locations 0 and 4.
144 </para>
145
146 <para>
147 This way, the writing operation most closely approximates the results of interpolated reading. Guard point mode should only be used with tables that have a guardpoint.
148 </para>
149
150 <para>
151 Guardpoint mode is accomplished by adding 0.5 to the total index, rounding to the next lowest integer, wrapping it modulo the factor of two which is one less than the table length, writing the table (locations 0 to 3 in our example) and then writing to the guard point if index = 0.
152 </para>
153
154 <para>
155 <emphasis>tablew</emphasis> has no output value. The last three parameters are optional and have default values of 0.
156 </para>
157 </refsect2>
158
159 <refsect2>
160 <title>Caution with k-rate table numbers</title>
161 <para>
162 At k-rate or a-rate, if a table number of &lt; 1 is given, or the table number points to a non-existent table, or to one which has a length of 0 (it is to be loaded from a file later) then an error will result and the instrument will be deactivated. <emphasis>kfn</emphasis> and <emphasis>afn</emphasis> must be initialized at the appropriate rate using <emphasis>init</emphasis>. Attempting to load an i-rate value into <emphasis>kfn</emphasis> or <emphasis>afn</emphasis> will result in an error.
163 </para>
164 </refsect2>
165 <warning>
166 <para>
167 Note that <emphasis>tablew</emphasis> is always a k-rate opcode. This means that even its i-rate version runs at k-rate and will write the value of the i-rate variable. For this reason, the following code will not work as expected:
168 </para>
169 <programlisting>
170 <emphasis role="csdtag">&lt;CsoundSynthesizer&gt;</emphasis>
171 <emphasis role="csdtag">&lt;CsOptions&gt;</emphasis>
172 <emphasis role="csdtag">&lt;/CsOptions&gt;</emphasis>
173 <emphasis role="csdtag">&lt;CsInstruments&gt;</emphasis>
174 giFt <emphasis role="opc">ftgen</emphasis> 1, 0, 8, 2, 0
175 <emphasis role="oblock">instr 1</emphasis>
176 indx <emphasis role="op">=</emphasis> 0
177 <emphasis role="opc">tablew</emphasis> 10, indx, giFt
178 ival <emphasis role="opc">tab_i</emphasis> indx, giFt
179 <emphasis role="opc">print</emphasis> ival
180 <emphasis role="oblock">endin</emphasis>
181 <emphasis role="csdtag">&lt;/CsInstruments&gt;</emphasis>
182 <emphasis role="csdtag">&lt;CsScore&gt;</emphasis>
183 <emphasis role="stamnt">i</emphasis> 1 0 1
184 <emphasis role="csdtag">&lt;/CsScore&gt;</emphasis>
185 <emphasis role="csdtag">&lt;/CsoundSynthesizer&gt;</emphasis></programlisting>
186 <para>
187 Although it may seem this program should print a 10 to the console. It will print 0, because <link linkend="tab"><citetitle>tab_i</citetitle></link> will read the value at the initialization of the note, before the first performance pass, when <emphasis>tablew</emphasis> writes its value.
188 </para>
189 </warning>
190 </refsect1>
191
192 <refsect1>
193 <title>See also</title>
194 <para><link linkend="TableReadwrit"><citetitle>Read/Write Operations</citetitle></link></para>
195 </refsect1>
196
197 <refsect1>
198 <title>Credits</title>
199 <para>
200 <simplelist>
201 <member>Author: Robin Whittle</member>
202 <member>Australia</member>
203 <member>May 1997</member>
204 </simplelist>
205 </para>
206 </refsect1>
207 </refentry>