|
Gin
|
Temporary audio buffer allocated from a shared pool to avoid allocations. More...
#include <gin_scratchbuffer.h>
Inherits juce::AudioSampleBuffer.
Public Member Functions | |
| ScratchBuffer (int numChannels, int numSamples) | |
| ScratchBuffer (juce::AudioSampleBuffer &buffer) | |
| ScratchBuffer (const ScratchBuffer &) | |
| ~ScratchBuffer () | |
Temporary audio buffer allocated from a shared pool to avoid allocations.
ScratchBuffer provides a convenient way to get temporary audio buffers without allocating memory on the heap. Buffers are retrieved from a thread-safe pool and automatically returned when the ScratchBuffer goes out of scope.
This is useful in real-time audio code where you need temporary buffers but want to avoid allocation overhead and fragmentation. The pool grows as needed but buffers are reused, minimizing allocations after initialization.
Key Features:
Note: While buffer retrieval from the pool uses locking, this is generally acceptable as the lock contention is minimal and allocation is avoided.
Usage:
| ScratchBuffer::ScratchBuffer | ( | juce::AudioSampleBuffer & | buffer | ) |
| ScratchBuffer::ScratchBuffer | ( | const ScratchBuffer & | ) |
| ScratchBuffer::~ScratchBuffer | ( | ) |