All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::RingBufferDelay< TElem > Class Template Reference

Ring buffer for delays. More...

#include <Radiant/RingBuffer.hpp>

Inheritance diagram for Radiant::RingBufferDelay< TElem >:
Radiant::RingBuffer< TElem >

Public Member Functions

void advance ()
 Advance the counter by one.
 
void advanceN (unsigned nSteps)
 Advance the counter by given number of steps. More...
 
TElem & getNewest (unsigned nDelay)
 Get a sample from the buffer. More...
 
const TElem & getNewest (unsigned nDelay) const
 Get a sample from the buffer. More...
 
TElem & getNewest ()
 Get the newest sample from the buffer.
 
const TElem & getNewestConst (unsigned nDelay) const
 Get a sample from the buffer. More...
 
const TElem & getNewestConst () const
 Get a sample from the buffer. More...
 
unsigned getSampleCount () const
 Returns the number of samples processed. More...
 
void put (const TElem &v)
 Advance the delay line and set the "newest" sample. More...
 
void reset ()
 Reset the buffer.
 
 RingBufferDelay ()
 Construct an empty buffer.
 
 RingBufferDelay (unsigned size)
 Construct a new buffer and initializes it to the given size. More...
 
void setSampleCount (unsigned int nCount)
 Sets the number of samples processed. More...
 
unsigned sizeOf () const
 Get memory usage in bytes. More...
 
virtual ~RingBufferDelay ()
 Destructor.
 
- Public Member Functions inherited from Radiant::RingBuffer< TElem >
TElem * data ()
 Get a raw pointer to data. More...
 
const TElem * data () const
 Get a raw pointer to data. More...
 
int elemSize () const
 Get the size of a sample in bytes. More...
 
TElem & getIndex (unsigned nIndex)
 Get a sample from the buffer. More...
 
const TElem & getIndex (unsigned nIndex) const
 Get a sample from the buffer. More...
 
const TElem & getIndexConst (unsigned nIndex) const
 Get a sample from the buffer. More...
 
unsigned mask () const
 Report mask used for address translation. More...
 
RingBuffer< TElem > & operator= (const RingBuffer &xrBuffer)
 Deep copy operator. More...
 
TElem & operator[] (unsigned nIndex)
 Get the sample with the given index. More...
 
const TElem & operator[] (unsigned nIndex) const
 Get the sample with the given index. More...
 
bool resize (unsigned nBufSize)
 Resize the buffer. More...
 
 RingBuffer ()
 Create an empty ring buffer.
 
 RingBuffer (unsigned nSize)
 Create a ring-buffer with given minimum size. More...
 
 RingBuffer (const RingBuffer &xrBuffer)
 Create a deep copy. More...
 
void setAll (TElem xVal)
 Set all buffer values. More...
 
void setIndex (unsigned nIndex, const TElem &xVal)
 Set a sample of the buffer. More...
 
unsigned size () const
 Get buffer size. More...
 
unsigned sizeOf () const
 Get buffer size in bytes. More...
 
virtual ~RingBuffer ()
 Destroy the ring-buffer and free memory.
 

Protected Attributes

unsigned m_position
 The current position in the buffer.
 
- Protected Attributes inherited from Radiant::RingBuffer< TElem >
TElem * m_line
 Data buffer.
 
unsigned m_mask
 Mask for determining index.
 
unsigned m_size
 Real size.
 

Additional Inherited Members

- Static Public Member Functions inherited from Radiant::RingBuffer< TElem >
static unsigned targetSize (unsigned nBufSize)
 Calculate the real size of the buffer if the required number of samples is nBufSize. More...
 

Detailed Description

template<class TElem>
class Radiant::RingBufferDelay< TElem >

Ring buffer for delays.

This sublass if RingBuffer introduces a sample counter that is used to calculate delays.

RingBufferDelay<float> delay(128); // Create a new delay line
delay.getNewest() = 0.4; // Set the current value to 0.4
delay.advance(); // Advance the line
float delayedValue = delay.getNewest(1);// delayedValue = 0.4

Constructor & Destructor Documentation

template<class TElem>
Radiant::RingBufferDelay< TElem >::RingBufferDelay ( unsigned  size)
inline

Construct a new buffer and initializes it to the given size.

Parameters
sizebuffer size in samples

Member Function Documentation

template<class TElem>
void Radiant::RingBufferDelay< TElem >::advanceN ( unsigned  nSteps)
inline

Advance the counter by given number of steps.

Parameters
nStepsnumber of steps to advance
template<class TElem>
TElem& Radiant::RingBufferDelay< TElem >::getNewest ( unsigned  nDelay)
inline

Get a sample from the buffer.

Parameters
nDelaydelay in samples
Returns
delayed sample
template<class TElem>
const TElem& Radiant::RingBufferDelay< TElem >::getNewest ( unsigned  nDelay) const
inline

Get a sample from the buffer.

Parameters
nDelaydelay in samples
Returns
delayed sample
template<class TElem>
const TElem& Radiant::RingBufferDelay< TElem >::getNewestConst ( unsigned  nDelay) const
inline

Get a sample from the buffer.

Parameters
nDelaydelay in samples
Returns
delayed sample
template<class TElem>
const TElem& Radiant::RingBufferDelay< TElem >::getNewestConst ( ) const
inline

Get a sample from the buffer.

Parameters
nDelaydelay in samples
Returns
delayed sample
template<class TElem>
unsigned Radiant::RingBufferDelay< TElem >::getSampleCount ( ) const
inline

Returns the number of samples processed.

Returns
number of samples
template<class TElem>
void Radiant::RingBufferDelay< TElem >::put ( const TElem &  v)
inline

Advance the delay line and set the "newest" sample.

Parameters
vnewest sample to set
template<class TElem>
void Radiant::RingBufferDelay< TElem >::setSampleCount ( unsigned int  nCount)
inline

Sets the number of samples processed.

Parameters
nCountnumber of samples
template<class TElem>
unsigned Radiant::RingBufferDelay< TElem >::sizeOf ( ) const
inline

Get memory usage in bytes.

Returns
number of bytes used by the buffer