arduino-audio-tools
Loading...
Searching...
No Matches
ProgressStream Class Referenceabstract

Generic calss to measure the the total bytes which were processed in order to calculate the progress as a percentage of the total size. More...

#include <CodecOpusOgg.h>

Inheritance diagram for ProgressStream:
ModifyingStream ModifyingStream AudioStream AudioStream AudioStream AudioStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream AudioInfoSource AudioInfoSupport BaseStream

Public Member Functions

 ProgressStream ()=default
 ProgressStream ()=default
 ProgressStream (AudioStream &stream)
 ProgressStream (AudioStream &stream)
 ProgressStream (Print &print)
 ProgressStream (Print &print)
 ProgressStream (Stream &stream)
 ProgressStream (Stream &stream)
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfoOut ()
virtual AudioInfo audioInfoOut ()
int available () override
int available () override
virtual int availableForWrite () override
 Provides the nubmer of bytes we can write.
virtual int availableForWrite () override
 Provides the nubmer of bytes we can write.
bool begin () override
bool begin () override
bool begin (ProgressStreamInfo info)
bool begin (ProgressStreamInfo info)
bool begin (size_t len)
bool begin (size_t len)
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
ProgressStreamInfo & defaultConfig ()
ProgressStreamInfo & defaultConfig ()
virtual void end ()
virtual void end ()
virtual void flush () override
virtual void flush () override
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
virtual operator bool ()
virtual operator bool ()
float percentage ()
 Provides the processed percentage: If no size has been defined we return 0.
float percentage ()
 Provides the processed percentage: If no size has been defined we return 0.
size_t processedBytes ()
 Provides the number of processed bytes.
size_t processedBytes ()
 Provides the number of processed bytes.
size_t processedSecs ()
 Provides the number of processed seconds.
size_t processedSecs ()
 Provides the number of processed seconds.
size_t readBytes (uint8_t *data, size_t len) override
 Provides the data from all streams mixed together.
size_t readBytes (uint8_t *data, size_t len) override
 Provides the data from all streams mixed together.
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
void setAudioInfo (AudioInfo info) override
 Defines the input AudioInfo.
void setAudioInfo (AudioInfo info) override
 Defines the input AudioInfo.
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
virtual void setOutput (AudioOutput &out)
 Defines/Changes the output target and registers for audio change notifications.
virtual void setOutput (AudioOutput &out)
 Defines/Changes the output target and registers for audio change notifications.
virtual void setOutput (Print &out)=0
 Defines/Changes the output target.
virtual void setOutput (Print &out)=0
 Defines/Changes the output target.
void setPrint (Print &print)
void setPrint (Print &print)
void setSize (size_t len)
 Updates the total size and restarts the percent calculation.
void setSize (size_t len)
 Updates the total size and restarts the percent calculation.
virtual void setStream (AudioStream &io)
 Defines/Changes the input & output and registers for audio change notifications.
void setStream (Print &print)
void setStream (Print &print)
void setStream (Stream &stream) override
 Defines/Changes the input & output.
void setStream (Stream &stream) override
 Defines/Changes the input & output.
void setWriteBufferSize (int size)
void setWriteBufferSize (int size)
size_t size ()
 Provides the current total size (defined by setSize).
size_t size ()
 Provides the current total size (defined by setSize).
size_t totalBytes ()
 Provides the total_size provided in the configuration.
size_t totalBytes ()
 Provides the total_size provided in the configuration.
size_t totalSecs ()
 Converts the totalBytes() to seconds.
size_t totalSecs ()
 Converts the totalBytes() to seconds.
virtual size_t write (uint8_t ch) override
virtual size_t write (const uint8_t *data, size_t len) override
 Writes raw PCM audio data, which will be the input for the volume control.
virtual size_t write (const uint8_t *data, size_t len) override
 Writes raw PCM audio data, which will be the input for the volume control.
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).

Protected Member Functions

