varargout{1} = handles.output;
% --- 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) set(hObject,'string','录音中'); pause(0.1);
Fs=str2double(get(handles.frequency,'String')); t=str2double(get(handles.recordtime,'String'));
ai=analoginput('winsound',0);%初始化录音麦克 chan =addchannel(ai,[1 2]);%1表示单声道,待我改了这句之后,录音就可以用回声效果了
set(ai,'SampleRate',Fs);
duration=t; %录音时间
set(ai,'SamplesPerTrigger',duration*Fs); start(ai); y=0;time=0;
[y,time]=getdata(ai);%读出相应的数据 handles.y=y; handles.Fs=Fs;
guidata(hObject,handles);
set(hObject,'string','完毕');
set(handles.play,'Enable','on');
set(handles.bfluyinwenjian,'Enable','on'); set(handles.lowStrong,'Enable','on'); set(handles.huisheng,'Enable','on');
%set(handles.yuchuli,'Enable','on'); %set(handles.yuchuliqd,'Enable','on');
%set(handles.fuliyebianhuan,'Enable','on'); %set(handles.baocun,'Enable','on');
%set(handles.biansheng,'Enable','on');
% --- Executes on button press in dakaiqueding.
% --- Executes on button press in openfile.
function openfile_Callback(hObject, eventdata, handles) % hObject handle to openfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) [filename pathname]=uigetfile({'*.wav','ALL FILES(*.*)'},'选择声音文件');
if isequal([filename pathname],[0,0]) return; end
str=[pathname filename];%选择的声音文件路径和文件名
[temp Fs]=wavread(str); % temp表示声音数据 Fs表示频率 handles.y=temp;handles.Fs=Fs; handles.xuanze=2;
guidata(hObject,handles);
%set(handles.yuchuli,'Enable','on'); %set(handles.yuchuliqd,'Enable','on');
%set(handles.fuliyebianhuan,'Enable','on'); %set(handles.baocun,'Enable','on');
%set(handles.biansheng,'Enable','on'); set(handles.play,'Enable','on');
set(handles.bfluyinwenjian,'Enable','on'); set(handles.lowStrong,'Enable','on'); set(handles.huisheng,'Enable','on');
function recordtime_Callback(hObject, eventdata, handles) % hObject handle to recordtime (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 as text % str2double(get(hObject,'String')) returns contents of recordtime as a double
% --- Executes during object creation, after setting all properties. function recordtime_CreateFcn(hObject, eventdata, handles) % hObject handle to recordtime (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 play.
function play_Callback(hObject, eventdata, handles) % hObject handle to play (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Enable')
set(handles.record,'Value',0);
set(handles.recordtime,'Enable','off'); set(handles.startrecord,'Enable','off'); set(handles.openfile,'Enable','off'); set(handles.open,'Value',0);
%set(handles.bofangpinlv,'Enable','on'); %set(handles.bofangqueding,'Enable','on'); set(handles.frequency,'Enable','off');
playspeed=str2double(get(handles.speed,'String')); handles.Fs=playspeed * handles.Fs ; wavplay(handles.y,handles.Fs); else end;
function frequency_Callback(hObject, eventdata, handles) % hObject handle to frequency (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 as text % str2double(get(hObject,'String')) returns contents of frequency as a double
% --- Executes during object creation, after setting all properties. function frequency_CreateFcn(hObject, eventdata, handles) % hObject handle to frequency (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 open.
function open_Callback(hObject, eventdata, handles) % hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of open if get(hObject,'Value')
set(handles.record,'Value',0);
set(handles.recordtime,'Enable','off'); set(handles.startrecord,'Enable','off'); set(handles.openfile,'Enable','on'); set(handles.play,'Enable','off');
set(handles.bfluyinwenjian,'Enable','off'); %set(handles.bofangpinlv,'Enable','off'); %set(handles.bofangqueding,'Enable','off'); set(handles.frequency,'Enable','off'); else end;
% --- Executes on button press in record.
function record_Callback(hObject, eventdata, handles) % hObject handle to record (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of record if get(hObject,'Value')
set(handles.startrecord,'string','开始录音'); set(handles.frequency,'Enable','on'); set(handles.open,'Value',0);
set(handles.recordtime,'Enable','on'); set(handles.startrecord,'Enable','on'); set(handles.openfile,'Enable','off');
set(handles.play,'Enable','off');%录音时,播放按键失效,下同
set(handles.bfluyinwenjian,'Enable','off'); set(handles.lowStrong,'Enable','off'); set(handles.huisheng,'Enable','off');
%set(handles.bofangpinlv,'Enable','off'); %set(handles.bofangqueding,'Enable','off'); %set(handles.startrecord,'string','开始'); else end;
function speed_Callback(hObject, eventdata, handles) % hObject handle to speed (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 speed as text % str2double(get(hObject,'String')) returns contents of speed as a double
% --- Executes during object creation, after setting all properties. function speed_CreateFcn(hObject, eventdata, handles) % hObject handle to speed (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 lowStrong.
function lowStrong_Callback(hObject, eventdata, handles) % hObject handle to lowStrong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(hObject,'Enable')
handles.fp1=1000;handles.fs1=2200; %设定低通滤波器通带截止频