Debian Codegraph @

opcodes/modmatrix.xml

raw symbols SCIP
1
2
3 <refentry id="modmatrix">
4 <indexterm id="IndexModmatrix"><primary>modmatrix</primary></indexterm>
5 <refentryinfo><title>Miscellaneous</title></refentryinfo>
6 <refmeta>
7 <refentrytitle>modmatrix</refentrytitle>
8 </refmeta>
9
10 <refnamediv>
11 <refname>modmatrix</refname>
12 <refpurpose>
13 Modulation matrix opcode with optimizations for sparse matrices.
14 </refpurpose>
15 </refnamediv>
16
17 <refsect1>
18 <title>Description</title>
19 <para>
20 The opcode can be used to let a large number of k-rate modulator
21 variables modulate a large number of k-rate parameter variables,
22 with arbitrary scaling of each modulator-to-parameter
23 connection. Csound ftables are used to hold both the input
24 (parameter) variables, the modulator variables, and the scaling
25 coefficients. Output variables are written to another Csound ftable.
26 </para>
27 </refsect1>
28
29 <refsect1>
30 <title>Syntax</title>
31 <synopsis><command>modmatrix</command> iresfn, isrcmodfn, isrcparmfn, imodscale, inum_mod, \\
32 inum_parm, kupdate</synopsis>
33 </refsect1>
34
35 <refsect1>
36 <title>Initialization</title>
37 <para>
38 <emphasis>iresfn</emphasis> -- ftable number for the parameter output variables
39 </para>
40 <para>
41 <emphasis>isrcmodfn</emphasis> -- ftable number for the modulation source variables
42 </para>
43 <para>
44 <emphasis>isrcparmfn</emphasis> -- ftable number for the parameter input variables
45 </para>
46 <para>
47 <emphasis>imodscale</emphasis> -- scaling/routing coefficient
48 matrix. This is also a csound ftable, used as a matrix of
49 inum_mod rows and inum_parm columns.
50 </para>
51 <para>
52 <emphasis>inum_mod</emphasis> -- number of modulation variables
53 </para>
54 <para>
55 <emphasis>inum_parm</emphasis> -- number of parmeter (input and
56 output) variables.
57 </para>
58 <para>
59 The arguments <emphasis>inum_mod</emphasis>
60 and <emphasis>inum_parm</emphasis> do not have to be set to
61 power-of-two values.
62 </para>
63 </refsect1>
64
65 <refsect1>
66 <title>Performance</title>
67 <para>
68 <emphasis>kupdate</emphasis> -- flag to update the scaling
69 coefficients. When the flag is set to a nonzero value, the
70 scaling coefficients are read directly from the imodscale
71 ftable. When the flag is set to zero, the scaling coefficients
72 are scanned, and an optimized scaling matrix stored internally
73 in the opcode.
74 </para>
75 <para>
76 For each modulator in <emphasis>isrcmodfn</emphasis>, scale it
77 with the coefficient (in <emphasis>imodscale</emphasis>)
78 determining to what degree it should influence each
79 parameter. Then sum all modulators for each parameter and add
80 the resulting modulator value to the input parameter value read from
81 <emphasis>iscparmfn</emphasis>. Finally, write the output
82 parameter values to table <emphasis>iresfn</emphasis>.
83 </para>
84 <para>
85 The following tables give insight into the processing performed
86 by the modmatrix opcode, for a simplified example using 3
87 parameter and 2 modulators. Let’s call the parameters
88 &quot;cps1&quot;, &quot;cps2&quot;, and &quot;cutoff&quot;, and
89 the modulators &quot;lfo1&quot; and &quot;lfo2&quot;.
90 </para>
91 <para>
92 The input variables may at a given point in time have these
93 values:
94 <table id="modmatrix-table1" frame="all" colsep="1">
95 <tgroup cols="4">
96 <thead>
97 <row>
98 <entry></entry>
99 <entry>cps1</entry>
100 <entry>cps2</entry>
101 <entry>cutoff</entry> </row>
102 </thead>
103
104 <tbody>
105 <row>
106 <entry><emphasis>isrcparmfn</emphasis></entry>
107 <entry>400</entry>
108 <entry>800</entry>
109 <entry>3</entry>
110 </row>
111 </tbody>
112 </tgroup>
113 </table>
114 </para>
115 <para>
116 </para>
117 <para>
118 ... while the modulator variables have these values:
119 <table id="modmatrix-table2" frame="all" colsep="1">
120 <tgroup cols="3">
121 <thead>
122 <row>
123 <entry></entry>
124 <entry>lfo1</entry>
125 <entry>lfo2</entry>
126 </row>
127 </thead>
128
129 <tbody>
130 <row>
131 <entry><emphasis>isrcmodfn</emphasis></entry>
132 <entry>0.5</entry>
133 <entry>-0.2</entry>
134 </row>
135 </tbody>
136 </tgroup>
137 </table>
138 </para>
139 <para>
140 The scaling/routing coefficients used:
141 <table id="modmatrix-table3" frame="all" colsep="1">
142 <tgroup cols="4">
143 <thead>
144 <row>
145 <entry><emphasis>imodscale</emphasis></entry>
146 <entry>cps1</entry>
147 <entry>cps2</entry>
148 <entry>cutoff</entry>
149 </row>
150 </thead>
151
152 <tbody>
153 <row>
154 <entry><emphasis>lfo1</emphasis></entry>
155 <entry>40</entry>
156 <entry>0</entry>
157 <entry>-2</entry>
158 </row>
159 <row>
160 <entry><emphasis>lfo2</emphasis></entry>
161 <entry>-50</entry>
162 <entry>100</entry>
163 <entry>3</entry>
164 </row>
165 </tbody>
166 </tgroup>
167 </table>
168 </para>
169 <para>
170 ... and the resulting output values:
171 <table id="modmatrix-table4" frame="all" colsep="1">
172 <tgroup cols="4">
173 <thead>
174 <row>
175 <entry></entry>
176 <entry>cps1</entry>
177 <entry>cps2</entry>
178 <entry>cutoff</entry>
179 </row>
180 </thead>
181
182 <tbody>
183 <row>
184 <entry><emphasis>iresfn</emphasis></entry>
185 <entry>430</entry>
186 <entry>780</entry>
187 <entry>1.4</entry>
188 </row>
189 <row>
190 <entry><emphasis>lfo2</emphasis></entry>
191 <entry>-50</entry>
192 <entry>100</entry>
193 <entry>3</entry>
194 </row>
195 </tbody>
196 </tgroup>
197 </table>
198 </para>
199 <para>
200 The output value for &quot;cps1&quot; is calculated as
201 400+(0.5*40)+(-0.2*-50), similarly for &quot;cps2&quot;
202 800+(0.5*0)+(-0.2*100), and for cutoff: 3+(0.5*-2)+(-0.2*3)
203 </para>
204 <para>
205 The imodscale ftable may be specified in the score like this:
206 <programlisting>f1 0 8 -2 200 0 2 50 300 -1.5</programlisting>
207 </para>
208 <para>
209 Or more conveniently using <link linkend="ftgen"><citetitle>ftgen</citetitle></link> in the orchestra:
210 <programlisting>gimodscale ftgen 0, 0, 8, -2, 200, 0, 2, 50, 300, -1.5</programlisting>
211 </para>
212
213
214 <para>
215 Obviously, the parameter and modulator variables need not be
216 static values, and similarly, the scaling routing coefficient
217 table may be continuously rewritten using opcodes
218 like <link linkend="tablew"><citetitle>tablew</citetitle></link>.
219 </para>
220
221 </refsect1>
222
223
224 <refsect1>
225 <title>Examples</title>
226
227 <para>
228 Here is an example of the modmatrix opcode. It uses the file <ulink url="examples/modmatrix.csd"><citetitle>modmatrix.csd</citetitle></ulink>.
229 <example>
230 <title>Example of the modmatrix opcode.</title>
231 <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
232 <xi:include href="examples-xml/modmatrix.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
233 </example>
234 </para>
235 </refsect1>
236
237 <refsect1>
238 <title>See also</title>
239 <para><link linkend="MiscopcodesTop"><citetitle>Miscellaneous opcodes</citetitle></link></para>
240 </refsect1>
241
242 <refsect1>
243 <title>Credits</title>
244 <para>By:</para>
245 <para>Oeyvind Brandtsegg and Thom Johansen</para>
246 <para>New in version 5.12</para>
247 </refsect1>
248
249 </refentry>