设计目的
目前,随着科技的不断发展,音频信号处理技术也发展异常迅猛,并且数字信号处理己成为主流。运用计算机来处理数字信号, 这就使得数字信号的处理速度非常快,这也是数字信号处理技术发展迅猛的主要原因。将各种各样的音频信号转换为数字信号之后我们就可以快速而轻松的对这些音频信号进行处理了。在这方面,早己出现如语音识别软件的各种关于音频信号处理的软件, 随着计算机技术的持续发展,计算机运算速度的大幅提高, 音频处理软件的处理能力越来越强。以语音识别软件为例,现在的语音识别软件的识别准确度越来越高,识别速度越来越快,而今,我们运用的软件是软件, 这都主要归功于数字信号处理技术的发展。所以说, 用数字信号处理音频信号的发展前景非常广阔。那么,我们就有理由选用数字信号处理的方法处理类似于钢琴音的音频信号。
设计意义
语音信号处理是综合性的多学科领域和涉及面很广的研究。由于该课程设计是真实语音的实际应用,运用语音中常见的表示形式——音乐,把数字信号处理的概念及分析方法应用于生活实际 ,激发学习热情,可以使我们增进对包络降噪,提高我们分析问题和解决问题的能力。而音乐作为一种语音常见的表示形式,作为与日常生活、学习等联系紧密的艺术学科,正在逐步走向数字化、科技化。近年来,现代音乐技术尤其是电子音乐技术取得了飞速的发展,以计算机技术为基础的音乐识别、检索、合成等问题,得到了更多研究人员的关注。
数字化音乐技术在音乐教学当中发挥出重大的作用,还可以推动音乐创作智能化的发展。音乐合成技术的实现使得自动谱曲成为可能,音乐合成技术降低了音乐创作的门槛,方便更多的音乐爱好者可以创作出属于自己的作品。此外,音乐合成技术也有助于电子琴研制的发展、传统乐器音色的改善等。对语音处理有着深远得意义。
设计要求
利用数字信号处理的相关知识,基于MATLAB设计实现一个带有GUI界面的钢琴音效处理系统,该系统可实现钢琴曲目的播放以及钢琴乐曲的弹奏等功能。
设计任务
在设计中涉及到以下两个主要方面:
第一,钢琴音信号特征的分析;找到Do、 Re、Mi、Fa、Sol、La、Si的基频的数学关系;
第二,用数字信号处理的办法处理钢琴音。编写函数, 用正弦波来合成钢琴的声音。电子琴的每个音阶均对应一个特定频率的信号, 通过调用程序产生一系列特定频率的声音,从而达到虚拟电子琴的功能。
第三,利用包络来消噪音,采用不同速度的衰减, 根据乐音持续时间的长短来确定衰减的快慢,乐音持续时间越长,衰减的越慢,持续时间越短,衰减的越快。当输入不同的频率时就会产生不同音色的声音。
设计原理
基本结构
钢琴拥有88个琴键,其中52个白色琴键,36个黑色琴键。第1号琴键为A2,第88号琴键为c5。本次课题,我们组设计的是36个琴键,其中12个低音键,12个中音键,12高音键。
钢琴音区
第1号琴键A2为最低音,发出乐音的基频为27.5Hz,第88号琴键c5为最高音,发出乐音的基频为4186.01Hz。钢琴上存在着一个国际基准音,为第49号琴键a1,也就是小字一组的第6个白键,其发出乐音的基频为440Hz(也称作标准音)。
本次课题我们设计的最低音频率为261.626HZ,最高音频为1975.533HZ。
音乐合成及播放
根据每个音符的节奏,利用函数对应不同的频率,产生的音频信号存入数组,再用sound函数播放。由于相位不连续会产生高频分量,可通过包络修正每一个音符,保证在音符信号幅度为零。
MATLAB模拟钢琴发声的原理
乐音特征由振动波的频率、时长、振幅、频谱四种物理量所决定。乐音四种物理量是乐器具有完美表现与感染效果不可缺失的四大元素,所以对乐音的研究,应首先从物理学入手。物理学研究发现,声音的音高和声波的振动频率关系密切,琴弦振动时,观察振动的波形图,两个相邻同方向峰值之间的间隔时间称为振荡周期,琴弦振动周期越短,则振动频率越高,表现为产生的声音音高越高。
十二平均律简介
钢琴是遵循十二平均律制制作的乐器,钢琴上每相邻的两个琴键(包括黑、白琴键)的频率差异称为半音。半音是十二平均律体系中最小的频率差异距离,即最小的音高距离。将一个八度音程十二等分为十二个半音。其数学意义为:八度音程指的是从基频至两倍频率的范围。因此在八度音程中分为十二等分乃是把这个频率范围分为十二个等比级数,其结果就是每个后续音的基频为前一个音的1.059463 倍。
音高特征对应振动的频率
钢琴键盘上的每个琴键对应着不同基频的乐音,无论白键、黑键,钢琴上相邻两个键的音高相差半音。相邻的同名音级的音 程距离为八度(Octave)。
音长特征对应振动的时长
音长指单个乐音发出声音的持续时间,其实质是琴弦的振动持续时间,因此对音长的识别则是实现对琴弦的振动波持续时间的识别。音乐节奏被定义为“2/4”节拍标识,即指一个“四分音符”为一个完整的“音乐节拍”,所以“八分音符”的发音时间应为半拍,“八分音符”乐音的持续的时间应为“四分音符”乐音的 1/2 半;而“十六分音符”乐音应持续发音 1/4 拍。所以对音长的识别,其实质是检测声音的振动时长,从而实现了识别乐曲的节奏模式。在乐曲中,小节是音乐乐句的基础,包含了若干数量的节拍数。本次课题《我和我的祖国》以6/8为主,有小部分9/8拍。
音强特征对应振动的振幅
根据钢琴弦的振动原理,钢琴低音区的键A2(27.5Hz)至A25(110Hz)必须使用长、粗、质量大的琴弦,使用大型弦槌,形成较大的冲击力,击打琴弦的有效部位,才能获得与中音区相匹配的音量。在钢琴乐音合成时,应当加以注意,对不同频率段的音符的振幅强度应当分别处理,争对人类听觉神经系统的特性,以保证高音、中音、低音区域不同乐音的音强更加和谐。
简而言之,要想利用matlab简单的发出一段声音,只要找到该声音对应的频率、音长,并且最好利用包络函数稍加润色,然后利用程序进行相应发声即可。
GUI钢琴界面的设计
GUI界面的设计可以通过全编程以及guide和部分编程,本次课题我们选择是guide和部分编程的方式实现。在该界面的设计中,汇集以下三部分内容,即钢琴琴键包括低音区、中音区、高音区以及“播放音乐”按钮,对各个“按钮”与“坐标区”之间建立关联,使用回调函数,从而实现钢琴的基本功能。
设计过程
音乐合成与播放
本系统所研究的对象为音乐,根据《我和我的祖国》的钢琴简谱和“十二平均率”计算出各个乐音的频率。我们通过设置采样频率Fs=8192Hz,使用函数生成等距的点,利用sin函数实现采样频率乘以等距离的点生成音频矩阵,每个音符都需要调用gen_wav函数实现发声,且每个音符都要设置发音的时长,最后利用包络检波实现降噪润色。
获取音符基本信息
声音是一种常见的物理现象。物体机械振动形成声波,借助空气媒介,传至人类的耳膜,引起神经反射,被人类感知为声音,人脑又对声音信号快速翻译成人类可以理解的音乐、音乐和各种已知的声音。人类能感知的声音在每秒振动数为20-20000次左右,即20 Hz-20000 Hz的频率范围。音乐中使用的乐音通过长期改良、调整,已形成了固定组合,能够表达作曲者的感情,传递作曲者的思想,形成音乐文化。考虑到人耳对声波频率的感知能力,音乐乐音被限定在27-4100 Hz的频率范围内,超过这个频率范围,人类不能清晰地感知,对表现塑造音乐形象的意义不大。
根据十二平均律表找到音对应的频率
为了便于计算,这里我们取《我和我的祖国》的曲调为1=C(与实际乐谱中的曲调不相同),即简谱音符”1”对应“do”。我们取中音区的小字一组,查看表1,即音符”1”对应的频率为523Hz。以此类推计算出第一句歌词中各乐音对应的频率如表所示。将频率以及音长(节奏)信息输入到一个函数中存储。
以下为歌曲《我和我的祖国》对应的部分钢琴简谱。
由基本的乐理基础,可得简谱和唱名的对应关系如下图
添加包络衰减实现降噪
运行程序,听音乐合成效果,会听到相邻乐音之间有“啪”的杂声,这是由于相位不连续产生了高频分量。这种噪声严重影响了合成音乐的质量。丧失了真实感。解决方法可以通过包络修正每一个乐音,以保证在乐音的邻接处信号幅度为零。
利用y=kx+b型包络函数润色声音
声音信号遵循着自己的规律上下起伏变化,这并不符合从发声时声音最强并逐渐减弱的规律。因此,我们引入y=kx+b型包络函数润色声音,辅助其“衰减”,
以sin函数为例:
从图中的”pic2”可以看到,相比于原始的sin函数,信号y已经有一个随时间衰减的过程了,从而实现降噪的功能。
利用sound函数播放声音,需满足sound(y,Fs)的结构,其中 Fs代表采样率,取为Fs=8192(matlab的默认采样率区间为1000-38400,超出这个区间就不能播出声音了)。而y代表音频信号矩阵,我们将前面得到的音符频率代入到正弦函数中得到一个信号值:
并且,为了使音乐具备基础的节奏(即使得每一个音符有长有短),我们引入另外一个量rhythm,它用于控制每个音符的长度。例如二分音符对应的rhythm值就大于四分音符对应的rhythm值。则音频信号矩阵y就可以表示为:
根据以上分析,在MATLAB编写如下程序:
function y= gen_wave( tone,rhythm )
%定义采样频率
Fs=8192;
x=linspace(0,2*rhythm*pi,floor(rhythm*Fs));%floor朝负无穷方向取整,保证采样频率为整
%定义基础音阶对应的频率
freqs=[261.626,277.183,293.665,311.127,329.628,349.228,369.994,391.995,415.305,440,466.164,493.883,523.251,554.365,587.33,622.254,659.255,698.456,739.989,784.991,830.609,880,932.328,987.767,1046.502,1108.731,1174.659,1244.508,1318.51,1396.913,1479.978,1567.982,1661.219,1760,1864.655,1975.533];
%声音
y=sin(freqs(tone)*x).*(1-x/(rhythm*2*pi));
end
在该界面中,汇集以下三部分内容,即钢琴低音区、中音区、高音区以及“播放音乐”按钮,通过使用回调函数,对各个“按钮”与“坐标区”之间建立关联,从而实现钢琴的基本功能,编写设置音长和频率并发声。
- 利用GUI制作钢琴界面,并为每个普通按钮添加回调函数,实现钢琴的基本功能。
- 通过对照曲目钢琴简谱,设置乐音对应的频率、音长,同时利用包络函数润色音乐,使系统可实现较好地模拟钢琴琴声,并且完成钢琴曲目的播放和弹奏。
- 本课程的设计可以根据自己的兴趣爱好,自行调节并弹奏,来使音乐变得更加动听,具有灵活性。
在完成本次课程设计的过程中,我们熟悉了MATLAB的基本指令、GUI界面的设计以及函数调用,也让我们对处理连续时间信号方法有了更深刻的认识。
基于 MATLAB的音乐信号合成及处理,通过这次的课程设计,加深了我们对数字信号处理所学知识的了解,增强了我们对教学知识的运用和主动研究的能力。让我们掌握信号处理过程的仿真设计方法,也让我们加深对了对处理连续时间信号的原理、方法所依据理论的理解。通过编写Matlab程序,利用matlab软件来实现对乐音信号的仿真,从而加深我们对模拟信号数字化处理的理解,了解音乐信号时间特性、频率特性变化所带来的影响,初步学会改善音乐播放效果。在运所学知识和学习Matlab 软件的同时也学习到音乐的基本组成,有了充分准备和宝贵经验,培养应用知识和独立思考的能力,提高分析问题和解决问题的能力。
[1]程美芳. 钢琴音色识别与电子合成系统的设计与实现[M].北京:科学出版社
[2]张明照,刘政波,刘斌,等.应用 MATLAB实现信号分析和处理[M].北京:科学出版社
[3]基于Matlab/GUI的音乐播放器设计[J]. 燕丽红. 现代电子技术 . 2015,第008期
[4]李敏等.基于MATLAB的音乐分析与合成实验设计.大连:大连民族学院学报,2010.
[5]做音质更好的音乐播放器欧迪福斯亚洲区高层谈ARM1音乐播放器 [J].现代音响技术.2013,第007期
[6]谢芳,陆文骏.基于MATLAB的含噪音乐信号降噪处理方法[J].九江学院学报(自然科学版),2022,37(03):45-49.DOI:10.19717/j.cnki.jjun.2022.03.011.
[7]燕丽红.基于Matlab&GUI音乐信号处理平台的设计[J].计算机与数字工程,2020,48(01):267-270.
代码:
function y= gen_wave( tone,rhythm )
%定义采样频率
Fs=8192;
x=linspace(0,2*rhythm*pi,floor(rhythm*Fs));%floor朝负无穷方向取整,保证采样频率为整
%定义基础音阶对应的频率
freqs=[261.626,277.183,293.665,311.127,329.628,349.228,369.994,391.995,415.305,440,466.164,493.883,523.251,554.365,587.33,622.254,659.255,698.456,739.989,784.991,830.609,880,932.328,987.767,1046.502,1108.731,1174.659,1244.508,1318.51,1396.913,1479.978,1567.982,1661.219,1760,1864.655,1975.533];
%声音
y=sin(freqs(tone)*x).*(1-x/(rhythm*2*pi));
end
function varargout = GUI1(varargin)
% GUI1 MATLAB code for GUI1.fig
% GUI1, by itself, creates a new GUI1 or raises the existing
% singleton*.
%
% H = GUI1 returns the handle to a new GUI1 or the handle to
% the existing singleton*.
%
% GUI1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI1.M with the given input arguments.
%
% GUI1('Property','Value',...) creates a new GUI1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI1_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 GUI1
% Last Modified by GUIDE v2.5 05-Apr-2023 20:45:03
% Begin initialization code - lowone NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI1_OpeningFcn, ...
'gui_OutputFcn', @GUI1_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 - lowone NOT EDIT
% --- Executes just before GUI1 is made visible.
function GUI1_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 GUI1 (see VARARGIN)
% Choose default command line output for GUI1
handles.output = hObject;
handles.SampleRate = 1/10000;
handles.Soundfcn = 0;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI1_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 lowone.
function lowone_Callback(hObject, eventdata, handles)
% hObject handle to lowone (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(1,1);
sound(y,8192);
% --- Executes on button press in lowtwo.
function lowtwo_Callback(hObject, eventdata, handles)
% hObject handle to lowtwo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(3,1);
sound(y,8192);
% --- Executes on button press in lowthree.
function lowthree_Callback(hObject, eventdata, handles)
% hObject handle to lowthree (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(5,1);
sound(y,8192);
% --- Executes on button press in lowfour.
function lowfour_Callback(hObject, eventdata, handles)
% hObject handle to lowfour (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(6,1);
sound(y,8192);
% --- Executes on button press in lowfive.
function lowfive_Callback(hObject, eventdata, handles)
% hObject handle to lowfive (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(8,1);
sound(y,8192);
% --- Executes on button press in lowsix.
function lowsix_Callback(hObject, eventdata, handles)
% hObject handle to lowsix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(10,1);
sound(y,8192);
% --- Executes on button press in lowseven.
function lowseven_Callback(hObject, eventdata, handles)
% hObject handle to lowseven (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(12,1);
sound(y,8192);
% --- Executes on button press in one.
function one_Callback(hObject, eventdata, handles)
% hObject handle to one (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(13,1);
sound(y,8192);
% --- Executes on button press in two.
function two_Callback(hObject, eventdata, handles)
% hObject handle to two (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(15,1);
sound(y,8192);
% --- Executes on button press in three.
function three_Callback(hObject, eventdata, handles)
% hObject handle to three (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(17,1);
sound(y,8192);
% --- Executes on button press in seven.
function seven_Callback(hObject, eventdata, handles)
% hObject handle to seven (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(24,1);
sound(y,8192);
% --- Executes on button press in six.
function six_Callback(hObject, eventdata, handles)
% hObject handle to six (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(22,1);
sound(y,8192);
% --- Executes on button press in five.
function five_Callback(hObject, eventdata, handles)
% hObject handle to five (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(20,1);
sound(y,8192);
% --- Executes on button press in foor.
function foor_Callback(hObject, eventdata, handles)
% hObject handle to foor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(18,1);
sound(y,8192);
% --- Executes on button press in Sharplow1.
function Sharplow1_Callback(hObject, eventdata, handles)
% hObject handle to Sharplow1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(2,1);
sound(y,8192);
% --- Executes on button press in Sharplow2.
function Sharplow2_Callback(hObject, eventdata, handles)
% hObject handle to Sharplow2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(4,1);
sound(y,8192);
% --- Executes on button press in Sharplow4.
function Sharplow4_Callback(hObject, eventdata, handles)
% hObject handle to Sharplow4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(7,1);
sound(y,8192);
% --- Executes on button press in Sharplow5.
function Sharplow5_Callback(hObject, eventdata, handles)
% hObject handle to Sharplow5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(9,1);
sound(y,8192);
% --- Executes on button press in Sharplow6.
function Sharplow6_Callback(hObject, eventdata, handles)
% hObject handle to Sharplow6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(11,1);
sound(y,8192);
% --- Executes on button press in Sharp2.
function Sharp2_Callback(hObject, eventdata, handles)
% hObject handle to Sharp2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(16,1);
sound(y,8192);
% --- Executes on button press in Sharp1.
function Sharp1_Callback(hObject, eventdata, handles)
% hObject handle to Sharp1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(14,1);
sound(y,8192);
% --- Executes on button press in Sharp4.
function Sharp4_Callback(hObject, eventdata, handles)
% hObject handle to Sharp4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(19,1);
sound(y,8192);
% --- Executes on button press in Sharp5.
function Sharp5_Callback(hObject, eventdata, handles)
% hObject handle to Sharp5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(21,1);
sound(y,8192);
% --- Executes on button press in Sharp6.
function Sharp6_Callback(hObject, eventdata, handles)
% hObject handle to Sharp6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(23,1);
sound(y,8192);
% --- Executes on button press in highone.
function highone_Callback(hObject, eventdata, handles)
% hObject handle to highone (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(25,1);
sound(y,8192);
% --- Executes on button press in hightwo.
function hightwo_Callback(hObject, eventdata, handles)
% hObject handle to hightwo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(27,1);
sound(y,8192);
% --- Executes on button press in highthree.
function highthree_Callback(hObject, eventdata, handles)
% hObject handle to highthree (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(29,1);
sound(y,8192);
% --- Executes on button press in highfoor.
function highfoor_Callback(hObject, eventdata, handles)
% hObject handle to highfoor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(30,1);
sound(y,8192);
% --- Executes on button press in highfive.
function highfive_Callback(hObject, eventdata, handles)
% hObject handle to highfive (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(32,1);
sound(y,8192);
% --- Executes on button press in highsix.
function highsix_Callback(hObject, eventdata, handles)
% hObject handle to highsix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(34,1);
sound(y,8192);
% --- Executes on button press in highseven.
function highseven_Callback(hObject, eventdata, handles)
% hObject handle to highseven (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(36,1);
sound(y,8192);
% --- Executes on button press in Sharphigh1.
function Sharphigh1_Callback(hObject, eventdata, handles)
% hObject handle to Sharphigh1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(26,1);
sound(y,8192);
% --- Executes on button press in Sharphigh2.
function Sharphigh2_Callback(hObject, eventdata, handles)
% hObject handle to Sharphigh2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(28,1);
sound(y,8192);
% --- Executes on button press in Sharphigh4.
function Sharphigh4_Callback(hObject, eventdata, handles)
% hObject handle to Sharphigh4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(31,1);
sound(y,8192);
% --- Executes on button press in Sharphigh5.
function Sharphigh5_Callback(hObject, eventdata, handles)
% hObject handle to Sharphigh5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(33,1);
sound(y,8192);
% --- Executes on button press in Sharphigh6.
function Sharphigh6_Callback(hObject, eventdata, handles)
% hObject handle to Sharphigh6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = gen_wave(35,0.3);
sound(y,8192);
% --- Executes on button press in Zuguo.
function Zuguo_Callback(hObject, eventdata, handles)
% hObject handle to Zuguo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs = 8192;
%我和我的祖国
y1 = gen_wave(20,0.3);
y2 = gen_wave(22,0.3);
y3 = gen_wave(20,0.5);
y4 = gen_wave(18,0.3);
y5 = gen_wave(17,0.3);
y6 = gen_wave(15,0.5);
y7 = gen_wave(13,1);
y8 = gen_wave(8,1.5);
y = [y1,y2,y3,y4,y5,y6,y7,y8];
%一刻也不能分割
y1 = gen_wave(13,0.3);
y2 = gen_wave(17,0.3);
y3 = gen_wave(25,0.3);
y4 = gen_wave(24,0.3);
y5 = gen_wave(22,0.3);
y6 = gen_wave(17,0.25);
y7 = gen_wave(20,1.5);
y = [y,y1,y2,y3,y4,y5,y6,y7];
%无论我走到哪里
y1 = gen_wave(22,0.3);
y2 = gen_wave(24,0.3);
y3 = gen_wave(22,0.3);
y4 = gen_wave(20,0.3);
y5 = gen_wave(18,0.3);
y6 = gen_wave(17,0.3);
y7 = gen_wave(15,1);
y8 = gen_wave(10,1.5);
y = [y,y1,y2,y3,y4,y5,y6,y7,y8];
%都流出一首赞歌
y1 = gen_wave(12,0.3);
y2 = gen_wave(10,0.3);
y3 = gen_wave(8,0.3);
y4 = gen_wave(20,0.3);
y5 = gen_wave(13,0.3);
y6 = gen_wave(15,0.3);
y7 = gen_wave(17,1.5);
y = [y,y1,y2,y3,y4,y5,y6,y7];
%我歌唱每一座高山
y1 = gen_wave(20,0.3);
y2 = gen_wave(22,0.3);
y3 = gen_wave(20,0.3);
y4 = gen_wave(18,0.3);
y5 = gen_wave(17,0.3);
y6 = gen_wave(15,0.3);
y7 = gen_wave(13,1);
y8 = gen_wave(8,1.5);
y = [y,y1,y2,y3,y4,y5,y6,y7,y8];
%我歌唱每一条河
y1 = gen_wave(13,0.3);
y2 = gen_wave(17,0.3);
y3 = gen_wave(25,0.3);
y4 = gen_wave(24,0.3);
y5 = gen_wave(27,0.3);
y6 = gen_wave(25,0.3);
y7 = gen_wave(22,1.5);
y = [y,y1,y2,y3,y4,y5,y6,y7];
%袅袅炊烟
y1 = gen_wave(25,0.3);
y2 = gen_wave(24,0.3);
y3 = gen_wave(22,0.3);
y4 = gen_wave(20,1);
y = [y,y1,y2,y3,y4];
%小小村落
y1 = gen_wave(22,0.3);
y2 = gen_wave(20,0.3);
y3 = gen_wave(18,0.3);
y4 = gen_wave(17,1);
y = [y,y1,y2,y3,y4];
%路上一道辙
y1 = gen_wave(12,0.7);
y2 = gen_wave(10,0.3);
y3 = gen_wave(8,1);
y4 = gen_wave(15,0.3);
y5 = gen_wave(13,1.5);
y = [y,y1,y2,y3,y4,y5];
sound(y,Fs);