If you search the forum for ‘SPL’ you’ll get some hits. This has been discussed & done before. Although you can make something like an SPL meter, it’s difficult to make a “real one” because of averaging & [u]weighting[/u].
I know that the sensitivity of the electret mic is -44dBV/Pa, how can I use these values to calculate a value for decibels?
There’s usually a fair amount of tolerance in those specs and virtually every SPL meter is calibrated against an already-calibrated SPL meter.
Do you know what those numbers mean? I assume that’s RMS voltage…
0dBV is 1 volt, so -44dB is 6.1mV
dB = 20log(Vx/Vref)
Voltage Ratio = 10(dB/20)
One Pa is 94dB SPL (I just Googled that.) So, 94dB is 6mV (before amplification?).
Once you’ve got “the numbers” you can choose 94dB or calculate any other dB value as your internal reference.
For example, if you read 12mV, that’s +6dB relative to your 6mV reference, so you’ve got 100dB SPL.
float RMS = (volts*0.3535);
That’s only true for a sine wave. Real world sounds will have a larger peak-to-RMS (or peak-to-average) ratio. You can choose to measure peak SPL, average SPL, or RMS SPL, but you’ll have to make RMS or average calculations the “hard way”. (And average is easier than RMS).
Are you getting ‘useful’ readings?
The MAX4466 is an amplifier chip, not a microphone. Do you know how much amplification you’ve got?
I’m guessing The Arduino can’t measure negative voltages and I assume the amplifier’s output is biased but you didn’t subtract-out the bias in your readings.
Everything above plus:-
a MAX4466 electret microphone to measure sound level and have coded it so that it prints out a variation of levels from 0 - 3.3v depending on sound level.
OK it would be good to see the circuit.
Are you using an envelope follower? If not then the chances of that code finding the actual peak of the waveform are slim, and the chances drop as the frequency increases.
if (sample < 1024) // toss out spurious readings
Is stupid : you can never get a reading equal or greater than 1024 from the A/D.
And why convert the reading to volts anyway, it takes time and it is perfectly fine as an arbitrary units number.