continually write to and read from a buffer~
![](https://music.arts.uci.edu/dobrian/maxcookbook/sites/default/files/styles/adaptive/adaptive-image/public/tenseconds.png?itok=8FWBaE5Q)
This example shows how to create a buffer~ that always contains the last ten seconds of audio coming out of and adc~. (It assumes that the sampling rate is 44,100 Hz.) Even though a tapin~ is already implemented as a ring buffer –– that is, it always contains the most recently received milliseconds of signal ––you can also use count~ and poke~ and index~ to continually write to and read from a buffer~.
Keep in mind that one generally doesn’t move the buffer by moving every sample in memory, because that would be laborious; one uses a pointer to the current time (the most recently stored sample), which moves as you write into the buffer. Writing over-and-over into the same buffer keeps that buffer filled with the most recent signal. The idea is explained pretty well on Wikipedia’s page about "Circular buffer".