1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
MultiOutDemandUGen : DUGen {
// a class for UGens with multiple outputs
var <channels;
*newFromDesc { arg rate, numOutputs, inputs;
^super.new.rate_(rate).inputs_(inputs).initOutputs(numOutputs, rate)
}
initOutputs { arg numChannels, rate;
if(numChannels.isNil or: { numChannels < 1 }, {
Error("%: wrong number of channels (%)".format(this, numChannels)).throw
});
channels = Array.fill(numChannels, { arg i;
OutputProxy(rate, this, i);
});
if (numChannels == 1, {
^channels.at(0)
});
^channels
}
numOutputs { ^channels.size }
writeOutputSpecs { arg file;
channels.do({ arg output; output.writeOutputSpec(file); });
}
synthIndex_ { arg index;
synthIndex = index;
channels.do({ arg output; output.synthIndex_(index); });
}
}
Dneuromodule : MultiOutDemandUGen {
*new { |numChannels, theta, x, weights|
^super.multiNew(\demand, *[numChannels] ++ theta ++ x ++ weights )
}
*ar { |dt, numChannels, theta, x, weights|
^Duty.ar(dt, 0, this.new(numChannels, theta, x, weights))
}
*kr { |dt, numChannels, theta, x, weights|
^Duty.ar(dt, 0, this.new(numChannels, theta, x, weights))
}
init { arg numChannels ... theInputs;
inputs = [numChannels] ++ theInputs;
channels = numChannels.collect { |i|
OutputProxy(rate, this, i)
};
^channels
}
checkInputs { ^this.checkNInputs(1) } // TODO: check.
}
|