|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Power-of-two circular buffer with compile-time interpolated read access. More...
#include <RingBuffer.h>
Public Member Functions | |
| RingBuffer () noexcept=default | |
| Constructs an empty ring buffer. No allocation happens until prepare() is called, honouring the framework's "allocate only in
prepare()" contract. All methods are safe no-ops before prepare(). | |
| void | prepare (int maxSamples) noexcept |
| Allocates the ring buffer with the given capacity. | |
| void | reset () noexcept |
| Clears the buffer to zero without deallocating. Safe to call from the audio thread. | |
| void | push (T sample) noexcept |
| Pushes a single sample into the buffer. | |
| void | pushBlock (const T *samples, int numSamples) noexcept |
| Pushes a block of samples into the buffer. | |
| T | read (int delaySamples) const noexcept |
| Reads a sample at an integer delay. | |
| template<InterpMethod Method = InterpMethod::Cubic> | |
| T | readInterpolated (T delaySamples) const noexcept |
| Reads a sample at a fractional delay using the specified interpolation. | |
| int | getCapacity () const noexcept |
| const T * | data () const noexcept |
| int | getWritePosition () const noexcept |
Power-of-two circular buffer with compile-time interpolated read access.
| T | Sample type (float or double). Requires FloatType concept. |
Definition at line 57 of file RingBuffer.h.
|
defaultnoexcept |
|
inlinenoexcept |
Definition at line 250 of file RingBuffer.h.
|
inlinenoexcept |
Definition at line 249 of file RingBuffer.h.
|
inlinenoexcept |
Definition at line 251 of file RingBuffer.h.
|
inlinenoexcept |
Allocates the ring buffer with the given capacity.
Capacity is rounded up to the next power of two. Existing content is cleared. Memory is aligned to 32 bytes. Not thread-safe against concurrent processing calls.
| maxSamples | Maximum number of samples to store. Clamped release-safe to [1, 2^30] (non-positive requests allocate a single sample; larger ones would overflow the power-of-two round-up). |
Definition at line 78 of file RingBuffer.h.
|
inlinenoexcept |
Pushes a single sample into the buffer.
| sample | The sample to write. |
Definition at line 129 of file RingBuffer.h.
|
inlinenoexcept |
Pushes a block of samples into the buffer.
Copies in at most two contiguous memcpy spans (pre-wrap / post-wrap) with a single write-position update, several times faster than a per-sample push loop for block-based delays.
| samples | Source buffer. |
| numSamples | Number of samples to push. |
Definition at line 146 of file RingBuffer.h.
|
inlinenoexcept |
Reads a sample at an integer delay.
A delay of 0 returns the most recently pushed sample.
| delaySamples | Delay in samples (0 to capacity-1). |
Definition at line 179 of file RingBuffer.h.
|
inlinenoexcept |
Reads a sample at a fractional delay using the specified interpolation.
The interpolation method is selected at compile time (no per-sample dispatch in the audio thread).
| Method | Interpolation method to use. |
| delaySamples | Fractional delay in samples. |
Definition at line 210 of file RingBuffer.h.
|
inlinenoexcept |
Clears the buffer to zero without deallocating. Safe to call from the audio thread.
Definition at line 118 of file RingBuffer.h.