nix
Gerard 5 years ago
parent de8e5110f3
commit 04f0db5267

@ -307,7 +307,7 @@ public:
auto& client = mWrapper->client(); auto& client = mWrapper->client();
auto& params = mWrapper->params(); auto& params = mWrapper->params();
const Unit* unit = this; const Unit* unit = this;
bool trig = IsModel_t<Client>::value ? mPrevTrig && in0(0) > 0 : false; bool trig = IsModel_t<Client>::value ? !mPrevTrig && in0(0) > 0 : false;
bool shouldProcess = IsModel_t<Client>::value ? trig : true; bool shouldProcess = IsModel_t<Client>::value ? trig : true;
mPrevTrig = trig; mPrevTrig = trig;
@ -318,7 +318,7 @@ public:
Wrapper::setParams(mWrapper, Wrapper::setParams(mWrapper,
params, mWrapper->mControlsIterator); // forward on inputs N + audio inputs as params params, mWrapper->mControlsIterator); // forward on inputs N + audio inputs as params
params.constrainParameterValues(); params.constrainParameterValues();
}
for (index i = 0; i < client.audioChannelsIn(); ++i) for (index i = 0; i < client.audioChannelsIn(); ++i)
{ {
if (mInputConnections[asUnsigned(i)]) if (mInputConnections[asUnsigned(i)])
@ -337,7 +337,7 @@ public:
mOutputs[asUnsigned(i)].reset(out(static_cast<int>(i)), 0, 1); mOutputs[asUnsigned(i)].reset(out(static_cast<int>(i)), 0, 1);
} }
client.process(mAudioInputs, mOutputs, mContext); client.process(mAudioInputs, mOutputs, mContext);
} // }
} }
private: private:
std::vector<bool> mInputConnections; std::vector<bool> mInputConnections;
@ -594,7 +594,7 @@ public:
return true; return true;
} }
static void destroy(World* world, void* data) static void destroy(World* /*world*/, void* data)
{ {
if(!data) return; if(!data) return;
auto& s = *static_cast<SharedState<Client>*>(data); auto& s = *static_cast<SharedState<Client>*>(data);
@ -995,17 +995,17 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
return std::string(recv ? recv : ""); return std::string(recv ? recv : "");
} }
static auto fromArgs(Unit* x, FloatControlsIter& args, std::string, int) static auto fromArgs(Unit* /*x*/, FloatControlsIter& args, std::string, int)
{ {
// first is string size, then chars // first is string size, then chars
index size = static_cast<index>(args.next()); index size = static_cast<index>(args.next());
auto ft = FluidSCWrapper::getInterfaceTable(); // auto ft = FluidSCWrapper::getInterfaceTable();
auto w = x->mWorld; // auto w = x->mWorld;
// char* chunk = // char* chunk =
// static_cast<char*>(ft->fRTAlloc(w, asUnsigned(size + 1))); // static_cast<char*>(ft->fRTAlloc(w, asUnsigned(size + 1)));
std::string res; std::string res;
res.resize(size); res.resize(asUnsigned(size));
// if (!chunk) // if (!chunk)
// { // {
@ -1015,7 +1015,7 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
// } // }
for (index i = 0; i < size; ++i) for (index i = 0; i < size; ++i)
res[i] = static_cast<char>(args.next()); res[asUnsigned(i)] = static_cast<char>(args.next());
// res[size] = 0; // terminate string // res[size] = 0; // terminate string
// auto res = std::string{chunk}; // auto res = std::string{chunk};
@ -1415,7 +1415,7 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
return true; return true;
}, },
nullptr, // NRT Thread: No-op nullptr, // NRT Thread: No-op
[](World* w, void* data) // RT thread: clean up [](World* /*w*/, void* data) // RT thread: clean up
{ {
MessageData* m = static_cast<MessageData*>(data); MessageData* m = static_cast<MessageData*>(data);
// m->~MessageData(); // m->~MessageData();
@ -1451,7 +1451,7 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
// float* values = static_cast<float*>( // float* values = static_cast<float*>(
// ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float))); // ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float)));
float* values = new float[numArgs]; float* values = new float[asUnsigned(numArgs)];
// copy return data // copy return data
ToFloatArray::convert(values, static_cast<T>(result)); ToFloatArray::convert(values, static_cast<T>(result));
@ -1492,7 +1492,7 @@ class FluidSCWrapper : public impl::FluidSCWrapperBase<C>
// float* values = static_cast<float*>( // float* values = static_cast<float*>(
// ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float))); // ft->fRTAlloc(x->mNode->mWorld, asUnsigned(numArgs) * sizeof(float)));
float* values = new float[numArgs]; float* values = new float[asUnsigned(numArgs)];
ToFloatArray::convert(values, std::tuple<Ts...>(result), offsets, ToFloatArray::convert(values, std::tuple<Ts...>(result), offsets,
std::index_sequence_for<Ts...>()); std::index_sequence_for<Ts...>());

@ -48,15 +48,18 @@ FluidDataSet : FluidManipulationClient {
} }
addPoint{|label, buffer, action| addPoint{|label, buffer, action|
this.prSendMsg(\addPoint,[label.asSymbol,buffer.asUGenInput],action); buffer = this.prEncodeBuffer(buffer);
this.prSendMsg(\addPoint,[label.asSymbol,buffer],action);
} }
getPoint{|label, buffer, action| getPoint{|label, buffer, action|
this.prSendMsg(\getPoint,[label.asSymbol,buffer.asUGenInput],action); buffer = this.prEncodeBuffer(buffer);
this.prSendMsg(\getPoint,[label.asSymbol,buffer],action,outputBuffers:[buffer]);
} }
updatePoint{|label, buffer, action| updatePoint{|label, buffer, action|
this.prSendMsg(\updatePoint,[label.asSymbol,buffer.asUGenInput],action); buffer = this.prEncodeBuffer(buffer);
this.prSendMsg(\updatePoint,[label.asSymbol,buffer],action,outputBuffers:[buffer]);
} }
deletePoint{|label, action| deletePoint{|label, action|

@ -26,9 +26,10 @@ FluidKMeans : FluidRTDataClient {
} }
predictPoint { |buffer, action| predictPoint { |buffer, action|
buffer = this.prEncodeBuffer(buffer);
this.prSendMsg(\predictPoint, this.prSendMsg(\predictPoint,
[buffer.asUGenInput], action, [buffer], action,
[number(FluidMessageResponse,_,_)] [number(FluidMessageResponse,_,_)],outputBuffers:[buffer]
); );
} }
} }

@ -15,9 +15,10 @@ FluidKNNClassifier : FluidRTDataClient {
} }
predictPoint {|buffer, action| predictPoint {|buffer, action|
buffer = this.prEncodeBuffer(buffer);
this.prSendMsg(\predictPoint, this.prSendMsg(\predictPoint,
[buffer.asUGenInput], action, [buffer.asUGenInput], action,
[string(FluidMessageResponse,_,_)] [string(FluidMessageResponse,_,_)],outputBuffers:[buffer]
); );
} }
} }

@ -18,7 +18,8 @@ FluidKNNRegressor : FluidRTDataClient {
} }
predictPoint { |buffer, action| predictPoint { |buffer, action|
this.prSendMsg(\predictPoint, [buffer.asUGenInput], action, buffer = this.prEncodeBuffer(buffer);
[number(FluidMessageResponse,_,_)]); this.prSendMsg(\predictPoint, [buffer], action,
[number(FluidMessageResponse,_,_)],outputBuffers:[buffer]);
} }
} }

@ -44,8 +44,10 @@ FluidMLPRegressor : FluidRTDataClient {
} }
predictPoint { |sourceBuffer, targetBuffer, action| predictPoint { |sourceBuffer, targetBuffer, action|
sourceBuffer = this.prEncodeBuffer(sourceBuffer);
targetBuffer = this.prEncodeBuffer(targetBuffer);
this.prSendMsg(\predictPoint, this.prSendMsg(\predictPoint,
[sourceBuffer.asUGenInput, targetBuffer.asUGenInput], action); [sourceBuffer.asUGenInput, targetBuffer.asUGenInput], action,outputBuffers:[targetBuffer]);
} }
} }
@ -94,7 +96,8 @@ FluidMLPClassifier : FluidRTDataClient {
} }
predictPoint { |sourceBuffer, action| predictPoint { |sourceBuffer, action|
sourceBuffer = this.prEncodeBuffer(sourceBuffer);
this.prSendMsg(\predictPoint, this.prSendMsg(\predictPoint,
[sourceBuffer.asUGenInput], action, string(FluidMessageResponse,_,_)); [sourceBuffer], action, string(FluidMessageResponse,_,_));
} }
} }

@ -116,7 +116,9 @@ FluidManipulationClient {
this.prSendMsg(\size,[],action,[numbers(FluidMessageResponse,_,1,_)]); this.prSendMsg(\size,[],action,[numbers(FluidMessageResponse,_,1,_)]);
} }
prSendMsg { |msg, args, action,parser| prEncodeBuffer { |buf| buf !? {^buf.asUGenInput} ?? {^-1} }
prSendMsg { |msg, args, action,parser,outputBuffers|
if(this.server.serverRunning.not,{(this.asString + " server not running").error; ^nil}); if(this.server.serverRunning.not,{(this.asString + " server not running").error; ^nil});
forkIfNeeded{ forkIfNeeded{
synth ?? {onSynthFree.value; server.sync}; synth ?? {onSynthFree.value; server.sync};
@ -125,7 +127,16 @@ FluidManipulationClient {
defer{ defer{
var result; var result;
result = FluidMessageResponse.collectArgs(parser,msg.drop(3)); result = FluidMessageResponse.collectArgs(parser,msg.drop(3));
if(action.notNil){action.value(result)}{action.value}; if(outputBuffers.notNil) {
forkIfNeeded {
outputBuffers.collectInPlace{ |b|
server.cachedBufferAt(b) !? {|x| x.updateInfo}
};
server.sync;
if(action.notNil){action.value(*(outputBuffers++result))}{action.value};
};
}
{if(action.notNil){action.value(result)}{action.value};}
} }
},'/'++msg, server.addr, nil,[synth.nodeID]).oneShot; },'/'++msg, server.addr, nil,[synth.nodeID]).oneShot;
server.listSendMsg(['/u_cmd', synth.nodeID, ugen.synthIndex, msg].addAll(args)); server.listSendMsg(['/u_cmd', synth.nodeID, ugen.synthIndex, msg].addAll(args));

@ -21,8 +21,11 @@ FluidNormalize : FluidRTDataClient {
} }
transformPoint{|sourceBuffer, destBuffer, action| transformPoint{|sourceBuffer, destBuffer, action|
sourceBuffer = this.prEncodeBuffer(sourceBuffer);
destBuffer = this.prEncodeBuffer(destBuffer);
this.prSendMsg(\transformPoint, this.prSendMsg(\transformPoint,
[sourceBuffer.asUGenInput, destBuffer.asUGenInput], action [sourceBuffer, destBuffer], action,
outputBuffers:[destBuffer]
); );
} }
} }

@ -17,6 +17,8 @@ FluidPCA : FluidRTDataClient {
} }
transformPoint{|sourceBuffer, destBuffer, action| transformPoint{|sourceBuffer, destBuffer, action|
this.prSendMsg(\transformPoint,[sourceBuffer.asUGenInput, destBuffer.asUGenInput], action); sourceBuffer = this.prEncodeBuffer(sourceBuffer);
destBuffer = this.prEncodeBuffer(destBuffer);
this.prSendMsg(\transformPoint,[sourceBuffer, destBuffer], action, outputBuffers:[destBuffer]);
} }
} }

@ -20,8 +20,10 @@ FluidStandardize : FluidRTDataClient {
} }
transformPoint{|sourceBuffer, destBuffer, action| transformPoint{|sourceBuffer, destBuffer, action|
sourceBuffer = this.prEncodeBuffer(sourceBuffer);
destBuffer = this.prEncodeBuffer(destBuffer);
this.prSendMsg(\transformPoint, this.prSendMsg(\transformPoint,
[sourceBuffer.asUGenInput, destBuffer.asUGenInput], action [sourceBuffer, destBuffer], action, outputBuffers:[destBuffer]
); );
} }
} }

@ -186,8 +186,7 @@ code::
//pitching //pitching
{ {
var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir / 2)); var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir / 2));
var step = Stepper.kr(trig,max:3); var point = 2.collect{ TIRand.kr(0,3,trig).linlin(0,3,-1,1) };
var point = TRand.kr(-0.1, [0.1, 0.1], trig) + [step.mod(2).linlin(0,1,-0.6,0.6),step.div(2).linlin(0,1,-0.6,0.6)] ;
point.collect{|p,i| BufWr.kr([p],~inpPoint,i)}; point.collect{|p,i| BufWr.kr([p],~inpPoint,i)};
Out.kr(~ib.index,[trig]); Out.kr(~ib.index,[trig]);
T2A.ar(trig)*0.1; T2A.ar(trig)*0.1;

@ -182,8 +182,7 @@ code::
//pitching //pitching
{ {
var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir /2).poll); var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir /2).poll);
var step = Stepper.kr(trig,max:3); var point = 2.collect{TIRand.kr(0,3,trig).linlin(0,3,-1,1)};
var point = TRand.kr(-0.1, [0.1, 0.1], trig) + [step.mod(2).linlin(0,1,-0.6,0.6),step.div(2).linlin(0,1,-0.6,0.6)] ;
point.collect{|p,i| BufWr.kr([p],~inpPoint,i)}; point.collect{|p,i| BufWr.kr([p],~inpPoint,i)};
Out.kr(~ib.index,[trig]); Out.kr(~ib.index,[trig]);
T2A.ar(trig)*0.1; T2A.ar(trig)*0.1;

@ -192,8 +192,7 @@ code::
//pitching //pitching
{ {
var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir /2).poll); var trig = Impulse.kr(MouseX.kr(0,1).exprange(0.5,ControlRate.ir /2).poll);
var step = Stepper.kr(trig,max:3); var point = 2.collect{TIRand.kr(0,3,trig).linlin(0,3,-1,1)};
var point = TRand.kr(-0.1, [0.1, 0.1], trig) + [step.mod(2).linlin(0,1,-0.6,0.6),step.div(2).linlin(0,1,-0.6,0.6)] ;
point.collect{|p,i| BufWr.kr([p],~inpPoint,i)}; point.collect{|p,i| BufWr.kr([p],~inpPoint,i)};
Out.kr(~ib.index,[trig]); Out.kr(~ib.index,[trig]);
T2A.ar(trig)*0.1; T2A.ar(trig)*0.1;

Loading…
Cancel
Save