refactor stubs for NRT objects
parent
8a60b12996
commit
b4655bd4d8
@ -1,46 +1,16 @@
|
|||||||
FluidBufThreadDemo : UGen{
|
FluidBufThreadDemo : UGen{
|
||||||
var <>synth, <>server;
|
|
||||||
|
|
||||||
*kr {|result, time, doneAction = 0|
|
|
||||||
|
|
||||||
|
*kr {|result, time, doneAction = 0|
|
||||||
result = result.asUGenInput;
|
result = result.asUGenInput;
|
||||||
|
result.isNil.if {this.class.name+": Invalid output buffer".throw};
|
||||||
result.isNil.if {"FluidBufThreadDemo: Invalid output buffer".throw};
|
|
||||||
|
|
||||||
//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)
|
|
||||||
^this.multiNew(\control, result, time, doneAction);
|
^this.multiNew(\control, result, time, doneAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
*process { |server, result, time = 1000, action|
|
*process { |server, result, time = 1000, action|
|
||||||
|
^FluidNRTProcess.new(
|
||||||
var synth,instance;
|
server, this, action, [result]
|
||||||
|
).process(
|
||||||
result = result.asUGenInput;
|
result, time
|
||||||
|
);
|
||||||
result.isNil.if {"FluidBufThreadDemo: Invalid output buffer".throw};
|
|
||||||
|
|
||||||
server = server ? Server.default;
|
|
||||||
server.ifNotRunning({
|
|
||||||
"WARNING: Server not running".postln;
|
|
||||||
^nil;
|
|
||||||
});
|
|
||||||
|
|
||||||
synth = { instance = FluidBufThreadDemo.kr(result, time, doneAction:Done.freeSelf)}.play(server);
|
|
||||||
|
|
||||||
forkIfNeeded{
|
|
||||||
synth.waitForFree;
|
|
||||||
server.sync;
|
|
||||||
result = server.cachedBufferAt(result); result.updateInfo; server.sync;
|
|
||||||
action.value(result);
|
|
||||||
};
|
|
||||||
instance.synth = synth;
|
|
||||||
instance.server = server;
|
|
||||||
^instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel{
|
|
||||||
if(this.server.notNil)
|
|
||||||
{this.server.sendMsg("/u_cmd", this.synth.nodeID, this.synthIndex, "cancel")};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
FluidNRTProcess : Object{
|
||||||
|
var <server, <ugen, <action, <outputBuffers, <synth;
|
||||||
|
|
||||||
|
*new {|server, ugen, action, outputBuffers|
|
||||||
|
^super.newCopyArgs(server, ugen, action, outputBuffers).init;
|
||||||
|
}
|
||||||
|
|
||||||
|
init{
|
||||||
|
server = server ? Server.default;
|
||||||
|
server.ifNotRunning({
|
||||||
|
"FluidNRTProcess: Server not running".throw;
|
||||||
|
});
|
||||||
|
if (ugen.isNil){
|
||||||
|
"FluidNRTProcess: UGen is nil".throw;
|
||||||
|
};
|
||||||
|
outputBuffers = outputBuffers.collect{|b|
|
||||||
|
var checked = server.cachedBufferAt(b.asUGenInput);
|
||||||
|
checked.isNil.if{ (ugen.asString ++":" + "Invalid buffer").throw};
|
||||||
|
checked
|
||||||
|
}
|
||||||
|
^this;
|
||||||
|
}
|
||||||
|
|
||||||
|
process{|...ugenArgs|
|
||||||
|
synth = {
|
||||||
|
ugen.performList(\kr, ugenArgs.collect{|a| a.asUGenInput} ++ Done.freeSelf)
|
||||||
|
}.play(server);
|
||||||
|
synth.postln;
|
||||||
|
forkIfNeeded{
|
||||||
|
synth.waitForFree;
|
||||||
|
server.sync;
|
||||||
|
outputBuffers.do{|buf|
|
||||||
|
buf = server.cachedBufferAt(buf.asUGenInput);
|
||||||
|
buf.updateInfo;
|
||||||
|
server.sync;
|
||||||
|
};
|
||||||
|
if(action.notNil){action.valueArray(outputBuffers)};
|
||||||
|
};
|
||||||
|
^this;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel{
|
||||||
|
if(server.notNil && synth.notNil) {synth.free};
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue