When setting up recording in a looping buffer, getRecordPosition() will show the buffer filling to the end and then loop back to the start and keep going.
It’s relatively easy to keep track of the current "head" of the buffer via getRecordPosition and maintain a "last sample read" index (paying attention to buffer wrapping) and be able to read blocks of recorded data.
The only thing that could foul this up is if the caller didn’t (or couldn’t) get back to the buffer in time and the recording position looped one or more times.
Granted, data will be lost (we didn’t retrieve it and the buffer wrapped and overwrote it). The issue I am looking at is knowing that this happened and "re-syncing" with the buffer after "being away" too long.
Is there any way at present to obtain a buffer-wrap counter? Or could it be added to getRecordPosition to return a pair of int’s that represent a buffer wrap counter along with the current recording position within the buffer?
Taken together, you could know if you’re still within the buffer data or that in your absense, the buffer has wrapped more than once and you need to account for it.
- billp asked 12 years ago
- You must login to post comments