ar grain2 kcps, kfmd, kgdur, iovrlp, kfn, iwfn[, irpow[, iseed[, imode]]] ar grain3 kcps, kphs, kfmd, kpmd, kgdur, kdens, imaxovr, kfn, iwfn, kfrpow, kprpow[, iseed[, imode]]
Generate granular synthesis textures. grain2 is simpler to use, but grain3 offers more control.
iovrlp – fixed number of overlapping grains in grain2
imaxovr – maximum number of overlapping grains in grain3. The number of overlaps can be calculated as kdens*kgdur, however, imaxovr can be overestimated at no cost in rendering time. A single overlap uses 16 to 32 bytes of memory, depending on operating system.
iwfn – function table containing window waveform. Use GEN20 to calculate iwfn.
irpow – controls the random distribution of grain frequency. If irpow is positive, the distribution (where x is in the range -1 to 1) is:
For negative irpow values, the distribution is:
(1 - abs(x))(-1/irpow)-1
Setting irpow to -1, 0, or 1 will result in uniform distribution. This is also faster to calculate. The default value of irpow is 0.
iseed – seed value for the random number generator. iseed must be a positive integer in the range 1 to 2147483646 (231 - 2). The default is 0.
imode – sum of the following values (default is 0):
kcps – grain frequency in Hz
kphs – grain phase
kfmd – bipolar random variation of grain frequency, in Hz
kpmd – bipolar random variation of beginning phase
kgdur – grain duration in seconds. kgdur also controls the duration of already active grains, by controlling the speed at which iwfn is read. This is unaffected by imode.
kdens – number of grains per second. In grain2, kdens = iovrlp/kgdur.
kfrpow – distribution of random frequency variation. See irpow.
kprpow – distribution of random phase variation. See irpow.
kfn – function table containing the grain waveform. Aliasing can be avoided by selecting, at k-rate, from a set of band-limited tables generated by GEN30.
grain3 will emulate grain2 by setting kphs = 0.5, kpmd = 0.5, and kprpow = 0.
|Figure 1: grain2 Random Distribution|
New Csound 4.16