Closed dmeliza closed 8 months ago
One fairly simple solution for the period boundary problem is to use a ringbuffer that's at least two periods long. There's the "front" part corresponding to the current period, and a "back" part corresponding to the subsequent one. In each cycle of the process function, the back part is zeroed, and then any pulses that start in the current period are written to the combined front/back buffer. Then we copy the front part to the output buffer and advance the read and write pointers.
The click is currently a single sample, which may not be long enough to detect downstream. Letting it be more than one sample long introduces some complexity, though, as the click may span periods.