Matlab演奏天空之城
Matlab——天空之城
主函數(shù):
Fs=8192;
y1 = air_city(6,0.25,-1);
y2 = air_city(7,0.25,-1);
y=[y1,y2];
y1 = air_city(1,0.75,0);
y2 = air_city(7,0.25,-1);
y3 = air_city(1,0.5,0);
y4 = air_city(3,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(7,1.5,-1);
y2 = air_city(3,0.5,-1);
y = [y,y1,y2];
y1 = air_city(6,0.75,-1);
y2 = air_city(5,0.25,-1);
y3 = air_city(6,0.5,-1);
y4 = air_city(1,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(5,1.5,-1);
y2 = air_city(3,0.5,-1);
y = [y,y1,y2];
y1 = air_city(4,0.75,-1);
y2 = air_city(3,0.25,-1);
y3 = air_city(4,0.25,-1);
y4 = air_city(1,0.75,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(3,1.5,-1);
y2 = air_city(1,0.5,0);
y = [y,y1,y2];
y1 = air_city(7,0.75,-1);
x2 = linspace(0, 2 * pi * 0.25, floor(Fs * 0.25));
y2 = sin(370 * x2) .* (1 - x2 / (0.25 * 2 * pi)); %低四度
x3 = linspace(0, 2 * pi * 0.5, floor(Fs * 0.5));
y3 = sin(370 * x3) .* (1 - x3 / (0.5 * 2 * pi));
y4 = air_city(1,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(7,1.5,-1);
y2 = air_city(6,0.25,-1);
y3 = air_city(7,0.25,-1);
y = [y,y1,y2,y3];
y1 = air_city(1,0.75,0);
y2 = air_city(7,0.25,-1);
y3 = air_city(1,0.5,0);
y4 = air_city(3,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(7,1.5,-1);
y2 = air_city(3,0.25,-1);
y3 = air_city(3,0.25,-1);
y = [y,y1,y2,y3];
y1 = air_city(6,0.75,-1);
y2 = air_city(5,0.25,-1);
y3 = air_city(6,0.5,-1);
y4 = air_city(1,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(5,1.5,-1);
y2 = air_city(3,0.5,-1);
y = [y,y1,y2];
y1 = air_city(4,0.5,-1);
y2 = air_city(1,0.25,0);
y3 = air_city(7,0.75,-1);
y4 = air_city(1,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(2,0.5,0);
y2 = air_city(3,0.25,0);
y3 = air_city(1,1.25,0); %1/4拍在延遲1拍
y = [y,y1,y2,y3];
y1 = air_city(1,0.25,0);
y2 = air_city(7,0.25,-1);
y3 = air_city(6,0.5,-1);
y4 = air_city(7,0.5,-1);
x5 = linspace(0, 2 * pi * 0.5, floor(Fs * 0.5));
y5 = sin(415 * x5) .* (1 - x5 / (0.5 * 2 * pi)); %低四度
y = [y,y1,y2,y3,y4,y5];
y1 = air_city(6,1.5,-1);
y2 = air_city(1,0.25,0);
y3 = air_city(2,0.25,0);
y = [y,y1,y2,y3];
y1 = air_city(3,0.75,0);
y2 = air_city(2,0.25,0);
y3 = air_city(3,0.5,0);
y4 = air_city(5,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(2,1.5,0);
y2 = air_city(5,0.5,-1);
y = [y,y1,y2];
y1 = air_city(1,0.75,0);
y2 = air_city(7,0.25,-1);
y3 = air_city(1,0.5,0);
y4 = air_city(2,0.25,0);
y5 = air_city(3,0.25,0);
y = [y,y1,y2,y3,y4,y5];
y1 = air_city(3,2,0);
y=[y,y1];
y1 = air_city(6,0.25,-1);
y2 = air_city(7,0.25,-1);
y3 = air_city(1,0.5,0);
y4 = air_city(7,0.25,-1);
y5 = air_city(1,0.25,0);
y6 = air_city(2,0.5,0);
y = [y,y1,y2,y3,y4,y5,y6];
y1 = air_city(1,0.75,0);
y2 = air_city(5,0.25,-1);
y3 = air_city(5,1,-1);
y = [y,y1,y2,y3];
y1 = air_city(4,0.5,0);
y2 = air_city(3,0.5,0);
y3 = air_city(2,0.5,0);
y4 = air_city(1,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(3,1.5,0);
y2 = air_city(3,0.5,0);
y = [y,y1,y2];
y1 = air_city(6,0.75,0);
y2 = air_city(6,0.25,0);
y3 = air_city(5,0.75,0);
y4 = air_city(5,0.25,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(3,0.25,0);
y2 = air_city(2,0.25,0);
y3 = air_city(1,0.5,0);
y4 = air_city(1,1,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(2,0.75,0);
y2 = air_city(1,0.25,0);
y3 = air_city(2,0.5,0);
y4 = air_city(5,0.5,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(3,1.5,0);
y2 = air_city(3,0.5,0);
y = [y,y1,y2];
y1 = air_city(6,0.75,0);
y2 = air_city(6,0.25,0);
y3 = air_city(5,0.75,0);
y4 = air_city(5,0.25,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(3,0.25,0);
y2 = air_city(2,0.25,0);
y3 = air_city(1,0.5,0);
y4 = air_city(1,1,0);
y = [y,y1,y2,y3,y4];
y1 = air_city(2,0.75,0);
y2 = air_city(1,0.25,0);
y3 = air_city(2,0.5,0);
y4 = air_city(7,0.5,-1);
y = [y,y1,y2,y3,y4];
y1 = air_city(6,1.5,-1);
y = [y,y1];
sound(y,Fs);
air_city調(diào)用函數(shù):
function y = air_city( tone, rythm, tend)
%tone代表音程(音的頻率)
%rythm代表拍子
%tune代表升降號,tune=1——升調(diào)(高八度),tune=-1——降調(diào)(低八度)
Fs=8192;
%低音
if tune==-1
freqs = [262, 294, 329, 349, 392, 440, 494];
x = linspace(0, 2 * pi * rythm, floor(Fs * rythm));
y = sin(freqs(tone) * x) .* (1 - x / (rythm * 2 * pi));
end
%中音
if tune==0
freqs = [523, 587, 659, 698, 783, 880,988];
x = linspace(0, 2 * pi * rythm, floor(Fs * rythm));
y = sin(freqs(tone) * x) .* (1 - x / (rythm * 2 * pi));
end
%高音
if tune ==1
freqs=[1046,1175,1318,1397,1568,1760,1967];
x=linspace(0,2 * pi* rythm,Fs * rythm);
y=sin(x * freqs(tone)).(1-x/(2 * rythm * pi));
end
end
總結(jié)
以上是生活随笔為你收集整理的Matlab演奏天空之城的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树莓派与声音传感器 python
- 下一篇: 搜狗和QQ 拼音输入法,如何输入拼音的音