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

tv = 0 : 1/fpv : (length(xv)-1)/fpv; %%%%%%%%%%%%%%%%%%%%%%%% pamietaæ!
figure(1)
subplot(421);
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);

subplot(422);
plot(tr_t(1:fpvN21),atr_v(1:fpvN21));

%% filtr
M = 1001;
fgr = 1500; % tylko do filtracji, a nie do wyznaczania transmitancji bezposrednio
fgrN = fgr/(fpv/2);
fhN= 2^nextpow2(M);
fhN21 = fhN/2 +1;

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

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

tr_th = linspace (0, fpv, fhN);%%%%%%%%%%%%%%
 
subplot(423);
plot(tr_th(1:fhN21), atr_h(1:fhN21)); 



%filtracja

k = filter (h, 1, xv);

tr_k = fft(k, fpvN);
atr_k = abs(tr_k);
hold on;
grid on;
subplot(424)
plot(tr_t(1:fpvN21), atr_k(1:fpvN21));




