arduino-audio-tools
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
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
 
Compressorclone ()
 
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
 
float compress (float inSampleF)
 
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
 
float threshold
 
int32_t timeout
 

Detailed Description

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

Author
Phil Schatzmann

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