class library: DUGen - the server now handles audio-rate inputs correctly
[supercollider.git] / SCClassLibrary / Common / Audio / DelayWr.sc
blob16ac31bc238a7dbc06cc88653a0d659788b5d701
1 PingPong {
2         //your buffer should be the same numChannels as your inputs
3         *ar { arg  bufnum=0,  inputs, delayTime, feedback=0.7, rotate=1;
5                 var trig, delayedSignals;
7                 trig = Impulse.kr(delayTime.reciprocal);
9                 delayedSignals =
10                         PlayBuf.ar(inputs.numChannels,bufnum,1.0,trig,
11                                 0,
12                                 0.0).rotate(rotate)
13                         * feedback + inputs;
15                 RecordBuf.ar(delayedSignals,bufnum,0.0,1.0,0.0,1.0,0.0,trig);
17                 ^delayedSignals
18         }
22 /* old sc3d5 version
23 PingPong {
24         *ar { arg bank, index, inputs, delayTime, feedback=0.7, rotate=1, interpolationType=2;
26                 var indices, delayedSignals, outputs;
28                 delayedSignals = PlayBuf.ar(bank, index, -1, delayTime, interpolationType).postln;
30                 outputs = delayedSignals.rotate(rotate) * feedback + inputs;
32                 RecordBuf.ar(bank, index, outputs, run: -1);    // feedback to buffers
34                 ^outputs
35         }
40 /**
44         these are still set up for sc3d5 style PlayBuf.
45         won't work on scsynth yet
46         -felix
50 DelayProcess {
51         *ar { arg bank, firstIndex, function, inputs, delayTime, interpolationType=2;
52                 var indices, delayedSignals, outputs;
53                 //[bank, firstIndex, function, inputs, delayTime, interpolationType].postln;
54                 if (delayTime.isArray, {
55                         // need separate buffers.
57                         inputs = inputs.asArray;
58                         indices = Array.series(inputs.size, firstIndex, 1);
60                         // tap the delay lines
61                         delayedSignals = PlayBuf.ar(bank, indices, -1, delayTime, interpolationType).postln;
63                         outputs = function.value(inputs, delayedSignals);
65                         // mix the delayed signal with the input
67                         RecordBuf.arN(bank, indices, outputs, run: -1); // feedback to buffers
68                 },{
69                         // tap the delay lines
70                         delayedSignals = PlayBuf.ar(bank, firstIndex, -1, delayTime, interpolationType).postln;
72                         outputs = function.value(inputs, delayedSignals);
74                         // mix the delayed signal with the input
76                         RecordBuf.ar(bank, firstIndex, outputs, run: -1);       // feedback to buffers
77                 });
79                 ^outputs        // output the mixed signal and force the DelayWr into the call graph
80         }
83 **/