/*---------------------------------------------------------------------------*/
/*
  File: dyncompr.h

  Dynamic compressor.
*/
/*---------------------------------------------------------------------------*/

#ifndef DYNCOMPR_H_
#define DYNCOMPR_H_

#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------*/

#define DYNAMIC_COMPRESSOR_MODE_RATIO2  0
#define DYNAMIC_COMPRESSOR_MODE_RATIO3  1

typedef struct dynamic_compressor_s
{
    int mode;
    dword energy_threshold;
    dword limit_threshold;
    dword noise_threshold;
    dword max_gain;
    word gain_range;
    word gain_range_for_gain;
    word noise_attenuation;
    word time_constant;
    dword gain;
} t_dynamic_compressor;

void dynamic_compressor_init(t_dynamic_compressor *p_dyncompr, dword energy_threshold, dword max_gain, dword noise_threshold, word noise_attenuation, int mode = DYNAMIC_COMPRESSOR_MODE_RATIO3, dword limit_threshold = 0x7fffffff);
short dynamic_compressor_exec(t_dynamic_compressor *p_dyncompr, short in_sample);
short dynamic_compressor_exec_for_gain(t_dynamic_compressor *p_dyncompr, short in_sample);


/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif

#endif

/*---------------------------------------------------------------------------*/
