From fadafa8e6b7481efcb97c5f6cdfa74039bd815be Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 1 Nov 2013 18:30:40 -0700 Subject: [PATCH] cmProc3.h : Added equal power cross fade to XFader object. --- cmProc3.c | 6 +++++- cmProc3.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmProc3.c b/cmProc3.c index e4dbf80..0c01940 100644 --- a/cmProc3.c +++ b/cmProc3.c @@ -2055,10 +2055,14 @@ cmRC_t cmXfaderExec( cmXfader* p, unsigned procSmpCnt, const bool* chGateV, cmReal_t g = cp->gain; if( cp->gateFl ) + { cp->gain = cmMin(cp->gain + i_dgain,1.0); + cp->ep_gain = sqrt(0.5 + 0.5 * cos(3.14159*cp->gain)); + } else { cp->gain = cmMax(cp->gain - o_dgain,0.0); + cp->ep_gain = sqrt(0.5 - 0.5 * cos(3.14159*cp->gain)); cp->offFl = g>0.0 && cp->gain==0.0; // notice fade-out transition end } @@ -2094,7 +2098,7 @@ cmRC_t cmXfaderExecAudio( cmXfader* p, unsigned procSmpCnt, const bool* gateV unsigned i; for(i=0; ichArray[i].gain); + cmVOS_MultVaVS(y,procSmpCnt,x[i],p->chArray[i].ep_gain); return rc; } diff --git a/cmProc3.h b/cmProc3.h index 07525b2..852d5bc 100644 --- a/cmProc3.h +++ b/cmProc3.h @@ -299,6 +299,7 @@ extern "C" { // to the audio signal - unless you use cmXfaderExecAudio() typedef struct { + cmReal_t ep_gain; cmReal_t gain; bool gateFl; // true if channel is on bool onFl; // true if gateFl transitioned to true on this cycle