From af918cfd3763df16f83c419ef45b5ae85f2952c3 Mon Sep 17 00:00:00 2001 From: John Glover Date: Thu, 30 Dec 2010 18:47:47 +0000 Subject: Update to sms_approxResidual --- sms/synthesis.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sms/synthesis.c b/sms/synthesis.c index e9b0967..9523ee6 100644 --- a/sms/synthesis.c +++ b/sms/synthesis.c @@ -175,20 +175,19 @@ void sms_approxResidual(SMS_ResidualParams *residualParams) /* get energy of spectrum */ int i; sfloat fMag = 0.0; - /*for(i = 0; i < pAnalParams->sizeStocMagSpectrum; i++)*/ - /* fMag += (pAnalParams->stocMagSpectrum[i] * pAnalParams->stocMagSpectrum[i]);*/ + for(i = 0; i < residualParams->sizeStocMagSpectrum; i++) + fMag += (residualParams->stocMagSpectrum[i] * pAnalParams->stocMagSpectrum[i]); - /**pSmsData->pFStocGain = fMag / pAnalParams->sizeStocMagSpectrum;*/ + /* if no gain or no coefficients return */ + sfloat stocGain = fMag / residualParams->sizeStocMagSpectrum; + if(stocGain <= 0) + return; - /*int i, sizeSpec1Used;*/ - /*int sizeSpec1 = pSmsData->nCoeff;*/ + int i, sizeSpec1Used; + int sizeSpec1 = residualParams->nCoeffs; /*int sizeSpec2 = pSynthParams->sizeHop;*/ - /*int sizeFft = pSynthParams->sizeHop << 1; [> 50% overlap, so sizeFft is 2x sizeHop <]*/ - /*sfloat fStocGain;*/ - - /*[> if no gain or no coefficients return <]*/ - /*if (*(pSmsData->pFStocGain) <= 0)*/ - /* return 0;*/ + int sizeSpec2 = residualParams->residualSize; + int sizeFft = sizeSpec2 << 1; /* 50% overlap, so sizeFft is 2x sizeHop */ /*sizeSpec1Used = sizeSpec1 * pSynthParams->iSamplingRate / pSynthParams->iOriginalSRate;*/ -- cgit v1.2.3