vadd
Adds a scalar value to a vector in a table.
Syntax
Initialization
ifn - number of the table hosting the vectorial signal to be processed
Performance
kval - scalar value to be added
kelements - number of elements of the vector
kdstoffset - index offset for the destination table (Optional, default=0)
kverbose - Selects whether or not warnings are printed (Optional, default=0)
vadd adds the value of kval to each element of the vector contained in the table ifn, starting from table index kdstoffset. 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.
Note that this opcode runs at k-rate so the value of kval is added every control period. Use with care or you will end up with very large numbers (or use vadd_i).
These opcodes (vadd, vmult, vpow and vexp) perform numeric operations between a vectorial control signal (hosted by the table ifn), and a scalar signal (kval). Result is a new vector that overrides old values of ifn. All these opcodes work at k-rate.
Negative values for kdstoffset are valid. Elements from the vector that are outside the table, will be discarded, and they will not wrap around the table.
If the optional kverbose argument is different to 0, the opcode will print warning messages every k-pass if table lengths are exceeded.
In all these opcodes, the resulting vectors are stored in ifn, overriding the intial vectors. If you want to keep initial vector, use vcopy or vcopy_i 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 vcella, adsynt, adsynt2, etc. They can also be useful in conjunction with the spectral opcodes pvsftw and pvsftr.
Note
Please note that the elements 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 ielements is changed inside the instrument, for example in:
Examples
Here is an example of the vadd opcode. It uses the file vadd.csd.
See also
Operations Vectorial/Scalar Signal
Credits
Written by Gabriel Maldonado. Optional arguments added by Andres Cabrera and Istvan Varga.
New in Csound 5 (Previously available only on CsoundAV)