arduino-audio-tools
|
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>
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 () |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream | |
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) |
Defines/Changes the output target. | |
void | setOutput (Stream &in) |
same as setStream | |
void | setStream (Print &out) |
same as set Output | |
void | setStream (Stream &in) |
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. | |
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 () |
VolumeStreamConfig | setupAudioInfo (AudioInfo cfg) |
Provides a VolumeStreamConfig based on a AudioInfo. | |
void | setupVectors () |
Resizes the vectors. | |
void | setupVolumeStreamConfig (VolumeStreamConfig cfg) |
Stores the local variable and calculates some max values. | |
VolumeControl & | volumeControl () |
float | volumeValue (float vol) |
Protected Attributes | |
int | _timeout = 10 |
CachedVolumeControl | cached_volume {pot_vc} |
Vector< float > | factor_for_channel |
VolumeStreamConfig | info |
bool | is_notify_active = true |
bool | is_started = false |
LinearVolumeControl | linear_vc {true} |
int | max_channels = 0 |
float | max_value = 32767 |
Vector< AudioInfoSupport * > | notify_vector |
Stream * | p_in =nullptr |
Print * | p_out =nullptr |
SimulatedAudioPot | pot_vc |
RingBuffer< uint8_t > | tmp_in {0} |
RingBuffer< uint8_t > | tmp_out {0} |
float | volume_value = 1.0f |
Vector< float > | volume_values |
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.