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

We can build a input or an output chain: an input chain starts with setInput(); followed by add() an output chain consinsts of add() and ends with setOutput();. More...

#include <Pipeline.h>

Inheritance diagram for Pipeline:
AudioStream BaseStream AudioInfoSupport AudioInfoSource BaseStream AudioInfoSupport AudioInfoSource Stream Stream Stream Stream Print Print Print Print Print Print Print Print

Classes

struct  ModifyingStreamAdapter
 Support for ModifyingOutput. More...

Public Member Functions

 Pipeline ()=default
 ~Pipeline ()
bool add (ModifyingOutput &out)
 adds a component
bool add (ModifyingStream &io)
 adds a component
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
void addNotifyAudioChange (AudioInfoSupport &bi) override
 Subscribes to notifications on last component of the chain.
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
AudioInfo audioInfoOut () override
 Provides the resulting AudioInfo from the last node.
int available () override
int availableForWrite () override
bool begin () override
 Optional method: Calls begin on all components.
bool begin (AudioInfo info)
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
void end () override
 Calls end on all components.
virtual void flush () override
virtual void flush () override
bool hasComponents ()
 Returns true if we have at least 1 component.
bool isActive ()
 Determines if the pipeline is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isOK ()
 Returns true if pipeline is correctly set up.
ModifyingStream & last ()
 Provides the last component.
 operator bool () override
 Returns true if pipeline is correctly set up and is active.
ModifyingStream & operator[] (int idx)
 Access to the components by index.
size_t readBytes (uint8_t *data, size_t len) override
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 setActive (bool flag)
 Activates/deactivates the pipeline (default is active).
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
void setAudioInfo (AudioInfo newInfo) override
 Defines the AudioInfo for the first node.
bool setInput (AudioStream &in)
 Defines the input for an input pipeline: must be first call before add().
bool setInput (Stream &in)
 Defines the input for an input pipeline: must be first call before add().
void setNotifyActive (bool flag)
 Activates/deactivates notifications.
bool setOutput (AudioOutput &out)
 Defines the output for an output pipeline: must be last call after add().
bool setOutput (AudioStream &out)
 Defines the output for an output pipeline: must be last call after add().
bool setOutput (Print &out)
 Defines the output for an output pipeline: must be last call after add().
void setWriteBufferSize (int size)
void setWriteBufferSize (int size)
int size ()
 Provides the number of components.
virtual size_t write (uint8_t ch) override
size_t write (const uint8_t *data, size_t len) override
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

Stream * getInput ()
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
Vector< ModifyingStream * > cleanup {0}
Vector< ModifyingStream * > components {0}
bool has_input = false
bool has_output = false
AudioInfo info
bool is_active = true
bool is_notify_active = true
bool is_ok = true
Vector< AudioInfoSupport * > notify_vector
AudioStream * p_ai_input = nullptr
AudioInfoSource * p_ai_source = nullptr
AudioOutput * p_out_print = nullptr
AudioStream * p_out_stream = nullptr
Print * p_print = nullptr
Stream * p_stream = nullptr
RingBuffer< uint8_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
int write_buffer_size = 8

Detailed Description

We can build a input or an output chain: an input chain starts with setInput(); followed by add() an output chain consinsts of add() and ends with setOutput();.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ Pipeline()

Pipeline ( )
default

◆ ~Pipeline()

~Pipeline ( )
inline

Member Function Documentation

◆ add() [1/2]

bool add ( ModifyingOutput & out)
inline

adds a component

◆ add() [2/2]

bool add ( ModifyingStream & io)
inline

adds a component

◆ 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]

void addNotifyAudioChange ( AudioInfoSupport & bi)
inlineoverride

Subscribes to notifications on last component of the chain.

◆ audioInfo() [1/2]

◆ audioInfo() [2/2]

◆ audioInfoOut()

AudioInfo audioInfoOut ( )
inlineoverridevirtual

Provides the resulting AudioInfo from the last node.

Reimplemented from AudioInfoSupport.

◆ available()

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Optional method: Calls begin on all components.

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AudioInfo info)
inline

Optional method: Calls begin on all components and setAudioInfo on first coponent to update the full chain

◆ clearNotifyAudioChange() [1/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clearNotifyAudioChange() [2/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ end()

void end ( )
inlineoverridevirtual

Calls end on all components.

Reimplemented from BaseStream.

◆ flush() [1/2]

◆ flush() [2/2]

◆ getInput()

Stream * getInput ( )
inlineprotected

we read from the last node or the defined input: null if no input is available

◆ hasComponents()

bool hasComponents ( )
inline

Returns true if we have at least 1 component.

◆ isActive()

bool isActive ( )
inline

Determines if the pipeline is active.

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

◆ isOK()

bool isOK ( )
inline

Returns true if pipeline is correctly set up.

◆ last()

ModifyingStream & last ( )
inline

Provides the last component.

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

operator bool ( )
inlineoverridevirtual

Returns true if pipeline is correctly set up and is active.

Reimplemented from AudioStream.

◆ operator[]()

ModifyingStream & operator[] ( int idx)
inline

Access to the components by index.

◆ readBytes()

size_t readBytes ( uint8_t * data,
size_t len )
inlineoverridevirtual

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.

◆ setActive()

void setActive ( bool flag)
inline

Activates/deactivates the pipeline (default is active).

◆ setAudioInfo() [1/2]

◆ setAudioInfo() [2/2]

void setAudioInfo ( AudioInfo newInfo)
inlineoverride

Defines the AudioInfo for the first node.

◆ setInput() [1/2]

bool setInput ( AudioStream & in)
inline

Defines the input for an input pipeline: must be first call before add().

◆ setInput() [2/2]

bool setInput ( Stream & in)
inline

Defines the input for an input pipeline: must be first call before add().

◆ setNotifyActive()

void setNotifyActive ( bool flag)
inline

Activates/deactivates notifications.

◆ setOutput() [1/3]

bool setOutput ( AudioOutput & out)
inline

Defines the output for an output pipeline: must be last call after add().

◆ setOutput() [2/3]

bool setOutput ( AudioStream & out)
inline

Defines the output for an output pipeline: must be last call after add().

◆ setOutput() [3/3]

bool setOutput ( Print & out)
inline

Defines the output for an output pipeline: must be last call after add().

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ size()

int size ( )
inline

Provides the number of components.

◆ write() [1/2]

◆ write() [2/2]

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

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

◆ cleanup

Vector<ModifyingStream*> cleanup {0}
protected

◆ components

Vector<ModifyingStream*> components {0}
protected

◆ has_input

bool has_input = false
protected

◆ has_output

bool has_output = false
protected

◆ info

AudioInfo info
protectedinherited

◆ is_active

bool is_active = true
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_ok

bool is_ok = true
protected

◆ notify_vector

Vector< AudioInfoSupport * > notify_vector
protectedinherited

◆ p_ai_input

AudioStream* p_ai_input = nullptr
protected

◆ p_ai_source

AudioInfoSource* p_ai_source = nullptr
protected

◆ p_out_print

AudioOutput* p_out_print = nullptr
protected

◆ p_out_stream

AudioStream* p_out_stream = nullptr
protected

◆ p_print

Print* p_print = nullptr
protected

◆ p_stream

Stream* p_stream = nullptr
protected

◆ tmp_in

RingBuffer< uint8_t > tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer< uint8_t > tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = 8
protectedinherited

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