diff --git a/cmProc3.c b/cmProc3.c index 0c01940..0108037 100644 --- a/cmProc3.c +++ b/cmProc3.c @@ -2057,7 +2057,7 @@ cmRC_t cmXfaderExec( cmXfader* p, unsigned procSmpCnt, const bool* chGateV, 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)); + cp->ep_gain = sqrt(0.5 - 0.5 * cos(3.14159*cp->gain)); } else { @@ -2133,6 +2133,22 @@ void cmXfaderAllOff( cmXfader* p ) p->chArray[i].gateFl = false; } +void cmXfaderJumpToDestinationGain( cmXfader* p ) +{ + unsigned i = 0; + for(i=0; ichCnt; ++i) + { + if( p->chArray[i].gateFl ) + p->chArray[i].gain = 1.0; + else + p->chArray[i].gain = 0.0; + + p->chArray[i].onFl = false; + p->chArray[i].offFl = false; + p->chArray[i].ep_gain = p->chArray[i].gain; + } +} + //========================================================================================================================================== cmFader* cmFaderAlloc( cmCtx*c, cmFader* p, cmReal_t srate, cmReal_t fadeTimeMs ) { diff --git a/cmProc3.h b/cmProc3.h index 852d5bc..c1fd407 100644 --- a/cmProc3.h +++ b/cmProc3.h @@ -299,8 +299,8 @@ extern "C" { // to the audio signal - unless you use cmXfaderExecAudio() typedef struct { - cmReal_t ep_gain; - cmReal_t gain; + cmReal_t ep_gain; // equal power xfade gain + cmReal_t gain; // linear gain bool gateFl; // true if channel is on bool onFl; // true if gateFl transitioned to true on this cycle bool offFl; // true if gateFl transitioned to false on this cycle @@ -333,6 +333,7 @@ extern "C" { // Set all gates to false except chIdx. void cmXfaderSelectOne( cmXfader* p, unsigned chIdx ); void cmXfaderAllOff( cmXfader* p ); + void cmXfaderJumpToDestinationGain( cmXfader* p ); // jump to dest. gain based on gate state //======================================================================================================================= // This fader object accepts a gate signal. When the gate is high it increments