天天看點

【語音處理】基于matlab GUI聲音信号頻譜分析儀【含Matlab源碼 325期】

一、簡介

二、源代碼

function varargout = SpectrumAnalysis(varargin)
% SPECTRUMANALYSIS MATLAB code for SpectrumAnalysis.fig
%      SPECTRUMANALYSIS, by itself, creates a new SPECTRUMANALYSIS or raises the existing
%      singleton*.
%
%      H = SPECTRUMANALYSIS returns the handle to a new SPECTRUMANALYSIS or the handle to
%      the existing singleton*.
%
%      SPECTRUMANALYSIS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SPECTRUMANALYSIS.M with the given input arguments.
%
%      SPECTRUMANALYSIS('Property','Value',...) creates a new SPECTRUMANALYSIS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before SpectrumAnalysis_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to SpectrumAnalysis_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 SpectrumAnalysis

% Last Modified by GUIDE v2.5 02-Nov-2011 15:49:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SpectrumAnalysis_OpeningFcn, ...
                   'gui_OutputFcn',  @SpectrumAnalysis_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 SpectrumAnalysis is made visible.
function SpectrumAnalysis_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 SpectrumAnalysis (see VARARGIN)

% Choose default command line output for SpectrumAnalysis
handles.output = hObject;
xlabel(handles.axes1,'Time (s)','fontweight','bold');
xlabel(handles.axes2,'Freqency (Hz)','fontweight','bold');
xlabel(handles.axes3,'Freqency (Hz)','fontweight','bold');
ylabel(handles.axes1,'Amplitude','fontweight','bold');
ylabel(handles.axes2,'Amplitude','fontweight','bold');
ylabel(handles.axes3,'Amplitude','fontweight','bold');

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes SpectrumAnalysis wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = SpectrumAnalysis_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 edit_Fs_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Fs (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 edit_Fs as text
%        str2double(get(hObject,'String')) returns contents of edit_Fs as a double


% --- Executes during object creation, after setting all properties.
function edit_Fs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Fs (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 edit_TestA_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TestA (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 edit_TestA as text
%        str2double(get(hObject,'String')) returns contents of edit_TestA as a double


% --- Executes during object creation, after setting all properties.
function edit_TestA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TestA (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 edit_TestF_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TestF (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 edit_TestF as text
%        str2double(get(hObject,'String')) returns contents of edit_TestF as a double


% --- Executes during object creation, after setting all properties.
function edit_TestF_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TestF (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


           

三、運作結果

四、備注