www.pudn.com > CELP.ZIP > init.m


global h len pcbsize szsubf subvec nzero numsubv scalor descalor sub_cnt frm_num 
global frames pdmin pdmax shiftrange olpc former curr twelfth minv maxv b_hpf a_hpf d_hpf1 a_lpf b_lpf d_lpf1 
global FirstComp dlysize dlyml dlymh dfrac wsinc syn_e0 pbuf lbuf gamma1 nsubf gamma2 codebook_lpc 
global bpa bla bra bwa bpb blb brb bwb pdelay intp gamma nfrac frange del_intv frame_count 
global pcode pgain cindex cgain TRUE FALSE prev pdlyindx lpcMat lpcword 
 
len=30;                              % length of truncated convolution 
pcbsize=256;                         % length of pitch delay book 
frames=240;                          % Size of frame 
szsubf=60;                           % Size of subframe 
nsubf=frames/szsubf;                 % Number of subframe per frame 
subvec=20;                           % Size of subvector in each subframe 
numsubv=szsubf/subvec;               % Number of subvector in each subframe 
nzero=4;                             % Number of non-zero in each subvector 
pdmin=20;                            % Min pitch delay 
pdmax=147;                           % Max pitch dealy 
shiftrange=64;                       % Delta search range 
frange=6;                             % fractional search range 
intp=128;                            % Number of integer delay (128) 
scalor=10e2;                          % Scaler of input speech data; 
descalor=10e-2;                       % Descaler of input speech data; 
minv = zeros( 1, frames ) - 32768;   % Maximum allowed speech sample value 
maxv = zeros( 1, frames ) + 32767;   % Minimum allowed speech sample value 
b_hpf = [ 0.940, -1.879, 0.940 ];    % Design of pre-process filter: HPF @ 100 HZ  
a_hpf = [ 1.0, -1.932595, 0.935420 ];  
d_hpf1 = zeros( 2, 1 ); 
 
sub_cnt=0;                           % Overall count of sub-frame 
former=zeros(frames,1); 
TRUE = 1;                            % Flag  
FALSE = 0; 
olpc=10;                             % Order of lpc filters 
 
bpa = zeros( 1, intp+szsubf+pdmin-1 );        % Pitch memory for 1/P(z) 
bpb = zeros( 1, intp+szsubf+pdmin-1 );        % Pitch memory for 1/P(z) 
bla = zeros( 1, olpc );                 % Spectrum memory for 1/A(z) 
blb = zeros( 1, olpc );                 % Spectrum memory for 1/A(z) 
bra = zeros( 1, olpc );                 % Spectrum memory for A(z) 
brb = zeros( 1, olpc );                 % Spectrum memory for A(z) 
bwa = zeros( 1, olpc );                 % Spectrum memory for 1/A(z/gamma) 
bwb = zeros( 1, olpc );                 % Spectrum memory for 1/A(z/gamma) 
pdelay = zeros(1, intp+szsubf+pdmin-1 ); % Pitch delay buffer for codebook 
 
pcode=[];                               % Pitch codeword matrix 
pgain=[];                               % Pitch gain matrix 
cindex=[];                               % Excitation codeword 
cgain=[];                               % Excitation gain matrix 
lpcMat=[]; 
prev=0;                                 % Used in delta search to record the last pitch code 
load('pdlyindx.dat');                   % Load pitch delay table (Uniform integer delay and non-uniform fractional delay) 
pdlyindx=reshape(pdlyindx',1,size(pdlyindx,1)*size(pdlyindx,2)); 
gamma1=0.8;                           % Weighting factor (0.8) 
gamma2=0.99413; 
frm_num=0; 
former=zeros(1,frames);              % Used in analysis for buffering former sub-frame 
curr=zeros(1,frames);                % Used in analysis for buffering current sub-frame 
dlysize=40;                          % Length of interpolation interval, in samples 
dlyml=-20;                           % Start of interpolation interval 
dlymh=19;                            % End of interpolation interval 
wsinc=zeros(nfrac,dlysize);          % Memory storing weighted sinc values 
dfrac=[0.25,0.33333333,0.5,0.66666667,0.75]; % Fractional delays 
FirstComp=TRUE;                      % Flag of computing weighted sinc 
nfrac=5;                             % Number of fractional delays 
syn_e0=zeros(1,frames);              % synthesized white noise like error signal  
pbuf=zeros( 1, intp+szsubf+pdmin-1 );      % Pitch buffer used in synthesis 
lbuf=zeros(1,olpc);                  % LPC buffer used in synthesis 
twelfth=[3,4,6,8,9];                 % Fractional delays for hamming window 
del_intv=2;                          % Interval defined by Pitch delta search (2 or 4) 
 
% Initialize variables used in postfilter 
global Ycg y59save y60save Engcg cbindx cbgbk ALPHA BETA TC ipZ opZ 
 
ALPHA=0.8; 
BETA=0.5; 
TC=0.01; 
ipZ=0; 
opZ=0;