之前同学用Matlab编了一首《蜜雪冰城主题曲》,甚是有趣。而今天在b站刷到有up主用C++演奏《起风了》,遂将代码记录如下。
实现原理:通过引入
flip是Integer型参数,代表音的高低,相邻为半音,如60和61,隔1为全音,如63和65
volume为设备的音量值,普遍使用的是0-100之间的值
channel为通道,默认使用0即可。
#include
#include
#pragma comment(lib,"winmm.lib")
using namespace std;
enum Scale
{
Rest = 0, C8 = 108, B7 = 107, A7s = 106, A7 = 105, G7s = 104, G7 = 103, F7s = 102, F7 = 101, E7 = 100,
D7s = 99, D7 = 98, C7s = 97, C7 = 96, B6 = 95, A6s = 94, A6 = 93, G6s = 92, G6 = 91, F6s = 90, F6 = 89,
E6 = 88, D6s = 87, D6 = 86, C6s = 85, C6 = 84, B5 = 83, A5s = 82, A5 = 81, G5s = 80, G5 = 79, F5s = 78,
F5 = 77, E5 = 76, D5s = 75, D5 = 74, C5s = 73, C5 = 72, B4 = 71, A4s = 70, A4 = 69, G4s = 68, G4 = 67,
F4s = 66, F4 = 65, E4 = 64, D4s = 63, D4 = 62, C4s = 61, C4 = 60, B3 = 59, A3s = 58, A3 = 57, G3s = 56,
G3 = 55, F3s = 54, F3 = 53, E3 = 52, D3s = 51, D3 = 50, C3s = 49, C3 = 48, B2 = 47, A2s = 46, A2 = 45,
G2s = 44, G2 = 43, F2s = 42, F2 = 41, E2 = 40, D2s = 39, D2 = 38, C2s = 37, C2 = 36, B1 = 35, A1s = 34,
A1 = 33, G1s = 32, G1 = 31, F1s = 30, F1 = 29, E1 = 28, D1s = 27, D1 = 26, C1s = 25, C1 = 24, B0 = 23,
A0s = 22, A0 = 21
};
enum Voice
{
X1 = C2, X2 = D2, X3 = E2, X4 = F2, X5 = G2, X6 = A2, X7 = B2,
L1 = C3, L2 = D3, L3 = E3, L4 = F3, L5 = G3, L6 = A3, L7 = B3,
M1 = C4, M2 = D4, M3 = E4, M4 = F4, M5 = G4, M6 = A4, M7 = B4,
H1 = C5, H2 = D5, H3 = E5, H4 = F5, H5 = G5, H6 = A5, H7 = B5,
LOW_SPEED = 500, MIDDLE_SPEED = 400, HIGH_SPEED = 300,
_ = 0XFF
};
// 起风了
void Wind()
{
HMIDIOUT handle;
midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);
midiOutShortMsg(handle, 34 << 8 | 0xC0);
int volume = 0x7f;
int voice = 0x0;
int sleep = 1000;
int wind[] =
{
400,0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,0,L7,M1,M2,M3,300,L2,0,M5,M3,M2,M3,M1,M2,L7,M1,300,L5,0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,0,L7,M1,M2,M3,300,L2,0,M5,M3,M2,M3,M1,M2,L7,M1,300,L5,
0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,0,L7,M1,M2,M3,300,L2,0,M5,M3,M2,M3,M1,M2,L7,M1,300,L5,0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,
0,M6,M3,M2,L6,M3,L6,M2,M3,L6,_,_,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M1,300,M2,700,0,M1,M2,M3,M2,M1,300,L5,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M3,300,M2,0,M1,700,300,M2,_,_,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M3,300,M2,0,M1,700,300,L6,_,
0,M3,M2,M1,M2,300,M1,_,0,M3,M2,M1,M2,300,M1,700,0,L5,M3,M2,M1,M2,300,M1,_,_,_,
M1,M2,M3,M1,M6,0,M5,M6,300,_,700,0,M1,300,M7,0,M6,M7,300,_,_,M7,0,M6,M7,300,_,M3,0,H1,H2,H1,M7,300,M6,M5,M6,0,M5,M6,_,M5,M6,M5,300,M6,0,M5,M2,300,_,0,M5,700,300,M3,_,_,_,
M1,M2,M3,M1,M6,0,M5,M6,300,_,700,0,M1,300,M7,0,M6,M7,300,_,_,M7,0,M6,M7,300,_,M3,0,H1,H2,H1,M7,300,M6,M5,M6,0,H3,H3,300,_,M5,M6,0,H3,H3,300,_,0,M5,700,300,M6,_,_,_,_,_,
H1,H2,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H2,0,H1,M6,300,_,0,H1,H1,300,H2,0,H1,300,M6,700,0,_,300,H1,700,H3,_,0,H3,H4,H3,H2,H3,300,H2,700,
H1,H2,H3,0,H6,H5,_,H6,H5,_,H6,H5,300,_,H3,H3,0,H6,H5,_,H6,H5,_,H6,H5,700,300,H3,700,H2,0,H1,M6,700,300,
H3,700,H2,0,H1,300,M6,700,H1,H1,_,_,_,_,_,
0,M6,300,H3,700,H2,0,H1,M6,700,300,H3,H2,700,300,0,H1,M6,300,700,H1,H1,_,_,
0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,0,L7,M1,M2,M3,300,L2,0,M5,M3,M2,M3,M1,M2,L7,M1,300,L5,0,L7,M1,M2,M3,300,L3,0,M5,M3,300,L2,L5,2,_,
0,M6,M3,M2,L6,M3,L6,M2,M3,L6,_,_,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M1,300,M2,700,0,M1,M2,M3,M2,M1,300,L5,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M3,300,M2,0,M1,700,300,M2,_,_,_,
M2,700,0,M1,300,M2,700,0,M1,300,M2,M3,M5,0,M3,700,300,M2,700,0,M3,300,M2,0,M1,700,300,L6,_,
0,M3,M2,M1,M2,300,M1,_,0,M3,M2,M1,M2,300,M1,700,0,L5,M3,M2,M1,M2,300,M1,_,_,_,
M1,M2,M3,M1,M6,0,M5,M6,300,_,700,0,M1,300,M7,0,M6,M7,300,_,_,M7,0,M6,M7,300,_,M3,0,H1,H2,H1,M7,300,M6,M5,M6,0,M5,M6,_,M5,M6,M5,300,M6,0,M5,M2,300,_,0,M5,700,300,M3,_,_,_,
M1,M2,M3,M1,M6,0,M5,M6,300,_,700,0,M1,300,M7,0,M6,M7,300,_,_,M7,0,M6,M7,300,_,M3,0,H1,H2,H1,M7,300,M6,M5,M6,0,H3,H3,300,_,M5,M6,0,H3,H3,300,_,0,M5,700,300,M6,_,_,_,_,_,
H1,H2,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H2,0,H1,M6,300,_,0,H1,H1,300,H2,0,H1,300,M6,700,0,_,300,H1,700,H3,_,0,H3,H4,H3,H2,H3,300,H2,700,
H1,H2,H3,0,H6,H5,_,H6,H5,_,H6,H5,300,_,H3,H3,0,H6,H5,_,H6,H5,_,H6,H5,700,300,H3,700,H2,0,H1,M6,700,300,
H3,700,H2,0,H1,300,M6,700,H1,H1,_,_,_,_,_,
H1,H2,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H2,0,H1,M6,300,_,0,H1,H1,300,H2,0,H1,300,M6,700,0,_,300,H1,700,H3,_,0,H3,H4,H3,H2,H3,300,H2,700,
H1,H2,H3,0,H6,H5,_,H6,H5,_,H6,H5,300,_,H3,H3,0,H6,H5,_,H6,H5,_,H6,H5,700,300,H3,700,H2,0,H1,M6,700,300,
H3,700,H2,0,H1,300,M6,700,H1,H1,_,_,_,_,_,
H1,H2,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H3,0,H6,H5,300,_,0,H6,H5,300,_,0,H6,H5,300,_,0,H2,H3,300,H2,0,H1,M6,300,_,0,H1,H1,300,H2,0,H1,300,M6,700,0,_,300,H1,700,H3,_,0,H3,H4,H3,H2,H3,300,H2,700,
H1,H2,H3,0,H6,H5,_,H6,H5,_,H6,H5,300,_,H3,H3,0,H6,H5,_,H6,H5,_,H6,H5,700,300,H3,700,H2,0,H1,M6,700,300,
H3,700,H2,0,H1,300,M6,700,H1,H1,_,_,_,_,_,
0,M6,300,H3,700,H2,0,H1,M6,700,300,H3,H2,700,300,0,H1,M6,300,700,H1,H1,_,_,_,_,_,_,_,
};
for (auto i : wind) {
if (i == LOW_SPEED || i == HIGH_SPEED || i == MIDDLE_SPEED) {
sleep = i;//Sleep(i/2);
continue;
}
if (i == 0) { sleep = 175; continue; }
if (i == 700) { Sleep(175); continue; }
if (i == _) {
Sleep(500);
continue;
}
voice = (volume << 16) + ((i) << 8) + 0x90;
midiOutShortMsg(handle, voice);
cout << voice << endl;
Sleep(sleep);
}
midiOutClose(handle);
}
// 平凡之路
void Trivial()
{
HMIDIOUT handle;
midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);
int volume = 0x7f;
int voice = 0x0;
int sleep = 300;
int trivial[] =
{
MIDDLE_SPEED, X6,L6,M3,M1,M1,L4,M4,M1,X1,L5,M3,M1,L7,M1,M2,L5,X6,L6,M3,M1,M1,L4,M4,M1,X1,L5,M3,M1,L7,M1,M2,L5,_,_,
400,M3,M3,0,M6,M6,_,_,400,M1,M2,0,M3,M3,_,400,_,_,_,_,_,_,_,_,M3,M3,0,M6,M6,_,_,400,_,M5,M5,M4,M3,_,_,_,_,_,_,_,_,
M3,M3,M6,_,M1,M2,M3,_,_,_,_,_,_,_,M3,M3,M1,M4,0,M4,M4,_,400,M3,M1,_,_,_,
400,M3,M3,0,M6,M6,_,_,400,M1,M2,0,M3,M3,_,400,_,_,_,_,_,_,_,_,M3,M3,0,M6,M6,_,_,400,_,M5,M5,M4,M3,_,_,_,_,_,_,_,_,
M3,M3,M6,_,M1,M2,M3,_,_,_,_,_,_,_,M3,M3,M1,M4,0,M4,M4,_,400,M3,M1,_,_,_,_,_,
M5,M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300,M5,M6,M7,H1,0,M7,H1,_,M5,300,M6,M6,_,M6,0,H1,H1,_,300,H1,H1,0,H1,H2,_,M5,300,
M6,M7,H1,0,M7,H1,_,H3,700,H6,700,H5,_,H4,H3,_,H3,H2,_,M6,700,M7,H1,_,700,H1,0,H2,H1,_,H1,M7,300,H1,0,H2,_,H1,700,M7,H1,_,_,_,
400,M3,M3,0,M6,M6,_,_,400,M1,M2,0,M3,M3,_,400,_,_,_,_,_,_,_,_,M3,M3,0,M6,M6,_,_,400,_,M5,M5,M4,M3,_,_,_,_,_,_,_,_,
M3,M3,M6,_,M1,M2,M3,_,_,_,_,_,_,_,M3,M3,M1,0,M4,300,M4,M4,_,400,M3,M1,_,_,_,_,_,
};
for (auto i : trivial) {
if (i == LOW_SPEED || i == HIGH_SPEED || i == MIDDLE_SPEED) {
sleep = i;//Sleep(i/2);
continue;
}
if (i == 0) { sleep = 150; continue; }
if (i == 700) { Sleep(180); continue; }
if (i == _) {
Sleep(300);
continue;
}
voice = (volume << 16) + (i << 8) + 0x90;
midiOutShortMsg(handle, voice);
cout << voice << endl;
Sleep(sleep);
}
midiOutClose(handle);
}
// 孤勇者
void GYZ()
{
HMIDIOUT handle;
midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);
//midiOutShortMsg(handle,32<<8+0xC0);
int volume = 0x7f;
int voice = 0x0;
int sleep = 350;
int gyz[] =
{
M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,M2,L7,M1,L6,
M3,_,_,_,_,_,0,700,M1,M2,M1,300,M3,_,_,_,_,700,0,M1,M2,M1,M2,M3,300,L6,700,0,M1,300,L6,700,0,M1,300,L6,700,0,M1,300,M2,M1,L7,_,_,_,_,_,_,_,
M3,_,_,_,_,_,0,700,M1,M2,M1,300,M3,_,_,_,_,700,0,M1,M2,M1,M2,M3,300,L6,700,0,M1,300,L6,700,0,M1,300,L6,700,0,M1,300,M3,M2,L7,_,_,_,_,_,_,_,
0,L6,M1,300,M6,0,700,M6,M6,M5,300,M6,0,M6,M5,M6,M5,M6,M5,700,300,M3,700,_,_,_,_,_,0,L6,M1,300,M6,0,M6,M6,M5,M6,M5,300,M7,700,0,M7,M7,M6,300,M7,0,700,300,M6,0,M3,300,_,_,_,_,
_,0,M3,M5,M3,300,M2,700,0,M3,300,M2,700,0,M3,300,M2,700,0,M3,300,0,M5,M3,M5,M3,300,M2,700,0,M3,300,M2,700,0,M3,300,M2,_,_,0,M1,M2,300,M3,L6,M1,M3,M2,700,0,M3,M2,700,300,M1,L6,_,_,_,_,_,_,
0,M6,M7,H1,H2,M7,H1,300,H1,0,H1,M7,H1,H2,M7,H1,300,
H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,0,M6,M7,H1,H2,M7,H1,300,
H1,0,H1,M7,H1,H2,M7,H1,300,H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,
H5,H3,700,0,H5,300,H3,700,0,H5,300,0,H3,H5,H6,H3,300,H5,H5,H3,700,0,H5,300,H3,700,0,H5,H3,H5,H6,H3,300,
H5,0,H5,H5,H3,700,H2,300,H2,0,H1,H3,_,300,H2,H2,0,H1,300,M6,700,_,_,_,_,_,_,
0,H5,H5,H3,700,300,H2,H2,0,H1,H3,_,300,H2,H2,0,H1,M6,_,_,_,_,_,_,_,
_,_,_,_,_,_,_,_, _,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,0,M6,M5,300,M6,700,0,M5,M6,M5,M6,M5,300,M6,0,M6,M5,M6,M5,M6,M5,700,M3,700,M3,_,_,_,_,
0,M6,M5,300,M6,700,0,M5,M6,M5,M6,M5,300,M7,700,0,M7,M7,M6,M7,M6,700,300,M3,700,_,_,700,0,M3,M5,M3,300,M2,700,0,M3,300,M2,700,0,M3,300,M2,700,0,M3,M5,M3,M5,M3,300,M2,700,0,M3,300,M2,700,0,M3,300,M2,_,_,
0,M1,M2,300,M3,M6,H1,H3,H2,700,0,H3,300,H2,700,300,H1,M6,_,_,_,_,_,
0,M6,M7,H1,H2,M7,H1,300,H1,0,H1,M7,H1,H2,M7,H1,300,
H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,0,M6,M7,H1,H2,M7,H1,300,
H1,0,H1,M7,H1,H2,M7,H1,300,H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,
H5,H3,700,0,H5,300,H3,700,0,H5,300,0,H3,H5,H6,H3,300,H5,H5,H3,700,0,H5,300,H3,700,0,H5,H3,H5,H6,H3,300,
H5,0,H5,H5,H3,700,H2,300,H2,0,H1,H3,_,300,H2,H2,0,H1,300,M6,700,_,_,_,_,_,_,
0,H5,H5,H3,700,300,H2,H2,0,H1,H3,_,300,H2,H2,0,H1,M6,_,_,_,_,_,_,_,
L6,M1,M3,M7,_,M7,0,M7,M7,300,M6,_,_,_,_,_,_,_,_,L6,M1,M3,M7,_,M7,0,M7,M7,300,M6,_,_,_,_,_,_,_,_,
0,M6,M7,H1,H2,M7,H1,300,H1,0,H1,M7,H1,H2,M7,H1,300,
H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,0,M6,M7,H1,H2,M7,H1,300,
H1,0,H1,M7,H1,H2,M7,H1,300,H1,0,H1,H2,H3,H2,H3,H2,300,H3,0,H3,H2,300,H3,H5,H3,
H5,H3,700,0,H5,300,H3,700,0,H5,300,0,H3,H5,H6,H3,300,H5,H5,H3,700,0,H5,300,H3,700,0,H5,H3,H5,H6,H3,300,
H5,0,H5,H5,H3,700,H2,300,H2,0,H1,H3,_,300,H2,H2,0,H1,300,M6,700,_,_,_,_,_,_,
0,H5,H5,H3,700,300,H2,H2,0,H1,H3,_,300,H2,H2,0,H1,M6,_,_,_,_,_,_,_,
};
for (auto i : gyz) {
if (i == LOW_SPEED || i == HIGH_SPEED || i == MIDDLE_SPEED) {
sleep = i;//Sleep(i/2);
continue;
}
if (i == 0) { sleep = 175; continue; }
if (i == 700) { Sleep(175); continue; }
if (i == _) {
Sleep(350);
continue;
}
// if (i == 900) volume += 100;
voice = (volume << 16) + ((i) << 8) + 0x90;
midiOutShortMsg(handle, voice);
cout << voice << endl;
Sleep(sleep);
}
midiOutClose(handle);
}
// 海阔天空
void HKTK()
{
HMIDIOUT handle;
midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);
//midiOutShortMsg(handle, 34 << 8 | 0xC0);
int volume = 0x7f;
int voice = 0x0;
int sleep = 400; int tmp = 0;
int hktk[] =
{
X4,(H7 - 1),_,H6,_,_,_, H5,H4,H3,H2,_,(L7 - 1),M1,M4,(X7 - 1),_,_,_,_, (L7 - 1),M1,M4,(X7 - 1),_,_,_,_,(L7 - 1),M1,M5,M4,_,_,_,_,_,M4,_,M3,_,_,_,
1000,M3,0,M2,700,300,M1,_,_,_,_,_,_,0,M3,M4,300,M5,0,M5,M5,300,_,M6,700,M5,_,_,
0,M6,M7,300,H1,0,H1,300,H1,700,H1,H1,M7,0,M6,300,M5,700,0,M6,300,_,_,_,_,_,
M6,M5,M5,_,_,M5,M3,_,M3,M4,M3,M2,M2,0,M3,M2,300,_,_,M3,0,M2,M2,_,300,M1,M1,0,M1,M1,300,_,_,M2,M1,M1,_,_,_,_,_,_,
1000,M3,0,M2,700,300,M1,_,_,_,_,_,_,0,M3,M4,300,M5,0,M5,M5,300,_,M6,700,M5,_,_,
0,M6,M7,300,H1,0,H1,300,H1,700,H1,H1,M7,0,M6,300,M5,700,0,M6,300,_,_,_,_,_,
M6,M5,M5,_,_,M5,M3,_,M3,M4,M3,M2,M2,0,M3,M2,300,_,_,M3,0,M2,M2,_,300,M1,M1,0,M1,M1,300,_,_,M2,M1,M1,_,_,_,_,_,_,
_,0,M6,M7,300,H1,0,H1,H1,_,300,H1,M7,M6,0,M5,300,M5,700,M5,_,0,M3,300,M2,700,M1,_,_,_,_,0,H1,H1,300,H1,0,H1,H2,_,300,H2,0,H1,300,H2,700,H3,_,_,_,H3,0,H2,300,H1,700,
_,0,H1,H1,300,H1,0,H1,H2,300,_,_,_,0,M5,M5,300,H3,_,H2,_,H1,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,0,H2,H2,H1,300,M7,700,H1,_,_,_,_,_,_,_,
1000,M3,0,M2,700,300,M1,_,_,_,_,_,_,0,M3,M4,300,M5,0,M5,M5,300,_,M6,700,M5,_,_,
0,M6,M7,300,H1,0,H1,300,H1,700,H1,H1,M7,0,M6,300,M5,700,0,M6,300,_,_,_,_,_,
M6,M5,M5,_,_,M5,M3,_,M3,M4,M3,M2,M2,0,M3,M2,300,_,_,M3,0,M2,M2,_,300,M1,M1,0,M1,M1,300,_,_,M2,M1,M1,_,_,_,_,_,_,
_,0,M6,M7,300,H1,0,H1,H1,_,300,H1,M7,M6,0,M5,300,M5,700,M5,_,0,M3,300,M2,700,M1,_,_,_,_,0,H1,H1,300,H1,0,H1,H2,_,300,H2,0,H1,300,H2,700,H3,_,_,_,H3,0,H2,300,H1,700,
_,0,H1,H1,300,H1,0,H1,H2,300,_,_,_,0,M5,M5,300,H3,_,H2,_,H1,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,0,H2,H2,H1,300,M7,700,H1,_,_,_,_,_,_,_,
M6,M6,M7,M6,M7,H1,_,_,_,0,H1,H1,300,H2,H1,H2,H3,_,_,_,H3,H2,_,_,0,H2,H3,300,H1,_,_,_,_,_,
_,0,M6,M7,300,H1,0,H1,H1,_,300,H1,M7,M6,0,M5,300,M5,700,M5,_,0,M3,300,M2,700,M1,_,_,_,_,0,H1,H1,300,H1,0,H1,H2,_,300,H2,0,H1,300,H2,700,H3,_,_,_,H3,0,H2,300,H1,700,
_,0,H1,H1,300,H1,0,H1,H2,300,_,_,_,0,M5,M5,300,H3,_,H2,_,H1,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,0,H2,H2,H1,300,M7,700,H1,_,_,_,_,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,_,_,0,M5,M5,300,H3,_,H2,_,H1,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,0,H2,H2,H1,300,M7,700,H1,_,_,_,_,_,_,_,
_,0,M6,M7,300,H1,0,H1,H1,_,300,H1,M7,M6,0,M5,300,M5,700,M5,_,0,M3,300,M2,700,M1,_,_,_,_,0,H1,H1,300,H1,0,H1,H2,_,300,H2,0,H1,300,H2,700,H3,_,_,_,H3,0,H2,300,H1,700,
_,0,H1,H1,300,H1,0,H1,H2,300,_,_,_,0,M5,M5,300,H3,_,H2,_,H1,_,_,_,
_,0,H1,H1,300,H1,0,H1,H2,300,_,0,H2,H2,H1,300,M7,700,H1,_,_,_,_,_,_,_,
};
for (auto i : hktk) {
if (i == LOW_SPEED || i == HIGH_SPEED || i == MIDDLE_SPEED) {
sleep = i;//Sleep(i/2);
continue;
}
if (i == 0) { sleep = 200; continue; }
if (i == 700) { Sleep(200); continue; }
if (i == _) {
Sleep(400);
continue;
}
if (i == 1000) { tmp = +5; continue; }
// if (i == 900) volume += 100;
voice = (volume << 16) + ((i + tmp) << 8) + 0x90;
midiOutShortMsg(handle, voice);
cout << voice << endl;
Sleep(sleep);
}
midiOutClose(handle);
}
int main()
{
// Wind(); // 起风了
// Trivial(); // 平凡之路
// GYZ(); // 孤勇者
HKTK(); // 海阔天空
return 0;
}