From 2b9cec80434f0bef506633deff97d289b483c97d Mon Sep 17 00:00:00 2001
From: John Glover <j@johnglover.net>
Date: Sat, 16 Feb 2013 15:22:20 +0000
Subject: [mq] Fix bug in TWM and use more harmonics in predictions.

---
 simpl/mq.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/simpl/mq.py b/simpl/mq.py
index 8e86718..d8a701d 100644
--- a/simpl/mq.py
+++ b/simpl/mq.py
@@ -18,7 +18,7 @@ def twm(peaks, f_min=0.0, f_max=3000.0, f_step=20.0):
     q = 1.4
     r = 0.5
     rho = 0.33
-    N = 8
+    N = 20
     Err = {}
 
     max_amp = max([x.amplitude for x in peaks])
@@ -43,7 +43,7 @@ def twm(peaks, f_min=0.0, f_max=3000.0, f_step=20.0):
 
         # calculate mismatch between predicted and actual peaks
         for h in harmonics:
-            k = best_match(f_current, [x.frequency for x in peaks])
+            k = best_match(h, [x.frequency for x in peaks])
             f = peaks[k].frequency
             a = peaks[k].amplitude
             Err_pm += abs(h - f) * (h ** -p) + (a / max_amp) * \
-- 
cgit v1.2.3