Hello,
I’ve noticed that when using “getPoint” or “getLabel” in some sort of loop (in order to get multiple responses) I need to insert an “s.sync” in order to get an accurate response. I have also since noticed it in the FluidDataSet help file. This feels a little clunky and certainly is slow.
Would it be possible to create a “getn” kind of behavior where I could pass an array of ids and then get an array of responses out of one call to the server? This could be a “flattened” array that I would then have to clump into it’s appropriate multidimensional form, but could also be a multidimensional array.
This seems like perhaps a lower priority as I don’t have a specific implementation concern in mind, but does seem like an extension of what the tool does–and I found it confusing that I would need to insert the “s.sync”, it seemed un idiomatic for SC. The “getn” would feel idiomatic.
Thank you!
s.boot;
~n_dims = 3;
// make empty dataset
~dataset = FluidDataSet(s,\kmeans_test,~n_dims);
// fill up the dataset
(
100.do({
arg i;
Buffer.loadCollection(s,Array.fill(~n_dims,{rrand(0.0,1.0)}),1,{
arg buf;
~dataset.addPoint(i.asSymbol,buf);
});
});
)
(
// this doesn't work, return all zeros
100.do({
arg i;
Buffer.alloc(s,~n_dims,1,{
arg buf;
~dataset.getPoint(i.asSymbol,buf,{
buf.getn(0,3,{
arg points;
"%:\t%\t%\t%".format(i,points[0],points[1],points[2]).postln;
});
});
});
});
)
(
// this does work. i have to let the server sync so that the osc flying back and forth doesnt get messed up?
Task({
100.do({
arg i;
var buf = Buffer.alloc(s,~n_dims);
// =========================================================================
// ============= this is the change from what is above =====================
s.sync;
// =========================================================================
// =========================================================================
~dataset.getPoint(i.asSymbol,buf,{
buf.getn(0,3,{
arg points;
//points.postln;
"%:\t%\t%\t%".format(i,points[0],points[1],points[2]).postln;
});
});
});
}).play;
)