class library: SynthDef - lazy implementation of removeUGen
[supercollider.git] / HelpSource / Classes / PingPong.schelp
blobc6dd30a38b58afdb6f00c6a37865702d81680056
1 class:: PingPong
2 summary:: Stereo ping-pong delay.
3 related:: Classes/SinOsc
4 categories::  UGens>Delays>Buffer
7 Description::
9 Bounces sound between two outputs…  Like a ping-pong ball. PingPong is
10 actually a compound built upon  link::Classes/RecordBuf::  and
11 link::Classes/PlayBuf:: .
14 classmethods::
16 method::ar
18 argument::bufnum
19 First index of a multi channel buffer.
21 argument::inputs
22 An array of audio inputs, the same size as your buffer.
24 argument::delayTime
25 Delay time in seconds.
27 argument::feedback
28 Feedback coefficient.
30 argument::rotate
32 Which rotates the inputArray by one step. (left → right, right →
33 left). Rotation of 0 (or 2) would result in no rotation to the
34 inputArray.
37 Examples::
39 code::
42 s = Server.local;
43 s.waitForBoot({
45 b = Buffer.alloc(s,44100 * 2, 2);
47 SynthDef("help-PingPong",{ arg out=0,bufnum=0,feedback=0.5,delayTime=0.2;
48         var left, right;
49         left = Decay2.ar(Impulse.ar(0.7, 0.25), 0.01, 0.25,
50                 SinOsc.ar(SinOsc.kr(3.7,0,200,500)));
51         right = Decay2.ar(Impulse.ar(0.5, 0.25), 0.01, 0.25,
52                 Resonz.ar(PinkNoise.ar(4), SinOsc.kr(2.7,0,1000,2500), 0.2));
54         Out.ar(0,
55                 PingPong.ar(bufnum, [left,right], delayTime, feedback, 1)
56         )
57 }).play(s,[\out, 0, \bufnum, b.bufnum,\feedback,0.5,\delayTime,0.1]);
58 });
63 s = Server.local;
64 s.waitForBoot({
66 b = Buffer.alloc(s,44100 * 2, 2);
68 SynthDef("help-PingPong",{ arg out=0,bufnum=0;
69         var left, right;
70         left = Decay2.ar(Impulse.ar(0.7, 0.25), 0.01, 0.25,
71                 SinOsc.ar(SinOsc.kr(3.7,0,200,500)));
72         right = Decay2.ar(Impulse.ar(0.5, 0.25), 0.01, 0.25,
73                 Resonz.ar(PinkNoise.ar(4), SinOsc.kr(2.7,0,1000,2500),
74 0.2));
76         Out.ar(0,
77                 PingPong.ar(bufnum, [left,right] *  EnvGen.kr(Env([1, 1, 0], [2, 0.1])),
78                         0.1, 0.8, 1)
79         )
80 }).play(s,[\out, 0, \bufnum, b.bufnum]);
81 });
90 Patch({ arg buffer,feedback=0.5,delayTime=0.2;
91         var left, right;
92         left = Decay2.ar(Impulse.ar(0.7, 0.25), 0.01, 0.25,
93                 SinOsc.ar(SinOsc.kr(3.7,0,200,500)));
94         right = Decay2.ar(Impulse.ar(0.5, 0.25), 0.01, 0.25,
95                 Resonz.ar(PinkNoise.ar(4), SinOsc.kr(2.7,0,1000,2500), 0.2));
97         PingPong.ar(buffer.bufnumIr, [left,right], delayTime, feedback, 1)
99 }).gui