this hurts

Dependencies:   FFT

Revision:
6:d311a95f1e9b
Parent:
5:598d94b45bad
Parent:
3:3dbf078989b1
Child:
7:0d62545e6d73
--- a/main.cpp	Thu Dec 03 01:34:44 2020 +0000
+++ b/main.cpp	Thu Dec 03 15:50:45 2020 +0000
@@ -21,6 +21,7 @@
 string song;
 bool play;
 
+<<<<<<< working copy
 #define BUFFER_SIZE 50
 
 // delete later
@@ -38,6 +39,9 @@
  41483,37964,39215,35908,31570,28332,24492,23121,
  22874,18154,15541,15263,12463,12198,13301,9951
 };*/
+=======
+#define BUFFER_SIZE 64
+>>>>>>> merge rev
 
 // states for display output
 const int on[8][8] = {
@@ -97,19 +101,38 @@
 
 
 
+<<<<<<< working copy
 void display_fft(int sample[])
 {
 
+=======
+void display_fft(float sample[]) {
+    
+>>>>>>> merge rev
     int state = 0;
-    int freq = 0;
+    float freq = 0;
     matrix.begin(0x70);
+<<<<<<< working copy
 
     for (int a = 0; a < 50; a++) {
 
         freq = sample[a];
 
+=======
+    
+    int s = sizeof(sample);
+    
+    pc.printf("%d\n", s);
+    
+    for (int a = 0; a < 64; a++) {
+            
+        freq = sample[a];
+        
+        pc.printf("%d\n",freq);
+        
+>>>>>>> merge rev
         // determine state based on the FFT output range
-        if (freq >= 0 && freq < 10000) {
+        if (freq < 10000) {
             state = 5; // OFF
         } else if (freq >= 10000 && freq < 25000) {
             state = 4; // LOW
@@ -118,9 +141,15 @@
         } else if (freq >= 40000 && freq < 55000) {
             state = 2; // HIGH
         } else if (freq >= 55000) {
+<<<<<<< working copy
             state = 1; // ON
         }
 
+=======
+            state = 1; // HIGHEST
+        } 
+        
+>>>>>>> merge rev
         // switch statement based on the state
         switch (state) {
             case(1): // CASE HIGHEST
@@ -190,10 +219,16 @@
             default:
                 break;
         }
+<<<<<<< working copy
 
 
     }
 
+=======
+        
+        pc.printf("done");
+    
+>>>>>>> merge rev
 }
 
 //Reads SD card and passes value to frequency display
@@ -204,10 +239,16 @@
         pc.printf("Error opening file\n");
         return;
     }
+<<<<<<< working copy
 
     int buffer[BUFFER_SIZE];
+=======
+    
+    float buffer[BUFFER_SIZE];
+>>>>>>> merge rev
     int buffer_index = 0;
     int value;
+<<<<<<< working copy
     pc.printf("Thread start\n");
     while(fscanf(fp,"%d,",&value) == 1) {
         buffer[buffer_index] = value;
@@ -221,6 +262,23 @@
             memset(buffer,0,sizeof(buffer));
 
         }
+=======
+
+    while(fscanf(fp,"%d,",&value) == 1){
+           buffer[buffer_index] = (float)value;
+           buffer_index++;
+           //pc.printf("%d\n",value);
+           //buffer_index++;
+           if(buffer_index == BUFFER_SIZE)
+           {
+               //fast fourier tranform function here
+               vRealFFT(buffer, 64);
+               display_fft(buffer);
+               buffer_index = 0;
+               memset(buffer,0,sizeof(buffer));
+               
+           }
+>>>>>>> merge rev
     }
 
     fclose(fp);