diff options
-rw-r--r-- | sms.py | 4 | ||||
-rw-r--r-- | sms/analysis.c | 9 |
2 files changed, 8 insertions, 5 deletions
@@ -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]; } |