function varargout = gui_study(varargin)
% GUI_STUDY MATLAB code for gui_study.fig
% GUI_STUDY, by itself, creates a new GUI_STUDY or raises the existing
% singleton*.
%
% H = GUI_STUDY returns the handle to a new GUI_STUDY or the handle to
% the existing singleton*.
%
% GUI_STUDY('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_STUDY.M with the given input arguments.
%
% GUI_STUDY('Property','Value',...) creates a new GUI_STUDY or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_study_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_study_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 gui_study
% Last Modified by GUIDE v2.5 16-Apr-2013 22:45:31
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_study_OpeningFcn, ...
'gui_OutputFcn', @gui_study_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 gui_study is made visible.
function gui_study_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 gui_study (see VARARGIN)
% Choose default command line output for gui_study
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_study wait for user response (see UIRESUME)
% uiwait(handles.figure1);
set(handles.stopbutton,'enable','off')
% --- Outputs from this function are returned to the command line.
function varargout = gui_study_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 startbutton.
function startbutton_Callback(hObject, eventdata, handles)
% hObject handle to startbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (~isempty(daqfind))
stop(daqfind)
end
ai=analoginput('winsound');
addchannel(ai,[1 2]);
set(ai,'SampleRate',8000);
timePeriod=0.1;
set(ai,'SamplesPerTrigger',timePeriod*ai.sampleRate);
set(ai,'TriggerRepeat',1);
set(ai,'TriggerType','manual');
set(ai,'TimerPeriod',timePeriod);
set(ai,'BufferingConfig',[2048,20]);
start(ai);
trigger(ai);
d=getdata(ai,ai.SamplesPertrigger);
hline(1)=plot(handles.axes1,1:size(d,1),d(:,1),'b');
xlim('auto');
hline(2)=plot(handles.axes2,1:size(d,1),d(:,2),'r');
xlim('auto');
handles.ai=ai;
guidata(hObject,handles);
data.ai=ai;
data.handles=handles;
data.hline=hline;
set(ai,'UserData',data);
set(handles.startbutton,'enable','off');
set(handles.stopbutton,'enable','on');
set(data.ai,'TimerFcn',@updateData);
% --- Executes on button press in stopbutton.
function stopbutton_Callback(hObject, eventdata, handles)
% hObject handle to stopbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield(handles,'ai')
if isrunning(handles.ai)
stop(handles.ai);
end
end
set(handles.startbutton,'enable','on');
set(handles.stopbutton,'enable','off');
% --- Executes on button press in exitbutton.
function exitbutton_Callback(hObject, eventdata, handles)
% hObject handle to exitbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
answer=questdlg('你想退出程序码?','Warning!');
switch answer
case{'No','Cancel'}
return;
case 'Yes'
if isfield(handles,'ai')
if isvalid(handles.ai)
if isrunning(handles.ai)
stop(handles.ai);
end
end
delete(handles.ai);
delete(handles.figure1);
else
delete(handles.figure1);
end
end
function updateData(obj,event)
x=peekdata(obj,obj.SamplesPerTrigger);
h=obj.UserData;
set(h.hline(1),'YData',x(:,1));
set(h.hline(2),'YData',x(:,2));
drawnow;
基于MATLAB的声音采集
需积分: 50 175 浏览量
2013-11-30
14:22:46
上传
评论 1
收藏 9KB ZIP 举报
莎儿
- 粉丝: 1
- 资源: 2
最新资源
- 基于MQTT的智能宠物投喂系统
- 312749069629470selfieU重绘.apk
- http%3A%2F%2Fimg.wsdl.vivo.com.cn%2Fappstore%2Fdeveloper%2Ficon%2F201412%2F201412231038336
- 主要记录B站up主莫烦matplotlib教程中的代码.zip
- Java SE Development Kit 8u411 Windows x64 Installer
- 用于科学绘图的 Matplotlib 样式.zip
- Java SE Development Kit 11.0.23 Windows x64 Installer
- 毕业设计-后端项目-网站民宿展示网站SSM
- 基于python绘图,程序详细展示了绘图过程中详尽的命令语句,使得图片达到可发表程度 .zip
- Java SE Development Kit 11.0.23 macOS x64 DMG Installer
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