No BSD License  

Highlights from
speech processing tool

image thumbnail
from speech processing tool by MEKHMOUKH Abdenour
speech processing tool

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

% Last Modified by GUIDE v2.5 28-Jan-2008 19:09:04

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @analysehomomorphique_OpeningFcn, ...
                   'gui_OutputFcn',  @analysehomomorphique_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 analysehomomorphique is made visible.
function analysehomomorphique_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 analysehomomorphique (see VARARGIN)

% Choose default command line output for analysehomomorphique
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes analysehomomorphique wait for user response (see UIRESUME)
% uiwait(handles.figure1);


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

clc;
[fname,pname] = uigetfile('*.wav','Slectionner un fichier wav');
[son,Fs,bits] = wavread(fname);
savefile = 'test.mat';
save(savefile,'son','Fs','bits')
data = getappdata(gcbf, 'metricdata');
data.son= son;
data.Fs= Fs;
data.bits= bits;
setappdata(gcbf, 'metricdata', data);
h=guidata(gcbo);
    set(h.popupmenu2,'Enable','off'); 
% --- 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)
data = getappdata(gcbf, 'metricdata');
Fs=data.Fs;
son=data.son;
sound(son,Fs);



% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1

choix=get(hObject,'Value');
data = getappdata(gcbf, 'metricdata');
Fs=data.Fs;
son=data.son;
bw=data.bits;
s=size(son);
t = (1:s(1))/Fs

if choix==1

plot(t,son);zoom xon;
xlabel(['t en [s]'],'FontSize',14,'Color','b');
ylabel(['Amplitude'],'FontSize',14,'Color','b');
legend('Son produit');
end


if choix==2
    h=guidata(gcbo);
    set(h.popupmenu2,'Enable','on'); 
ms1=Fs/1000;
ms20=Fs/50;
load fenetre;
if fenetre==1
Y=fft(son.*hanning(length(son)));
end

if fenetre==2
Y=fft(son.*hann(length(son)));
end

if fenetre==3
Y=fft(son.*bartlett(length(son)));
end

if fenetre==4
Y=fft(son.*blackman(length(son)));
end


%axes(handles.axes1);   
C=fft(log(abs(Y)+eps));
q=(ms1:ms20)/Fs;
plot(q,abs(C(ms1:ms20)));
legend('Cepstre');
xlabel('Quefrence (s)','fontsize',14);
ylabel('Amplitude','fontsize',14);
[c,fx]=max(abs(C(ms1:ms20)));

set(handles.fondamentale,'string',Fs/(ms1+fx-1));
end

if choix==3
    h=guidata(gcbo);
    set(h.popupmenu2,'Enable','off'); 
axes(handles.axes1) ;  
spectrogram(son,Fs,bw);
end


if choix==4
h=guidata(gcbo);
    set(h.popupmenu2,'Enable','off'); 

Y=fft(son.*hamming(length(son)));

hz5000=5000*length(Y)/Fs;

f=(0:hz5000)*Fs/length(Y);
axes(handles.axes1);   


plot(f,20*log10(abs(Y(1:length(f)))+eps));

legend('Spectre');

xlabel('Frequence (Hz)');

ylabel('Magnitude (dB)');
end
if choix==5
    h=guidata(gcbo);
    set(h.popupmenu2,'Enable','off'); 
    ms1=Fs/1000;

ms20=Fs/50;

% calculer l'autocorrelation

r=xcorr(son,ms20,'coeff');

%

% plot autocorrelation

d=(-ms20:ms20)/Fs;


plot(d,r);

legend('Autocorrelation');

xlabel('Temps (s)');

ylabel('Correlation coeff.');
end
% --- 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)


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

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[fname,pname] = uigetfile('*.mat','Slectionner un fichier Data');
load (fname);
data = getappdata(gcbf, 'metricdata');
data.son= son;
data.Fs= Fs;
data.bits= bits;
setappdata(gcbf, 'metricdata', data);


% --- Executes during object creation, after setting all properties.
function fondamentale_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fondamentale (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function fondamentale_Callback(hObject, eventdata, handles)
% hObject    handle to fondamentale (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 fondamentale as text
%        str2double(get(hObject,'String')) returns contents of fondamentale as a double


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in listbox2.




% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2

fenetre = get(hObject,'Value')
save fenetre;


% --- Executes on button press in pushbutton5.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (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 pushbutton1.
function pushbutton9_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)


% --- 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)


Contact us at files@mathworks.com