size_t byteRate ()
size_t byteRate ()
size_t measure (size_t len)
size_t measure (size_t len)
virtual int not_supported (int out, const char *msg="")
virtual int not_supported (int out, const char *msg="")
void notifyAudioChange (AudioInfo info)
void notifyAudioChange (AudioInfo info)
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
AudioInfo info
bool is_notify_active = true
Vector< AudioInfoSupport * > notify_vector
AudioInfoSupport * p_info_from = nullptr
Print * p_print = nullptr
Stream * p_stream = nullptr
ProgressStreamInfo progress_info
RingBuffer< uint8_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
size_t total_processed = 0
int write_buffer_size = 8

Detailed Description

Generic calss to measure the the total bytes which were processed in order to calculate the progress as a percentage of the total size.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ProgressStream() [1/8]

ProgressStream ( )
default

◆ ProgressStream() [2/8]

ProgressStream ( Print & print)
inline

◆ ProgressStream() [3/8]

ProgressStream ( Stream & stream)
inline

◆ ProgressStream() [4/8]

ProgressStream ( AudioStream & stream)
inline

◆ ProgressStream() [5/8]

ProgressStream ( )
default

◆ ProgressStream() [6/8]

ProgressStream ( Print & print)
inline

◆ ProgressStream() [7/8]

ProgressStream ( Stream & stream)
inline

◆ ProgressStream() [8/8]

ProgressStream ( AudioStream & stream)
inline

Member Function Documentation

