arduino-audio-tools
Loading...
Searching...
No Matches
DynamicMemoryStream Class Reference

MemoryStream which is written and read using the internal RAM. For each write the data is allocated on the heap. More...

#include <CodecOpusOgg.h>

Inheritance diagram for DynamicMemoryStream:
BaseStream BaseStream Stream Stream Stream Stream Print Print Print Print Print Print Print Print

Public Member Functions

 DynamicMemoryStream ()=default
 DynamicMemoryStream ()=default
 DynamicMemoryStream (bool isLoop, int defaultBufferSize=125, int maxRecords=0)
 DynamicMemoryStream (bool isLoop, int defaultBufferSize=125, int maxRecords=0)
void assign (DynamicMemoryStream &ref)
void assign (DynamicMemoryStream &ref)
virtual int available () override
virtual int available () override
virtual int availableForWrite () override
virtual int availableForWrite () override
virtual bool begin () override
 Intializes the processing.
virtual bool begin () override
 Intializes the processing.
void clear ()
void clear ()
virtual void end () override
virtual void end () override
virtual void flush () override
virtual void flush () override
size_t getPos ()
 Returns the current read position.
size_t getPos ()
 Returns the current read position.
List< DataNode * > & list ()
List< DataNode * > & list ()
 operator bool ()
 operator bool ()
template<typename T>
void postProcessSmoothTransition (int channels, float factor=0.01, int remove=0)
 Post processing after the recording. We add a smooth transition at the beginning and at the end.
template<typename T>
void postProcessSmoothTransition (int channels, float factor=0.01, int remove=0)
 Post processing after the recording. We add a smooth transition at the beginning and at the end.
virtual size_t readBytes (uint8_t *data, size_t len) override
virtual size_t readBytes (uint8_t *data, size_t len) override
void rewind ()
 Sets the read position to the beginning.
void rewind ()
 Sets the read position to the beginning.
void setConsumeOnRead (bool consume)
 Enable or disable consuming reads (remove records as they are read).
void setConsumeOnRead (bool consume)
 Enable or disable consuming reads (remove records as they are read).
virtual void setLoop (bool loop)
 Automatically rewinds to the beginning when reaching the end.
virtual void setLoop (bool loop)
 Automatically rewinds to the beginning when reaching the end.
void setMaxRecords (int max_records)
void setMaxRecords (int max_records)
void setWriteBufferSize (int size)
void setWriteBufferSize (int size)
size_t size ()
size_t size ()
virtual size_t write (uint8_t ch) override
virtual size_t write (const uint8_t *data, size_t len) override
virtual size_t write (const uint8_t *data, size_t len) override

Protected Member Functions

void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

Protected Attributes

int _timeout = 10
bool alloc_failed = false
List< DataNode * > audio_list
bool consume_on_read = false
int default_buffer_size = 125
bool is_loop = false
List< DataNode * >::Iterator it = audio_list.end()
int max_records = 0
size_t read_pos = 0
RingBuffer< uint8_t > temp_audio {0}
RingBuffer< uint8_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
size_t total_available = 0
int write_buffer_size = 8

Detailed Description

MemoryStream which is written and read using the internal RAM. For each write the data is allocated on the heap.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ DynamicMemoryStream() [1/4]

DynamicMemoryStream ( )
default

◆ DynamicMemoryStream() [2/4]

DynamicMemoryStream ( bool isLoop,
int defaultBufferSize = 125,
int maxRecords = 0 )
inline

◆ DynamicMemoryStream() [3/4]

DynamicMemoryStream ( )
default

◆ DynamicMemoryStream() [4/4]

DynamicMemoryStream ( bool isLoop,
int defaultBufferSize = 125,
int maxRecords = 0 )
inline

Member Function Documentation

◆ assign() [1/2]

void assign ( DynamicMemoryStream & ref)
inline

◆ assign() [2/2]

void assign ( DynamicMemoryStream & ref)
inline

◆ available() [1/2]

virtual int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ available() [2/2]

virtual int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite() [1/2]

