|
Vital
|
A template for a memory buffer that stores time-domain samples for one or more channels. More...
#include <memory.h>
Public Member Functions | |
| MemoryTemplate (int size) | |
| Constructs the memory with a given size (rounded up to a power of two). | |
| MemoryTemplate (const MemoryTemplate &other) | |
| Copy constructor. | |
| virtual | ~MemoryTemplate () |
| Destructor. | |
| void | push (poly_float sample) |
| Pushes a poly_float of samples (one sample per channel) into the memory. | |
| void | clearMemory (int num, poly_mask clear_mask) |
| Clears a specified number of samples in the memory for channels indicated by a mask. | |
| void | clearAll () |
| Clears all samples in the memory for all channels. | |
| void | readSamples (mono_float *output, int num_samples, int offset, int channel) const |
| Reads samples from the memory into an output buffer. | |
| unsigned int | getOffset () const |
| Gets the current offset (write position) in the buffer. | |
| void | setOffset (int offset) |
| Sets the current offset (write position) in the buffer. | |
| int | getSize () const |
| Gets the size of the memory buffer. | |
| int | getMaxPeriod () const |
| Gets the maximum allowed period for reading samples. | |
Static Public Attributes | |
| static constexpr mono_float | kMinPeriod = 2.0f |
| Minimum allowed period of time delay. | |
| static constexpr int | kExtraInterpolationValues = 3 |
| Extra values to support cubic interpolation. | |
Protected Attributes | |
| std::unique_ptr< mono_float[]> | memories_ [kChannels] |
| Unique pointers to each channel's buffer. | |
| mono_float * | buffers_ [kChannels] |
| Raw pointers to each channel buffer. | |
| unsigned int | size_ |
| The size of the memory buffer. | |
| unsigned int | bitmask_ |
| Bitmask for efficient modulo operations. | |
| unsigned int | offset_ |
| Current write offset in the buffer. | |
A template for a memory buffer that stores time-domain samples for one or more channels.
MemoryTemplate provides a ring buffer of samples. Samples can be pushed into the buffer and later retrieved based on a certain delay or offset. It supports clearing sections of the buffer and ensures that size is always a power-of-two for indexing efficiency.
| kChannels | The number of channels stored in the memory. |
|
inline |
Constructs the memory with a given size (rounded up to a power of two).
| size | The desired size of the memory buffer. |
|
inline |
Copy constructor.
| other | Another MemoryTemplate to copy from. |
|
inlinevirtual |
Destructor.
|
inline |
Clears all samples in the memory for all channels.
|
inline |
Clears a specified number of samples in the memory for channels indicated by a mask.
| num | The number of samples to clear. |
| clear_mask | A poly_mask indicating which channels to clear. |
|
inline |
Gets the maximum allowed period for reading samples.
|
inline |
Gets the current offset (write position) in the buffer.
|
inline |
Gets the size of the memory buffer.
|
inline |
Pushes a poly_float of samples (one sample per channel) into the memory.
| sample | The sample to push for each channel (interleaved in poly_float). |
|
inline |
Reads samples from the memory into an output buffer.
| output | Pointer to the output array to fill. |
| num_samples | Number of samples to read. |
| offset | The offset (delay) from the current write position. |
| channel | The channel to read from. |
|
inline |
Sets the current offset (write position) in the buffer.
| offset | The new offset. |
|
protected |
Bitmask for efficient modulo operations.
|
protected |
Raw pointers to each channel buffer.
|
staticconstexpr |
Extra values to support cubic interpolation.
|
staticconstexpr |
Minimum allowed period of time delay.
|
protected |
Unique pointers to each channel's buffer.
|
protected |
Current write offset in the buffer.
|
protected |
The size of the memory buffer.