I would like to write a signal into an array (tabwrite~) and I want to know at all times exactly which sample index is being written.
In SC I would do this with:
var phase = Phasor.ar(0, 1, 0, BufFrames.kr(bufnum));
var signal = ... something...;
BufWr.ar(signal, bufnum, phase);
In Pure Data.... [tabwrite~] takes no phase inlet. Nor does it provide a phase outlet.
I could do a sample-by-sample integrator with [rpole~ 1] but then... how to reset it exactly at the end of the array? I could just let it integrate for a few minutes, but without resetting, it will hit the limits of floating point precision after 6 minutes or so. So it needs to be reset.
[phasor~ (1 / array duration in seconds)] --> [*~ array frames] gives fractional sample indices, which of course does not accurately reflect sample-by-sample integration of DC = 1 -- therefore rounding error will eventually kill this approach.
Is there an external to do this?
My intention was to make a demo of recording into a circular buffer and catching event onsets with bonk~, saving the sample indices into a list to use with a buffer player. This presumes accurate knowledge of the buffer position being written to at any moment. That's the rationale for the question.
hjh