init
Initialises one or more objects.
This opcode can be used for various purposes in its different versions, to initialise variables, arrays, and other objects.
Syntax
Initialization
Puts the value of the i-time expression arg into a variable, i.e., initialize the result. Note that init provides the only case of an init-time statement being permitted to write into a perf-time (k- or a-rate) result cell; the statement has no effect at perf-time. In the case of opcode definition variables, the name of an existing opcode is passed as a string.
It is possible to initialise upto 24 variables
of the same class in one statement. If there are more output
variables than input expressions then the last one is repeated.
It is an error to have more inputs than outputs.
The array form allocates space for a array object (of any number of dimensions).
In the case of instrument instances, the opcode takes any pfields as parameters, and run an initialisation pass, returning any error codes (or zero in case of success).
For opcode objects, the code runs the initialisation routine (if it exists) defined for the opcode. The input arguments and outputs should match the opcode signature for the object being initialised.
Examples
Here is an example of the init opcode. It uses the file init.csd.
Its output should include lines like these:
i 1 time 0.00073: 1.00000
i 1 time 0.10014: 138.00000
i 1 time 0.20027: 276.00000
i 1 time 0.30041: 414.00000
i 1 time 0.40054: 552.00000
i 1 time 0.50068: 690.00000
i 1 time 0.60009: 827.00000
i 1 time 0.70023: 965.00000
i 1 time 0.80036: 1103.00000
i 1 time 0.90050: 1241.00000
i 2 time 2.00054: 1.00000
i 2 time 2.09995: 1.00000
i 2 time 2.20009: 1.00000
i 2 time 2.30023: 1.00000
i 2 time 2.40036: 1.00000
i 2 time 2.50050: 1.00000
i 2 time 2.59991: 1.00000
i 2 time 2.70005: 1.00000
i 2 time 2.80018: 1.00000
i 2 time 2.90032: 1.00000
The following example shows the init opcode in the context of instrument and opcode initialisation.
See also
Initialization and Reinitialization
Credits
Init first appeared in the original Csound, but the extension to multiple values is by
Author: John ffitch
University of Bath, and Codemist Ltd.
Bath, UK
February 2010
Multiple form new in version 5.13; t-variable form new in 5.14.