]> git.sesse.net Git - pitch/commitdiff
Add the same dB-safeguard to glpitch as to pitch.
authorsgunderson@bigfoot.com <>
Mon, 19 Jul 2010 22:15:28 +0000 (00:15 +0200)
committersgunderson@bigfoot.com <>
Mon, 19 Jul 2010 22:15:28 +0000 (00:15 +0200)
glpitch.cpp

index 90c47b8502715ec95bda0f2a7e73a97c819dc26d..e40f8ce83c7c4138224b5fca209601257cc5a709 100644 (file)
@@ -49,17 +49,18 @@ int main(void)
                glVertex2f(MAX_X, 0.0f);
                glEnd();
 
                glVertex2f(MAX_X, 0.0f);
                glEnd();
 
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
-               double peak_pos = find_pos(peak.first);
-
-               glBegin(GL_QUADS);      
-               glColor4f(0.0, 1.0f, 0.0f, 0.2f);
-               glVertex2f(peak_pos - 0.1, 0.0f);
-               glVertex2f(peak_pos - 0.1, 1.0f);
-               glVertex2f(peak_pos + 0.1, 1.0f);
-               glVertex2f(peak_pos + 0.1, 0.0f);
-               glEnd();
+               if (peak.second - log10(FFT_LENGTH) >= 0.0) {
+                       double peak_pos = find_pos(peak.first);
+
+                       glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+                       glBegin(GL_QUADS);      
+                       glColor4f(0.0, 1.0f, 0.0f, 0.2f);
+                       glVertex2f(peak_pos - 0.1, 0.0f);
+                       glVertex2f(peak_pos - 0.1, 1.0f);
+                       glVertex2f(peak_pos + 0.1, 1.0f);
+                       glVertex2f(peak_pos + 0.1, 0.0f);
+                       glEnd();
+               }
 
                glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                glBegin(GL_LINES);
 
                glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                glBegin(GL_LINES);