How to find maximums or peaks of sound

Untested example.
Leo..

int rawValue, minimum, maximum, peakValue;
int threshold = 100; // sensitivity

void setup() {
  Serial.begin(9600);
}

void loop() {
  minimum = 0; // reset
  maximum = 0;
  for (int i = 0; i < 500; i++) { // measure
    rawValue = analogRead(A0);
    if (rawValue < minimum) minimum = rawValue; // store min peak
    if (rawValue > maximum) maximum = rawValue; // store max peak
  }
  peakValue = maximum - minimum; // calc difference
  if (peakValue > threshold) { // action
    // do something
  }
  Serial.print("Peak value: ");
  Serial.println(peakValue);
  delay(250); // remove in final code
}