arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SingleBuffer< T > Class Template Reference

A simple Buffer implementation which just uses a (dynamically sized) array. More...

#include <Buffers.h>

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

Public Member Functions

 SingleBuffer ()
 Construct a new Single Buffer w/o allocating any memory.
 
 SingleBuffer (int size)
 Construct a new Single Buffer object.
 
Taddress () override
 Provides address to beginning of the buffer.
 
int available () override
 provides the number of entries that are available to read
 
int availableForWrite () override
 provides the number of entries that are available to write
 
void clear ()
 same as reset
 
int clearArray (int len) override
 consumes len bytes and moves current data to the beginning
 
Tdata ()
 Provides address of actual data.
 
bool isEmpty ()
 
bool isFull () override
 checks if the buffer is full
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
void onExternalBufferRefilled (void *data, int len)
 notifies that the external buffer has been refilled
 
T peek () override
 peeks the actual entry from the buffer
 
T read () override
 reads a single value
 
virtual int readArray (T data[], int len)
 reads multiple values
 
int readFrames (T data[][2], int len)
 reads multiple values for array of 2 dimensional frames
 
template<int rows, int channels>
int readFrames (T(&data)[rows][channels])
 
void reset () override
 clears the buffer
 
void resize (int size)
 
size_t setAvailable (size_t available_size)
 
void setClearWithZero (bool flag)
 Sets the buffer to 0 on clear.
 
size_t size ()
 
bool write (T sample) override
 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

void setWritePos (int pos)
 

Protected Attributes

Vector< Tbuffer {0}
 
int current_read_pos = 0
 
int current_write_pos = 0
 
bool is_clear_with_zero = false
 
friend NBuffer< T >
 
bool owns_buffer = true
 

Detailed Description

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

A simple Buffer implementation which just uses a (dynamically sized) array.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ SingleBuffer()

template<typename T >
SingleBuffer ( int  size)
inline

Construct a new Single Buffer object.

Parameters
size

Member Function Documentation

◆ address()

template<typename T >
T * address ( )
inlineoverridevirtual

Provides address to beginning of the buffer.

Implements BaseBuffer< T >.

◆ available()

template<typename T >
int available ( )
inlineoverridevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

template<typename T >
int availableForWrite ( )
inlineoverridevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ clearArray()

template<typename T >
int clearArray ( int  len)
inlineoverridevirtual

consumes len bytes and moves current data to the beginning

Reimplemented from BaseBuffer< T >.

◆ isFull()

template<typename T >
bool isFull ( )
inlineoverridevirtual

checks if the buffer is full

Implements BaseBuffer< T >.

◆ peek()

template<typename T >
T peek ( )
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<typename T >
T read ( )
inlineoverridevirtual

reads a single value

Implements BaseBuffer< T >.

◆ readArray()

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

◆ reset()

template<typename T >
void reset ( )
inlineoverridevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ setAvailable()

template<typename T >
size_t setAvailable ( size_t  available_size)
inline

If we load values directly into the address we need to set the avialeble size

◆ size()

template<typename T >
size_t size ( )
inlinevirtual

Implements BaseBuffer< T >.

◆ write()

template<typename T >
bool write ( T  data)
inlineoverridevirtual

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: