function varargout = lecture(varargin)
% LECTURE M-file for lecture.fig
% LECTURE, by itself, creates a new LECTURE or raises the existing
% singleton*.
%
% H = LECTURE returns the handle to a new LECTURE or the handle to
% the existing singleton*.
%
% LECTURE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LECTURE.M with the given input arguments.
%
% LECTURE('Property','Value',...) creates a new LECTURE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before lecture_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to lecture_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 lecture
% Last Modified by GUIDE v2.5 01-Aug-2006 19:09:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lecture_OpeningFcn, ...
'gui_OutputFcn', @lecture_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 lecture is made visible.
function lecture_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 lecture (see VARARGIN)
% Choose default command line output for lecture
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes lecture wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = lecture_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('*.*','Slectionner un fichier wav');
[son,Fs,bits] = wavread(fname);
%fp=fopen(filename,'r');
%z=fread(fp,'short');
save son;
save Fs;
%*** dfinition des constantes ***
Trame=floor(20*Fs/1000); % 20 ms
%*** segmentation en trames
[xtr,NB_TR] = trame(son,Trame,0);
guidata(hObject, handles);
set(handles.nbtrame,'string',NB_TR);
guidata(hObject, handles);
set(handles.freqech,'string',Fs);
t = (1:length(son))/Fs;
axes(handles.axes1);
plot(t,son);zoom xon;
grid on;
title(['Evolution Temporelle '],'FontSize',14,'Color','b')
xlabel(['t en [s]'],'FontSize',14,'Color','b');
ylabel(['Amplitude'],'FontSize',14,'Color','r');
legend('Son produit');
x=son;
% --- Executes during object creation, after setting all properties.
function nbtrame_CreateFcn(hObject, eventdata, handles)
% hObject handle to nbtrame (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 nbtrame_Callback(hObject, eventdata, handles)
% hObject handle to nbtrame (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 nbtrame as text
% str2double(get(hObject,'String')) returns contents of nbtrame as a double
% --- Executes during object creation, after setting all properties.
function freqech_CreateFcn(hObject, eventdata, handles)
% hObject handle to freqech (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 freqech_Callback(hObject, eventdata, handles)
% hObject handle to freqech (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 freqech as text
% str2double(get(hObject,'String')) returns contents of freqech as a double
% --- 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');
ntra=data.ntra;
%premire partie: analyse sur quelques trames choisies dans diffrentes zones du signal
ORDRE=10; % ordre de l'analyse LPC
load son;
load Fs;
x=son;
Trame=floor(20*Fs/1000) % 20 ms
%*** segmentation en trames
[xtr,NB_TR] = trame(son,Trame,0);
trames_choisies=ntra;%au pif
for tr=1:length(trames_choisies)
x=xtr(:,trames_choisies(tr));
%analyse LPC sur une trame
[coef_a,E(tr)]=lpc(x.*hanning(Trame),ORDRE);
a(tr,:)=real(coef_a);%la routine matlab lpc retourne un vecteur complexe (de partie imaginaire quasi nulle)
%calcul du rsiduel
e(:,tr)=filter(a(tr,:),1,x);
%exploitation des signaux et de l'analyse LPC
grid on;
%trac du signal et de l'erreur de prdiction
figure(3*tr)
subplot(211);plot(x);
title(['trame N : ',num2str(trames_choisies(tr)) ]);
legend('Signal Original')
subplot(212);plot(e(:,tr));legend('Rsiduel de l''analyse LPC')
%rponse frquentielle du filtre 1/A(z)
[h,f]=freqz(sqrt(E(tr)*Trame),a(tr,:),512);
f=f/2/pi*Fs;
%trac du spectre FFT et du spectre LPC surperpos
figure(3*tr+1)
subplot(211);fft_tr(x,Fs,3*tr+1);
title(['Trame N : ',num2str(trames_choisies(tr)) ]);
hold on;plot(f,20*log10(abs(h)),'r')
legend('Spectre FFT du signal original','Spectre LPC du Signal Original')
subplot(212);fft_tr(e(:,tr),Fs,3*tr+1);
legend('Spectre FFT du rsiduel')
amdfnorm(x,20,100,8000,3*tr+2);
title(['Trame N : ',num2str(trames_choisies(tr)) ]);
end
% --- Executes during object creation, after setting all properties.
function ntra_CreateFcn(hObject, eventdata, handles)
% hObject handle to ntra (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 ntra_Callback(hObject, eventdata, handles)
% hObject handle to ntra (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 ntra as text
% str2double(get(hObject,'String')) returns contents of ntra as a double
ntra = str2double(get(hObject, 'String'));
if isnan(ntra)
set(hObject, 'String', 0);
errordlg('Entrer un nombre SVP','Error');
end
data = getappdata(gcbf, 'metricdata');
data.ntra = ntra;
setappdata(gcbf, 'metricdata', data);
% --- 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)
% --- 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)
button = questdlg('Voulez Vous fermer ?', ...
'Quiter l''application','Oui','Non','No');
switch button
case 'Oui',
clc;
disp('*******************************************************************');
disp('************ Dveloppe par :MEKHMOUKH Abdenour *************');
disp('************ Dpartement d''Electronique *************');
disp('************ Universit de Bejaia Aot 2006 *************');
disp('*******************************************************************');
close;
case 'Non',
quit cancel;
end