📄 disto.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.
%
% ******************************************************************
% DISTO
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 8-8-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Compute distortion/distance measures and likelihood ratio
%
% DESIGN NOTES
%
% Calculate distortions/distances (log spectral error, etc.).
% See the first reference below for a complete description. A
% "reference" system is compared against a "test" system. Because
% of the nonsymetric nature of the Itakura-Saito measure which some
% of these distortion measures are based, poorer measures will be
% obtained if the "reference" and "test" systems are reversed.
% Because of gain uncertainties, a few measures are reported.
% (Peter Kroon generally uses the measure DM(5).)
%
% REFERENCES
%
% 1. "Distance Measures for Speech Processing", A.H. Gray and J.D. Markel,
% IEEE Trans. on ASSP, Vol. ASSP-24, no. 5, Oct. 1976
%
% 2. "Quantization and Bit Allocation in Speech Processing",
% A.H. Gray and J.D. Markel,IEEE Trans. on ASSP, Vol. ASSP-24
% no. 6, Dec. 1976
%
% 3. "A Note on Quantization and Bit Allocation in Speech Processing",
% A.H. Gray and J.D. Markel,IEEE Trans. on ASSP, Vol. ASSP-25
% no. 3, June 1977
%
% VARIABLES
%
% INPUTS
% s - "Reference" speech input
% ts - "Test" speech input
% ws - Hamming window, length l
% l - Length of comparison (record lengths)
% no - Filter order
% sumdm - Distances averaging accumulator (current sum)
% framedm - Distances averaging subframe counter (current count)
%
% OUTPUTS
% dm - Distances array (current subframe)
% sumdm - Distances averaging accumulator (current sum)
% framedm - Distances averaging subframe counter (current count)
%
% INTERNALS
% ssw - Windowed "reference" sequence
% tsw - Windowed "test" sequence
% c0hp - 0th autocorrelation lag, reference speech
% chp - Higher-order autocorrelation lags, reference speech
% c0tsw - 0th autocorrelation lag, test speech
% ctsw - Higher-order autocorrelation lags, test speech
%
% ******************************************************************
function [ dm, sumdm, framedm ] = disto( s, ts, ws, l, no, sumdm, framedm )
% ALLOCATE AUTOCORRELATION LAG VECTORS
chp = zeros( no+1, 1 );
ctsw = zeros( no+1, 1 );
% APPLY HAMMING WINDOW TO REFERENCE AND TEST SPEECH SEQUENCES
ssw = ws .* s;
tsw = ws .* ts;
% COMPUTE AUTO CORRELATION LAGS FOR BOTH REFERENCE AND TEST SEQUENCES
[ c0hp, chp(2:no+1) ] = cor( ssw, l, no );
[ c0tsw, ctsw(2:no+1) ] = cor( tsw, l, no );
% ASSEMBLE AUTOCORRELATION LAGS INTO SINGLE VECTOR
chp(1) = c0hp;
ctsw(1) = c0tsw;
% COMPUTE DISTANCE AND DISTORTION MEASURES
if ( chp(1) ~= 0.00 ) & ( ctsw(1) ~= 0.00 )
[ dm, sumdm, framedm ] = dist( no, 4*no, chp, ctsw, sumdm, framedm );
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -