Crossfade between n signals.

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I'm looking for an efficient way to crossfade between an arbitrary number of signals.

Say I have 4 inputs {A,B,C,D}, and an amount variable amt, that varies between 0 and 1.

Code: Select all

when amt = 0 :  A = 1, B = 0, C = 0, D = 0.

when amt = 1 :  A = 0, B = 0, C = 0, D = 1.
Should I precompute a map, or a kernal that gives me 4 amplitude values at any point of amt?

Or is there a nice (polynomial?) way of doing it on the fly?

I know i can use 4 sine waves with offset phases to mix things, but I'd like to avoid using four trig functions for each sample.

Thank you in advance for any help!

Post

Code: Select all

double f = amt; // 0.0 to 1.0
int N = 4; // four signals
double ff, fi;
fi = ff = f * (double)(N);
fi = floor(fi);
int s0 = (int)(fi);
int s1 = (s0+1) % N;
ff -= fi; // fraction

out = linear_interpolate(signal[s0], signal[s1], ff);
this will give you a linear mix.. you can further play with the actual mixing, shape the fraction (ff) or use a pan law of some sort..
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

Thank you Antto! Just what I was after. :hyper:

Post Reply

Return to “DSP and Plugin Development”