【数字信号】基于Matlab GUI数字均衡器设计【含Matlab源码 904期】

一、简介

基于Matlab GUI数字均衡器设计

二、源代码

function varargout = balancer(varargin)
% BALANCER MATLAB code for balancer.fig
%      BALANCER, by itself, creates a new BALANCER or raises the existing
%      singleton*.
%
%      H = BALANCER returns the handle to a new BALANCER or the handle to
%      the existing singleton*.
%
%      BALANCER('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BALANCER.M with the given input arguments.
%
%      BALANCER('Property','Value',...) creates a new BALANCER or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before balancer_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to balancer_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
 

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @balancer_OpeningFcn, ...
                   'gui_OutputFcn',  @balancer_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 balancer is made visible.
function balancer_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to audio_begin
% 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 balancer (see VARARGIN)

% Choose default command line output for balancer
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = balancer_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to audio_begin
% 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;


% --- Executes on button press in audioload.
function audioload_Callback(hObject, eventdata, handles)
% hObject    handle to audioload (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    [FileName] = uigetfile('*','Select the audio file');
    [handles.audio , handles.audioFs ] = audioread(FileName) ;
    Audio_f = abs( fft(handles.audio) );
    plot( handles.audio_begin,Audio_f );
    handles.audioname.String = FileName;
    
    handles.audio_100 = fx_FIR( handles.audioFs, 1 ,100 , handles.audio);
    handles.audio_200 = fx_FIR( handles.audioFs, 100 ,200 , handles.audio);
    handles.audio_500 = fx_FIR( handles.audioFs, 200 ,500 , handles.audio);
    handles.audio_1K = fx_FIR( handles.audioFs, 500 ,1000 , handles.audio);
    handles.audio_2K = fx_FIR( handles.audioFs, 1000 ,2000 , handles.audio);
    handles.audio_4K = fx_FIR( handles.audioFs, 2000 ,4000 , handles.audio);
    handles.audio_8K = fx_FIR( handles.audioFs, 4000 ,8000 , handles.audio);
    handles.audio_16K = fx_FIR( handles.audioFs, 8000 ,20000 , handles.audio);
    
    %now_audio = audio_1K;
    handles.now_audio = handles.audio_100 + handles.audio_200 + handles.audio_500 + handles.audio_1K + handles.audio_2K + handles.audio_4K + handles.audio_8K + handles.audio_16K;
    sound( handles.now_audio , handles.audioFs );
    
    Audio_ff = abs( fft( handles.now_audio ) );
    plot( handles.audio_end , Audio_ff );
    
end
% Update handles structure
guidata(hObject, handles);


function audioname_Callback(hObject, eventdata, handles)
% hObject    handle to audioname (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 audioname as text
%        str2double(get(hObject,'String')) returns contents of audioname as a double


% --- Executes during object creation, after setting all properties.
function audioname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to audioname (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 slider movement.
function Freq100_Callback(hObject, eventdata, handles)
% hObject    handle to Freq100 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    a = get(handles.Freq100 , 'Value');
    b = get(handles.Freq200 , 'Value');
    c = get(handles.Freq500 , 'Value');
    d = get(handles.Freq1K , 'Value');
    e = get(handles.Freq2K , 'Value');
    f = get(handles.Freq4K , 'Value');
    g = get(handles.Freq8K , 'Value');
    h = get(handles.Freq16K , 'Value');
    
    handles.Freq100num.String = num2str( a*100 );
    all = get(handles.audiovoice , 'Value');
    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );
    Audio_ff = abs( fft( handles.now_audio ) );
    plot( handles.audio_end , Audio_ff );
    
end
guidata(hObject, handles);
% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function Freq100_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Freq100 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider7_Callback(hObject, eventdata, handles)
% hObject    handle to slider7 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider8_Callback(hObject, eventdata, handles)
% hObject    handle to slider8 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider9_Callback(hObject, eventdata, handles)
% hObject    handle to slider9 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider10_Callback(hObject, eventdata, handles)
% hObject    handle to slider10 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider11_Callback(hObject, eventdata, handles)
% hObject    handle to slider11 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

三、运行结果

【数字信号】基于Matlab GUI数字均衡器设计【含Matlab源码 904期】_第1张图片

四、备注

版本:2014a

你可能感兴趣的:(matlab,信号处理)