merge updates to Xfader in cmProc3.c and cmDspFx.c.
This commit is contained in:
commit
4e117d50a9
19
cmProc3.c
19
cmProc3.c
@ -2033,7 +2033,9 @@ cmRC_t cmXfaderExec( cmXfader* p, unsigned procSmpCnt, const bool* chGateV,
|
||||
bool gateFl = false;
|
||||
|
||||
// gain change associated with procSmpCnt
|
||||
cmReal_t dgain = (cmReal_t)procSmpCnt / p->fadeSmpCnt;
|
||||
//cmReal_t dgain = (cmReal_t)procSmpCnt / p->fadeSmpCnt;
|
||||
cmReal_t i_dgain = (cmReal_t)procSmpCnt / p->fadeInSmpCnt;
|
||||
cmReal_t o_dgain = (cmReal_t)procSmpCnt / p->fadeOutSmpCnt;
|
||||
|
||||
unsigned i;
|
||||
// for each channel
|
||||
@ -2053,10 +2055,10 @@ cmRC_t cmXfaderExec( cmXfader* p, unsigned procSmpCnt, const bool* chGateV,
|
||||
cmReal_t g = cp->gain;
|
||||
|
||||
if( cp->gateFl )
|
||||
cp->gain = cmMin(cp->gain + dgain,1.0);
|
||||
cp->gain = cmMin(cp->gain + i_dgain,1.0);
|
||||
else
|
||||
{
|
||||
cp->gain = cmMax(cp->gain - dgain,0.0);
|
||||
cp->gain = cmMax(cp->gain - o_dgain,0.0);
|
||||
cp->offFl = g>0.0 && cp->gain==0.0; // notice fade-out transition end
|
||||
}
|
||||
|
||||
@ -2100,6 +2102,17 @@ cmRC_t cmXfaderExecAudio( cmXfader* p, unsigned procSmpCnt, const bool* gateV
|
||||
void cmXfaderSetXfadeTime( cmXfader* p, cmReal_t fadeTimeMs )
|
||||
{
|
||||
p->fadeSmpCnt = floor(fadeTimeMs * p->srate /1000.0);
|
||||
p->fadeInSmpCnt = p->fadeSmpCnt;
|
||||
p->fadeOutSmpCnt = p->fadeSmpCnt;
|
||||
}
|
||||
|
||||
void cmXfaderSetXfadeInTime( cmXfader* p, cmReal_t fadeTimeMs )
|
||||
{
|
||||
p->fadeInSmpCnt = floor(fadeTimeMs * p->srate /1000.0);
|
||||
}
|
||||
void cmXfaderSetXfadeOutTime( cmXfader* p, cmReal_t fadeTimeMs )
|
||||
{
|
||||
p->fadeOutSmpCnt = floor(fadeTimeMs * p->srate /1000.0);
|
||||
}
|
||||
|
||||
void cmXfaderSelectOne( cmXfader* p, unsigned chIdx )
|
||||
|
@ -311,6 +311,8 @@ extern "C" {
|
||||
unsigned chCnt;
|
||||
cmXfaderCh* chArray;
|
||||
unsigned fadeSmpCnt;
|
||||
unsigned fadeInSmpCnt;
|
||||
unsigned fadeOutSmpCnt;
|
||||
cmReal_t srate;
|
||||
bool gateFl; // true if any channels are on
|
||||
bool onFl; // true on cycle where gate transitions to 'on'.
|
||||
@ -324,6 +326,9 @@ extern "C" {
|
||||
cmRC_t cmXfaderExec( cmXfader* p, unsigned procSmpCnt, const bool* gateV, unsigned chCnt );
|
||||
cmRC_t cmXfaderExecAudio( cmXfader* p, unsigned procSmpCnt, const bool* gateV, unsigned chCnt, const cmSample_t* x[], cmSample_t* y );
|
||||
void cmXfaderSetXfadeTime( cmXfader* p, cmReal_t fadeTimeMs );
|
||||
void cmXfaderSetXfadeInTime( cmXfader* p, cmReal_t fadeTimeMs );
|
||||
void cmXfaderSetXfadeOutTime( cmXfader* p, cmReal_t fadeTimeMs );
|
||||
|
||||
// Set all gates to false except chIdx.
|
||||
void cmXfaderSelectOne( cmXfader* p, unsigned chIdx );
|
||||
void cmXfaderAllOff( cmXfader* p );
|
||||
|
@ -1417,6 +1417,8 @@ enum
|
||||
kChCntXfId,
|
||||
kFadeTimeMsXfId,
|
||||
kMstrGateXfId,
|
||||
kFadeInTimeMsXfId,
|
||||
kFadeOutTimeMsXfId,
|
||||
kOnXfId,
|
||||
kOffXfId,
|
||||
kGateBaseXfId,
|
||||
@ -1445,6 +1447,8 @@ cmDspInst_t* _cmDspXfaderAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigne
|
||||
{ "chs", kChCntXfId, 0, 0, kUIntDsvFl | kReqArgDsvFl, "Input and Output channel count"},
|
||||
{ "ms", kFadeTimeMsXfId, 0, 0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Fade time in milliseonds."},
|
||||
{ "mgate", kMstrGateXfId, 0, 0, kInDsvFl | kBoolDsvFl | kOptArgDsvFl, "Master gate - can be used to set all gates."},
|
||||
{ "ims", kFadeInTimeMsXfId, 0, 0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Fade in time in milliseonds."},
|
||||
{ "oms", kFadeOutTimeMsXfId, 0, 0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Fade out time in milliseonds."},
|
||||
{ "on", kOnXfId, 0, 0, kOutDsvFl | kSymDsvFl, "Send 'on' when all ch's transition from off to on."},
|
||||
{ "off", kOffXfId, 0, 0, kOutDsvFl | kSymDsvFl, "Send 'off' when all ch's transition from on to off."},
|
||||
};
|
||||
@ -1592,6 +1596,15 @@ cmDspRC_t _cmDspXfaderRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
|
||||
p->chGateV[i] = fl;
|
||||
}
|
||||
break;
|
||||
|
||||
case kFadeInTimeMsXfId:
|
||||
cmXfaderSetXfadeInTime(p->xfdp,cmDspDouble(inst,kFadeInTimeMsXfId));
|
||||
break;
|
||||
|
||||
case kFadeOutTimeMsXfId:
|
||||
cmXfaderSetXfadeOutTime(p->xfdp,cmDspDouble(inst,kFadeOutTimeMsXfId));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// record gate changes into p->chGateV[] for later use in _cmDspXfaderExec().
|
||||
|
Loading…
Reference in New Issue
Block a user