comparison scripts/audio/mu2lin.m @ 2325:b5568c31ee2c

[project @ 1996-07-15 22:20:21 by jwe]
author jwe
date Mon, 15 Jul 1996 22:20:21 +0000
parents 5ca126254d15
children 8b262e771614
comparison
equal deleted inserted replaced
2324:fdc6e2f81333 2325:b5568c31ee2c
19 19
20 ## usage: y = mu2lin (x [, bit]) 20 ## usage: y = mu2lin (x [, bit])
21 ## 21 ##
22 ## If x is a vector of audio data with mu-law encoding, mu2lin (x) 22 ## If x is a vector of audio data with mu-law encoding, mu2lin (x)
23 ## holds the same data with linear encoding. 23 ## holds the same data with linear encoding.
24 ## The optional argument bit specifies whether the input data is 24 ## The optional argument bit specifies whether the input data is
25 ## 8 bit (default) or 16 bit. 25 ## 8 bit (default) or 16 bit.
26 26
27 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> 27 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at>
28 ## Created: 18 October 1994 28 ## Created: 18 October 1994
29 ## Adapted-By: jwe 29 ## Adapted-By: jwe
30 30
31 function y = mu2lin (x, bit) 31 function y = mu2lin (x, bit)
32 32
33 if (nargin == 1) 33 if (nargin == 1)
34 bit = 8; 34 bit = 8;
35 elseif (nargin == 2) 35 elseif (nargin == 2)
36 if (bit != 8 && bit != 16) 36 if (bit != 8 && bit != 16)
37 error ("mu2lin: bit must be either 8 or 16"); 37 error ("mu2lin: bit must be either 8 or 16");
41 endif 41 endif
42 42
43 if (! is_vector (x)) 43 if (! is_vector (x))
44 error ("mu2lin: x must be a vector"); 44 error ("mu2lin: x must be a vector");
45 endif 45 endif
46 46
47 exp_lut = [0; 132; 396; 924; 1980; 4092; 8316; 16764]; 47 exp_lut = [0; 132; 396; 924; 1980; 4092; 8316; 16764];
48 48
49 ## invert x bitwise 49 ## invert x bitwise
50 x = 255 - x; 50 x = 255 - x;
51 51