Skip to content

daisysp::Compressor

More...

#include <compressor.h>

Public Functions

Name
Compressor()
~Compressor()
void Init(float sample_rate)
float Process(float in)
float Process(float in, float key)
float Apply(float in)
void ProcessBlock(float * in, float * out, size_t size)
void ProcessBlock(float * in, float * out, float * key, size_t size)
void ProcessBlock(float ** in, float ** out, float * key, size_t channels, size_t size)
float GetRatio()
void SetRatio(float ratio)
float GetThreshold()
void SetThreshold(float threshold)
float GetAttack()
void SetAttack(float attack)
float GetRelease()
void SetRelease(float release)
float GetMakeup()
void SetMakeup(float gain)
void AutoMakeup(bool enable)
float GetGain()

Detailed Description

class daisysp::Compressor;

Todo: Add soft/hard knee settings

dynamics compressor

influenced by compressor in soundpipe (from faust).

Modifications made to do:

  • Less calculations during each process loop (coefficients recalculated on parameter change).
  • C++-ified
  • added sidechain support
  • pulled gain apart for monitoring and multichannel support
  • improved readability
  • improved makeup-gain calculations
  • changing controls now costs a lot less
  • a lot less expensive

by: shensley, improved upon by AvAars

Public Functions Documentation

function Compressor

inline Compressor()

function ~Compressor

inline ~Compressor()

function Init

void Init(
    float sample_rate
)

Parameters:

  • sample_rate rate at which samples will be produced by the audio engine.

Initializes compressor


function Process

float Process(
    float in
)

Parameters:

  • in audio input signal

Compress the audio input signal, saves the calculated gain


function Process

inline float Process(
    float in,
    float key
)

Parameters:

  • in audio input signal (to be compressed)
  • key audio input that will be used to side-chain the compressor

Compresses the audio input signal, keyed by a secondary input.


function Apply

inline float Apply(
    float in
)

Parameters:

  • in audio input signal

Apply compression to the audio signal, based on the previously calculated gain


function ProcessBlock

inline void ProcessBlock(
    float * in,
    float * out,
    size_t size
)

Parameters:

  • in audio input signal
  • out audio output signal
  • size the size of the block

Compresses a block of audio


function ProcessBlock

void ProcessBlock(
    float * in,
    float * out,
    float * key,
    size_t size
)

Parameters:

  • in audio input signal (to be compressed)
  • out audio output signal
  • key audio input that will be used to side-chain the compressor
  • size the size of the block

Compresses a block of audio, keyed by a secondary input


function ProcessBlock

void ProcessBlock(
    float ** in,
    float ** out,
    float * key,
    size_t channels,
    size_t size
)

Parameters:

  • in audio input signals (to be compressed)
  • out audio output signals
  • key audio input that will be used to side-chain the compressor
  • channels the number of audio channels
  • size the size of the block

Compresses a block of multiple channels of audio, keyed by a secondary input


function GetRatio

inline float GetRatio()

Gets the amount of gain reduction


function SetRatio

inline void SetRatio(
    float ratio
)

Parameters:

  • ratio Expects 1.0 -> 40. (untested with values < 1.0)

Sets the amount of gain reduction applied to compressed signals


function GetThreshold

inline float GetThreshold()

Gets the threshold in dB


function SetThreshold

inline void SetThreshold(
    float threshold
)

Parameters:

  • threshold Expects 0.0 -> -80.

Sets the threshold in dB at which compression will be applied


function GetAttack

inline float GetAttack()

Gets the envelope time for onset of compression


function SetAttack

inline void SetAttack(
    float attack
)

Parameters:

  • attack Expects 0.001 -> 10

Sets the envelope time for onset of compression for signals above the threshold.


function GetRelease

inline float GetRelease()

Gets the envelope time for release of compression


function SetRelease

inline void SetRelease(
    float release
)

Parameters:

  • release Expects 0.001 -> 10

Sets the envelope time for release of compression as input signal falls below threshold.


function GetMakeup

inline float GetMakeup()

Gets the additional gain to make up for the compression


function SetMakeup

inline void SetMakeup(
    float gain
)

Parameters:

  • gain Expects 0.0 -> 80

Manually sets the additional gain to make up for the compression


function AutoMakeup

inline void AutoMakeup(
    bool enable
)

Parameters:

  • enable true to enable, false to disable

Enables or disables the automatic makeup gain. Disabling sets the makeup gain to 0.0


function GetGain

inline float GetGain()

Gets the gain reduction in dB

---

Updated on 2024-01-03 at 19:38:46 +0000