]> git.sesse.net Git - pitch/commitdiff
Make glpitch user exitable.
authorsgunderson@bigfoot.com <>
Mon, 19 Jul 2010 23:02:58 +0000 (01:02 +0200)
committersgunderson@bigfoot.com <>
Mon, 19 Jul 2010 23:02:58 +0000 (01:02 +0200)
glpitch.cpp

index e40f8ce83c7c4138224b5fca209601257cc5a709..a3c301051046fe2466b3bb5a7a45a234a905703d 100644 (file)
@@ -27,6 +27,19 @@ int main(void)
        glClear(GL_COLOR_BUFFER_BIT);
 
        for ( ;; ) {
+               SDL_Event event;
+               while (SDL_PollEvent(&event)) {
+                       switch (event.type) {
+                       case SDL_KEYUP:
+                               if (event.key.keysym.sym == SDLK_ESCAPE) {
+                                       exit(0);
+                               }
+                               break;
+                       case SDL_QUIT:
+                               exit(0);
+                       }
+               }
+
                short buf[FFT_LENGTH / PAD_FACTOR / OVERLAP];
                read_chunk(fd, buf, FFT_LENGTH / PAD_FACTOR / OVERLAP);
                std::pair<double, double> peak = pd.detect_pitch(buf);