📄 init.m
字号:
% MATLAB SIMULATION OF FS-1015 LPC-10e
% COPYRIGHT (C) 1996-99 ANDREAS SPANIAS and TED PAINTER
%
% This Copyright applies only to this particular MATLAB implementation
% of the LPC-10e 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 unauthorized distribution to individuals or networks
% is prohibited. Be aware that use of the standard in any form is goverened
% by rules of the US DoD.
% This program is free software. It is distributed in the hope that it will
% be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. There is no commitment
% or even implied commitment on behalf of Andreas Spanias or Ted Painter
% for maintenance or support of this code.
%
% MATLAB is trademark of The Mathworks Inc
%
% ALL DERIVATIVE WORKS MUST INCLUDE THIS COPYRIGHT NOTICE.
%
% ******************************************************************
% INIT
%
% PORTED TO MATLAB FROM LPC-55 C RELEASE
% 2-14-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Initializes all global and static data objects
%
% DESIGN NOTES
%
% "Statics" were implemented as packed matricies for several functions
% early in the development process. Although these were preserved,
% the practice was abandoned in favor of using MATLAB globals where
% static behavior was required.
%
% INTERNAL VARIABLES
% h0 - h15 - LPF31 lowpass tap weights
%
% GLOBAL VARIABLES BY FUNCTION
%
% LPC10.M
% SimRunning - First or subsequent call flag
%
% HP100.M
% hp100z1 - Highpass filter memory, first stage
% hp100z2 - Highpass filter memory, second stage
%
% ANALYS.M
% inbuf - Raw speech, scaled to 12-bits + sign
% pebuf - Preemphasized speech
% lpbuf - Lowpass filtered speech buffer
% awin - Analysis window indicies (3 frames)
% ewin - Energy window indicies "
% rmsbuf - RMS energy "
% rcbuf - Reflection coefficients "
% ivbuf - Inverse filtered speech
% bias - DC bias estimate for input speech
% tau - Table of AMDF pitch lags
% voibuf - Voicing decisions for 3 frames
%
% LPFILT31.M
% alpf31 - Lowpass filter H(Z) denominator taps
% blpf31 - Lowpass filter H(Z) numerator taps
% zlpf31 - Lowpass filter H(Z) memory
%
% PREEMP.M
% zpre - Preemphasis filter memory
%
% IVFILT.M
% ziv - Inverse filter memory
%
% TBDM.M
% tau2 - Table of high-resolution lags
%
% VOICE.M
% nvdcl - Number of voicing decision coefficient vectors (VDCs)
% ref - Reference energy for for initialization/dither threshold
% vstate - Decimal interpretation of binary voicing classification
% dither - Zero crossing threshold level
% sfbue - Static copy of full band unvoiced energy
% slbue - Static copy of low band unvoiced energy
% lbve - Low band voiced energy
% fbve - Full band voiced energy
% fbue - Full band unvoiced energy
% ofbue - Previous full band unvoiced energy
% lbue - Low band unvoiced energy
% olbue - Previous low band unvoiced energy
% snr - Estimated SNR
% vdcl - SNR values corresponding to the set of VDCs
% voice - History of linear discriminant analysis results
% vdc - 2-D voicing decision coefficient vector
%
% DYPTRK.M
% ipoint - Current frame position pointer
% alphax - Scaled version of alpha
% s - Winner array
% p - Pitch pointer array
%
% PLACEA.M
% allv - True if five most recent half-frame decisions = V
%
% ENCODE.M
% enctab - Table of Hamming 8,4 redundancy bits used for
% protection of RC1-RC4 during unvoiced frames.
% entau - Pitch encoding table
% enadd - Table of negative values of the bias of the
% probability density functions (pdf) of each of
% the last eight RCs.
% enscl - Table of scale factors for each of the last eight
% RCs.
% enbits - Table of number of shifts nescessary to properly
% scale each of the last 8 RCs to their respective
% bit allocations.
% entab6 - Log-area-ratio (LAR) table for encoding of RC1 and RC2
% rmst - Energy encoding table
%
% DECODE.M
% ivtab - Table containing all nescessary logical flow
% information for this routine.
% corth - Smoothing threshold table, one row per error rate
% class (2-D, 4x8).
% detau - Pitch decoding table
% detab7 - Table for inverse LAR decoding of RC1, RC2
% descl - Table of scale factors for each of the last 8 RCs
% deadd - Table of pdf biases for the last 8 RCs
% qb - Quantization bias table of the last 8 RCs
% nbit - Number of bits allocated to each of the RCs
% zrc - Zero forcing table for RC5 through RC10
% drc - Matrix of future, present, past, and last frame RCs
% dpit - Vector of future, present, past, and last frame pitch
% drms - Vector of future, present, past, and last frame RMS
% ivp2h - Voicing condition of previous second half frame
% erate - Measured bit error rate
% iovoic - 2-bit voicing condition code for present frame
% first - Flag set only for first frame of data
%
% HAM84.M
% dactab - Hamming 8,4 decode table
%
% SYNTHS.M
% ivuv - Epoch voicing decisions
% ipiti - Pitch epoch lengths
% rmsi - Pitch epoch energy
% rci - Pitch epoch reflection coefficients
% pc - Pitch epoch predictor coefficients
% sout - Pitch epoch output speech
%
% PITSYN.M
% ivoico - Voicing decision of previous second half frame
% ipito - Pitch of last epoch from previous frame
% rmso - Energy of previous frame
% rco - Reflection coefficients of previous frame
% yarc - Temp storage for present frame RCs during voiced
% section of transition frame to unvoiced.
% psFirst - Flag to indicate first call to PITSYN.M
% jsamp - Number of samples from end of previous frame not
% yet assigned to an epoch.
%
% BSYNZ.M
% kexc - Voiced excitation base sequence (predefined)
% exc - Input excitation for LPC synthesis filter I (all zero)
% exc2 - Input and output for LPC synthesis filter II (all pole)
% ipo - Pitch epoch length, previous epoch
% bsRmso - Previous epoch energy
% Zlpf - Filter memory, excitation LPF
% Zhpf - Filter memory, excitation HPF
%
% RANDOM.M
% j - Random tap index 1
% k - Random tap index 2
% y - Random generator taps
%
% DEEMPH.M
% Zdemph - Deemphasis filter memory
%
% BUFMAN.M
% BigBuf - Circular matching buffer - bsynz -> 180 samples/frame
% sPtr - Head pointer
% ePtr - Tail pointer
%
% GUI.M
% guiDisplayMode - Frequency or time mode flag
% guiDisplayType - Speech I/O, excitation, or pole plot flag
% guiState - State flag: startup, runtime, or shutdown
% guiSline - Handle to status line graphic object
% guiSbuf1 - Buffering allows gui to track LPC-10 buffering
% guiSbuf2 - " " "
% guiSin - Input signal buffer for plotting
% guiFrames - Number of frames in current input file
% guiExcit - Excitation signal buffer for plotting
%
% "STATICS" - USED GLOBALS IN MOST PLACES RATHER THAN THESE
% analysState - Static variables for analys.m
% onsetState - Static variables for onset.m
%
% CONSTANTS
% LFRAME - Input speech frame size
% AF - Analysis frame index (into 3 frame buffer)
% READ - Read flag to control diskio
% WRITE - Write flag to control diskio
% EOF - Status flag for diskio
% OSLEN - Onset buffer size
% MAXWIN - The maximum length of a window
% LTAU - Number of points (lags) in the AMDF
% SBUFL - The lower index of speech buffers INBUF and PEBUF
% LBUFL - The lower index of speech buffer LPBUF
% MAXORD - Maximum predictor order
% ORDER - Predictor order
% MIDTAP - Random number generator middle tap
% MAXTAP - Random number generator last tap
% MAXPIT - Maximum pitch period
% DVWINL - Default lower index of the voicing window
% DVWINH - Default upper index of the voicing window
% MXVDCL - Voicing detection SNR array size
% BBUFSIZE - Circular matching buffer size
%
% ******************************************************************
% CLEAR MEMORY
clear global
clear
clear all
clc
% DECLARE ALL GLOBAL CONSTANTS
global LFRAME AF OSLEN SBUFL LBUFL MAXORD MIDTAP MAXTAP MAXPIT;
global EOF READ WRITE MAXWIN LTAU ORDER;
% DEFINE GLOBAL CONSTANTS
READ = 0;
WRITE = 1;
EOF = -99;
LFRAME = 180;
AF = 3;
OSLEN = 10;
MAXWIN = 156;
LTAU = 60;
SBUFL = 181;
LBUFL = 25;
MAXORD = 10;
ORDER = 10;
MIDTAP = 2;
MAXTAP = 5;
MAXPIT = 156;
% DECLARE ALL LOCAL CONSTANTS
DVWINL = 307;
DVWINH = 462;
% GLOBAL VARIABLES ARE DECLARED ADJACENT TO THEIR DEFINITIONS
% LPC10.M
global LPC10path
LPC10path = cd;
% LPCEXEC.M
global FrameCnt
FrameCnt = 0;
% HP100.M
global hp100z1 hp100z2;
hp100z1 = zeros( 2, 1 );
hp100z2 = zeros( 2, 1 );
% ANALYS.M
global inbuf pebuf lpbuf ivbuf bias zpre tau voibuf awin ewin rmsbuf rcbuf;
inbuf = zeros( LFRAME * AF, 1 );
pebuf = zeros( LFRAME * AF, 1 );
lpbuf = zeros( 696, 1 );
awin = zeros( 2, AF );
awin(1,AF) = DVWINL;
awin(2,AF) = DVWINH;
ewin = zeros( 2, AF );
rmsbuf = zeros( AF, 1 );
rcbuf = zeros( MAXORD, AF );
ivbuf = zeros( 312, 1 );
bias = 0.00;
zpre = zeros( 2, 1 );
tau = [ ...
20,21,22,23,24,25,26,27,28,29,30,31,32,33,34, ...
35,36,37,38,39,40,42,44,46,48,50,52,54,56,58,60,62,64,66, ...
68,70,72,74,76,78,80,84,88,92,96,100,104,108,112,116,120, ...
124,128,132,136,140,144,148,152,156 ...
];
tau = tau';
voibuf = zeros( 2, AF+1 );
% LPFILT31.M
global alpf31 blpf31 zlpf31;
% FILTER TAP WEIGHTS
h0 = -0.0097201988;
h1 = -0.0105179986;
h2 = -0.0083479648;
h3 = 0.0005860774;
h4 = 0.0130892089;
h5 = 0.0217052232;
h6 = 0.0184161253;
h7 = 0.0003397230;
h8 = -0.0260797087;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -