Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 15.13 KB | None | 0 0
  1. function varargout = GUI(varargin)
  2. % GUI MATLAB code for GUI.fig
  3. %      GUI, by itself, creates a new GUI or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = GUI returns the handle to a new GUI or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in GUI.M with the given input arguments.
  11. %
  12. %      GUI('Property','Value',...) creates a new GUI or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before GUI_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to GUI_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 GUI
  24.  
  25. % Last Modified by GUIDE v2.5 21-Nov-2017 11:38:35
  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', @GUI_OpeningFcn, ...
  32.                    'gui_OutputFcn',  @GUI_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 GUI is made visible.
  48. function GUI_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 GUI (see VARARGIN)
  54.  
  55. % Choose default command line output for GUI
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61. % UIWAIT makes GUI wait for user response (see UIRESUME)
  62. % uiwait(handles.figure1);
  63. set(handles.edit1, 'String', '0');
  64. set(handles.edit2, 'String', '0');
  65. set(handles.edit3, 'String', '0');
  66. % --- Outputs from this function are returned to the command line.
  67. function varargout = GUI_OutputFcn(hObject, eventdata, handles)
  68. % varargout  cell array for returning output args (see VARARGOUT);
  69. % hObject    handle to figure
  70. % eventdata  reserved - to be defined in a future version of MATLAB
  71. % handles    structure with handles and user data (see GUIDATA)
  72.  
  73. % Get default command line output from handles structure
  74. varargout{1} = handles.output;
  75.  
  76.  
  77. % --- Executes on selection change in popupmenu1.
  78. function popupmenu1_Callback(hObject, eventdata, handles)
  79. % hObject    handle to popupmenu1 (see GCBO)
  80. % eventdata  reserved - to be defined in a future version of MATLAB
  81. % handles    structure with handles and user data (see GUIDATA)
  82.  
  83. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
  84. %        contents{get(hObject,'Value')} returns selected item from popupmenu1
  85.  
  86.  
  87. % --- Executes during object creation, after setting all properties.
  88. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  89. % hObject    handle to popupmenu1 (see GCBO)
  90. % eventdata  reserved - to be defined in a future version of MATLAB
  91. % handles    empty - handles not created until after all CreateFcns called
  92.  
  93. % Hint: popupmenu controls usually have a white background on Windows.
  94. %       See ISPC and COMPUTER.
  95. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  96.     set(hObject,'BackgroundColor','white');
  97. end
  98. set(hObject, 'String', {'Sinus 1Khz', 'E Piano', 'Drums'});
  99.  
  100.  
  101. % --- Executes on selection change in popupmenu2.
  102. function popupmenu2_Callback(hObject, eventdata, handles)
  103. % hObject    handle to popupmenu2 (see GCBO)
  104. % eventdata  reserved - to be defined in a future version of MATLAB
  105. % handles    structure with handles and user data (see GUIDATA)
  106.  
  107. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
  108. %        contents{get(hObject,'Value')} returns selected item from popupmenu2
  109.  
  110.  
  111. % --- Executes during object creation, after setting all properties.
  112. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  113. % hObject    handle to popupmenu2 (see GCBO)
  114. % eventdata  reserved - to be defined in a future version of MATLAB
  115. % handles    empty - handles not created until after all CreateFcns called
  116.  
  117. % Hint: popupmenu controls usually have a white background on Windows.
  118. %       See ISPC and COMPUTER.
  119. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  120.     set(hObject,'BackgroundColor','white');
  121. end
  122. set(hObject, 'String', {'Gleichrichtung'});
  123.  
  124. % --- Executes on selection change in popupmenu3.
  125. function popupmenu3_Callback(hObject, eventdata, handles)
  126. % hObject    handle to popupmenu3 (see GCBO)
  127. % eventdata  reserved - to be defined in a future version of MATLAB
  128. % handles    structure with handles and user data (see GUIDATA)
  129.  
  130. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
  131. %        contents{get(hObject,'Value')} returns selected item from popupmenu3
  132.  
  133.  
  134. % --- Executes during object creation, after setting all properties.
  135. function popupmenu3_CreateFcn(hObject, eventdata, handles)
  136. % hObject    handle to popupmenu3 (see GCBO)
  137. % eventdata  reserved - to be defined in a future version of MATLAB
  138. % handles    empty - handles not created until after all CreateFcns called
  139.  
  140. % Hint: popupmenu controls usually have a white background on Windows.
  141. %       See ISPC and COMPUTER.
  142. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  143.     set(hObject,'BackgroundColor','white');
  144. end
  145. set(hObject, 'String', {'Half', 'Full', 'Diode'});
  146.  
  147. % --- Executes on selection change in popupmenu4.
  148. function popupmenu4_Callback(hObject, eventdata, handles)
  149. % hObject    handle to popupmenu4 (see GCBO)
  150. % eventdata  reserved - to be defined in a future version of MATLAB
  151. % handles    structure with handles and user data (see GUIDATA)
  152.  
  153. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
  154. %        contents{get(hObject,'Value')} returns selected item from popupmenu4
  155.  
  156.  
  157. % --- Executes during object creation, after setting all properties.
  158. function popupmenu4_CreateFcn(hObject, eventdata, handles)
  159. % hObject    handle to popupmenu4 (see GCBO)
  160. % eventdata  reserved - to be defined in a future version of MATLAB
  161. % handles    empty - handles not created until after all CreateFcns called
  162.  
  163. % Hint: popupmenu controls usually have a white background on Windows.
  164. %       See ISPC and COMPUTER.
  165. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  166.     set(hObject,'BackgroundColor','white');
  167. end
  168. set(hObject, 'String', {'Aus', '2x', '4x'});
  169.  
  170. % --- Executes on selection change in popupmenu5.
  171. function popupmenu5_Callback(hObject, eventdata, handles)
  172. % hObject    handle to popupmenu5 (see GCBO)
  173. % eventdata  reserved - to be defined in a future version of MATLAB
  174. % handles    structure with handles and user data (see GUIDATA)
  175.  
  176. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5 contents as cell array
  177. %        contents{get(hObject,'Value')} returns selected item from popupmenu5
  178.  
  179.  
  180. % --- Executes during object creation, after setting all properties.
  181. function popupmenu5_CreateFcn(hObject, eventdata, handles)
  182. % hObject    handle to popupmenu5 (see GCBO)
  183. % eventdata  reserved - to be defined in a future version of MATLAB
  184. % handles    empty - handles not created until after all CreateFcns called
  185.  
  186. % Hint: popupmenu controls usually have a white background on Windows.
  187. %       See ISPC and COMPUTER.
  188. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  189.     set(hObject,'BackgroundColor','white');
  190. end
  191. set(hObject, 'String', {'lin', 'log'});
  192.  
  193. % --- Executes on slider movement.
  194. function slider1_Callback(hObject, eventdata, handles)
  195. % hObject    handle to slider1 (see GCBO)
  196. % eventdata  reserved - to be defined in a future version of MATLAB
  197. % handles    structure with handles and user data (see GUIDATA)
  198.  
  199. % Hints: get(hObject,'Value') returns position of slider
  200. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  201. to_string(handles.edit1, handles.slider1,[1 21], 'dB', 'log', 1);
  202.  
  203. % --- Executes during object creation, after setting all properties.
  204. function slider1_CreateFcn(hObject, eventdata, handles)
  205. % hObject    handle to slider1 (see GCBO)
  206. % eventdata  reserved - to be defined in a future version of MATLAB
  207. % handles    empty - handles not created until after all CreateFcns called
  208.  
  209. % Hint: slider controls usually have a light gray background.
  210. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  211.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  212. end
  213.  
  214.  
  215. % --- Executes on slider movement.
  216. function slider2_Callback(hObject, eventdata, handles)
  217. % hObject    handle to slider2 (see GCBO)
  218. % eventdata  reserved - to be defined in a future version of MATLAB
  219. % handles    structure with handles and user data (see GUIDATA)
  220.  
  221. % Hints: get(hObject,'Value') returns position of slider
  222. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  223. to_string(handles.edit2, handles.slider2,[1 21], 'dB', 'log', 1);
  224.  
  225. % --- Executes during object creation, after setting all properties.
  226. function slider2_CreateFcn(hObject, eventdata, handles)
  227. % hObject    handle to slider2 (see GCBO)
  228. % eventdata  reserved - to be defined in a future version of MATLAB
  229. % handles    empty - handles not created until after all CreateFcns called
  230.  
  231. % Hint: slider controls usually have a light gray background.
  232. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  233.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  234. end
  235.  
  236.  
  237. % --- Executes on slider movement.
  238. function slider3_Callback(hObject, eventdata, handles)
  239. % hObject    handle to slider3 (see GCBO)
  240. % eventdata  reserved - to be defined in a future version of MATLAB
  241. % handles    structure with handles and user data (see GUIDATA)
  242.  
  243. % Hints: get(hObject,'Value') returns position of slider
  244. %        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
  245. to_string(handles.edit3, handles.slider3,[1 21], 'dB', 'log', 1);
  246.  
  247. % --- Executes during object creation, after setting all properties.
  248. function slider3_CreateFcn(hObject, eventdata, handles)
  249. % hObject    handle to slider3 (see GCBO)
  250. % eventdata  reserved - to be defined in a future version of MATLAB
  251. % handles    empty - handles not created until after all CreateFcns called
  252.  
  253. % Hint: slider controls usually have a light gray background.
  254. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  255.     set(hObject,'BackgroundColor',[.9 .9 .9]);
  256. end
  257.  
  258.  
  259.  
  260. function edit1_Callback(hObject, eventdata, handles)
  261. % hObject    handle to edit1 (see GCBO)
  262. % eventdata  reserved - to be defined in a future version of MATLAB
  263. % handles    structure with handles and user data (see GUIDATA)
  264.  
  265. % Hints: get(hObject,'String') returns contents of edit1 as text
  266. %        str2double(get(hObject,'String')) returns contents of edit1 as a double
  267. parsestring(handles.edit1, handles.slider1,[1 21], 'dB', 'log', 1);
  268.  
  269. % --- Executes during object creation, after setting all properties.
  270. function edit1_CreateFcn(hObject, eventdata, handles)
  271. % hObject    handle to edit1 (see GCBO)
  272. % eventdata  reserved - to be defined in a future version of MATLAB
  273. % handles    empty - handles not created until after all CreateFcns called
  274.  
  275. % Hint: edit controls usually have a white background on Windows.
  276. %       See ISPC and COMPUTER.
  277. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  278.     set(hObject,'BackgroundColor','white');
  279. end
  280.  
  281.  
  282.  
  283. function edit2_Callback(hObject, eventdata, handles)
  284. % hObject    handle to edit2 (see GCBO)
  285. % eventdata  reserved - to be defined in a future version of MATLAB
  286. % handles    structure with handles and user data (see GUIDATA)
  287.  
  288. % Hints: get(hObject,'String') returns contents of edit2 as text
  289. %        str2double(get(hObject,'String')) returns contents of edit2 as a double
  290. parsestring(handles.edit2, handles.slider2,[1 21], 'dB', 'log', 1);
  291.  
  292. % --- Executes during object creation, after setting all properties.
  293. function edit2_CreateFcn(hObject, eventdata, handles)
  294. % hObject    handle to edit2 (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: edit controls usually have a white background on Windows.
  299. %       See ISPC and COMPUTER.
  300. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  301.     set(hObject,'BackgroundColor','white');
  302. end
  303.  
  304.  
  305.  
  306. function edit3_Callback(hObject, eventdata, handles)
  307. % hObject    handle to edit3 (see GCBO)
  308. % eventdata  reserved - to be defined in a future version of MATLAB
  309. % handles    structure with handles and user data (see GUIDATA)
  310.  
  311. % Hints: get(hObject,'String') returns contents of edit3 as text
  312. %        str2double(get(hObject,'String')) returns contents of edit3 as a double
  313. parsestring(handles.edit3, handles.slider3,[1 21], 'dB', 'log', 1);
  314.  
  315. % --- Executes during object creation, after setting all properties.
  316. function edit3_CreateFcn(hObject, eventdata, handles)
  317. % hObject    handle to edit3 (see GCBO)
  318. % eventdata  reserved - to be defined in a future version of MATLAB
  319. % handles    empty - handles not created until after all CreateFcns called
  320.  
  321. % Hint: edit controls usually have a white background on Windows.
  322. %       See ISPC and COMPUTER.
  323. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  324.     set(hObject,'BackgroundColor','white');
  325. end
  326.  
  327.  
  328. % --- Executes on button press in pushbutton1.
  329. function pushbutton1_Callback(hObject, eventdata, handles)
  330. % hObject    handle to pushbutton1 (see GCBO)
  331. % eventdata  reserved - to be defined in a future version of MATLAB
  332. % handles    structure with handles and user data (see GUIDATA)
  333. switch(get(handles.popupmenu1, 'Value'))
  334.     case 1
  335.         fs = 44100;
  336.         s = (cos(2*pi*1000/fs*(0:1:(2*fs))));
  337.     case 2
  338.         [s, fs] = audioread('e-piano.wav');
  339.     case 3
  340.         [s, fs] = audioread('drums.wav');
  341. end;
  342. s = processing(s, fs, handles);
  343. sound(s, fs);
  344.  
  345. % --- Executes on button press in pushbutton2.
  346. function pushbutton2_Callback(hObject, eventdata, handles)
  347. % hObject    handle to pushbutton2 (see GCBO)
  348. % eventdata  reserved - to be defined in a future version of MATLAB
  349. % handles    structure with handles and user data (see GUIDATA)
  350. fs = 44100;
  351. s  = (cos(2*pi*1000/fs*(0:1:(fs))));
  352. skala = get(handles.popupmenu5, 'String');
  353. skala = lower(char(skala(get(handles.popupmenu5, 'Value'))));
  354. axes(handles.axes2);
  355. plotfft(processing(s, fs, handles), fs, 8192,skala);
  356. kennlinie(handles)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement