Pulse Code Modulation

From Hydrogenaudio Knowledgebase
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Pulse Code Modulation (PCM) is a method of recording sound as digital data. For more information on the method, its history and uses, see the Wikipedia entry.[1]

(Linear) PCM is used for audio CD, can (optionally) be found on DVD (and Blu-Ray) discs, is the data form transmitted in AES3 / S/PDIF digital audio interfaces[2] and is the most common content of WAVE and AIFF files. Most lossless audio codecs for end-users compress linear PCM. Being by far the most common form for audio end-users, one will often see linear PCM referred to as merely "PCM". The phrases "linear PCM" or the abbreviation "LPCM" occur more common in the context of DVD or Blu-Ray[3], sometimes leading to the erroneous notion that "linear PCM" necessarily must be of the form supported by the DVD formats.

ADPCM is common in telecommunication.

Linear PCM

In Linear PCM, the quantization levels are linear in amplitude. To visualize, each 16-bit sample of CD audio represents the amplitude as a number between −32768 and 32767 in equidistant steps: a difference from 2 to 11 makes for the same as the difference from 13000 to 13009. Linear PCM can be converted with ordinary multi-bit converters: the 12th bit contributes the same to the analog signal no matter what the other bits are. Consumer-audio "digital output" connections like S/PDIF (coaxial or TOSlink optical, the latter more common from computer motherboards) and audio over HDMI (although other encodings might be transferred as well).

As a counterexample formed by modifying a PCM signal with a nonlinearity: HDCD's low level adjustment can flag the lower bits to signify something else if the signal is close to zero (i.e., depending on the more significant bits), and its peak extension is also a nonlinearity. A non-HDCD-aware DAC will omit these steps, and decode linearly – the DAC will receive as 'PCM', as the flags are hidden in the signal.

Integer vs floating-point LPCM

The WAVE and AIFF formats offer both 32-bit integer (like the 16-bit example above, except with the much bigger range -2147483648 to 2147483647) and 32/64-bit floating-point PCM formats. 32-bit floating-point represents numbers in the IEEE 754 floating-point format; in simplified terms, it is 24 bit integer augmented with a giant volume control acting on each sample. IEEE 754 is a general-purpose format, and the "volume control" happens to be a veritable overkill for audio purposes; it makes floating-point format is thus immune to clipping for all purposes except deliberately running hundreds of dB off.

End-users acquiring a "32-bit" WAVE (or AIFF) file might sometimes encounter compatibility issues from confusing the two. 32-bit integer and 32-bit float do not have much in common except the "32", which is how much space is spent storing a sample. Conversion between the two is not lossless either way, and in particular, ffmpeg might clip when converting from float.

Differential PCM

Differential PCM will, in simplified terms, encode the difference between consecutive samples. The adaptive differential PCM (ADPCM) variant is common in e.g. telecommunication, where the signal is typically companded using given nonlinear functions specified as A-law[4] and µ-law[5] (wikipedia links).

Further reading