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 phsical read buffer | |
int | available () |
determines the available entries for the current read buffer | |
int | availableForWrite () |
determines the available entries for the write buffer | |
virtual int | bufferCountEmpty () |
Provides the number of entries that are available to write. | |
virtual int | bufferCountFilled () |
Provides the number of entries that are available to read. | |
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 %. | |
bool | peek (T &result) override |
peeks the actual entry from the buffer | |
bool | read (T &result) override |
reads an entry from the buffer | |
virtual int | readArray (T data[], int len) |
reads multiple values | |
void | reset () |
resets all buffers | |
virtual void | resize (int size, int count) |
Resize the buffers by defining a new buffer size and buffer count. | |
unsigned long | sampleRate () |
provides the actual sample rate | |
size_t | size () |
Provides the total capacity (=buffer size * buffer count) | |
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 | |
NBuffer ()=default | |
empty constructor only allowed by subclass | |
virtual bool | addAvailableBuffer (BaseBuffer< T > *buffer) |
virtual bool | addFilledBuffer (BaseBuffer< T > *buffer) |
void | freeMemory () |
virtual BaseBuffer< T > * | getNextAvailableBuffer () |
virtual BaseBuffer< T > * | getNextFilledBuffer () |
void | resetCurrent () |
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} |
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.
|
inlinevirtual |
returns the address of the start of the phsical read buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
determines the available entries for the current read buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
determines the available entries for the write buffer
Implements BaseBuffer< T >.
|
inlinevirtual |
Provides the number of entries that are available to write.
Reimplemented in SynchronizedNBufferRTOST< T >.
|
inlinevirtual |
Provides the number of entries that are available to read.
Reimplemented in SynchronizedNBufferRTOST< T >.
|
inlinevirtualinherited |
Removes the next len entries.
Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.
|
inlinevirtual |
checks if the buffer is full
Reimplemented from BaseBuffer< T >.
|
inlineoverridevirtual |
peeks the actual entry from the buffer
Implements BaseBuffer< T >.
|
inlineoverridevirtual |
reads an entry from the buffer
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
reads multiple values
Reimplemented in RingBufferFile< File, T >, BufferRTOS< T >, SynchronizedBuffer< T >, BufferRP2040T< T >, and NBufferFile< File, T >.
|
inlinevirtual |
resets all buffers
Implements BaseBuffer< T >.
|
inlinevirtual |
Resize the buffers by defining a new buffer size and buffer count.
Reimplemented in SynchronizedNBufferRTOST< T >.
|
inlinevirtual |
Provides the total capacity (=buffer size * buffer count)
Implements BaseBuffer< T >.
Reimplemented in SynchronizedNBufferRTOST< T >.
|
inlinevirtual |
write add an entry to the buffer
Implements BaseBuffer< T >.
|
inlinevirtualinherited |
Fills the buffer data.
Reimplemented in BufferRTOS< T >, SynchronizedBuffer< T >, BufferRP2040T< T >, SingleBuffer< T >, RingBufferFile< File, T >, and NBufferFile< File, T >.