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

OBSOLETE AudioEffects: the template class describes the input audio to which the effects are applied: e.g. SineGenerator, SquareWaveGenerator, GeneratorFromStream etc. We support only one channel of int16_t data! More...

#include <AudioEffects.h>

Inheritance diagram for AudioEffects< GeneratorT >:
SoundGenerator< effect_t >

Public Member Functions

 AudioEffects ()=default
 Default constructor.
 
 AudioEffects (AudioEffects &copy)
 Copy constructor.
 
 AudioEffects (GeneratorT &generator)
 Constructor which is assigning a generator.
 
 AudioEffects (Stream &input, int channels=2, float volume=1.0)
 
virtual ~AudioEffects ()
 Destructor.
 
void addEffect (AudioEffect &effect)
 Adds an effect object (by reference)
 
void addEffect (AudioEffect *effect)
 Adds an effect using a pointer.
 
virtual AudioInfo audioInfo ()
 Provides the AudioInfo.
 
virtual bool begin ()
 Starts the processing.
 
virtual bool begin (AudioInfo info)
 Starts the processing with the provided AudioInfo.
 
void clear ()
 deletes all defined effects
 
virtual AudioInfo defaultConfig ()
 Provides the default configuration.
 
virtual void end ()
 
virtual void end (bool allow_rampdown)
 
AudioEffectfindEffect (int id)
 Finds an effect by id.
 
GeneratorT & generator ()
 Provides access to the sound generator.
 
virtual bool isActive ()
 Checks if the begin method has been called - after end() isActive is false.
 
AudioEffectoperator[] (int idx)
 gets an effect by index
 
virtual size_t readBytes (uint8_t *data, size_t len)
 Provides the data as byte array with the requested number of channels.
 
effect_t readSample () override
 provides the resulting sample
 
virtual size_t readSamples (effect_t *data, size_t len)
 
virtual void restart ()
 Restarts the generator, e.g. after a play time has been defined and reached.
 
virtual void setAudioInfo (AudioInfo info)
 Defines/updates the AudioInfo.
 
virtual void setFrequency (float frequency)
 Abstract method: not implemented! Just provides an error message...
 
void setInput (GeneratorT &in)
 Defines the input source for the raw guitar input.
 
virtual void setPlayTime (uint32_t playMs, uint8_t upPercent=20, uint8_t downPercent=30)
 Defines the play time in ms and the ramp up and ramp down time in percent.
 
virtual void setRampTimes (uint32_t playMs, uint32_t upMs=5, uint32_t downMs=5)
 
size_t size ()
 Provides the actual number of defined effects.
 

Protected Member Functions

effect_t applyRamp (effect_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
 
bool activeWarningIssued
 
uint32_t currentSample
 
uint32_t downMs
 
uint8_t downPercent
 
uint32_t downSamples
 
AudioEffectCommon effects
 
float factor
 
AudioInfo info
 
bool owns_generator = false
 
GeneratorT * p_generator =nullptr
 
uint32_t playMs
 
uint32_t playSamples
 
float rampDownDec
 
float rampUpInc
 
RingBuffer< uint8_t > ring_buffer
 
uint32_t upMs
 
uint8_t upPercent
 
uint32_t upSamples
 

Detailed Description

template<class GeneratorT>
class audio_tools::AudioEffects< GeneratorT >

OBSOLETE AudioEffects: the template class describes the input audio to which the effects are applied: e.g. SineGenerator, SquareWaveGenerator, GeneratorFromStream etc. We support only one channel of int16_t data!

We subclass the AudioEffects from GeneratorT so that we can use this class with the GeneratedSoundStream class to output the audio.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioEffects() [1/4]

template<class GeneratorT >
AudioEffects ( )
default

Default constructor.

◆ AudioEffects() [2/4]

template<class GeneratorT >
AudioEffects ( AudioEffects< GeneratorT > &  copy)
inline

Copy constructor.

◆ AudioEffects() [3/4]

template<class GeneratorT >
AudioEffects ( GeneratorT &  generator)
inline

Constructor which is assigning a generator.

◆ AudioEffects() [4/4]

template<class GeneratorT >
AudioEffects ( Stream input,
int  channels = 2,
float  volume = 1.0 
)
inline

Constructor which is assigning a Stream as input. The stream must consist of int16_t values with the indicated number of channels. Type type parameter is e.g. <GeneratorFromStream<effect_t>

◆ ~AudioEffects()

template<class GeneratorT >
virtual ~AudioEffects ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addEffect() [1/2]

template<class GeneratorT >
void addEffect ( AudioEffect effect)
inline

Adds an effect object (by reference)

◆ addEffect() [2/2]

template<class GeneratorT >
void addEffect ( AudioEffect effect)
inline

Adds an effect using a pointer.

◆ applyRamp()

effect_t applyRamp ( effect_t  sample)
inlineprotectedinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlinevirtualinherited

Provides the AudioInfo.

◆ begin() [1/2]

virtual bool begin ( )
inlinevirtualinherited

Starts the processing.

◆ begin() [2/2]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

Starts the processing with the provided AudioInfo.

◆ clear()

template<class GeneratorT >
void clear ( )
inline

deletes all defined effects

◆ defaultConfig()

virtual AudioInfo defaultConfig ( )
inlinevirtualinherited

Provides the default configuration.

◆ end() [1/2]

virtual void end ( )
inlinevirtualinherited

◆ end() [2/2]

virtual void end ( bool  allow_rampdown)
inlinevirtualinherited

Ends the processing. If either setPlayTime() or setRampTimes() have been set, then allow_rampdown=true will start a ramp-down instead of stopping immediately.

◆ findEffect()

template<class GeneratorT >
AudioEffect * findEffect ( int  id)
inline

Finds an effect by id.

◆ generator()

template<class GeneratorT >
GeneratorT & generator ( )
inline

Provides access to the sound generator.

◆ isActive()

virtual bool isActive ( )
inlinevirtualinherited

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

◆ operator[]()

template<class GeneratorT >
AudioEffect * operator[] ( int  idx)
inline

gets an effect by index

◆ readBytes()

virtual size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlinevirtualinherited

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

◆ readBytesFrames()

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

◆ readBytesFromBuffer()

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

◆ readSample()

template<class GeneratorT >
effect_t readSample ( )
inlineoverridevirtual

provides the resulting sample

Implements SoundGenerator< effect_t >.

◆ readSamples()

virtual size_t readSamples ( effect_t data,
size_t  len 
)
inlinevirtualinherited

Provides the data as T array (interleaved by channel) with the requested number of samples (values, not frames)

◆ recalculatePlayTime()

void recalculatePlayTime ( )
inlineprotectedinherited

◆ restart()

virtual void restart ( )
inlinevirtualinherited

Restarts the generator, e.g. after a play time has been defined and reached.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlinevirtualinherited

Defines/updates the AudioInfo.

◆ setFrequency()

virtual void setFrequency ( float  frequency)
inlinevirtualinherited

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

◆ setInput()

template<class GeneratorT >
void setInput ( GeneratorT &  in)
inline

Defines the input source for the raw guitar input.

◆ setPlayTime()

virtual void setPlayTime ( uint32_t  playMs,
uint8_t  upPercent = 20,
uint8_t  downPercent = 30 
)
inlinevirtualinherited

Defines the play time in ms and the ramp up and ramp down time in percent.

◆ setRampTimes()

virtual void setRampTimes ( uint32_t  playMs,
uint32_t  upMs = 5,
uint32_t  downMs = 5 
)
inlinevirtualinherited

Alternative to setPlayTime. It sets ramp-up and ramp-down times in ms instead of percentages. If playMs == 0, it will play indefinitely. restart();begin(); starts the ramp-up and sustain as normal, but it will sustain forever. end(true) triggers a ramp-down then inactive.

◆ size()

template<class GeneratorT >
size_t size ( )
inline

Provides the actual number of defined effects.

Member Data Documentation

◆ active

bool active
protectedinherited

◆ activeWarningIssued

bool activeWarningIssued
protectedinherited

◆ currentSample

uint32_t currentSample
protectedinherited

◆ downMs

uint32_t downMs
protectedinherited

◆ downPercent

uint8_t downPercent
protectedinherited

◆ downSamples

uint32_t downSamples
protectedinherited

◆ effects

template<class GeneratorT >
AudioEffectCommon effects
protected

◆ factor

float factor
protectedinherited

◆ info

AudioInfo info
protectedinherited

◆ owns_generator

template<class GeneratorT >
bool owns_generator = false
protected

◆ p_generator

template<class GeneratorT >
GeneratorT* p_generator =nullptr
protected

◆ playMs

uint32_t playMs
protectedinherited

◆ playSamples

uint32_t playSamples
protectedinherited

◆ rampDownDec

float rampDownDec
protectedinherited

◆ rampUpInc

float rampUpInc
protectedinherited

◆ ring_buffer

RingBuffer<uint8_t> ring_buffer
protectedinherited

◆ upMs

uint32_t upMs
protectedinherited

◆ upPercent

uint8_t upPercent
protectedinherited

◆ upSamples

uint32_t upSamples
protectedinherited

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