si jala

Dependencies:   FastAnalogIn NVIC_set_all_priorities mbed-dsp mbed

Fork of KL25Z_FFT_Demo_tony by Luis Daniel Castillo

Revision:
2:177596541c8d
Parent:
1:7421267b0777
Child:
3:1c6625b2d363
--- a/main.cpp	Tue Nov 15 22:16:24 2016 +0000
+++ b/main.cpp	Tue Nov 15 23:04:41 2016 +0000
@@ -62,10 +62,9 @@
 float magnitudes[FFT_SIZE];
 int sampleCounter = 0;
 
-int arrayPosition;
-int maxFrequencyValue;
+int maxFrequencyValue = 0;
 
-int FFTFrequency;
+int FFTFrequency = 0;
 
 // Convert a frequency to the appropriate FFT bin it will fall within.
 int frequencyToBin(float frequency)
@@ -111,17 +110,20 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 
-void set_ArrayPosition()
+int set_ArrayPosition()
 {
     float maxValue = 0.0;
-    
+    int arrayPosition = 0;  
+      
     for(int counter=0; counter < FFT_SIZE; counter++)
     {
         if(magnitudes[counter] > maxValue){
             maxValue = magnitudes[counter];
-            arrayPosition = counter+1;
+            arrayPosition = counter;
         }
     }
+    
+    return arrayPosition;
 }
 
 int get_FFTFrequency()
@@ -130,7 +132,7 @@
     
     set_ArrayPosition();
     
-    return (maxFrequencyValue*arrayPosition)/FFT_SIZE;
+    return (maxFrequencyValue*sarrayPosition)/(FFT_SIZE-1);
     
 }
 ////////////////////////////////////////////////////////////////////////////////
@@ -187,9 +189,6 @@
             //Obtaining the value of the frequency 
             FFTFrequency = get_FFTFrequency();
             
-            for(int i=0; 
-            pc.printf("Frequency is: ", FFTFrequency);
-            pc.printf("\r\n [");
             
             // Restart audio sampling.
             samplingBegin();