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

An File backed Ring Buffer that we can use to receive streaming audio. We expect an open p_file as parameter. More...

#include <Buffers.h>

Inheritance diagram for RingBufferFile< File, T >:
BaseBuffer< T >

Public Member Functions

 RingBufferFile (bool autoRewind=true)
 
 RingBufferFile (File &file, bool autoRewind=true)
 
T * address () override
 returns the address of the start of the physical read 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
 
virtual int clearArray (int len)
 Removes the next len entries.
 
bool isEmpty ()
 
bool isFull () override
 checks if the buffer is full
 
peek () override
 peeks the actual entry from the buffer
 
read () override
 reads a single value
 
int readArray (T data[], int count) override
 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 setAutoRewind (bool flag)
 
void setFile (File &bufferFile, bool clear=false)
 Assigns the p_file to be used.
 
size_t size () override
 
virtual bool write (T data) override
 write add an entry to the buffer
 
int writeArray (const T data[], int len) override
 Fills the data from the buffer.
 
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 file_read (T *result, int count)
 
void file_seek (int pos)
 
int file_write (const T *data, int count)
 
void setWritePos (int pos)
 

Protected Attributes

bool auto_rewind = true
 
int element_count
 
int max_size = 2147483647
 
friend NBuffer< T >
 
Filep_file = nullptr
 
int read_pos
 
int write_pos
 

Detailed Description

template<class File, typename T>
class audio_tools::RingBufferFile< File, T >

An File backed Ring Buffer that we can use to receive streaming audio. We expect an open p_file as parameter.

If you want to keep the processed data, call setAutoRewind(false) and call p_file->save() when you are done!

Template Parameters
File
T

Member Function Documentation

◆ setAutoRewind()

void setAutoRewind ( bool  flag)
inline

if the full buffer has been consumed we restart from the 0 p_file position Set this value to false if you want to keep the full processed data in the p_file


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