DIY ring buffer
For time-delayed audio, we need to create what's called a "circular buffer" or a "ring buffer", an array of samples to which we record continuously in a loop, and which we can then use always to access the most recently recorded sound from the past.