# Calculating sound amplitude in dB from a WAV file

Started by January 27, 2005
```"Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
news:IbKdnZQLGLNhLmTcRVn-2w@centurytel.net...
>
> "Jon Harris" <goldentully@hotmail.com> wrote in message
> news:35t81qF4r6eq0U1@individual.net...
> >
> > A very important parameter is the distance between the sound source and
> > the
> > microphone.  I think 1m is a typical specification.  You also need to make
> > some
> > assumptions about the recording environment--consider that a drum played
> > in a
> > small reflective room sounds louder than the same drum outside on a lawn
> > due to
> > reflections.
>
> 1m is a typical *reference* distance for the sound pressure measured.  It
> isn't necessarily typical at all for the distance of the actual measurement.
>
> Example:
>
> Measure sound pressure level in free space (or reasonable facsimile thereof)
> at 10 meters distance from projector to receiver.
> Assume spherical spreading and correct the sound pressure level back to 1m
> using 20log(R1/R0) so 20dB where R1 is 10m and R0 is 1m.  At least that's
> how I remember it.....

That makes sense.  I've always seen the charts that say at 1m, but if you are
measuring say a jet engine, it might be a little easier to back off a bit and
then compensate mathematically when doing the actual measurement!  :-)

```
```"Jon Harris" <goldentully@hotmail.com> wrote in message
news:35ve69F4s60c0U1@individual.net...
> "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
> news:IbKdnZQLGLNhLmTcRVn-2w@centurytel.net...
>>
>> "Jon Harris" <goldentully@hotmail.com> wrote in message
>> news:35t81qF4r6eq0U1@individual.net...
>> >
>> > A very important parameter is the distance between the sound source and
>> > the
>> > microphone.  I think 1m is a typical specification.  You also need to
>> > make
>> > some
>> > assumptions about the recording environment--consider that a drum
>> > played
>> > in a
>> > small reflective room sounds louder than the same drum outside on a
>> > lawn
>> > due to
>> > reflections.
>>
>> 1m is a typical *reference* distance for the sound pressure measured.  It
>> isn't necessarily typical at all for the distance of the actual
>> measurement.
>>
>> Example:
>>
>> Measure sound pressure level in free space (or reasonable facsimile
>> thereof)
>> at 10 meters distance from projector to receiver.
>> Assume spherical spreading and correct the sound pressure level back to
>> 1m
>> using 20log(R1/R0) so 20dB where R1 is 10m and R0 is 1m.  At least that's
>> how I remember it.....
>
> That makes sense.  I've always seen the charts that say at 1m, but if you
> are
> measuring say a jet engine, it might be a little easier to back off a bit
> and
> then compensate mathematically when doing the actual measurement!  :-)

Right.  The charts or specifications use 1m because that's the standard for
comparison.  Otherwise you'd be forever trying to figure out how to compare
two sources / projectors.  This way, assuming the measurement and the
distance correction were both reasonable, you can compare two sources
directly.  Radiation patterns come into the equation of course....

Fred

```
```To make a calibrated recording you must first use good equipment that is
linear with both frequency and level over the ranges of concern.  Then, you
must make sure the equipment does not have an automatic gain control that
will attenuate loud sounds and amplify soft ones in an attempt to squeeze
everything into the best range of the system.  Then, you must record a
signal of known level on the recording, noting all gain settings of the
system.  This is most commonly done with a field calibrator - a device
placed over the microphone that produces a tone of known level.  If you make
any changes in gain settings between the recording of the calibration tone
and the recording of the sound of interest, then you must note these and
make appropriate adjustments to the level at play back.
<50295@web.de> wrote in message
> Hi everyone,
>
> I suppose this is an easy question for some, but I'm trying to
> calculate in dB, the amplitude of a recorded WAV sound file. Is this
> possible? How can it be done? Are there any libraries/APIs that do
> this?
>
> Thanks,
>
> - Olumide
>

```
```Hello Fred and others,

I recall the standard for 120 dB spl is 0.946 watts/meter^2.  So dB spl is
simply a power density. Apparently this standard assumes a standard size for
the eardrum, etc. But at least this is a way to calibrate a sound meter.

Clay

"Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
news:gt-dnZXWKaXQAWfcRVn-iw@centurytel.net...
>
> "Jon Harris" <goldentully@hotmail.com> wrote in message
> news:35ve69F4s60c0U1@individual.net...
>> "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
>> news:IbKdnZQLGLNhLmTcRVn-2w@centurytel.net...
>>>
>>> "Jon Harris" <goldentully@hotmail.com> wrote in message
>>> news:35t81qF4r6eq0U1@individual.net...
>>> >
>>> > A very important parameter is the distance between the sound source
>>> > and
>>> > the
>>> > microphone.  I think 1m is a typical specification.  You also need to
>>> > make
>>> > some
>>> > assumptions about the recording environment--consider that a drum
>>> > played
>>> > in a
>>> > small reflective room sounds louder than the same drum outside on a
>>> > lawn
>>> > due to
>>> > reflections.
>>>
>>> 1m is a typical *reference* distance for the sound pressure measured.
>>> It
>>> isn't necessarily typical at all for the distance of the actual
>>> measurement.
>>>
>>> Example:
>>>
>>> Measure sound pressure level in free space (or reasonable facsimile
>>> thereof)
>>> at 10 meters distance from projector to receiver.
>>> Assume spherical spreading and correct the sound pressure level back to
>>> 1m
>>> using 20log(R1/R0) so 20dB where R1 is 10m and R0 is 1m.  At least
>>> that's
>>> how I remember it.....
>>
>> That makes sense.  I've always seen the charts that say at 1m, but if you
>> are
>> measuring say a jet engine, it might be a little easier to back off a bit
>> and
>> then compensate mathematically when doing the actual measurement!  :-)
>
> Right.  The charts or specifications use 1m because that's the standard
> for comparison.  Otherwise you'd be forever trying to figure out how to
> compare two sources / projectors.  This way, assuming the measurement and
> the distance correction were both reasonable, you can compare two sources
> directly.  Radiation patterns come into the equation of course....
>
> Fred
>

```
```"Clay S. Turner" <Physics@Bellsouth.net> wrote in message
news:6oSKd.18\$t67.8@bignews5.bellsouth.net...
> Hello Fred and others,
>
> I recall the standard for 120 dB spl is 0.946 watts/meter^2.  So dB spl is
> simply a power density. Apparently this standard assumes a standard size
> for the eardrum, etc. But at least this is a way to calibrate a sound
> meter.
>
>
> Clay

The standard for SPL is in micropascals (Pa=N/m^2) and 0dB is *different* if
you are working in water vs. in air.  120Db spl in air is at the threshold
of pain or injury.  0dB is usually the standard or reference and at the
threshold of hearing.

0dB == 0.0002 ubar = 1E+5 upa/ubar  * 0.0002= 20upa in air
and
0dB == 1upa in water

Fred

```
```Fred Marshall wrote:

..
> The standard for SPL is in micropascals (Pa=N/m^2) and 0dB is *different* if
> you are working in water vs. in air.  120Db spl in air is at the threshold
> of pain or injury.  0dB is usually the standard or reference and at the
> threshold of hearing.
>
> 0dB == 0.0002 ubar = 1E+5 upa/ubar  * 0.0002= 20upa in air
> and
> 0dB == 1upa in water
>
> Fred
>
>
>
But note that music studio engineers use 0dBFS to indicate digital peak (i.e.
maximum amplitude, +-32767 in a 16bit system), with all lesser levels
accordingly indicated as a negative dB value. For floating point samples (in
both soundfile formats such as WAVE and AIFF-C, and streaming plugin formats
such as DX and VST), 0dBFS is defined to be 1.0. In mixing desks faders are
marked from 0dB down to -inf, with typically some room above for gain, up to
+24dB or so. This will often translate to nominal 0dB being calibrated as, for
example, -18dBFS (there are other conventions), allowing engineers to use a
digital desk and feel they have the same headroom "at the top" that they enjoyed
in the analogue-tape studio (using the famous "fader-creep" technique).

With this measuring-downwards system, the same dB level will translate
trasnparently to any sample size, whether 8bit, 24 or 32bit int, 32bit float and
even 64bit float, which some soundfile formats can support. There have even been
20bit formats.

Richard Dobson

```
```"Richard Dobson" <richarddobson@blueyonder.co.uk> wrote in message
news:nI3Ld.2659\$8B3.1098@text.news.blueyonder.co.uk...
> Fred Marshall wrote:
>
> ..
>> The standard for SPL is in micropascals (Pa=N/m^2) and 0dB is *different*
>> if you are working in water vs. in air.  120Db spl in air is at the
>> threshold of pain or injury.  0dB is usually the standard or reference
>> and at the threshold of hearing.
>>
>> 0dB == 0.0002 ubar = 1E+5 upa/ubar  * 0.0002= 20upa in air
>> and
>> 0dB == 1upa in water
>>
>> Fred
>>
>>
>>
>  But note that music studio engineers use 0dBFS to indicate digital peak
> (i.e. maximum amplitude, +-32767 in a 16bit system), with all lesser
> levels accordingly indicated as a negative dB value. For floating point
> samples (in both soundfile formats such as WAVE and AIFF-C, and streaming
> plugin formats such as DX and VST), 0dBFS is defined to be 1.0. In mixing
> desks faders are marked from 0dB down to -inf, with typically some room
> above for gain, up to +24dB or so. This will often translate to nominal
> 0dB being calibrated as, for example, -18dBFS (there are other
> conventions), allowing engineers to use a digital desk and feel they have
> the same headroom "at the top" that they enjoyed in the analogue-tape
> studio (using the famous "fader-creep" technique).
>
> With this measuring-downwards system, the same dB level will translate
> trasnparently to any sample size, whether 8bit, 24 or 32bit int, 32bit
> float and even 64bit float, which some soundfile formats can support.
> There have even been 20bit formats.

Ah.  Very interesting and a useful thing to know for DSP!
Of course, it is independent of actual SPL and only applies to received,
converted, levels.

Fred

```