summaryrefslogtreecommitdiff
path: root/src/sms/sms.c
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2013-01-21 22:08:31 +0100
committerJohn Glover <j@johnglover.net>2013-01-21 22:08:31 +0100
commit4d00d10a308c4a0337f56d4c95b5f62596bbb69e (patch)
tree84316e64a8f42359bc9992002cdb5cddbc793b8a /src/sms/sms.c
parent0e39f53d8e2092018ae54f1e6679ab837511da77 (diff)
downloadsimpl-4d00d10a308c4a0337f56d4c95b5f62596bbb69e.tar.gz
simpl-4d00d10a308c4a0337f56d4c95b5f62596bbb69e.tar.bz2
simpl-4d00d10a308c4a0337f56d4c95b5f62596bbb69e.zip
[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.
Diffstat (limited to 'src/sms/sms.c')
-rw-r--r--src/sms/sms.c8
1 files changed, 8 insertions, 0 deletions
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);