View Source NxAudio.Transforms.MuLawDecoding (nx_audio v0.3.0)
Implementation of μ-law decoding, which reverses μ-law encoding compression.
μ-law decoding takes a compressed signal (typically in the range [-1, 1]) and expands it back to its original form. This is the inverse operation of μ-law encoding.
Mathematical Formula
The μ-law decoding formula is:
$F^{-1}(y) = sign(y) \frac{(1 + μ)^{|y|} - 1}{μ}$
where:
- $y$ is the encoded signal (normalized between -1 and 1)
- $μ$ (mu) is the compression parameter (typically 255 for 8-bit encoding)
- $sign(y)$ is the sign function
How it Works
- Takes the compressed signal (normalized between -1 and 1)
- Applies the inverse logarithmic function
- Restores the original signal's dynamic range
- Preserves the sign of the original signal
References
- ITU-T Recommendation G.711
- Digital Signal Processing principles and implementations
Summary
Functions
Decodes a μ-law encoded audio signal back to its original form.
Functions
@spec transform( NxAudio.IO.audio_tensor(), keyword() ) :: NxAudio.IO.audio_tensor()
Decodes a μ-law encoded audio signal back to its original form.
Options
:quantization_channels
- Number of quantization channels. Defaults to 256.
Examples
iex> encoded = Nx.tensor([0.8, -0.5, 0.3])
iex> NxAudio.Transforms.MuLawDecoding.transform(encoded)