Skip to main content

Module pcm

Module pcm 

Source
Expand description

Interleaved 16-bit PCM with the measurements pydub exposes.

Every formula here is pydub’s, which is audioop’s underneath, and the integer truncation is load-bearing: rms is an int, so dBFS is the log of a rounded-down value, not of the true RMS. Reproducing the rounding matters more than being more accurate.

Structs§

Pcm
Interleaved i16 samples plus the format they were decoded at.

Constants§

MAX_POSSIBLE_AMPLITUDE
Sample width is always 2 in this pipeline; pydub’s max_possible_amplitude is 2^16 / 2.

Functions§

py_round 🔒
Python’s round() — half away from zero is not what it does; it is banker’s rounding, so 0.5 goes to 0 and 1.5 goes to 2.
ratio_to_db
pydub.utils.ratio_to_db in amplitude mode, -inf at zero. See crate::segment::ratio_to_db for why this is not log10.