Advertisement
MarouaneTheViper

Untitled

May 13th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.22 KB | None | 0 0
  1. function varargout = DSP_Equalizer(varargin)
  2. % DSP_EQUALIZER MATLAB code for DSP_Equalizer.fig
  3. % DSP_EQUALIZER, by itself, creates a new DSP_EQUALIZER or raises the existing
  4. % singleton*.
  5. %
  6. % H = DSP_EQUALIZER returns the handle to a new DSP_EQUALIZER or the handle to
  7. % the existing singleton*.
  8. %
  9. % DSP_EQUALIZER('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in DSP_EQUALIZER.M with the given input arguments.
  11. %
  12. % DSP_EQUALIZER('Property','Value',...) creates a new DSP_EQUALIZER or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before DSP_Equalizer_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to DSP_Equalizer_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help DSP_Equalizer
  24.  
  25. % Last Modified by GUIDE v2.5 13-May-2019 22:10:28
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name', mfilename, ...
  30. 'gui_Singleton', gui_Singleton, ...
  31. 'gui_OpeningFcn', @DSP_Equalizer_OpeningFcn, ...
  32. 'gui_OutputFcn', @DSP_Equalizer_OutputFcn, ...
  33. 'gui_LayoutFcn', [] , ...
  34. 'gui_Callback', []);
  35. if nargin && ischar(varargin{1})
  36. gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42. gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before DSP_Equalizer is made visible.
  48. function DSP_Equalizer_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject handle to figure
  51. % eventdata reserved - to be defined in a future version of MATLAB
  52. % handles structure with handles and user data (see GUIDATA)
  53. % varargin command line arguments to DSP_Equalizer (see VARARGIN)
  54.  
  55. % Choose default command line output for DSP_Equalizer
  56. global C Fs;
  57.  
  58. Fs=str2double(get(handles.samplefreq,'string'));
  59. if isempty(Fs)
  60. Fs = 40000;
  61. set(handles.samplefreq,'string',40000)
  62. end
  63. C=zeros(1,9);
  64. set(handles.slider1,'min',-25);
  65. set(handles.slider1,'max',25);
  66. set(handles.slider1,'value',0);
  67. set(handles.slider1,'SliderStep',[0.025,0.05]);
  68. set(handles.slider1,'string',num2str(0));
  69.  
  70. set(handles.slider2,'min',-25);
  71. set(handles.slider2,'max',25);
  72. set(handles.slider2,'value',0);
  73. set(handles.slider2,'SliderStep',[0.025,0.05]);
  74. set(handles.slider2,'string',num2str(0));
  75.  
  76. set(handles.slider3,'min',-25);
  77. set(handles.slider3,'max',25);
  78. set(handles.slider3,'value',0);
  79. set(handles.slider3,'SliderStep',[0.025,0.05]);
  80. set(handles.slider3,'string',num2str(0));
  81.  
  82. set(handles.slider4,'min',-25);
  83. set(handles.slider4,'max',25);
  84. set(handles.slider4,'value',0);
  85. set(handles.slider4,'SliderStep',[0.025,0.05]);
  86. set(handles.slider4,'string',num2str(0));
  87.  
  88. set(handles.slider5,'min',-25);
  89. set(handles.slider5,'max',25);
  90. set(handles.slider5,'value',0);
  91. set(handles.slider5,'SliderStep',[0.025,0.05]);
  92. set(handles.slider5,'string',num2str(0));
  93.  
  94. set(handles.slider6,'min',-25);
  95. set(handles.slider6,'max',25);
  96. set(handles.slider6,'value',0);
  97. set(handles.slider6,'SliderStep',[0.025,0.05]);
  98. set(handles.slider6,'string',num2str(0));
  99.  
  100. set(handles.slider7,'min',-25);
  101. set(handles.slider7,'max',25);
  102. set(handles.slider7,'value',0);
  103. set(handles.slider7,'SliderStep',[0.025,0.05]);
  104. set(handles.slider7,'string',num2str(0));
  105.  
  106. set(handles.slider8,'min',-25);
  107. set(handles.slider8,'max',25);
  108. set(handles.slider8,'value',0);
  109. set(handles.slider8,'SliderStep',[0.025,0.05]);
  110. set(handles.slider8,'string',num2str(0));
  111.  
  112. set(handles.slider9,'min',-25);
  113. set(handles.slider9,'max',25);
  114. set(handles.slider9,'value',0);
  115. set(handles.slider9,'SliderStep',[0.025,0.05]);
  116. set(handles.slider9,'string',num2str(0));
  117.  
  118. set(handles.gain1,'enable','off')
  119. set(handles.gain2,'enable','off')
  120. set(handles.gain3,'enable','off')
  121. set(handles.gain4,'enable','off')
  122. set(handles.gain5,'enable','off')
  123. set(handles.gain6,'enable','off')
  124. set(handles.gain7,'enable','off')
  125. set(handles.gain8,'enable','off')
  126. set(handles.gain9,'enable','off')
  127. set(handles.gain1,'string','1')
  128. set(handles.gain2,'string','1')
  129. set(handles.gain3,'string','1')
  130. set(handles.gain4,'string','1')
  131. set(handles.gain5,'string','1')
  132. set(handles.gain6,'string','1')
  133. set(handles.gain7,'string','1')
  134. set(handles.gain8,'string','1')
  135. set(handles.gain9,'string','1')
  136.  
  137. set(handles.pop1,'enable','off')
  138. set(handles.playinputbutton,'enable','off')
  139. set(handles.playoutputbutton,'enable','off')
  140. set(handles.savebutton,'enable','off')
  141. set(handles.inputplotbutton,'enable','off')
  142. set(handles.outputplotbutton,'enable','off')
  143. set(handles.analyzebutton,'enable','off')
  144. set(handles.samplefreq,'enable','off')
  145. axes(handles.inputplot_time);
  146. title('Input: Time Domain');
  147. grid on;
  148. axes(handles.inputplot_freq);
  149. title('Input: Frequency Domain');
  150. grid on;
  151. axes(handles.outputplot_time);
  152. title('Output: Time Domain');
  153. grid on;
  154. axes(handles.outputplot_freq);
  155. title('Output: Frequency Domain');
  156. grid on;
  157.  
  158. handles.output = hObject;
  159.  
  160. % Update handles structure
  161. guidata(hObject, handles);
  162.  
  163. % UIWAIT makes DSP_Equalizer wait for user response (see UIRESUME)
  164. % uiwait(handles.figure1);
  165.  
  166.  
  167. % --- Outputs from this function are returned to the command line.
  168. function varargout = DSP_Equalizer_OutputFcn(hObject, eventdata, handles)
  169. % varargout cell array for returning output args (see VARARGOUT);
  170. % hObject handle to figure
  171. % eventdata reserved - to be defined in a future version of MATLAB
  172. % handles structure with handles and user data (see GUIDATA)
  173.  
  174. % Get default command line output from handles structure
  175. varargout{1} = handles.output;
  176.  
  177.  
  178. % --- Executes on slider movement.
  179. function slider1_Callback(hObject, eventdata, handles)
  180. % hObject handle to slider1 (see GCBO)
  181. % eventdata reserved - to be defined in a future version of MATLAB
  182. % handles structure with handles and user data (see GUIDATA)
  183.  
  184. % Hints: get(hObject,'Value') returns position of slider
  185. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  186. global C;
  187. C(1)=get(hObject,'value');
  188. set(handles.gain1,'string',num2str(C(1)));
  189.  
  190.  
  191.  
  192. % --- Executes during object creation, after setting all properties.
  193. function slider1_CreateFcn(hObject, eventdata, handles)
  194. % hObject handle to slider1 (see GCBO)
  195. % eventdata reserved - to be defined in a future version of MATLAB
  196. % handles empty - handles not created until after all CreateFcns called
  197.  
  198. % Hint: slider controls usually have a light gray background.
  199. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  200. set(hObject,'BackgroundColor',[.9 .9 .9]);
  201. end
  202.  
  203.  
  204. % --- Executes on slider movement.
  205. function slider2_Callback(hObject, eventdata, handles)
  206. % hObject handle to slider2 (see GCBO)
  207. % eventdata reserved - to be defined in a future version of MATLAB
  208. % handles structure with handles and user data (see GUIDATA)
  209.  
  210. % Hints: get(hObject,'Value') returns position of slider
  211. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  212. global C;
  213. C(2)=get(hObject,'value');
  214. set(handles.gain2,'string',num2str(C(2)));
  215.  
  216.  
  217. % --- Executes during object creation, after setting all properties.
  218. function slider2_CreateFcn(hObject, eventdata, handles)
  219. % hObject handle to slider2 (see GCBO)
  220. % eventdata reserved - to be defined in a future version of MATLAB
  221. % handles empty - handles not created until after all CreateFcns called
  222.  
  223. % Hint: slider controls usually have a light gray background.
  224. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  225. set(hObject,'BackgroundColor',[.9 .9 .9]);
  226. end
  227.  
  228.  
  229. % --- Executes on slider movement.
  230. function slider3_Callback(hObject, eventdata, handles)
  231. % hObject handle to slider3 (see GCBO)
  232. % eventdata reserved - to be defined in a future version of MATLAB
  233. % handles structure with handles and user data (see GUIDATA)
  234.  
  235. % Hints: get(hObject,'Value') returns position of slider
  236. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  237. global C;
  238. C(3)=get(hObject,'value');
  239. set(handles.gain3,'string',num2str(C(3)));
  240.  
  241.  
  242. % --- Executes during object creation, after setting all properties.
  243. function slider3_CreateFcn(hObject, eventdata, handles)
  244. % hObject handle to slider3 (see GCBO)
  245. % eventdata reserved - to be defined in a future version of MATLAB
  246. % handles empty - handles not created until after all CreateFcns called
  247.  
  248. % Hint: slider controls usually have a light gray background.
  249. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  250. set(hObject,'BackgroundColor',[.9 .9 .9]);
  251. end
  252.  
  253.  
  254. % --- Executes on slider movement.
  255. function slider4_Callback(hObject, eventdata, handles)
  256. % hObject handle to slider4 (see GCBO)
  257. % eventdata reserved - to be defined in a future version of MATLAB
  258. % handles structure with handles and user data (see GUIDATA)
  259.  
  260. % Hints: get(hObject,'Value') returns position of slider
  261. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  262. global C;
  263. C(4)=get(hObject,'value');
  264. set(handles.gain4,'string',num2str(C(4)));
  265.  
  266.  
  267. % --- Executes during object creation, after setting all properties.
  268. function slider4_CreateFcn(hObject, eventdata, handles)
  269. % hObject handle to slider4 (see GCBO)
  270. % eventdata reserved - to be defined in a future version of MATLAB
  271. % handles empty - handles not created until after all CreateFcns called
  272.  
  273. % Hint: slider controls usually have a light gray background.
  274. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  275. set(hObject,'BackgroundColor',[.9 .9 .9]);
  276. end
  277.  
  278.  
  279. % --- Executes on slider movement.
  280. function slider5_Callback(hObject, eventdata, handles)
  281. % hObject handle to slider5 (see GCBO)
  282. % eventdata reserved - to be defined in a future version of MATLAB
  283. % handles structure with handles and user data (see GUIDATA)
  284.  
  285. % Hints: get(hObject,'Value') returns position of slider
  286. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  287. global C;
  288. C(5)=get(hObject,'value');
  289. set(handles.gain5,'string',num2str(C(5)));
  290.  
  291.  
  292. % --- Executes during object creation, after setting all properties.
  293. function slider5_CreateFcn(hObject, eventdata, handles)
  294. % hObject handle to slider5 (see GCBO)
  295. % eventdata reserved - to be defined in a future version of MATLAB
  296. % handles empty - handles not created until after all CreateFcns called
  297.  
  298. % Hint: slider controls usually have a light gray background.
  299. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  300. set(hObject,'BackgroundColor',[.9 .9 .9]);
  301. end
  302.  
  303.  
  304. % --- Executes on slider movement.
  305. function slider6_Callback(hObject, eventdata, handles)
  306. % hObject handle to slider6 (see GCBO)
  307. % eventdata reserved - to be defined in a future version of MATLAB
  308. % handles structure with handles and user data (see GUIDATA)
  309.  
  310. % Hints: get(hObject,'Value') returns position of slider
  311. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  312. global C;
  313. C(6)=get(hObject,'value');
  314. set(handles.gain6,'string',num2str(C(6)));
  315.  
  316.  
  317. % --- Executes during object creation, after setting all properties.
  318. function slider6_CreateFcn(hObject, eventdata, handles)
  319. % hObject handle to slider6 (see GCBO)
  320. % eventdata reserved - to be defined in a future version of MATLAB
  321. % handles empty - handles not created until after all CreateFcns called
  322.  
  323. % Hint: slider controls usually have a light gray background.
  324. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  325. set(hObject,'BackgroundColor',[.9 .9 .9]);
  326. end
  327.  
  328.  
  329. % --- Executes on slider movement.
  330. function slider7_Callback(hObject, eventdata, handles)
  331. % hObject handle to slider7 (see GCBO)
  332. % eventdata reserved - to be defined in a future version of MATLAB
  333. % handles structure with handles and user data (see GUIDATA)
  334.  
  335. % Hints: get(hObject,'Value') returns position of slider
  336. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  337. global C;
  338. C(7)=get(hObject,'value');
  339. set(handles.gain7,'string',num2str(C(7)));
  340.  
  341.  
  342. % --- Executes during object creation, after setting all properties.
  343. function slider7_CreateFcn(hObject, eventdata, handles)
  344. % hObject handle to slider7 (see GCBO)
  345. % eventdata reserved - to be defined in a future version of MATLAB
  346. % handles empty - handles not created until after all CreateFcns called
  347.  
  348. % Hint: slider controls usually have a light gray background.
  349. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  350. set(hObject,'BackgroundColor',[.9 .9 .9]);
  351. end
  352.  
  353.  
  354. % --- Executes on slider movement.
  355. function slider8_Callback(hObject, eventdata, handles)
  356. % hObject handle to slider8 (see GCBO)
  357. % eventdata reserved - to be defined in a future version of MATLAB
  358. % handles structure with handles and user data (see GUIDATA)
  359.  
  360. % Hints: get(hObject,'Value') returns position of slider
  361. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  362. global C;
  363. C(8)=get(hObject,'value');
  364. set(handles.gain8,'string',num2str(C(8)));
  365.  
  366.  
  367. % --- Executes during object creation, after setting all properties.
  368. function slider8_CreateFcn(hObject, eventdata, handles)
  369. % hObject handle to slider8 (see GCBO)
  370. % eventdata reserved - to be defined in a future version of MATLAB
  371. % handles empty - handles not created until after all CreateFcns called
  372.  
  373. % Hint: slider controls usually have a light gray background.
  374. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  375. set(hObject,'BackgroundColor',[.9 .9 .9]);
  376. end
  377.  
  378.  
  379. % --- Executes on slider movement.
  380. function slider9_Callback(hObject, eventdata, handles)
  381. % hObject handle to slider9 (see GCBO)
  382. % eventdata reserved - to be defined in a future version of MATLAB
  383. % handles structure with handles and user data (see GUIDATA)
  384.  
  385. % Hints: get(hObject,'Value') returns position of slider
  386. % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  387. global C;
  388. C(9)=get(hObject,'value');
  389. set(handles.gain9,'string',num2str(C(9)));
  390.  
  391.  
  392. % --- Executes during object creation, after setting all properties.
  393. function slider9_CreateFcn(hObject, eventdata, handles)
  394. % hObject handle to slider9 (see GCBO)
  395. % eventdata reserved - to be defined in a future version of MATLAB
  396. % handles empty - handles not created until after all CreateFcns called
  397.  
  398. % Hint: slider controls usually have a light gray background.
  399. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  400. set(hObject,'BackgroundColor',[.9 .9 .9]);
  401. end
  402.  
  403.  
  404. % --- Executes on selection change in pop1.
  405. function pop1_Callback(hObject, eventdata, handles)
  406. % hObject handle to pop1 (see GCBO)
  407. % eventdata reserved - to be defined in a future version of MATLAB
  408. % handles structure with handles and user data (see GUIDATA)
  409.  
  410. % Hints: contents = cellstr(get(hObject,'String')) returns pop1 contents as cell array
  411. % contents{get(hObject,'Value')} returns selected item from pop1
  412.  
  413.  
  414. % --- Executes during object creation, after setting all properties.
  415. function pop1_CreateFcn(hObject, eventdata, handles)
  416. % hObject handle to pop1 (see GCBO)
  417. % eventdata reserved - to be defined in a future version of MATLAB
  418. % handles empty - handles not created until after all CreateFcns called
  419.  
  420. % Hint: popupmenu controls usually have a white background on Windows.
  421. % See ISPC and COMPUTER.
  422. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  423. set(hObject,'BackgroundColor','white');
  424. end
  425.  
  426.  
  427. % --- Executes on selection change in pop2.
  428. function pop2_Callback(hObject, eventdata, handles)
  429. % hObject handle to pop2 (see GCBO)
  430. % eventdata reserved - to be defined in a future version of MATLAB
  431. % handles structure with handles and user data (see GUIDATA)
  432.  
  433. % Hints: contents = cellstr(get(hObject,'String')) returns pop2 contents as cell array
  434. % contents{get(hObject,'Value')} returns selected item from pop2
  435.  
  436.  
  437. % --- Executes during object creation, after setting all properties.
  438. function pop2_CreateFcn(hObject, eventdata, handles)
  439. % hObject handle to pop2 (see GCBO)
  440. % eventdata reserved - to be defined in a future version of MATLAB
  441. % handles empty - handles not created until after all CreateFcns called
  442.  
  443. % Hint: popupmenu controls usually have a white background on Windows.
  444. % See ISPC and COMPUTER.
  445. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  446. set(hObject,'BackgroundColor','white');
  447. end
  448.  
  449.  
  450. % --- Executes on selection change in pop3.
  451. function pop3_Callback(hObject, eventdata, handles)
  452. % hObject handle to pop3 (see GCBO)
  453. % eventdata reserved - to be defined in a future version of MATLAB
  454. % handles structure with handles and user data (see GUIDATA)
  455.  
  456. % Hints: contents = cellstr(get(hObject,'String')) returns pop3 contents as cell array
  457. % contents{get(hObject,'Value')} returns selected item from pop3
  458.  
  459.  
  460. % --- Executes during object creation, after setting all properties.
  461. function pop3_CreateFcn(hObject, eventdata, handles)
  462. % hObject handle to pop3 (see GCBO)
  463. % eventdata reserved - to be defined in a future version of MATLAB
  464. % handles empty - handles not created until after all CreateFcns called
  465.  
  466. % Hint: popupmenu controls usually have a white background on Windows.
  467. % See ISPC and COMPUTER.
  468. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  469. set(hObject,'BackgroundColor','white');
  470. end
  471.  
  472.  
  473. % --- Executes on selection change in pop4.
  474. function pop4_Callback(hObject, eventdata, handles)
  475. % hObject handle to pop4 (see GCBO)
  476. % eventdata reserved - to be defined in a future version of MATLAB
  477. % handles structure with handles and user data (see GUIDATA)
  478.  
  479. % Hints: contents = cellstr(get(hObject,'String')) returns pop4 contents as cell array
  480. % contents{get(hObject,'Value')} returns selected item from pop4
  481.  
  482.  
  483. % --- Executes during object creation, after setting all properties.
  484. function pop4_CreateFcn(hObject, eventdata, handles)
  485. % hObject handle to pop4 (see GCBO)
  486. % eventdata reserved - to be defined in a future version of MATLAB
  487. % handles empty - handles not created until after all CreateFcns called
  488.  
  489. % Hint: popupmenu controls usually have a white background on Windows.
  490. % See ISPC and COMPUTER.
  491. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  492. set(hObject,'BackgroundColor','white');
  493. end
  494.  
  495.  
  496. % --- Executes on selection change in pop5.
  497. function pop5_Callback(hObject, eventdata, handles)
  498. % hObject handle to pop5 (see GCBO)
  499. % eventdata reserved - to be defined in a future version of MATLAB
  500. % handles structure with handles and user data (see GUIDATA)
  501.  
  502. % Hints: contents = cellstr(get(hObject,'String')) returns pop5 contents as cell array
  503. % contents{get(hObject,'Value')} returns selected item from pop5
  504.  
  505.  
  506. % --- Executes during object creation, after setting all properties.
  507. function pop5_CreateFcn(hObject, eventdata, handles)
  508. % hObject handle to pop5 (see GCBO)
  509. % eventdata reserved - to be defined in a future version of MATLAB
  510. % handles empty - handles not created until after all CreateFcns called
  511.  
  512. % Hint: popupmenu controls usually have a white background on Windows.
  513. % See ISPC and COMPUTER.
  514. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  515. set(hObject,'BackgroundColor','white');
  516. end
  517.  
  518.  
  519. % --- Executes on selection change in pop6.
  520. function pop6_Callback(hObject, eventdata, handles)
  521. % hObject handle to pop6 (see GCBO)
  522. % eventdata reserved - to be defined in a future version of MATLAB
  523. % handles structure with handles and user data (see GUIDATA)
  524.  
  525. % Hints: contents = cellstr(get(hObject,'String')) returns pop6 contents as cell array
  526. % contents{get(hObject,'Value')} returns selected item from pop6
  527.  
  528.  
  529. % --- Executes during object creation, after setting all properties.
  530. function pop6_CreateFcn(hObject, eventdata, handles)
  531. % hObject handle to pop6 (see GCBO)
  532. % eventdata reserved - to be defined in a future version of MATLAB
  533. % handles empty - handles not created until after all CreateFcns called
  534.  
  535. % Hint: popupmenu controls usually have a white background on Windows.
  536. % See ISPC and COMPUTER.
  537. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  538. set(hObject,'BackgroundColor','white');
  539. end
  540.  
  541.  
  542. % --- Executes on selection change in pop7.
  543. function pop7_Callback(hObject, eventdata, handles)
  544. % hObject handle to pop7 (see GCBO)
  545. % eventdata reserved - to be defined in a future version of MATLAB
  546. % handles structure with handles and user data (see GUIDATA)
  547.  
  548. % Hints: contents = cellstr(get(hObject,'String')) returns pop7 contents as cell array
  549. % contents{get(hObject,'Value')} returns selected item from pop7
  550.  
  551.  
  552. % --- Executes during object creation, after setting all properties.
  553. function pop7_CreateFcn(hObject, eventdata, handles)
  554. % hObject handle to pop7 (see GCBO)
  555. % eventdata reserved - to be defined in a future version of MATLAB
  556. % handles empty - handles not created until after all CreateFcns called
  557.  
  558. % Hint: popupmenu controls usually have a white background on Windows.
  559. % See ISPC and COMPUTER.
  560. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  561. set(hObject,'BackgroundColor','white');
  562. end
  563.  
  564.  
  565. % --- Executes on selection change in pop8.
  566. function pop8_Callback(hObject, eventdata, handles)
  567. % hObject handle to pop8 (see GCBO)
  568. % eventdata reserved - to be defined in a future version of MATLAB
  569. % handles structure with handles and user data (see GUIDATA)
  570.  
  571. % Hints: contents = cellstr(get(hObject,'String')) returns pop8 contents as cell array
  572. % contents{get(hObject,'Value')} returns selected item from pop8
  573.  
  574.  
  575. % --- Executes during object creation, after setting all properties.
  576. function pop8_CreateFcn(hObject, eventdata, handles)
  577. % hObject handle to pop8 (see GCBO)
  578. % eventdata reserved - to be defined in a future version of MATLAB
  579. % handles empty - handles not created until after all CreateFcns called
  580.  
  581. % Hint: popupmenu controls usually have a white background on Windows.
  582. % See ISPC and COMPUTER.
  583. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  584. set(hObject,'BackgroundColor','white');
  585. end
  586.  
  587.  
  588. % --- Executes on selection change in pop9.
  589. function pop9_Callback(hObject, eventdata, handles)
  590. % hObject handle to pop9 (see GCBO)
  591. % eventdata reserved - to be defined in a future version of MATLAB
  592. % handles structure with handles and user data (see GUIDATA)
  593.  
  594. % Hints: contents = cellstr(get(hObject,'String')) returns pop9 contents as cell array
  595. % contents{get(hObject,'Value')} returns selected item from pop9
  596.  
  597.  
  598. % --- Executes during object creation, after setting all properties.
  599. function pop9_CreateFcn(hObject, eventdata, handles)
  600. % hObject handle to pop9 (see GCBO)
  601. % eventdata reserved - to be defined in a future version of MATLAB
  602. % handles empty - handles not created until after all CreateFcns called
  603.  
  604. % Hint: popupmenu controls usually have a white background on Windows.
  605. % See ISPC and COMPUTER.
  606. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  607. set(hObject,'BackgroundColor','white');
  608. end
  609.  
  610.  
  611. % --- Executes on button press in loadbutton.
  612. function loadbutton_Callback(hObject, eventdata, handles)
  613. % hObject handle to loadbutton (see GCBO)
  614. % eventdata reserved - to be defined in a future version of MATLAB
  615. % handles structure with handles and user data (see GUIDATA)
  616. global file_name;
  617. [filename, pathname] = uigetfile('*wav','Load a .wav file');
  618. file_name = strcat(pathname,filename)
  619. Nowplaying = strcat('Now Playing: ',filename)
  620. if ~isempty(file_name)
  621. set(handles.gain1,'enable','on')
  622. set(handles.gain2,'enable','on')
  623. set(handles.gain3,'enable','on')
  624. set(handles.gain4,'enable','on')
  625. set(handles.gain5,'enable','on')
  626. set(handles.gain6,'enable','on')
  627. set(handles.gain7,'enable','on')
  628. set(handles.gain8,'enable','on')
  629. set(handles.gain9,'enable','on')
  630. set(handles.pop1,'enable','on')
  631. set(handles.playinputbutton,'enable','on')
  632. set(handles.playoutputbutton,'enable','on')
  633. set(handles.savebutton,'enable','on')
  634. set(handles.inputplotbutton,'enable','on')
  635. set(handles.outputplotbutton,'enable','on')
  636. set(handles.analyzebutton,'enable','on')
  637. set(handles.samplefreq,'enable','on')
  638. set(handles.filename,'string',Nowplaying)
  639. end
  640.  
  641.  
  642.  
  643. % --- Executes on button press in playinputbutton.
  644. function playinputbutton_Callback(hObject, eventdata, handles)
  645. % hObject handle to playinputbutton (see GCBO)
  646. % eventdata reserved - to be defined in a future version of MATLAB
  647. % handles structure with handles and user data (see GUIDATA)
  648. global file_name;
  649. [y,Fs]=audioread(file_name);
  650. sound(y,Fs);
  651.  
  652. % --- Executes on button press in inputplotbutton.
  653. function inputplotbutton_Callback(hObject, eventdata, handles)
  654. % hObject handle to inputplotbutton (see GCBO)
  655. % eventdata reserved - to be defined in a future version of MATLAB
  656. % handles structure with handles and user data (see GUIDATA)
  657. global file_name;
  658. [y,Fs]=audioread(file_name);
  659. y = y(:,1);
  660. s_length = length(y);
  661. frameSize = fix(y*0.001*Fs);
  662. dt = 1/Fs;
  663. t = 0:dt:(length(y)*dt)-dt;
  664. axes(handles.inputplot_time);
  665. plot(t,y);
  666. grid on;
  667. xlabel('Seconds');
  668. ylabel('Amplitude');
  669. axes(handles.inputplot_freq);
  670. plot(psd(spectrum.periodogram,y,'Fs',Fs,'NFFT',length(y)));
  671.  
  672. % --- Executes on button press in outputplotbutton.
  673. function outputplotbutton_Callback(hObject, eventdata, handles)
  674. % hObject handle to outputplotbutton (see GCBO)
  675. % eventdata reserved - to be defined in a future version of MATLAB
  676. % handles structure with handles and user data (see GUIDATA)
  677. global file_name C;
  678. [x,Fs]=audioread(file_name);
  679. dt = 1/Fs;
  680. allItems = handles.pop1.String; % A cell array of all strings in the popup.
  681. selectedIndex = handles.pop1.Value; % An integer saying which item has been selected.
  682. selectedfilter = allItems{selectedIndex};
  683. if strcmp(selectedfilter, 'IIR') == 1
  684. [a,b]=coef();
  685. foo=2*Fs;
  686. Nb=round(length(x)/foo);
  687. y=0;
  688. for i=1:floor(Nb)
  689. part=x((i-1)*foo+1:i*foo);
  690. for k=1:9
  691. y=[y filter(C(k)*b{k},a{k},part)];
  692. end
  693. t = 0:dt:(length(y)*dt)-dt;
  694. axes(handles.outputplot_time);
  695. plot(t,y);
  696. grid on;
  697. xlabel('Seconds');
  698. ylabel('Amplitude');
  699. axes(handles.outputplot_freq);
  700. plot(psd(spectrum.periodogram,y,'Fs',Fs,'NFFT',length(y)));
  701. y=0;
  702. grid on;
  703. end
  704. end
  705.  
  706. function [a,b]=coef()
  707. global Fs;
  708. %Filter 1
  709. Rp1 = 0.5;
  710. Rs1 = 30;
  711. Fp1 = 170/(Fs/2)
  712. Fs1 = 200/(Fs/2)
  713. n1 = cheb1ord(Fp1,Fs1,Rp1,Rs1);
  714. [b1,a1] = cheby1(n1,Rp1,Fp1,'low');
  715. %Filter 2
  716. Rp2=0.5;
  717. Rs2=30;
  718. Fp2=[170,310]/(Fs/2);
  719. Fs2=[100,390]/(Fs/2);
  720. n2=cheb1ord(Fp2,Fs2,Rp2,Rs2);
  721. [b2,a2]=cheby1(n2,Rp2,Fp2);
  722. %Filter 3
  723. Rp3=0.5;
  724. Rs3=30;
  725. Fp3=[310,600]/(Fs/2);
  726. Fs3=[250,640]/(Fs/2);
  727. n3=cheb2ord(Fp3,Fs3,Rp3,Rs3);
  728. [b3,a3]=cheby2(n3,Rp3,Fp3);
  729. %Filter 4
  730. Rp4=0.5;
  731. Rs4=30;
  732. Fp4=[600,1000]/(Fs/2);
  733. Fs4=[400,1100]/(Fs/2);
  734. n4=cheb2ord(Fp4,Fs4,Rp4,Rs4);
  735. [b4,a4]=cheby2(n4,Rp4,Fp4);
  736. %Filter 5
  737. Rp5=0.5;
  738. Rs5=30;
  739. Fp5=[1000,3000]/(Fs/2);
  740. Fs5=[800,3200]/(Fs/2);
  741. n5=cheb2ord(Fp5,Fs5,Rp5,Rs5);
  742. [b5,a5]=cheby2(n5,Rp5,Fp5);
  743. %Filter 6
  744. Rp6=0.5;
  745. Rs6=30;
  746. Fp6=[3000,6000]/(Fs/2);
  747. Fs6=[2960,6040]/(Fs/2);
  748. n6=cheb2ord(Fp6,Fs6,Rp6,Rs6);
  749. [b6,a6]=cheby2(n6,Rp6,Fp6);
  750. %Filter 7
  751. Rp7=0.5;
  752. Rs7=30;
  753. Fp7=[6000,12000]/(Fs/2);
  754. Fs7=[5500,12500]/(Fs/2);
  755. n7=cheb2ord(Fp7,Fs7,Rp7,Rs7);
  756. [b7,a7]=cheby2(n7,Rp7,Fp7);
  757. %Filter 8
  758. Rp8=0.5;
  759. Rs8=30;
  760. Fp8=[12000,14000]/(Fs/2);
  761. Fs8=[10000,17000]/(Fs/2);
  762. n8=cheb2ord(Fp8,Fs8,Rp8,Rs8);
  763. [b8,a8]=cheby2(n8,Rp8,Fp8);
  764. %Filter 9
  765. Rp9=0.5;
  766. Rs9=30;
  767. Fp9=16000/(Fs/2);
  768. Fs9=16500/(Fs/2);
  769. n9=cheb2ord(Fp9,Fs9,Rp9,Rs9);
  770. [b9,a9]=cheby2(n9,Rp9,Fp9,'high');
  771.  
  772. a = {a1,a2,a3,a4,a5,a6,a7,a8,a9};
  773. b = {b1,b2,b3,b4,b5,b6,b7,b8,b9};
  774.  
  775.  
  776. % --- Executes on button press in savebutton.
  777. function savebutton_Callback(hObject, eventdata, handles)
  778. % hObject handle to savebutton (see GCBO)
  779. % eventdata reserved - to be defined in a future version of MATLAB
  780. % handles structure with handles and user data (see GUIDATA)
  781.  
  782.  
  783. % --- Executes on button press in analyzebutton.
  784. function analyzebutton_Callback(hObject, eventdata, handles)
  785. % hObject handle to analyzebutton (see GCBO)
  786. % eventdata reserved - to be defined in a future version of MATLAB
  787. % handles structure with handles and user data (see GUIDATA)
  788.  
  789.  
  790. % --- Executes on button press in playoutputbutton.
  791. function playoutputbutton_Callback(hObject, eventdata, handles)
  792. % hObject handle to playoutputbutton (see GCBO)
  793. % eventdata reserved - to be defined in a future version of MATLAB
  794. % handles structure with handles and user data (see GUIDATA)
  795. global file_name C;
  796. [x,Fs]=audioread(file_name);
  797. allItems = handles.pop1.String; % A cell array of all strings in the popup.
  798. selectedIndex = handles.pop1.Value; % An integer saying which item has been selected.
  799. selectedfilter = allItems{selectedIndex};
  800. if strcmp(selectedfilter, 'IIR') == 1
  801. [a,b]=coef();
  802. foo=2*Fs;
  803. Nb=round(length(x)/foo);
  804. y=0;
  805. for i=1:floor(Nb)
  806. part=x((i-1)*foo+1:i*foo);
  807. for k=1:9
  808. y=y+filter(C(k)*b{k},a{k},part);
  809. end
  810. sound(y,Fs);
  811. y=0;
  812. end
  813. end
  814.  
  815.  
  816.  
  817.  
  818. function samplefreq_Callback(hObject, eventdata, handles)
  819. % hObject handle to samplefreq (see GCBO)
  820. % eventdata reserved - to be defined in a future version of MATLAB
  821. % handles structure with handles and user data (see GUIDATA)
  822.  
  823. % Hints: get(hObject,'String') returns contents of samplefreq as text
  824. % str2double(get(hObject,'String')) returns contents of samplefreq as a double
  825.  
  826.  
  827. % --- Executes during object creation, after setting all properties.
  828. function samplefreq_CreateFcn(hObject, eventdata, handles)
  829. % hObject handle to samplefreq (see GCBO)
  830. % eventdata reserved - to be defined in a future version of MATLAB
  831. % handles empty - handles not created until after all CreateFcns called
  832.  
  833. % Hint: edit controls usually have a white background on Windows.
  834. % See ISPC and COMPUTER.
  835. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  836. set(hObject,'BackgroundColor','white');
  837. end
  838.  
  839.  
  840.  
  841. function gain1_Callback(hObject, eventdata, handles)
  842. % hObject handle to gain1 (see GCBO)
  843. % eventdata reserved - to be defined in a future version of MATLAB
  844. % handles structure with handles and user data (see GUIDATA)
  845.  
  846. % Hints: get(hObject,'String') returns contents of gain1 as text
  847. % str2double(get(hObject,'String')) returns contents of gain1 as a double
  848.  
  849.  
  850. % --- Executes during object creation, after setting all properties.
  851. function gain1_CreateFcn(hObject, eventdata, handles)
  852. % hObject handle to gain1 (see GCBO)
  853. % eventdata reserved - to be defined in a future version of MATLAB
  854. % handles empty - handles not created until after all CreateFcns called
  855.  
  856. % Hint: edit controls usually have a white background on Windows.
  857. % See ISPC and COMPUTER.
  858. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  859. set(hObject,'BackgroundColor','white');
  860. end
  861.  
  862.  
  863.  
  864. function gain2_Callback(hObject, eventdata, handles)
  865. % hObject handle to gain2 (see GCBO)
  866. % eventdata reserved - to be defined in a future version of MATLAB
  867. % handles structure with handles and user data (see GUIDATA)
  868.  
  869. % Hints: get(hObject,'String') returns contents of gain2 as text
  870. % str2double(get(hObject,'String')) returns contents of gain2 as a double
  871.  
  872.  
  873. % --- Executes during object creation, after setting all properties.
  874. function gain2_CreateFcn(hObject, eventdata, handles)
  875. % hObject handle to gain2 (see GCBO)
  876. % eventdata reserved - to be defined in a future version of MATLAB
  877. % handles empty - handles not created until after all CreateFcns called
  878.  
  879. % Hint: edit controls usually have a white background on Windows.
  880. % See ISPC and COMPUTER.
  881. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  882. set(hObject,'BackgroundColor','white');
  883. end
  884.  
  885.  
  886.  
  887. function gain3_Callback(hObject, eventdata, handles)
  888. % hObject handle to gain3 (see GCBO)
  889. % eventdata reserved - to be defined in a future version of MATLAB
  890. % handles structure with handles and user data (see GUIDATA)
  891.  
  892. % Hints: get(hObject,'String') returns contents of gain3 as text
  893. % str2double(get(hObject,'String')) returns contents of gain3 as a double
  894.  
  895.  
  896. % --- Executes during object creation, after setting all properties.
  897. function gain3_CreateFcn(hObject, eventdata, handles)
  898. % hObject handle to gain3 (see GCBO)
  899. % eventdata reserved - to be defined in a future version of MATLAB
  900. % handles empty - handles not created until after all CreateFcns called
  901.  
  902. % Hint: edit controls usually have a white background on Windows.
  903. % See ISPC and COMPUTER.
  904. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  905. set(hObject,'BackgroundColor','white');
  906. end
  907.  
  908.  
  909.  
  910. function gain4_Callback(hObject, eventdata, handles)
  911. % hObject handle to gain4 (see GCBO)
  912. % eventdata reserved - to be defined in a future version of MATLAB
  913. % handles structure with handles and user data (see GUIDATA)
  914.  
  915. % Hints: get(hObject,'String') returns contents of gain4 as text
  916. % str2double(get(hObject,'String')) returns contents of gain4 as a double
  917.  
  918.  
  919. % --- Executes during object creation, after setting all properties.
  920. function gain4_CreateFcn(hObject, eventdata, handles)
  921. % hObject handle to gain4 (see GCBO)
  922. % eventdata reserved - to be defined in a future version of MATLAB
  923. % handles empty - handles not created until after all CreateFcns called
  924.  
  925. % Hint: edit controls usually have a white background on Windows.
  926. % See ISPC and COMPUTER.
  927. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  928. set(hObject,'BackgroundColor','white');
  929. end
  930.  
  931.  
  932.  
  933. function gain5_Callback(hObject, eventdata, handles)
  934. % hObject handle to gain5 (see GCBO)
  935. % eventdata reserved - to be defined in a future version of MATLAB
  936. % handles structure with handles and user data (see GUIDATA)
  937.  
  938. % Hints: get(hObject,'String') returns contents of gain5 as text
  939. % str2double(get(hObject,'String')) returns contents of gain5 as a double
  940.  
  941.  
  942. % --- Executes during object creation, after setting all properties.
  943. function gain5_CreateFcn(hObject, eventdata, handles)
  944. % hObject handle to gain5 (see GCBO)
  945. % eventdata reserved - to be defined in a future version of MATLAB
  946. % handles empty - handles not created until after all CreateFcns called
  947.  
  948. % Hint: edit controls usually have a white background on Windows.
  949. % See ISPC and COMPUTER.
  950. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  951. set(hObject,'BackgroundColor','white');
  952. end
  953.  
  954.  
  955.  
  956. function gain6_Callback(hObject, eventdata, handles)
  957. % hObject handle to gain6 (see GCBO)
  958. % eventdata reserved - to be defined in a future version of MATLAB
  959. % handles structure with handles and user data (see GUIDATA)
  960.  
  961. % Hints: get(hObject,'String') returns contents of gain6 as text
  962. % str2double(get(hObject,'String')) returns contents of gain6 as a double
  963.  
  964.  
  965. % --- Executes during object creation, after setting all properties.
  966. function gain6_CreateFcn(hObject, eventdata, handles)
  967. % hObject handle to gain6 (see GCBO)
  968. % eventdata reserved - to be defined in a future version of MATLAB
  969. % handles empty - handles not created until after all CreateFcns called
  970.  
  971. % Hint: edit controls usually have a white background on Windows.
  972. % See ISPC and COMPUTER.
  973. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  974. set(hObject,'BackgroundColor','white');
  975. end
  976.  
  977.  
  978.  
  979. function gain7_Callback(hObject, eventdata, handles)
  980. % hObject handle to gain7 (see GCBO)
  981. % eventdata reserved - to be defined in a future version of MATLAB
  982. % handles structure with handles and user data (see GUIDATA)
  983.  
  984. % Hints: get(hObject,'String') returns contents of gain7 as text
  985. % str2double(get(hObject,'String')) returns contents of gain7 as a double
  986.  
  987.  
  988. % --- Executes during object creation, after setting all properties.
  989. function gain7_CreateFcn(hObject, eventdata, handles)
  990. % hObject handle to gain7 (see GCBO)
  991. % eventdata reserved - to be defined in a future version of MATLAB
  992. % handles empty - handles not created until after all CreateFcns called
  993.  
  994. % Hint: edit controls usually have a white background on Windows.
  995. % See ISPC and COMPUTER.
  996. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  997. set(hObject,'BackgroundColor','white');
  998. end
  999.  
  1000.  
  1001.  
  1002. function gain8_Callback(hObject, eventdata, handles)
  1003. % hObject handle to gain8 (see GCBO)
  1004. % eventdata reserved - to be defined in a future version of MATLAB
  1005. % handles structure with handles and user data (see GUIDATA)
  1006.  
  1007. % Hints: get(hObject,'String') returns contents of gain8 as text
  1008. % str2double(get(hObject,'String')) returns contents of gain8 as a double
  1009.  
  1010.  
  1011. % --- Executes during object creation, after setting all properties.
  1012. function gain8_CreateFcn(hObject, eventdata, handles)
  1013. % hObject handle to gain8 (see GCBO)
  1014. % eventdata reserved - to be defined in a future version of MATLAB
  1015. % handles empty - handles not created until after all CreateFcns called
  1016.  
  1017. % Hint: edit controls usually have a white background on Windows.
  1018. % See ISPC and COMPUTER.
  1019. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1020. set(hObject,'BackgroundColor','white');
  1021. end
  1022.  
  1023.  
  1024.  
  1025. function gain9_Callback(hObject, eventdata, handles)
  1026. % hObject handle to gain9 (see GCBO)
  1027. % eventdata reserved - to be defined in a future version of MATLAB
  1028. % handles structure with handles and user data (see GUIDATA)
  1029.  
  1030. % Hints: get(hObject,'String') returns contents of gain9 as text
  1031. % str2double(get(hObject,'String')) returns contents of gain9 as a double
  1032.  
  1033.  
  1034. % --- Executes during object creation, after setting all properties.
  1035. function gain9_CreateFcn(hObject, eventdata, handles)
  1036. % hObject handle to gain9 (see GCBO)
  1037. % eventdata reserved - to be defined in a future version of MATLAB
  1038. % handles empty - handles not created until after all CreateFcns called
  1039.  
  1040. % Hint: edit controls usually have a white background on Windows.
  1041. % See ISPC and COMPUTER.
  1042. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1043. set(hObject,'BackgroundColor','white');
  1044. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement