oneShot: free the responder before running user func (avoid error)
[supercollider.git] / HelpSource / Classes / GrainFM.schelp
blob49314bf3405fd94231a0c833de8d16e3d00ad0a0
1 class:: GrainFM
2 summary:: Granular synthesis with frequency modulated sine tones
3 categories:: UGens>Generators>Granular
4 related:: Classes/GrainIn, Classes/GrainSin, 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).
19         
20 argument:: carfreq
21 the carrier freq of the grain generators internal oscillator
23 argument:: modfreq
24 the modulating freq of the grain generators internal oscillator
26 argument:: index
27 the index of modulation
28         
29 argument:: pan
30 determines where to pan the output.
31 list::
32 ## If numChannels = 1, no panning is done. 
33 ## If numChannels = 2, panning is similar to Pan2.
34 ## If numChannels > 2, pannins is the same as PanAz.
37 argument:: envbufnum
38 the buffer number containing a singal to use for the grain envelope. -1 uses a built-in Hann envelope.
40 argument:: maxGrains
41 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.
43 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. ::
45 discussion:: All args except numChannels and trigger are polled at grain creation time.
46 instancemethods::
47 private:: init, argNamesInputsOffset
49 examples::
50 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(\fm_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                 GrainFM.ar(2, Impulse.kr(10), 0.1, 440 + freqdev, 200, LFNoise1.kr.range(1, 10),
72                         pan, envbuf) * env)
73         }).send(s);
77 // use built-in env
78 x = Synth(\fm_grain_test, [\envbuf, -1])
80 // switch to the custom env
81 x.set(\envbuf, z)
82 x.set(\envbuf, -1);
84 x.set(\gate, 0);