flucoma / flucoma-sc

Fluid Corpus Manipulation plugins for Supercollider
BSD 3-Clause "New" or "Revised" License
70 stars 16 forks source link

KDTree KR supports the same behaviour than the NRT query #156

Closed tremblap closed 1 year ago

tremblap commented 1 year ago

This gives the RT querying (kr) the same behaviour than the NRT, when radius=0 returns all up to k, and k=0 returns all in radius.

the size of the output buffer is a hard cap on the number of points returned.

the KR out is the number of valid points in the buffer.

test code:

a = Dictionary.newFrom([\cols, 3, \data, Dictionary.newFrom(4.collect{|i|[i.asSymbol, i.dup(3)]}.flatten)])

d = FluidDataSet(s)
d.load(a)
d.print

b = Buffer.alloc(s,6)
c = Buffer.alloc(s,3)

k = FluidKDTree(s)
k.fit(d)

x= {arg nb = 1, radius = 0; var poke = Impulse.kr(1); k.kr(poke,c,b,nb,radius).poll(poke); FluidBufToKr.kr(b).poll(poke); Silent.ar();}.play

c.sendCollection(1.5.dup(3)) //try on the spot, and without. fun

x.set(\nb, 0)
x.set(\radius, 0.01)