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

A specialized MemoryTemplate for two-channel (stereo) audio. More...

#include <memory.h>

Inheritance diagram for vital::StereoMemory:
vital::MemoryTemplate< 2 >

Public Member Functions

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

StereoMemory stores two channels of audio samples and can retrieve past samples for both channels simultaneously using cubic interpolation.

Constructor & Destructor Documentation

◆ StereoMemory() [1/2]

vital::StereoMemory::StereoMemory ( int size)
inline

Constructs a stereo memory with the given size.

Parameters
sizeThe initial size of the memory buffer.

◆ StereoMemory() [2/2]

vital::StereoMemory::StereoMemory ( StereoMemory & other)
inline

Copy constructor.

Parameters
otherAnother StereoMemory to copy from.

Member Function Documentation

◆ get()

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

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

Parameters
pastA poly_float of "time ago" values (for one channel pair).
Returns
The interpolated stereo sample values at the requested times.

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