◆ addNotifyAudioChange() [1/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ addNotifyAudioChange() [2/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ audioInfo() [1/2]

◆ audioInfo() [2/2]

◆ audioInfoOut() [1/2]

◆ audioInfoOut() [2/2]

◆ available() [1/2]

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ available() [2/2]

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite() [1/2]

virtual int availableForWrite ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from BaseStream.

◆ availableForWrite() [2/2]

virtual int availableForWrite ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from BaseStream.

◆ begin() [1/6]

bool begin ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [2/6]

bool begin ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [3/6]

bool begin ( ProgressStreamInfo info)
inline

◆ begin() [4/6]

bool begin ( ProgressStreamInfo info)
inline

◆ begin() [5/6]

bool begin ( size_t len)
inline

Updates the total size and restarts the percent calculation: Same as calling setSize()

◆ begin() [6/6]

bool begin ( size_t len)
inline

Updates the total size and restarts the percent calculation: Same as calling setSize()

◆ byteRate() [1/2]

size_t byteRate ( )
inlineprotected

◆ byteRate() [2/2]

size_t byteRate ( )
inlineprotected

◆ clearNotifyAudioChange() [1/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clearNotifyAudioChange() [2/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ defaultConfig() [1/2]

ProgressStreamInfo & defaultConfig ( )
inline

◆ defaultConfig() [2/2]

ProgressStreamInfo & defaultConfig ( )
inline

◆ end() [1/2]

virtual void end ( )
inlinevirtualinherited

Reimplemented in A2DPStream, AbstractURLStream, AdapterAudioOutputToAudioStream, AdaptiveResamplingStream, AnalogAudioStream, AdapterAudioOutputToAudioStream, AudioStreamWrapper, AudioStreamWrapper, CallbackStream, CallbackStream, CatStream, CatStream, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, InputMixer< T, SumT >, InputMixer< T, SumT >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, TimerCallbackAudioStream, TimerCallbackAudioStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, AudioBLEServer, AudioBLEStream, AudioEffectStream, AudioEffectStreamT< T >, AudioFFTBase, AudioKitStream, AudioLoRa, AudioMP34DT05, AudioStreamWrapper, AutomaticGainControlStream, BufferedTaskStream, CallbackStream, CatStream, ChannelFormatConverterStream, DynamicMemoryStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, ESPNowStream, FaustStream< DSP >, FileLoopT< FileType >, FileLoopT< File >, FilteredStream< T, TF >, FormatConverterStream, GeneratedSoundStream< T >, GoertzelStream, HLSStreamT< URLStream >, HLSStreamT< URLStreamESP32 >, HttpRequest, I2SCodecStream, I2SStream, ICYStreamT< T >, ICYStreamT< URLStream >, ICYStreamT< URLStreamESP32 >, InputMerge< T >, InputMixer< T, SumT >, MemoryStream, MiniAudioStream, MozziStream, NRF24Stream, NumberFormatConverterStream, Pipeline, Pipeline::ModifyingStreamAdapter, PortAudioStream, PureDataStream, QueueStream< T >, ReformatBaseStream, SPDIFOutput, SPIAudioSlave, StdioStream, SupportedRatesStream, TimerCallbackAudioStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, URLStreamESP32, USBAudioDeviceBase, USBAudioHostBase, VolumeStream, VS1053Stream, and WM8960Stream.

◆ end() [2/2]

virtual void end ( )
inlinevirtualinherited

Reimplemented in A2DPStream, AbstractURLStream, AdapterAudioOutputToAudioStream, AdaptiveResamplingStream, AnalogAudioStream, AdapterAudioOutputToAudioStream, AudioStreamWrapper, AudioStreamWrapper, CallbackStream, CallbackStream, CatStream, CatStream, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, InputMixer< T, SumT >, InputMixer< T, SumT >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, TimerCallbackAudioStream, TimerCallbackAudioStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, AudioBLEServer, AudioBLEStream, AudioEffectStream, AudioEffectStreamT< T >, AudioFFTBase, AudioKitStream, AudioLoRa, AudioMP34DT05, AudioStreamWrapper, AutomaticGainControlStream, BufferedTaskStream, CallbackStream, CatStream, ChannelFormatConverterStream, DynamicMemoryStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, ESPNowStream, FaustStream< DSP >, FileLoopT< FileType >, FileLoopT< File >, FilteredStream< T, TF >, FormatConverterStream, GeneratedSoundStream< T >, GoertzelStream, HLSStreamT< URLStream >, HLSStreamT< URLStreamESP32 >, HttpRequest, I2SCodecStream, I2SStream, ICYStreamT< T >, ICYStreamT< URLStream >, ICYStreamT< URLStreamESP32 >, InputMerge< T >, InputMixer< T, SumT >, MemoryStream, MiniAudioStream, MozziStream, NRF24Stream, NumberFormatConverterStream, Pipeline, Pipeline::ModifyingStreamAdapter, PortAudioStream, PureDataStream, QueueStream< T >, ReformatBaseStream, SPDIFOutput, SPIAudioSlave, StdioStream, SupportedRatesStream, TimerCallbackAudioStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, URLStreamESP32, USBAudioDeviceBase, USBAudioHostBase, VolumeStream, VS1053Stream, and WM8960Stream.

◆ flush() [1/2]

◆ flush() [2/2]

◆ isNotifyActive() [1/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isNotifyActive() [2/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ measure() [1/2]

size_t measure ( size_t len)
inlineprotected

◆ measure() [2/2]

size_t measure ( size_t len)
inlineprotected

◆ not_supported() [1/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ not_supported() [2/2]

virtual int not_supported ( int out,
const char * msg = "" )
inlineprotectedvirtualinherited

◆ notifyAudioChange() [1/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ notifyAudioChange() [2/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ operator bool() [1/2]

◆ operator bool() [2/2]

◆ percentage() [1/2]

float percentage ( )
inline

Provides the processed percentage: If no size has been defined we return 0.

◆ percentage() [2/2]

float percentage ( )
inline

Provides the processed percentage: If no size has been defined we return 0.

◆ processedBytes() [1/2]

size_t processedBytes ( )
inline

Provides the number of processed bytes.

◆ processedBytes() [2/2]

size_t processedBytes ( )
inline

Provides the number of processed bytes.

◆ processedSecs() [1/2]

size_t processedSecs ( )
inline

Provides the number of processed seconds.

◆ processedSecs() [2/2]

size_t processedSecs ( )
inline

Provides the number of processed seconds.

◆ readBytes() [1/2]

size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Provides the data from all streams mixed together.

Reimplemented from AudioStream.

◆ readBytes() [2/2]

size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

Provides the data from all streams mixed together.

Reimplemented from AudioStream.

◆ readSilence() [1/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ readSilence() [2/2]

virtual size_t readSilence ( uint8_t * buffer,
size_t length )
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ 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().

◆ removeNotifyAudioChange() [1/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ removeNotifyAudioChange() [2/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

◆ setAudioInfo() [1/2]

void setAudioInfo ( AudioInfo info)
inlineoverridevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setAudioInfo() [2/2]

void setAudioInfo ( AudioInfo info)
inlineoverridevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setNotifyActive() [1/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setNotifyActive() [2/2]

void setNotifyActive ( bool flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active).

◆ setOutput() [1/4]

virtual void setOutput ( AudioOutput & out)
inlinevirtualinherited

Defines/Changes the output target and registers for audio change notifications.

Reimplemented in AudioInputMonitor, AudioInputMonitor, EncodedAudioStream, ReformatBaseStream, TimedStream, VolumeMeter, and VolumeMeter.

◆ setOutput() [2/4]

virtual void setOutput ( AudioOutput & out)
inlinevirtualinherited

Defines/Changes the output target and registers for audio change notifications.

Reimplemented in AudioInputMonitor, AudioInputMonitor, EncodedAudioStream, ReformatBaseStream, TimedStream, VolumeMeter, and VolumeMeter.

◆ setOutput() [3/4]

◆ setOutput() [4/4]

◆ setPrint() [1/2]

void setPrint ( Print & print)
inline

◆ setPrint() [2/2]

void setPrint ( Print & print)
inline

◆ setSize() [1/2]

void setSize ( size_t len)
inline

Updates the total size and restarts the percent calculation.

◆ setSize() [2/2]

void setSize ( size_t len)
inline

Updates the total size and restarts the percent calculation.

◆ setStream() [1/5]

virtual void setStream ( AudioStream & io)
inlinevirtualinherited

Defines/Changes the input & output and registers for audio change notifications.

Reimplemented in AudioInputMonitor, AudioInputMonitor, EncodedAudioStream, ReformatBaseStream, TimedStream, VolumeMeter, and VolumeMeter.

◆ setStream() [2/5]

void setStream ( Print & print)
inline

◆ setStream() [3/5]

void setStream ( Print & print)
inline

◆ setStream() [4/5]

void setStream ( Stream & in)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ setStream() [5/5]

void setStream ( Stream & in)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ size() [1/2]

size_t size ( )
inline

Provides the current total size (defined by setSize).

◆ size() [2/2]

size_t size ( )
inline

Provides the current total size (defined by setSize).

◆ totalBytes() [1/2]

size_t totalBytes ( )
inline

Provides the total_size provided in the configuration.

◆ totalBytes() [2/2]

size_t totalBytes ( )
inline

Provides the total_size provided in the configuration.

◆ totalSecs() [1/2]

size_t totalSecs ( )
inline

Converts the totalBytes() to seconds.

◆ totalSecs() [2/2]

size_t totalSecs ( )
inline

Converts the totalBytes() to seconds.

◆ write() [1/3]

◆ write() [2/3]

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

Writes raw PCM audio data, which will be the input for the volume control.

Reimplemented from AudioStream.

◆ write() [3/3]

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

Writes raw PCM audio data, which will be the input for the volume control.

Reimplemented from AudioStream.

◆ writeSilence() [1/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

◆ writeSilence() [2/2]

virtual void writeSilence ( size_t len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector< AudioInfoSupport * > notify_vector
protectedinherited

◆ p_info_from

AudioInfoSupport * p_info_from = nullptr
protected

◆ p_print

Print * p_print = nullptr
protected

◆ p_stream

Stream * p_stream = nullptr
protected

◆ progress_info

ProgressStreamInfo progress_info
protected

◆ tmp_in

RingBuffer< uint8_t > tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer< uint8_t > tmp_out {0}
protectedinherited

◆ total_processed

size_t total_processed = 0
protected

◆ write_buffer_size

int write_buffer_size = 8
protectedinherited

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