arduino-audio-tools
Loading...
Searching...
No Matches
Compressor Class Reference

Compressor inspired by https://github.com/YetAnotherElectronicsChannel/STM32_DSP_COMPRESSOR/blob/master/code/Src/main.c. More...

#include <AudioEffect.h>

Inheritance diagram for Compressor:
AudioEffect

Public Member Functions

 Compressor (const Compressor &copy)=default
 Copy Constructor.
 Compressor (uint32_t sampleRate=44100, uint16_t attackMs=30, uint16_t releaseMs=20, uint16_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5)
 Default Constructor.
virtual bool active ()
 determines if the effect is active
Compressor * clone ()
int id ()
 Allows to identify an effect.
effect_t process (effect_t input)
 Processes the sample.
virtual void setActive (bool value)
 sets the effect active/inactive
void setAttack (uint16_t attackMs)
 Defines the attack duration in ms.
void setCompressionRatio (float compressionRatio)
 Defines the compression ratio from 0 to 1.
void setHold (uint16_t holdMs)
 Defines the hold duration in ms.
void setId (int id)
 Allows to identify an effect.
void setRelease (uint16_t releaseMs)
 Defines the release duration in ms.
void setThresholdPercent (uint8_t thresholdPercent)
 Defines the threshod in %.

Protected Types

enum  CompStates { S_NoOperation , S_Attack , S_GainReduction , S_Release }

Protected Member Functions

int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
effect_t compress (effect_t inSample)
void copyParent (AudioEffect *copy)
void recalculate ()

Protected Attributes

bool active_flag = true
int32_t attack_count
float gain
float gain_step_attack
float gain_step_release
float gainreduce
int32_t hold_count
int id_value = -1
int32_t release_count
uint32_t sample_rate
enum CompStates state = S_NoOperation
int32_t threshold
int32_t timeout

Detailed Description

Member Enumeration Documentation

◆ CompStates

enum CompStates
protected
Enumerator
S_NoOperation 
S_Attack 
S_GainReduction 
S_Release 

Constructor & Destructor Documentation

◆ Compressor() [1/2]

Compressor ( const Compressor & copy)
default

Copy Constructor.

◆ Compressor() [2/2]

Compressor ( uint32_t sampleRate = 44100,
uint16_t attackMs = 30,
uint16_t releaseMs = 20,
uint16_t holdMs = 10,
uint8_t thresholdPercent = 10,
float compressionRatio = 0.5 )
inline

Default Constructor.

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()

Compressor * clone ( )
inlinevirtual

Implements AudioEffect.

◆ compress()

effect_t compress ( effect_t inSample)
inlineprotected

◆ copyParent()

void copyParent ( AudioEffect * copy)
inlineprotectedinherited

◆ id()

int id ( )
inlineinherited

Allows to identify an effect.

◆ process()

effect_t process ( effect_t input)
inlinevirtual

Processes the sample.

Implements AudioEffect.

◆ recalculate()

void recalculate ( )
inlineprotected

◆ setActive()

virtual void setActive ( bool value)
inlinevirtualinherited

sets the effect active/inactive

◆ setAttack()

void setAttack ( uint16_t attackMs)
inline

Defines the attack duration in ms.

◆ setCompressionRatio()

void setCompressionRatio ( float compressionRatio)
inline

Defines the compression ratio from 0 to 1.

◆ setHold()

void setHold ( uint16_t holdMs)
inline

Defines the hold duration in ms.

◆ setId()

void setId ( int id)
inlineinherited

Allows to identify an effect.

◆ setRelease()

void setRelease ( uint16_t releaseMs)
inline

Defines the release duration in ms.

◆ setThresholdPercent()

void setThresholdPercent ( uint8_t thresholdPercent)
inline

Defines the threshod in %.

Member Data Documentation

◆ active_flag

bool active_flag = true
protectedinherited

◆ attack_count

int32_t attack_count
protected

◆ gain

float gain
protected

◆ gain_step_attack

float gain_step_attack
protected

◆ gain_step_release

float gain_step_release
protected

◆ gainreduce

float gainreduce
protected

◆ hold_count

int32_t hold_count
protected

◆ id_value

int id_value = -1
protectedinherited

◆ release_count

int32_t release_count
protected

◆ sample_rate

uint32_t sample_rate
protected

◆ state

enum CompStates state = S_NoOperation
protected

◆ threshold

int32_t threshold
protected

◆ timeout

int32_t timeout
protected

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