# Equal Power Crossfading of Reverb

**URL:** <https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872>\
**Category:** General JUCE discussion\
**Created:** [January 17, 2021, 4:00pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872 "2021-01-17T16:00:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadhu](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sadhu](https://forum.juce.com/u/sadhu)\
**Post date:** [January 17, 2021, 4:00pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/1 "2021-01-17T16:00:10Z")

</div>

I was looking at the code in this post and adapted it to what I need. Which is mixing the dry signal and a completely wet reverb and effects chain. But the final post at the end mentions equal power crossfading to avoid a volume drop in the middle of the dial:

> [@Convolution Dry/Mix](https://forum.juce.com/t/convolution-dry-mix/27035/2):
>
> I don’t believe there’s one included in the DSP library, but writing your own should be trivial. Just create a secondary buffer that gets allocated to the proper buffer size in your prepare method and make a copy to it as the first step in your process method, then apply a gain to both streams based on the normalized position of the dry/wet knob, and finally mix them together into the output buffer using addition. Here’s an implementation I did for an old project using the dsp:: API. The projec…

After some reading online I think I basically need to do this (I am assuming the signals are de-correlated). I suck at math and just want to know if I am on the right track I sounds like it is working to my ears.

`
wetMix.setGainLinear(sqrt(fxKnob));
dryMix.setGainLinear(sqrt(1.0-fxKnob));
`

Am I on the right track? Also, if the signal was correlated would I use a more linear sweep with 0.5 in the middle? What would be an example of a more correlated signal? A chorus? Sorry for all the questions I just want to understand this better so I don’t need to ask about it in the future.

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 17, 2021, 4:09pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/2 "2021-01-17T16:09:04Z")

</div>

`sqrt(0.5)` gives you the right -3dB midpoint but, from what I recall trying that, you get nasty steps at the extremities in the signal that is going to towards silence when close to 0 or 1

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 17, 2021, 4:11pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/3 "2021-01-17T16:11:08Z")

</div>

> <https://dsp.stackexchange.com/questions/21691/algorithm-to-pan-audio>

Something like that using `sin()` and `cos()` with ±45° as the limits for the angles.

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 17, 2021, 4:11pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/4 "2021-01-17T16:11:59Z")

</div>

(I know that linked question is about panning, but the principle is the same for crossfading.)

---

<div class="post-metadata">

**Author:** ![sadhu](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sadhu](https://forum.juce.com/u/sadhu)\
**Post date:** [January 17, 2021, 4:53pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/5 "2021-01-17T16:53:35Z")

</div>

Thanks for the response! That panning math using the sin and cos looks simple enough I may try to implement that. I am not really noticing the issues with the edges of the Square Root pan though so maybe my use case is fine to just use that. I may just code up both and see which one I intuitively like better. I assume the SQRT uses less cycles so if I can get away with that I maybe just keep it.

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 17, 2021, 9:50pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/6 "2021-01-17T21:50:37Z")

</div>

OK if it works then that’s good. This graph should help illustrate what I mean:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/3/38b840dafe5a605de4030208e44bcf46855c0a0d.png)

---

<div class="post-metadata">

**Author:** ![sadhu](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sadhu](https://forum.juce.com/u/sadhu)\
**Post date:** [January 18, 2021, 5:11am UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/7 "2021-01-18T05:11:17Z")

</div>

I coded this, does it look pretty much correct? It is sounding fine to me but I want to be sure. In this case the “fxKnob” sweeps from -45 to +45

`
const double degrad = M_PI / 180;
const double sqrt2d2 = sqrt(2)/2.0;
double fxAngle = degrad * fxKnob; // convert degree to rad
`

`wetMix.setGainLinear(sqrt2d2 * (cos(fxAngle) + sin(fxAngle)) );
dryMix.setGainLinear(sqrt2d2 * (cos(fxAngle) - sin(fxAngle)) );
`

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 18, 2021, 12:40pm UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/8 "2021-01-18T12:40:06Z")

</div>

45° is pi/4

So assuming your `fxKnob` is in the range [-1,1] then just multiply by that for your `fxAngle`

---

<div class="post-metadata">

**Author:** ![sadhu](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sadhu](https://forum.juce.com/u/sadhu)\
**Post date:** [January 19, 2021, 12:10am UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/9 "2021-01-19T00:10:58Z")

</div>

Yeah I guess I wouldn’t want the "mix"parameter exposed to the user as going from -45 to 45. I switched it to the -1 to +1 system and it sounds great. Thank you

---

<div class="post-metadata">

**Author:** ![martinrobinson-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/martinrobinson-2/32/630_2.png) [@martinrobinson-2](https://forum.juce.com/u/martinrobinson-2)\
**Post date:** [January 19, 2021, 11:17am UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/10 "2021-01-19T11:17:14Z")

</div>

Ah yes sorry, I see now. I missed the bit where you said the fxKnob was ±45!

---

<div class="post-metadata">

**Author:** ![refusesoftware](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/refusesoftware/32/20561_2.png) [@refusesoftware](https://forum.juce.com/u/refusesoftware)\
**Post date:** [January 26, 2021, 4:36am UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/11 "2021-01-26T04:36:19Z")

</div>

In Juce 6 you can get a bunch of these crossfading options by using `dsp::DryWetMixer` and choosing a [DryWetMixingRule](https://docs.juce.com/master/namespacedsp.html#a88d33c6b783d9a78aee07335dbf9a968).

---

<div class="post-metadata">

**Author:** ![sadhu](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sadhu](https://forum.juce.com/u/sadhu)\
**Post date:** [January 27, 2021, 12:15am UTC](https://forum.juce.com/t/equal-power-crossfading-of-reverb/43872/12 "2021-01-27T00:15:42Z")

</div>

Oh that is interesting, would the equivalent of the above algorithm be the “balanced” rule then? I finished the project I needed this for but I am sure I will have to implement the same thing at some point in the future.
