arduino-audio-tools
|
A lock free N buffer. If count=2 we create a DoubleBuffer, if count=3 a TripleBuffer etc. More...
#include <Buffers.h>
Public Member Functions | |
NBuffer (int size, int count) | |
T * | address () |
returns the address of the start of the physical read buffer | |
int | available () |
provides the number of entries that are available to read | |
int | availableForWrite () |
provides the number of entries that are available to write | |
virtual int | bufferCountEmpty () |
virtual int | bufferCountFilled () |
void | clear () |
same as reset | |
virtual int | clearArray (int len) |
Removes the next len entries. | |
bool | isEmpty () |
bool | isFull () |
checks if the buffer is full | |
virtual float | levelPercent () |
Returns the level of the buffer in %. | |
T | peek () |
peeks the actual entry from the buffer | |
T | read () |
reads a single value | |
virtual int | readArray (T data[], int len) |
reads multiple values | |
BaseBuffer< T > & | readEnd () |
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 () |
clears the buffer | |
virtual void | resize (int size, int count) |
unsigned long | sampleRate () |
size_t | size () |
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. | |
BaseBuffer< T > & | writeEnd () |
Protected Member Functions | |
virtual bool | addAvailableBuffer (BaseBuffer< T > *buffer) |
virtual bool | addFilledBuffer (BaseBuffer< T > *buffer) |
void | freeMemory () |
virtual BaseBuffer< T > * | getNextAvailableBuffer () |
virtual BaseBuffer< T > * | getNextFilledBuffer () |
void | resetCurrent () |
void | setWritePos (int pos) |
Protected Attributes | |
BaseBuffer< T > * | actual_read_buffer = nullptr |
BaseBuffer< T > * | actual_write_buffer = nullptr |
QueueFromVector< BaseBuffer< T > * > | available_buffers {0, nullptr} |
uint16_t | buffer_count = 0 |
int | buffer_size = 0 |
QueueFromVector< BaseBuffer< T > * > | filled_buffers {0, nullptr} |
friend | NBuffer< T > |
unsigned long | sample_count = 0 |
unsigned long | start_time = 0 |
A lock free N buffer. If count=2 we create a DoubleBuffer, if count=3 a TripleBuffer etc.