📄 csub.m
字号:
% MATLAB SIMULATION OF NSA FS-1016 CELP v3.2
% COPYRIGHT (C) 1995-99 ANDREAS SPANIAS AND TED PAINTER
%
% This Copyright applies only to this particular MATLAB implementation
% of the FS-1016 CELP coder. The MATLAB software is intended only for educational
% purposes. No other use is intended or authorized. This is not a public
% domain program and distribution to individuals or networks is strictly
% prohibited. Be aware that use of the standard in any form is goverened
% by rules of the US DoD. Therefore patents and royalties may apply to
% authors, companies, or committees associated with this standard, FS-1016. For
% questions regarding the MATLAB implementation please contact Andreas
% Spanias at (602) 965-1837. For questions on rules,
% royalties, or patents associated with the standard, please contact the DoD.
%
% ALL DERIVATIVE WORKS MUST INCLUDE THIS COPYRIGHT NOTICE.
%
% ******************************************************************
% CSUB
%
% MATLAB REVISION HISTORY
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 6-20-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Run adaptive and stochastic codebook searches
%
% DESIGN NOTES
%
% See individual subroutines
%
% VARIABLES
%
% INPUTS
% s - Speech or residual segment
% l - Stochastic analysis frame size
% lp - Adaptive (pitch) analysis frame size
%
% OUTPUTS
% v - Optimum excitation vector
%
% INTERNALS
%
% GLOBALS
% e0 - Codebook search initial error and updated error
% d1a - Memory 1/P(z) (pitch)
% d1b - Memory 1/P(z) (pitch)
% d2a - Memory 1/A(z) (spectrum)
% d2b - Memory 1/A(z) (spectrum)
% d3a - Memory A(z) (spectrum)
% d3b - Memory A(z) (spectrum)
% d4a - Memory 1/A(z/gamma) (spectrum)
% d4b - Memory 1/A(z/gamma) (spectrum)
% mxsw - Modified excitation control switch
% nseg - Segment (subframe) counter, cumulative
%
% CONSTANTS
% MAXNO - Predictor order
% MAXPA - Dimension of d1a, d1b
%
% ******************************************************************
function v = csub( s, l, lp )
% DECLARE GLOBAL CONSTANTS
global MAXNO MAXPA;
% DECLARE GLOBAL VARAIBLES
global e0 d1a d1b d2a d2b d3a d3b d4a d4b mxsw nseg;
% INITIALIZE LOCAL AND STATIC VARIABLES
e0 = zeros( l, 1 );
% FIND INITIAL ERROR WITHOUT PITCH VQ
[ d1a, d2a, d3a, d4a ] = confg( s, l, d1a, d2a, d3a, d4a, 0, 1, 1, 1 );
% RESTORE FILTER MEMORIES: 1/A(Z), A(Z), 1/A(Z/GAMMA)
d2a = d2b;
d3a = d3b;
d4a = d4b;
% FIND IMPULSE RESPONSE OF THE PERCEPTUAL WEIGHTING FILTER, h(n)
impulse(l);
% COMPUTE EUCLIDEAN NORM OF THE FIRST ERROR SIGNAL
if mxsw == 1
mexcite1( l );
end
% DO PITCH (ADAPTIVE) CODEBOOK SEARCH
% GET PP PARAMETERS EVERY SEGMENT IF LP == L, OTHERWISE GET PP
% PARAMETERS ON ODD SEGMENTS
if lp == l
psearch( l );
elseif rem( nseg, 2 ) == 1
psearch( lp );
end
% FIND INITIAL ERROR WITH PITCH VQ
e0 = zeros( l, 1 );
[ d1a, d2a, d3a, d4a ] = confg( s, l, d1a, d2a, d3a, d4a, 1, 1, 1, 1 );
% COMPUTE NORM OF SECOND ERROR SIGNAL
if mxsw == 1
mexcite2( l );
end
% STOCHASTIC CODEBOOK SEARCH
v = cbsearch( l, 0 );
% UPDATE FILTER STATES
e0 = v;
[ d1b, d2b, d3b, d4b ] = confg( s, l, d1b, d2b, d3b, d4b, 1, 1, 1, 1 );
d1a = d1b;
d2a = d2b;
d3a = d3b;
d4a = d4b;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -