| 1 | |
| 2 | <refentry id="vmult"> |
| 3 | <indexterm id="IndexVmult"><primary>vmult</primary></indexterm> |
| 4 | <refentryinfo><title>Vectorial:Scalar operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>vmult</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>vmult</refname> |
| 11 | <refpurpose> |
| 12 | Multiplies a vector in a table by a scalar value. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Multiplies a vector in a table by a scalar value. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis><command>vmult</command> ifn, kval, kelements [, kdstoffset] [, kverbose]</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Initialization</title> |
| 30 | <para> |
| 31 | <emphasis>ifn</emphasis> - number of the table hosting the vectorial signal to be processed |
| 32 | </para> |
| 33 | </refsect1> |
| 34 | |
| 35 | <refsect1> |
| 36 | <title>Performance</title> |
| 37 | <para> |
| 38 | <emphasis>kval</emphasis> - scalar value to be multiplied |
| 39 | </para> |
| 40 | <para> |
| 41 | <emphasis>kelements</emphasis> - number of elements of the vector |
| 42 | </para> |
| 43 | <para> |
| 44 | <emphasis>kdstoffset</emphasis> - index offset for the destination table (Optional, default = 0) |
| 45 | </para> |
| 46 | <para> |
| 47 | <emphasis>kverbose</emphasis> - Selects whether or not warnings are printed (Default=0) |
| 48 | </para> |
| 49 | <para> |
| 50 | <emphasis>vmult</emphasis> multiplies each element of the vector contained in the table <emphasis>ifn</emphasis> by <emphasis>kval</emphasis>, starting from table index <emphasis>kdstoffset</emphasis>. This enables you to process a specific section of a table by specifying the offset and the number of elements to be processed. Offset is counted starting from 0, so if no offset is specified (or set to 0), the table will be modified from the beginning. |
| 51 | </para> |
| 52 | <para> |
| 53 | Note that this opcode runs at k-rate so the value of <emphasis>kval</emphasis> is multiplied every control period. Use with care or you will end up with very large numbers (or use <link linkend="vmult_i"><citetitle>vmult_i</citetitle></link>). |
| 54 | </para> |
| 55 | <para> |
| 56 | These opcodes (<link linkend="vadd"><citetitle>vadd</citetitle></link>, <link linkend="vmult"><citetitle>vmult</citetitle></link>, <link linkend="vpow"><citetitle>vpow</citetitle></link> and <link linkend="vexp"><citetitle>vexp</citetitle></link>) perform numeric operations between a vectorial control signal (hosted by the table <emphasis>ifn</emphasis>), and a scalar signal (<emphasis>kval</emphasis>). Result is a new vector that overrides old values of <emphasis>ifn</emphasis>. All these opcodes work at k-rate. |
| 57 | </para> |
| 58 | <para> |
| 59 | Negative values for <emphasis>kdstoffset</emphasis> are valid. Elements from the vector that are outside the table, will be discarded, and they will not wrap around the table. |
| 60 | </para> |
| 61 | <para> |
| 62 | If the optional <emphasis>kverbose</emphasis> argument is different to 0, the opcode will print warning messages every k-pass if table lengths are exceeded. |
| 63 | </para> |
| 64 | <para> |
| 65 | In all these opcodes, the resulting vectors are stored in <emphasis>ifn</emphasis>, overriding the initial vectors. If you want to keep initial vector, use <link linkend="vcopy"><citetitle>vcopy</citetitle></link> or <link linkend="vcopy_i"><citetitle>vcopy_i</citetitle></link> to copy it in another table. All these operators are designed to be used together with other opcodes that operate with vectorial signals such as <link linkend="vcella"><citetitle>vcella</citetitle></link>, <link linkend="adsynt"><citetitle>adsynt</citetitle></link>, <link linkend="adsynt2"><citetitle>adsynt2</citetitle></link>, etc. They can also be useful in conjunction with the spectral opcodes <link linkend="pvsftw"><citetitle>pvsftw</citetitle></link> and <link linkend="pvsftr"><citetitle>pvsftr</citetitle></link>. |
| 66 | </para> |
| 67 | <note> |
| 68 | <para> |
| 69 | Please note that the <emphasis>elements</emphasis> argument has changed in version 5.03 from i-rate to k-rate. This will change the opcode's behavior in the unusual cases where the i-rate variable <emphasis>ielements</emphasis> is changed inside the instrument, for example in: |
| 70 | <programlisting> |
| 71 | <emphasis role="oblock">instr</emphasis> 1 |
| 72 | ielements <emphasis role="op">=</emphasis> 10 |
| 73 | <emphasis role="opc">vadd</emphasis> 1, 1, ielements |
| 74 | ielements <emphasis role="op">=</emphasis> 20 |
| 75 | <emphasis role="opc">vadd</emphasis> 2, 1, ielements |
| 76 | <emphasis role="opc">turnoff</emphasis> |
| 77 | <emphasis role="oblock">endin</emphasis></programlisting> |
| 78 | </para> |
| 79 | </note> |
| 80 | </refsect1> |
| 81 | |
| 82 | <refsect1> |
| 83 | <title>Example</title> |
| 84 | <para> |
| 85 | Here is an example of the vmult opcode. It uses the file <ulink url="examples/vmult-2.csd"><citetitle>vmult-2.csd</citetitle></ulink>. |
| 86 | <example> |
| 87 | <title>Example of the vmult opcode.</title> |
| 88 | <xi:include href="examples-xml/vmult-2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 89 | </example> |
| 90 | </para> |
| 91 | <para> |
| 92 | Here is another example of the vmult opcode. It uses the file <ulink url="examples/vmult.csd"><citetitle>vmult.csd</citetitle></ulink>. |
| 93 | <example> |
| 94 | <title>Example of the vmult opcode.</title> |
| 95 | <xi:include href="examples-xml/vmult.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 96 | </example> |
| 97 | </para> |
| 98 | </refsect1> |
| 99 | |
| 100 | <refsect1> |
| 101 | <title>See also</title> |
| 102 | <para><link linkend="vectorialscalar"><citetitle>Operations Vectorial/Scalar Signal</citetitle></link></para> |
| 103 | </refsect1> |
| 104 | |
| 105 | <refsect1> |
| 106 | <title>Credits</title> |
| 107 | <para>Written by Gabriel Maldonado. Optional arguments added by Andres Cabrera and Istvan Varga.</para> |
| 108 | <para>Example by Andres Cabrera.</para> |
| 109 | <para>New in Csound 5 (Previously available only on CsoundAV)</para> |
| 110 | </refsect1> |
| 111 | </refentry> |