arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Classes | 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 file as parameter. More...

#include <Buffers.h>

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

Classes

struct  OffsetInfo
 

Public Member Functions

 RingBufferFile (int size)
 
 RingBufferFile (int size, File &file)
 
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
 
bool begin (File &bufferFile)
 Assigns the p_file to be used.
 
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
 
virtual float levelPercent ()
 Returns the level of the buffer in %.
 
bool peek (T &result) override
 peeks the actual entry from the buffer
 
int peekArray (T data[], int count)
 gets multiple values w/o removing them
 
bool read (T &result) override
 Reads a single value from the buffer.
 
int readArray (T data[], int count) override
 reads multiple values
 
void reset () override
 clears the buffer
 
void resize (int size)
 Defines the capacity.
 
size_t size () override
 Provides the capacity.
 
bool write (T data) override
 write add a single 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)
 Writes the indicated number of objects.
 
bool file_seek (int pos)
 Seeks to the given object position.
 
int file_write (const T *data, int count)
 Reed the indicated number of objects.
 
OffsetInfo getOffset (int pos, int len)
 
void setWritePos (int pos)
 

Protected Attributes

int element_count = 0
 
int max_size = 0
 
friend NBuffer< T >
 
Filep_file = nullptr
 
int read_pos = 0
 
int write_pos = 0
 

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 file as parameter.

Template Parameters
Filefile class
Tthe buffered object type

Member Function Documentation

◆ address()

template<class File , typename T >
T * address ( )
inlineoverridevirtual

returns the address of the start of the physical read buffer

Implements BaseBuffer< T >.

◆ available()

template<class File , typename T >
int available ( )
inlineoverridevirtual

provides the number of entries that are available to read

Implements BaseBuffer< T >.

◆ availableForWrite()

template<class File , typename T >
int availableForWrite ( )
inlineoverridevirtual

provides the number of entries that are available to write

Implements BaseBuffer< T >.

◆ clearArray()

template<typename T >
virtual int clearArray ( int  len)
inlinevirtualinherited

Removes the next len entries.

Reimplemented in SingleBuffer< T >, SingleBuffer< int16_t >, and SingleBuffer< uint8_t >.

◆ getOffset()

template<class File , typename T >
OffsetInfo getOffset ( int  pos,
int  len 
)
inlineprotected

Get positons and sizes to handle overflow wrapping to prevent writing past max_size

◆ isFull()

template<class File , typename T >
bool isFull ( )
inlineoverridevirtual

checks if the buffer is full

Reimplemented from BaseBuffer< T >.

◆ peek()

template<class File , typename T >
bool peek ( T &  result)
inlineoverridevirtual

peeks the actual entry from the buffer

Implements BaseBuffer< T >.

◆ read()

template<class File , typename T >
bool read ( T &  result)
inlineoverridevirtual

Reads a single value from the buffer.

Implements BaseBuffer< T >.

◆ readArray()

template<class File , typename T >
int readArray ( data[],
int  count 
)
inlineoverridevirtual

reads multiple values

Reimplemented from BaseBuffer< T >.

◆ reset()

template<class File , typename T >
void reset ( )
inlineoverridevirtual

clears the buffer

Implements BaseBuffer< T >.

◆ size()

template<class File , typename T >
size_t size ( )
inlineoverridevirtual

Provides the capacity.

Implements BaseBuffer< T >.

◆ write()

template<class File , typename T >
bool write ( data)
inlineoverridevirtual

write add a single entry to the buffer

Implements BaseBuffer< T >.

◆ writeArray()

template<class File , typename T >
int writeArray ( const T  data[],
int  len 
)
inlineoverridevirtual

Fills the data from the buffer.

Reimplemented from BaseBuffer< T >.


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