summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sms/filters.c20
-rw-r--r--sms/sms.c2
-rw-r--r--sms/sms.h2
3 files changed, 18 insertions, 6 deletions
diff --git a/sms/filters.c b/sms/filters.c
index 9c13ad5..7f31317 100644
--- a/sms/filters.c
+++ b/sms/filters.c
@@ -33,9 +33,13 @@
*/
sfloat sms_preEmphasis(sfloat fInput, SMS_AnalParams *pAnalParams)
{
- sfloat fOutput = fInput - SMS_EMPH_COEF * pAnalParams->preEmphasisLastValue;
- pAnalParams->preEmphasisLastValue = fOutput;
- return fOutput;
+ if(pAnalParams->preEmphasis)
+ {
+ sfloat fOutput = fInput - SMS_EMPH_COEF * pAnalParams->preEmphasisLastValue;
+ pAnalParams->preEmphasisLastValue = fOutput;
+ return fOutput;
+ }
+ return fInput;
}
/* de-emphasis filter function, it returns the filtered value
@@ -44,9 +48,13 @@ sfloat sms_preEmphasis(sfloat fInput, SMS_AnalParams *pAnalParams)
*/
sfloat sms_deEmphasis(sfloat fInput, SMS_SynthParams *pSynthParams)
{
- sfloat fOutput = fInput + SMS_EMPH_COEF * pSynthParams->deEmphasisLastValue;
- pSynthParams->deEmphasisLastValue = fInput;
- return fOutput;
+ if(pSynthParams->deEmphasis)
+ {
+ sfloat fOutput = fInput + SMS_EMPH_COEF * pSynthParams->deEmphasisLastValue;
+ pSynthParams->deEmphasisLastValue = fInput;
+ return fOutput;
+ }
+ return fInput;
}
/*! \brief function to implement a zero-pole filter
diff --git a/sms/sms.c b/sms/sms.c
index 89bfa9f..8294224 100644
--- a/sms/sms.c
+++ b/sms/sms.c
@@ -139,6 +139,7 @@ void sms_initAnalParams(SMS_AnalParams *pAnalParams)
pAnalParams->iMaxDelayFrames = MAX(pAnalParams->iMinTrackLength, pAnalParams->iMaxSleepingTime) + 2 +
(pAnalParams->minGoodFrames + pAnalParams->analDelay);
pAnalParams->fResidualAccumPerc = 0.;
+ pAnalParams->preEmphasis = 1; /*!< perform pre-emphasis by default */
pAnalParams->preEmphasisLastValue = 0.;
/* spectral envelope params */
pAnalParams->specEnvParams.iType = SMS_ENV_NONE; /* turn off enveloping */
@@ -412,6 +413,7 @@ void sms_initSynthParams(SMS_SynthParams *synthParams)
synthParams->pPhaseBuff = NULL;
synthParams->pSpectra = NULL;
synthParams->approxEnvelope = NULL;
+ synthParams->deEmphasis = 1; /*!< perform de-emphasis by default */
synthParams->deEmphasisLastValue = 0;
}
diff --git a/sms/sms.h b/sms/sms.h
index 6e5e407..f998145 100644
--- a/sms/sms.h
+++ b/sms/sms.h
@@ -242,6 +242,7 @@ typedef struct
int analDelay; /*! number of frames in the past to be looked in possible re-analyze */
sfloat fResidualAccumPerc; /*!< accumalitive residual percentage */
int sizeNextRead; /*!< size of samples to read from sound file next analysis */
+ int preEmphasis; /*!< whether or not to perform pre-emphasis */
sfloat preEmphasisLastValue;
SMS_Data prevFrame; /*!< the previous analysis frame */
SMS_SEnvParams specEnvParams; /*!< all data for spectral enveloping */
@@ -306,6 +307,7 @@ typedef struct
int origSizeHop; /*!< original number of samples used to create each analysis frame */
int nTracks;
int nStochasticCoeff;
+ int deEmphasis; /*!< whether or not to perform de-emphasis */
sfloat deEmphasisLastValue;
sfloat *pFDetWindow; /*!< array to hold the window used for deterministic synthesis \see SMS_WIN_IFFT */
sfloat *pFStocWindow; /*!< array to hold the window used for stochastic synthesis (Hanning) */