Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- % FREKUENSI SAMPLING & WAKTU
- fs=8000;
- t=0:1/fs:1;
- N=length(t);
- % PENGAMBILAN & PEMBAGIAN DATA
- in=audioread('PSDKASUSA2.wav');
- dt1=in(1:8001);
- dt2=in(8001:16002);
- dt3=in(16002:24003);
- dt4=in(24003:32004);
- dt5=in(32004:40005);
- dt6=in(40005:48006);
- % NILAI KOEFISIEN K
- k1=round(697/fs*N);
- k2=round(770/fs*N);
- k3=round(852/fs*N);
- k4=round(941/fs*N);
- k5=round(1209/fs*N);
- k6=round(1336/fs*N);
- k7=round(1477/fs*N);
- % FILTERING
- a1=[1 -2*cos(2*pi*k1/N) 1];
- a2=[1 -2*cos(2*pi*k2/N) 1];
- a3=[1 -2*cos(2*pi*k3/N) 1];
- a4=[1 -2*cos(2*pi*k4/N) 1];
- a5=[1 -2*cos(2*pi*k5/N) 1];
- a6=[1 -2*cos(2*pi*k6/N) 1];
- a7=[1 -2*cos(2*pi*k7/N) 1];
- % NADA 1
- y1 = filter(1,a1,dt1);
- y2 = filter(1,a2,dt1);
- y3 = filter(1,a3,dt1);
- y4 = filter(1,a4,dt1);
- y5 = filter(1,a5,dt1);
- y6 = filter(1,a6,dt1);
- y7 = filter(1,a7,dt1);
- % NADA 2
- y1 = filter(1,a1,dt2);
- y2 = filter(1,a2,dt2);
- y3 = filter(1,a3,dt2);
- y4 = filter(1,a4,dt2);
- y5 = filter(1,a5,dt2);
- y6 = filter(1,a6,dt2);
- y7 = filter(1,a7,dt2);
- % NADA 3
- y1 = filter(1,a1,dt3);
- y2 = filter(1,a2,dt3);
- y3 = filter(1,a3,dt3);
- y4 = filter(1,a4,dt3);
- y5 = filter(1,a5,dt3);
- y6 = filter(1,a6,dt3);
- y7 = filter(1,a7,dt3);
- % NADA 4
- y1 = filter(1,a1,dt4);
- y2 = filter(1,a2,dt4);
- y3 = filter(1,a3,dt4);
- y4 = filter(1,a4,dt4);
- y5 = filter(1,a5,dt4);
- y6 = filter(1,a6,dt4);
- y7 = filter(1,a7,dt4);
- % NADA 5
- y1 = filter(1,a1,dt5);
- y2 = filter(1,a2,dt5);
- y3 = filter(1,a3,dt5);
- y4 = filter(1,a4,dt5);
- y5 = filter(1,a5,dt5);
- y6 = filter(1,a6,dt5);
- y7 = filter(1,a7,dt5);
- % NADA 6
- y1 = filter(1,a1,dt6);
- y2 = filter(1,a2,dt6);
- y3 = filter(1,a3,dt6);
- y4 = filter(1,a4,dt6);
- y5 = filter(1,a5,dt6);
- y6 = filter(1,a6,dt6);
- y7 = filter(1,a7,dt6);
- % POWER TIAP FREKUENSI
- m(1)=sqrt(y1(N)^2+y1(N-1)^2-2*cos(2*pi*k1/N)*y1(N)*y1(N-1));
- m(2)=sqrt(y2(N)^2+y2(N-1)^2-2*cos(2*pi*k2/N)*y2(N)*y2(N-1));
- m(3)=sqrt(y3(N)^2+y3(N-1)^2-2*cos(2*pi*k3/N)*y3(N)*y3(N-1));
- m(4)=sqrt(y4(N)^2+y4(N-1)^2-2*cos(2*pi*k4/N)*y4(N)*y4(N-1));
- m(5)=sqrt(y5(N)^2+y5(N-1)^2-2*cos(2*pi*k5/N)*y2(N)*y2(N-1));
- m(6)=sqrt(y6(N)^2+y6(N-1)^2-2*cos(2*pi*k6/N)*y3(N)*y3(N-1));
- m(7)=sqrt(y7(N)^2+y7(N-1)^2-2*cos(2*pi*k7/N)*y4(N)*y4(N-1));
- f = [697 770 852 941 1209 1336 1477];
- subplot(2,3,1)
- stem(f,m);grid
- xlabel('frequency (Hz)')
- title ('DTMF Magnitude')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement