Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc, clear, close all
- [x, Fs1] = audioread('whitenoise2018.wav');
- [y, Fs2] = audioread('whitenoise_rec2018.wav');
- dt = 10/length(x);
- T = 10;
- t = 0:dt:T-dt;
- fs = Fs1;
- X = fft(x);
- Y = fft(y);
- Rxx = xcorr(x,x);
- Rxy = xcorr(x,y);
- subplot(2,1,1);
- plot((-length(Rxx)/2 : length(Rxx)/2-1)/fs*1000, Rxx) %s->ms
- axis tight;
- xlabel('time [ms]');
- ylabel('Rxx');
- title('Autokorelacja Rxx');
- grid on;
- subplot(2,1,2);
- plot((-length(Rxy)/2 : length(Rxy)/2-1)/fs*1000, Rxy) %s->ms
- axis tight;
- xlabel('czas [ms]');
- ylabel('Rxy');
- title('Korelacja krzyżowa Rxy');
- grid on;
- figure();
- H = Y./X;
- N = length(H);
- absH = abs(H);
- argH = unwrap(angle(H));
- f=(0:length(absH)/2-1)*fs/(length(absH));
- subplot(2,1,1);
- semilogx(f,20*log((absH(1:N/2))));
- axis tight;
- xlabel('częstotliowość [Hz]');
- ylabel('|L|');
- line([fs/2 fs/2], ylim,'Color',[1 0 0],'LineWidth',1);
- title('Ch-ka amplitudowo-częstotliwościowa');
- grid on;
- subplot(2,1,2);
- semilogx(f,(argH(1:N/2)));
- axis tight;
- xlabel('częstotliowość [Hz]');
- ylabel('faza [ ^o]');
- line([fs/2 fs/2], ylim,'Color',[1 0 0],'LineWidth',1);
- title('Ch-ka fazowowo-częstotliwościowa');
- grid on;
- figure();
- h = ifft(H);
- plot(t(1:1500),h(1:1500));
- axis tight;
- xlabel('czas [s]');
- ylabel('A');
- title('Odpowiedź impulsowa');
- grid on;
- peak = 0.1;
- for i=1:length(h)
- if h(i) >= peak
- distance = i/fs*320;
- break;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement