Extracting Amplitude Data from Linear PCM on the iPhone

北慕城南 提交于 2019-12-02 18:32:10

1) the os x/iphone file read routines allow you to determine the sample format, typically one of SInt8, SInt16, SInt32, Float32, Float64, or contiguous 24 bit signed int for LPCM

2) for int formats, MIN_FOR_TYPE represents the max amplitude in the negative phase, and MAX_FOR_TYPE represents the maximum amplitude in the positive. 0 equals silence. floating point formats modulate between [-1...1], with zero as with float. when reading, writing, recording, or working with a specific format, endianness will matter - a file may require a specific format, and you typically want to manipulate the data in the native endianness. some routines in the apple audio file libs allow you to pass a flag denoting source endianness, rather than you manually converting it. CAF is a bit more complicated - it acts like a meta wrapper for one or more audio files, and supports many types.

3) the amplitude representation for lpcm is just a brute-force linear amplitude representation (no conversion/decoding is required to playback, and the amplitude steps are equal).

4) see #2. the values are not related to air pressure, they are related to 0 dBFS; e.g. if you're outputting the stream straight to a DAC, then the int max (or -1/1 if floating point) represents the level at which an individual sample will clip.

Bonus) it, like every ADC and component chain has limits to what it can handle on input in terms of voltage. additionally, the sampling rate defines the highest frequency that may be captured (the highest being half of the sampling rate). the adc may use a fixed or selectable bit depth, but the max input voltage does not generally change when choosing another bit depth.

one mistake you're making at the code level: you're manipulating `outBuffer' as chars - not SInt16

  1. If you ask for 16-bit samples in your recording format, then you get 16-bit samples. But other formats do exist in many Core Audio record/play APIs, and in possible caf file formats.

  2. In mono, you just get an array of signed 16-bit ints. You can specifically ask for big or little endian in some of the Core Audio recording APIs.

  3. Unless you want to calibrate for your particular device model's mic or your external mic (and make sure audio processing/AGC is turned off), you might want to consider the audio levels to be arbitrary scaled. Plus the response varies with mic directionality and audio frequency as well.

  4. The center point for 16-bit audio samples is commonly 0 (range about -32k to 32k). No bias.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!