virtual int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite() [2/2]

virtual int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

virtual bool begin ( )
inlineoverridevirtual

Intializes the processing.

Reimplemented from BaseStream.

◆ begin() [2/2]

virtual bool begin ( )
inlineoverridevirtual

Intializes the processing.

Reimplemented from BaseStream.

◆ clear() [1/2]

void clear ( )
inline

◆ clear() [2/2]

void clear ( )
inline

◆ end() [1/2]

virtual void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ end() [2/2]

virtual void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ flush() [1/2]

◆ flush() [2/2]

◆ getPos() [1/2]

size_t getPos ( )
inline

Returns the current read position.

◆ getPos() [2/2]

size_t getPos ( )
inline

Returns the current read position.

◆ list() [1/2]

List< DataNode * > & list ( )
inline

◆ list() [2/2]

List< DataNode * > & list ( )
inline

◆ operator bool() [1/2]

operator bool ( )
inlineinherited

◆ operator bool() [2/2]

operator bool ( )
inlineinherited

◆ postProcessSmoothTransition() [1/2]

template<typename T>
void postProcessSmoothTransition ( int channels,
float factor = 0.01,
int remove = 0 )
inline

Post processing after the recording. We add a smooth transition at the beginning and at the end.

Template Parameters
T
Parameters
factor

◆ postProcessSmoothTransition() [2/2]

template<typename T>
void postProcessSmoothTransition ( int channels,
float factor = 0.01,
int remove = 0 )
inline

Post processing after the recording. We add a smooth transition at the beginning and at the end.

Template Parameters
T
Parameters
factor

◆ readBytes() [1/2]

virtual size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Implements BaseStream.

◆ readBytes() [2/2]

virtual size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Implements BaseStream.

◆ refillReadBuffer() [1/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ refillReadBuffer() [2/2]

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().

◆ rewind() [1/2]

void rewind ( )
inline

Sets the read position to the beginning.

◆ rewind() [2/2]

void rewind ( )
inline

Sets the read position to the beginning.

◆ setConsumeOnRead() [1/2]

void setConsumeOnRead ( bool consume)
inline

Enable or disable consuming reads (remove records as they are read).

◆ setConsumeOnRead() [2/2]

void setConsumeOnRead ( bool consume)
inline

Enable or disable consuming reads (remove records as they are read).

◆ setLoop() [1/2]

virtual void setLoop ( bool loop)
inlinevirtual

Automatically rewinds to the beginning when reaching the end.

◆ setLoop() [2/2]

virtual void setLoop ( bool loop)
inlinevirtual

Automatically rewinds to the beginning when reaching the end.

◆ setMaxRecords() [1/2]

void setMaxRecords ( int max_records)
inline

◆ setMaxRecords() [2/2]

void setMaxRecords ( int max_records)
inline

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ size() [1/2]

size_t size ( )
inline

◆ size() [2/2]

size_t size ( )
inline

◆ write() [1/3]

◆ write() [2/3]

virtual size_t write ( const uint8_t * data,
size_t len )
inlineoverridevirtual

Implements BaseStream.

◆ write() [3/3]

virtual size_t write ( const uint8_t * data,
size_t len )
inlineoverridevirtual

Implements BaseStream.

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ alloc_failed

bool alloc_failed = false
protected

◆ audio_list

List< DataNode * > audio_list
protected

◆ consume_on_read

bool consume_on_read = false
protected

◆ default_buffer_size

int default_buffer_size = 125
protected

◆ is_loop

bool is_loop = false
protected

◆ it

List< DataNode * >::Iterator it = audio_list.end()
protected

◆ max_records

int max_records = 0
protected

◆ read_pos

size_t read_pos = 0
protected

◆ temp_audio

RingBuffer< uint8_t > temp_audio {0}
protected

◆ tmp_in

RingBuffer< uint8_t > tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer< uint8_t > tmp_out {0}
protectedinherited

◆ total_available

size_t total_available = 0
protected

◆ write_buffer_size

int write_buffer_size = 8
protectedinherited

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