1 #ifndef _STEREOCOMPRESSOR_H
2 #define _STEREOCOMPRESSOR_H 1
4 // A simple compressor based on absolute values, with independent
5 // attack/release times. There is no sidechain or lookahead, but the
6 // peak value is shared between both channels.
8 // The compressor was originally written by, and is copyrighted by, Rune Holm.
9 // It has been adapted and relicensed under GPLv3 (or, at your option,
10 // any later version) for Nageru, so that its license matches the rest of the code.
14 class StereoCompressor {
16 StereoCompressor(float sample_rate)
17 : sample_rate(sample_rate) {
22 peak_level = compr_level = 0.1f;
26 // Process <num_samples> interleaved stereo data in-place.
27 // Attack and release times are in seconds.
28 void process(float *buf, size_t num_samples, float threshold, float ratio,
29 float attack_time, float release_time, float makeup_gain);
31 // Last level estimated (after attack/decay applied).
32 float get_level() { return compr_level; }
34 // Last attenuation factor applied, e.g. if 5x compression is currently applied,
35 // this number will be 0.2.
36 float get_attenuation() { return scalefactor; }
45 #endif /* !defined(_STEREOCOMPRESSOR_H) */