情人节特别篇:用c++弹奏音乐“海阔天空”与“孤勇者”

news/2024/11/22 21:21:12/

W...Y的主页 💕

代码库分享 😊


目录

孤勇者

海阔天空


今天是2023年8月22日七夕情人节,但是对我来说就是再普通不过的日子。我相信有很多人期待这一天的到来,和自己的对象出去享受快乐时光。但是我只有一个人独孤的度过短暂的时光,我相信一定有兄弟与我处境相同。

孤勇者

不要悲伤,不要哭泣,快乐的日子终会来临!!!

送给大家一首用c++写的孤勇者,让大家在今天都可以快乐度过!

注意:使用vs、devc++等编译器均可执行代码,只需要创建一个源文件即可。

#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <Windows.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{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 GYZ(){HMIDIOUT handle;midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);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;}voice = (volume << 16) + ((i) << 8) + 0x90;midiOutShortMsg(handle, voice);cout << voice << endl;Sleep(sleep);}midiOutClose(handle);
}
int main(void)
{GYZ();return 0;
}

孤勇者

都,是勇敢的

你额头的伤口,你的,不同,你犯的错

都,不必隐藏

你破旧的玩偶,你的,面具,你的自我

他们说,要带着光,驯服每一头怪兽

他们说,要缝好你的伤,没有人爱小丑

为何孤独,不可,光荣

人只有不完美,值得歌颂

谁说污泥满身的不算英雄

爱你孤身走暗巷,爱你不跪的模样

爱你对峙过绝望,不肯哭一场

爱你破烂的衣裳,却敢堵命运的枪

爱你和我那么像,缺口都一样

去吗,配吗,这褴褛的披风

战吗,战啊,以最卑微的梦

致那黑夜中的呜咽与怒吼

谁说站在光里的才算英雄

他们说,要戒了你的狂

就像擦掉了污垢

他们说,要顺台阶而上

而代价是低头

那就让我,不可,乘风

你一样骄傲着,那种孤勇

谁说对弈平凡的不算英雄

爱你孤身走暗巷,爱你不跪的模样

爱你对峙过绝望,不肯哭一场

爱你破烂的衣裳,却敢堵命运的枪

爱你和我那么像,缺口都一样

去吗,配吗,这褴褛的披风

战吗,战啊,以最卑微的梦

致那黑夜中的呜咽与怒吼

谁说站在光里的才算英雄

你的斑驳,与众不同

你的沉默,震耳欲聋

You Are The Hero

爱你孤身走暗巷,爱你不跪的模样

爱你对峙过绝望,不肯哭一场

爱你来自于蛮荒,一生不借谁的光

你将造你的城邦,在废墟之上

去吗,去啊,以最卑微的梦

战吗,战啊,以最孤高的梦

致那黑夜中的呜咽与怒吼

谁说站在光里的才算英雄

海阔天空

长风破浪会有时,直挂云帆济沧海,虽然我们这个七夕节没有那么快乐,但是今天一定也会有人在努力提升自己,让自己变得更优秀。

前方的光明在等着大家,就像海阔天空中的一句歌词一样:多少次, 迎着冷眼与嘲笑,从没有放弃过心中的理想。一首海阔天空送给一直在默默努力奋斗的人们,坚持下来一定会成功!!!

#include <iostream>
#include <Windows.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{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 HKTK(){HMIDIOUT handle;midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL);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;continue;}if (i == 0) { sleep = 200; continue; }if (i == 700) { Sleep(200); continue; }if (i == _) {Sleep(400);continue;}if (i == 1000) { tmp = +5; continue; }voice = (volume << 16) + ((i + tmp) << 8) + 0x90;midiOutShortMsg(handle, voice);cout << voice << endl;Sleep(sleep);}midiOutClose(handle);}int main(void)
{HKTK();return 0;
}

海闊天空

今天我 寒夜裡看雪飄過
懷著冷卻了的心窩漂遠方
風雨裏追趕 霧裡分不清影蹤
天空海闊你與我 可會變 (誰沒在變)

多少次 迎著冷眼與嘲笑
從沒有放棄過心中的理想
一剎那恍惚 若有所失的感覺
不知不覺已變淡 心裡愛 (誰明白我)

