1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
| function varargout = interface_sofiene(varargin)
% INTERFACE_SOFIENE M-file for interface_sofiene.fig
% INTERFACE_SOFIENE, by itself, creates a new INTERFACE_SOFIENE or raises the existing
% singleton*.
%
% H = INTERFACE_SOFIENE returns the handle to a new INTERFACE_SOFIENE or the handle to
% the existing singleton*.
%
% INTERFACE_SOFIENE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in INTERFACE_SOFIENE.M with the given input arguments.
%
% INTERFACE_SOFIENE('Property','Value',...) creates a new INTERFACE_SOFIENE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before interface_sofiene_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to interface_sofiene_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 interface_sofiene
% Last Modified by GUIDE v2.5 10-Mar-2010 21:42:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @interface_sofiene_OpeningFcn, ...
'gui_OutputFcn', @interface_sofiene_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 interface_sofiene is made visible.
function interface_sofiene_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 interface_sofiene (see VARARGIN)
% Choose default command line output for interface_sofiene
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes interface_sofiene wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = interface_sofiene_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;
set(handles.visualiser,'Enable','off');
set(handles.ecouter,'Enable','off');
set(handles.visualiser_sig_percu,'Enable','off');
set(handles.ecouter_sig_percu,'Enable','off');
set(handles.age,'Enable','off');
set(handles.sexe,'Enable','off');
set(handles.pertes,'Enable','off');
set(handles.seuil_age,'Enable','off');
set(handles.testing_staticText1,'Enable','off');
set(handles.testing_staticText,'Enable','off');
% --- Executes on button press in parcourir.
function parcourir_Callback(hObject, eventdata, handles)
% hObject handle to parcourir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% "uigetfile" donne une fenetre d'explorateur des fichiers de paramètres
% avec (type de fichier "*.wav", nom de la fenetre) et qui donne le nom de
% fichier et le chemin respectivement Filename et Pathname
[FileName,PathName] = uigetfile('*.wav','rechercher le fichier wav');
% le chemin total : concatination du nom du fichier et son chemin dans une
% chaine de caractères.
x=fullfile(PathName,FileName);
%Pour l'affichage d'une chaine_de_caractères dans un objet de type "Edit" de l'interface on met :
%set(handles.nom_objet,'string',chaine_de_caractères)
set(handles.chemin,'string',x);% x serait de type string présentant le path du fichier son
set(handles.parcourir,'UserData',x);
%calculer la durée en secondes d'un fichier WAV
[y,Fe] = wavread(x);
%transformation du stéréo vers le mono
if size(y,2) == 2
y = (y(:,1) + y(:,2))/2;
end
%l=length(y);
%activer et déactiver les boutons necessaires pour l'enchainement de
%l'algorithme
set(handles.visualiser,'Enable','on');
set(handles.ecouter,'Enable','on');
set(handles.age,'Enable','on');
set(handles.sexe,'Enable','on');
set(handles.seuil_age,'Enable','on');
set(handles.pertes,'Enable','on');
set(handles.visualiser_sig_percu,'Enable','off');
set(handles.ecouter_sig_percu,'Enable','off');
% sauvgarde du signal 'y' et de 'fe' dans "UserData" afin d'être utilisée dans
% d'autres fonctions
set(handles.parcourir,'UserData',y);
%set(handles.parcourir,'UserData1',Fe);
%set(handles.parcourir,'UserData',l);
% --- Executes during object creation, after setting all properties.
function saisir_sig_CreateFcn(hObject, eventdata, handles)
% hObject handle to saisir_sig (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 during object creation, after setting all properties.
function enreg_sig_CreateFcn(hObject, eventdata, handles)
% hObject handle to enreg_sig (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 visualiser.
function visualiser_Callback(hObject, eventdata, handles)
% hObject handle to visualiser (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% pour lire une variable locale d'une autre fonction callback
y=get(handles.parcourir,'UserData');
%Fe=get(handles.parcourir,'UserData');
%l=get(handles.parcourir,'UserData');
%t=(1:l)/Fe ; % on définit l'axe des temps
figure
plot(y), grid on , title('Allure temporelle du signal enregistré'), xlabel('nbre d échantillons'), ylabel('amplitude du signal')
% Hint: get(hObject,'Value') returns toggle state of visualiser
% --- Executes on button press in ecouter.
function ecouter_Callback(hObject, eventdata, handles)
% hObject handle to ecouter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y=get(handles.parcourir,'UserData');
%Fe=get(handles.parcourir,'UserData1');
au_play1=audioplayer(y,44100);
play(au_play1);
pause(length(y));
% Hint: get(hObject,'Value') returns toggle state of ecouter
% --- Executes on button press in seuil_normal.
function seuil_normal_Callback(hObject, eventdata, handles)
% hObject handle to seuil_normal (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fe=44100;
N=1024;
%%%%%%%%%%%%%%%%%%%%%%%%%%
s=[];
freq=(0:N-1).*(fe/(2*N));
freq=freq/1000;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% On intoduit ci-dessus l'équation définie par la norme MPEG %%%%
%%%%% et ce pour calculer le seuil d'audition absolu %%%
s=(3.64*(freq.^(-0.8)))-(6*(exp(-0.6.*(freq-(3.3)).^2)))+(0.001*(freq.^4));%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
plot(freq,s, 'r'); title(' Seuil d''audition absolu ');xlabel('Fréquence(Hz)'); ylabel('Amplitudes (dB)');
% --- Executes on selection change in sexe.
function sexe_Callback(hObject, eventdata, handles)
% hObject handle to sexe (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
switch get(handles.sexe,'Value')
case 1
set(handles.testing_staticText,'FontSize',homme);
case 2
set(handles.testing_staticText,'FontSize',femme);
otherwise
end
set(handles.age, 'string');
guidata(hObject,handles);
% Hints: contents = get(hObject,'String') returns sexe contents as cell array
% contents{get(hObject,'Value')} returns selected item from sexe
% --- Executes during object creation, after setting all properties.
function sexe_CreateFcn(hObject, eventdata, handles)
% hObject handle to sexe (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in age.
function age_Callback(hObject, eventdata, handles)
% hObject handle to age (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
switch get(handles.age,'Value')
case 1
set(handles.testing_staticText1,'FontSize',30);
case 2
set(handles.testing_staticText1,'FontSize',40);
case 3
set(handles.testing_staticText1,'FontSize',50);
case 4
set(handles.testing_staticText1,'FontSize',60);
case 5
set(handles.testing_staticText1,'FontSize',70);
case 6
set(handles.testing_staticText1,'FontSize',80);
case 7
set(handles.testing_staticText1,'FontSize',90);
otherwise
end
set(handles.age, 'string');
guidata(hObject,handles);
% Hints: contents = get(hObject,'String') returns age contents as cell array
% contents{get(hObject,'Value')} returns selected item from age
% --- 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 pertes.
function pertes_Callback(hObject, eventdata, handles)
% hObject handle to pertes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
sexe_list = get(handles.sexe, 'String');
a = sexe_list{get(handles.sexe, 'Value')};
age_list = get(handles.age, 'String');
b = age_list{get(handles.age, 'Value')};
switch a
case 'homme'
coef=[0.003 0.003 0.0035 0.004 0.0055 0.007 0.0115 0.016 0.018 0.022];%%%ce sont les coefficients
pertes=coef.*(b-18)^2;
p=polyfit(freq,pertes,4);
f=polyval(p,freq);
plot(freq,pertes,'o') ; title (' Approximation des pertes auditives chez l homme ');
xlabel (' frequence(KHz) ') ;ylabel ('pertes auditives (dB) ') ;hold on;plot(freq,f), grid on;
case 'femme'
coef=[0.003 0.003 0.0035 0.004 0.005 0.006 0.0075 0.009 0.012 0.015];
pertes=coef.*(b-18)^2;
p=polyfit(freq,pertes,6);
f=polyval(p,freq);
plot(freq,pertes,'o'); title (' Approximation des pertes auditives chez la femme');
xlabel (' frequence(KHz) '),ylabel ('pertes auditives (dB) ' ) ;hold on;plot(freq,f), grid on ;
end
guidata(hObject,handles); |
Partager