X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=stereocompressor.cpp;h=d9f1142fa3595b08ccaadd9431cb70fd7a602288;hb=9e47a2f661b9d292598ef0277e507458e3dad62f;hp=9291dc366b8384f15cf1d204cd05ce603a0c1671;hpb=9d603968d9163e2e821c6630420faa931e2b4c2d;p=nageru diff --git a/stereocompressor.cpp b/stereocompressor.cpp index 9291dc3..d9f1142 100644 --- a/stereocompressor.cpp +++ b/stereocompressor.cpp @@ -1,8 +1,8 @@ -#include +#include "stereocompressor.h" + #include #include - -#include "stereocompressor.h" +#include using namespace std; @@ -68,7 +68,7 @@ inline float fastpow(float x, float y) inline float compressor_knee(float x, float threshold, float inv_threshold, float inv_ratio_minus_one, float postgain) { assert(inv_ratio_minus_one <= 0.0f); - if (x > threshold && inv_ratio_minus_one < 0.0f) { + if (x > threshold) { return postgain * fastpow(x * inv_threshold, inv_ratio_minus_one); } else { return postgain; @@ -93,6 +93,17 @@ void StereoCompressor::process(float *buf, size_t num_samples, float threshold, float *left_ptr = buf; float *right_ptr = buf + 1; + if (inv_ratio_minus_one >= 0.0) { + for (size_t i = 0; i < num_samples; ++i) { + *left_ptr *= makeup_gain; + left_ptr += 2; + + *right_ptr *= makeup_gain; + right_ptr += 2; + } + return; + } + float peak_level = this->peak_level; float compr_level = this->compr_level;