32 template<
size_t kChannels>
45 for (
int i = 0; i < static_cast<int>(kChannels); ++i) {
56 for (
int i = 0; i < static_cast<int>(kChannels); ++i) {
77 for (
int i = 0; i < static_cast<int>(kChannels); ++i) {
95 for (
int p = 0; p < static_cast<int>(kChannels); ++p) {
98 for (
int i = start; i != end; i = (i + 1) &
bitmask_)
103 buffer[
size_ + i] = 0.0f;
112 for (
int c = 0; c < static_cast<int>(kChannels); ++c)
126 int start_index = (
offset_ - num_samples - offset) & bitmask;
127 for (
int i = 0; i < num_samples; ++i)
128 output[i] = buffer[(i + start_index) & bitmask];
A specialized MemoryTemplate for poly_float::kSize channels.
Definition memory.h:174
force_inline poly_float get(poly_float past) const
Retrieves a poly_float of samples from the memory using cubic interpolation.
Definition memory.h:194
Memory(int size)
Constructs a polyphonic memory with the given size.
Definition memory.h:180
Memory(Memory &other)
Copy constructor.
Definition memory.h:186
A template for a memory buffer that stores time-domain samples for one or more channels.
Definition memory.h:33
unsigned int getOffset() const
Gets the current offset (write position) in the buffer.
Definition memory.h:135
static constexpr int kExtraInterpolationValues
Extra values to support cubic interpolation.
Definition memory.h:36
unsigned int bitmask_
Bitmask for efficient modulo operations.
Definition memory.h:163
unsigned int size_
The size of the memory buffer.
Definition memory.h:162
void push(poly_float sample)
Pushes a poly_float of samples (one sample per channel) into the memory.
Definition memory.h:75
mono_float * buffers_[kChannels]
Raw pointers to each channel buffer.
Definition memory.h:161
void clearMemory(int num, poly_mask clear_mask)
Clears a specified number of samples in the memory for channels indicated by a mask.
Definition memory.h:91
void readSamples(mono_float *output, int num_samples, int offset, int channel) const
Reads samples from the memory into an output buffer.
Definition memory.h:123
int getMaxPeriod() const
Gets the maximum allowed period for reading samples.
Definition memory.h:155
void setOffset(int offset)
Sets the current offset (write position) in the buffer.
Definition memory.h:141
MemoryTemplate(int size)
Constructs the memory with a given size (rounded up to a power of two).
Definition memory.h:42
unsigned int offset_
Current write offset in the buffer.
Definition memory.h:164
std::unique_ptr< mono_float[]> memories_[kChannels]
Unique pointers to each channel's buffer.
Definition memory.h:160
virtual ~MemoryTemplate()
Destructor.
Definition memory.h:69
int getSize() const
Gets the size of the memory buffer.
Definition memory.h:147
static constexpr mono_float kMinPeriod
Minimum allowed period of time delay.
Definition memory.h:35
MemoryTemplate(const MemoryTemplate &other)
Copy constructor.
Definition memory.h:55
void clearAll()
Clears all samples in the memory for all channels.
Definition memory.h:111
A specialized MemoryTemplate for two-channel (stereo) audio.
Definition memory.h:216
force_inline poly_float get(poly_float past) const
Retrieves a poly_float of samples from the stereo memory using cubic interpolation.
Definition memory.h:235
StereoMemory(StereoMemory &other)
Copy constructor.
Definition memory.h:228
StereoMemory(int size)
Constructs a stereo memory with the given size.
Definition memory.h:222
#define VITAL_ASSERT(x)
Definition common.h:11
#define force_inline
Definition common.h:23
force_inline bool isFinite(poly_float value)
Checks if all lanes in a poly_float are finite.
Definition poly_utils.h:610
force_inline poly_float toFloat(poly_int integers)
Casts a poly_int to poly_float lane-by-lane.
Definition poly_utils.h:733
force_inline int nextPowerOfTwo(mono_float value)
Finds the next power of two greater than or equal to a float value.
Definition utils.h:370
force_inline poly_float toPolyFloatFromUnaligned(const mono_float *unaligned)
Loads a poly_float from an unaligned float pointer.
Definition poly_utils.h:249
force_inline matrix getCatmullInterpolationMatrix(poly_float t)
Creates a Catmull-Rom interpolation matrix from a poly_float t.
Definition poly_utils.h:227
force_inline matrix getValueMatrix(const mono_float *buffer, poly_int indices)
Creates a matrix of 4 poly_float lanes from a single buffer at varying indices.
Definition poly_utils.h:262
force_inline poly_int toInt(poly_float floats)
Casts a poly_float to poly_int by truncation.
Definition poly_utils.h:748
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
A structure representing a 4x1 matrix of poly_float rows.
Definition matrix.h:19
force_inline poly_float multiplyAndSumRows(const matrix &other)
Multiplies and sums corresponding rows of this matrix with another matrix.
Definition matrix.h:93
force_inline void transpose()
Transposes the matrix in-place.
Definition matrix.h:44
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
static force_inline poly_mask vector_call lessThan(poly_float one, poly_float two)
Definition poly_values.h:1105
static force_inline mask_simd_type vector_call greaterThan(simd_type one, simd_type two)
Compares two SIMD float registers, element-wise, for greater than.
Definition poly_values.h:971
Represents a vector of integer values using SIMD instructions.
Definition poly_values.h:56