VCV Rack API v2
Loading...
Searching...
No Matches
rack::dsp::AppleRingBuffer< T, S, N > Struct Template Reference

A cyclic buffer which maintains a valid linear array of size S by sliding along a larger block of size N. More...

#include <ringbuffer.hpp>

Public Member Functions

void returnBuffer ()
 
void push (T t)
 
shift ()
 
bool empty () const
 
bool full () const
 
size_t size () const
 
size_t capacity () const
 
T * endData (size_t n)
 Returns a pointer to S consecutive elements for appending, requesting to append n elements.
 
void endIncr (size_t n)
 Actually increments the end position Must be called after endData(), and n must be at most the n passed to endData()
 
const T * startData () const
 Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards.
 
void startIncr (size_t n)
 

Public Attributes

size_t start = 0
 
size_t end = 0
 
data [N]
 

Detailed Description

template<typename T, size_t S, size_t N>
struct rack::dsp::AppleRingBuffer< T, S, N >

A cyclic buffer which maintains a valid linear array of size S by sliding along a larger block of size N.

This is not thread-safe. The linear array of S elements are moved back to the start of the block once it outgrows past the end. This happens every N - S pushes, so the push() time is O(1 + S / (N - S)). For example, a float buffer of size 64 in a block of size 1024 is nearly as efficient as RingBuffer. Not thread-safe.

Member Function Documentation

◆ returnBuffer()

template<typename T , size_t S, size_t N>
void rack::dsp::AppleRingBuffer< T, S, N >::returnBuffer ( )
inline

◆ push()

template<typename T , size_t S, size_t N>
void rack::dsp::AppleRingBuffer< T, S, N >::push ( T t)
inline

◆ shift()

template<typename T , size_t S, size_t N>
T rack::dsp::AppleRingBuffer< T, S, N >::shift ( )
inline

◆ empty()

template<typename T , size_t S, size_t N>
bool rack::dsp::AppleRingBuffer< T, S, N >::empty ( ) const
inline

◆ full()

template<typename T , size_t S, size_t N>
bool rack::dsp::AppleRingBuffer< T, S, N >::full ( ) const
inline

◆ size()

template<typename T , size_t S, size_t N>
size_t rack::dsp::AppleRingBuffer< T, S, N >::size ( ) const
inline

◆ capacity()

template<typename T , size_t S, size_t N>
size_t rack::dsp::AppleRingBuffer< T, S, N >::capacity ( ) const
inline

◆ endData()

template<typename T , size_t S, size_t N>
T * rack::dsp::AppleRingBuffer< T, S, N >::endData ( size_t n)
inline

Returns a pointer to S consecutive elements for appending, requesting to append n elements.

◆ endIncr()

template<typename T , size_t S, size_t N>
void rack::dsp::AppleRingBuffer< T, S, N >::endIncr ( size_t n)
inline

Actually increments the end position Must be called after endData(), and n must be at most the n passed to endData()

◆ startData()

template<typename T , size_t S, size_t N>
const T * rack::dsp::AppleRingBuffer< T, S, N >::startData ( ) const
inline

Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards.

◆ startIncr()

template<typename T , size_t S, size_t N>
void rack::dsp::AppleRingBuffer< T, S, N >::startIncr ( size_t n)
inline

Member Data Documentation

◆ start

template<typename T , size_t S, size_t N>
size_t rack::dsp::AppleRingBuffer< T, S, N >::start = 0

◆ end

template<typename T , size_t S, size_t N>
size_t rack::dsp::AppleRingBuffer< T, S, N >::end = 0

◆ data

template<typename T , size_t S, size_t N>
T rack::dsp::AppleRingBuffer< T, S, N >::data[N]

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