arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

Adjust the volume of the related input or output: To work properly the class needs to know the bits per sample and number of channels! AudioChanges are forwareded to the related Print or Stream class. More...

#include <VolumeStream.h>

Inheritance diagram for VolumeStream:
ModifyingStream VolumeSupport AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 VolumeStream ()=default
 Default Constructor.
 
 VolumeStream (AudioOutput &out)
 Constructor which assigns Print output.
 
 VolumeStream (AudioStream &io)
 Constructor which assigns Stream input or output.
 
 VolumeStream (Print &out)
 Constructor which assigns Print output.
 
 VolumeStream (Stream &in)
 Constructor which assigns Stream input or output.
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
virtual int available () 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 (AudioInfo cfg)
 
bool begin (VolumeStreamConfig cfg)
 starts the processing
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
VolumeStreamConfig defaultConfig ()
 
void end () override
 
virtual void flush () override
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
virtual size_t readBytes (uint8_t *data, size_t len) override
 Read raw PCM audio data, which will be the input for the volume control.
 
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.
 
void resetVolumeControl ()
 Resets the volume control to use the standard logic.
 
void setAudioInfo (AudioInfo cfg) override
 Detines the Audio info - The bits_per_sample are critical to work properly!
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setOutput (Print &out) override
 Defines/Changes the output target.
 
void setOutput (Stream &in)
 same as setStream

 
void setStream (Print &out)
 same as set Output
 
void setStream (Stream &in) override
 Defines/Changes the input & output.
 
bool setVolume (float vol) override
 Defines the volume for all channels: needs to be in the range of 0 to 1.0 (if allow boost has not been set)
 
bool setVolume (float vol, int channel)
 Sets the volume for one channel.
 
void setVolumeControl (VolumeControl &vc)
 Defines the volume control logic.
 
void setWriteBufferSize (int size)
 
float volume () override
 Provides the current (avg) volume accross all channels.
 
float volume (int channel)
 Provides the current volume setting for the indicated channel.
 
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 (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

void applyVolume (const uint8_t *buffer, size_t size)
 
void applyVolume16 (int16_t *data, size_t size)
 
void applyVolume24 (int24_t *data, size_t size)
 
void applyVolume32 (int32_t *data, size_t size)
 
float factorForChannel (int channel)
 
bool isAllChannelsFullVolume ()
 
bool isVolumeUpdate ()
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
void resizeVectors (int channels)
 Resizes the vectors.
 
void setVolumeStreamConfig (VolumeStreamConfig cfg)
 Stores the local variable and calculates some max values.
 
VolumeStreamConfig toVolumeStreamConfig (AudioInfo cfg)
 Provides a VolumeStreamConfig based on a AudioInfo.
 
VolumeControlvolumeControl ()
 
float volumeValue (float vol)
 

Protected Attributes

int _timeout = 10
 
CachedVolumeControl cached_volume {pot_vc}
 
Vector< floatfactor_for_channel
 
VolumeStreamConfig info
 
bool is_notify_active = true
 
bool is_started = false
 
LinearVolumeControl linear_vc {true}
 
float max_value = 32767
 
Vector< AudioInfoSupport * > notify_vector
 
Streamp_in =nullptr
 
Printp_out =nullptr
 
SimulatedAudioPot pot_vc
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
float volume_value = 1.0f
 
Vector< floatvolume_values
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Adjust the volume of the related input or output: To work properly the class needs to know the bits per sample and number of channels! AudioChanges are forwareded to the related Print or Stream class.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ VolumeStream() [1/5]

VolumeStream ( )
default

Default Constructor.

◆ VolumeStream() [2/5]

VolumeStream ( Print out)
inline

Constructor which assigns Print output.

◆ VolumeStream() [3/5]

VolumeStream ( Stream in)
inline

Constructor which assigns Stream input or output.

◆ VolumeStream() [4/5]

VolumeStream ( AudioOutput out)
inline

Constructor which assigns Print output.

◆ VolumeStream() [5/5]

VolumeStream ( AudioStream io)
inline

Constructor which assigns Stream input or output.

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ applyVolume()

void applyVolume ( const uint8_t buffer,
size_t  size 
)
inlineprotected

◆ applyVolume16()

void applyVolume16 ( int16_t data,
size_t  size 
)
inlineprotected

◆ applyVolume24()

void applyVolume24 ( int24_t data,
size_t  size 
)
inlineprotected

◆ applyVolume32()

void applyVolume32 ( int32_t data,
size_t  size 
)
inlineprotected

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

virtual int available ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from BaseStream.

◆ begin() [1/3]

bool begin ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [2/3]

bool begin ( AudioInfo  cfg)
inline

◆ begin() [3/3]

bool begin ( VolumeStreamConfig  cfg)
inline

starts the processing

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ defaultConfig()

VolumeStreamConfig defaultConfig ( )
inline

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ factorForChannel()

float factorForChannel ( int  channel)
inlineprotected

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ isAllChannelsFullVolume()

bool isAllChannelsFullVolume ( )
inlineprotected

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isVolumeUpdate()

bool isVolumeUpdate ( )
inlineprotected

◆ not_supported()

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

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readBytes()

virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

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

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

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

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

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

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ resetVolumeControl()

void resetVolumeControl ( )
inline

Resets the volume control to use the standard logic.

◆ resizeVectors()

void resizeVectors ( int  channels)
inlineprotected

Resizes the vectors.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  cfg)
inlineoverridevirtual

Detines the Audio info - The bits_per_sample are critical to work properly!

Reimplemented from AudioStream.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setOutput() [1/2]

void setOutput ( Print out)
inlineoverridevirtual

Defines/Changes the output target.

Implements ModifyingStream.

◆ setOutput() [2/2]

void setOutput ( Stream in)
inline

same as setStream

◆ setStream() [1/2]

void setStream ( Print out)
inline

same as set Output

◆ setStream() [2/2]

void setStream ( Stream in)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ setVolume() [1/2]

bool setVolume ( float  vol)
inlineoverridevirtual

Defines the volume for all channels: needs to be in the range of 0 to 1.0 (if allow boost has not been set)

Reimplemented from VolumeSupport.

◆ setVolume() [2/2]

bool setVolume ( float  vol,
int  channel 
)
inline

Sets the volume for one channel.

◆ setVolumeControl()

void setVolumeControl ( VolumeControl vc)
inline

Defines the volume control logic.

◆ setVolumeStreamConfig()

void setVolumeStreamConfig ( VolumeStreamConfig  cfg)
inlineprotected

Stores the local variable and calculates some max values.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ toVolumeStreamConfig()

VolumeStreamConfig toVolumeStreamConfig ( AudioInfo  cfg)
inlineprotected

Provides a VolumeStreamConfig based on a AudioInfo.

◆ volume() [1/2]

float volume ( )
inlineoverridevirtual

Provides the current (avg) volume accross all channels.

Reimplemented from VolumeSupport.

◆ volume() [2/2]

float volume ( int  channel)
inline

Provides the current volume setting for the indicated channel.

◆ volumeControl()

VolumeControl & volumeControl ( )
inlineprotected

◆ volumeValue()

float volumeValue ( float  vol)
inlineprotected

◆ write() [1/2]

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() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ cached_volume

CachedVolumeControl cached_volume {pot_vc}
protected

◆ factor_for_channel

Vector<float> factor_for_channel
protected

◆ info

VolumeStreamConfig info
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_started

bool is_started = false
protected

◆ linear_vc

LinearVolumeControl linear_vc {true}
protected

◆ max_value

float max_value = 32767
protected

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_in

Stream* p_in =nullptr
protected

◆ p_out

Print* p_out =nullptr
protected

◆ pot_vc

SimulatedAudioPot pot_vc
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ volume_value

float volume_value = 1.0f
protectedinherited

◆ volume_values

Vector<float> volume_values
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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