# Typo in the Reverb algorithm

**URL:** <https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825>\
**Category:** General JUCE discussion\
**Created:** [May 11, 2014, 8:26am UTC](https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825 "2014-05-11T08:26:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [May 11, 2014, 8:26am UTC](https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825/1 "2014-05-11T08:26:09Z")

</div>

Hello Jules !

There is a typo in your reverb algoritm. The processMono function should be written like this :

```
void processMono (float* const samples, const int numSamples) noexcept
{
        jassert (samples != nullptr);

        if (shouldUpdateDamping)
            updateDamping();

        for (int i = 0; i < numSamples; ++i)
        {
            const float input = samples[i] * gain;
            float output = 0;

            for (int j = 0; j < numCombs; ++j) // accumulate the comb filters in parallel
                output += comb[0][j].process (input);

            for (int j = 0; j < numAllPasses; ++j) // run the allpass filters in series
                output = allPass[0][j].process (output);

            // better !
            samples[i] = output * wet1 + samples[i] * dry * 0.5f;
            
            // wrong, because of the gain, and the dryScalefactor
            //samples[i] = output * wet1 + in * dry;

        }
}
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 11, 2014, 8:28am UTC](https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825/2 "2014-05-11T08:28:42Z")

</div>

Ah, good catch! Many thanks!

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [May 14, 2014, 7:34am UTC](https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825/3 "2014-05-14T07:34:00Z")

</div>

Hello Jules !

I have a question. In the function setParameters of the reverb, there is this code :

```
const float wetScaleFactor = 3.0f;
const float dryScaleFactor = 2.0f;
```

What is its use ? In the fix I proposed for the processMono, I added a 0.5f multiplication to compensate this, since I want the effect to be equivalent to a bypass when the dry parameter is one, and the wet parameter is zero. I thought it was some kind of compensation for stereo signals, but you didn't add my extra multiplication when you fix the bug on the processMono function...  
&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 14, 2014, 9:13am UTC](https://forum.juce.com/t/typo-in-the-reverb-algorithm/12825/4 "2014-05-14T09:13:03Z")

</div>

IIRC that's&nbsp;there to make the parameters compatible with the parameters for the old Freeverb plugin&nbsp;which this class emulates.&nbsp;

True,&nbsp;it's a bit odd that the value is 2.0, and I'm not sure why that's the case.&nbsp;But I obviously can't change its behaviour now, because that'd mean that all existing code which uses a Reverb object would suddenly&nbsp;produce&nbsp;different output.
