Signalsmith Audio's DSP Library  1.6.0
Useful C++ classes/templates for audio effects
Nested Classes | Types | Methods
signalsmith::delay::Buffer< Sample > Class Template Reference

#include <delay.h>

Detailed Description

template<typename Sample>
class signalsmith::delay::Buffer< Sample >

Single-channel delay buffer.

Access is used with buffer[], relative to the internal read/write position ("head"). This head is moved using ++buffer (or buffer += n), such that buffer[1] == (buffer + 1)[0] in a similar way iterators/pointers.

Operations like buffer - 10 or buffer++ return a View, which holds a fixed position in the buffer (based on the read/write position at the time).

The capacity includes both positive and negative indices. For example, a capacity of 100 would support using any of the ranges:

buffer[-99] to buffer[0] buffer[-50]to buffer[49] buffer[0] to buffer[99]`

Although buffers are usually used with historical samples accessed using negative indices e.g. buffer[-10], you could equally use it flipped around (moving the head backwards through the buffer using --buffer).

Nested Classes

class  View
 Holds a view for a particular position in the buffer. More...
 

Types

using MutableView = View< false >
 
using ConstView = View< true >
 

Methods

 Buffer (int minCapacity=0)
 
 Buffer (const Buffer &other)=delete
 
Bufferoperator= (const Buffer &other)=delete
 
 Buffer (Buffer &&other)=default
 
Bufferoperator= (Buffer &&other)=default
 
void resize (int minCapacity, Sample value=Sample())
 
void reset (Sample value=Sample())
 
MutableView view (int offset=0)
 
ConstView view (int offset=0) const
 
ConstView constView (int offset=0) const
 
Sample & operator[] (int offset)
 
const Sample & operator[] (int offset) const
 
template<typename Data >
void write (Data &&data, int length)
 Write data into the buffer. More...
 
template<typename Data >
void read (int length, Data &&data) const
 Read data out from the buffer. More...
 
Bufferoperator++ ()
 
Bufferoperator+= (int i)
 
Bufferoperator-- ()
 
Bufferoperator-= (int i)
 
MutableView operator++ (int)
 
MutableView operator+ (int i)
 
ConstView operator+ (int i) const
 
MutableView operator-- (int)
 
MutableView operator- (int i)
 
ConstView operator- (int i) const
 

Method Details

◆ read()

template<typename Sample >
template<typename Data >
void signalsmith::delay::Buffer< Sample >::read ( int  length,
Data &&  data 
) const
inline

Read data out from the buffer.

◆ write()

template<typename Sample >
template<typename Data >
void signalsmith::delay::Buffer< Sample >::write ( Data &&  data,
int  length 
)
inline

Write data into the buffer.