📄 pencode.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.
%
% ******************************************************************
% PENCODE
%
% PORTED TO MATLAB FROM CELP 3.2a C RELEASE
% 7-7-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Encode and quantize pitch gain for various quantizer types
%
% DESIGN NOTES
%
% This funtion uses output level data obtained by Max's minimum
% distortion quantization priciples and quantizes to the nearest
% level (L1 norm). (Using level data only was found superior to
% using both of Max's level and boundry data.)
%
% VARIABLES
%
% INPUTS
% input - Pitch gain input (unquantized or true value)
%
% OUTPUTS
% index - Quantized pitch gain index
% qpgain - Quantized pitch gain value
%
% GLOBALS
% pitch2max5 - Quantization table
%
% REFERENCES
%
% 1. Quantizing for Minimum Distorion
% J. Max, IRE Trans. Inform. Theory, vol. IT-6, pp.7-12, Mar. 1960
%
% 2. Data used in the quantizer table generation is from file 3m3f.spd,
% a standard speech data file distributed by NSA with CELP 3.2a.
%
% ******************************************************************
%
% NOTE WELL
%
% While the author(s) of the original pitchencode() function (C language)
% indicate the source of the data used to generate this Lloyd-Max quantizer,
% they fail to indicate what set of assumptions were applied to the data
% set. What type of pdf has been assumed? Gaussian, Laplacian, Rayleigh, etc.
% As shown in [1] above, pdf assumptions are built in to the quantizer/
% quantization levels. More information would be helpful.
%
% The quantizer table used below has been blindly copied from the C
% implementation without knowledge of the governing assumptions.
%
% See init.m for the table pitch2max5.
%
% ******************************************************************
function [ index, qpgain ] = pencode( input )
% DECLARE GLOBALS
global pitch2max5
% QUANTIZE INPUT TO NEAREST VALUE IN PITCH2MAX5 TABLE
[ qpgain, index ] = min( abs( input - pitch2max5 ) );
% RETURN QUANTIZED VALUE TO CALLER
qpgain = pitch2max5( index );
% CORRECT INDICIES TO MATCH C LANGUAGE RESULTS FOR EASE OF TEST/VERIFICATION
index = index - 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -