         maxval=fht_log_out[i];
         maxi=i;
       }
-      noise_acc += fht_log_out[i];
     }
-    noise_val = noise_acc/126.0f;
     sei();
-    int note=maxi;
+    note=maxi;
+    
     // Evaluate a window around the detected note
     float notef = 0;
     int accum=0;

        accum += v;
      }
    }
  
    //Serial.print("\n");
    
    if(accum>0)
    { Serial.print(" ");
      Serial.print(notef/(float)(accum));
      Serial.print(" ");
      Serial.print(note-win);
      Serial.print(" ");
      Serial.print(note+win);
      Serial.print(" ");
      Serial.print(maxval);
      Serial.print(" ");
      Serial.print(noise_val);
      Serial.print(" ");
      Serial.print(maxval/noise_val);
      Serial.print(" ");
      Serial.print(volume);
      Serial.println(" ");

    fht_mag_log(); // take the output of the fht
    uint8_t maxval=0;
    int maxi=0;
    //for(int i=0;i<FHT_N/2;i++)
    for(int i=0;i<126;i++)
    {
