#include <delay.h>
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 | |
Buffer & | operator= (const Buffer &other)=delete |
Buffer (Buffer &&other)=default | |
Buffer & | operator= (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... | |
Buffer & | operator++ () |
Buffer & | operator+= (int i) |
Buffer & | operator-- () |
Buffer & | operator-= (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 |
|
inline |
Read data out from the buffer.
|
inline |
Write data into the buffer.