You are on page 1of 2

1.

close all
2. clc
3. clear all
4.
5. [x, Fs] = audioread('psd1.wav'); %Input Audio
6. N = length(x);
7. T = N/Fs;
8. dt = 1/Fs;
9. t = (0:N-1)*dt;
10.
11. figure
12. subplot(2,1,1)
13. plot(t,x(:,1))
14. title('sinyal audio dengan derau pada domain waktu');
15. ylabel('L Stereo');
16. xlim([0 t(end)]);
17. subplot(2,1,2)
18. plot(t,x(:,2))
19. ylabel('R Stereo');
20. xlabel('waktu (sekon)');
21. xlim([0 t(end)]);
22.
23.
24. %% %Filter Audio
25. impulse=impz(getFilter); %Response Impulse Filter
26.
27. x1 = konvolusi1(x(:,1),impulse);
28. x2 = konvolusi1(x(:,2),impulse);%Konvolusi Antara Sinyal X Audio
dengan Respon Impuls Filter
29. X3 = [x1,x2];
30.
31. figure
32. subplot(2,1,1)
33. plot(impulse)
34. title('respon impuls filter kontinyu');
35. subplot(2,1,2)
36. stem(impulse)
37. title('respon impuls filter diskrit');
38. figure
39. freqz(impulse)
40. title('respon impuls filter domain frekuensi');
41.
42. %%
43. N1 = length(X3);
44. T1 = N1/Fs;
45. dt1 = 1/Fs;
46. t1 = (0:N1-1)*dt1;
47. figure
48. subplot(2,1,1)
49. plot(t1,X3(:,1))
50. title('sinyal audio setelah filtering pada domain waktu');
51. ylabel('L Stereo');
52. xlim([0 t1(end)]);
53. subplot(2,1,2)
54. plot(t1,X3(:,2))
55. ylabel('R Stereo');
56. xlabel('waktu (sekon)');
57. xlim([0 t1(end)]);
58.
59. %% % grafik transformasi fourier sinyal audio
60. m = 8000;
61. X1 = fft(x);
62. X1=X1(2:N/2+1);
63. f=(1:N/2).'/T;
64. X1 = freqAvg(X1,m);
65. f = freqAvg(f,m);
66.
67. m1 = 8000;
68. X2 = fft(X3);
69. X2=X2(2:N1/2+1);
70. f1=(1:N1/2).'/T1;
71. X2 = freqAvg(X2,m1);
72. f1 = freqAvg(f1,m1);
73.
74. figure
75. subplot(2,1,1)
76. plot(f,(abs(X1)))
77. title('sinyal audio dengan derau pada domain frekuensi') ;
78. subplot(2,1,2)
79. plot(f1,(abs(X2)))
80. title('sinyal audio setelah filtering pada domain frekuensi') ;
81.
82. figure
83. subplot(2,1,1)
84. plot(x)
85. title('sinyal x dengan derau pada domain frekuensi') ;
86. subplot(2,1,2)
87. plot(X3)
88. title('sinyal x setelah filtering pada domain frekuensi') ;
89.
90. % sound(X3,Fs);
91. %% % Design Filter
92. % FIR WINDOW KAISER
93.
94. function Hd = getFilter
95. %GETFILTER Returns a discrete-time filter object.
96. % Generated on: 03-Jan-2020 21:02:32
97.
98. Fpass = 1000; % Passband Frequency
99. Fstop = 1200; % Stopband Frequency
100. Apass = 1; % Passband Ripple (dB)
101. Astop = 90; % Stopband Attenuation (dB)
102. Fs = 44100; % Sampling Frequency
103.
104. h = fdesign.lowpass('fp,fst,ap,ast', Fpass, Fstop, Apass, As
top, Fs);
105. Hd = design(h, 'kaiserwin', ...
106. 'MinOrder', 'any');
107. end

You might also like