pub struct MULAW(/* private fields */);Expand description
Mu-law companded sample, as defined by ITU-T G.711. Stored as 1 byte. A single byte has no byte order, so there are no little endian and big endian variants.
Mu-law fits the dynamic range of a 14 bit linear value into 8 bits, using a piecewise linear approximation of a logarithmic curve. The closest numeric type is i16, and the decoded values are scaled to that range. The largest representable magnitude is 32124, so the range does not quite reach the limits of an i16.
Note that i16 is wider than the 256 values this format can represent,
so unlike the linear formats, from_number
quantizes and a number does not survive a roundtrip unchanged.
Quantizing an already quantized value changes nothing further.
Note that a byte value of zero is not silence. It decodes to -32124.
The mu-law code for silence is 0xFF.
This is the format used for telephony in North America and Japan.
It appears as WAVE_FORMAT_MULAW in wav files, as PCMU in RTP streams,
and as SND_PCM_FORMAT_MU_LAW in ALSA.