[Voice processing] based on Matlab GUI audio signal analyzer [including Matlab source code 876 period]

[Voice processing] based on Matlab GUI audio signal analyzer [including Matlab source code 876 period]

1. Introduction

Audio signal analyzer based on Matlab GUI

2. the source code

function varargout = soundanalyze2(varargin) % SOUNDANALYZE2 MATLAB code for soundanalyze2.fig % SOUNDANALYZE2, by itself, creates a new SOUNDANALYZE2 or raises the existing % singleton*. % % H = SOUNDANALYZE2 returns the handle to a new SOUNDANALYZE2 or the handle to % the existing singleton*. % % SOUNDANALYZE2( 'CALLBACK' ,hObject,eventData,handles,...) calls the local % function named CALLBACK in SOUNDANALYZE2.M with the given input arguments. % % SOUNDANALYZE2( 'Property' , 'Value' ,...) creates a new SOUNDANALYZE2 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before soundanalyze2_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to soundanalyze2_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 soundanalyze2 % Last Modified by GUIDE v2 .5 02 -Jul -2014 16 : 27 : 40 % Begin initialization code-DO NOT EDIT gui_Singleton = 1 ; gui_State = struct( 'gui_Name' , mfilename, ... 'gui_Singleton' , gui_Singleton, ... 'gui_OpeningFcn' , @soundanalyze2_OpeningFcn, ... 'gui_OutputFcn' , @soundanalyze2_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 soundanalyze2 is made visible. function soundanalyze2_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 soundanalyze2 (see VARARGIN) %% **_OpeningFcn function is the command executed when the GUI is opened, and the GUI interface has not been displayed yet %% Load the background image into Matlab %% If the image is not in the current directory, the full path must be used % backgroundImage = importdata( 'backgound.jpg' ); %% Select coordinate system % axes(handles.axes_backgound); %% Add the picture to the coordinate system, so it becomes the background % image(backgroundImage); %% Remove the axis label of the coordinate system % axis off handles.addednoise = 0 ; % Choose default command line output for soundanalyze2 handles.output = hObject; % Update handles structure guidata (hObject, handles) ; % UIWAIT makes soundanalyze2 wait for user response (see UIRESUME) % uiwait ( handles.figure1 ) ; % --- Outputs from this function are returned to the command line. function varargout = soundanalyze2_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 ; function recordtime_input_Callback(hObject, eventdata, handles) % hObject handle to recordtime_input (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 recordtime_input as text % str2double(get(hObject,'String')) returns contents of recordtime_input as a double % --- Executes during object creation, after setting all properties. function recordtime_input_CreateFcn(hObject, eventdata, handles) % hObject handle to recordtime_input (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 startrecord. function startrecord_Callback (hObject, eventdata, handles) % hObject handle to startrecord (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) recordtime = str2double(get(handles.recordtime_input, 'string' )); sample_frequency = str2double(get(handles.edit_sample_frequency, 'string' )); handles.Fs = sample_frequency; recObj = audiorecorder(sample_frequency, 16 , 1 ); info_msgbox = msgbox( 'Recording...please wait a moment' , 'status' ); recordblocking(recObj, recordtime); close(info_msgbox) handles.Sample = getaudiodata(recObj); handles.Sample = handles.Sample ' ; handles.inputtype = 1 ; guidata(hObject,handles); plot(handles.axes_time_waveform,... 0 : 1/sample_frequency:recordtime -1/sample_frequency,... handles.Sample); title(handles.axes_time_waveform, 'The time domain waveform of the original signal' ) xlabel(handles.axes_time_waveform, 'time(s)' ); ylabel(handles.axes_time_waveform, 'amplitude' ); set (handles.pushbutton_timanyalze, 'enable' , 'on' ) set (handles.pushbutton_frequencyanyalze, 'enable' , 'on' ) set (handles.pushbutton_noise_gensig, 'enable' , ' on' ) set (handles.pushbutton_play, 'enable' , 'on' ) % --- Executes on key press with focus on radiobutton_soundcard and none of its controls. function radiobutton_soundcard_KeyPressFcn (hObject, eventdata, handles) % hObject handle to radiobutton_soundcard (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key (s) that was pressed % Modifier: name (s) of the modifier key (s) (ie, control, shift) pressed % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton_timanyalze. function pushbutton_timanyalze_Callback (hObject, eventdata, handles) % hObject handle to pushbutton_timanyalze (see GCBO) % eventdata reserved-to be defined in a future version of MATLAB Structure with Handles Handles% and User Data (See guidata) Switch handles.inputtype Case . 1 SET (handles.period_value, 'String' , 0 ) SET (handles.frequency_value, 'String' , 0 ) SET (handles.amplitude_value, 'String ' , 0 ) set (handles.phase_position_value, 'string' , 0 ) case 2 set (handles.period_value, 'string' , 0 ) set (handles.frequency_value, 'string' , 0 ) set (handles.amplitude_value, 'string' , 0 ) set (handles.phase_position_value, 'string' , 0 ) case 3 set (handles.period_value, 'string' , 1/str2double(get(handles.edit_frequency, 'string' ))) set ( handles.frequency_value , 'string' ,str2double(get(handles.edit_frequency, 'string' ))) set (handles.amplitude_value, 'string',str2double(get(handles.edit_amplitude, 'string' ))) set ( handles.phase_position_value , 'string' ,str2double(get(handles.edit_phase_position, 'string' ))) end set (handles.peak_value, 'string' ,max(handles.Sample)) set (handles.mean_value, 'string' ,mean(handles.Sample)) set (handles.mean_square_error_value, 'string' , std (handles.Sample) ) set (handles.variance_value, 'string' ,var(handles.Sample)) function period_value_Callback (hObject, eventdata , handles) % hObject handle to period_value (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 period_value as text % str2double (get(hObject, 'String' )) returns contents of period_value as a double % --- Executes during object creation, after setting all properties. function period_value_CreateFcn (hObject, eventdata , handles) % hObject handle to period_value (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 function frequency_value_Callback (hObject, eventdata, handles) % hObject handle to frequency_value (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 frequency_value as text % str2double (get(hObject, 'String' )) returns contents of frequency_value as a double % --- Executes during object creation, after setting all properties. function frequency_value_CreateFcn (hObject, eventdata, handles) % hObject handle to frequency_value (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 function amplitude_value_Callback (hObject, eventdata, handles) % hObject handle to amplitude_value (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 amplitude_value as text % str2double (get(hObject, 'String' )) returns contents of amplitude_value as a double % --- Executes during object creation, after setting all properties. function amplitude_value_CreateFcn (hObject, eventdata, handles) % hObject handle to amplitude_value (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 function phase_position_value_Callback (hObject, eventdata , handles) % hObject handle to phase_position_value (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 phase_position_value as text % str2double (get(hObject, 'String' )) returns contents of phase_position_value as a double % --- Executes during object creation, after setting all properties. function phase_position_value_CreateFcn (hObject, eventdata , handles) % hObject handle to phase_position_value (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 Copy code

3. running results

4. remarks

Version: 2014