clang:在 Win10 上编译 MIDI 音乐程序(一)

先从 Microsoft C++ Build Tools - Visual Studio

下载 1.73GB 安装 "Microsoft C++ Build Tools“

访问 Swift.org - Download Swift
找到 Windows 10:x86_64
下载 swift-5.10-RELEASE-windows10.exe  大约490MB
建议安装在 D:\Swift\ ,安装后大约占2.56GB

简单来说,Clang是一个编译器,目前用来编译C、C++、Objective-C语言。

where clang
D:\Swift\Toolchains\5.10.0+Asserts\usr\bin\clang.exe

cd D:\Swift\testc

短笛伴奏《荒天帝》的专属bgm《我曾爱过一个人》,编辑  huangtiandi.cpp  如下

#include <iostream>
#include <windows.h>  
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib")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
{H1 = C4, H2 = D4, H3 = E4, H4 = F4, H5 = G4, H6 = A4, H7 = B4,J1 = C5, J2 = D5, J3 = E5, J4 = F5, J5 = G5, J6 = A5, J7 = B5,K1 = C6, K2 = D6, K3 = E6, K4 = F6, K5 = G6, K6 = A6, K7 = B6,L1 = C7, L2 = D7, L3 = E7, L4 = F7, L5 = G7, L6 = A7, L7 = B7,
};
// 《荒天帝》的专属bgm《我曾爱过一个人》
int htd[] = {J1,H7,J1,H6,J5,J6,J5,J2,J4,J3,J3,J2,J3,J2,J1,J1,H7,H6,H6,J6,J5,J2,J2,J4,J3,J1,H7,J1,H6,J5,J6,J5,J2,J4,J3,J3,J2,J3,J2,J1,J1,H7,H6,J2,J3,J2,J3,J5,H5,H6,J1,H7,J1,H6,J5,J6,J5,J2,J4,J3,J3,J2,J3,J2,J1,J1,H7,H6,H6,J6,J5,J2,J2,J4,J3,J1,H7,J1,H6,J5,J6,J5,J2,J4,J3,J3,J2,J3,J2,J1,J1,H7,H6,J3,J2,J5,H5,H6,
};
// 时长数组
int shichang[] = {250,250,250,500,250,250,500,250,250,250,250,250,125,125,500,250,250,500,250,250,250,250,250,250,1000,250,250,250,500,250,250,250,250,250,250,250,250,125,125,500,250,250,500,250,250,250,250,250,250,1000,250,250,250,500,250,250,250,250,250,250,250,250,125,125,500,250,250,500,250,250,250,250,250,250,1000,250,250,250,500,250,250,250,250,250,250,250,250,125,125,500,250,250,500,500,500,250,250,1250,
};
// 力度
int lidu[] = {1,0,0,2,0,0,1,1,0,2,2,0,0,0,1,0,0,2,0,0,1,1,0,0,2,1,0,0,2,0,0,1,1,0,2,2,0,0,0,1,0,0,2,0,0,1,1,0,0,2,1,0,0,2,0,0,1,1,0,2,2,0,0,0,1,0,0,2,0,0,1,1,0,0,2,1,0,0,2,0,0,1,1,0,2,2,0,0,0,1,0,0,2,0,1,1,0,0,
};
// 演奏 《我曾爱过一个人》
void huangtiandi()
{HMIDIOUT handle;midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL); // 打开midi设备midiOutShortMsg(handle, 72 << 8 | 0xC2); // 设置通道2的乐器为 短笛unsigned char sd = 0x90 | (2 & 0x0F); // statusByte: 0为声道unsigned short note = 0;    //音符编号unsigned short v = 120; // velocity 力度值,范围通常在0-127for (int i=0; i < 98; i++) {note = htd[i];if (lidu[i] ==0) v = 40;else if(lidu[i] ==1) v = 80;else if (lidu[i] ==2) v = 120;unsigned long noteOnMsg = (((unsigned long)v <<16) | (((unsigned long)note) <<8) | (unsigned long)sd);midiOutShortMsg(handle, noteOnMsg); // 发送MIDI消息Sleep(shichang[i]); // 停顿,给音节演奏的时间midiOutShortMsg(handle, 0x7BB2); // 停止通道2上的演奏}midiOutShortMsg(handle, 0x7BB2); // 停止通道2上的演奏midiOutClose(handle); // 关闭midi设备
}int main()
{huangtiandi();return 0;
}

编译  clang huangtiandi.cpp -o huangtiandi.exe

运行  huangtiandi.exe

详细参阅:《荒天帝》专属BGM——midi笛子音乐谱曲


钢琴伴奏《起风了》,编写  qifengle.cpp  如下

#include <iostream>
#include <windows.h>  
#include <mmsystem.h>
#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 // F大调
{H1 = F2, H2 = G2, H3 = A2, H4 = B2, H5 = C3, H6 = D3, H7 = E3,J1 = F3, J2 = G3, J3 = A3, J4 = B3, J5 = C4, J6 = D4, J7 = E4,K1 = F4, K2 = G4, K3 = A4, K4 = B4, K5 = C5, K6 = D5, K7 = E5,L1 = F5, L2 = G5, L3 = A5, L4 = B5, L5 = C6, L6 = D6, L7 = E6,LOW_SPEED = 500, MIDDLE_SPEED = 400, HIGH_SPEED = 300,_ = 0//XFF
};
// 歌词
char geci[58][40] = {"这一路上走走停停","顺着少年漂流的痕迹","迈出车站的前一刻","竟有些犹豫","不禁笑这近乡情怯","仍无可避免","而长野的天","依旧那么暖","风吹起了从前\n","从前初识这世间 万般流连","看着天边似在眼前","也甘愿赴汤蹈火去走它一遍","如今走过这世间 万般流连","翻过岁月不同侧脸","措不及防闯入你的笑颜\n","我曾难自拔于世界之大","也沉溺于其中梦话","不得真假 不做挣扎 不惧笑话","我曾将青春翻涌成她","也曾指尖弹出盛夏","心之所动 且就随缘去吧","逆着光行走 任风吹雨打", "","短短的路走走停停","也有了几分的距离","不知抚摸的是故事", "还是段心情","也许期待的不过是", "与时间为敌","再次看到你","微凉晨光里","笑得很甜蜜\n","从前初识这世间 万般流连","看着天边似在眼前","也甘愿赴汤蹈火去走它一遍","如今走过这世间 万般流连","翻过岁月不同侧脸","措不及防闯入你的笑颜\n","我曾难自拔于世界之大","也沉溺于其中梦话","不得真假 不做挣扎 不惧笑话","我曾将青春翻涌成她","也曾指尖弹出盛夏","心之所动 且就随缘去吧","","晚风吹起你鬓间的白发","抚平回忆留下的疤","你的眼中 明暗交杂 一笑生花","暮色遮住你蹒跚的步伐","走进床头藏起的画","画中的你 低着头说话\n","我仍感叹于世界之大","也沉醉于儿时情话","不剩真假 不做挣扎 无谓笑话\n" ,"我终将青春还给了她","连同指尖弹出的盛夏","心之所动 就随风去了","以爱之名 你还愿意吗\n" 
};
// 歌曲《起风了》The Wind Rises
int qfl[] = {H7,J1,J2,J3, _,H5,J5,J3,J3, _, _, _,H7, _, _, _,H7,J1,J2,J3, _,H5,J5,J3,J2,J3,J1,J2,H7,J1,H5, _,H7,J1,J2,J3, _,H5,J5,J3,J3, _, _, _,H7, _, _, _,H7,J1,J2,J3, _,H5,J5,J3,J2,J3,J1,J2,H7,J1,H5, _,J7,K1,K2,K3, _,J5,K5,K3,K3, _, _, _,J7,K1,K2,K3, _,J5,K5,K3,K2,K3,K1,K2,J7,K1,J5, _,J7,K1,K2,K3, _,J5,K5,K3,K3, _, _, _, _, K6,K3,K2,J6,J3,H6,J2,J3,H6, _, _, _,9, // 前奏J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 这一路上走走停停J2, _, _,J1,J2, _,J1,J2,J3,J2,J1,H6, _, _, _,9, // 顺着少年漂流的痕迹J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 迈出车站的前一刻J2, _, _,J3,J2, _,J1,J2,J2, _, _, _,9, // 竟有些犹豫J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 不禁笑这近乡情怯J2, _, _,J3,J2, _,J1, _,H6, _, _, _,9, // 仍无可避免J3,J2,J1,J2,J1, _, _, _,9, // 而长野的天J3,J2,J1,J2,J1, _, _, _,9, // 依旧那么暖H5,J3,J2,J1,J2, _,J1, _, _, _, _, _,9, // 风吹起了从前J1, _,J2, _,J3, _,J1, _,J6, _,J5,J6, _, _,J2,J7, _,J6,J7, _, _,9, // 从前初识这世间 万般流连J7, _,J6,J7, _,J3, _,K1,K2,K1,J7,J6, _, _,9, // 看着天边似在眼前J5, _,J6, _,J5,J6,J5,J6,J5,J6, _,J5,J2, _,J5, _,J3, _, _, _,9, // 也甘愿赴汤蹈火去走它一遍J1, _,J2, _,J3, _,J1, _,J6, _,J5,J6, _, _,J2,J7, _,J6,J7, _, _,9, // 如今走过这世间 万般流连J7, _,J6,J7, _,J3, _,K1,K2,K1,J7,J6, _, _,9, // 翻过岁月不同侧脸J5, _,J6, _,K3,K3, _,J5, _,J6, _,K3,K3, _,J5,J6, _,J6, _, _, _,9, // 措不及防闯入你的笑颜K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我曾难自拔于世界之大K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 也沉溺于其中梦话K2,K1,K1,J6, _,K1, _,K1,K2, _,K1,J6, _,K1,K1, _,K3, _,K3,K2,K3, _,K2, _, _,9, // 不得真假 不做挣扎 不惧笑话K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我曾将青春翻涌成她K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 也曾指尖弹出盛夏K3,K2,K2,K1, _,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _,9, // 心之所动 且就随缘去吧J6, _,K3, _,K2, _,K1,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _, _, _,9, // 逆着光行走 任风吹雨打J7,K1,K2,K3, _,J5,K5,K3,K3, _, _, _,J7,K1,K2,K3, _,J5,K5,K3,K2,K3,K1,K2,J7,K1,J5, _,J7,K1,K2,K3, _,J5,K5,K3,K3, _, _, _, _,K6,K3,K2,J6,J3,H6,J2,J3,H6, _, _, _,9, // 间奏1J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 短短的路走走停停J2, _, _,J1,J2, _,J1,J2,J3,J2,J1,H6, _, _, _,9, // 也有了几分的距离J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 不知抚摸的是故事J2, _, _,J3,J2, _,J1,J2,J2, _, _, _,9, // 还是段心情J2, _, _,J1,J2, _,J1,J2, _,J3, _,J5, _,J3, _,9, // 也许期待的不过是J2, _, _,J3,J2, _,J1, _,H6, _, _, _,9, // 与时间为敌J3,J2,J1,J2,J1, _, _, _,9, // 再次看到你J3,J2,J1,J2,J1, _, _, _,9, // 微凉晨光里H5,J3,J2,J1,J2, _,J1, _, _, _, _, _,9, // 笑得很甜蜜J1, _,J2, _,J3, _,J1, _,J6, _,J5,J6, _, _,J2,J7, _,J6,J7, _, _,9, // 从前初识这世间 万般流连J7, _,J6,J7, _,J3, _,K1,K2,K1,J7,J6, _, _,9, // 看着天边似在眼前J5, _,J6, _,J5,J6,J5,J6,J5,J6, _,J5,J2, _,J5, _,J3, _, _, _,9, // 也甘愿赴汤蹈火去走它一遍J1, _,J2, _,J3, _,J1, _,J6, _,J5,J6, _, _,J2,J7, _,J6,J7, _, _,9, // 如今走过这世间 万般流连J7, _,J6,J7, _,J3, _,K1,K2,K1,J7,J6, _, _,9, // 翻过岁月不同侧脸J5, _,J6, _,K3,K3, _,J5, _,J6, _,K3,K3, _,J5,J6, _,J6, _, _, _,9, // 措不及防闯入你的笑颜K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我曾难自拔于世界之大K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 也沉溺于其中梦话K2,K1,K1,J6, _,K1, _,K1,K2, _,K1,J6, _,K1,K1, _,K3, _,K3,K2,K3, _,K2, _, _,9, // 不得真假 不做挣扎 不惧笑话K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我曾将青春翻涌成她K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 也曾指尖弹出盛夏K3,K2,K2,K1, _,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _, _, _,9, // 心之所动 且就随缘去吧K3,J2,K5,K3,K2,K3,K1,K2,J7,K1,J5, _,J7,K1,K2,K3, _,J3,K5,K3, _, _, _, _,J7,K1,K2,K3, _,J3,K5,K3, _, _, _, _,K2, _,H7, _,J6,K5, _,J5,K6, _, _,K1,K3,J6,K6,K5,K2, _, _, _,K2, _,H7, _,J4,K7, _,J7, _,K4,K7, _,J7, _,K4,K7, _,K6,K4, _,H1, _,K6, _,J5, _,K5, _,J4, _,K4, _,K3, _,K2, _,K1, _,K7,_, _, _,K7,_, _, _,K7,_, _, _,K7,_, _, _,9, // 间奏2K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 晚风吹起你鬓间的白发K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 抚平回忆留下的疤K2,K1,K1,J6, _,K1, _,K1,K2, _,K1,J6, _,K1,K1, _,K3, _,K3,K2,K3, _,K2, _, _,9, // 你的眼中 明暗交杂 一笑生花K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 暮色遮住你蹒跚的步伐K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 走进床头藏起的画K3,K2,K2,K1, _,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _, _, _, _,9, // 画中的你 低着头说话K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我仍感叹于世界之大K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 也沉醉于儿时情话K2,K1,K1,J6, _,K1, _,K1,K2, _,K1,J6, _,K1,K1, _,K3, _,K3,K2,K3, _,K2, _, _,9, // 不剩真假 不做挣扎 无谓笑话K1, _,K2, _,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K2, _, _,9, // 我终将青春还给了她K2,K3, _,K6,K5, _,K6,K5, _,K6,K5, _,K3, _, _,9, // 连同指尖弹出的盛夏K3,K2,K2,K1, _,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _,9, // 心之所动 就随风去了J6, _,K3, _,K2, _,K1,J6, _,K3, _,K2, _,K1,J6, _,K1, _,K1, _, _, _, _, _, // 以爱之名 你还愿意吗
};
// 用C++演奏歌曲《起风了》The Wind Rises
void qifengle()
{HMIDIOUT handle;midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);midiOutShortMsg(handle, 0 << 8 | 0xC0); // 设置通道0的乐器为 大钢琴unsigned short note = 0;    // 音符编号unsigned short v = 100; // velocity 力度值,范围通常在0-127unsigned char sd = 0x90 | (0 & 0x0F);// statusByte: 0为声道int c = 0;for (int i=0; i < 1280; i++) {if (qfl[i] == 9){cout << geci[c] << endl;c++;}else {Sleep(175);if (qfl[i]=='_') Sleep(110);else note = qfl[i];}// 组合3个字节的消息到一个DWORD值unsigned long noteOnMsg = (((unsigned long)v <<16) | (((unsigned long)note) <<8) | (unsigned long)sd);// 发送MIDI消息midiOutShortMsg(handle, noteOnMsg);}midiOutClose(handle);
}int main()
{qifengle();return 0;
}

编译  clang qifengle.cpp -o qifengle.exe 

运行 chcp 65001

运行 qifengle.exe

详细参阅:C语言midi编程钢琴演奏


钢琴伴奏《夏天》,编辑  Summer.cpp  如下

#include <iostream>
#include <Windows.h>
#pragma comment(lib,"winmm.lib")
using namespace std;/*midi参数: 音量<<16 + 声调<<8 + 乐器类型音量范围: 0x0-0x7f乐器范围: 0x90-0x9f 其中0x99为鼓类,其余皆为钢琴音阶范围: 0x0-7f 以下为中音的音调16进制参数对照表(注意:以下数据仅为本人通过自己乐感来测试得出的,不一定正确,仅供参考)Do:0x3c Re:0x3e Mi:0x40 Fa:0x41 So:0x43 La:0x45 Xi:0x47 Do+1:0x48
*/
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
{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
};int summer[] = {H1,_,M5,M1,H1,H2,M3,_,H5,_,H1,H2,_,H3,_,H1,H2,_,H3,_,H1,_,M5,M1,H1,H2,M3,_,H5,_,H2,H2,_,H3,_,H2,H3,_,H3,_,H3,H2,H1,_,H1,M5,M6,M3,M5,_,H3,H2,H1,_,H1,M5,M6,M3,M5,_,H3,H2,H2,_,H2,H1,M7,_,M6,M7,M5,M6,_,_,M6,M5,M6,_,M5,H1,H2,H5,M5,H1,H2,M5,H5,_,M5,H1,H2,M5,H5,M5,H1,M5,H2,M5,H5,_,M5,H1,H2,H5,M5,H1,H2,M5,H5,_,M5,H1,H2,H5,M5,H1,M5,H2,M5,H5,_,H1,_,M5,M1,H1,H2,M5,H3,_,H5,M5,H2,H2,_,H3,_,H1,H2,_,H3,_,H1,_,M5,M1,H1,H2,M5,H3,_,H5,_,H2,H2,_,H3,_,H2,M3,_,H3,_,H3,H2,M3,H1,_,H1,M5,M6,M3,M5,_,H3,H2,M3,H1,_,H1,M5,M6,M3,M5,_,H3,H2,H2,_,H2,H1,M7,_,M6,M7,M5,M6,_,_,_,};void Summer() {HMIDIOUT handle;midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);int volume = 0x7f;int voice = 0x0;int s = 300; // sleep 毫秒for (auto i : summer) {if (i == LOW_SPEED || i == HIGH_SPEED || i == MIDDLE_SPEED) {s = i;continue;}if (i == _) {Sleep(300);continue;}voice = (volume << 16) + (i << 8) + 0x94;cout << hex << voice << endl; // 输出16进制midiOutShortMsg(handle, voice);Sleep(s);}midiOutClose(handle);
}int main()
{Summer();return 0;
}

