Advertisement
Guest User

hafid

a guest
Nov 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. clc
  2.  
  3. % FREKUENSI SAMPLING & WAKTU
  4. fs=8000;
  5. t=0:1/fs:1;
  6. N=length(t);
  7.  
  8. % PENGAMBILAN & PEMBAGIAN DATA
  9. in=audioread('PSDKASUSA2.wav');
  10. dt1=in(1:8001);
  11. dt2=in(8001:16002);
  12. dt3=in(16002:24003);
  13. dt4=in(24003:32004);
  14. dt5=in(32004:40005);
  15. dt6=in(40005:48006);
  16.  
  17. % NILAI KOEFISIEN K
  18. k1=round(697/fs*N);
  19. k2=round(770/fs*N);
  20. k3=round(852/fs*N);
  21. k4=round(941/fs*N);
  22. k5=round(1209/fs*N);
  23. k6=round(1336/fs*N);
  24. k7=round(1477/fs*N);
  25.  
  26. % FILTERING
  27. a1=[1 -2*cos(2*pi*k1/N) 1];
  28. a2=[1 -2*cos(2*pi*k2/N) 1];
  29. a3=[1 -2*cos(2*pi*k3/N) 1];
  30. a4=[1 -2*cos(2*pi*k4/N) 1];
  31. a5=[1 -2*cos(2*pi*k5/N) 1];
  32. a6=[1 -2*cos(2*pi*k6/N) 1];
  33. a7=[1 -2*cos(2*pi*k7/N) 1];
  34.  
  35. % NADA 1
  36. y1 = filter(1,a1,dt1);
  37. y2 = filter(1,a2,dt1);
  38. y3 = filter(1,a3,dt1);
  39. y4 = filter(1,a4,dt1);
  40. y5 = filter(1,a5,dt1);
  41. y6 = filter(1,a6,dt1);
  42. y7 = filter(1,a7,dt1);
  43.  
  44. % NADA 2
  45. y1 = filter(1,a1,dt2);
  46. y2 = filter(1,a2,dt2);
  47. y3 = filter(1,a3,dt2);
  48. y4 = filter(1,a4,dt2);
  49. y5 = filter(1,a5,dt2);
  50. y6 = filter(1,a6,dt2);
  51. y7 = filter(1,a7,dt2);
  52.  
  53. % NADA 3
  54. y1 = filter(1,a1,dt3);
  55. y2 = filter(1,a2,dt3);
  56. y3 = filter(1,a3,dt3);
  57. y4 = filter(1,a4,dt3);
  58. y5 = filter(1,a5,dt3);
  59. y6 = filter(1,a6,dt3);
  60. y7 = filter(1,a7,dt3);
  61.  
  62. % NADA 4
  63. y1 = filter(1,a1,dt4);
  64. y2 = filter(1,a2,dt4);
  65. y3 = filter(1,a3,dt4);
  66. y4 = filter(1,a4,dt4);
  67. y5 = filter(1,a5,dt4);
  68. y6 = filter(1,a6,dt4);
  69. y7 = filter(1,a7,dt4);
  70.  
  71. % NADA 5
  72. y1 = filter(1,a1,dt5);
  73. y2 = filter(1,a2,dt5);
  74. y3 = filter(1,a3,dt5);
  75. y4 = filter(1,a4,dt5);
  76. y5 = filter(1,a5,dt5);
  77. y6 = filter(1,a6,dt5);
  78. y7 = filter(1,a7,dt5);
  79.  
  80. % NADA 6
  81. y1 = filter(1,a1,dt6);
  82. y2 = filter(1,a2,dt6);
  83. y3 = filter(1,a3,dt6);
  84. y4 = filter(1,a4,dt6);
  85. y5 = filter(1,a5,dt6);
  86. y6 = filter(1,a6,dt6);
  87. y7 = filter(1,a7,dt6);
  88.  
  89. % POWER TIAP FREKUENSI
  90. m(1)=sqrt(y1(N)^2+y1(N-1)^2-2*cos(2*pi*k1/N)*y1(N)*y1(N-1));
  91. m(2)=sqrt(y2(N)^2+y2(N-1)^2-2*cos(2*pi*k2/N)*y2(N)*y2(N-1));
  92. m(3)=sqrt(y3(N)^2+y3(N-1)^2-2*cos(2*pi*k3/N)*y3(N)*y3(N-1));
  93. m(4)=sqrt(y4(N)^2+y4(N-1)^2-2*cos(2*pi*k4/N)*y4(N)*y4(N-1));
  94. m(5)=sqrt(y5(N)^2+y5(N-1)^2-2*cos(2*pi*k5/N)*y2(N)*y2(N-1));
  95. m(6)=sqrt(y6(N)^2+y6(N-1)^2-2*cos(2*pi*k6/N)*y3(N)*y3(N-1));
  96. m(7)=sqrt(y7(N)^2+y7(N-1)^2-2*cos(2*pi*k7/N)*y4(N)*y4(N-1));
  97.  
  98. f = [697 770 852 941 1209 1336 1477];
  99. subplot(2,3,1)
  100. stem(f,m);grid
  101. xlabel('frequency (Hz)')
  102. title ('DTMF Magnitude')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement