cwFlowProc.cpp: Allow interactive changing of audio_delay() delay param.

This commit is contained in:
kevin 2023-05-25 16:02:00 -04:00
parent a4188a7ff0
commit abcaa093c7

View File

@ -2384,8 +2384,53 @@ namespace cw
return kOkRC;
}
rc_t _update_delay( instance_t* ctx, variable_t* var )
{
rc_t rc = kOkRC;
inst_t* inst = (inst_t*)ctx->userPtr;
abuf_t* ibuf = nullptr;
real_t delayMs = 0;
unsigned delayFrameN = 0;
if((rc = var_get(ctx,kInPId, kAnyChIdx, ibuf )) != kOkRC )
goto errLabel;
if((rc = var_get( var, delayMs )) != kOkRC )
goto errLabel;
delayFrameN = (unsigned)(fabs(delayMs) * ibuf->srate / 1000.0);
if( delayFrameN > inst->maxDelayFrameN )
{
delayFrameN = inst->maxDelayFrameN;
cwLogWarning("The audio delay length is limited to %i milliseconds.", (int)((delayFrameN * 1000) / ibuf->srate));
}
vop::zero(inst->delayBuf->buf,inst->delayBuf->chN*inst->delayBuf->frameN);
for(unsigned i=0; i<ibuf->chN; ++i)
{
inst->cntV[i] = delayFrameN;
inst->idxV[i] = 0;
}
errLabel:
return rc;
}
rc_t value( instance_t* ctx, variable_t* var )
{ return kOkRC; }
{
rc_t rc = kOkRC;
switch( var->vid )
{
case kDelayMsPId:
rc = _update_delay(ctx,var);
break;
}
return rc;
}
rc_t exec( instance_t* ctx )
{