Make FluidBufAudioTransport.sc conform to general NRT class structure
parent
5bd0832981
commit
05c5b3da3c
@ -1,59 +1,40 @@
|
|||||||
FluidBufAudioTransport : UGen{
|
FluidBufAudioTransport : UGen{
|
||||||
|
*new1 { |rate, source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking=0|
|
||||||
var <>synth, <>server;
|
|
||||||
|
|
||||||
*kr { |source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1|
|
|
||||||
|
|
||||||
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
||||||
var blocking = 0;
|
|
||||||
|
|
||||||
source1.isNil.if {"FluidAudioTransport: Invalid source 1 buffer".throw};
|
source1.isNil.if {"FluidAudioTransport: Invalid source 1 buffer".throw};
|
||||||
source2.isNil.if {"FluidAudioTransport: Invalid source 2 buffer".throw};
|
source2.isNil.if {"FluidAudioTransport: Invalid source 2 buffer".throw};
|
||||||
source1 = source1.asUGenInput;
|
source1 = source1.asUGenInput;
|
||||||
source2 = source2.asUGenInput;
|
source2 = source2.asUGenInput;
|
||||||
|
|
||||||
|
destination.isNil.if {"FluidAudioTransport: Invalid destination buffer".throw};
|
||||||
|
destination = destination.asUGenInput;
|
||||||
|
|
||||||
destination.isNil.if {"FluidAudioTransport: Invalid destination buffer".throw};
|
|
||||||
destination = destination.asUGenInput;
|
|
||||||
//NB For wrapped versions of NRT classes, we set the params for maxima to
|
//NB For wrapped versions of NRT classes, we set the params for maxima to
|
||||||
//whatever has been passed in language-side (e.g maxFFTSize still exists as a parameter for the server plugin, but makes less sense here: it just needs to be set to a legal value)
|
//whatever has been passed in language-side (e.g maxFFTSize still exists as a parameter for the server plugin, but makes less sense here: it just needs to be set to a legal value)
|
||||||
|
^super.new1(rate,source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize, maxFFTSize, trig,blocking)
|
||||||
|
|
||||||
^this.multiNew(\control, source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize,maxFFTSize, trig,blocking);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*kr { |source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1|
|
||||||
*process { |server, source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, action|
|
^this.new1(\control, source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize, trig);
|
||||||
var synth, instance;
|
}
|
||||||
|
|
||||||
|
|
||||||
source1.isNil.if {"FluidAudioTransport: Invalid source 1 buffer".throw};
|
|
||||||
source2.isNil.if {"FluidAudioTransport: Invalid source 2 buffer".throw};
|
|
||||||
|
|
||||||
destination.isNil.if {"FluidAudioTransport: Invalid destination buffer".throw};
|
|
||||||
|
|
||||||
|
|
||||||
source1 = source1.asUGenInput;
|
*process { |server, source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, action|
|
||||||
source2 = source2.asUGenInput;
|
^FluidNRTProcess.new(
|
||||||
destination = destination.asUGenInput;
|
server, this, action, [destination]
|
||||||
|
).process(
|
||||||
server = server ? Server.default;
|
source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame2, numFrames2, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize
|
||||||
server.ifNotRunning({
|
)
|
||||||
"WARNING: Server not running".postln;
|
|
||||||
^nil;
|
|
||||||
});
|
|
||||||
synth = { instance = FluidBufAudioTransport.kr(source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize, trig:1)}.play(server);
|
|
||||||
forkIfNeeded{
|
|
||||||
synth.waitForFree;
|
|
||||||
server.sync;
|
|
||||||
if (destination != -1) {destination = server.cachedBufferAt(destination); destination.updateInfo; server.sync;} {destination = nil};
|
|
||||||
action.value(destination);
|
|
||||||
};
|
|
||||||
instance.synth = synth;
|
|
||||||
instance.server = server;
|
|
||||||
^instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel{
|
*processBlocking { |server, source1, startFrame1 = 0, numFrames1 = -1, startChan1 = 0, numChans1 = -1, source2, startFrame2 = 0, numFrames2 = -1, startChan2 = 0, numChans2 = -1, destination, interpolation=0.0, bandwidth=255, windowSize = 1024, hopSize = -1, fftSize = -1, action|
|
||||||
if(this.server.notNil)
|
^FluidNRTProcess.new(
|
||||||
{this.server.sendMsg("/u_cmd", this.synth.nodeID, this.synthIndex, "cancel")};
|
server, this, action, [destination],blocking:1
|
||||||
}
|
).process(
|
||||||
|
source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame2, numFrames2, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue