grain2
Easy-to-use granular synthesis texture generator.
Generate granular synthesis textures. grain2 is simpler to use, but grain3 offers more control.
Syntax
Initialization
iovrlp -- (fixed) number of overlapping grains.
iwfn -- function table containing window waveform (Use GEN20 to calculate iwfn).
irpow (optional, default=0) -- this value controls the distribution of grain frequency variation. If irpow is positive, the random distribution (x is in the range -1 to 1) is
for negative irpow values, it is
Setting irpow to -1, 0, or 1 will result in uniform distribution (this is also faster to calculate). The image below shows some examples for irpow. The default value of irpow is 0.
![[A graph of distributions for different values of .]](../../images/grain2_rand-448x289.png)
iseed (optional, default=0) -- seed value for random number generator (positive integer in the range 1 to 2147483646 (231 - 2)). Zero or negative value seeds from current time (this is also the default).
imode (optional default=0) -- sum of the following values:
- 8: interpolate window waveform (slower).
- 4: do not interpolate grain waveform (fast, but lower quality).
- 2: grain frequency is continuously modified by kcps and kfmd (by default, each grain keeps the frequency it was launched with). This may be slower at high control rates.
- 1: skip initialization.
Performance
ares -- output signal.
kcps -- grain frequency in Hz.
kfmd -- random variation (bipolar) in grain frequency in Hz.
kgdur -- grain duration in seconds. kgdur also controls the duration of already active grains (actually the speed at which the window function is read). This behavior does not depend on the imode flags.
kfn -- function table containing grain waveform. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by GEN30, to avoid aliasing).
Note
grain2 internally uses the same random number generator as rnd31. So reading its documentation is also recommended.
Examples
Here is an example of the grain2 opcode. It uses the file grain2.csd.
Example of the grain2 opcode. | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
See Also
Credits
Author: Istvan Varga
New in version 4.15
Updated April 2002 by Istvan Varga