From 4d00d10a308c4a0337f56d4c95b5f62596bbb69e Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 21 Jan 2013 22:08:31 +0100 Subject: [partial_tracking,sms] Fix bug in SMS partial tracking. GetNextClosestPeak was missing peaks in some situations. Some general tidy up of SMS partial tracking code. --- src/sms/sms.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/sms/sms.c') diff --git a/src/sms/sms.c b/src/sms/sms.c index ac14694..5799489 100644 --- a/src/sms/sms.c +++ b/src/sms/sms.c @@ -893,16 +893,22 @@ sfloat sms_fundDeviation(SMS_AnalParams *pAnalParams, int iCurrentFrame) int i; if(pAnalParams->minGoodFrames < 1) + { return -1; + } /* get the sum of the past few fundamentals */ for(i = 0; (i < pAnalParams->minGoodFrames) && (iCurrentFrame-i >= 0); i++) { fFund = pAnalParams->ppFrames[iCurrentFrame-i]->fFundamental; if(fFund <= 0) + { return -1; + } else + { fSum += fFund; + } } /* find the average */ @@ -910,7 +916,9 @@ sfloat sms_fundDeviation(SMS_AnalParams *pAnalParams, int iCurrentFrame) /* get the deviation from the average */ for(i = 0; (i < pAnalParams->minGoodFrames) && (iCurrentFrame-i >= 0); i++) + { fDeviation += fabs(pAnalParams->ppFrames[iCurrentFrame-i]->fFundamental - fAverage); + } /* return the deviation from the average */ return fDeviation / (pAnalParams->minGoodFrames * fAverage); -- cgit v1.2.3