cmDspKr.c : Added compiled bypass flag and parameter setters to EchoCancel.
This commit is contained in:
parent
2d1f53c3d0
commit
0d1824b9c3
@ -3787,11 +3787,11 @@ cmDspInst_t* _cmDspEchoCancelAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
|
|||||||
0 );
|
0 );
|
||||||
|
|
||||||
|
|
||||||
p->r = cmNlmsEcAlloc(ctx->cmProcCtx, NULL, 0,0,0 );
|
p->r = cmNlmsEcAlloc(ctx->cmProcCtx, NULL, 0, 0,0,0 );
|
||||||
|
|
||||||
cmDspSetDefaultDouble( ctx, &p->inst, kMuEcId, 0, 0.1);
|
cmDspSetDefaultDouble( ctx, &p->inst, kMuEcId, 0, 0.1);
|
||||||
cmDspSetDefaultUInt( ctx, &p->inst, kImpRespN_EcId, 0, 2048);
|
cmDspSetDefaultUInt( ctx, &p->inst, kImpRespN_EcId, 0, 2048);
|
||||||
cmDspSetDefaultUInt( ctx, &p->inst, kDelayN_EcId, 0, 3963);
|
cmDspSetDefaultUInt( ctx, &p->inst, kDelayN_EcId, 0, 1906);
|
||||||
|
|
||||||
return &p->inst;
|
return &p->inst;
|
||||||
}
|
}
|
||||||
@ -3804,7 +3804,7 @@ cmDspRC_t _cmDspEchoCancelSetup( cmDspCtx_t* ctx, cmDspInst_t* inst )
|
|||||||
unsigned hN = cmDspUInt(inst,kImpRespN_EcId);
|
unsigned hN = cmDspUInt(inst,kImpRespN_EcId);
|
||||||
unsigned delayN = cmDspUInt(inst,kDelayN_EcId);
|
unsigned delayN = cmDspUInt(inst,kDelayN_EcId);
|
||||||
|
|
||||||
if( cmNlmsEcInit(p->r,mu,hN,delayN) != cmOkRC )
|
if( cmNlmsEcInit(p->r,cmDspSampleRate(ctx),mu,hN,delayN) != cmOkRC )
|
||||||
rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to initialize the internal echo canceller.");
|
rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Unable to initialize the internal echo canceller.");
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -3835,6 +3835,7 @@ cmDspRC_t _cmDspEchoCancelExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
|
|||||||
{
|
{
|
||||||
cmDspRC_t rc = kOkDspRC;
|
cmDspRC_t rc = kOkDspRC;
|
||||||
cmDspEchoCancel_t* p = (cmDspEchoCancel_t*)inst;
|
cmDspEchoCancel_t* p = (cmDspEchoCancel_t*)inst;
|
||||||
|
bool bypassFl = false;
|
||||||
|
|
||||||
const cmSample_t* fV = cmDspAudioBuf(ctx,inst,kFiltInEcId,0);
|
const cmSample_t* fV = cmDspAudioBuf(ctx,inst,kFiltInEcId,0);
|
||||||
unsigned fN = cmDspAudioBufSmpCount(ctx,inst,kFiltInEcId,0);
|
unsigned fN = cmDspAudioBufSmpCount(ctx,inst,kFiltInEcId,0);
|
||||||
@ -3845,21 +3846,50 @@ cmDspRC_t _cmDspEchoCancelExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
|
|||||||
cmSample_t* yV = cmDspAudioBuf(ctx,inst,kOutEcId,0);
|
cmSample_t* yV = cmDspAudioBuf(ctx,inst,kOutEcId,0);
|
||||||
unsigned yN = cmDspAudioBufSmpCount(ctx,inst,kOutEcId,0);
|
unsigned yN = cmDspAudioBufSmpCount(ctx,inst,kOutEcId,0);
|
||||||
|
|
||||||
|
assert( fN==uN && fN==yN );
|
||||||
|
|
||||||
|
if( bypassFl )
|
||||||
|
{
|
||||||
|
cmVOS_Copy(yV,yN,fV);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if( fV !=NULL && uV != NULL && yV != NULL )
|
if( fV !=NULL && uV != NULL && yV != NULL )
|
||||||
{
|
{
|
||||||
assert( uN == yN && fN == yN );
|
assert( uN == yN && fN == yN );
|
||||||
cmNlmsEcExec(p->r,uV,fV,yV,yN);
|
cmNlmsEcExec(p->r,uV,fV,yV,yN);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmDspRC_t _cmDspEchoCancelRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
cmDspRC_t _cmDspEchoCancelRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
||||||
{
|
{
|
||||||
//cmDspEchoCancel_t* p = (cmDspEchoCancel_t*)inst;
|
cmDspEchoCancel_t* p = (cmDspEchoCancel_t*)inst;
|
||||||
|
|
||||||
cmDspSetEvent(ctx,inst,evt);
|
cmDspSetEvent(ctx,inst,evt);
|
||||||
|
|
||||||
|
if( p->r != NULL )
|
||||||
|
{
|
||||||
|
switch(evt->dstVarId)
|
||||||
|
{
|
||||||
|
case kMuEcId:
|
||||||
|
cmNlmsEcSetMu( p->r, cmDspReal(inst,kMuEcId));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kImpRespN_EcId:
|
||||||
|
cmNlmsEcSetIrN( p->r, cmDspUInt(inst,kImpRespN_EcId));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kDelayN_EcId:
|
||||||
|
cmNlmsEcSetDelayN( p->r, cmDspUInt(inst,kDelayN_EcId));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("mu:%f dN:%i hN:%i\n",p->r->mu,p->r->delayN,p->r->hN);
|
||||||
|
|
||||||
return kOkDspRC;
|
return kOkDspRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user