原諒我這一生不羈放縱愛自由
也會怕有一天會跌倒 oh-no
背棄了理想 誰人都可以
哪會怕有一天只你共我

今天我 寒夜裡看雪飄過
懷著冷卻了的心窩漂遠方
風雨裏追趕 霧裡分不清影蹤
天空海闊你與我 可會變 (誰沒在變)

原諒我這一生不羈放縱愛自由
也會怕有一天會跌倒 oh-no
背棄了理想 誰人都可以
哪會怕有一天只你共我 oh-yeah

仍然自由自我
永遠高唱我歌 走遍千里

原諒我這一生不羈放縱愛自由
也會怕有一天會跌倒 oh-no
背棄了理想 誰人都可以
哪會怕有一天只你共我 oh-yeah

(原諒我這一生不羈放縱愛自由) oh-yeah
(也會怕有一天會跌倒) oh-oh
(背棄了理想 誰人都可以) whoa-oh
(哪會怕有一天只你共我)


http://www.ppmy.cn/news/1061083.html

相关文章

【电路设计】220V AC转低压DC电路概述

前言 最近因项目需要,电路板上要加上一个交流220V转低压直流,比如12V或者5V这种。一般来说,比较常见也比较简单的做法是使用一个变压器将220V AC进行降压,比如降到22V AC,但是很遗憾的是,支持220V的变压器一般体积很大,而板子留给电源部分的面积又非常有限,所以不得不研…

在C++中利用rapidjson实现Python中的字典(Dict)

python 中的dict如下&#xff1a; Dicts {"Stain":{"ResultType": "Physics","Results": [{"Key": "KeyPoints","Title": "瑕疵区域","Unit": "","Value": …

前端监控之异常监控(一)

前言 当我们的项目中假设出现了下面几种场景&#xff1a; 点击按钮后&#xff0c;页面无响应页面跳转后显示白屏页面卡顿...... 这些情况都是非常影响用户体验的&#xff0c;对于用户来说&#xff0c;是难以接受的&#xff0c;用户可能就此流失掉了。 因此前端非常有必要针对…

【ROS】解决ros-Noetic-desktop-full安装过程中未满足的依赖关系问题 【转载】

【ROS】解决ros-Noetic-desktop-full安装过程中未满足的依赖关系问题 【转载】 文章目录 【ROS】解决ros-Noetic-desktop-full安装过程中未满足的依赖关系问题 【转载】问题描述Reference 问题描述 在安装ROS1 Noetic时遇到了依赖项不满足的问题&#xff0c;如下&#xff1a; …

打开软件提示msvcp140.dll丢失的解决方法,msvcp140主要丢失原因

今天&#xff0c;我将为大家介绍一种非常常见的问题——msvcp140.dll丢失。这个问题可能会导致许多应用程序无法正常运行&#xff0c;甚至崩溃。但是&#xff0c;请不要担心&#xff0c;我会为大家提供5种解决方法&#xff0c;帮助大家轻松解决问题。 首先&#xff0c;我们来看…

算法笔记(三):数组

静态数组 动态数组 把动态数组封装为一个类 1、属性 public class DynamicArray implements Iterable<Integer> {private int size 0; // 逻辑大小(有效的元素个数)private int capacity 8; // 容量private int[] array {}; // 动态数组 }2、方法 1&#xff…

【Golang】什么是内存逃逸?

文章目录 要从C/C谈起Golang的内存逃逸 要从C/C谈起 在C/C中&#xff0c;局部变量被分配到栈区&#xff0c;一旦当前函数执行完毕&#xff0c;局部变量占用的内存也将被释放&#xff0c;因此以下代码无法将数组的内容传递出去。 int *getArray() {int array[7] {1, 2, 3, 4,…

【C++精华铺】9.STL string

目录 1. string类的优势 2. string类的常用接口 2.1 常用构造 1. 空串构造&#xff1a;string(); 2. C串构造&#xff1a;string(const char* s); 3. 拷贝构造&#xff1a;string(const string& str); 4. 字符填充构造&#xff1a;string(size_t n, char c); 5. 迭代…