Sie sind auf Seite 1von 16

function varargout = ATIKK(varargin)

% ATIKK MATLAB code for ATIKK.fig


% ATIKK, by itself, creates a new ATIKK or raises the existing
% singleton*.
%
% H = ATIKK returns the handle to a new ATIKK or the handle to
% the existing singleton*.
%
% ATIKK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ATIKK.M with the given input arguments.
%
% ATIKK('Property','Value',...) creates a new ATIKK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ATIKK_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ATIKK_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ATIKK

% Last Modified by GUIDE v2.5 21-May-2018 15:57:59

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ATIKK_OpeningFcn, ...
'gui_OutputFcn', @ATIKK_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before ATIKK is made visible.


function ATIKK_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to ATIKK (see VARARGIN)

% Choose default command line output for ATIKK


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes ATIKK wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = ATIKK_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
close;
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton4.


function pushbutton4_Callback(hObject, eventdata, handles)
axes(handles.axes1)
cla reset
axes(handles.axes2)
cla reset
axes(handles.axes3)
cla reset
set(handles.edit1,'String',[0])
set(handles.edit2,'String',[0])
set(handles.edit3,'String',[0])
set(handles.edit4,'String',[0])
set(handles.edit5,'String',[])
set(handles.edit6,'String',[0])
set(handles.edit7,'String',[0])
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

function edit6_Callback(hObject, eventdata, handles)


% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a
double

% --- Executes during object creation, after setting all properties.


function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit7_Callback(hObject, eventdata, handles)


% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text


% str2double(get(hObject,'String')) returns contents of edit7 as a
double

% --- Executes during object creation, after setting all properties.


function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of edit1 as a
double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text


% str2double(get(hObject,'String')) returns contents of edit2 as a
double

% --- Executes during object creation, after setting all properties.


function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)


% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text


% str2double(get(hObject,'String')) returns contents of edit3 as a
double

% --- Executes during object creation, after setting all properties.


function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)


% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text


% str2double(get(hObject,'String')) returns contents of edit4 as a
double

% --- Executes during object creation, after setting all properties.


function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in listbox1.


function listbox1_Callback(hObject, eventdata, handles)
A = handles.axes1;
idMode = get (hObject,'value');
%untuk menampilkan segmen grafik pada selang x1;y1

%figure,plot(y)
Fs=str2num(get(handles.edit1,'string'));
myRecording=handles.audio;
waktu=1;
t=0:1/Fs:waktu; %sesuaikan dengan waktu
t(length(t))=[1];
if idMode == 1
x1=find(t==0);
y1=find(t==0);
t1=t(x1:y1);
y1=myRecording(x1:y1);
signalpieces=A(0:0);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));

elseif idMode == 2
x1=find(t==0);
y1=find(t==0.2);
t1=t(x1:y1);
y1=myRecording(x1:y1);
one=A(0:0.2);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));

elseif idMode == 3
x1=find(t==0.2);
y1=find(t==0.4);
t1=t(x1:y1);
y1=myRecording(x1:y1);
two=A(0.2:0.4);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));

elseif idMode == 4
x1=find(t==0.4);
y1=find(t==0.6);
t1=t(x1:y1);
y1=myRecording(x1:y1);
three=A(0.4:0.6);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));

elseif idMode == 5
x1=find(t==0.6);
y1=find(t==0.8);
t1=t(x1:y1);
y1=myRecording(x1:y1);
four=A(0.6:0.8);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));

elseif idMode == 6
x1=find(t==0.8);
y1=find(t==1.0);
t1=t(x1:y1);
y1=myRecording(x1:y1);
five=A(0.8:1.0);
axes(handles.axes2);
plot(t1,y1);
title('Fast Fourier Transform Graph');
grid on

sil=[];
for i=1:length(y1),
if(y1(i)>-.005)&&(y1(i)<.005),
sil(i)=1;
else
sil(i)=0;
end
end
sil;
sum(sil);
silent_ratio=sum(sil)/length(y1)
Y=fft(y1);
power=abs(Y(1:(length(Y)+1)/2));
frek=Fs*(0:(length(Y)-1)/2)/length(Y);
kuadrat=power.^2;
avarage_energy=sum(kuadrat)/length(power)
axes(handles.axes3)
plot(frek,power)
grid on
title('Avarage Energy Graph')
set(handles.edit6,'string',strcat(num2str(silent_ratio)));
set(handles.edit7,'string',strcat(num2str(avarage_energy)));
end
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents


as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1

% --- Executes during object creation, after setting all properties.


function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
Fs=str2num(get(handles.edit1,'string'));
nBits=str2num(get(handles.edit2,'string'));
nChannels=str2num(get(handles.edit3,'string'));
t=str2num(get(handles.edit4,'string'));

recObj = audiorecorder(Fs,nBits,nChannels);
set(handles.edit5,'String','Start Speaking.....')
recordblocking(recObj,t);
set(handles.edit5,'String','End of Recording.....')

myRecording = getaudiodata(recObj);
handles.audio=myRecording
axes(handles.axes1)
plot(myRecording)
grid on
title('Input Sound Signal')

handles.Fs = Fs;
handles.myRecording = myRecording;
guidata(hObject,handles);
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
myRecording = handles.myRecording;
Fs = handles.Fs;

sound(myRecording,Fs);
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

function edit5_Callback(hObject, eventdata, handles)


% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text


% str2double(get(hObject,'String')) returns contents of edit5 as a
double

% --- Executes during object creation, after setting all properties.


function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Das könnte Ihnen auch gefallen