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

Base class to define the abstract interface for the sound generating classes. More...

#include <SoundGenerator.h>

Inheritance diagram for SoundGenerator< T >:
STKGenerator< stk::Instrmnt, int16_t > STKGenerator< StkCls, int16_t > SineWaveGenerator< int16_t > GeneratorFixedValue< T > GeneratorFromArray< T > GeneratorFromStream< T > GeneratorMixer< T > PinkNoiseGenerator< T > STKGenerator< StkCls, T > SilenceGenerator< T > SineFromTable< T > SineWaveGenerator< T > TestGenerator< T > WhiteNoiseGenerator< T >

Public Member Functions

 SoundGenerator ()
 
virtual ~SoundGenerator ()
 
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.
 
virtual T readSample ()=0
 Provides a single sample.
 
virtual void setAudioInfo (AudioInfo info)
 Defines/updates the AudioInfo.
 
virtual void setFrequency (float frequency)
 Abstract method: not implemented! Just provides an error message...
 
void setPlayTime (uint32_t playMs, uint8_t upPercent=20, uint8_t downPercent=30)
 

Protected Member Functions

T applyRamp (T sample)
 
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)
 
void recalculatePlayTime ()
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
uint32_t currentSample = 0
 
uint8_t downPercent = 40
 
float factor = 1.0f
 
AudioInfo info
 
uint32_t playMs = 0
 
uint32_t playSamples = 0
 
float rampDownDec = 0.0
 
uint32_t rampDownSamples = 0
 
float rampUpInc = 0.0
 
RingBuffer< uint8_tring_buffer {0}
 
uint8_t upPercent = 5
 
uint32_t upSamples = 0
 

Detailed Description

template<class T = int16_t>
class audio_tools::SoundGenerator< T >

Base class to define the abstract interface for the sound generating classes.

Author
Phil Schatzmann
Template Parameters
T

Constructor & Destructor Documentation

◆ SoundGenerator()

template<class T = int16_t>
SoundGenerator ( )
inline

◆ ~SoundGenerator()

template<class T = int16_t>
virtual ~SoundGenerator ( )
inlinevirtual

Member Function Documentation

◆ applyRamp()

template<class T = int16_t>
T applyRamp ( T  sample)
inlineprotected

◆ audioInfo()

template<class T = int16_t>
virtual AudioInfo audioInfo ( )
inlinevirtual

Provides the AudioInfo.

◆ begin() [1/2]

template<class T = int16_t>
virtual bool begin ( )
inlinevirtual

◆ begin() [2/2]

template<class T = int16_t>
virtual bool begin ( AudioInfo  info)
inlinevirtual

◆ defaultConfig()

template<class T = int16_t>
virtual AudioInfo defaultConfig ( )
inlinevirtual

◆ end()

template<class T = int16_t>
virtual void end ( )
inlinevirtual

ends the processing

Reimplemented in GeneratorFromArray< T >.

◆ isActive()

template<class T = int16_t>
virtual bool isActive ( )
inlinevirtual

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

◆ readBytes()

template<class T = int16_t>
virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlinevirtual

Provides the data as byte array with the requested number of channels.

◆ readBytesFrames()

template<class T = int16_t>
size_t readBytesFrames ( uint8_t buffer,
size_t  lengthBytes,
int  frames,
int  channels 
)
inlineprotected

◆ readBytesFromBuffer()

template<class T = int16_t>
size_t readBytesFromBuffer ( uint8_t buffer,
size_t  lengthBytes,
int  frame_size,
int  channels 
)
inlineprotected

◆ readSample()

template<class T = int16_t>
virtual T readSample ( )
pure virtual

◆ recalculatePlayTime()

template<class T = int16_t>
void recalculatePlayTime ( )
inlineprotected

◆ setAudioInfo()

template<class T = int16_t>
virtual void setAudioInfo ( AudioInfo  info)
inlinevirtual

Defines/updates the AudioInfo.

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

◆ setFrequency()

template<class T = int16_t>
virtual void setFrequency ( float  frequency)
inlinevirtual

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

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

◆ setPlayTime()

template<class T = int16_t>
void setPlayTime ( uint32_t  playMs,
uint8_t  upPercent = 20,
uint8_t  downPercent = 30 
)
inline

Member Data Documentation

◆ active

template<class T = int16_t>
bool active = false
protected

◆ activeWarningIssued

template<class T = int16_t>
bool activeWarningIssued = false
protected

◆ currentSample

template<class T = int16_t>
uint32_t currentSample = 0
protected

◆ downPercent

template<class T = int16_t>
uint8_t downPercent = 40
protected

◆ factor

template<class T = int16_t>
float factor = 1.0f
protected

◆ info

template<class T = int16_t>
AudioInfo info
protected

◆ playMs

template<class T = int16_t>
uint32_t playMs = 0
protected

◆ playSamples

template<class T = int16_t>
uint32_t playSamples = 0
protected

◆ rampDownDec

template<class T = int16_t>
float rampDownDec = 0.0
protected

◆ rampDownSamples

template<class T = int16_t>
uint32_t rampDownSamples = 0
protected

◆ rampUpInc

template<class T = int16_t>
float rampUpInc = 0.0
protected

◆ ring_buffer

template<class T = int16_t>
RingBuffer<uint8_t> ring_buffer {0}
protected

◆ upPercent

template<class T = int16_t>
uint8_t upPercent = 5
protected

◆ upSamples

template<class T = int16_t>
uint32_t upSamples = 0
protected

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