Title: Reinitialization in Csound
1Re-initialization in Csound
- The Csound reinit opcode provides a means to
re-initialize portions of an instrument program
during performance. - During a re-initialization pass, k-rate
execution pauses temporarily and a new I-time
pass is made through the range of statements
specified. - After the re-initialization pass, k-rate
execution resumes normally.
2Re-initialization Opcodes
3Basic Coding Principles
- Re-initialization begins at the statement
following the reinit label and continues until an
endin or rireturn opcode is encountered. - reinit is always used intermittently, often in a
conditional context. I.e., if a specified
condition is met, or if a certain amount of time
has elapsed, then re-initialize the necessary
part of the instrument. - The Csound timout opcode is very useful in
conjunction with reinit, and often paired with it
when periodic re-initialization is needed - Syntax timout istart, idur, label
4Conditional Re-initialization
gliss start reinit here kgliss line 1,
iglissdur,2 rireturn end reinit
here if (kgliss lt 2) kgoto continue reinit gli
ss restart gliss continue kgate linen iamp,iris
e,p3,idecay asig oscili iamp,icpskgliss,ifn ou
t asig endin
5Periodic Reinitialization
N.B., re-initialization will include the timout
opcode start timout 0, idur,
continue reinit start skipped for idur
secs continue kgate linen iamp,irise,idur,idec
ay asig oscili kgate,icps,ifn out
asig endin
6Re-initialization Notes
- Only i-type statements, expressions, and
arguments will be changed during a
re-initialization pass. - To access the current value of a k-variable
during re-initialization, use the Csound i()
function, e.g.
kdur table kindex,ifunction start idur i(kdur
) kgate linen iamp,idur.1,idur,idur.5 timout
0, idur, continue reinit start start reinit
above continue rireturn end reinit here
7Reading Assignment
- Read Boulanger Chapter 17 RP Constrained
Random Event Generation and Retriggering in
Csound - Read the Csound Manual about reinit, rigoto,
rireturn, and timout. - Experiment!