So re: Flucoma how to save and load a fitted kdtree, I noticed point: Buffer
was getting copied into ~results: Array
, incorrectly, but there were correct results returned by knearest, which meant knearest was acting asynchronously. In fact, if the knearest wasn’t wrapped into a task or a new buffer, point: Buffer
, wasn’t allocated per ~points: ( normed 2-features from hit detected audio )
, the ~results would be filled with entries that were the same
4 nearest neighbours, and once the kdtree could read the correct coordinates from the buffer, another stream of same results.
The question is, how do i get this to work sequentially, such that I don’t need to fork one task per point, and use xpoint: Buffer
instead of allocating a buffer per point like point: Buffer
. I assume that using a FluidDataSet and adding columns and entries there somehow is able to queue up these requests, but is there a supercollider centric manner of doing this? There’s probably other projects that use long running processes that require some kind of synchronization as well, how would they do it?
var xpoint=Buffer.alloc(s,2);
~results=[];
~points.do({
|py i|
var point=Buffer.alloc(s,2);
var tt=Task({
1.do({
point.setn(0,[py[0],py[1]]);
~tree.kNearest(point,4,{
arg nearest;
~results=~results.add([py[0],py[1],nearest]);
});
});
});
tt.start();
});