Sysquake Pro – Table of Contents
Sysquake for LaTeX – Table of Contents
Library - sigenc
sigenc is a library which adds to LME functions for encoding and decoding scalar signals. It implements quantization, DPCM (differential pulse code modulation), and companders used in telephony.
The following statement makes available functions defined in sigenc:
use sigenc
Functions
alawcompress
A-law compressor.
Syntax
use sigenc output = alawcompress(input) output = alawcompress(input, a)
Description
alawcompress(input,a) compresses signal input with A-law method using parameter a. The signal is assumed to be in [-1,1]; values outside this range are clipped. input can be a real array of any size and dimension. The default value of a is 87.6.
The compressor and its inverse, the expander, are static, nonlinear filters used to improve the signal-noise ratio of quantized signals. The compressor should be used before quantization (or on a signal represented with a higher precision).
See also
alawexpand
A-law expander.
Syntax
use sigenc output = alawexpand(input) output = alawexpand(input, a)
Description
alawexpand(input,a) expands signal input with A-law method using parameter a. input can be a real array of any size and dimension. The default value of a is 87.6.
See also
dpcmdeco
Differential pulse code modulation decoding.
Syntax
use sigenc output = dpcmdeco(i, codebook, predictor)
Description
dpcmdeco(i,codebook,predictor) reconstructs a signal encoded with differential pulse code modulation. It performs the opposite of dpcmenco.
See also
dpcmenco
Differential pulse code modulation encoding.
Syntax
use sigenc i = dpcmenco(input, codebook, partition, predictor)
Description
dpcmenco(input,codebook,partition,predictor) quantizes the signal in vector input with differential pulse code modulation. It predicts the future response with the finite-impulse response filter given by polynomial predictor, and it quantizes the residual error with codebook and partition like quantiz. The output i is an array of codes with the same size and dimension as input.
The prediction
y*(k) = sum predictor(i+1) * yq(k-i) for i = 1,2,...,length(predictor)-1
where
Example
use sigenc t = 0:0.1:10; x = sin(t); codebook = -.1:.01:.1; partition = -.0:.01:.09; predictor = [0, 1]; i = dpcmenco(x, codebook, partition, predictor); y = dpcmdeco(i, codebook, predictor);
See also
dpcmopt
Differential pulse code modulation decoding.
Syntax
use sigenc (predictor, codebook, partition) = dpcmopt(in, order, n) (predictor, codebook, partition) = dpcmopt(in, order, codebook0) (predictor, codebook, partition) = dpcmopt(in, predictor, ...) (predictor, codebook, partition) = dpcmopt(..., tol) predictor = dpcmopt(in, order)
Description
dpcmopt(in,order,n) gives the optimal predictor of order order, codebook of size n and partition to encode the signal in vector in with differential pulse code modulation. The result can be used with dpcmenco to encode signals with similar properties. If the second input argument is a vector, it is used as the predictor and not optimized further; its first element must be zero. If the third input argument is a vector, it is used as an initial guess for the codebook, which has the same length. An optional fourth input argument provides the tolerance (the default is 1e-7).
If only the predictor is required, only the input and the predictor order must be supplied as input arguments.
See also
lloyds
Optimal quantization.
Syntax
use sigenc (partition, codebook) = lloyds(input, n) (partition, codebook) = lloyds(input, codebook0) (partition, codebook) = lloyds(..., tol)
Description
lloyds(input,n) computes the optimal partition and codebook for quantizing signal input with n codes, using the Lloyds algorithm.
If the second input argument is a vector, lloyds(input,codebook0) uses codebook0 as an initial guess for the codebook. The result has the same length.
A third argument can be used to specify the tolerance used as the stopping criterion of the optimization loop. The default is 1e-7.
Example
We start from a suboptimal partition and compute the distortion:
use sigenc partition = [-1, 0, 1]; codebook = [-2, -0.5, 0.5, 2]; in = -5:0.6:3; (i, out, dist) = quantiz(in, partition, codebook); dist 2.1421
The partition is optimized with lloyds, and the same signal is quantized again. The distortion is reduced.
(partition_opt, codebook_opt) = lloyds(in, codebook) partition_opt = -2.9 -0.5 1.3 codebook_opt = -4.1 -1.7 0.4 2.2 (i, out, dist) = quantiz(in, partition_opt, codebook_opt); dist 1.0543
See also
quantiz
Table-based signal quantization.
Syntax
use sigenc i = quantiz(input, partition) (i, output, distortion) = quantiz(input, partition, codebook)
Description
quantiz(input,partition) quantizes signal input
using partition as boundaries between different ranges. Range
from
quantiz(input,partition,codebook) uses codebook as a look-up table to convert back from codes to signal. It should be a vector with one more element than partition. With a second output argument, quantiz gives codebook(i).
With a third output argument, quantiz computes the distortion between input and codebook(i), i.e. the mean of the squared error.
Example
use sigenc partition = [-1, 0, 1]; codebook = [-2, -0.5, 0.5, 2]; in = randn(1, 5) in = 0.1799 -9.7676e-2 -1.1431 -0.4986 1.0445 (i, out, dist) = quantiz(in, partition, codebook) i = 2 1 0 1 2 out = 0.5 -0.5 -2 -0.5 0.5 dist = 0.259
See also
ulawcompress
mu-law compressor.
Syntax
use sigenc output = ulawcompress(input) output = ulawcompress(input, mu)
Description
ulawcompress(input,mu) compresses signal input with mu-law method using parameter mu. input can be a real array of any size and dimension. The default value of mu is 255.
The compressor and its inverse, the expander, are static, nonlinear filters used to improve the signal-noise ratio of quantized signals. The compressor should be used before quantization (or on a signal represented with a higher precision).
See also
ulawexpand
mu-law expander.
Syntax
use sigenc output = ulawexpand(input) output = ulawexpand(input, mu)
Description
ulawexpand(input,mu) expands signal input with mu-law method using parameter a. input can be a real array of any size and dimension. The default value of mu is 255.