       continue;
     }
     for (int i = 0; i < samplesRead; i++) {
-      minwave = min(sampleBuffer[i], minwave);
-      maxwave = max(sampleBuffer[i], maxwave);
-      samples--;
+      float newVal = tempBuffer[i];
+      acc += newVal;
+      numInAcc++;
+      if (numInAcc >= ACC_SIZE) {
+          float value = acc / ACC_SIZE;
+          acc = 0;
+          numInAcc = 0;
+          minwave = min(value, minwave);
+          maxwave = max(value, maxwave);
+          addToFFT(value);
+      }
+      // minwave = min(tempBuffer[i], minwave);
+      // maxwave = max(tempBuffer[i], maxwave);
+
+      //samples--;
     }
     // clear the read count
     samplesRead = 0;
   }
+  Serial.print("max: ");
+  Serial.println(maxwave);
+  Serial.print("min: ");
+  Serial.println(minwave);
   return maxwave - minwave;
 }
 

  delay(300);
}

/*****************************************************************/
int32_t getPDMwave(int32_t samples) {
  short minwave = 30000;

int32_t mic;

extern PDMClass PDM;
short tempBuffer[256];  // buffer to read samples into, each sample is 16-bits
float acc = 0;
float fftBuffer[FFT_SIZE];
uint16_t numInAcc = 0;
volatile int samplesRead; // number of samples read

void setup(void) {
  // This allows for higher precision micros().  Without dwt micros updates in increments of about 1000.
  dwt_enable();
  Serial.begin(115200);
  // while (!Serial) delay(10);
  Serial.println("Feather Sense Sensor Demo");
