﻿# G.711 voice input: companded codewords are not linear PCM samples

G.711 voice input: companded codewords are not linear PCM samples. A focused voice-infrastructure guide with the documented mechanism, a reproducible validation scenario, evidence and operational limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/voice-g711-companded-bytes-pcm-input/
Language: en

G.711 telephony payload bytes are companded codewords, not linear waveform amplitudes. Converting an unsigned byte array directly to floating-point values does not decode the sound. A speech gateway needs the negotiated A-law or mu-law conversion before applying the amplitude and sample-rate contract expected by its neural audio model.

## The audio contract

The RTP audio profile identifies PCMA and PCMU as different logarithmic sample encodings. Their byte-level payload representation must be interpreted with the selected law. A linear unsigned audio format in a capture API has different semantics even if its sample occupies the same storage width. Header removal, companding decode, channel handling, resampling and model normalization are consequently distinct operations. Performing only the final normalization leaves the earlier representation error intact and can create a waveform with plausible length but incorrect amplitude relationships.

## Implementation details

Carry codec identity from session negotiation to the payload decoder. Produce a documented linear waveform representation, then apply any necessary rate conversion and model-specific normalization as explicit stages. Preserve valid sample count and channel assignment throughout the path. Reject an unknown law instead of guessing from the first bytes or from whether an ASR output looks fluent. Keep the raw packet structure out of model input. A successful tensor allocation should be treated as a memory operation, not evidence that telephony payload decoding was correct.

## A constructed validation case

Use known codeword fixtures and a reference decode for each supported law, including values that exercise sign and near-silence behavior. Compare the adapter's linear samples before resampling or normalization. Add deliberate wrong-law decoding and direct-byte-to-float conversion as negative controls. Then inspect the complete prepared waveform's rate, duration and amplitude. Acceptance requires correct decoding at the companding boundary and truthful subsequent conversion metadata; a plausible transcript from one phrase cannot certify this low-level contract or every telephone route.

## Operational limits

Correct companding decode does not restore information the telephony codec never preserved. Evaluate recognition on the actual channel conditions separately. This boundary prevents a representation bug from being mistaken for an inherent limitation of a speech model or a need for more GPU capacity.

## Primary references

[Rfc3551](https://www.rfc-editor.org/rfc/rfc3551.html); [Portaudio Api](https://portaudio.com/docs/v19-doxydocs/portaudio_8h.html).

This is a proposed voice-system validation, not an executed Retrivium benchmark. Preserve the implementation version and unresolved outcomes; interface documentation does not establish the quality or timing of a deployed voice service.

## Related reading

[RNNoise floating-point input: PCM amplitude scale is part of the interface](/journal/fg2-rnnoise-float-pcm-amplitude-format/); [Audio resampling for datasets: keep timestamps aligned when sample counts change](/journal/data-guide-audio-resample-time-labels/).
