Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / FreeSelf.schelp
blobc206bca8ed991aa43f4a8132e34843daf7cb2308
1 class:: FreeSelf
2 summary:: When triggered, free enclosing synth.
3 related:: Classes/PauseSelf, Classes/Free
4 categories::  UGens>Synth control
7 Description::
8 Free enclosing synth when input signal crosses from non-positive to
9 positive.
12 classmethods::
14 method::kr
16 argument::in
18 The input signal.
21 Examples::
23 code::
25 SynthDef("freeSelf-help", { arg out, t_trig;
26         FreeSelf.kr(t_trig);
27         Out.ar(out, SinOsc.ar(400,0,0.2));
28 }).send(s);
31 s.sendMsg("/s_new", "freeSelf-help", 1731);
32 s.sendMsg("/n_set", 1731, \t_trig, 1);
34 // a single impulse SynthDef:
37 SynthDef("dirac", { arg out, amp=0.1;
38         var u;
39         u = Impulse.ar(1);
40         FreeSelf.kr(u);
41         Out.ar(out, u * amp);
42                 // multiply by amp after using for release, so amp = 0
43                 // doesn't cause synth buildup.
44 }).send(s);
48 Task {
49         loop({
50                 fork {
51                         exprand(34, 156).do {|i|
52                                 i = i + 1;
53                                 s.sendMsg("/s_new", "dirac", -1,0,0, \amp, 1 / i);
54                                 (0.006 * i).wait;
55                         };
56                 };
57                 1.wait;
58         })
59 } .play;