From fc19d9d11bb0d89caac38787812d77f329ccc2e3 Mon Sep 17 00:00:00 2001 From: hwdro Date: Tue, 8 Sep 2015 13:29:17 +0300 Subject: [PATCH] obs-filters: Fix noise-gate calculation errors For both cases the cur_level calculations were "wrong". For one channel case, I assume that was only an oversight, as for two channels case cur_level "calculation", getting the level from downmixing to mono will result in an attenuated level than expected. One solution is to use the highest level of both channels to drive the gate. --- plugins/obs-filters/noise-gate-filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/obs-filters/noise-gate-filter.c b/plugins/obs-filters/noise-gate-filter.c index c56be6999..fd3575328 100644 --- a/plugins/obs-filters/noise-gate-filter.c +++ b/plugins/obs-filters/noise-gate-filter.c @@ -120,8 +120,8 @@ static struct obs_audio_data *noise_gate_filter_audio(void *data, for (size_t i = 0; i < audio->frames; i++) { float cur_level = (channels == 2) - ? (fabsf(adata[0][i] + adata[1][i]) * 0.5f) - : (fabsf(adata[0][i]) * 0.5f); + ? fmaxf(fabsf(adata[0][i]), fabsf(adata[1][i])) + : fabsf(adata[0][i]); if (cur_level > open_threshold && !ng->is_open) { ng->is_open = true;