Вы находитесь на странице: 1из 10

function varargout = bimbingan2(varargin)

% BIMBINGAN2 M-file for bimbingan2.fig


% BIMBINGAN2, by itself, creates a new BIMBINGAN2 or raises the existing
% singleton*.
%
% H = BIMBINGAN2 returns the handle to a new BIMBINGAN2 or the handle to
% the existing singleton*.
%
% BIMBINGAN2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BIMBINGAN2.M with the given input arguments.
%
% BIMBINGAN2('Property','Value',...) creates a new BIMBINGAN2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before bimbingan2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to bimbingan2_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 bimbingan2

% Last Modified by GUIDE v2.5 20-Oct-2010 17:44:45

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @bimbingan2_OpeningFcn, ...
'gui_OutputFcn', @bimbingan2_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 bimbingan2 is made visible.


function bimbingan2_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 bimbingan2 (see VARARGIN)

% Choose default command line output for bimbingan2


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
% UIWAIT makes bimbingan2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = bimbingan2_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 pushbutton1.


function pushbutton1_Callback(hObject, eventdata, 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)[nama_file
nama_folder] = uigetfile('*.wav','pilih file suara' );
[nama_file nama_folder] = uigetfile('*.wav','pilih file suara' );
file_sound1 =[nama_folder nama_file];

[suara_piano,fs] = wavread (file_sound1);


figure(3)
subplot(2,1,1); plot(suara_piano); title('time');
subplot(2,1,2); spectrogram(suara_piano(:),'yaxis');title('spectrogram');
% axes(handles.axes1);spectrogram(suara, 'yaxis');
save suara_piano.mat suara_piano fs

handles = guidata(gcbf);
set (handles.edit2,'string',file_sound1);
save file_sound1.mat

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

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
% 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)
load suara_piano.mat
s= suara_piano(1:5000);
ls= length(s);

[C,L] = wavedec(s,7,'haar');
cA7 = appcoef (C,L,'haar',7);
cD7 = detcoef (C,L,7);
cD6 = detcoef (C,L,6);
cD5 = detcoef (C,L,5);
cD4 = detcoef (C,L,4);
cD3 = detcoef (C,L,3);
cD2 = detcoef (C,L,2);
cD1 = detcoef (C,L,1);
A7 = wrcoef ('a' , C, L, 'haar' ,7);
D1 = wrcoef ('d',C,L, 'haar', 1);
D2 = wrcoef ('d',C,L, 'haar', 2);
D3 = wrcoef ('d',C,L, 'haar', 3);
D4 = wrcoef ('d',C,L, 'haar', 4);
D5 = wrcoef ('d',C,L, 'haar', 5);
D6 = wrcoef ('d',C,L, 'haar', 6);
D7 = wrcoef ('d',C,L, 'haar', 7);
figure(4)
subplot (4,2,1); plot(A7); title ('approximation a7')
subplot (4,2,2); plot (D1); title ('detail D1')
subplot (4,2,3); plot (D2); title ('detail D2')
subplot (4,2,4); plot (D3); title ('detail D3')
subplot (4,2,5); plot (D4); title ('detail D4')
subplot (4,2,6); plot (D5); title ('detail D5')
subplot (4,2,7); plot (D6); title ('detail D6')
subplot (4,2,8); plot (D7); title ('detail D7')

% --- Executes on button press in pushbutton4.


function pushbutton4_Callback(hObject, eventdata, handles)
% 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)
load suara_gitar.mat
s= suara_gitar(1:5000);
ls= length(s);

[C,L] = wavedec(s,7,'haar');
[C,L] = wavedec(s,7,'haar');
cA7 = appcoef (C,L,'haar',7);
cD7 = detcoef (C,L,7);
cD6 = detcoef (C,L,6);
cD5 = detcoef (C,L,5);
cD4 = detcoef (C,L,4);
cD3 = detcoef (C,L,3);
cD2 = detcoef (C,L,2);
cD1 = detcoef (C,L,1);
A7 = wrcoef ('a' , C, L, 'haar' ,7);
D1 = wrcoef ('d',C,L, 'haar', 1);
D2 = wrcoef ('d',C,L, 'haar', 2);
D3 = wrcoef ('d',C,L, 'haar', 3);
D4 = wrcoef ('d',C,L, 'haar', 4);
D5 = wrcoef ('d',C,L, 'haar', 5);
D6 = wrcoef ('d',C,L, 'haar', 6);
D7 = wrcoef ('d',C,L, 'haar', 7);
figure(4)
subplot (4,2,1); plot(A7); title ('approximation a7')
subplot (4,2,2); plot (D1); title ('detail D1')
subplot (4,2,3); plot (D2); title ('detail D2')
subplot (4,2,4); plot (D3); title ('detail D3')
subplot (4,2,5); plot (D4); title ('detail D4')
subplot (4,2,6); plot (D5); title ('detail D5')
subplot (4,2,7); plot (D6); title ('detail D6')
subplot (4,2,8); plot (D7); title ('detail D7')

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% 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)
[nama_file nama_folder] = uigetfile('*.wav','pilih file suara' );
file_sound =[nama_folder nama_file];

[suara_gitar,fs] = wavread (file_sound);


figure(2)
subplot(2,1,1); plot(suara_gitar); title('time');
subplot(2,1,2); spectrogram(suara_gitar(:),'yaxis');title('spectrogram');
% axes(handles.axes1);spectrogram(suara, 'yaxis');
save suara_gitar.mat suara_gitar fs

handles = guidata(gcbf);
set (handles.edit3,'string',file_sound);
save file_sound.mat
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_piano.mat
x=suara_piano;
N=length(suara_piano);
sign_length= size(x,1);
s=0;

for i=1:(sign_length-1),
s=s+abs(sign(x(i))- sign (x(i+1)));
end
zc=1/(2*N) * s;
%zc1=1/(2) * s;
set(handles.edit5,'string',num2str(zc));

% --- Executes on button press in pushbutton12.


function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_gitar
x= suara_gitar;
N=length(suara_gitar);
sign_length=size(x,1);
s=0;
for i=1:sign_length,
s=s+x(i)^2;
end
E = (1/N)*s;

set(handles.edit7,'string',num2str(E));

% --- Executes on button press in pushbutton13.


function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_gitar.mat
x=suara_gitar;
N=length(suara_gitar);
sign_length= size(x,1);
s=0;

for i=1:(sign_length-1),
s=s+abs(sign(x(i))- sign (x(i+1)));
end
zc=1/(2*N) * s;
%zc1=1/(2) * s;
set(handles.edit8,'string',num2str(zc));

% --- Executes on button press in pushbutton14.


function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_piano
x= suara_piano;
N=length(suara_piano);
sign_length=size(x,1);
s=0;
for i=1:sign_length,
s=s+x(i)^2;
end
E = (1/N)*s;

set(handles.edit6,'string',num2str(E));

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

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 edit8_Callback(hObject, eventdata, handles)


% hObject handle to edit8 (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 edit8 as text


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

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


function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 button press in pushbutton15.


function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_piano.mat suara_piano fs
% [cepstra,aspectrum,pspectrum]=melfcc(suara_piano,fs);
% 'wintime': 0.016...
% 'lifterexp': 0 ...
% 'minfreq': 133.33...
% 'maxfreq': 6855.6...
% 'sumpower': 0);

% --- Executes on button press in pushbutton16.


function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_piano.mat suara_piano fs
fft_sp=fft(suara_piano,2048);
energib11 = fft_sp.*conj(fft_sp);
energib1=sum (energib11(1:7));
energib2=sum(energib11(1024:2048));
eratio=10*log(energib1/energib2);
set(handles.edit9,'string',num2str(eratio));

% --- Executes on button press in pushbutton17.


function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_gitar.mat suara_gitar fs
fft_sp=fft(suara_gitar,2048);
energib11 = fft_sp.*conj(fft_sp);
energib1=sum (energib11(1:7));
energib2=sum(energib11(1024:2048));
eratio=10*log(energib1/energib2);
set(handles.edit10,'string',num2str(eratio));

function edit9_Callback(hObject, eventdata, handles)


% hObject handle to edit9 (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 edit9 as text


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

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


function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (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 edit10 as text


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

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


function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (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 button press in pushbutton18.


function pushbutton18_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_piano.mat suara_piano fs
x = (1:length(suara_piano))./fs;
[m,mn]=mfcc(suara_piano);

[w2 h2] = size(m);


t = linspace(0,max(x),w2);
f = 1:h2; %f = f./max(f);

axes(handles.axes13) % MFCC
surf(t,f,rot90(rot90(rot90(m))),'EdgeColor','none') % rot90 supaya
TampilanNya dari Bawah
title('MFCC')
axis tight, colormap jet, view(0,90)

ciriMFCC = mean(abs(m(5:end,:))); % Jumlah semua Data Horizontal MFCC


ciriMFCC = ciriMFCC ./max(ciriMFCC);

axes(handles.axes14) % Ciri MFCC


plot(ciriMFCC)
% plot(ciriMFCC,linspace(0,1,length(ciriMFCC)))
title('Kurva MFCC')
axis tight

% --- Executes on button press in pushbutton19.


function pushbutton19_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load suara_gitar.mat suara_gitar fs
x = (1:length(suara_gitar))./fs;
[m,mn]=mfcc(suara_gitar);

[w2 h2] = size(m);


t = linspace(0,max(x),w2);
f = 1:h2; %f = f./max(f);

axes(handles.axes15) % MFCC
surf(t,f,rot90(rot90(rot90(m))),'EdgeColor','none') % rot90 supaya
TampilanNya dari Bawah
title('MFCC')
axis tight, colormap jet, view(0,90)

ciriMFCC = mean(abs(m(5:end,:))); % Jumlah semua Data Horizontal MFCC


ciriMFCC = ciriMFCC ./max(ciriMFCC);

axes(handles.axes16) % Ciri MFCC


plot(ciriMFCC)
% plot(ciriMFCC,linspace(0,1,length(ciriMFCC)))
title('Kurva MFCC')
axis tight

Вам также может понравиться