[coll], or list, or tables? Maintaining a list of onset timepoints into a circular buffer
I'm using a circular buffer to record live audio ([buffer~], [count~], [poke~]).
When [bonk~] detects an onset, I'm grabbing the current write head position and I'd like to store it in some sort of collection.
Because it's a circular buffer, time points saved in the collection will "age out" when the write head wraps back around to the same position.
I had thought to use [coll] but the catch is -- AFAICS, you can search for a specific data key that you know to be in the collection, but if, for instance, you want to match the smallest existing data key that is >= a value that may or may not exist in the collection, I don't see a method to do that. Does [coll] do that?
Or would it be better to use a list, or a couple of arrays, and accept that I'd just have to O(n) iterate over the entire list for every pruning operation?
Just curious what's the best way.
hjh
i would say it depends on point precision.
if you would use integer ms values, you could wipe
coll indexes older then current record position.
assuming you use position as index.
if you would use integer ms value, you could wipe
coll indexes older then current record position.
Integer ms values are fine.
I was going to poll the write head position periodically, say, every 500 ms, and erase all entries where writehead < entry index <= writehead+500 (to avoid wiping out new entries added in the last 500 ms).
But I suppose I could continually increment these integers instead of wrapping (2^31 ms is about 2 million seconds! more than enough) but... is there a [coll] method that would remove indices < some x? I don't see such a method in the reference. Everything in [coll] seems to depend on an exact match.
Anyway rolling my own iteration would be OK, just wondering if [coll] or a different object has some magic.
hjh
you can run clocker together with count or other sampling signal
and remove coll indexes.
At same time you grab current clock time when onset gets detected
and place it into coll.
little gap between read/write time is all it needs.
Getting answers about what to do outside of coll, but nothing about [coll] methods.
OK. So I decided to use a [table] instead.
hjh
I don't actually understand what do you want to do with that onset
detected positions in a looping buffer which gets overwritten on each loop iteration.
and also not what problem with coll you have