   if (modifier < MIN_MODIFIER){
   modifier = MIN_MODIFIER;
   }
-  captureBeat(spectrum[0]);
+  captureBeat((spectrum[0]+spectrum[0])>>1);
 }
 
 void sendSpectrum() {

byte spectrum[9];


#define SIZE 1024
#define SLICE 32

byte huge[SIZE];
long energy[SIZE/SLICE];
int p = 0;
long t;
long start;
long last_beat;
long beat_length;

    sumEnergy/=SIZE;
    energy[(SIZE/SLICE)-1] = newEnergy;
    long diff = millis()-t;
    if (newEnergy > 1.2 * sumEnergy && diff > .8*beat_length) {
      if (offBeat) {
        t = millis();  
        beat_length = beat_length*.9 + diff*.1;
        if (beat_length < 375) beat_length = 375; //160bpm
        if (beat_length > 600) beat_length = 600; //100bpm
        
        bpm = 60000/(float)beat_length;
      }
      offBeat = false;
    } 
    else {
      offBeat = true;
    }

//Serial.println(bpm);
          }
  
  
}

