# Crossfading smoothly between AudioSources

**URL:** <https://forum.juce.com/t/crossfading-smoothly-between-audiosources/22395>\
**Category:** Audio Plugins\
**Created:** [May 12, 2017, 2:36pm UTC](https://forum.juce.com/t/crossfading-smoothly-between-audiosources/22395 "2017-05-12T14:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mashu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mashu/32/579_2.png) [@mashu](https://forum.juce.com/u/mashu)\
**Post date:** [May 12, 2017, 2:36pm UTC](https://forum.juce.com/t/crossfading-smoothly-between-audiosources/22395/1 "2017-05-12T14:36:44Z")

</div>

is there something in Juce that makes it easy to crossfade between 2 AudioSources, and then stop processing the unneeded one when the crossfade is complete?

In my case, I have a bank of effects that need to be changed in realtime, with smooth glitch-free changes, so am looking for ~5ms crossfades as the new effect is faded in, and the old one faded out.

I guess i can write my own Crossfader class, but just wondering if this has already been done, so maybe i don’t have to re-invent the wheel?

---

<div class="post-metadata">

**Author:** ![fefanto](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fefanto/32/1518_2.png) [@fefanto](https://forum.juce.com/u/fefanto)\
**Post date:** [May 12, 2017, 5:32pm UTC](https://forum.juce.com/t/crossfading-smoothly-between-audiosources/22395/2 "2017-05-12T17:32:41Z")

</div>

Take a look at the LinearSmoothedValue class. It should be in the effects folder of the juce\_audio\_basics module.

If you need an exponentially smoothed value I made a small class based on the same interface:

> <https://gist.github.com/fefanto/3057474c020c2cdfab5c462c50b1cc48>
