欢迎来到天天文库
浏览记录
ID:21569995
大小:41.50 KB
页数:14页
时间:2018-10-23
《matlab合成音乐》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、MATLAB合成的音乐%只要把程序复制在MATlab里运行一下就可以播放下面这段音乐!希望大家喜欢!fs=44100;%sampleratedt=1/fs;T16=0.125;t16=[0:dt:T16];[tempk]=size(t16);t4=linspace(0,4*T16,4*k);t8=linspace(0,2*T16,2*k);[tempi]=size(t4);[tempj]=size(t8);%Modificationfunctionsmod4=sin(pi*t4/t4(end));mod8=sin(pi*t8/t8(end));mod
2、16=sin(pi*t16/t16(end));f0=2*146.8;%referencefrequencyScaleTable=[2/33/45/615/16...19/85/44/33/25/39/515/8...29/45/28/3310/315/44...1/29/165/8];%1/4notesdo0f=mod4.*cos(2*pi*ScaleTable(21)*f0*t4);re0f=mod4.*cos(2*pi*ScaleTable(22)*f0*t4);mi0f=mod4.*cos(2*pi*ScaleTable(23)*f0*t4)
3、;fa0f=mod4.*cos(2*pi*ScaleTable(1)*f0*t4);so0f=mod4.*cos(2*pi*ScaleTable(2)*f0*t4);la0f=mod4.*cos(2*pi*ScaleTable(3)*f0*t4);ti0f=mod4.*cos(2*pi*ScaleTable(4)*f0*t4);do1f=mod4.*cos(2*pi*ScaleTable(5)*f0*t4);re1f=mod4.*cos(2*pi*ScaleTable(6)*f0*t4);mi1f=mod4.*cos(2*pi*ScaleTable(
4、7)*f0*t4);fa1f=mod4.*cos(2*pi*ScaleTable(8)*f0*t4);so1f=mod4.*cos(2*pi*ScaleTable(9)*f0*t4);la1f=mod4.*cos(2*pi*ScaleTable(10)*f0*t4);tb1f=mod4.*cos(2*pi*ScaleTable(11)*f0*t4);ti1f=mod4.*cos(2*pi*ScaleTable(12)*f0*t4);do2f=mod4.*cos(2*pi*ScaleTable(13)*f0*t4);re2f=mod4.*cos(2*p
5、i*ScaleTable(14)*f0*t4);mi2f=mod4.*cos(2*pi*ScaleTable(15)*f0*t4);fa2f=mod4.*cos(2*pi*ScaleTable(16)*f0*t4);so2f=mod4.*cos(2*pi*ScaleTable(17)*f0*t4);la2f=mod4.*cos(2*pi*ScaleTable(18)*f0*t4);ti2f=mod4.*cos(2*pi*ScaleTable(19)*f0*t4);do3f=mod4.*cos(2*pi*ScaleTable(20)*f0*t4);bl
6、kf=zeros(1,i);%1/8notesfa0e=mod8.*cos(2*pi*ScaleTable(1)*f0*t8);so0e=mod8.*cos(2*pi*ScaleTable(2)*f0*t8);la0e=mod8.*cos(2*pi*ScaleTable(3)*f0*t8);ti0e=mod8.*cos(2*pi*ScaleTable(4)*f0*t8);do1e=mod8.*cos(2*pi*ScaleTable(5)*f0*t8);re1e=mod8.*cos(2*pi*ScaleTable(6)*f0*t8);mi1e=mod8
7、.*cos(2*pi*ScaleTable(7)*f0*t8);fa1e=mod8.*cos(2*pi*ScaleTable(8)*f0*t8);so1e=mod8.*cos(2*pi*ScaleTable(9)*f0*t8);la1e=mod8.*cos(2*pi*ScaleTable(10)*f0*t8);tb1e=mod8.*cos(2*pi*ScaleTable(11)*f0*t8);ti1e=mod8.*cos(2*pi*ScaleTable(12)*f0*t8);do2e=mod8.*cos(2*pi*ScaleTable(13)*f0*
8、t8);re2e=mod8.*cos(2*pi*ScaleTable(14)*f0*t8);mi2e=mod
此文档下载收益归作者所有