1 Demand : MultiOutUGen {
2 *ar { arg trig, reset, demandUGens;
3 ^this.multiNewList(['audio', trig, reset] ++ demandUGens.asArray)
5 *kr { arg trig, reset, demandUGens;
6 ^this.multiNewList(['control', trig, reset] ++ demandUGens.asArray)
8 init { arg ... argInputs;
10 ^this.initOutputs(inputs.size - 2, rate)
12 checkInputs { ^this.checkSameRateAsFirstInput }
17 *ar { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0;
18 ^this.multiNew('audio', dur, reset, doneAction, level)
20 *kr { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0;
21 ^this.multiNew('control', dur, reset, doneAction, level)
24 ^if(inputs.at(0).rate === \demand) {
25 if (inputs.at(1).rate !== \demand and: { inputs.at(1).rate !== \scalar } and:
26 { inputs.at(1).rate !== rate }) {
27 ("reset input is not" + rate + "rate: " + inputs.at(1) + inputs.at(1).rate);
36 *ar { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0, gapFirst = 0;
37 ^this.multiNew('audio', dur, reset, doneAction, level, gapFirst)
39 *kr { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0, gapFirst = 0;
40 ^this.multiNew('control', dur, reset, doneAction, level, gapFirst)
44 // old version with gap first
46 *ar { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0;
47 ^TDuty.ar(dur, reset, level, doneAction, 1)
49 *kr { arg dur = 1.0, reset = 0.0, level = 1.0, doneAction = 0;
50 ^TDuty.kr(dur, reset, level, doneAction, 1)
56 *kr { arg level, dur, shape = 1, curve = 0, gate = 1.0, reset = 1.0,
57 levelScale = 1.0, levelBias = 0.0, timeScale = 1.0, doneAction=0;
58 ^this.multiNew('control', level, dur, shape, curve, gate, reset,
59 levelScale, levelBias, timeScale, doneAction)
61 *ar { arg level, dur, shape = 1, curve = 0, gate = 1.0, reset = 1.0,
62 levelScale = 1.0, levelBias = 0.0, timeScale = 1.0, doneAction=0;
63 if(gate.rate === 'audio' or: { reset.rate === 'audio' }) {
64 if(gate.rate !== 'audio') { gate = K2A.ar(gate) };
65 if(reset.rate !== 'audio') { reset = K2A.ar(reset) };
67 ^this.multiNew('audio', level, dur, shape, curve, gate, reset,
68 levelScale, levelBias, timeScale, doneAction)
73 // some n-ary op special cases
74 linlin { arg inMin, inMax, outMin, outMax, clip=\minmax;
75 ^((this.prune(inMin, inMax, clip)-inMin)/(inMax-inMin) * (outMax-outMin) + outMin);
78 linexp { arg inMin, inMax, outMin, outMax, clip=\minmax;
79 ^(pow(outMax/outMin, (this-inMin)/(inMax-inMin)) * outMin)
80 .prune(outMin, outMax, clip);
83 explin { arg inMin, inMax, outMin, outMax, clip=\minmax;
84 ^(log(this.prune(inMin, inMax, clip)/inMin))
85 / (log(inMax/inMin)) * (outMax-outMin) + outMin
88 expexp { arg inMin, inMax, outMin, outMax, clip=\minmax;
89 ^pow(outMax/outMin, log(this.prune(inMin, inMax, clip/inMin) / log(inMax/inMin)) * outMin)
94 *new { arg start = 1, step = 1, length = inf;
95 ^this.multiNew('demand', length, start, step)
100 *new { arg start = 1, grow = 2, length = inf;
101 ^this.multiNew('demand', length, start, grow)
106 *new { arg bufnum = 0, phase = 0.0, loop = 1.0;
107 ^this.multiNew('demand', bufnum, phase, loop)
112 *new { arg input = 0.0, bufnum = 0, phase = 0.0, loop = 1.0;
113 ^this.multiNew('demand', bufnum, phase, input, loop)
118 *new { arg list, repeats = 1;
119 ^this.multiNewList(['demand', repeats] ++ list)
127 Dxrand : ListDUGen {}
130 *new { arg list, weights, repeats = 1;
131 var size = list.size;
132 weights = weights.extend(size, 0.0);
133 ^this.multiNewList(['demand', repeats, size] ++ weights ++ list)
138 *new { arg list, index;
139 ^this.multiNewList(['demand', index] ++ list)
143 Dswitch : Dswitch1 {}
146 *new { arg lo = 0.0, hi = 1.0, length = inf;
147 ^this.multiNew('demand', length, lo, hi)
154 *new { arg lo = 0.0, hi = 1.0, step = 0.01, length = inf;
155 ^this.multiNew('demand', length, lo, hi, step)
163 ^this.multiNew('demand', n, in)
169 ^this.multiNew('demand', in)
174 *new { arg in, reset = 0.0;
175 ^this.multiNew('demand', in, reset)
180 *new { arg in, label, run = 1, trigid = -1;
181 ^this.multiNew('demand', in, label, run, trigid)
184 *new1 { arg rate, in, label, run, trigid;
185 label = label ?? { "DemandUGen(%)".format(in.class) };
187 ^super.new.rate_(rate).addToSynth.init(*[in, trigid, run, label.size] ++ label);
191 // behave as identical in multiple uses
194 var <>source, stutter, numUses;
197 ^super.new.source_(source).init
202 stutter = Dstutter(1, source);
206 numUses = numUses + 1;
207 stutter.inputs[0] = numUses;