编译  clang Summer.cpp -o Summer.exe
运行  Summer.exe

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/7267.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Docker新建容器 修改运行容器端口

一、修改容器的映射端口 项目需求修改容器的映射端口 二、解决方案 停止需要修改的容器 修改hostconfig.json文件 重启docker 服务 启动修改容器 三、方案 目前正在运行的容器 宿主机的89 端口 映射 容器端口80 3.1测试环境中新建nginx服务 docker run -itd --n…

打破 AI 算力天花板,Meta超大规模AI基础设施架构解读

Meta超大规模AI智算基础设施架构设计 摘要 双重 GPU 集群&#xff0c;每群配备 2.4 万个 H100 芯片&#xff0c;分别采用 RoCE 和 InfiniBand 网络连接。LLaMA3 就是在这两个集群上训练出来的&#xff1b;Meta AI 将部署庞大算力集群&#xff0c;拥有 35 万张 H100 GPU&#x…

【C语言】第一个C程序:hello world

printf简介 printf是C语言提供的库函数&#xff0c;可以在屏幕上打印格式化数据。这里不作展开&#xff0c;只需要知道&#xff0c;如果要打印hello world&#xff0c;就把双引号引起来的"hello world"作为参数传给printf就行了。如果想要在打印后换行&#xff0c;要…

