mu2lin

Converts 8-bit mu-law codes back to linear audio samples.

Category: Data Import and Analysis > Data Import and Export

Syntax

y = mu2lin(mu)

Decodes mu-law values from 0 to 255 into samples in the range -1 to 1.

Description

This is the inverse of lin2mu, up to the quantization error. Small amplitudes are reproduced with finer steps than large ones, so the error grows with the signal level.

Input arguments

mu
Mu-law codes, integers from 0 to 255.

Output arguments

y
Linear samples, of the same size as mu.

Example

Quantization error

y = [-0.9 -0.1 0 0.1 0.9];
z = mu2lin(lin2mu(y))
err = abs(z - y)
Output
z = 1×5

   -0.8866   -0.0995         0    0.0995    0.8866
err = 1×5

    0.0134    0.0005         0    0.0005    0.0134

See also

lin2mu audioread audiowrite