arduino-audio-tools
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Tremolo Class Reference

Tremolo AudioEffect: periodic change of the volume (amplitude modulation) between (100 - depth)% and 100%. More...

#include <AudioEffect.h>

Inheritance diagram for Tremolo:
Inheritance graph
[legend]
Collaboration diagram for Tremolo:
Collaboration graph
[legend]

Public Types

enum  Shape { Triangle , Sine }
 Waveform of the modulation. More...
 

Public Member Functions

 Tremolo (const Tremolo &copy)=default
 
 Tremolo (int16_t duration_ms=2000, uint8_t depthPercent=50, uint32_t sampleRate=44100)
 
virtual bool active ()
 determines if the effect is active
 
Tremolo * clone ()
 
uint8_t depth ()
 
int16_t duration ()
 
int id ()
 Allows to identify an effect.
 
effect_t process (effect_t input)
 calculates the effect output from the input
 
float rate ()
 
virtual void setActive (bool value)
 sets the effect active/inactive
 
void setDepth (uint8_t percent)
 Depth in percent: the volume changes between (100 - depth)% and 100%.
 
void setDuration (int16_t ms)
 Period of the modulation in ms (<= 0: no modulation)
 
void setId (int id)
 Allows to identify an effect.
 
void setPhase (float degrees)
 
void setRate (float hz)
 Speed of the modulation in Hz (e.g. 5.5 for an electric piano)
 
void setSampleRate (uint32_t sampleRate)
 Sample rate of the processed audio.
 
void setShape (Shape shape)
 Waveform: Triangle (default) or Sine.
 
Shape shape ()
 

Protected Member Functions

int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
 
void copyParent (AudioEffect *copy)
 
int32_t gainAt (float pos)
 Gain (Q16) at a position in the period: (1 - depth) .. 1.
 
void nextSegment ()
 
void recalculate ()
 

Protected Attributes

bool active_flag = true
 
int16_t duration_ms = 0
 
int32_t gain = 65536
 
int32_t gain_step = 0
 
int id_value = -1
 
uint8_t p_percent = 50
 
Shape p_shape = Triangle
 
float phase = 0.0f
 
float rate_hz = 0.0f
 
int remaining = 0
 
uint32_t sample_rate = 44100
 
float segment_inc = 0.0f
 

Static Protected Attributes

static constexpr int SEGMENT = 32
 

Detailed Description

Tremolo AudioEffect: periodic change of the volume (amplitude modulation) between (100 - depth)% and 100%.

The gain is calculated every 32 samples and interpolated linearly in between: per sample only one integer multiplication is needed (no float operation, no division), for the float and the fixed point configuration.

Author
Phil Schatzmann

Member Enumeration Documentation

◆ Shape

enum Shape

Waveform of the modulation.

Enumerator
Triangle 
Sine 

Constructor & Destructor Documentation

◆ Tremolo() [1/2]

Tremolo ( int16_t  duration_ms = 2000,
uint8_t  depthPercent = 50,
uint32_t  sampleRate = 44100 
)
inline

Tremolo constructor - use e.g. duration_ms=2000; depthPercent=50; sampleRate=44100

◆ Tremolo() [2/2]

Tremolo ( const Tremolo &  copy)
default

Member Function Documentation

◆ active()

virtual bool active ( )
inlinevirtualinherited

determines if the effect is active

◆ clip()

int16_t clip ( int32_t  in,
int16_t  clipLimit = 32767,
int16_t  resultLimit = 32767 
)
inlineprotectedinherited

generic clipping method

◆ clone()

Tremolo * clone ( )
inlinevirtual

Implements AudioEffect.

◆ copyParent()

void copyParent ( AudioEffect *  copy)
inlineprotectedinherited

◆ depth()

uint8_t depth ( )
inline

◆ duration()

int16_t duration ( )
inline

◆ gainAt()

int32_t gainAt ( float  pos)
inlineprotected

Gain (Q16) at a position in the period: (1 - depth) .. 1.

◆ id()

int id ( )
inlineinherited

Allows to identify an effect.

◆ nextSegment()

void nextSegment ( )
inlineprotected

Calculates the gain at the end of the next segment: the gain is interpolated linearly inside of the segment

◆ process()

effect_t process ( effect_t  in)
inlinevirtual

calculates the effect output from the input

Implements AudioEffect.

◆ rate()

float rate ( )
inline

◆ recalculate()

void recalculate ( )
inlineprotected

Parameters changed: the next segment ramps from the current gain to the new values (no clicks)

◆ setActive()

virtual void setActive ( bool  value)
inlinevirtualinherited

sets the effect active/inactive

◆ setDepth()

void setDepth ( uint8_t  percent)
inline

Depth in percent: the volume changes between (100 - depth)% and 100%.

◆ setDuration()

void setDuration ( int16_t  ms)
inline

Period of the modulation in ms (<= 0: no modulation)

◆ setId()

void setId ( int  id)
inlineinherited

Allows to identify an effect.

◆ setPhase()

void setPhase ( float  degrees)
inline

Phase of the modulation in degrees, e.g. 180 for the right channel of a stereo auto pan

◆ setRate()

void setRate ( float  hz)
inline

Speed of the modulation in Hz (e.g. 5.5 for an electric piano)

◆ setSampleRate()

void setSampleRate ( uint32_t  sampleRate)
inline

Sample rate of the processed audio.

◆ setShape()

void setShape ( Shape  shape)
inline

Waveform: Triangle (default) or Sine.

◆ shape()

Shape shape ( )
inline

Member Data Documentation

◆ active_flag

bool active_flag = true
protectedinherited

◆ duration_ms

int16_t duration_ms = 0
protected

◆ gain

int32_t gain = 65536
protected

◆ gain_step

int32_t gain_step = 0
protected

◆ id_value

int id_value = -1
protectedinherited

◆ p_percent

uint8_t p_percent = 50
protected

◆ p_shape

Shape p_shape = Triangle
protected

◆ phase

float phase = 0.0f
protected

◆ rate_hz

float rate_hz = 0.0f
protected

◆ remaining

int remaining = 0
protected

◆ sample_rate

uint32_t sample_rate = 44100
protected

◆ SEGMENT

constexpr int SEGMENT = 32
staticconstexprprotected

◆ segment_inc

float segment_inc = 0.0f
protected

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