setksmps — Sets the local ksmps value in a user-defined opcode block.
Sets the local ksmps value in a user-defined opcode block.
The setksmps statement can be used to set the local ksmps value of the user-defined opcode block. It has one i-time parameter specifying the new ksmps value (which is left unchanged if zero is used). setksmps should be used before any other opcodes (but allowed after xin), otherwise unpredictable results may occur.
iksmps -- sets the local ksmps value.
If iksmps is set to zero, the ksmps of the caller instrument or opcode is used (this is the default behavior).
Note | |
---|---|
The local ksmps is implemented by splitting up a control period into smaller sub-kperiods and temporarily modifying internal Csound global variables. This also requires converting the rate of k-rate input and output arguments (input variables receive the same value in all sub-kperiods, while outputs are written only in the last one). |
Warning about local ksmps | |
---|---|
When the local ksmps is not the same as the orchestra level ksmps value (as specified in the orchestra header). Global a-rate operations must not be used in the user-defined opcode block. These include:
In general, the local ksmps should be used with care as it is an experimental feature. Though it works correctly in most cases. |
The setksmps statement can be used to set the local ksmps value of the user-defined opcode block. It has one i-time parameter specifying the new ksmps value (which is left unchanged if zero is used). setksmps should be used before any other opcodes (but allowed after xin), otherwise unpredictable results may occur.
The syntax of a user-defined opcode block is as follows:
opcode name, outtypes, intypes
xinarg1 [, xinarg2] [, xinarg3] ... [xinargN] xin
[setksmps iksmps]
... the rest of the instrument's code.
xout xoutarg1 [, xoutarg2] [, xoutarg3] ... [xoutargN]
endop
The new opcode can then be used with the usual syntax:
[xinarg1] [, xinarg2] ... [xinargN] name [xoutarg1] [, xoutarg2] ... [xoutargN] [, iksmps]