Gointerface接口声明实现及作用详解
270
2022-09-08
【信号处理】数字电子琴设计与实现含Matlab源码(现代数字信号处理matlab仿真)
1 简介
电子琴发展概况
电子琴是随着电子技术的广泛应用而产生。1959年,世界上第一台全晶体管双排键电子琴在日本诞生。从此,电子琴技术不断发展成熟,电子琴的普及也越来越广。
电子琴在中国的推广始于20世纪八十年代,至今在音色、音质、演奏的便利性等方面都达到了相当成熟的地步,而且随着集成电路技术的发展,其升级换代可以在保持原有结构不变的情况下,通过简单的芯片更换实现。但是,电子琴也有明显的不足之处:与非电子乐器,如钢琴、管弦乐器等的协奏问题,限制了电子琴在重要音乐场所的使用,这极大的影响了电子琴的应用和推广。协调电子琴与非电子乐器的协奏,是当前音乐界人士和电子琴开发商的当务之急。
电子琴发音原理
物体振动时会发出声音,振动的频率不同,声音的音调就不同。在电子琴里,虽然没有振动的弦、簧、管等物体,却有许多特殊的电装置,每个电装置一工作,就会使喇叭发出一定频率的声音。当按动某个琴键时,就会使与它对应的电装置工作,从而使喇叭发出某种音调的声音。
电子琴的音量控制器,实质上是一个可调电阻器。当转动音量控制器旋扭时,可调电阻器的电阻就随着变化。电阻大小的变化,又会引起喇叭声音强弱的变化。所以转动音量控制旋扭时,电子琴发声的响度就随之变化。
当乐器发声时,除了发出某一频率的声音──基音以外,还会发出响度较小、频率加倍的辅助音──谐音。我们听到的乐器的声音是它发出的基音和谐音混合而成的。不同的乐器发出同一基音时,不仅谐音的数目不同,而且各谐音的响度也不同。因而使不同的乐器具有不同的音品。在电子琴里,除了有与基音对应的电装置外,还有与许多谐音对应的电装置,适当地选择不同的谐音电装置,就可以模仿出不同乐器的声音来。
2 部分代码
function varargout = digtai_piano(varargin)% DIGTAI_PIANO M-file for digtai_piano.fig% DIGTAI_PIANO, by itself, creates a new DIGTAI_PIANO or raises the existing% singleton*.%% H = DIGTAI_PIANO returns the handle to a new DIGTAI_PIANO or the handle to% the existing singleton*.%% DIGTAI_PIANO('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in DIGTAI_PIANO.M with the given input arguments.%% DIGTAI_PIANO('Property','Value',...) creates a new DIGTAI_PIANO or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before digtai_piano_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to digtai_piano_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% Copyright 2002-2003 The MathWorks, Inc.% Edit the above text to modify the response to help digtai_piano% Last Modified by GUIDE v2.5 28-Sep-2007 10:39:23% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @digtai_piano_OpeningFcn, ... 'gui_OutputFcn', @digtai_piano_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 digtai_piano is made visible.function digtai_piano_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 digtai_piano (see VARARGIN)% Choose default command line output for digtai_pianohandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes digtai_piano wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = digtai_piano_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 structurevarargout{1} = handles.output;% --- 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)A=1;f=131;Fs=11025;P=60;T=1.0/f;dt=T/Fs;N=T/dt;t=linspace(0,1,N);y=A*sin(2*pi*f*t+P);Phandel=findobj('Tag','edit1')set(Phandel,'String',f,'FontSize',15.0)plot(t,y,'r');grid ;axis([0,0.1,-1.5,1.5]);wavplay(y,11025);pause(1);cla;% --- 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)A=1;f=147;Fs=11025;P=60;T=1.0/f;dt=T/Fs;N=T/dt;t=linspace(0,1,N);y=A*sin(2*pi*f*t+P);Phandel=findobj('Tag','edit1')set(Phandel,'String',f,'FontSize',15.0)plot(t,y,'r');grid ;axis([0,0.1,-1.5,1.5]);wavplay(y,11025);pause(1);cla;% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)A=1;f=165;Fs=11025;P=60;T=1.0/f;dt=T/Fs;N=T/dt;t=linspace(0,1,N);y=A*sin(2*pi*f*t+P);Phandel=findobj('Tag','edit1')set(Phandel,'String',f,'FontSize',15.0)plot(t,y,'r');grid ;axis([0,0.1,-1.5,1.5]);wavplay(y,11025);pause(1);cla;% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)A=1;f=175;Fs=11025;P=60;T=1.0/f;dt=T/Fs;N=T/dt;t=linspace(0,1,N);y=A*sin(2*pi*f*t+P);Phandel=findobj('Tag','edit1')set(Phandel,'String',f,'FontSize',15.0)plot(t,y,'r');grid ;axis([0,0.1,-1.5,1.5]);wavplay(y,11025);pause(1);cla;% --- Executes on button press in pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)% hObject handle to pushbutton7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)A=1;f=196;
3 仿真结果
4 参考文献
[1]陈禄洪, 邵群英, 蔡伟强. 基于MATLAB数字电子琴的音乐喷泉控制系统设计[J]. 2018.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~