Add some nice but not so useful color to glpitch (showing audio volume).
authorsgunderson@bigfoot.com <>
Wed, 21 Jul 2010 17:42:28 +0000 (19:42 +0200)
committersgunderson@bigfoot.com <>
Wed, 21 Jul 2010 17:42:28 +0000 (19:42 +0200)
glpitch.cpp

index 2f81619..f494bc7 100644 (file)
@@ -100,12 +100,14 @@ int main(void)
 
                if (peak.second - log10(FFT_LENGTH) >= 0.0) {
                        double peak_pos = find_display_pos(peak.first);
+                       double strength = peak.second / 40.0f;
 
+                       glEnable(GL_POLYGON_SMOOTH);
                        glBlendFunc(GL_SRC_ALPHA, GL_ONE);
                        glEnable(GL_POLYGON_SMOOTH);
 
                        glBegin(GL_QUADS);      
-                       glColor4f(0.0, 1.0f, 0.0f, 0.2f);
+                       glColor4f(0.0f, strength, 1.0 - strength, 0.2f);
                        glVertex2f(peak_pos - 0.1, 0.0f);
                        glVertex2f(peak_pos - 0.1, 1.0f);
                        glVertex2f(peak_pos + 0.1, 1.0f);