arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
audio_tools::VolumeStream Class Reference

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! More...

#include <AudioStreams.h>

Inheritance diagram for audio_tools::VolumeStream:
audio_tools::AudioStreamX audio_tools::AudioStream audio_tools::Stream audio_tools::AudioBaseInfoDependent audio_tools::AudioBaseInfoSource audio_tools::Print

Public Member Functions

 VolumeStream ()=default
 Default Constructor.
 
 VolumeStream (Print &out)
 Constructor which assigns Print output.
 
 VolumeStream (Stream &in)
 Constructor which assigns Stream input or output.
 
 ~VolumeStream ()
 Destructor.
 
virtual int available () override
 Provides the nubmer of bytes we can write. More...
 
virtual int availableForWrite () override
 Provides the nubmer of bytes we can write. More...
 
bool begin (AudioBaseInfo cfg)
 
bool begin (VolumeStreamConfig cfg)
 starts the processing
 
VolumeStreamConfig defaultConfig ()
 
void end () override
 
virtual size_t readBytes (uint8_t *buffer, size_t length) override
 Read raw PCM audio data, which will be the input for the volume control. More...
 
void resetVolumeControl ()
 Resets the volume control to use the standard logic.
 
void setAudioInfo (AudioBaseInfo cfg) override
 Detines the Audio info - The bits_per_sample are critical to work properly! More...
 
void setTarget (Print &out)
 
void setTarget (Stream &in)
 
void setVolume (float vol)
 Defines the volume for all channels: needs to be in the range of 0 to 1.0.
 
void setVolume (float vol, int channel)
 Sets the volume for one channel.
 
void setVolumeControl (VolumeControl &vc)
 Defines the volume control logic.
 
float volume ()
 Provides the current volume setting.
 
float volume (int channel)
 Provides the current volume setting for the indicated channel.
 
virtual size_t write (const uint8_t *buffer, size_t size) override
 Writes raw PCM audio data, which will be the input for the volume control. More...
 
- Public Member Functions inherited from audio_tools::AudioStreamX
 AudioStreamX (AudioStreamX const &)=delete
 
virtual int available () override
 
AudioStreamXoperator= (AudioStreamX const &)=delete
 
virtual int peek () override
 
virtual int read () override
 
virtual size_t readBytes (uint8_t *buffer, size_t length) override
 
virtual size_t write (const uint8_t *buffer, size_t size) override
 
virtual size_t write (uint8_t) override
 
- Public Member Functions inherited from audio_tools::AudioStream
 AudioStream (AudioStream const &)=delete
 
virtual AudioBaseInfo audioInfo () override
 
virtual int availableForWrite () override
 
virtual bool begin ()
 
virtual void end ()
 
virtual void flush () override
 
 operator bool ()
 
AudioStreamoperator= (AudioStream const &)=delete
 
virtual size_t readBytes (char *buffer, size_t length)
 
virtual size_t readBytes (uint8_t *buffer, size_t length) STREAM_WRITE_OVERRIDE=0
 
virtual void setAudioInfo (AudioBaseInfo info) override
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi) override
 
virtual StreamtoStreamPointer ()
 
virtual size_t write (const uint8_t *buffer, size_t size) override=0
 
- Public Member Functions inherited from audio_tools::Stream
virtual int available ()
 
virtual int peek ()
 
virtual int read ()
 
virtual size_t readBytes (uint8_t *buffer, size_t len)
 
virtual void setTimeout (size_t t)
 
- Public Member Functions inherited from audio_tools::Print
virtual int availableForWrite ()
 
virtual void flush ()
 
virtual int print (char c, PrintCharFmt spec)
 
virtual int print (const char *msg)
 
virtual int print (int number)
 
virtual int println (const char *msg="")
 
virtual size_t write (const char *buffer, size_t size)
 
virtual size_t write (const char *str)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
virtual size_t write (uint8_t ch)
 
- Public Member Functions inherited from audio_tools::AudioBaseInfoDependent
virtual AudioBaseInfo audioInfo ()=0
 
virtual void setAudioInfo (AudioBaseInfo info)=0
 
virtual bool validate (AudioBaseInfo &info)
 
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi)=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)
 
void cleanup ()
 
float factorForChannel (int channel)
 
void setup (float vol)
 
VolumeControlvolumeControl ()
 
float volumeValue (float vol)
 
- Protected Member Functions inherited from audio_tools::AudioStream
virtual int not_supported (int out)
 

Protected Attributes

CachedVolumeControl cached_volume {pot_vc}
 
float * factor_for_channel = nullptr
 
VolumeStreamConfig info
 
bool is_active = false
 
LinearVolumeControl linear_vc {true}
 
int max_channels =0
 
float max_value = 32767
 
Streamp_in =nullptr
 
Printp_out =nullptr
 
SimulatedAudioPot pot_vc
 
float * volume_values = nullptr
 
- Protected Attributes inherited from audio_tools::AudioStream
AudioBaseInfo info
 
AudioBaseInfoDependentp_notify =nullptr
 

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!

Author
Phil Schatzmann

Member Function Documentation

◆ available()

virtual int audio_tools::VolumeStream::available ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from audio_tools::AudioStreamX.

◆ availableForWrite()

virtual int audio_tools::VolumeStream::availableForWrite ( )
inlineoverridevirtual

Provides the nubmer of bytes we can write.

Reimplemented from audio_tools::AudioStream.

◆ end()

void audio_tools::VolumeStream::end ( )
inlineoverridevirtual

Reimplemented from audio_tools::AudioStream.

◆ readBytes()

virtual size_t audio_tools::VolumeStream::readBytes ( uint8_t *  buffer,
size_t  length 
)
inlineoverridevirtual

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

Reimplemented from audio_tools::AudioStreamX.

◆ setAudioInfo()

void audio_tools::VolumeStream::setAudioInfo ( AudioBaseInfo  cfg)
inlineoverridevirtual

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

Reimplemented from audio_tools::AudioStream.

◆ write()

virtual size_t audio_tools::VolumeStream::write ( const uint8_t *  buffer,
size_t  size 
)
inlineoverridevirtual

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

Reimplemented from audio_tools::AudioStreamX.


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