summaryrefslogtreecommitdiff
path: root/sms/analysis.c
diff options
context:
space:
mode:
authorJohn Glover <glover.john@gmail.com>2010-10-19 17:19:31 +0100
committerJohn Glover <glover.john@gmail.com>2010-10-19 17:19:31 +0100
commitb46b988f164f983fc889c7bc0c96953e4609d27a (patch)
treecf75870f5cebc9eebe4d7540aa509d5eb89308b2 /sms/analysis.c
parent30755b92afeae5a5a32860b4f4297180f6d3398d (diff)
downloadsimpl-b46b988f164f983fc889c7bc0c96953e4609d27a.tar.gz
simpl-b46b988f164f983fc889c7bc0c96953e4609d27a.tar.bz2
simpl-b46b988f164f983fc889c7bc0c96953e4609d27a.zip
SMS bug fix, peak magnitudes from SMSPeakDetection were in db instead of linear.
Diffstat (limited to 'sms/analysis.c')
-rw-r--r--sms/analysis.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sms/analysis.c b/sms/analysis.c
index 87e5222..3f46e5f 100644
--- a/sms/analysis.c
+++ b/sms/analysis.c
@@ -222,6 +222,11 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara
pSpectralPeaks->nPeaksFound = pAnalParams->ppFrames[iCurrentFrame]->nPeaks;
pSpectralPeaks->nPeaks = pAnalParams->peakParams.iMaxPeaks;
pSpectralPeaks->pSpectralPeaks = pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks;
+ /* convert peak amps to mag */
+ for(i = 0; i < pSpectralPeaks->nPeaksFound; i++)
+ {
+ pSpectralPeaks->pSpectralPeaks[i].fMag = sms_dBToMag(pSpectralPeaks->pSpectralPeaks[i].fMag);
+ }
return pSpectralPeaks->nPeaksFound;
}
else
@@ -253,8 +258,8 @@ void sms_setPeaks(SMS_AnalParams *pAnalParams, int numamps, float* amps,
for(i = 0; i < numamps; i++)
{
- /* copy current peaks to the previous frame's peaks */
- currentFrame->pSpectralPeaks[i].fMag = amps[i];
+ /* copy current peaks data */
+ currentFrame->pSpectralPeaks[i].fMag = sms_magToDB(amps[i]);
currentFrame->pSpectralPeaks[i].fFreq = freqs[i];
currentFrame->pSpectralPeaks[i].fPhase = phases[i];
}