www.pudn.com > dspproject.rar > extend_function1.m, change:2016-10-24,size:7018b


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

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

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = extend_function1_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 fpath0
[filename5, pathname5] = uigetfile('*.wav','选择声音文件');
if isequal(filename5,0)||isequal(pathname5,0) %判断是否打开音频
    return;
end;
fpath0=[pathname5 filename5];

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fpath0 yindiao
[x,fs,bits] =wavread(fpath0);
%sound(x,fs,bits);                 %对语音信号进行回放
x0=x(:,1);                       %读入的x矩阵有两列,取第1列
%Fs=2*fs;                           %采样频率
%n=length(x0); %语音信号的长度
%Y=fft(x0,n); %傅里叶变换 
%N=length(x0)+1;
%Y=fft(x0);%做FFT变换,以下为绘图函数
%Y=abs(Y);
%Y=Y(1:N/2);  
%f=(0:N-1)*fs/N;
%f=f(1:N/2);
%plot(handles.axes1,x0);
%plot(handles.axes2,Y);
%t=0:1/fs:(n-1)/fs;
%男声转换为女声%
y1=voice(x0,yindiao);                %调整voice()第2个参数转换音调,>1降调,<1升调,y1为x转换后的声音
sound(y1,fs);
wavwrite(y1,fs,'man_woman.wav');
%[x,ft]=wavread('man_woman.wav');

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fpath0 time
[x,Fs,bits]=wavread(fpath0);%回音
y=[x;zeros(32000,1)]+0.2*[zeros(32000,1);x];%一次回声信号延迟N=3200,衰减系a=0.5
sound(5*y,Fs);


% --- 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)
main

% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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
global yindiao
yindiao=get(hObject,'value');


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (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 slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (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
global time
time=get(hObject,'value');

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