Synthesize windowed signal after LPC

조회 수: 1 (최근 30일)
Abdullah Fahim
Abdullah Fahim 2015년 8월 7일
I am trying to check the functionality of lpc() function in matlab. So, - I read a wav file using audioread(), - Make blocks of 320 samples, with 50% overlap - Multiply each block by hamming window, - Get LPC coeff of each block by lpc() - Get LP Residual by inverse filter - Get back the original signal block by LPC coeff and LP Residual - Add the blocks together using overlap-add method.
However, the output is totally distorted. Not sure what is wrong with my code.
[yr,fr] = audioread('myaudio.wav');
initlen = length(yr); % Signal length
windowsize = 320;
overlapsize = 160;
framelength = 160;
blocks = ceil(initlen/framelength);
hammingwindow = hamming(windowsize);
extrazeros = (windowsize-framelength)/2;
yr_work = padarray(yr, extrazeros, 'pre'); % Pad zeros at the beginning
extrazeros = extrazeros + (blocks*framelength) - initlen;
yr_work = padarray(yr_work, extrazeros, 'post'); % Pad zeros at the end
est_yr = zeros(windowsize, blocks); % Array of processed blocks
for i=1:framelength:(blocks*framelength)
yr_w = yr_work(i:i+windowsize-1);
yr_w = yr_w.*hammingwindow; % apply Hamming window
a = lpc(yr_w, lpcorder);
res_yr_w = filter(a,1,yr_w); % LP Residual by inverse filter
est_yr(:, ceil(i/framelength)) = filter(1,a,res_yr_w);
end
% add blocks together
yd = zeros(initlen, 1); % final output
for i=1:blocks
arrstart = ((i-1)*framelength) + 1;
arrend = arrstart + framelength - 1;
yd(arrstart:arrend) = est_yr(overlapsize+1:end,i);
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Modeling에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by