arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GeneratorFromStream< T > Class Template Reference

An Adapter Class which lets you use any Stream as a Generator. More...

#include <SoundGenerator.h>

Inheritance diagram for GeneratorFromStream< T >:
SoundGenerator< T > VolumeSupport

Public Member Functions

 GeneratorFromStream (Stream &input, int channels=1, float volume=1.0)
 Constructs a new Generator from a Stream object that can be used e.g. as input for AudioEffectss.
 
virtual AudioInfo audioInfo ()
 Provides the AudioInfo.
 
virtual bool begin ()
 
virtual bool begin (AudioInfo info)
 
virtual AudioInfo defaultConfig ()
 Provides the default configuration.
 
virtual void end ()
 ends the processing
 
virtual bool isActive ()
 
virtual size_t readBytes (uint8_t *data, size_t len)
 Provides the data as byte array with the requested number of channels.
 
readSample ()
 Provides a single sample from the stream.
 
virtual void setAudioInfo (AudioInfo info)
 Defines/updates the AudioInfo.
 
void setChannels (int channels)
 
virtual void setFrequency (float frequency)
 Abstract method: not implemented! Just provides an error message...
 
void setStream (Stream &input)
 (Re-)Assigns a stream to the Adapter class
 
virtual bool setVolume (float volume)
 define the actual volume in the range of 0.0f to 1.0f
 
virtual float volume ()
 provides the actual volume in the range of 0.0f to 1.0f
 

Protected Member Functions

size_t readBytesFrames (uint8_t *buffer, size_t lengthBytes, int frames, int channels)
 
size_t readBytesFromBuffer (uint8_t *buffer, size_t lengthBytes, int frame_size, int channels)
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
int channels = 1
 
AudioInfo info
 
float maxValue
 
Streamp_stream = nullptr
 
RingBuffer< uint8_t > ring_buffer {0}
 
float volume_value = 1.0f
 

Detailed Description

template<class T>
class audio_tools::GeneratorFromStream< T >

An Adapter Class which lets you use any Stream as a Generator.

Author
Phil Schatzmann
Template Parameters
T

Constructor & Destructor Documentation

◆ GeneratorFromStream()

template<class T >
GeneratorFromStream ( Stream input,
int  channels = 1,
float  volume = 1.0 
)
inline

Constructs a new Generator from a Stream object that can be used e.g. as input for AudioEffectss.

Parameters
inputStream
channelsnumber of channels of the Stream
volumefactor my which the sample value is multiplied - default 1.0; Use it e.g. to reduce the volume (e.g. with 0.5)

Member Function Documentation

◆ begin() [1/2]

template<class T >
virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/2]

template<class T >
virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ defaultConfig()

template<class T >
virtual AudioInfo defaultConfig ( )
inlinevirtualinherited

◆ end()

template<class T >
virtual void end ( )
inlinevirtualinherited

ends the processing

Reimplemented in GeneratorFromArray< T >.

◆ isActive()

template<class T >
virtual bool isActive ( )
inlinevirtualinherited

Checks if the begin method has been called - after end() isActive returns false

◆ readSample()

template<class T >
T readSample ( )
inlinevirtual

Provides a single sample from the stream.

Implements SoundGenerator< T >.

◆ setAudioInfo()

template<class T >
virtual void setAudioInfo ( AudioInfo  info)
inlinevirtualinherited

Defines/updates the AudioInfo.

Reimplemented in SineWaveGenerator< T >, and SineWaveGenerator< int16_t >.

◆ setFrequency()

template<class T >
virtual void setFrequency ( float  frequency)
inlinevirtualinherited

Abstract method: not implemented! Just provides an error message...

Reimplemented in SineFromTable< T >, SineWaveGenerator< T >, and SineWaveGenerator< int16_t >.

◆ setVolume()

virtual bool setVolume ( float  volume)
inlinevirtualinherited

define the actual volume in the range of 0.0f to 1.0f

Reimplemented in Maximilian, I2SCodecStream, VS1053Stream, VolumeStream, A2DPStream, and AudioPlayer.

◆ volume()

virtual float volume ( )
inlinevirtualinherited

provides the actual volume in the range of 0.0f to 1.0f

Reimplemented in I2SCodecStream, VS1053Stream, AudioPlayer, and VolumeStream.


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