数据分析之Tebleau可视化:树状图、日历图、气泡图

树状图&#xff08;适合子分类比较多的&#xff09; 1.基本树状图的绘制 同时选择产品子分类和销售金额----选择智能推荐----选择树状图 2.双层树状图的绘制 将第二个维度地区拖到产品分类的下面---大的划分区域是上面的维度&#xff08;产品分类&#xff09;&#xff0c;看着…

牛客热题:单链表排序

&#x1f4df;作者主页&#xff1a;慢热的陕西人 &#x1f334;专栏链接&#xff1a;力扣刷题日记 &#x1f4e3;欢迎各位大佬&#x1f44d;点赞&#x1f525;关注&#x1f693;收藏&#xff0c;&#x1f349;留言 文章目录 牛客热题&#xff1a;单链表排序题目链接方法一&…

如何压缩word文档的大小?6个方法教你方便的压缩word文档

如何压缩word文档的大小&#xff1f;6个方法教你方便的压缩word文档 以下是六个常用的软件和方法&#xff0c;可以帮助您方便地压缩Word文档大小&#xff1a; 使用Microsoft Word内置功能&#xff1a; 在Microsoft Word中&#xff0c;您可以使用内置的压缩功能来减小文档的大…

Celery(分布式任务队列)入门学习笔记

Celery 的简单介绍 用 Celery 官方的介绍&#xff1a;它是一个分布式任务队列; 简单&#xff0c;灵活&#xff0c;可靠的处理大量消息的分布式系统; 它专注于实时处理&#xff0c;并支持任务调度。 Celery 如果使用 RabbitMQ 作为消息系统的话&#xff0c;整个应用体系就是下…

25.哀家要长脑子了---哈希表

1.525. 连续数组 - 力扣&#xff08;LeetCode&#xff09; 在我对通义千问的一番折磨下&#xff0c;终于弄清楚一点点了。哈希表存储前缀和数组值 用一个counter来记录nums中0、1数量差值的变化。 哈希表map存储某个特定的counter值首次出现的位置。counter的计算&#xff1a;…

【深度学习】序列模型

深度学习&#xff08;Deep Learning&#xff09;是机器学习的一个分支领域&#xff1a;它是从数据中学习表示的一种新方法&#xff0c;强调从连续的层中进行学习&#xff0c;这些层对应于越来越有意义的表示。 1. 为什么选择序列模型&#xff1f; 循环神经网络&#xff08;RNN…

(二)JSP教程——taglib指令

创建标签文件 首先创建一个Web项目&#xff0c;在webapp/WEB-INF目录下创建一个tags文件夹 在tags文件夹中创建一个oddNumberSum.tag文件&#xff0c;Tag文件时扩展名为.tag的文本文件&#xff0c;其结构和JSP文件非常相似&#xff0c;该文件的目录结构如图所示 创建Tag文件的…

Linux基础之makefile/make

目录 一、背景 二、makefile和make的讲解 2.1 使用方法 2.2 伪目标文件 2.3 文件的属性以及属性的更新 2.4 makefile的自动推导 一、背景 这里会提及为什么要使用makefile和make&#xff0c;以及他们是什么和作用。 会不会写makefile&#xff0c;从一个侧面说明了一个人是…

怎么口语外教一对一课程?这篇文章告诉你答案!

怎么口语外教一对一课程&#xff1f;在当今全球化的时代&#xff0c;英语口语能力已经成为许多人追求的重要技能。为了满足这一需求&#xff0c;市场上涌现出了许多提供一对一口语外教课程的软件。这些软件不仅提供了与母语为英语的外教进行实时交流的机会&#xff0c;还通过互…

遭遇.halo勒索病毒怎么办?如何识别和应对.halo勒索病毒

导言&#xff1a; 近年来&#xff0c;网络安全问题愈发严峻&#xff0c;其中勒索病毒成为了威胁企业和个人数据安全的重要隐患。在2023年初&#xff0c;一种新的勒索病毒——.halo勒索病毒开始在网络上肆虐&#xff0c;给广大用户带来了极大的困扰。本文91数据恢复将对.halo勒…

c3 笔记6 认识css样式表

<link>与import应该如何选择?事实上&#xff0c;使用link与import链接外部样式文件的效果看起来是一样的&#xff0c;区别在于<link>是HTML标记而import属于CSS语法。<link>标记有rel、type与href属性&#xff0c;可以指定CSS样式表的名称&#xff0c;这样就…

控制台调试 hover 后才出现的元素

调试 hover后才出现的元素 打开开发者工具&#xff0c;鼠标放在hover时才出现的元素上&#xff0c;然后点击右键&#xff1b; 不要选中任何选项&#xff0c;将鼠标移动到开发者工具的调试面板中&#xff1b; 按下N键&#xff0c;此时悬浮的元素不会消失&#xff0c;定位成功。…

知到java笔记(4.1--继承的用法以及this和super的用法)

格式&#xff1a; 例子&#xff1a; get set获取父类的私有变量 private属性 this和super区别&#xff1a; this用法 super用法 例子

计算机毕设

随着社会和国家的重视&#xff0c;大学对于大学生毕业设计越来越重视。 做软件设计设计方面&#xff0c;前后端分离是必不可少的&#xff0c;代码管理工具&#xff0c;前后端接口测试是项目中必须要用到的工具。做大数据设计方面&#xff0c;主要是要用到爬虫进行数据爬取&…

【数据分析面试】36.SAAS公司邮件营销策略分析(业务分析)

题目 假设你在一个B2B SAAS公司营销团队工作。本季度即将结束&#xff0c;但当前收入距离预期目标还差10%。营销团队的一个高管要求负责电子邮件营销的人向所有客户群发邮件&#xff0c;要求他们购买更多产品。这是个好主意吗&#xff1f;为什么&#xff1f; 提示1&#xff1…

[论文笔记]Longformer: The Long-Document Transformer

引言 今天带来论文Longformer: The Long-Document Transformer的笔记。 基于Transformer的模型由于其自注意力操作而无法处理长序列&#xff0c;该操作随着序列长度呈二次扩展。为了解决这一限制&#xff0c;本篇工作提出了Longformer&#xff0c;其注意力机制随着序列长度呈…

接口测试之Mock测试方法

&#x1f345; 视频学习&#xff1a;文末有免费的配套视频可观看 &#x1f345; 点击文末小卡片&#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 一、关于Mock测试 1、什么是Mock测试&#xff1f; Mock 测试就是在测试过程中&#xff0c;对于…