function varargout = graph1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @graph1_OpeningFcn, ...
'gui_OutputFcn', @graph1_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
function graph1_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = graph1_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function playsound(soundtype, frequency, amp, phase)
Fs=41000;
x=[0:1/Fs:1];
switch soundtype
case 1 %正弦波
y=amp*sin(2*pi*frequency*x+phase);
case 2 %三角波
y=amp*sawtooth(2*pi*frequency*x+phase,0.5);
case 3 %锯齿波
y=amp*sawtooth(2*pi*frequency*x+phase);
case 4 %方波
y=amp*square(2*pi*frequency*x+phase);
case 5 %白噪声
y=amp*(2*rand(size(x))-1);
otherwise
errordlg('Illegal wave type','Choose errer');%向界面发送错误的对话框
end
plot(x,y);% 显示波形
axis([0,0.01,-200,200]);
wavplay(y,Fs,'async');%播放声音,使用async(异步)模式可以实现发声的混迭
function frequency_Callback(hObject, eventdata, handles)
handles.frequency=str2double(get(hObject,'String'));
guiddata(hObject,handles);
function frequency_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function amp_Callback(hObject, eventdata, handles)
handles.ampe=str2double(get(hObject,'String'));
guiddata(hObject,handles);
function amp_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function phase_Callback(hObject, eventdata, handles)
handles.phase=str2double(get(hObject,'String'));
guiddata(hObject,handles);
function phase_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in soundtype.这是下拉菜单
function soundtype_Callback(hObject, eventdata, handles)
handles.soundtype=get(hObject,'Value');
guidata(hObject,handles); %以获得存储所需要的波形
% --- Executes during object creation, after setting all properties.
function soundtype_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbuttonbroadcast.
function pushbuttonbroadcast_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,handles.frequency,handles.amp,handles.phase);
% --- Executes on button press in pushbuttondefault.初始化
function pushbuttondefault_Callback(hObject, eventdata, handles)
set(handles.soundtype,'Value',1);
set(handles.frequency,'String','300');
set(handles.amp,'String','180');
set(handles.phase,'String','0');
handles.soundtype=1;
handles.frequency=300;
handles.amp=180;
handles.phase=0;
guidata(hObject,handles);
% --- Executes on button press in pushbuttonA.
function pushbuttonA_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,261.63,handles.amp,handles.phase);
function pushbuttonB_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,293.66,handles.amp,handles.phase);
function pushbuttonC_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,329.63,handles.amp,handles.phase);
function pushbuttonD_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,349.23,handles.amp,handles.phase);
function pushbuttonE_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,392.00,handles.amp,handles.phase);
function pushbuttonF_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,440.00,handles.amp,handles.phase);
function pushbuttonG_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,493.88,handles.amp,handles.phase);
function pushbuttonH_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,131,handles.amp,handles.phase);
function pushbuttonI_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,150,handles.amp,handles.phase);
function pushbuttonJ_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,180,handles.amp,handles.phase);
function pushbuttonK_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,190,handles.amp,handles.phase);
function pushbuttonN_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,200,handles.amp,handles.phase);
function pushbuttonO_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,210,handles.amp,handles.phase);
function pushbuttonL_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,220,handles.amp,handles.phase);
function pushbuttonM_Callback(hObject, eventdata, handles)
playsound(handles.soundtype,230,handles.amp,handles.phase);
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
function axes1_CreateFcn(hObject, eventdata, handles)
海神之光
- 粉丝: 5w+
- 资源: 6477
最新资源
- HTML5实现好看的网络视频分享平台网站模板.zip
- HTML5实现好看的小清新电商家具商城模板.zip
- HTML5实现好看的物流运输公司网站模板.zip
- HTML5实现好看的舞蹈学院官网网站模板.zip
- HTML5实现好看的新闻资讯播报网站模板.zip
- HTML5实现好看的新闻杂志资讯网站模板.zip
- HTML5实现好看的新车销售平台网站模板.zip
- HTML5实现好看的牙齿护理医疗网站模板.zip
- HTML5实现好看的医疗科技公司网站模板.zip
- HTML5实现好看的眼睛护理医院网站模板.zip
- 基于单片机的指纹考勤机系统设计.zip
- 可以直接复制网页内容的工具
- 前端开发中的HTML和CSS圣诞树绘制方法
- 基于单片机的厨房安全检测系统.zip
- 车灯后罩冲压机工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- IMDB前250电视剧数据集,电视剧排行数据,电视剧数据集
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