summaryrefslogtreecommitdiff
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
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.
-rw-r--r--sms.py4
-rw-r--r--sms/analysis.c9
2 files changed, 8 insertions, 5 deletions
diff --git a/sms.py b/sms.py
index de4277e..4c4584c 100644
--- a/sms.py
+++ b/sms.py
@@ -15,8 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import simpl
-import pysms
-import numpy as np
+import simpl.pysms as pysms
class SMSPeakDetection(simpl.PeakDetection):
"Sinusoidal peak detection using SMS"
@@ -173,7 +172,6 @@ class SMSPeakDetection(simpl.PeakDetection):
pos = 0
self._analysis_params.iSizeSound = len(audio)
while pos < len(audio):
- print pos, self.frame_size, self._analysis_params.sizeNextRead, len(audio)
# change frame size based on sizeNextRead
if not self.static_frame_size:
if pos + self.frame_size < len(audio):
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];
}