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

编辑  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/web/6043.shtml

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

相关文章

SQL 基础 | UNION 用法介绍

在SQL中&#xff0c;UNION操作符用于合并两个或多个SELECT语句的结果集&#xff0c;形成一个新的结果集。 使用UNION时&#xff0c;合并的结果集列数必须相同&#xff0c;并且列的数据类型也需要兼容。 默认情况下&#xff0c;UNION会去除重复的行&#xff0c;只保留唯一的行。…

Flutter笔记:使用Flutter私有类涉及的授权协议问题

Flutter笔记 使用Flutter私有类涉及的授权协议问题 - 文章信息 - Author: 李俊才 (jcLee95) Visit me at CSDN: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAddress of this article:https://blog.cs…

【跟马少平老师学AI】-【神经网络是怎么实现的】(七-1)词向量

一句话归纳&#xff1a; 1&#xff09;神经网络不仅可以处理图像&#xff0c;还可以处理文本。 2&#xff09;神经网络处理文本&#xff0c;先要解决文本的表示&#xff08;图像的表示用像素RGB&#xff09;。 3&#xff09;独热编码词向量&#xff1a; 词表&#xff1a;{我&am…

ensp 配置s5700 ssh登陆

#核心配置 sys undo info-center enable sysname sw1 vlan 99 stelnet server enable telnet server enable int g 0/0/1 port lin acc port de vlan 99 q user-interface vty 0 4 protocol inbound ssh authentication-mode aaa q aaa local-user admin0 password cipher adm…

Java集合框架-容器源码分析

Java集合框架-容器&源码分析 文章目录 Java集合框架-容器&源码分析[TOC](文章目录)前言一、集合框架概述二、Collection接口及其子接口(List/Set)及实现类2.1 Collection接口中方法2.2 遍历&#xff1a;Iterator迭代器接口&foreach(5.0新特性)2.3 Connection子接口…

SQL 基础 | AS 的用法介绍

SQL&#xff08;Structured Query Language&#xff09;是一种用于管理和操作数据库的标准编程语言。 在SQL中&#xff0c;AS关键字有几种不同的用法&#xff0c;主要用于重命名表、列或者查询结果。 以下是AS的一些常见用法&#xff1a; 重命名列&#xff1a;在SELECT语句中&a…

C++深度解析教程笔记7

C深度解析教程笔记7 第13课 - 进阶面向对象&#xff08;上&#xff09;类和对象小结 第14课 - 进阶面向对象&#xff08;下&#xff09;类之间的基本关系继承组合 类的表示法实验-类的继承 第15课 - 类与封装的概念实验-定义访问级别cmd 实验小结 第16课 - 类的真正形态实验-st…

Web,Sip,Rtsp,Rtmp,WebRtc,专业MCU融屏视频混流会议直播方案分析

随着万物互联&#xff0c;视频会议直播互动深入业务各方面&#xff0c;主流SFU并不适合管理&#xff0c;很多业务需要各种监控终端&#xff0c;互动SIP硬件设备&#xff0c;Web在线业务平台能相互融合&#xff0c;互联互通&#xff0c; 视频混流直播&#xff0c;录存直播推广&a…

c++ 筛选裁决文书 1985-2021的数据 分析算法的差异

c cpp 并行计算筛选过滤 裁决文书网1985-2021 的300g数据 数据 数据解压以后大概300g&#xff0c;最开始是使用python代码进行计算&#xff0c;但是python实在太慢了&#xff0c;加上多进程也不行&#xff0c; 于是 使用c 进行 计算 c这块最开始使用的是 i7-9700h 用的是单线…

基于Spring Boot的心灵治愈交流平台设计与实现

基于Spring Boot的心灵治愈交流平台设计与实现 开发语言&#xff1a;Java框架&#xff1a;springbootJDK版本&#xff1a;JDK1.8数据库工具&#xff1a;Navicat11开发软件&#xff1a;eclipse/myeclipse/idea 系统部分展示 系统功能界面图&#xff0c;在系统首页可以查看首页…

C++类成员函数重载

