Home > voicebox > pcma2lin.m

pcma2lin

PURPOSE ^

PCMU2LIN Convert A-law PCM to linear X=(P,M,S)

SYNOPSIS ^

function x=pcma2lin(p,m,s)

DESCRIPTION ^

PCMU2LIN Convert A-law PCM to linear X=(P,M,S)
    lin = pcma2lin(pcma,m,s) where pcma contains a vector or matrix
    of A-law values in the range 0 to 255.
    No checking is performed to see that numbers are in this range.

    Input values are exclusive ored with m (default=85)

    Output values are divided by the scale factor s:

           s        Output Range

           1        +-4032    (integer values)
        2017.396342    +-1.998616 (default)
        4032        +-1
        4096        +-0.984375 (+-1 nominal full scale)

    The default value of s is 2017.396342 which equals
    sqrt((1120^2 + 2624^2)/2). This factor follows ITU standard G.711 and
    the sine wave with PCM-A values [225 244 244 225 97 116 116 97]
    has a mean square value of unity corresponding to 0 dBm0.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x=pcma2lin(p,m,s)
0002 %PCMU2LIN Convert A-law PCM to linear X=(P,M,S)
0003 %    lin = pcma2lin(pcma,m,s) where pcma contains a vector or matrix
0004 %    of A-law values in the range 0 to 255.
0005 %    No checking is performed to see that numbers are in this range.
0006 %
0007 %    Input values are exclusive ored with m (default=85)
0008 %
0009 %    Output values are divided by the scale factor s:
0010 %
0011 %           s        Output Range
0012 %
0013 %           1        +-4032    (integer values)
0014 %        2017.396342    +-1.998616 (default)
0015 %        4032        +-1
0016 %        4096        +-0.984375 (+-1 nominal full scale)
0017 %
0018 %    The default value of s is 2017.396342 which equals
0019 %    sqrt((1120^2 + 2624^2)/2). This factor follows ITU standard G.711 and
0020 %    the sine wave with PCM-A values [225 244 244 225 97 116 116 97]
0021 %    has a mean square value of unity corresponding to 0 dBm0.
0022 
0023 
0024 
0025 %      Copyright (C) Mike Brookes 1998
0026 %      Version: $Id: pcma2lin.m 713 2011-10-16 14:45:43Z dmb $
0027 %
0028 %   VOICEBOX is a MATLAB toolbox for speech processing.
0029 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 %   This program is free software; you can redistribute it and/or modify
0033 %   it under the terms of the GNU General Public License as published by
0034 %   the Free Software Foundation; either version 2 of the License, or
0035 %   (at your option) any later version.
0036 %
0037 %   This program is distributed in the hope that it will be useful,
0038 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0040 %   GNU General Public License for more details.
0041 %
0042 %   You can obtain a copy of the GNU General Public License from
0043 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0044 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0046 
0047 if nargin<3
0048   t=4.95688418E-4;
0049   if nargin<2 m=85; end
0050 else
0051   t=1/s;
0052 end
0053 
0054 if m q=bitxor(p,m); else q=p; end;
0055 k=rem(q,16);
0056 g=floor(q/128);
0057 e=(q-k-128*g)/16;
0058 f=(abs(e-1)-e+1)/2;
0059 x=(2*g-1).*(pow2(k+16.5,e)+f.*(k-15.5))*t;

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003