On Tue, Nov 30, 2010 at 3:50 AM, Element Green
<jgr...@users.sourceforge.net> wrote:
> I hadn't given this much thought and just assumed a linear cross fade
> (0-100%) would be the way to do it

I'll try to elucidate with two extreme examples. If the signal is
white noise, then a linear cross-fade will make a dip in the volume,
centered at the cross fade. This is because the phases of the two
signals (one being faded in an one being faded out) don't match and
there will be partial cancellation of components of the signal. On
average the phase difference will be 90 deg. I recall my frustration
using a sample editor which only offered linear cross-fade. It would
often create this kind of a dip. The other example: If the signal is
sinusoidal, then you can adjust the loop length to obtain a perfect
match. In this case the linear cross fade will work perfectly: It does
nothing, as the signals are already identical around the loop points.

For uncorrelated signals you'd like to use something like this instead
of a linear cross fade, to compensate for the dip:

x = 0..1 is the time position inside the cross-fade
f(x) is the gain function for the signal that is being faded in
f(1-x) is the gain function for the signal that is being faded out

These constraints should be satisfied:

f(0) = 0
f(1) = 1
f(x)^2 + f(1-x)^2 = 1

The last constraint above normalizes power or amplitude for the
mixture of uncorrelated signals.

Some functions that are applicable:

f(x) = sqrt(x)
f(x) = sin(pi/2*x)
f(x) = x/sqrt(x^2+(1-x)^2)

The last one is probably my favorite, as it has the same gain ratio
f(x)/f(1-x) as a linear cross fade. It doesn't start the fade in as
abruptly as the others.

This is quite a similar problem as finding a nice pan law.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp

Reply via email to