grain2 Signal Generators:Granular Synthesis grain2 grain2 Easy-to-use granular synthesis texture generator. Description Generate granular synthesis textures. grain2 is simpler to use, but grain3 offers more control. Syntax ares grain2 kcps, kfmd, kgdur, iovrlp, kfn, iwfn [, irpow] \ [, iseed] [, imode] 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 abs(x) ˆ ((1 / irpow) - 1); for negative irpow values, it 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 image below shows some examples for irpow. The default value of irpow is 0. [A graph of distributions for different values of irpow.] A graph of distributions for different values of irpow. 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. See the sections Real-time Audio and Command Line Flags for more information on using command line flags. See Also Granular Synthesis Credits Author: &nameistvan; New in version 4.15 Updated April 2002 by &nameistvan;