FluidManipulation: Remaining SClang class stubs – NEEDS TESTING
parent
6a9febafea
commit
7aa5705bc1
@ -0,0 +1,5 @@
|
||||
FluidAudioTransport : UGen {
|
||||
*ar { arg in = 0, interpolation=0.0, bandwidth=255,windowSize= 1024, hopSize= -1, fftSize= -1, maxFFTSize = 16384;
|
||||
^this.multiNew('audio', in.asAudioRateInput(this), interpolation, bandwidth, windowSize, hopSize, fftSize, maxFFTSize)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
FluidBufAudioTransport : UGen{
|
||||
|
||||
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, doneAction = 0|
|
||||
|
||||
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
||||
|
||||
source1.isNil.if {"FluidAudioTransport: Invalid source 1 buffer".throw};
|
||||
source2.isNil.if {"FluidAudioTransport: Invalid source 2 buffer".throw};
|
||||
source1 = source1.asUGenInput;
|
||||
source2 = source2.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
|
||||
//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, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize, doneAction);
|
||||
}
|
||||
|
||||
|
||||
*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|
|
||||
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;
|
||||
source2 = source2.asUGenInput;
|
||||
destination = destination.asUGenInput;
|
||||
|
||||
server = server ? Server.default;
|
||||
server.ifNotRunning({
|
||||
"WARNING: Server not running".postln;
|
||||
^nil;
|
||||
});
|
||||
synth = { instance = FluidBufSines.kr(source1, startFrame1, numFrames1, startChan1, numChans1, source2, startFrame1, numFrames1, startChan2, numChans2, destination, interpolation, bandwidth, windowSize, hopSize, fftSize, doneAction:Done.freeSelf)}.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{
|
||||
if(this.server.notNil)
|
||||
{this.server.sendMsg("/u_cmd", this.synth.nodeID, this.synthIndex, "cancel")};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
FluidKMeans : UGen {
|
||||
|
||||
var <> synth, <> server;
|
||||
|
||||
*kr {
|
||||
^this.multiNew('control');
|
||||
}
|
||||
|
||||
*new{ |server|
|
||||
var synth, instance;
|
||||
server = server ? Server.default;
|
||||
synth = {instance = FluidKMeans.kr()}.play(server);
|
||||
instance.server = server;
|
||||
instance.synth = synth;
|
||||
^instance
|
||||
}
|
||||
|
||||
train{|dataset,k, maxIter = 100, buffer, action|
|
||||
|
||||
buffer = buffer ? -1;
|
||||
|
||||
this.pr_sendMsg(\train,[dataset, k,maxIter, buffer.asUGenInput],action);
|
||||
}
|
||||
|
||||
cluster{ |dataset, labelset, k, maxIter=100, buffer,action|
|
||||
buffer = buffer ? -1;
|
||||
this.pr_sendMsg(\cluster,[dataset, labelset, k, maxIter, buffer.asUGenInput],action,k.collect{string(FluidMessageResponse,_,_)});
|
||||
}
|
||||
|
||||
predict { |buffer, action|
|
||||
this.pr_sendMsg(\predict,[buffer.asUGenInput],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
cols { |action|
|
||||
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
read{ |filename,action|
|
||||
this.pr_sendMsg(\read,[filename],action);
|
||||
}
|
||||
|
||||
write{ |filename,action|
|
||||
this.pr_sendMsg(\write,[filename],action);
|
||||
}
|
||||
|
||||
pr_sendMsg { |msg, args, action,parser|
|
||||
|
||||
OSCFunc(
|
||||
{ |msg|
|
||||
var result;
|
||||
// msg.postln;
|
||||
result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
|
||||
if(action.notNil){action.value(result)}{action.value};
|
||||
},'/'++msg).oneShot;
|
||||
|
||||
this.server.listSendMsg(['/u_cmd',this.synth.nodeID,this.synthIndex,msg].addAll(args));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
FluidKNN : UGen {
|
||||
|
||||
var <> synth, <> server;
|
||||
|
||||
*kr { |dims,k|
|
||||
^this.multiNew('control');
|
||||
}
|
||||
|
||||
*new{ |server,dims,k|
|
||||
var synth, instance;
|
||||
server = server ? Server.default;
|
||||
synth = {instance = FluidKNN.kr(dims,k)}.play(server);
|
||||
instance.server = server;
|
||||
instance.synth = synth;
|
||||
^instance
|
||||
}
|
||||
|
||||
index{|dataset, action|
|
||||
this.pr_sendMsg(\index,[dataset],action);
|
||||
}
|
||||
|
||||
classify{ |buffer, labelset, k, action|
|
||||
this.pr_sendMsg(\classify,[buffer.asUGenInput, labelset, k],action,k.collect{string(FluidMessageResponse,_,_)});
|
||||
}
|
||||
|
||||
regress { |buffer,dataset, k, action|
|
||||
this.pr_sendMsg(\regress,[buffer.asUGenInput, dataset,k],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
pr_sendMsg { |msg, args, action,parser|
|
||||
|
||||
OSCFunc(
|
||||
{ |msg|
|
||||
var result;
|
||||
// msg.postln;
|
||||
result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
|
||||
if(action.notNil){action.value(result)}{action.value};
|
||||
},'/'++msg).oneShot;
|
||||
|
||||
this.server.listSendMsg(['/u_cmd',this.synth.nodeID,this.synthIndex,msg].addAll(args));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
FluidLabelSet : UGen {
|
||||
|
||||
var <> synth, <> server;
|
||||
|
||||
*kr{ |name|
|
||||
^this.multiNew('control',name);
|
||||
}
|
||||
|
||||
*new{ |server, name|
|
||||
var synth, instance;
|
||||
server = server ? Server.default;
|
||||
synth = {instance = FluidLabelSet.kr(name)}.play(server);
|
||||
instance.server = server;
|
||||
instance.synth = synth;
|
||||
^instance
|
||||
}
|
||||
|
||||
*new1 { |rate, name|
|
||||
var ascii = name.ascii;
|
||||
^super.new1(*[rate, ascii.size].addAll(ascii));
|
||||
}
|
||||
|
||||
init { |size...chars|
|
||||
//Send the number of inputs (size of provider string) as specialIndex,
|
||||
//so server plugin knows what's going on
|
||||
specialIndex = -1;
|
||||
inputs = [size].addAll(chars);
|
||||
}
|
||||
|
||||
addPoint{|id, label, action|
|
||||
this.pr_sendMsg(\addPoint,[id, label],action);
|
||||
}
|
||||
|
||||
getPoint{|id, action|
|
||||
this.pr_sendMsg(\getPoint,[id],action);
|
||||
}
|
||||
|
||||
updatePoint{|id, label, action|
|
||||
this.pr_sendMsg(\updatePoint,[id, label],action);
|
||||
}
|
||||
|
||||
deletePoint{|id, action|
|
||||
this.pr_sendMsg(\deletePoint,[id],action);
|
||||
}
|
||||
|
||||
cols {|action|
|
||||
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
read{|filename,action|
|
||||
this.pr_sendMsg(\read,[filename],action);
|
||||
}
|
||||
|
||||
write{|filename,action|
|
||||
this.pr_sendMsg(\write,[filename],action);
|
||||
}
|
||||
|
||||
size { |action|
|
||||
this.pr_sendMsg(\size,[],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
clear { |action|
|
||||
this.pr_sendMsg(\clear,[],action);
|
||||
}
|
||||
|
||||
pr_sendMsg { |msg, args, action,parser|
|
||||
OSCFunc(
|
||||
{ |msg|
|
||||
var result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
|
||||
if(result.notNil){action.value(result)}{action.value};
|
||||
},'/'++msg
|
||||
).oneShot;
|
||||
|
||||
this.server.listSendMsg(['/u_cmd',this.synth.nodeID,this.synthIndex,msg].addAll(args));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
FluidNRTProcess : Object{
|
||||
var <server, <ugen, <action, <outputBuffers, <blocking, <synth;
|
||||
|
||||
*new {|server, ugen, action, outputBuffers, blocking = 0|
|
||||
^super.newCopyArgs(server, ugen, action, outputBuffers, blocking).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|
|
||||
|
||||
var c = Condition.new(false);
|
||||
|
||||
synth = {
|
||||
ugen.performList(\new1,\control, ugenArgs.collect{|a| a.asUGenInput} ++ Done.freeSelf ++ blocking);
|
||||
}.play(server);
|
||||
synth.postln;
|
||||
|
||||
OSCFunc({ |m|
|
||||
forkIfNeeded{
|
||||
outputBuffers.do{|buf|
|
||||
buf = server.cachedBufferAt(buf.asUGenInput);
|
||||
buf.updateInfo;
|
||||
};
|
||||
server.sync;
|
||||
if(action.notNil && m[2]==0){action.valueArray(outputBuffers)};
|
||||
c.test = true;
|
||||
c.signal;
|
||||
}
|
||||
},'/done',argTemplate:[synth.nodeID]).oneShot;
|
||||
|
||||
forkIfNeeded{
|
||||
c.wait;
|
||||
};
|
||||
^this;
|
||||
}
|
||||
|
||||
cancel{
|
||||
if(server.notNil && synth.notNil) {synth.free};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
FluidNormalize : UGen {
|
||||
|
||||
var <> synth, <> server;
|
||||
|
||||
*kr{ |min, max|
|
||||
^this.multiNew('control',min, max);
|
||||
}
|
||||
|
||||
*new{ |server, min, max|
|
||||
var synth, instance;
|
||||
server = server ? Server.default;
|
||||
synth = {instance = FluidNormalize.kr(min,max)}.play(server);
|
||||
instance.server = server;
|
||||
instance.synth = synth;
|
||||
^instance
|
||||
}
|
||||
|
||||
fit{|dataset, action|
|
||||
this.pr_sendMsg(\fit,[dataset],action);
|
||||
}
|
||||
|
||||
normalize{|sourceDataset, destDataset, action|
|
||||
this.pr_sendMsg(\normalize,[sourceDataset, destDataset],action);
|
||||
}
|
||||
|
||||
normalizePoint{|sourceBuffer, destBuffer, action|
|
||||
this.pr_sendMsg(\normalizePoint,[sourceBuffer, destBuffer],action);
|
||||
}
|
||||
|
||||
cols {|action|
|
||||
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
read{|filename,action|
|
||||
this.pr_sendMsg(\read,[filename],action);
|
||||
}
|
||||
|
||||
write{|filename,action|
|
||||
this.pr_sendMsg(\write,[filename],action);
|
||||
}
|
||||
|
||||
pr_sendMsg { |msg, args, action,parser|
|
||||
OSCFunc(
|
||||
{ |msg|
|
||||
var result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
|
||||
if(result.notNil){action.value(result)}{action.value};
|
||||
},'/'++msg
|
||||
).oneShot;
|
||||
|
||||
this.server.listSendMsg(['/u_cmd',this.synth.nodeID,this.synthIndex,msg].addAll(args));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
FluidStandardize : UGen {
|
||||
|
||||
var <> synth, <> server;
|
||||
|
||||
*kr{
|
||||
^this.multiNew('control');
|
||||
}
|
||||
|
||||
*new{ |server|
|
||||
var synth, instance;
|
||||
server = server ? Server.default;
|
||||
synth = {instance = FluidStandardize.kr}.play(server);
|
||||
instance.server = server;
|
||||
instance.synth = synth;
|
||||
^instance
|
||||
}
|
||||
|
||||
fit{|dataset, action|
|
||||
this.pr_sendMsg(\fit,[dataset],action);
|
||||
}
|
||||
|
||||
standardize{|sourceDataset, destDataset, action|
|
||||
this.pr_sendMsg(\standardize,[sourceDataset, destDataset],action);
|
||||
}
|
||||
|
||||
standardizePoint{|sourceBuffer, destBuffer, action|
|
||||
this.pr_sendMsg(\standardizePoint,[sourceBuffer, destBuffer],action);
|
||||
}
|
||||
|
||||
cols {|action|
|
||||
this.pr_sendMsg(\cols,[],action,[numbers(FluidMessageResponse,_,1,_)]);
|
||||
}
|
||||
|
||||
read{|filename,action|
|
||||
this.pr_sendMsg(\read,[filename],action);
|
||||
}
|
||||
|
||||
write{|filename,action|
|
||||
this.pr_sendMsg(\write,[filename],action);
|
||||
}
|
||||
|
||||
pr_sendMsg { |msg, args, action,parser|
|
||||
OSCFunc(
|
||||
{ |msg|
|
||||
var result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
|
||||
if(result.notNil){action.value(result)}{action.value};
|
||||
},'/'++msg
|
||||
).oneShot;
|
||||
|
||||
this.server.listSendMsg(['/u_cmd',this.synth.nodeID,this.synthIndex,msg].addAll(args));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue