📄 intanaly.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.
%
% ******************************************************************
% INTANALY
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 6-20-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Linearly interpolate between transmitted LSPs to generate 4
% intermediate sets of LSP frequencies for subframe analysis.
%
% DESIGN NOTES
%
% Linearly interpolates lsp's for analysis in
% nn (=4) subframes. This is a combination of inter- and
% intra-frame interpolation. There are two routines, one for the
% analyzer and one for the synthesizer.
%
% The lsps are interpolated from two transmitted frames,
% old and new. The lsp interpolation is calculated as follows:
%
% superframe: old new
%
% | | |
% |---------------------|---------------------|
% | | |
% \ /
% \ /
%
% subframe:
% 1 2 3 4
% | |
% ...---|--------|--------|--------|--------|
% | |
% v v v v
%
% weighting:
% old: 7/8 5/8 3/8 1/8
% new: 1/8 3/8 5/8 7/8
%
% Note: This is dependent on nn = ll/l = 4
%
% VARIABLES
%
% INPUTS
% nn - Number of subframes per frame
% lspnew - New frequency array (LSPs)
% (= new portion of LSP superframe)
% no - LPC filter order
%
% OUTPUTS
% lsp - Interpolated frequency matrix
%
% INTERNALS
% tempfreq - Monotonicity correction swap value
% i,j - Counter indicies
%
% GLOBALS
% w - Interpolation weights
% lspold - Old frame portion of LSP superframe
% oldlsp - Last subframe of previous frame LSPs
% for ill-conditioned cases
% FrameCnt - Current frame number
%
% ******************************************************************
function lsp = intanaly( lspnew, nn, no )
% DECLARE GLOBAL/STATIC VARIABLES
global w lspold oldlsp
% INTERPOLATE LSPs AND TEST FOR MONOTONICITY
for i = 1:nn
lsp( i, 1:no ) = ( ( w(1,i) * lspold( 1:no ) ) + ( w(2,i) * lspnew( 1:no ) ) )';
% CHECK FOR MONOTONICALLY INCREASING LSPs AND SWAP CROSSED LSPs
if any( lsp(i,2:no) < lsp(i,1:no-1) )
for j = 2:no
if lsp(i,j) < lsp(i,j-1)
fprintf( 'test.out', 'intanaly: Swapping nonmono lsps\n' );
tempfreq = lsp(i,j);
lsp(i,j) = lsp(i,j-1)
lsp(i,j-1) = tempfreq;
end
end
end
% RECHECK FOR MONOTONICALLY INCREASING LSPs AND SUBSTITUTE
% OLD LSPs IF STILL NONMONOTONIC
if any( lsp(i,2:no) < lsp(i,1:no-1) )
fprintf( 'test.out', 'intanaly: Resetting interp LSPs at frame %d\n', FrameCnt );
if i == 0
lsp( 1, 1:no ) = oldlsp( 1:no );
else
lsp( i, 1:no ) = lsp( i-1, 1:no );
end
end
end
% SAVE LSPs FOR NEXT PASS
lspold( 1:no ) = lspnew( 1:no );
oldlsp( 1:no ) = lsp( nn, 1:no );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -