Skip to content

Commit 41dcefb

Browse files
committed
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.
1 parent cea3015 commit 41dcefb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

alc/effects/reverb.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ struct EarlyReflections {
401401
*/
402402
DelayLineU Delay;
403403
std::array<size_t,NUM_LINES> Offset{};
404-
std::array<float,NUM_LINES> Coeff{};
404+
float Coeff{};
405405

406406
/* The gain for each output channel based on 3D panning. */
407407
struct OutGains {
@@ -926,10 +926,15 @@ void EarlyReflections::updateLines(const float density_mult, const float diffusi
926926
/* Calculate the delay length of each delay line. */
927927
length = EARLY_LINE_LENGTHS[i] * density_mult;
928928
Offset[i] = float2uint(length * frequency);
929-
930-
/* Calculate the gain (coefficient) for each line. */
931-
Coeff[i] = CalcDecayCoeff(length, decayTime);
932929
}
930+
931+
/* Calculate the gain (coefficient) for the secondary reflections based on
932+
* the average delay and decay time.
933+
*/
934+
const auto length = std::reduce(EARLY_LINE_LENGTHS.begin(), EARLY_LINE_LENGTHS.end(), 0.0f)
935+
/ float{EARLY_LINE_LENGTHS.size()} * density_mult;
936+
Coeff = CalcDecayCoeff(length, decayTime);
937+
933938
}
934939

935940
/* 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,
15511556

15521557
/* Apply a delay and bounce to generate secondary reflections. */
15531558
early_delay.writeReflected(offset, tempSamples, todo);
1559+
const auto feedb_coeff = mEarly.Coeff;
15541560
for(size_t j{0_uz};j < NUM_LINES;j++)
15551561
{
15561562
const auto input = early_delay.get(j);
15571563
auto feedb_tap = size_t{offset - mEarly.Offset[j]};
1558-
const auto feedb_coeff = float{mEarly.Coeff[j]};
15591564
auto out = outSamples[j].begin() + base;
15601565
auto tmp = tempSamples[j].begin();
15611566

0 commit comments

Comments
 (0)