www.pudn.com > dspproject.rar > ICAGUI.m, change:2016-10-23,size:6181b


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

% Last Modified by GUIDE v2.5 23-Oct-2016 19:23:19

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = ICAGUI_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;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fpath1 fpath2 finalL finalR FS
[Y1,FS,NBITS]=wavread(fpath1); % 将 WAV 文件转换成变量
[Y2,FS,NBITS]=wavread(fpath2);
FS,NBITS, % 显示采样频率和量化比特
Ym1=max(max(max(Y1)),max(abs(min(Y1)))), 
Ym2=max(max(max(Y2)),max(abs(min(Y2)))),% 找出双声道极值
X1=Y1/Ym1,
X2=Y2/Ym2,% 归一化处理
x1=X1(:,1),
x2=X2(:,1),% 抽取第 1 声道
x=[x1,x2],
x_=x'
[Out1, Out2, Out3]=fastica(x_);
mix11=Out2(1,1);
mix12=Out2(1,2);
mix21=Out2(2,1);
mix22=Out2(2,2);
ICresult_=Out1';
finalL=ICresult_(:,1),
wavwrite(finalL,FS,NBITS,'fica1L.wav')
finalR=ICresult_(:,2),
wavwrite(finalR,FS,NBITS,'fica1R.wav')

n=length(finalL);
Y=fft(finalL,n); %傅里叶变换 
N=length(finalL)+1;
Y=fft(finalL);%做FFT变换,以下为绘图函数
Y=abs(Y);
Y=Y(1:N/2);  
f=(0:N-1)*FS/N;
f=f(1:N/2);  

m=length(finalR);
Z=fft(finalR,m); %傅里叶变换 
M=length(finalR)+1;
Z=fft(finalR);%做FFT变换,以下为绘图函数
Z=abs(Z);
Z=Z(1:M/2);  
F=(0:M-1)*FS/M
F=F(1:M/2);  
%绘图
plot(handles.axes5,finalL);
xlabel('Hz');
ylabel('幅值');
plot(handles.axes6,Y);

plot(handles.axes8,finalR);
xlabel('Hz');
ylabel('幅值');
plot(handles.axes7,Z);
%在静态文本中逐个显示混合矩阵的元素
set(handles.text1,'string',mix11)
set(handles.text2,'string',mix12)
set(handles.text3,'string',mix21)
set(handles.text4,'string',mix22)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clear all;
global fpath1
[filename1, pathname1] = uigetfile('*.wav','选择声音文件');
if isequal(filename1,0)||isequal(pathname1,0) %判断是否打开音频
    return;
end;
fpath1=[pathname1 filename1];

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global finalL FS
sound(finalL,FS)


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fpath2
[filename2, pathname2] = uigetfile('*.wav','选择声音文件');
if isequal(filename2,0)||isequal(pathname2,0) %判断是否打开音频
    return;
end;
fpath2=[pathname2 filename2];


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
main


% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global FS finalR
sound(finalR,FS)