2 PlayBuf - sample player
5 PlayBuf : MultiOutUGen {
6 *ar { arg numChannels, bufnum=0, rate=1.0, trigger=1.0, startPos=0.0, loop = 0.0, doneAction=0;
7 ^this.multiNew('audio', numChannels, bufnum, rate, trigger, startPos, loop, doneAction)
10 *kr { arg numChannels, bufnum=0, rate=1.0, trigger=1.0, startPos=0.0, loop = 0.0, doneAction=0;
11 ^this.multiNew('control', numChannels, bufnum, rate, trigger, startPos, loop, doneAction)
14 init { arg argNumChannels ... theInputs;
16 ^this.initOutputs(argNumChannels, rate);
18 argNamesInputsOffset { ^2 }
21 TGrains : MultiOutUGen {
22 *ar { arg numChannels, trigger=0, bufnum=0, rate=1, centerPos=0,
23 dur=0.1, pan=0, amp=0.1, interp=4;
24 if (numChannels < 2) {
25 "TGrains needs at least two channels.".error;
28 ^this.multiNew('audio', numChannels, trigger, bufnum, rate, centerPos,
29 dur, pan, amp, interp)
31 init { arg argNumChannels ... theInputs;
33 ^this.initOutputs(argNumChannels, rate);
35 argNamesInputsOffset { ^2 }
40 // exception in GrafDef_Load: UGen 'SimpleLoopBuf' not installed.
42 SimpleLoopBuf : MultiOutUGen {
43 *ar { arg numChannels, bufnum=0, loopStart=0.0, loopEnd=99999.0, trigger=0.0;
44 ^this.multiNew('audio', numChannels, bufnum, loopStart, loopEnd, trigger)
47 init { arg argNumChannels ... theInputs;
49 ^this.initOutputs(argNumChannels, rate);
54 BufRd : MultiOutUGen {
55 *ar { arg numChannels, bufnum=0, phase=0.0, loop=1.0, interpolation=2;
56 ^this.multiNew('audio', numChannels, bufnum, phase, loop, interpolation)
58 *kr { arg numChannels, bufnum=0, phase=0.0, loop=1.0, interpolation=2;
59 ^this.multiNew('control', numChannels, bufnum, phase, loop, interpolation)
62 init { arg argNumChannels ... theInputs;
64 ^this.initOutputs(argNumChannels, rate);
66 argNamesInputsOffset { ^2 }
68 if (rate == 'audio' and: {inputs.at(1).rate != 'audio'}, {
69 ^("phase input is not audio rate: " + inputs.at(1) + inputs.at(1).rate);
71 ^this.checkValidInputs
76 *ar { arg inputArray, bufnum=0, phase=0.0, loop=1.0;
77 ^this.multiNewList(['audio', bufnum, phase,
78 loop] ++ inputArray.asArray)
81 *kr { arg inputArray, bufnum=0, phase=0.0, loop=1.0;
82 ^this.multiNewList(['control', bufnum, phase,
83 loop] ++ inputArray.asArray)
86 if (rate == 'audio' and: {inputs.at(1).rate != 'audio'}, {
87 ^("phase input is not audio rate: " + inputs.at(1) + inputs.at(1).rate);
89 ^this.checkValidInputs
95 *ar { arg inputArray, bufnum=0, offset=0.0, recLevel=1.0, preLevel=0.0,
96 run=1.0, loop=1.0, trigger=1.0, doneAction=0;
98 ['audio', bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction ]
102 *kr { arg inputArray, bufnum=0, offset=0.0, recLevel=1.0, preLevel=0.0,
103 run=1.0, loop=1.0, trigger=1.0, doneAction=0;
105 ['control', bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction ]
106 ++ inputArray.asArray
113 *ar { arg inputArray , bufnum=0;
114 this.multiNewList(['audio', bufnum] ++ inputArray.asArray);
117 *kr { arg inputArray , bufnum=0;
118 this.multiNewList(['control', bufnum] ++ inputArray.asArray);
124 *ar { arg inputArray, scopeNum=0, maxFrames = 4096, scopeFrames;
125 this.multiNewList(['audio', scopeNum, maxFrames, scopeFrames ? maxFrames] ++ inputArray.asArray);
128 *kr { arg inputArray, scopeNum=0, maxFrames = 4096, scopeFrames;
129 this.multiNewList(['control', scopeNum, maxFrames, scopeFrames ? maxFrames] ++ inputArray.asArray);
135 *ar { arg bufnum = 0, numChannels = 1, delaytime = 0.2;
137 n = delaytime * SampleRate.ir.neg; // this depends on the session sample rate, not buffer.
138 ^PlayBuf.ar(numChannels, bufnum, 1, 0, n, 1);
142 LocalBuf : WidthFirstUGen {
144 *new { arg numFrames = 1, numChannels = 1;
145 ^this.multiNew('scalar', numChannels, numFrames)
148 *new1 { arg rate ... args;
149 var maxLocalBufs = UGen.buildSynthDef.maxLocalBufs;
150 if(maxLocalBufs.isNil) {
151 maxLocalBufs = MaxLocalBufs.new;
152 UGen.buildSynthDef.maxLocalBufs = maxLocalBufs;
154 maxLocalBufs.increment;
155 ^super.new.rate_(rate).addToSynth.init( *args ++ maxLocalBufs )
161 if(shape.size == 1) { shape = [1, list.size] };
162 if(shape.size > 2) { Error("LocalBuf: list has not the right shape").throw };
163 buf = this.new(*shape.reverse);
164 buf.set(list.flop.flat);
168 numFrames { ^inputs[1] }
169 numChannels { ^inputs[0] }
171 set { arg values, offset = 0;
172 SetBuf(this, values.asArray, offset);
180 MaxLocalBufs : UGen {
182 ^this.multiNew('scalar', 0);
185 inputs[0] = inputs[0] + 1;
189 SetBuf : WidthFirstUGen {
190 *new { arg buf, values, offset = 0;
191 ^this.multiNewList(['scalar', buf, offset, values.size] ++ values)
195 ClearBuf : WidthFirstUGen {
197 ^this.multiNew('scalar', buf)