scide: LookupDialog - redo lookup on classes after partial lookup
[supercollider.git] / HelpSource / Classes / GrainSin.schelp
blob97af48bc4ace99b8afdab23f689289ae6c94efe1
1 class:: GrainSin
2 summary:: Granular synthesis with sine tones
3 categories:: UGens>Generators>Granular
4 related:: Classes/GrainIn, Classes/GrainFM, Classes/GrainBuf
6 classmethods::
7 private:: categories
9 method:: ar
11 argument:: numChannels
12 the number of channels to output. If 1, mono is returned and pan is ignored.
14 argument:: trigger
15 a kr or ar trigger to start a new grain. If ar, grains after the start of the synth are sample accurate.
17 argument:: dur
18 size of the grain (in seconds).
20 argument:: freq
21 the input to granulate
23 argument:: pan
24 determines where to pan the output.
25 list::
26 ## If numChannels = 1, no panning is done.
27 ## If numChannels = 2, panning is similar to Pan2.
28 ## If numChannels > 2, pannins is the same as PanAz.
31 argument:: envbufnum
32 the buffer number containing a singal to use for the grain envelope. -1 uses a built-in Hann envelope.
34 argument:: maxGrains
35 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.
37 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. ::
39 argument:: mul
41 argument:: add
43 discussion:: All args except numChannels and trigger are polled at grain creation time.
45 instancemethods::
46 private:: init, argNamesInputsOffset
48 Examples::
49 code::
51 s.boot;
54 var winenv;
55 // a custom envelope
56 winenv = Env([0, 1, 0], [0.5, 0.5], [8, -8]);
57 z = Buffer.sendCollection(s, winenv.discretize, 1);
59 SynthDef(\sin_grain_test, {arg gate = 1, amp = 1, envbuf;
60         var pan, env, freqdev;
61         // use mouse x to control panning
62         pan = MouseX.kr(-1, 1);
63         // use WhiteNoise and mouse y to control deviation from center pitch
64         freqdev = WhiteNoise.kr(MouseY.kr(0, 400));
65         env = EnvGen.kr(
66                 Env([0, 1, 0], [1, 1], \sin, 1),
67                 gate,
68                 levelScale: amp,
69                 doneAction: 2);
70         Out.ar(0,
71                 GrainSin.ar(2, Impulse.kr(10), 0.1, 440 + freqdev, pan, envbuf) * env)
72         }).send(s);
75 s.scope
76 // use built-in env
77 x = Synth(\sin_grain_test, [\envbuf, -1])
79 // switch to the custom env
80 x.set(\envbuf, z)
81 x.set(\envbuf, -1);
83 x.set(\gate, 0);