granule Signal Generators:Granular Synthesis granule granule A more complex granular synthesis texture generator. Description The granule unit generator is more complex than grain, but does add new possibilities. granule is a Csound unit generator which employs a wavetable as input to produce granularly synthesized audio output. Wavetable data may be generated by any of the GEN subroutines such as GEN01 which reads an audio data file into a wavetable. This enable a sampled sound to be used as the source for the grains. Up to 128 voices are implemented internally. The maximum number of voices can be increased by redefining the variable MAXVOICE in the grain4.h file. granule has a build-in random number generator to handle all the random offset parameters. Thresholding is also implemented to scan the source function table at initialization stage. This facilitates features such as skipping silence passage between sentences. The characteristics of the synthesis are controlled by 22 parameters. xamp is the amplitude of the output and it can be either audio rate or control rate variable. Syntax ares granule xamp, ivoice, iratio, imode, ithd, ifn, ipshift, igskip, igskip_os, ilength, kgap, igap_os, kgsize, igsize_os, iatt, idec \ [, iseed] [, ipitch1] [, ipitch2] [, ipitch3] [, ipitch4] [, ifnenv] Initialization ivoice -- number of voices. iratio -- ratio of the speed of the gskip pointer relative to output audio sample rate. eg. 0.5 will be half speed. imode -- +1 grain pointer move forward (same direction of the gskip pointer), -1 backward (oppose direction to the gskip pointer) or 0 for random. ithd -- threshold, if the sampled signal in the wavetable is smaller then ithd, it will be skipped. ifn -- function table number of sound source. ipshift -- pitch shift control. If ipshift is 0, pitch will be set randomly up and down an octave. If ipshift is 1, 2, 3 or 4, up to four different pitches can be set amount the number of voices defined in ivoice. The optional parameters ipitch1, ipitch2, ipitch3 and ipitch4 are used to quantify the pitch shifts. igskip -- initial skip from the beginning of the function table in sec. igskip_os -- gskip pointer random offset in sec, 0 will be no offset. ilength -- length of the table to be used starting from igskip in sec. igap_os -- gap random offset in % of the gap size, 0 gives no offset. igsize_os -- grain size random offset in % of grain size, 0 gives no offset. iatt -- attack of the grain envelope in % of grain size. idec -- decade of the grain envelope in % of grain size. iseed (optional, default=0.5) -- seed for the random number generator. ipitch1, ipitch2, ipitch3, ipitch4 (optional, default=1) -- pitch shift parameter, used when ipshift is set to 1, 2, 3 or 4. Time scaling technique is used in pitch shift with linear interpolation between data points. Default value is 1, the original pitch. ifnenv (optional, default=0) -- function table number to be used to generate the shape of the envelope. Performance xamp -- amplitude. kgap -- gap between grains in sec. kgsize -- grain size in sec. Examples Here is an example of the granule opcode. It uses the files granule.csd, marimba.aif and fox.wav Example of the granule opcode. See the sections Real-time Audio and Command Line Flags for more information on using command line flags. The above example reads a sound file called marimba.aif into wavetable number 1, a second reads fox.wav into wavetable number 2. The first note generates 10 seconds of stereo audio output using the wavetable. In the orchestra file, all parameters required to control the synthesis are passed from the score file. A linseg function generator is used to generate an envelope with 0.5 second of linear attack and decay. Stereo effect is generated by using different seeds for the two granule function calls. In the example, 0.17 is added to p20 (= iseed) before passing into the second granule call to ensure that all of the random offset events are different from the first one. The second note (wavetable number 2) has slightly different parameters. In the score file for the first note, the parameters are interpreted as: Parameter Interpreted As p5 (ivoice) the number of voices is set to 64 p6 (iratio) set to 0.5, it scans the wavetable at half of the speed of the audio output rate p7 (imode) set to 0, the grain pointer only move forward p8 (ithd) set to 0, skipping the thresholding process p9 (ifn) set to 1, function table number 1 is used p10 (ipshift) set to 4, four different pitches are going to be generated p11 (igskip) set to 0 and p12 (igskip_os) is set to 0.005, no skipping into the wavetable and a 5 mSec random offset is used p13 (ilength) set to 1, 1 second of the wavetable is to be used p14 (kgap) set to 0.01 and p15 (igap_os) is set to 50, 10 mSec gap with 50% random offset is to be used p16 (kgsize) set to 0.02 and p17 (igsize_os) is set to 50, 20 mSec grain with 50% random offset is used p18 (iatt) and p19 (idec) set to 25, 25% of linear attack and decade is applied to the grain p20 (iseed) seed for the random number generator is set to 0.39 p21 - p24 pitches set to 1 which is the original pitch, 1.42 which is a 5th up, 0.29 which is a 7th down and finally 2 which is an octave up. See Also Granular Synthesis Credits Author: Allan Lee Belfast 1996 New in version 3.35