|
TracktionEngine
|
A stack of audio buffers. More...
#include <tracktion_AudioBufferStack.h>
Public Member Functions | |
| AudioBufferStack ()=default | |
| Create an empty stack. | |
| choc::buffer::ChannelArrayBuffer< float > | allocate (choc::buffer::Size) |
| Returns an allocated buffer for a given size from the stack. | |
| void | release (choc::buffer::ChannelArrayBuffer< float > &&) |
| Releases an allocated buffer back to the stack. | |
| void | reset () |
| Releases all the internal allocated storage. | |
| void | reserve (size_t numBuffers, choc::buffer::Size) |
| Reserves a number of buffers of a given size, preallocating them. | |
| size_t | getNumBuffers () |
| Returns the current number of buffers in the stack. | |
| size_t | getAllocatedSize () |
| Returns the currently allocated size of all the buffers in bytes. | |
A stack of audio buffers.
If you need to quickly create and then return some audio buffers this class enables you to do that.
Note that the buffers can be pre-allocated but if you ask for a buffer which isn't in the pool, it will either resize an existing one or allocate a new one.
After processing a constant audio graph for a while though this should be completely allocation and lock-free.
However, it is not thread safe so you should use a different stack for each thread!
|
default |
Create an empty stack.
You won't be able to use this pool right away, you must reserve some a number of buffers for it to use first.
References allocate(), and release().
| choc::buffer::ChannelArrayBuffer< float > graph::AudioBufferStack::allocate | ( | choc::buffer::Size | size | ) |
Returns an allocated buffer for a given size from the stack.
This will attempt to get a buffer from the pre-allocated pool that can fit the size but if one can't easily be found, it will allocate one with new and return it.
Additionally, the returned buffer may be bigger than the size asked for so be sure to only use a view of it but retain ownership of the whole buffer. You can release it back to the pool later. It will also contain junk so be sure to clear or initialise the view required before use.
References allocate().
Referenced by allocate(), and AudioBufferStack().
| void graph::AudioBufferStack::release | ( | choc::buffer::ChannelArrayBuffer< float > && | buffer | ) |
Releases an allocated buffer back to the stack.
References release().
Referenced by AudioBufferStack(), and release().
| void graph::AudioBufferStack::reset | ( | ) |
Releases all the internal allocated storage.
References getAllocatedSize(), getNumBuffers(), and reserve().
| void graph::AudioBufferStack::reserve | ( | size_t | numBuffers, |
| choc::buffer::Size | size ) |
| size_t graph::AudioBufferStack::getNumBuffers | ( | ) |
Returns the current number of buffers in the stack.
References getNumBuffers().
Referenced by getNumBuffers(), and reset().
| size_t graph::AudioBufferStack::getAllocatedSize | ( | ) |
Returns the currently allocated size of all the buffers in bytes.
References getAllocatedSize().
Referenced by getAllocatedSize(), and reset().