TracktionEngine
Loading...
Searching...
No Matches
graph::AudioBufferStack Class Reference

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.

Detailed Description

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!

Constructor & Destructor Documentation

◆ AudioBufferStack()

graph::AudioBufferStack::AudioBufferStack ( )
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.

See also
reserve

References allocate(), and release().

Member Function Documentation

◆ allocate()

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.

See also
release

References allocate().

Referenced by allocate(), and AudioBufferStack().

◆ release()

void graph::AudioBufferStack::release ( choc::buffer::ChannelArrayBuffer< float > && buffer)

Releases an allocated buffer back to the stack.

References release().

Referenced by AudioBufferStack(), and release().

◆ reset()

void graph::AudioBufferStack::reset ( )

Releases all the internal allocated storage.

References getAllocatedSize(), getNumBuffers(), and reserve().

◆ reserve()

void graph::AudioBufferStack::reserve ( size_t numBuffers,
choc::buffer::Size size )

Reserves a number of buffers of a given size, preallocating them.

References reserve().

Referenced by reserve(), and reset().

◆ getNumBuffers()

size_t graph::AudioBufferStack::getNumBuffers ( )

Returns the current number of buffers in the stack.

References getNumBuffers().

Referenced by getNumBuffers(), and reset().

◆ getAllocatedSize()

size_t graph::AudioBufferStack::getAllocatedSize ( )

Returns the currently allocated size of all the buffers in bytes.

References getAllocatedSize().

Referenced by getAllocatedSize(), and reset().


The documentation for this class was generated from the following file: