matlab 董小姐,用matlab演奏一曲《董小姐》【源代码】

本帖最后由 青年梦想家 于 2015-11-19 21:27 编辑

%《董小姐》

%原词曲:宋东野

%现曲:MATLAB 制作人:LG

%曲谱见:

%%

clc;

clear all;

close all;

fs = 44100;%采样率

dt = 1/fs;

T16=0.25;% E4/4时长0.25s

t16 = 0:dt:T16;

[temp, k] = size(t16);

t4 = linspace(0,4*T16,4*k);

t8 = linspace(0,2*T16,2*k);

t3_16 = linspace(0,3*T16,3*k);

[temp, i] = size(t4);

[temp, j] = size(t8);

f = 440*(1/2)^(5/12);% E大调

d = 2^(1/12);

% Modification functions

mod4 = sin(pi*t4/t4(end));

mod8 = sin(pi*t8/t8(end));

mod16 = sin(pi*t16/t16(end));

%休止符

blk4 = zeros(1,i);%4分休止符

blk8 = zeros(1,j);%8分休止符

blk16 = zeros(1,k);%16分休止符

%4分音符

one4 = mod4.*sin(2*pi*f*d^1*t4);

two4 = mod4.*sin(2*pi*f*d^3*t4);

three4 = mod4.*sin(2*pi*f*d^5*t4);

four4 = mod4.*sin(2*pi*f*d^6*t4);

five4 = mod4.*sin(2*pi*f*d^8*t4);

six4 = mod4.*sin(2*pi*f*d^10*t4);

seven4 = mod4.*sin(2*pi*f*d^12*t4);

upone4 = mod4.*sin(2*pi*f*d^13*t4);

uptwo4 = mod4.*sin(2*pi*f*d^15*t4);

upthree4 = mod4.*sin(2*pi*f*d^17*t4);

%8分音符

one8 = mod8.*sin(2*pi*f*d^1*t8);

two8 = mod8.*sin(2*pi*f*d^3*t8);

three8 = mod8.*sin(2*pi*f*d^5*t8);

four8 = mod8.*sin(2*pi*f*d^6*t8);

five8 = mod8.*sin(2*pi*f*d^8*t8);

six8 = mod8.*sin(2*pi*f*d^10*t8);

seven8 = mod8.*sin(2*pi*f*d^12*t8);

upone8 = mod8.*sin(2*pi*f*d^13*t8);

uptwo8 = mod8.*sin(2*pi*f*d^15*t8);

upthree8 = mod8.*sin(2*pi*f*d^17*t8);

%16分音符

one16 = mod16.*sin(2*pi*f*d^1*t16);

two16 = mod16.*sin(2*pi*f*d^3*t16);

three16 = mod16.*sin(2*pi*f*d^5*t16);

four16 = mod16.*sin(2*pi*f*d^6*t16);

five16 = mod16.*sin(2*pi*f*d^8*t16);

six16 = mod16.*sin(2*pi*f*d^10*t16);

seven16 = mod16.*sin(2*pi*f*d^12*t16);

upone16 = mod16.*sin(2*pi*f*d^13*t16);

uptwo16 = mod16.*sin(2*pi*f*d^15*t16);

upthree16 = mod16.*sin(2*pi*f*d^17*t16);

upfive16 = mod16.*sin(2*pi*f*d^20*t16);

% 连音符

mod3_16 = sin(pi*t3_16/t3_16(end));

one3_16 = mod3_16.*sin(2*pi*f*d^1*t3_16);

two3_16 = mod3_16.*sin(2*pi*f*d^3*t3_16);

three3_16 = mod3_16.*sin(2*pi*f*d^5*t3_16);

four3_16 = mod3_16.*sin(2*pi*f*d^6*t3_16);

five3_16 = mod3_16.*sin(2*pi*f*d^8*t3_16);

six3_16 = mod3_16.*sin(2*pi*f*d^10*t3_16);

seven3_16 = mod3_16.*sin(2*pi*f*d^12*t3_16);

upone3_16 = mod3_16.*sin(2*pi*f*d^13*t3_16);

uptwo3_16 = mod3_16.*sin(2*pi*f*d^15*t3_16);

upthree3_16 = mod3_16.*sin(2*pi*f*d^17*t3_16);

%曲谱

melody = [blk4 five8 upone16 six3_16 blk8 blk8 six16 six16 six16 six16...

seven8 five8 five16 six16 five3_16 three8 blk16 two16 three16 two16...

three8 two16 five16 five4 blk8 two8 five8 two8...

five8 three8 blk4 blk4 blk4...

blk4 five8 upone16 six3_16 blk8 blk16 six16 seven16 five16...

seven16 seven8 five16 seven8 five16 seven3_16 six8 blk8 five16 five16...

six8 six16 six3_16 five8 blk4 three16 two8 three16...

one4 blk4 blk4 blk4...

blk4 five8 upone16 six3_16 blk8 blk8 six16 six16...

seven16 seven3_16 seven8 five16 seven16 seven16 six16 six8 blk8 three16 five16...

six8 five16 six16 five8 five3_16 six16 five8 two16 two8 five16 five16...

five8 three3_16 blk4 blk4 blk4...

blk4 five8 upone16 six3_16 blk8 six16 seven8 seven16...

seven16 five16 five8 upone8 uptwo16 upone8 six3_16 blk16 five16 six16 five16...

six4 blk16 five16 six16 six16 five3_16 seven3_16 seven16 upone16...

upone4 upone4 blk4 blk4...

blk8 upthree16 upthree16 upthree8 uptwo16 upthree8 uptwo8 uptwo16 uptwo8 upone16 upthree16...

upthree16 upthree3_16 five8 upone16 six3_16 blk8 blk8 blk16 five16...

upthree8 upthree16 uptwo16 upthree8 uptwo16 upthree8 uptwo8 uptwo16 upone16 upone8 five16...

five16 upthree8 upthree16 upthree4 blk4 blk4...

upthree8 six8 upthree8 upfive16 upthree16 upthree16 uptwo3_16 blk16 upone16 upone16 uptwo16...

upthree8 five8 upthree8 uptwo16 five8 six3_16 blk16 six16 six16 five16...

five8 five16 upone8 upone3_16 blk4 five8 upone16 upone16...

one4 blk4 blk4 blk16 six16 six16 five16...

five8 five16 upone8 upone3_16 blk4 five8 upone16 upone16...

one4 blk4 blk4 blk4...

blk4 blk4 blk4 blk4...

blk4 blk4 blk4 blk4...

five8 five16 upone8 upone3_16 blk4 five8 upone16 upone16...

one4 blk4 blk4 blk4...

blk4 blk4 blk4 blk4...

];

sound(melody, fs);

%%

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值