diff options
author | John Glover <glover.john@gmail.com> | 2010-12-01 19:52:02 +0000 |
---|---|---|
committer | John Glover <glover.john@gmail.com> | 2010-12-01 19:52:02 +0000 |
commit | e5625a21b62f11c7eccc0808a77766b50d973ea4 (patch) | |
tree | b2b4787c2639c45ebcb617d62ae11e45f4c32e60 /sms/peakDetection.c | |
parent | 5e25edb1b78f28bee09bd7513a80fb500bbd59c4 (diff) | |
download | simpl-e5625a21b62f11c7eccc0808a77766b50d973ea4.tar.gz simpl-e5625a21b62f11c7eccc0808a77766b50d973ea4.tar.bz2 simpl-e5625a21b62f11c7eccc0808a77766b50d973ea4.zip |
Fixed some memory management problems in the SMS analysis process
Diffstat (limited to 'sms/peakDetection.c')
-rw-r--r-- | sms/peakDetection.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sms/peakDetection.c b/sms/peakDetection.c index fc40e69..dfaddd4 100644 --- a/sms/peakDetection.c +++ b/sms/peakDetection.c @@ -169,17 +169,23 @@ int sms_detectPeaks(int sizeSpec, sfloat *pMag, sfloat *pPhase, sfloat fInvSizeFft = 1.0 / sizeFft; int iFirstBin = MAX(1, sizeFft * pAnalParams->fLowestFreq / pAnalParams->iSamplingRate); int iHighestBin = MIN(sizeSpec-1, sizeFft * pAnalParams->fHighestFreq / pAnalParams->iSamplingRate); + int iPeak = 0; /* clear peak structure */ - memset(pSpectralPeaks, 0, pAnalParams->maxPeaks * sizeof(SMS_Peak)); + for(iPeak = 0; iPeak < pAnalParams->maxPeaks; iPeak++) + { + pSpectralPeaks[iPeak].fFreq = 0.0; + pSpectralPeaks[iPeak].fMag = 0.0; + pSpectralPeaks[iPeak].fPhase = 0.0; + } /* set starting search values */ int iCurrentLoc = iFirstBin; - int iPeak = 0; /* index for spectral search */ sfloat fPeakMag = 0.0; /* magnitude of peak */ sfloat fPeakLoc = 0.0; /* location of peak */ /* find peaks */ + iPeak = 0; while((iPeak < pAnalParams->maxPeaks) && (FindNextPeak(pMag, iHighestBin, &iCurrentLoc, &fPeakMag, &fPeakLoc, pAnalParams->fMinPeakMag) == 1)) |