 
 #define ACC_SIZE 64
 #define FFT_SIZE 512
-#define HANN_SIZE 20
+#define HANN_SIZE 40
 #define FS (16000.0 / ACC_SIZE)
 #define F2 4.0f
 #define END_INDEX ((uint16_t) (F2 / (FS / FFT_SIZE)))

  fft_phase(FS, 0, F2, FFT_SIZE, fftBuffer, mag, phase, startIndex, endIndex);
  updatePhase(mag, phase, startIndex, endIndex);
  float hz = FS * _phaseRateAverage / 2 / PI;
  Serial.print("endIndex: "); Serial.println(endIndex);
  Serial.print("END_INDEX: "); Serial.println(END_INDEX);
  // Serial.print("BPM: "); Serial.println(hz * 60);
  //Serial.print("radsPerUpdate: "); Serial.println(_phaseRateAverage);


    }
    for (int i = 0; i < samplesRead; i++) {
      float newVal = tempBuffer[i];
      //acc += newVal * newVal;
      acc += newVal;
      numInAcc++;
      if (numInAcc >= ACC_SIZE) {
          float value = acc / ACC_SIZE;
          acc = 0;
          numInAcc = 0;
          addToFFT(value * value);
          // addToFFT(value);
      }

      //samples--;
    }
