[xw, fpw] = audioread('mbi04jeden.wav');
xv = decimate (xw, 6);
fpv = fpw/6;

tv = 0 : 1/fpv: ((length(xv)-1)/fpv);

figure(1)
subplot(4,1,1);
plot(tv, xv);

%% widmo
fpvN = 2^nextpow2(length(xv));
fpvN21 = fpvN/2 +1;

tr_xv = fft(xv, fpvN);
atr_xv = abs(tr_xv);

tr_t = linspace(0,fpv,fpvN);
subplot(4,1,2);
plot(tr_t(1:fpvN21),atr_xv(1:fpvN21));

%% filtracja
M = 1001;
fgr = 1000;
fgrN = fgr/(fpv/2);

h = fir1(M-1, fgrN ,'high');

%widmo filtra
fhN = 2^nextpow2(M);
fhN21 = fhN/2 +1;
tr_h = fft(h, fhN);
atr_h =abs(tr_h);

th = linspace (0, fpv, fhN);

subplot(414);
plot(th(1:fhN21), atr_h(1:fhN21));





f_xv = filter(h,1,xv);

tr_f_xv = fft(f_xv, fpvN);
atr_f_xv = abs(tr_f_xv);

subplot(4,1,3);
plot(tr_t(1:fpvN21), atr_f_xv(1:fpvN21));

