UGen : AbstractFunction
{
var <synth;
var <>inputs;
var <>rate = 'audio';
var <state = 0;
// instance creation
*ar1 {
^this.new;
} // create and set for audio rate output
(the default)
*kr1 {
^this.new.rate_('control');
} // create and set for control rate
output
*sr1 {
^this.new.rate_('spectral');
} // create and set for spectral rate
output
init { arg ... theInputs;
// store the inputs as an array
inputs = theInputs;
}
// use only ar or kr to create new instances
*new {
_UGen_New
^this.primitiveFailed
}
*newClear { ^this.shouldNotImplement
}
poll { // returns the current value
(a Float) of a running unit generator.
_UGenPoll
^this.primitiveFailed
}
source { ^this }
isValidUGenInput { ^true }
degreeToKey { arg scale, stepsPerOctave=12;
^DegreeToKey.kr(scale,
this, stepsPerOctave)
}
// PRIVATE
// function composition
composeUnaryOp { arg aSelector;
^UnaryOpUGen.new(aSelector,
this)
}
composeBinaryOp { arg aSelector,
anInput;
if (anInput.isValidUGenInput, {
^BinaryOpUGen.new(aSelector,
this, anInput)
},{
anInput.performBinaryOpOnUGen(aSelector, this);
});
}
reverseComposeBinaryOp { arg
aSelector, aUGen;
^BinaryOpUGen.new(aSelector,
aUGen, this)
}
composeNAryOp { arg aSelector,
anArgList;
^this.notYetImplemented
}
// complex support
asComplex { ^Complex.new(this, 0.0) }
performBinaryOpOnComplex { arg
aSelector, aComplex; ^aComplex.perform(aSelector, this.asComplex) }
if { arg trueUGen, falseUGen;
^(this * (trueUGen - falseUGen))
+ falseUGen;
}
}
MultiOutUGen : UGen {
// a class for UGens with multiple outputs
var channels;
initOutputs { arg argNumChannels;
var i = 0, outChan;
if (argNumChannels <= 1, {
outChan = OutputProxy.ar1(this);
channels = Array.with(outChan);
^outChan
},{
channels = Array.new(argNumChannels);
while ({ i < argNumChannels },{
outChan = OutputProxy.ar1(this);
channels.add(outChan);
i = i + 1;
});
^channels
});
}
}
UGenPlugIn : UGen
{
}
MultiOutUGenPlugIn : MultiOutUGen {
}
ExamplePlugIn : UGenPlugIn {
*ar { arg a = 0.0, b = 0.0;
^this.multiChannelPerform('ar1', a, b)
}
*kr { arg a = 0.0, b = 0.0;
^this.multiChannelPerform('kr1', a, b)
}
*ar1 { arg a = 0.0, b = 0.0;
^super.ar1.init(a, b)
}
*kr1 { arg a = 0.0, b = 0.0;
^super.kr1.init(a, b)
}
}
OutputProxy : UGen
{
var <>source;
*ar1 { arg itsSourceUGen;
^super.ar1.inputs_(itsSourceUGen).source_(itsSourceUGen)
}
*kr1 { arg itsSourceUGen;
^super.kr1.inputs_(itsSourceUGen).source_(itsSourceUGen)
}
*sr1 { arg itsSourceUGen;
^super.sr1.inputs_(itsSourceUGen).source_(itsSourceUGen)
}
}
This page was created by SimpleText2Html 1.0.3 on 22-Feb-100.