From 41dcefb519a6333be662ea507cd59fe13cf81d6d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 10 Dec 2024 03:19:04 -0800 Subject: [PATCH] Avoid per-line gains for the secondary early reflections Similar to the first reflections/input delay, there may still be enough spatial coeherence and cause direction-dependent attenuation. Since the first line provides a 0-delay path from the early reflections to the late reverb, use the average instead of the minimum delay. Not sure if using the decay time is the best idea, but since these are additional reflections after more room interaction, it doesn't seem completely wrong. --- alc/effects/reverb.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 006f02d3ea..1e16abc9de 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -401,7 +401,7 @@ struct EarlyReflections { */ DelayLineU Delay; std::array Offset{}; - std::array Coeff{}; + float Coeff{}; /* The gain for each output channel based on 3D panning. */ struct OutGains { @@ -926,10 +926,15 @@ void EarlyReflections::updateLines(const float density_mult, const float diffusi /* Calculate the delay length of each delay line. */ length = EARLY_LINE_LENGTHS[i] * density_mult; Offset[i] = float2uint(length * frequency); - - /* Calculate the gain (coefficient) for each line. */ - Coeff[i] = CalcDecayCoeff(length, decayTime); } + + /* Calculate the gain (coefficient) for the secondary reflections based on + * the average delay and decay time. + */ + const auto length = std::reduce(EARLY_LINE_LENGTHS.begin(), EARLY_LINE_LENGTHS.end(), 0.0f) + / float{EARLY_LINE_LENGTHS.size()} * density_mult; + Coeff = CalcDecayCoeff(length, decayTime); + } /* Update the EAX modulation step and depth. Keep in mind that this kind of @@ -1551,11 +1556,11 @@ void ReverbPipeline::processEarly(const DelayLineU &main_delay, size_t offset, /* Apply a delay and bounce to generate secondary reflections. */ early_delay.writeReflected(offset, tempSamples, todo); + const auto feedb_coeff = mEarly.Coeff; for(size_t j{0_uz};j < NUM_LINES;j++) { const auto input = early_delay.get(j); auto feedb_tap = size_t{offset - mEarly.Offset[j]}; - const auto feedb_coeff = float{mEarly.Coeff[j]}; auto out = outSamples[j].begin() + base; auto tmp = tempSamples[j].begin();