% --------------zkraceni signalu-------------------------------------------
function preprocessing(p_kanalu)

fm=3440;
Fvz = 48000;
[b,a]=pardp1(fm,Fvz); %dolni propust

for n=1:p_kanalu
    nazev = ['mic',int2str(n),'.wav'];
    [x,Fvz,Nbits]=wavread(nazev);
    x = filter(b,a,x);
    y = x(1:1024);
    wavwrite(y,Fvz,Nbits,nazev);
%     nazevT = ['mic',int2str(n),'.txt'];
%     fid = fopen(nazevT,'wt'); 
%     fprintf(fid,'%16.14f,\n',x); 
%     fclose(fid);
end

figure(1)
% title('\bfČasový průběh vstupního signálu','Fontname','MS Sans Serif');
x_osa = linspace(0,length(x)/Fvz, length(x));
plot(x_osa,x)
set(gca,'xlim',[0 length(x)/Fvz])
xlabel('{\it{t}}  [s]  \rightarrow')
ylabel('{\it{x}}  [-]  \rightarrow')

figure(2)
spectrogram(x,hanning(1024),512,1024,Fvz,'yaxis');
% title('\bfSpektrogram vstupního signálu','Fontname','MS Sans Serif')
set(gca,'ylim',[0 16000])
xlabel('{\itt} [s] \rightarrow');
ylabel('{\itf} [Hz] \rightarrow');
text(0.26,-1000,'{\itG} (dB) \downarrow');%0.011
caxis([-150 -66]);
colorbar
set(gca,'layer','top','box','on')

figure(3)
NN=2048;
[H,f]=freqz(b,a,NN,Fvz);
semilogx(f,20*log10(abs(H)))
grid on
set(gca,'xlim',[20 20000])
set(gca,'ylim',[-15 15])
% title('\bf Kmitočtová charakteristika parametrické dolní propusti','fontname','MS Sans Serif')
xlabel('{\itf} [Hz] \rightarrow')
ylabel('Modul [dB] \rightarrow')

