📄 lsptopc.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.
%
% ******************************************************************
% LSPTOPC
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 6-15-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Convert lsp frequencies to predictor coefficients
%
% DESIGN NOTES
%
% LSPTOPC converts line spectral frequencies to LPC predictor
% coefficients.
%
% The analysis filter may be reconstructed:
%
% A(z) = 1/2 [ P(z) + Q(z) ]
%
% LPC predictor coefficient convention is:
% p+1 -(i-1)
% A(z) = SUM a z where a = +1.0
% i=1 i 1
%
% VARIABLES
%
% INPUTS
% f - LSP frequencies
% no - LPC filter order
%
% OUTPUTS
% pc - LPC predictor coefficients
%
% INTERNALS
% xx - Analysis filter excitation
% xf - Analysis filter excitation
% p - LSP filter polynomial
% q - LSP filter polynomial
% a - LSP filter output
% b - LSP filter output
% a1,a2 - LSP filter memory
% b1,b2 - LSP filter memory
% i,k - Loop counters
% noh - no/2
% freq - Local copy of LSP frequencies
%
% GLOBALS
% FrameCnt - Current frame number
%
% ******************************************************************
function pc = lsptopc( f, no )
% DECLARE GLOBAL VARIABLES
global FrameCnt
% TEST FOR ILL-CONDITIONED INPUT LSPs
if ( any(f<=0.00) | any(f>=0.5) )
fprintf( 'lpstopc: LSPs out of bounds at frame %d\n', FrameCnt );
end
if any( f(2:no) <= f(1:no-1) )
fprintf( 'lpstopc: nonmonotonic LSPs at frame %d\n', FrameCnt );
end
% INITIALIZE LOCAL VARIABLES
noh = no / 2;
freq = f;
a = zeros( noh+1, 1 );
a1 = a;
a2 = a;
b = a;
b1 = a;
b2 = a;
pc = zeros( no, 1 );
% INITIALIZE LSP FILTER PARAMETERS
p = -2 * cos( 2*pi*freq((1:2:no-1)') );
q = -2 * cos( 2*pi*freq((2:2:no)') );
% COMPUTE IMPULSE RESPONSE OF ANALYSIS FILTER
xf = 0.00;
for k = 1:no+1
xx = 0.00;
if k == 1
xx = 1.00;
end
a(1) = xx + xf;
b(1) = xx - xf;
xf = xx;
for i = 1:noh
a(i+1) = a(i) + ( p(i) * a1(i) ) + a2(i);
b(i+1) = b(i) + ( q(i) * b1(i) ) + b2(i);
a2(i) = a1(i);
a1(i) = a(i);
b2(i) = b1(i);
b1(i) = b(i);
end
if k ~= 1
pc(k-1) = -0.5 * ( a(noh+1) + b(noh+1) );
end
end
% CONVERT TO PREDICTOR COEFFICIENT ARRAY CONFIGURATION
pc(2:no+1) = -pc(1:no);
pc(1) = 1.0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -