views:

109

answers:

3

Hello All,

I am working with audio in the iPhone OS and am a bit confused.

I am currently getting input from my audio buffer in the form of pcm values ranging from -32767 to 32768. I am hoping to perform a dbSPL conversion using the formula 20LOG10(p/pref).

I am aware that pRef is .00002 pascals, and would like to convert the pcm values to pascals.

My question is a) what are these pcm values representing exactly. b) how do I turn these values to pascals.

Thanks so much

+1  A: 

You can't do this conversion without additional information. The mapping of PCM values to physical units of pressure (pascals) depends on the volume setting, characteristics of the output device (earbuds? a PA system?), and the position of the observer with respect to the output device (right next to the speaker? 100 meters away?).

To answer the first part of your question: if you were to graph the sound pressure versus time for, say, a 1 kHz sine wave tone, the linear-quantized PCM values at the sample times would be roughly proportional to the sound pressure variations from ambient at that instant. ("Roughly", because input and output devices seldom have absolutely flat response curves over the entire audio frequency range.)

Jim Lewis
A: 

Your question is neither “iphone”, “objective-c” or “objective-c++”. But it can be answered very simple: http://en.wikipedia.org/wiki/Pulse-code_modulation

Greetings

Objective Interested Person
I appreciate your effort, but would rather not have you answer a question that you do not have any knowledge about. I have read the wikipedia several times, and the answer is "simple" not there. It is relevant to iPhone because hardware plays a role in this calculation.
sk8brder343
A: 

@sk8brder343, “the answer is ‘simple’ not there”: • You asked “what are these pcm values representing exactly” This is explained in the wikipedia-article. These values are the result of the sampling process by converting (in your case) the analog input values into digital numbers. In your case the steps between two values are constant – there is even a link to the article “Linear pulse code modulation”.

• And you asked “how do I turn these values to pascals” There simply can’t be distinct pressure-values. There is just something between the minimum and the maximum value of the pcm-signal. This values have to pass a reverting procedure (mostly done by the electronic device, not by software) to give a signal similar to the original imput. But there is no way to tell anybody, what preassure was the one, produced by the original sound source.

Question: how do you want to urge your (softwares) users to set up the same equipment you use? Maybe they have headphones, laying 100m aside of them – or they have the sound system of area desaster (you know Douglas Adams?) and wrap their head with the boxes!

Greetings

Objective Interested Person