Wednesday, February 28, 2018

Tapis FIR Berbasis Pencuplikan Frekuensi dan Implementasinya Pada Sinyal Audio


Antarmuka GUI MATLAB ini dapat dipakai untuk laboratorium sinyal bagi mahasiswa dan untuk menunjang penelitian bagi para peneliti. Anda bisa memesannya pada form pemesanan di bawah ini.











KODE UNTUK SALAH SATU EVENT CALLBACK:


% --- Executes on button press in Lowpass.
function Lowpass_Callback(hObject, eventdata, handles)
% hObject    handle to Lowpass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global x;

% Membaca semua parameter tapis
omega1s = str2num(get(handles.omega1s,'String'));
omega2s = str2num(get(handles.omega2s,'String'));
omega1p = str2num(get(handles.omega1p,'String'));
omega2p = str2num(get(handles.omega2p,'String'));
A1s = str2num(get(handles.A1s,'String'));
A2s = str2num(get(handles.A2s,'String'));
R1p = str2num(get(handles.R1p,'String'));
R2p = str2num(get(handles.R2p,'String'));

%Mengalikan dengan pi
%omega1s = omega1s * pi;
%omega1p = omega1p * pi;
%omega2s = omega2s * pi;
%omega2p = omega2p * pi;

if(omega1s > omega1p)

M=60; alpha=(M-1)/2; l=0:M-1; w1=(2*pi/M)*l;

%Membaca nilai slider
nilaiSlider = get(handles.slider1,'Value');

% Respon amplitudo ideal tercuplik
Hrs=[ones(1,3+nilaiSlider),0.5925,0.1099,zeros(1,47-nilaiSlider),0.1099,0.5925,ones(1,6)];

% respon amplitudo ideal
Hdr=[1,1,0,0]; wd1=[0,omega1p,omega1s,1]; 

k1=0:floor((M-1)/2); k2=floor((M-1)/2)+1:M-1;
angH=[-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H=Hrs.*exp(j*angH);

%Respon aktual
h=real(ifft(H,M));
[db,mag,pha,grd,w]=freqz_m(h,1);

[Hr,ww,a,L]=Hr_Tipe2(h);


%Menampilkan sampel-sampel frekuensi
axes(handles.axes7);
plot(w1(1:M/2)/pi, Hrs(1:M/2), 'o', wd1/2, Hdr,'color','r');
axis([0,1,-0.1,1.1]); title('Sampel-sampel frekuensi: M=60')
xlabel('frekuensi dalam unit pi'); ylabel('Hr(k)')
set(gca,'color',[0,0,0]);

%Menampilkan respon impuls
axes(handles.axes8);
stem(l,h,'color','r');
axis([-1,M,-0.1,0.4]); title('Respon impuls')
xlabel('frekuensi dalam unit pi'); ylabel('h(n)')
set(gca,'color',[0,0,0]);

%Menampilkan respon amplitudo
axes(handles.axes9);
plot(ww/pi, Hr, w1(1:M/2)/pi, Hrs(1:M/2), 'o','color','r');
axis([0,1,-0.2,1.2]); title('Respon amplitudo')
xlabel('frekuensi dalam unit pi'); ylabel('Hr(w)')
set(gca,'color',[0,0,0]);

%Menampilkan magnitudo dalam dB
axes(handles.axes3);
plot(w/pi, db,'color','r', 'LineWidth' ,2);
axis([0,1,-90,10]); title('Respon magnitudo')
xlabel('frekuensi dalam unit pi'); ylabel('dB')
set(gca,'color',[0,0,0]);

% Menghitung Hasil Penapisan
y = conv(double(x),double(h), 'same');
axes(handles.axes2); 
t = 0:length(y)-1;  %vektor indeks
stem(t,y,'linewidth',1,'color','y');title('Keluaran Tapis')
set(gca,'color',[0,0,0]);

else
    h = msgbox('Omega1s Harus Lebih Besar dari Omega1p');
end

%Menyimpan data global
global lowpass
lowpass = h;

%axes(handles.axes3)
%specgram(y, 8, 8);
%title('Spektrum Sinyal');
%set(gca,'color',[0,0,0]);


No comments: