2020-10-30 19:54:44 +00:00
|
|
|
%% lpss_lpc.m
|
|
|
|
%%
|
|
|
|
%% Load wav and calculate LPC coeffs
|
|
|
|
|
2020-11-03 22:21:19 +00:00
|
|
|
close all;clear all;clc;
|
2020-10-30 19:54:44 +00:00
|
|
|
|
2020-11-03 22:21:19 +00:00
|
|
|
ORDER = 50;
|
2020-10-30 19:54:44 +00:00
|
|
|
DISPLAY_SAMPLES = 1000;
|
|
|
|
|
|
|
|
% READ SIGNAL
|
|
|
|
[y, Fs] = audioread('samples/hood_m.wav');
|
2020-11-03 22:21:19 +00:00
|
|
|
L = length(y) % number of samples
|
2020-10-30 19:54:44 +00:00
|
|
|
DISPLAY_SAMPLES = min([DISPLAY_SAMPLES L]);
|
|
|
|
|
2020-11-03 22:21:19 +00:00
|
|
|
% CALCULATE FFT
|
|
|
|
[freq_dom_freqs, freq_dom_vals] = fft_(y, Fs);
|
|
|
|
|
|
|
|
for ITER=1:5:ORDER
|
2020-10-30 19:54:44 +00:00
|
|
|
|
|
|
|
% LPC
|
|
|
|
a = lpc(y,ITER); % signal, filter order
|
2020-11-03 22:21:19 +00:00
|
|
|
|
|
|
|
% COMPARE FREQ DOMAIN
|
|
|
|
[h, filter_freqs] = freqz(1, a, length(freq_dom_freqs), Fs);
|
|
|
|
|
|
|
|
figure(1)
|
|
|
|
plot(freq_dom_freqs, 20*log10(freq_dom_vals), 'r', filter_freqs, 20*log10(abs(h)), 'b')
|
|
|
|
% plot(w/pi, 20*log10(abs(h)))
|
2020-10-30 19:54:44 +00:00
|
|
|
grid
|
2020-11-03 22:21:19 +00:00
|
|
|
xlabel('Frequency (Hz)')
|
|
|
|
ylabel('Magnitude (dB)')
|
|
|
|
legend('Original Signal', 'LPC Filter')
|
2020-10-30 19:54:44 +00:00
|
|
|
|
2020-11-03 22:21:19 +00:00
|
|
|
% COMPARE TWO SIGNALS TIME DOMAIN
|
|
|
|
% est_y = filter(0.02, a, y);
|
|
|
|
% x = 1:DISPLAY_SAMPLES;
|
2020-10-30 19:54:44 +00:00
|
|
|
% figure(2)
|
2020-11-03 22:21:19 +00:00
|
|
|
% plot(x, y(end-DISPLAY_SAMPLES+1:end), x, est_y(end-DISPLAY_SAMPLES+1:end), '--')
|
|
|
|
% %plot(x, y(end-DISPLAY_SAMPLES+1:end))
|
|
|
|
% %plot(x, est_y(end-DISPLAY_SAMPLES+1:end))
|
2020-10-30 19:54:44 +00:00
|
|
|
% grid
|
2020-11-03 22:21:19 +00:00
|
|
|
% xlabel('Sample Number')
|
|
|
|
% ylabel('Amplitude')
|
|
|
|
% legend('Original signal','LPC estimate')
|
|
|
|
|
|
|
|
|
|
|
|
pause(0.5)
|
2020-10-30 19:54:44 +00:00
|
|
|
|
|
|
|
end
|