TB2 classes: Reduce boiler plate
parent
7aea07c621
commit
c742f4d14e
@ -1,42 +1,19 @@
|
|||||||
FluidKNN : UGen {
|
FluidKNN : FluidManipulationClient {
|
||||||
|
|
||||||
var <> synth, <> server;
|
|
||||||
|
|
||||||
*kr { |dims,k|
|
*kr { |dims,k|
|
||||||
^this.multiNew('control');
|
^this.multiNew('control', dims, k, Done.none, super.nonBlocking);
|
||||||
}
|
|
||||||
|
|
||||||
*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|
|
index{|dataset, action|
|
||||||
this.pr_sendMsg(\index,[dataset],action);
|
this.pr_sendMsg(\index,[dataset.asUGenInput],action);
|
||||||
}
|
}
|
||||||
|
|
||||||
classify{ |buffer, labelset, k, action|
|
classify{ |buffer, labelset, k, action|
|
||||||
this.pr_sendMsg(\classify,[buffer.asUGenInput, labelset, k],action,k.collect{string(FluidMessageResponse,_,_)});
|
this.pr_sendMsg(\classify,[buffer.asUGenInput, labelset.asUGenInput, k],action,k.collect{string(FluidMessageResponse,_,_)});
|
||||||
}
|
}
|
||||||
|
|
||||||
regress { |buffer,dataset, k, action|
|
regress { |buffer,dataset, k, action|
|
||||||
this.pr_sendMsg(\regress,[buffer.asUGenInput, dataset,k],action,[numbers(FluidMessageResponse,_,1,_)]);
|
this.pr_sendMsg(\regress,[buffer.asUGenInput, dataset.asUGenInput,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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue