Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtime-warp SC support #168

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions release-packaging/Classes/FluidDTW.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FluidDTW : FluidModelObject {

var <>constraint, <>constraintParam;

*new {|server, constraint = 0, constraintParam = 0|
^super.new(server,[constraint, constraintParam])
.constraint_(constraint)
.constraintParam_(constraintParam);
}

prGetParams{^[this.id,this.constraint,this.constraintParam];}

costMsg{|dataSeries, id1, id2|
^this.prMakeMsg(\cost, this.id, dataSeries.id, id1.asSymbol, id2.asSymbol)
}

cost{|dataSeries, id1, id2, action|
actions[\cost] = [string(FluidMessageResponse,_,_),action];
this.prSendMsg(this.costMsg(dataSeries, id1.asSymbol, id2.asSymbol));
}

bufCostMsg{|buffer1, buffer2|
^this.prMakeMsg(\bufCost, this.id,
this.prEncodeBuffer(buffer1),
this.prEncodeBuffer(buffer2));
}

bufCost{|buffer1, buffer2, action|
actions[\bufCost] = [string(FluidMessageResponse,_,_),action];
this.prSendMsg(this.bufCostMsg(buffer1,buffer2));
}
}
63 changes: 63 additions & 0 deletions release-packaging/Classes/FluidDTWClassifier.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FluidDTWClassifier : FluidModelObject {

var <>numNeighbours, <>constraint, <>constraintParam;

*new {|server, numNeighbours = 3, constraint = 0, constraintParam = 0|
^super.new(server,[numNeighbours, constraint, constraintParam])
.numNeighbours_(numNeighbours)
.constraint_(constraint)
.constraintParam_(constraintParam);
}

prGetParams{^[this.id,this.numNeighbours,this.constraint,this.constraintParam];}

fitMsg{|dataSeries, labelSet|
^this.prMakeMsg(\fit, id, dataSeries.id, labelSet.id)
}

fit{|dataSeries, labelSet, action|
actions[\fit] = [nil,action];
this.prSendMsg(this.fitMsg(dataSeries, labelSet));
}

predictMsg{|dataSeries, labelSet|
^this.prMakeMsg(\predict, id, dataSeries.id, labelSet.id)
}

predict{|dataSeries, labelSet, action|
actions[\predict] = [nil, action];
this.prSendMsg(this.predictMsg(dataSeries, labelSet));
}

predictSeriesMsg{|buffer|
^this.prMakeMsg(\predictSeries, id, this.prEncodeBuffer(buffer))
}

predictSeries {|buffer, action|
actions[\predictSeries] = [string(FluidMessageResponse,_,_),action];
this.prSendMsg(this.predictSeriesMsg(buffer));
}

// kr{|trig, inputBuffer,outputBuffer|
// ^FluidDTWClassifierQuery.kr(trig,
// this, this.numNeighbours,
// this.prEncodeBuffer(inputBuffer),
// this.prEncodeBuffer(outputBuffer));
// }

}

// FluidDTWClassifierQuery : FluidRTMultiOutUGen {
//
// *kr{ |trig, model,numNeighbours = 3,inputBuffer, outputBuffer |
// ^this.multiNew('control',trig, model.asUGenInput,
// numNeighbours,
// inputBuffer.asUGenInput, outputBuffer.asUGenInput)
// }
//
// init { arg ... theInputs;
// inputs = theInputs;
// ^this.initOutputs(1, rate);
// }
// }

65 changes: 65 additions & 0 deletions release-packaging/Classes/FluidDTWRegressor.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FluidDTWRegressor : FluidModelObject {

var <>numNeighbours, <>constraint, <>constraintParam;

*new {|server, numNeighbours = 3, constraint = 0, constraintParam = 0|
^super.new(server,[numNeighbours, constraint, constraintParam])
.numNeighbours_(numNeighbours)
.constraint_(constraint)
.constraintParam_(constraintParam);
}

prGetParams{^[this.id,this.numNeighbours,this.constraint,this.constraintParam];}

fitMsg{|dataSeries, dataSet|
^this.prMakeMsg(\fit,this.id,dataSeries.id,dataSet.id)
}

fit{|dataSeries, dataSet, action|
actions[\fit] = [nil,action];
this.prSendMsg(this.fitMsg(dataSeries, dataSet));
}

predictMsg{ |dataSeries, dataSet|
^this.prMakeMsg(\predict,this.id,dataSeries.id,dataSet.id)
}

predict{ |dataSeries, dataSet, action|
actions[\predict] = [nil, action];
this.prSendMsg(this.predictMsg(dataSeries, dataSet));
}

predictSeriesMsg { |sourceBuffer, targetBuffer|
^this.prMakeMsg(\predictSeries,id,
this.prEncodeBuffer(sourceBuffer),
this.prEncodeBuffer(targetBuffer),
["/b_query", targetBuffer.asUGenInput]);
}

predictSeries { |sourceBuffer, targetBuffer, action|
actions[\predictSeries] = [nil,{action.value(targetBuffer)}];
this.predictSeriesMsg(sourceBuffer, targetBuffer);
this.prSendMsg(this.predictSeriesMsg(sourceBuffer, targetBuffer));
}

// kr{|trig, inputBuffer, outputBuffer, numNeighbours|
// ^FluidKNNRegressorQuery.kr(K2A.ar(trig),
// this, numNeighbours??{this.numNeighbours},
// this.prEncodeBuffer(inputBuffer),
// this.prEncodeBuffer(outputBuffer));
// }
}

// FluidDTWRegressorQuery : FluidRTMultiOutUGen {
//
// *kr{ |trig, model,numNeighbours = 3,inputBuffer, outputBuffer |
// ^this.multiNew('control',trig, model.asUGenInput,
// numNeighbours,
// inputBuffer.asUGenInput, outputBuffer.asUGenInput)
// }
//
// init { arg ... theInputs;
// inputs = theInputs;
// ^this.initOutputs(1, rate);
// }
// }
158 changes: 158 additions & 0 deletions release-packaging/Classes/FluidDataSeries.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@

FluidDataSeries : FluidDataObject
{
*new{|server| ^super.new(server) }

addSeriesMsg{|identifier,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\addSeries,id,identifier.asSymbol,buffer);
}

addSeries{|identifier, buffer, action|
actions[\addSeries] = [nil,action];
this.prSendMsg(this.addSeriesMsg(identifier,buffer));
}

getSeriesMsg{|identifier,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\getSeries,id,identifier.asSymbol,buffer,["/b_query",buffer.asUGenInput]);
}

getSeries{|identifier, buffer, action|
actions[\getSeries] = [nil,action];
this.prSendMsg(this.getSeriesMsg(identifier,buffer));
}

updateSeriesMsg{|identifier,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\updateSeries,id,identifier.asSymbol,buffer,["/b_query",buffer.asUGenInput]);
}

updateSeries{|identifier, buffer, action|
actions[\updateSeries] = [nil,action];
this.prSendMsg(this.updateSeriesMsg(identifier,buffer));
}

setSeriesMsg{|identifier,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\setSeries,id,identifier.asSymbol,buffer,["/b_query",buffer.asUGenInput]);
}

setSeries{|identifier, buffer, action|
actions[\setSeries] = [nil,action];
this.prSendMsg(this.setSeriesMsg(identifier,buffer));
}

deleteSeriesMsg{|identifier| ^this.prMakeMsg(\deleteSeries,id,identifier.asSymbol);}

deleteSeries{|identifier, action|
actions[\deleteSeries] = [nil,action];
this.prSendMsg(this.deleteSeriesMsg(identifier));
}

addFrameMsg{|identifier,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\addFrame,id,identifier.asSymbol,buffer);
}

addFrame{|identifier, buffer, action|
actions[\addFrame] = [nil,action];
this.prSendMsg(this.addFrameMsg(identifier,buffer));
}

getFrameMsg{|identifier,time,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\getFrame,id,identifier.asSymbol,time.asInteger,buffer,["/b_query",buffer.asUGenInput]);
}

getFrame{|identifier, time, buffer, action|
actions[\getFrame] = [nil,action];
this.prSendMsg(this.getFrameMsg(identifier,time,buffer));
}

updateFrameMsg{|identifier,time,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\updateFrame,id,identifier.asSymbol,time.asInteger,buffer,["/b_query",buffer.asUGenInput]);
}

updateFrame{|identifier, time, buffer, action|
actions[\updateFrame] = [nil,action];
this.prSendMsg(this.updateFrameMsg(identifier,time,buffer));
}

setFrameMsg{|identifier,time,buffer|
buffer = this.prEncodeBuffer(buffer);
^this.prMakeMsg(\setFrame,id,identifier.asSymbol,time.asInteger,buffer,["/b_query",buffer.asUGenInput]);
}

setFrame{|identifier, time, buffer, action|
actions[\setFrame] = [nil,action];
this.prSendMsg(this.setFrameMsg(identifier,time,buffer));
}

deleteFrameMsg{|identifier,time| ^this.prMakeMsg(\deleteFrame,id,identifier.asSymbol,time.asInteger);}

deleteFrame{|identifier, time, action|
actions[\deleteFrame] = [nil,action];
this.prSendMsg(this.deleteFrameMsg(identifier,time));
}

clearMsg { ^this.prMakeMsg(\clear,id); }

clear { |action|
actions[\clear] = [nil,action];
this.prSendMsg(this.clearMsg);
}

mergeMsg{|sourceDataSeries, overwrite = 0|
^this.prMakeMsg(\merge,id,sourceDataSeries.asUGenInput,overwrite);
}

merge{|sourceDataSeries, overwrite = 0, action|
actions[\merge] = [nil,action];
this.prSendMsg(this.mergeMsg(sourceDataSeries,overwrite));
}

printMsg { ^this.prMakeMsg(\print,id); }

print { |action=(postResponse)|
actions[\print] = [string(FluidMessageResponse,_,_),action];
this.prSendMsg(this.printMsg);
}

getIdsMsg{|labelSet|
^this.prMakeMsg(\getIds, id, labelSet.asUGenInput);
}

getIds{|labelSet, action|
actions[\getIds] = [nil,action];
this.prSendMsg(this.getIdsMsg(labelSet));
}

getDataSetMsg{|time, destDataSet|
^this.prMakeMsg(\getDataSet, id, time, destDataSet.asUGenInput);
}

getDataSet{|time, destDataSet, action|
actions[\getDataSet] = [nil,action];
this.prSendMsg(this.getDataSetMsg(time, destDataSet));
}

kNearestMsg{|buffer,k|
^this.prMakeMsg(\kNearest,id, this.prEncodeBuffer(buffer),k);
}

kNearest{ |buffer, k, action|
actions[\kNearest] = [strings(FluidMessageResponse,_,_),action];
this.prSendMsg(this.kNearestMsg(buffer,k));
}

kNearestDistMsg{|buffer,k|
^this.prMakeMsg(\kNearestDist,id, this.prEncodeBuffer(buffer),k);
}

kNearestDist{ |buffer, k, action|
actions[\kNearestDist] = [strings(FluidMessageResponse,_,_),action];
this.prSendMsg(this.kNearestDistMsg(buffer,k));
}
}