2 summary:: Granular synthesis with sound stored in a buffer
3 categories:: UGens>Buffer, UGens>Generators>Granular
4 related:: Classes/GrainIn, Classes/GrainFM, Classes/GrainSin
11 argument:: numChannels
12 the number of channels to output. If 1, mono is returned and pan is ignored.
15 a kr or ar trigger to start a new grain. If ar, grains after the start of the synth are sample accurate.
18 size of the grain (in seconds).
21 the buffer holding a mono audio signal. If using multi-channel files, use Buffer.readChannel.
24 the playback rate of the sampled sound
27 the playback position for the grain to start with (0 is beginning, 1 is end of file)
30 the interpolation method used for pitchshifting grains:
32 ## 1 = no interpolation
34 ## 4 = cubic interpolation (more computationally intensive)
38 determines where to pan the output.
40 ## If numChannels = 1, no panning is done.
41 ## If numChannels = 2, panning is similar to Pan2.
42 ## If numChannels > 2, pannins is the same as PanAz.
46 the buffer number containing a singal to use for the grain envelope. -1 uses a built-in Hann envelope.
49 the maximum number of overlapping grains that can be used at a given time. This value is set at the UGens init time and can't be modified. Defaults to 512. This can be set lower for more efficient use of memory.
51 warning:: The above parameter is new (post SC 3.3.1) and has the potential to break code written <= 3.3.1. This parameter is BEFORE the mul slot, and you may need to update code to account for this difference. ::
53 discussion:: All args except numChannels and trigger are polled at grain creation time.
55 private:: init, argNamesInputsOffset
64 b = Buffer.read(s, Help.dir +/+ "sounds/a11wlk01-44_1.aiff");
66 winenv = Env([0, 1, 0], [0.5, 0.5], [8, -8]);
67 z = Buffer.sendCollection(s, winenv.discretize, 1);
69 SynthDef(\buf_grain_test, {arg gate = 1, amp = 1, sndbuf, envbuf;
70 var pan, env, freqdev;
71 // use mouse x to control panning
72 pan = MouseX.kr(-1, 1);
74 Env([0, 1, 0], [1, 1], \sin, 1),
79 GrainBuf.ar(2, Impulse.kr(10), 0.1, sndbuf, LFNoise1.kr.range(0.5, 2),
80 LFNoise2.kr(0.1).range(0, 1), 2, pan, envbuf) * env)
86 x = Synth(\buf_grain_test, [\sndbuf, b, \envbuf, -1])
88 // switch to the custom env