arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SynchronizedNBuffer< T > Class Template Reference

NBuffer which uses some RTOS queues to manage the available and filled buffers. More...

#include <SynchronizedBuffers.h>

Inheritance diagram for SynchronizedNBuffer< T >:
NBuffer< T > BaseBuffer< T >

Public Member Functions

 SynchronizedNBuffer (int bufferSize, int bufferCount, int writeMaxWait=portMAX_DELAY, int readMaxWait=portMAX_DELAY)
 
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
 
int bufferCountEmpty ()
 
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 %.
 
peek ()
 peeks the actual entry from the buffer
 
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
 
void resize (int bufferSize, int bufferCount)
 
unsigned long sampleRate ()
 
void setReadMaxWait (TickType_t ticks)
 
void setWriteMaxWait (TickType_t ticks)
 
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

bool addAvailableBuffer (BaseBuffer< T > *buffer)
 
bool addFilledBuffer (BaseBuffer< T > *buffer)
 
void cleanup ()
 Removes all allocated buffers.
 
void freeMemory ()
 
BaseBuffer< T > * getNextAvailableBuffer ()
 
BaseBuffer< T > * getNextFilledBuffer ()
 
void resetCurrent ()
 
void setWritePos (int pos)
 

Protected Attributes

BaseBuffer< T > * actual_read_buffer = nullptr
 
BaseBuffer< T > * actual_write_buffer = nullptr
 
QueueRTOS< BaseBuffer< T > * > available_buffers {0,portMAX_DELAY,0}
 
int buffer_count = 0
 
int buffer_size = 0
 
QueueRTOS< BaseBuffer< T > * > filled_buffers {0,portMAX_DELAY,0}
 
size_t max_size
 
friend NBuffer< T >
 
size_t read_max_wait
 
unsigned long sample_count = 0
 
unsigned long start_time = 0
 
size_t write_max_wait
 

Detailed Description

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

NBuffer which uses some RTOS queues to manage the available and filled buffers.

Template Parameters
T
COUNTnumber of buffers

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