arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
audio_tools::GeneratorFromStream< T > Class Template Reference

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

#include <SoundGenerator.h>

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

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. More...
 
readSample ()
 Provides a single sample from the stream. More...
 
void setChannels (int channels)
 
void setStream (Stream &input)
 (Re-)Assigns a stream to the Adapter class
 
void setVolume (float factor)
 Multiplies the input with the indicated factor (e.g. )
 
- Public Member Functions inherited from audio_tools::SoundGenerator< T >
virtual AudioBaseInfo audioInfo ()
 
virtual bool begin ()
 
virtual bool begin (AudioBaseInfo info)
 
virtual AudioBaseInfo defaultConfig ()
 
virtual void end ()
 ends the processing
 
virtual bool isActive ()
 Checks if the begin method has been called - after end() isActive returns false.
 
virtual size_t readBytes (uint8_t *buffer, size_t lengthBytes)
 Provides the data as byte array with the requested number of channels.
 
virtual T readSample ()=0
 Provides a single sample. More...
 
virtual size_t readSamples (T *data, size_t sampleCount=512)
 Provides the samples into simple array - which represents 1 channel.
 
virtual size_t readSamples (T src[][2], size_t frameCount)
 Provides the samples into a 2 channel array.
 
virtual void setAudioInfo (AudioBaseInfo info)
 
virtual void setFrequency (uint16_t frequency)
 

Protected Attributes

int channels =1
 
float maxValue
 
Streamp_stream = nullptr
 
int volume =1.0
 
- Protected Attributes inherited from audio_tools::SoundGenerator< T >
bool active = false
 
bool activeWarningIssued = false
 
AudioBaseInfo info
 
int output_channels = 1
 

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 >
audio_tools::GeneratorFromStream< 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

◆ readSample()

template<class T >
T audio_tools::GeneratorFromStream< T >::readSample ( )
inlinevirtual

Provides a single sample from the stream.

Implements audio_tools::SoundGenerator< T >.


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