matlab音乐分析代码,matlab音乐代码.docx

matlab音乐代码

functionliyugang() ??%Matlab版《新贵妃醉酒》 ??words1 = [3 5 6 1 7 1 7 5 7 7 6 3 5 6 1 6 1 6 2 5 5 3; ??????????0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0; ??????????0.5 0.5 1 1 0.5 0.25 0.25 0.5 0.5 1 2 0.5 0.5 1 1 0.5 0.25 0.25 0.5 0.5 1 3]; words2 = [6 3 2 7 6 1 6 5 3 5 3 2 1 6 5 1 1 6 3 5 6 1 7 5 7 7 6; ??????????0 1 1 0 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0; ??????????1 1 0.5 0.5 0.5 0.25 0.25 0.5 0.5 3 1 1 0.5 0.5 0.5 0.5 1 2 0.5 0.5 1 1 1 0.5 0.5 1 2]; words3 = [3 5 6 1 6 2 5 5 3 6 3 2 7 6 1 6 5 3 5 3 2 1 6 5 1 1 6; ??????????0 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 1 0 0 1 1 0; ??????????0.5 0.5 1 1 1 0.5 0.5 1 3 1 1 0.5 0.5 0.5 0.25 0.25 0.5 0.5 3 1 1 0.5 0.5 0.5 0.5 1 3]; ??y1 = generaterhythm(words1, 3); % in bE tune y2 = generaterhythm(words2, 3); % in bE tune y3 = generaterhythm(words3, 3); % in bE tune ??lxg = [y1,y2,y3]; sound(lxg,12000); % play it! %% generate a piece of rhythm functiony = generaterhythm(rhythm, basetune) fs = 8000; soundpos = [0 2 4 5 7 9 11 0:12]; y = zeros(1, sum(rhythm(3,:))*fs + 1); % initialize curpos = 1; forcount = 1 : length(rhythm) cursoundname = rhythm(1, count); cursoundpos = soundpos(cursoundname); curfreq = 220 * 2 .^ ((cursoundpos + basetune + 3) / 12 + rhythm(2, count)); cursound = generatetune(curfreq, rhythm(3, count), fs); y(1,curpos:(curpos + length(cursound) - 1)) = cursound; curpos = curpos + length(cursound); endfunctiony = generatetune (freq, time, fs) y1 = generatetune2 (freq + 3, time, fs); y2 = generatetune2 (freq - 3, time, fs); y3 = generatetune2 (freq, time, fs); y = (y1 + y2) / 8 + y3 * (3 / 4); functiony = generatetune2 (freq, time, fs) c = [ 1 0.2 0.4 0.08 0.2 0.05 0.1 0.04 ]; t = 0:1/fs:(time - 1/fs); y = zeros(1, length(t)); forj = 1 : 8 ????y = y + c(j) * sin(t*j*freq*2*pi); endforcount1 = 1 : length(y) ????y(1, count1) = y(1, count1) * amendment(count1 / 2000, length(y) / 2000); endfunctiony = amendment(p, l) ifp < 0.2 y = p * 5; elseifp < 0.3 y = 1.8 - p * 4; else????y = 0.6 * exp((0.3 - p)/5);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值