arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RingBuffer< T > Class Template Reference

Implements a typed Ringbuffer. More...

#include <Buffers.h>

Inheritance diagram for RingBuffer< T >:
BaseBuffer< T >

Public Member Functions

 RingBuffer (int size)
 
virtual T * address ()
 returns the address of the start of the physical read buffer
 
virtual int available ()
 provides the number of entries that are available to read
 
virtual int availableForWrite ()
 provides the number of entries that are available to write
 
void clear ()
 same as reset
 
virtual int clearArray (int len)
 Removes the next len entries.
 
bool isEmpty ()
 
virtual bool isFull ()
 checks if the buffer is full
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
bool peek (T &result) override
 peeks the actual entry from the buffer
 
virtual int peekArray (T *data, int n)
 
bool read (T &result) override
 reads a single value
 
virtual int readArray (T data[], int len)
 reads multiple values
 
virtual void reset ()
 clears the buffer
 
virtual void resize (int len)
 
virtual size_t size ()
 Returns the maximum capacity of the buffer.
 
virtual bool write (T data)
 write add an entry to the buffer
 
virtual int writeArray (const T data[], int len)
 Fills the buffer data.
 
virtual int writeArrayOverwrite (const T data[], int len)
 Fills the buffer data and overwrites the oldest data if the buffer is full.
 

Protected Member Functions

int nextIndex (int index)
 
void setWritePos (int pos)
 

Protected Attributes

Vector< T > _aucBuffer
 
int _iHead
 
int _iTail
 
int _numElems
 
int max_size = 0
 
friend NBuffer< T >
 

Detailed Description

template<typename T>
class audio_tools::RingBuffer< T >

Implements a typed Ringbuffer.

Template Parameters
T

Member Function Documentation

◆ address()

template<typename T >
virtual T * address ( )
inlinevirtual

returns the address of the start of the physical read buffer

Implements BaseBuffer< T >.

◆ available()

template<typename T >
virtual int available ( )
inlinevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

template<typename T >
virtual int availableForWrite ( )
inlinevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ clearArray()

template<typename T >
virtual int clearArray ( int  len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.

◆ isFull()

template<typename T >
virtual bool isFull ( )
inlinevirtual

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ peek()

template<typename T >
bool peek ( T &  result)
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<typename T >
bool read ( T &  result)
inlineoverridevirtual

reads a single value

Implements BaseBuffer< T >.

◆ readArray()

template<typename T >
virtual int readArray ( data[],
int  len 
)
inlinevirtualinherited

◆ reset()

template<typename T >
virtual void reset ( )
inlinevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ size()

template<typename T >
virtual size_t size ( )
inlinevirtual

Returns the maximum capacity of the buffer.

Implements BaseBuffer< T >.

◆ write()

template<typename T >
virtual bool write ( data)
inlinevirtual

write add an entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

template<typename T >
virtual int writeArray ( const T  data[],
int  len 
)
inlinevirtualinherited

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