swsmodel.m

来自「非常好的数字处理教程」· M 代码 · 共 43 行

M
43
字号
function [F,M] = swsmodel(D,R,H)% [F,M] = swsmodel(D,R,H)  Sine wave speech analysis%       D is a speech example sampled at R samples per second.%       Return a sinusoid model of up to 4 components with each sinusoid%       defined by a row of F (frequencies in Hz) and M (linear magnitude). %       Each column of F and M corresponds to H samples at R.%       Rows of F are sorted with lowest frequency first; %       sinusoids cannot cross.%%       Relies on lpcfit.m and lpca2frq.m to form LPC model and convert it %       into frequencies.% 2001-03-12 dpwe@ee.columbia.edu $Header: $if nargin < 2  R = 8000; endif nargin < 3  H = 128;end% Target sampling rateMyR = 8000;% Resample to 8 kHz, so LPC only picks main formantsif R ~= MyR  D = resample(D, round(MyR/1000) ,round(R/1000));end% Step size in units of my sampling rateHH = 2*round(H/R * MyR/2);% Form 8th-order LPC model (3 or 4 pole pairs)lpca = lpcfit2(D,8,2*HH,HH);% Convert poles to sorted freqs and magnitudes% If only 3 nonzero freqs are found, 4th row will have mag/frq zero[fa, ma] = lpca2frq(lpca);% Convert frqs into HzF = fa'*MyR/(2*pi);M = ma';

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?