diff options
author | John Glover <john@john-glovers-macbook.local> | 2010-12-21 11:25:11 +0000 |
---|---|---|
committer | John Glover <john@john-glovers-macbook.local> | 2010-12-21 11:25:11 +0000 |
commit | 8373f12eaf63b6db27a1848202a86aeeb15c4d26 (patch) | |
tree | 4f00a58a2d9b4939ccc3225aa76d20570d793cc2 /sms/synthesis.c | |
parent | 3f5c5d34d99b121bb621230a918b621a9524a015 (diff) | |
download | simpl-8373f12eaf63b6db27a1848202a86aeeb15c4d26.tar.gz simpl-8373f12eaf63b6db27a1848202a86aeeb15c4d26.tar.bz2 simpl-8373f12eaf63b6db27a1848202a86aeeb15c4d26.zip |
Fixing bugs in SMSResidual.
Diffstat (limited to 'sms/synthesis.c')
-rw-r--r-- | sms/synthesis.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sms/synthesis.c b/sms/synthesis.c index 8a679ca..e9b0967 100644 --- a/sms/synthesis.c +++ b/sms/synthesis.c @@ -146,6 +146,68 @@ static int StocSynthApprox(SMS_Data *pSmsData, SMS_SynthParams *pSynthParams) return 1; } +/*! \brief synthesizes one frame of the residual signal + * + * \param residualParams Parameters and memory for residual synthesis + */ +void sms_approxResidual(SMS_ResidualParams *residualParams) +{ + /* filter residual with a high pass filter */ + sms_filterHighPass(residualParams->residualSize, + residualParams->residual, + residualParams->samplingRate); + + sms_spectrumMag(residualParams->residualSize, + residualParams->residual, + residualParams->residualWindow, + residualParams->sizeStocMagSpectrum, + residualParams->stocMagSpectrum, + residualParams->fftBuffer); + + sms_spectralApprox(residualParams->stocMagSpectrum, + residualParams->sizeStocMagSpectrum, + residualParams->sizeStocMagSpectrum, + residualParams->stocCoeffs, + residualParams->nCoeffs, + residualParams->nCoeffs, + residualParams->approxEnvelope); + + /* get energy of spectrum */ + int i; + sfloat fMag = 0.0; + /*for(i = 0; i < pAnalParams->sizeStocMagSpectrum; i++)*/ + /* fMag += (pAnalParams->stocMagSpectrum[i] * pAnalParams->stocMagSpectrum[i]);*/ + + /**pSmsData->pFStocGain = fMag / pAnalParams->sizeStocMagSpectrum;*/ + + /*int i, sizeSpec1Used;*/ + /*int sizeSpec1 = pSmsData->nCoeff;*/ + /*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;*/ + + /*sizeSpec1Used = sizeSpec1 * pSynthParams->iSamplingRate / pSynthParams->iOriginalSRate;*/ + + /*[> sizeSpec1Used cannot be more than what is available \todo check by graph <]*/ + /*if(sizeSpec1Used > sizeSpec1) sizeSpec1Used = sizeSpec1;*/ + + /*sms_spectralApprox(pSmsData->pFStocCoeff, sizeSpec1, sizeSpec1Used,*/ + /* pSynthParams->pMagBuff, sizeSpec2, sizeSpec1Used,*/ + /* pSynthParams->approxEnvelope);*/ + + /*[> generate random phases <]*/ + /*for(i = 0; i < sizeSpec2; i++)*/ + /* pSynthParams->pPhaseBuff[i] = TWO_PI * sms_random();*/ + + /*sms_invQuickSpectrumW(pSynthParams->pMagBuff, pSynthParams->pPhaseBuff,*/ + /* sizeFft, pSynthParams->pSynthBuff, sizeFft,*/ + /* pSynthParams->pFStocWindow, pSynthParams->pSpectra);*/ +} + /*! \brief synthesizes one frame of SMS data * * \param pSmsData input SMS data |