What Are Linear PCM Values
I am working with audio in the iPhone OS and am a bit confus开发者_运维百科ed.
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
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.)
Lets get some intuition for the question
what are these pcm values representing exactly ( ranging from -32767 to 32768 )
Audio is simply a curve which fluctuates above and below a zero line ... if the curve sits at or too near the zero line for long enough period of time this maps to silence ... neither your speaker surface nor your eardrum do any wobbling ... alternatively if the audio curve violently wobbles from maximum value to minimum value more often than not for a stretch of time you have maximum volume hence a greater value of pascals
Audio in the wild which your ear hears is analog ... to digitize audio this analog curve must get converted into binary data by sampling the raw audio curve to record the curve height at X samples per second ... the fundamental digital format for audio is PCM which simply maps that continuous unbroken analog curve into distinct points on a graph ... PCM audio still appears as a curve yet when you zoom in its just distinct points on the curve ... each curve point has its X and Y value where X represents time (going left to right) and Y represents amplitude (going up and down) ... however only the Y values are stored and the X values are implied meaning each successive Y sample is by definition separated in time determined by the sampling rate so for a second of time with a sample rate of 44100 Hertz you will have 44100 values of Y per second of recording ( per channel )
The number of X measurements per second we call Sample Rate (often 44,100 per second) ... the number of bits used to record the fidelity of Y we call Bit Depth ... if we devote 3 bits the universe of possible Y values must fit in one of these rows
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 0
so for 3 bits the number of possible values of Y is 2^3 or 8 distinct values which sounds very distorted since the audio curve is far from continuous which is why CD quality audio uses two bytes ( 16 bits) of information to record the value of curve height Y which gives it 2^16 distinct values of Y which equates to the scale you gave us ( -32767 to 32768 ) ... 2^16 == 65536 distinct Y values ... the original continuous unbroken analog audio curve is now digitized into 2^16 choices of height values ranging from top to bottom of audio curve which to the human ear becomes indistinguishable from the source audio curve ... when doing audio calculations using floating point often the Y value gets normalized ... into say a range of -1.0 to +1.0 ... instead of ( -32767 to 32768)
So by now it should be clear the heart of your question concerning pascals ( unit of pressure ) is orthogonal to Y value range (bit depth) and is instead a function of the shape of the audio curve together with the sheer area of the speaker surface ... for a given choice of frequency(s) the degree to which the audio curve adheres to the canonical sine curve of that frequency while consuming the full range of possible Y values will maximize the amplitude ( volume ) thus driving the pascal value
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
精彩评论