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)
没有合适的资源?快使用搜索试试~ 我知道了~
数字信号基于matlab GUI数字电子琴【含Matlab源码 272期】.zip
共3个文件
jpg:1个
m:1个
fig:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 159 浏览量
2021-11-29
22:26:16
上传
评论 3
收藏 51KB ZIP 举报
温馨提示
CSDN海神之光上传的代码均可运行,亲测可用,直接替换数据即可,适合小白; 1、代码压缩包内容 主函数:graph.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,可私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开graph.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描博主博客文章底部QQ名片; 4.1 CSDN博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、通信、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识
资源推荐
资源详情
资源评论
收起资源包目录
【数字信号】基于matlab GUI数字电子琴【含Matlab源码 272期】.zip (3个子文件)
【数字信号】基于matlab GUI数字电子琴【含Matlab源码 272期】
运行结果.JPG 74KB
graph1.m 5KB
graph1.fig 10KB
共 3 条
- 1
资源评论
- m0_690243522022-04-19用户下载后在一定时间内未进行评价,系统默认好评。
- m0_613607012023-12-29资源内容详尽,对我有使用价值,谢谢资源主的分享。
- bugfree10112022-01-12用户下载后在一定时间内未进行评价,系统默认好评。
海神之光
- 粉丝: 5w+
- 资源: 6110
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功