What happens when AudioRecordQueue queue gets filled with blocks?

Status
Not open for further replies.

superflash

New member
Assuming that we allocated some audio memory from AudioMemory(x), what happens when the audio queue (instance of AudioRecordQueue) gets filled completely with samples?
I dug into the library itself (https://github.com/PaulStoffregen/Audio/blob/master/record_queue.cpp#L78) and found out the AudioRecordQueue::update()
method which if I am interpreting correctly, it is simply starting to fill with samples starting from the end of the queue. Am I correct regarding this?
 
When the sample blocks get filled up, the head resets to zero, which means the old sample data will start being overwritten. You can see the resetting happening on line 90:
Code:
if (h >= max_buffers) h = 0;

Also, you don't need to worry about allocating memory for this object. The memory is statically allocated inside the class definition, in record_queue.h on line 58:
Code:
audio_block_t * volatile queue[max_buffers];

max_buffers is defined earlier in record_queue.h to be either 53 or 209. AudioMemory(x) is only needed to reserve enough space for the PatchCord objects if I remember correctly.

Is there something specific you're trying to do?
 
When the sample blocks get filled up, the head resets to zero, which means the old sample data will start being overwritten. You can see the resetting happening on line 90:
Code:
if (h >= max_buffers) h = 0;

Also, you don't need to worry about allocating memory for this object. The memory is statically allocated inside the class definition, in record_queue.h on line 58:
Code:
audio_block_t * volatile queue[max_buffers];

max_buffers is defined earlier in record_queue.h to be either 53 or 209. AudioMemory(x) is only needed to reserve enough space for the PatchCord objects if I remember correctly.

Is there something specific you're trying to do?

Thank you for your detailed answer. I also appreciate your insight regarding AudioMemory. I am using a microphone for my project and wanted to know what
happens to the samples when the queue fills up.
Maybe I should start another thread but also wanted to ask what is the difference between ::clear() and ::freeBuffer().
Presumably clear will empty the whole queue while freeBuffer will only clear the block at the front of the queue.
 
Last edited:
Status
Not open for further replies.
Back
Top