views:

907

answers:

2

We are creating an application which records the surrounding sound and take necessary action if the sound crosses specified Decibel.

In order to achieve the application objective we are using following method from AudioQueueObject.h

- (void) getAudioLevels: (Float32 *) levels peakLevels: (Float32 *) peakLevels {

UInt32 propertySize = audioFormat.mChannelsPerFrame * sizeof (AudioQueueLevelMeterState);
AudioQueueGetProperty(
self.queueObject,
(AudioQueuePropertyID)kAudioQueueProperty_CurrentLevelMeterDB,
self.audioLevels,
&propertySize);

levels[0] = self.audioLevels[0].mAveragePower;
peakLevels[0] = self.audioLevels[0].mPeakPower;
}

We have the following set of queries

  1. The recorded sound shows the value in Decibel starting from -60. This value goes on increasing the moment sound gets louder. Maximum value recorded with this object is 0.0000. Please explain us how to interpret these values.

as per the documentation it says the values which we are getting is in digital decibels which needs to be converted to analog ,please suggest if there is any way of doing that.

thanks in advance

A: 

Digital audio consists of sample values with a particular absolute range (32767 to -32768 for CD-type audio, or +1.0 to -1.0 for floating-point). I'll assume Cocoa produces floating point audio data.

Decibel values are a relative logarithmic measure of volume. A decibel value of 0 means that the volume is as loud as it can possibly be, which corresponds to absolute sample values of +1.0 or -1.0. This earlier question gives a formula for converting decibel values to gain (gain, in contrast to decibels, is a simple linear multiplier of volume). From the formula, a decibel value of -20 dB corresponds to a gain of .1, which means your absolute sample value would be +0.1 or -0.1. -40 dB is the equivalent of a .01 gain, and -60 dB is the equivalent of a .001 gain.

MusiGenesis
first of all thanks for your valuable suggestions i just wanted to make these decibel values as the standard one like A normal conversation is 60 decibels ,Snoring is 85 decibels,A car horn is 110 decibels to track these activities kindly suggest me the ways to achieve this i will be very thankful to you guys.
@yogendra: sbooth's answer is a good explanation of how decibel units work. In your case, the noises you mention can only be analyzed by your software if they're recorded into arrays of sample values (like what's in a WAV file or on a CD). In this recording process, the peak amplitude cannot possibly be above the maximum value (32767 for CD audio, or +1.0 for floating-point), no matter what the sound is.
MusiGenesis
Out in the real world, sounds can just get louder and louder with no (practical) upper limit on volume. For this reason, the amplitude of a sound is measured in positive decibels. In a digital recording, the upper limit of volume is constrained by the maximum value of the data type, so amplitude is usually indicated by negative decibels, with 0 dB representing the maximum value.
MusiGenesis
To summarize, what you want to do is not possible at all. A recording of a mosquito buzzing right next to the microphone will sound just as loud as a recording of an airplane flying overhead (not really, but this illustrates the principle).
MusiGenesis
+3  A: 

I think part of your confusion concerns the term decibel: a decibel is a logarithmic unit that expresses the magnitude of a value relative to a reference (see Decibel). Although dB is frequently used to mean sound pressure or sound level, there are many different kinds of decibels.

The values returned by kAudioQueueProperty_CurrentLevelMeterDB are in dBFS (decibels full scale). dBFS is a digital-only measurement where 0 represents the maximum value a sample can contain (1.0 for floats, 32767 for 16 bit samples, etc), and all other values will be negative. So a float sample with a value of 0.5 would register as -6 dBFS since 20 * log10 (0.5 / 1.0) = -6.02

What you want to do is convert from dBFS (a digital measure) to dBu or dB SPL (both analog measures- dBu is referenced to 0.775 volts RMS and dB SPL to 20 µPa sound pressure).

Since dB SPL is not an SI unit, I mean 20 * log10 of the ratio of measured sound pressure between a source and a reference as measured at the ear. These are the normal values given for jet engines, jackhammers, whispers, gunshots, etc.

You can't accurately perform the conversion you want because dBFS is simply a measure of a digital signal's value relative to the maximum value it can contain- it bears no direct relation to dBu or dB SPL or any other measure of sound pressure or loudness.

It would be possible with a calibrated system to determine the relationship between the two values, but for an application meant for general consumption I'm not sure how you can attack this. One possible approach would be to measure the input level of the microphone for various known frequencies and sound levels and then correlate the data to what you are seeing.

sbooth