Record peak microphone readings

Hi,

I am trying to make a prototype SPL meter for a college project. I need to collect the average level over hour periods. This information will then be inputted into a mySQL database.

I have copied this code from the adafruit website:

And my equipment setup is the same too:

In the serial monitor i am getting readings in volts, which is fine for now.

As you can see in the code, a reading is taken every 50ms. That is 72,000 readings in an hour.

What i need (ideally within the pc) is to calculate the average (im guessing - add all of the 72,000 readings, then divide by 72,000). This will give me a number that i can will go into the database and be displayed on a .php website.

Help and advice would be very much appreciated!

/****************************************
Example Sound Level Sketch for the 
Adafruit Microphone Amplifier
****************************************/

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

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


void loop() 
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level

   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;

   // collect data for 50 mS
   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(0);
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
   double volts = (peakToPeak * 3.3) / 1024;  // convert to volts

   Serial.println(volts);
}

See Storing, and averaging microphone readings for more information.

What, exactly, are you measuring? I suspect that trends may be more interesting than an average over a one hour period.