'real-time' onset detection example

Ok now that I’m wrestling with pd, some old demons are coming back.

In looking at (presumably) @tremblap’s JIT-NMF example in the pd examples, there’s a del 2 in there, that makes me a bit uneasy:

I presume this is there to time-align the analysis window of 128 samples further down the patch, but using 2ms instead of 2.90249 (128 samps @ 44.1k) to allow for some snapshot~ “slop” in pd land.

Since snapshot~ doesn’t have an offset inlet in pd is there any way to ensure that the sample taken is always the correct one?

I’ve basically coded this up in pd and don’t notice any discrepancy between them, but since I’m not using change~ anymore, I don’t know if @a.harker’s test example is still valid:

If this isn’t valid, would it be a matter of adding an additional offset to the delay time of vectorsize - 1 to try and “align” it?

edit:

not seen this before on the forum!:
Screenshot 2022-12-21 at 6.37.41 pm