Difference between revisions of "Pulse Code Modulation"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
(Float. Navbox, because users might have navigated here using it.)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
'''Pulse Code Modulation''' ('''PCM''') is a method of recording sound as digital data. The amplitude of the audio signal is sampled at a regular [[sampling frequency]], and [[Quantization|quantized]] with a fixed [[bitdepth]].
 
 
 
{{stub}}
 
{{stub}}
 +
 +
'''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.<ref>https://en.wikipedia.org/wiki/PCM</ref>
 +
 +
(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<ref>https://en.wikipedia.org/wiki/AES3#Protocol</ref> and is the most common content of [[RIFF WAVE|WAVE]] and [[Audio Interchange File Format|AIFF]] files. Most [[lossless]] audio [[codec|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<ref>See for example https://en.wikipedia.org/wiki/Blu-ray#Audio for this usage</ref>, 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: [[High_Definition_Compatible_Digital|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 &ndash; 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 [https://en.wikipedia.org/wiki/Single-precision_floating-point_format 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<ref>https://en.wikipedia.org/wiki/A-law_algorithm</ref> and µ-law<ref>https://en.wikipedia.org/wiki/%CE%9C-law_algorithm</ref> (wikipedia links).
 +
 +
 +
= Further reading =
 +
 +
* [[Pulse-Density Modulation]] (PDM)
 +
* [[Pulse-Amplitude Modulation]] (PAM)
 +
* [http://web.archive.org/web/20030406235542/http://homepage.ntlworld.com:80/quantium/ahr/pcm.htm A page on PCM history] (Archived as of April 6, 2003)
 +
<references/>
 +
{{navbox audio codecs}}
 +
[[Category:Technical]]

Latest revision as of 13:24, 19 May 2024

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

  1. https://en.wikipedia.org/wiki/PCM
  2. https://en.wikipedia.org/wiki/AES3#Protocol
  3. See for example https://en.wikipedia.org/wiki/Blu-ray#Audio for this usage
  4. https://en.wikipedia.org/wiki/A-law_algorithm
  5. https://en.wikipedia.org/wiki/%CE%9C-law_algorithm