标签:note 大学 ons temp mat filename key rate lse
参考论文
钢琴音色识别与电子合成系统的设计与实现 程美芳 电子科技大学
https://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CMFD&dbname=CMFD201601&filename=1015701190.nh&uid=WEEvREcwSlJHSldRa1FhdXNXaEhoOG5EWWFBdVllNHRmb3VmejJxakNQMD0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!&v=MDc2MjRHN1M0SDlERnI1RWJQSVI4ZVgxTHV4WVM3RGgxVDNxVHJXTTFGckNVUkxPZVp1Wm5GeUhuVTczSlZGMjY=
可优化的点:
增加bmp参数,使得乐曲可以改变tempo
代码:
主函数:
clear;
clc;
fs = 44100; % sample rate
dt = 1/fs;
T16 = 0.2;%bmp
t16 = [0:dt:T16];
[temp k] = size(t16);
t2=linspace(0,T16,8*k);
t4 = linspace(0,4*T16,4*k);
t8 = linspace(0,2*T16,2*k);
[temp i] = size(t4);
[temp j] = size(t8);
blkf = zeros(1,i);
blke = zeros(1,j);
blks = zeros(1,k);
% So-FUCKING-Long Melody
%violin1
v1 = [
blkf blkf...%1
blkf blkf...
keys(5,5,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
key(6,5,4) key(6,5,4)...
key(6,5,4) key(7,4,8) blke...
keys(5,5,4) key(1,5,8) keys(5,5,8) ...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
keys(4,5,4) keys(4,5,4)...
keys(4,5,4) keys(4,5,8) key(5,5,8)...%10
keys(5,5,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
keys(1,5,4)+keys(1,6,4) keys(1,5,4)+keys(1,6,4) ...
keys(1,5,4)+keys(1,6,4) key(7,4,8)+key(7,5,8) key(6,4,8)+key(6,5,8)...
keys(5,4,4)+key(3,5,4)+keys(5,5,4) keys(4,4,8)+keys(1,5,8)+keys(4,5,8) key(6,4,8)+key(3,5,8)...%15
key(6,4,4)+keys(1,5,4) key(7,4,4)+keys(2,5,4)...
key(3,4,4)+keys(5,4,4) key(3,4,4)+key(6,4,4)...
key(5,4,4)+keys(6,4,4) keys(4,4,4)+key(7,4,4)...
keys(5,5,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
key(6,5,4) key(6,5,4)...%21
key(6,5,4) key(7,4,8) blke...
keys(5,5,4) key(1,5,8) keys(5,5,8) ...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
keys(4,5,4) keys(4,5,4)...
keys(4,5,4) keys(4,5,8) key(5,5,8)...%26
keys(5,5,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
keys(1,5,4)+keys(1,6,4) keys(1,5,4)+keys(1,6,4) ...
keys(1,5,4)+keys(1,6,4) key(7,4,8)+keys(5,5,8)+key(7,5,8) key(6,4,8)+keys(4,5,8)+key(6,5,8)...
keys(5,4,4)+key(3,5,4)+keys(5,5,4) keys(4,4,8)+keys(1,5,8)+keys(4,5,8) key(6,4,8)+key(3,5,8)...
key(6,4,4)+keys(1,5,4) keys(5,4,8)+key(7,4,8)+keys(2,5,8) keys(4,4,8)+key(6,4,8)...%32
key(3,4,4)+keys(5,4,4) key(3,4,4)+keys(5,4,4)...
keys(4,4,4)+key(6,4,4) key(5,4,4)+keys(6,4,4)...% 34 A-minor
key(5,4,4)+key(7,4,4)+key(5,5,4) keys(4,5,8) key(3,5,8)...
key(1,5,4) key(2,5,8) key(3,5,8)...
keys(4,5,4) key(3,5,8) key(2,5,8)...%37
key(7,4,4) key(1,5,8) key(2,5,8)...
key(3,5,4) keys(4,4,8)+keys(4,5,8) key(5,4,8)+key(5,5,8)...
key(6,4,4)+key(6,5,4) key(7,4,8)+key(7,5,8) key(1,5,8)+key(1,6,8)...
key(2,5,4)+key(2,6,4) keys(4,5,8)+keys(4,6,8) key(3,5,8)+key(3,6,8)...
key(2,5,4)+key(2,6,4) blke key(1,5,8)+key(1,6,8)...%42
key(7,4,4)+key(7,5,4) key(6,4,8)+key(6,5,8) key(5,4,8)+key(5,5,8)...
key(3,4,4)+key(3,5,4) keys(4,4,8)+keys(4,5,8) key(5,4,8)+key(5,5,8)...
key(7,4,8)+key(7,5,8) key(6,4,8)+key(6,5,8) key(5,4,8)+key(5,5,8) keys(4,4,8)+keys(4,5,8)...
keys(2,4,4)+keys(2,5,4) key(3,4,8)+key(3,5,8) keys(4,4,8)+keys(4,5,8)...
key(5,4,4)+key(5,5,4) key(6,4,8)+key(6,5,8) key(7,4,8)+key(7,5,8)...%47
key(1,5,4)+key(1,6,4) key(5,5,8)+key(5,6,8) blks keys(4,5,16)+keys(4,6,16)...
key(3,5,4)+key(3,6,4) keys(2,5,8) key(3,4,8)+keys(5,4,8)+keys(1,5,8)...
key(7,4,4) keys(6,4,8) keys(2,4,8)+keys(4,4,8)+key(7,4,8)...
keys(1,5,4) key(6,4,8) keys(1,4,8)+key(3,4,8)+keys(5,4,8)...
keys(1,4,8)+key(3,4,8)+keys(4,4,8) blke key(4,4,8) key(7,3,8)+keys(2,4,8)+keys(4,4,8)...%52
key(6,4,4) key(4,4,8) keys(4,4,8)+key(6,3,8)...
key(6,4,4) key(4,4,8) keys(4,4,8)+key(7,3,8)...
key(6,4,4) key(4,4,8) keys(4,4,8)+key(6,3,8)+keys(1,4,8)...
key(3,5,4) keys(2,5,8) keys(1,5,8)+keys(2,4,8)...
keys(5,5,4) key(7,4,8) keys(5,5,8)...%57
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
key(6,5,4) key(6,5,4)...
key(6,5,4) key(7,4,8) blke...
keys(5,5,4) key(1,5,8) keys(5,5,8) ...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...%62
keys(4,5,4) keys(4,5,8)+keys(4,4,8) key(3,5,8)...
keys(4,5,8)+keys(2,5,8) keys(1,5,8) key(7,4,8) key(6,4,8)+key(5,5,8)...
keys(5,5,4)+keys(5,4,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
keys(1,5,4)+keys(1,6,4) keys(1,5,4)+keys(1,6,4) keys(1,5,4)+keys(1,6,4) keys(2,5,8)+keys(2,6,8) key(3,5,8)+key(3,6,8)...
key(6,5,8)+key(6,6,8) keys(4,5,4)+keys(4,6,4) key(3,5,8)+key(3,6,8) key(2,5,8)+key(2,6,8) key(1,5,8)+key(1,6,8) keys(4,4,8)+keys(2,5,8)+keys(4,5,8) keys(4,4,16)+keys(2,5,16)+keys(4,5,16) keys(1,5,16)+keys(1,6,16)...
keys(1,5,8)+key(6,5,8)+keys(1,6,8) key(7,4,4)+key(7,5,4) keys(5,4,8)+keys(5,5,8) keys(4,5,8) key(3,5,8) key(7,4,8) key(7,4,16) key(1,5,16)...
key(6,5,8) keys(4,5,4) key(3,5,8)... %73
key(2,5,8) key(1,5,8) keys(4,4,8) keys(4,4,16) keys(1,5,16)...
keys(1,5,4) key(7,4,8) keys(5,4,8)...
keys(4,4,8) key(3,4,8) key(7,3,8) key(7,3,16) key(1,4,16)...
keys(1,4,8) keys(5,3,8) key(6,3,8) key(7,3,8)...
keys(1,4,8) key(6,4,8) keys(5,4,8) keys(4,4,8)...%78
key(3,4,8) key(1,4,8) keys(1,4,8) keys(2,4,8)...
key(3,4,8) key(3,5,8)+key(3,6,8) keys(2,5,8)+keys(2,6,8) keys(1,5,8)+keys(1,6,8)...
key(7,4,8)+key(7,5,8) keys(2,5,8) keys(4,4,8)+keys(4,5,8) key(3,4,8)+key(3,5,8)...
keys(2,4,8)+keys(2,5,8) key(7,4,8)+key(7,5,8) key(7,4,8)+keys(2,5,8)+key(7,5,8) key(7,4,16)+keys(2,5,16)+key(7,5,16) keys(5,4,16)+keys(5,5,16)...
keys(5,4,4)+keys(5,5,4) keys(4,4,4)+keys(4,5,4)...%83
keys(1,4,4)+keys(1,5,4) keys(2,4,4)+keys(2,5,4)...
key(3,4,4)+keys(5,4,4)+key(3,5,4) key(7,4,8) keys(5,5,8)...
keys(4,5,8) key(3,5,8) keys(2,5,8) key(3,5,8)...
key(6,5,4) key(6,5,4)...
key(6,5,4) keys(5,5,8) keys(4,5,8)...
key(3,5,8) blke key(7,3,8) keys(5,4,8)...%89
keys(4,4,8) key(3,4,8) keys(2,4,8) key(3,4,8)...
key(6,4,4) key(6,4,4)...
key(6,4,4) keys(5,4,8) keys(4,4,8)...
key(3,4,8) key(7,3,4)+key(3,4,4) key(7,3,8)+key(3,4,8)...
key(3,4,8)+keys(5,4,8) key(3,4,4)+keys(5,4,4) keys(5,4,8)+key(7,4,8)...
key(7,4,4)+key(3,5,4) blkf...
keys(5,4,4)+key(7,4,4)+key(3,5,4)+keys(5,5,4) blkf...
keys(5,3,2)+key(3,4,2)...
keys(5,3,2)+key(3,4,2)...
keys(5,3,2)+key(3,4,2) ...
keys(5,3,2)+key(3,4,2)...
];
%violin2
v2 = [
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%5
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%10
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%15
blkf blkf key(3,5,2) key(3,5,2) blkf blkf blkf blkf blkf blkf...%21
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%26
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%32
key(3,5,2) key(3,5,2) blkf blkf blkf blkf blkf blkf... %37
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%42
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%47
blkf blkf ...
blke key(3,4,4)+keys(5,4,4) blke...
blke keys(2,4,4)+keys(4,4,4) blke...
blke keys(1,4,4)+key(3,4,4) blke...
blke key(7,3,4)+keys(2,4,4) blke...%52
blke key(6,3,4)+key(3,4,4) blke...
blke key(7,3,4)+keys(2,4,4) blke...
blke keys(1,4,4)+key(6,3,4) blke...
blke keys(4,4,4) blke...
blkf blkf...%57
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%62
blkf blkf blkf blkf blkf blkf blkf blkf...
blkf blkf blkf blkf blkf blkf blkf blkf...
blkf blkf blkf blkf blkf blkf blkf blkf... %74
key(3,4,2) keys(1,4,4) blkf blkf blkf blkf blkf...%78
blkf blkf blkf blkf blkf blkf blkf blkf keys(1,5,2)...%83
key(6,4,4) key(6,4,4) blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%89
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf ...
];
%cello1
c1= [
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(4,3,4)+keys(1,4,4)+key(3,4,4) keys(4,3,8)+keys(1,4,8)+key(3,4,8)...
blke keys(4,3,4)+key(7,3,4)+keys(2,4,4) key(7,3,8)+keys(2,4,8)...
blke keys(5,3,8)+key(7,3,8)+key(3,4,8) blke keys(5,3,8)+key(1,4,8)...
blke keys(1,4,4)+key(3,4,4) keys(1,4,8)+key(3,4,8)...
blke keys(4,3,4)+key(7,3,4)+key(3,4,4) keys(4,3,8)+keys(6,3,8)+key(3,4,8)...
blke key(7,3,4)+keys(2,4,4) key(7,3,8)+keys(2,4,8)...%10
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4) keys(5,3,8)+key(7,3,8)...
blke keys(1,4,8)+key(3,4,8) blke keys(1,4,8)+key(4,4,8)...
keys(4,2,8)+keys(4,3,8) keys(1,4,8)+key(6,4,8) keys(5,4,8) keys(1,4,8)+keys(4,4,8)...
key(7,1,8) keys(5,3,8)+key(7,3,8) key(6,3,8)+keys(1,4,8) keys(1,4,8)+key(3,4,8)...%15
blke keys(4,3,4)+key(7,3,4) key(6,3,8)+key(7,3,8)...
key(3,2,8) key(3,3,4) key(3,3,8)...
key(3,3,8) key(3,3,8) keys(2,3,8) key(7,2,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(4,3,4)+keys(1,4,4)+key(3,4,4) keys(4,3,8)+keys(1,4,8)+key(3,4,8)...%21
blke keys(4,3,4)+key(7,3,4)+keys(2,4,4) key(7,3,8)+keys(2,4,8)...
blke keys(5,3,8)+key(7,3,8)+key(3,4,8) blke keys(5,3,8)+key(1,4,8)...
blke keys(1,4,4)+key(3,4,4) keys(1,4,8)+key(3,4,8)...
blke keys(4,3,4)+key(7,3,4)+key(3,4,4) keys(4,3,8)+keys(6,3,8)+key(3,4,8)...
blke key(7,3,4)+keys(2,4,4) key(7,3,8)+keys(2,4,8)...%26
blke key(7,3,4)+key(3,4,4) key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4) keys(5,3,8)+key(7,3,8)...
blke keys(1,4,8)+key(3,4,8) blke keys(1,4,8)+key(4,4,8)...
keys(4,2,8)+keys(4,3,8) keys(1,4,8)+key(6,4,8) keys(5,4,8) keys(1,4,8)+keys(4,4,8)...
blke keys(5,3,8)+key(7,3,8) key(6,3,8)+keys(1,4,8) keys(1,4,8)+key(3,4,8)...
blke key(6,3,4)+key(7,3,4) key(7,3,8)...%32
key(3,2,8) key(3,3,8) blke key(3,3,8)...
key(3,3,8) key(3,3,4) key(3,3,8)...
blke key(7,3,4)+key(2,4,4) key(7,3,8)+key(2,4,8)...
blke key(6,3,4)+key(1,4,4) key(6,3,8)+key(1,4,8)...
blke key(6,3,4)+key(2,4,4) key(6,3,8)+key(2,4,8)...%37
blke key(7,3,4)+key(2,4,4) key(7,3,8)+key(2,4,8)...
blke key(5,3,4)+key(1,4,4) key(5,3,8)+key(1,4,8)...
blke key(1,4,4)+key(2,4,4) key(1,4,8)+key(2,4,8)...
key(7,3,8) key(5,3,8) keys(1,4,8) key(5,3,8)...
key(6,3,8) keys(4,3,4) keys(4,3,8)...%42
blke key(5,3,4)+key(7,3,4)+key(2,4,4) key(5,3,8)+key(7,3,8)+keys(2,4,8)...
blke key(5,3,4)+key(7,3,4) key(5,3,8)+key(7,3,8)...
blke key(6,3,4)+key(1,4,4) key(6,3,8)+key(1,4,8)...
blke key(6,3,4)+key(7,3,4) key(6,3,8)+key(7,3,8)...
blke key(5,3,4)+key(7,3,4) key(5,3,8)+key(7,3,8)...%47
blke key(1,4,4)+key(3,4,4) key(6,3,8)+key(7,3,8)+keys(2,4,8)...
blkf blkf blkf blkf blkf blkf blkf blkf...%52
blke key(1,3,4)+keys(4,3,4) key(1,3,8)+keys(4,3,8)...
blke key(6,3,4)+keys(4,3,4) key(6,3,8)+keys(4,3,8)...
blke keys(1,3,4)+keys(4,3,4) keys(1,3,8)+keys(4,3,8)...
blke key(6,3,4)+key(7,3,4) keys(6,3,8)+key(7,3,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...%57
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(4,3,4)+keys(1,4,4)+key(3,4,4) keys(4,3,8)+keys(1,4,8)+key(3,4,8)...
blke keys(4,3,4)+key(7,3,4)+keys(2,4,4) key(7,3,8)+keys(2,4,8)...
blke keys(5,3,8)+key(7,3,8)+key(3,4,8) blke keys(5,3,8)+key(1,4,8)...
blke keys(5,3,4)+keys(1,4,4)+key(3,4,4) keys(5,3,8)+key(3,4,8)...%62
blke keys(6,3,4)+key(3,4,4) keys(6,3,8)+keys(1,4,8)...
blke key(6,3,4)+key(7,3,4) key(6,3,8)+key(7,3,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(1,4,4)+key(3,4,4) keys(1,4,8)+keys(4,4,8)...
blke keys(1,4,4)+keys(4,4,4)+key(6,4,4) keys(1,4,8)+keys(4,4,8)...
keys(4,2,8) key(1,4,8)+key(3,4,8)+key(6,4,8) key(1,4,8)+key(3,4,8)+key(6,4,8) key(1,4,8)+key(3,4,8)+key(6,4,8)...
key(6,3,8)+key(3,4,8)+key(6,4,8) key(6,3,8)+key(3,4,8)+key(6,4,8) key(7,3,8)+keys(2,4,8) key(6,3,8)...
blke key(7,4,8)+key(3,4,8) key(7,4,8)+key(3,4,8) key(7,4,8)+key(3,4,8)...
key(7,4,8)+key(3,4,8) key(7,4,8)+key(3,4,8) blke key(7,4,8)+key(3,4,8)...%72
blke key(6,3,8)+keys(1,4,8)+key(3,4,8) key(6,3,8)+keys(1,4,8)+key(3,4,8) key(6,3,8)+keys(1,4,8)+key(3,4,8)...
key(6,3,8)+key(3,4,8) key(6,3,8)+key(3,4,8) key(7,3,8)+keys(2,4,8) key(6,3,8)+keys(2,4,8)...
keys(5,2,8) key(3,3,8) key(5,3,4)...
keys(1,2,8) keys(5,2,8) key(3,3,8) keys(4,3,8) ...
keys(1,2,4)+key(6,2,4) key(7,1,4)+keys(4,2,4) ...
keys(1,2,4)+key(6,2,4) key(6,3,4)+keys(1,4,4)...%78
keys(1,2,8) keys(4,3,4)+key(6,3,4) key(3,3,8)+keys(5,3,8)...
keys(6,2,4) keys(6,3,4)+key(3,4,4)+key(5,4,4) ...
key(6,3,8)+keys(2,4,8)+keys(4,4,8) keys(6,2,8) keys(5,2,8) key(7,3,8)...
keys(4,2,8) key(6,3,8) key(4,2,4)...
keys(4,2,2)+keys(6,3,2)...%83
blkf blkf...
blke key(3,3,4)+key(7,3,4) key(3,3,8)+key(7,3,8)+key(3,4,8)...
blke keys(5,3,4)+key(7,3,4)+key(3,4,4) keys(5,3,8)+key(7,3,8)+key(3,4,8)...
blke key(6,3,4)+key(1,4,4) key(6,3,8)+keys(1,4,8)...
blke key(6,3,4)+key(2,4,4) key(6,3,8)+keys(2,4,8)...
blke key(7,2,4)+key(3,3,4) key(7,2,8)+key(3,3,8)...
blke key(3,3,4)+key(7,3,4) key(3,3,8)+key(7,3,8)...
blke keys(4,3,4)+key(6,3,4) keys(4,3,8)+key(6,3,8)...
blke keys(4,3,4)+key(7,3,4) key(6,3,8)+key(7,3,8)...
keys(1,2,8) keys(5,3,4) keys(5,3,8)...
key(7,3,8) key(7,3,4) key(3,4,8)...
keys(5,4,4) blkf...
key(3,3,4)+key(7,3,4)+key(3,4,4) blkf...
key(3,2,4) key(7,2,4) key(3,2,4) key(7,2,4)...
keys(3,1,2) keys(3,1,2)...
];
% cello2
c2=[
key(3,3,2) key(3,3,2) key(3,3,2) keys(5,2,2) keys(4,2,2)...%5
key(7,2,2) key(3,3,4) keys(2,3,4) keys(1,3,2) keys(4,2,2) key(7,2,2)...%10
key(3,2,2) keys(5,2,2) key(6,2,4) keys(5,2,4) blkf blkf blkf blkf... %15
key(7,1,4) key(7,2,4) blkf blkf blkf blkf key(3,2,2) keys(5,2,2) keys(4,2,2)...%21
key(7,2,2) key(3,3,4) keys(2,3,4) keys(1,3,2) keys(4,2,2) key(7,2,2)...%26
key(3,2,2) keys(5,2,2) key(6,2,4) keys(5,2,4) blkf blkf...
key(7,1,4) blkf key(7,1,4) key(7,2,4)...%31
blkf key(7,3,4) key(1,4,4) keys(1,4,4) key(2,3,2) key(2,3,2) key(2,3,2)...%37
key(2,3,2) key(1,3,2) key(2,3,2) key(2,3,2) key(2,3,2)...%42
key(5,3,2) key(5,3,2) keys(4,3,2) key(7,3,2) key(7,3,2)...%47
key(6,2,2) key(7,2,2)+keys(5,3,2) key(7,2,2)+key(6,3,2)...
key(7,2,2)+keys(5,3,2) key(7,2,2)+key(6,3,2)...%52
keys(4,2,2) key(7,2,2) keys(4,2,2) key(7,2,2) key(3,2,2)...%57
keys(5,2,2) keys(4,2,2)...
key(7,2,2) key(3,3,4) keys(2,3,4) keys(1,3,2)...%62
keys(4,2,2) key(7,2,2) key(3,2,2) keys(5,2,2)...
key(6,2,4) keys(5,2,4) keys(4,2,2)+keys(4,3,2)...
blkf blkf blkf blkf ...
keys(5,2,2) blkf keys(5,2,4)...
keys(4,2,2) blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...
blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...%83
key(7,1,2) key(3,2,2)...
keys(5,2,2) keys(4,2,2)...
key(7,2,2) key(3,2,2)...%89
keys(5,2,2) keys(4,2,2)...
key(7,2,2) blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf blkf...
];
% Get dirty
s = v1+v2+c1+c2;
pause(1);
sound(s,fs);
Key函数:
function g=key(n, o ,t)
fs = 44100; % sample rate
dt = 1/fs;
T16 = 0.2;%bmp
t16 = [0:dt:T16];
[temp k] = size(t16);
t2=linspace(0,8*T16,8*k);
t4 = linspace(0,4*T16,4*k);
t8 = linspace(0,2*T16,2*k);
[temp i] = size(t4);
[temp j] = size(t8);
% Modification functions
mod2 =sin(pi*t2/t2(end));
mod4 = sin(pi*t4/t4(end));
mod8 = sin(pi*t8/t8(end));
mod16 = sin(pi*t16/t16(end));
note=[16.352 18.354 20.602 21.827 24.5 27.500 30.868];
f=note(n)*power(2,o);
Phy=0:1/3:8/3;
if(t==2)
x=t2;
elseif(t==4)
x=t4;
elseif(t==8)
x=t8;
elseif(t==16)
x=t16;
end
n=1;
[t1,t2]=size(x);
y=zeros(n,t2);
for i=1:n
y(i,:)=piano([f],Phy(i),x);
end
g=y;
keys函数
function g=keys(n, o ,t)
fs = 44100; % sample rate
dt = 1/fs;
T16 = 0.2;%bmp
t16 = [0:dt:T16];
[temp k] = size(t16);
t2=linspace(0,8*T16,8*k);
t4 = linspace(0,4*T16,4*k);
t8 = linspace(0,2*T16,2*k);
[temp i] = size(t4);
[temp j] = size(t8);
% Modification functions
mod2 =sin(pi*t2/t2(end));
mod4 = sin(pi*t4/t4(end));
mod8 = sin(pi*t8/t8(end));
mod16 = sin(pi*t16/t16(end));
note=[17.324 19.445 0 23.125 25.927 29.135 0];
Phy=0:1/3:16/3;
f=note(n)*power(2,o);
Phy=0:1/3:8/3;
if(t==2)
x=t2;
elseif(t==4)
x=t4;
elseif(t==8)
x=t8;
elseif(t==16)
x=t16;
end
n=1;
[t1,t2]=size(x);
y=zeros(n,t2);
for i=1:n
y(i,:)=piano([f],Phy(i),x);
end
g=y;
paino函数:
function Y=piano(F,phy,t)
f=F.*(1:30);
Af=[440*1,987.8;440*2,368.6;440*3,620.2;440*4,483.9;440*5,156.7;440*6,83.62;440*7,120.1;440*8,70.73; 440*9,5.348;440*10,24.41;440*11,27.35;440*12,21.3;440*13,10.31;440*14,6.477;440*15,15.91;440*16,3.495;440*17,2.546;440*18,0.4751;440*19,0.8858;440*20,0.3792;440*21,0.6012;440*22,0.4224;440*23,0.1538;440*24,0.1454;440*25,0.2032;440*26,0.0483];
[n1,n2]=size(t);
y=zeros(25,n2);
for i=1:25
y(i,:)=1.5e-4.*Af(i,2).*exp(-2.5.*(t-phy)).*heaviside(t-phy).*sin(2.*pi.*f(i).*(t-phy));
end
Y=sum(y);end
标签:note 大学 ons temp mat filename key rate lse
原文地址:https://www.cnblogs.com/R-leporis/p/11822278.html