diff --git a/cmProc5.c b/cmProc5.c index a0f6449..af156db 100644 --- a/cmProc5.c +++ b/cmProc5.c @@ -694,6 +694,8 @@ cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp ) cmReflectCalc_t* p = *pp; + cmReflectCalcWrite(p,"/Users/kevin/temp/cmkc"); + if((rc = cmReflectCalcFinal(p)) != cmOkRC ) return rc; @@ -755,9 +757,12 @@ cmRC_t cmReflectCalcFinal( cmReflectCalc_t* p ) return cmOkRC; } -cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* yV, unsigned xyN ) +cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN ) { unsigned i; + + // feed audio into the PHAT's buffer + cmPhatExec(p->phat,xV,xyN); for(i=0; ixi) { @@ -766,12 +771,16 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* y else yV[i] = 0; + // if the PHAT has a complete buffer if( p->xi == p->phat->fhN ) { p->xi = 0; + // execute the correlation cmPhatChExec(p->phat,0,0,0); + // p->phat->xV now holds the correlation result + if( p->va != NULL ) cmVectArrayAppendS(p->va,p->phat->xV,p->phat->fhN ); } @@ -781,3 +790,20 @@ cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* y return cmOkRC; } + +cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr ) +{ + cmRC_t rc = cmOkRC; + + if( p->va != NULL) + { + const char* path = NULL; + + if((rc = cmVectArrayWrite(p->va, path = cmFsMakeFn(path,"reflect_calc","va",dirStr,NULL) )) != cmOkRC ) + rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Reflect calc file write failed."); + + cmFsFreeFn(path); + } + + return rc; +} diff --git a/cmProc5.h b/cmProc5.h index 84719b5..34f367c 100644 --- a/cmProc5.h +++ b/cmProc5.h @@ -208,11 +208,11 @@ extern "C" { cmReflectCalc_t* cmReflectCalcAlloc( cmCtx* ctx, cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult ); - cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp ); - cmRC_t cmReflectCalcInit( cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult ); + cmRC_t cmReflectCalcFree( cmReflectCalc_t** pp ); + cmRC_t cmReflectCalcInit( cmReflectCalc_t* p, const cmGoldSigArg_t* gsa, float phat_alpha, unsigned phat_mult ); cmRC_t cmReflectCalcFinal( cmReflectCalc_t* p ); - cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t xV, cmSample_t* yV, unsigned xyN ); - + cmRC_t cmReflectCalcExec( cmReflectCalc_t* p, const cmSample_t* xV, cmSample_t* yV, unsigned xyN ); + cmRC_t cmReflectCalcWrite( cmReflectCalc_t* p, const char* dirStr ); #ifdef __cplusplus