obs-filters: Ensure gain is positive for upward compressor
The gain should be positive for an upward compressor. Initially, the
gain would be zeroe'd below -60 dB to ensure noise is not amplified by
the upward compressor. This created a discontinuity at -60 dB since
just above -60 dB, the audio is boosted by +20 dB (at default
settings). This was fixed in commit 50db097 which decreased smoothly
the gain so that it's 0 dB at -60 dB. However that commit forgot to
limit the gain decrease which was negative below -60 dB.
This is fixed by the current commit.
Additionally initialization allowed -inf gain. We hard limit to positive
gains only as they should be for an upward compressor.
The bugfix was found by R1ch and put in form by pkv.
Co-authored-by: pkv <pkv@obsproject.com>
Signed-off-by: pkv <pkv@obsproject.com>
This commit is contained in:
parent
96aef4f048
commit
eef0faf741
1 changed files with 5 additions and 2 deletions
|
|
@ -360,12 +360,15 @@ static inline void process_sample(size_t idx, float *samples, float *env_buf,
|
|||
float diff = threshold - env_db;
|
||||
|
||||
if (is_upwcomp && env_db <= (threshold - 60.0f) / 2)
|
||||
diff = env_db + 60.0f;
|
||||
diff = env_db + 60.0f > 0 ? env_db + 60.0f : 0.0f;
|
||||
|
||||
float gain = 0.0f;
|
||||
float prev_gain = 0.0f;
|
||||
// Note that the gain is always >= 0 for the upward compressor
|
||||
// but is always <=0 for the expander.
|
||||
if (is_upwcomp) {
|
||||
prev_gain = idx > 0 ? fmaxf(gain_db[idx - 1], 0)
|
||||
: fmaxf(channel_gain, 0);
|
||||
// gain above knee (included for clarity):
|
||||
if (env_db >= threshold + knee / 2)
|
||||
gain = 0.0f;
|
||||
|
|
@ -377,9 +380,9 @@ static inline void process_sample(size_t idx, float *samples, float *env_buf,
|
|||
threshold + knee / 2 > env_db)
|
||||
gain = slope * powf(diff + knee / 2, 2) / (2.0f * knee);
|
||||
} else {
|
||||
prev_gain = idx > 0 ? gain_db[idx - 1] : channel_gain;
|
||||
gain = diff > 0.0f ? fmaxf(slope * diff, -60.0f) : 0.0f;
|
||||
}
|
||||
float prev_gain = idx > 0 ? gain_db[idx - 1] : channel_gain;
|
||||
|
||||
/* --------------------------------- */
|
||||
/* ballistics (attack/release) */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue