Vital
Loading...
Searching...
No Matches
vital::Memory Class Reference

A specialized MemoryTemplate for poly_float::kSize channels. More...

#include <memory.h>

Inheritance diagram for vital::Memory:
vital::MemoryTemplate< poly_float::kSize >

Public Member Functions

 Memory (int size)
 Constructs a polyphonic memory with the given size.
 
 Memory (Memory &other)
 Copy constructor.
 
force_inline poly_float get (poly_float past) const
 Retrieves a poly_float of samples from the memory using cubic interpolation.
 
- Public Member Functions inherited from vital::MemoryTemplate< poly_float::kSize >
 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.
 

Additional Inherited Members

- Static Public Attributes inherited from vital::MemoryTemplate< poly_float::kSize >
static constexpr mono_float kMinPeriod
 Minimum allowed period of time delay.
 
static constexpr int kExtraInterpolationValues
 Extra values to support cubic interpolation.
 
- Protected Attributes inherited from vital::MemoryTemplate< poly_float::kSize >
std::unique_ptr< mono_float[]> memories_ [kChannels]
 Unique pointers to each channel's buffer.
 
mono_floatbuffers_ [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.
 

Detailed Description

A specialized MemoryTemplate for poly_float::kSize channels.

Memory supports retrieval of past samples with cubic interpolation. It assumes that the period requested is between kMinPeriod and getMaxPeriod().

Constructor & Destructor Documentation

◆ Memory() [1/2]

vital::Memory::Memory ( int size)
inline

Constructs a polyphonic memory with the given size.

Parameters
sizeThe initial size of the memory buffer.

◆ Memory() [2/2]

vital::Memory::Memory ( Memory & other)
inline

Copy constructor.

Parameters
otherAnother Memory to copy from.

Member Function Documentation

◆ get()

force_inline poly_float vital::Memory::get ( poly_float past) const
inline

Retrieves a poly_float of samples from the memory using cubic interpolation.

Parameters
pastA poly_float of "time ago" values. Each lane corresponds to how many samples back in time we want to read.
Returns
The interpolated sample values at the requested times.

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