📄 intsynth.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.
%
% ******************************************************************
% INTSYNTH
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 8-3-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Linearly interpolate between transmitted LSPs to generate 4
% intermediate sets of LSP frequencies for subframe synthesis.
%
% DESIGN NOTES
%
% Linearly interpolates lsp's for synthesis in nn (=4) subframes.
% This version is only for use with absolute scalar LSP coding.
% The interpolated LSPs are identical to the interpolated set in the
% transmitter provided there are no transmission errors. If the
% LSP's are nonmonotonic, then LSP errors have occured and an
% attempt is made to "fix" them by repeating previous LSP values.
% If this correction fails (the vector is still nonmonotonic),
% then the entire previous LSP vector is repeated. (This version
% ignores twoerror and syndavg.)
%
% VARIABLES
%
% INPUTS
% nn - Number of subframes per frame
% lspnew - New frequency array (LSPs)
% no - Number of LSPs
% twoerror - Flag for occurrence of two errors in hamming
% protected bits
% syndavg - Bit error estimation parameter
%
% OUTPUTS
% lsp - Interpolated frequency matrix
%
% INTERNALS
% i - Loop counter
%
% GLOBALS
% FrameCnt - Current frame number
% wIS - Interpolation weights
% lspoldIS - Previous frame LSPs
%
% ******************************************************************
function lsp = intsynth( lspnew, nn, no, twoerror, syndavg )
% DECLARE GLOBAL/STATIC VARIABLES
global wIS lspoldIS FrameCnt
% CHECK LSPs; TRY TO FIX NONMONOTONIC LSPs BY REPEATING PAIR
if any( lspnew(2:no) <= lspnew(1:no-1) )
for i = 2:no
if lspnew(i) <= lspnew(i-1)
fprintf( 'intsynth: Try to fix nonmonotonic LSPs\n' );
lspnew(i) = lspoldIS(i);
lspnew(i-1) = lspoldIS(i-1);
end
end
end
% RECHECK FIXED LSPs
if any( lspnew(2:no) <= lspnew(1:no-1) )
% REPEAT ENTIRE LSP VECTOR IF NONMONOTONICITY HAS PERSISTED
fprintf( 'intsynth: Repeat entire LSP vector @ frame %d\n', FrameCnt );
lspnew = lspoldIS;
end
% INTERPOLATE LSPs AND TEST FOR MONOTONICITY
for i = 1:nn
lsp( i, 1:no ) = ( ( wIS(1,i) * lspoldIS( 1:no ) ) + ...
( wIS(2,i) * lspnew( 1:no ) ) )';
% CHECK FOR MONOTONICALLY INCREASING LSPs
if any( lsp(i,2:no) <= lsp(i,1:no-1) )
fprintf( 'intsynth: Nonmonotonic LSPs @ frame %d\n', FrameCnt );
end
end
% UPDATE LSP HISTORY
lspoldIS = lspnew;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -