Bug #925

Bounding box returned pitches are outside the range of drawn box

Added by Rachel Bittner over 10 years ago. Updated over 10 years ago.

Status:NewStart date:2014-04-09
Priority:NormalDue date:
Assignee:-% Done:

50%

Category:-
Target version:-

Description

When drawing a bounding box to get a pitch estimation, in many cases the frequency values returned are outside the selected range.

History

#1 Updated by Matthias Mauch over 10 years ago

Rachel Bittner wrote:

When drawing a bounding box to get a pitch estimation, in many cases the frequency values returned are outside the selected range.

Vertically or horizontally? (I should really be in bed... goodnight!)

#2 Updated by Rachel Bittner over 10 years ago

Vertically or horizontally? (I should really be in bed... goodnight!)

Vertically. (Horizontally as well, but this is not as big of a deal in my opinion)
Goodnight!

#3 Updated by Matthias Mauch over 10 years ago

  • % Done changed from 0 to 50

Ok, I fixed the horizontally overlapping ones.
Next vertial...

#4 Updated by Matthias Mauch over 10 years ago

Ok, I actually did vertical as well. It was mainly noticable in the bass frequencies, where the bin spacing is quite coarse.
The CHP plugin always uses the frequency bins that overlap the chosen frequency range. So there is always a danger of getting outside the box.

I changed it to only output frequencies that are in the chosen range, but I can't push the changes at the moment because I'm not a developer on the CHP project.
Chris, can you add me to that? My contribution, I hope would be benign (see patch, below).

diff -r e9b629578488 -r 5fb59edfab99 ConstrainedHarmonicPeak.cpp
--- a/ConstrainedHarmonicPeak.cpp    Mon Mar 10 14:51:09 2014 +0000
+++ b/ConstrainedHarmonicPeak.cpp    Thu Apr 10 18:37:55 2014 +0100
@@ -317,16 +317,25 @@
     double maxdb = -120.0;
     int maxidx = 0;
     for (int i = 0; i <= maxbin - minbin; ++i) {
-    if (hps[i] > maxdb) {
-        maxdb = hps[i];
-        maxidx = i;
-    }
+        if (hps[i] > maxdb) {
+            maxdb = hps[i];
+            maxidx = i;
+        }
+    }
+
+    if (maxidx == 0 || maxidx == maxbin - minbin) { // edge cases are useless
+        return fs;
     }

     double interpolated = findInterpolatedPeak(hps, maxidx, maxbin - minbin + 1);
+    
     interpolated = interpolated + minbin;

     double freq = interpolated * m_inputSampleRate / m_fftSize;
+    
+    if (freq < m_minFreq || freq > m_maxFreq) {
+        return fs;
+    }

Also available in: Atom PDF