close all;
clear all;
%% wczytanie i decymacja
[xw, fpw]=audioread('mbi04jeden.wav');
xv = decimate(xw, 6);
fpv= fpw/6;
tv = 0: 1/fpv : ((length(xv)-1)/fpv);

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

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

tr_v = fft(xv, fpvN);
atr_v = abs(tr_v);

tr_t = linspace(0, fpv, fpvN);

figure(2);
plot(tr_t(1:fpvN21), atr_v(1:fpvN21));

%% filtr
M=101;
fgr = 1000;
fgrN = fgr/(fpv/2);
h=fir1(M-1, fgrN, 'high');


k = filter(h, 1, xv);

%widmo transmitancji filtra
ffN = 2^nextpow2(M);
ffN21 = ffN/2 +1;

tr_h = fft(h, ffN);
atr_h = abs(tr_h);

 th = linspace (0,fpv ,ffN);
 
 figure(3);
 plot(th(1:ffN21), atr_h(1:ffN21));



tr_k = fft(k, fpvN);
atr_k = abs(tr_k);

figure(4);
t_k = linspace (0,fpv,fpvN);
plot(t_k(1:fpvN21),atr_k(1:fpvN21));