成员函数重载是指在同一个类里&#xff0c;有两个以上的函数具有相同的函数名。每种实现对应着一个函数体&#xff0c;但是形参的个数或者类型不同。 例如:减法函数重载 创建一个类&#xff0c;在类中定义3个名为subtract的重载成员函数&#xff0c;分别实现两…

【二等奖水平论文】2024五一数学建模C题22页保奖论文+22页matlab和13页python完整建模代码、可视图表+分解结果等(后续会更新)

一定要点击文末的卡片&#xff0c;那是资料获取的入口&#xff01; 点击链接加入群聊【2024五一数学建模】&#xff1a;http://qm.qq.com/cgi-bin/qm/qr?_wv1027&khoTDlhAS5N_Ffp-vucfG5WjeeJFxsWbz&authKey7oCSHS25VqSLauZ2PpiewRQ9D9PklaCxVS5X6i%2BAkDrey992f0t15…

能综合验证的RISCV内核开源项目调研选择

1. 评估的背景目的 考虑维度&#xff1a; 资源需求&#xff0c;开放程度&#xff0c;学习难度&#xff0c;工具链资源。 最好是国产FPGA支持&#xff0c;或者开源EDA工具链支持。 目标还是寻求一款在FPGA上低成本跑起来并能够支持一定的程序开发&#xff0c;最好实现一款…

人工智能 | Embedding

Embedding是什么 Embedding是一种将离散的符或对象映射到连续向量空间技术。在自然语言处理领域中&#xff0c;Embedding常用于将单词或句子为向量形式&#xff0c;以便计算机可以更好地理解和处理文本数据。 通过使用Embedding&#xff0c;我们可以将每个单词或句子表示为一…

eclipse开启服务后,网页无法打开,如何解决?

&#x1f3c6;本文收录于「Bug调优」专栏&#xff0c;主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案&#xff0c;希望能够助你一臂之力&#xff0c;帮你早日登顶实现财富自由&#x1f680;&#xff1b;同时&#xff0c;欢迎大家关注&&收藏&&…

kubectl_入门_service详解

Service 我们知道 Pod 的生命周期是有限的。可以用 ReplicaSet 和Deployment 来动态的创建和销毁 Pod&#xff0c;每个 Pod 都有自己的 IP 地址&#xff0c;但是如果 Pod 重建了的话那么他的 IP 很有可能也就变化了。 这就会带来一个问题&#xff1a;比如我们有一些后端的 Po…

jupyter notebook切换conda虚拟环境

首先&#xff0c;切换到某个虚拟环境&#xff0c;本人切换到了d2l环境&#xff1a; (d2l) C:\Users\10129>pip install ipykernel然后&#xff0c;如代码所示安装ipykernel包 最后&#xff0c;按下述代码执行&#xff1a; (d2l) C:\Users\10129>python -m ipykernel i…

mac电脑关于ios端的appium真机自动化测试环境搭建

一、app store 下载xcode,需要登录apple id 再开始下载 二、安装homebrew 1、终端输入命令&#xff1a; curl -fsSL <https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh>如果不能直接安装&#xff0c;而是出现了很多内容&#xff0c;那么这个时候不要着急&…

国产服务器操作系统部署NTP服务 _ 统信UOS _ 麒麟 _ 中科方德

原文链接&#xff1a;国产服务器操作系统部署NTP服务 | 统信UOS | 麒麟 | 中科方德 Hello&#xff0c;大家好啊&#xff01;在保持服务器时间的精确同步方面&#xff0c;时间同步服务器&#xff08;NTP服务器&#xff09;扮演着至关重要的角色&#xff0c;它能确保系统操作的时…

【论文阅读笔记】TS2Vec: Towards Universal Representation of Time Series

【论文阅读笔记】TS2Vec: Towards Universal Representation of Time Series 摘要 这段文字介绍了一个名为TS2Vec的通用框架&#xff0c;用于学习时间序列数据的表示&#xff0c;可以在任意语义层次上进行。与现有方法不同&#xff0c;TS2Vec通过对增强的上下文视图进行层次化…