洒水车的 bgm,听一遍唱一遍
本帖最后由 zhangjinxuan 于 2023-6-26 19:57 编辑使用 windows.h 中的 beep 函数做出的洒水车 bgm:
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
const int sounds = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 130, 146, 164, 174, 195, 220, 246, },
{0, 262, 294, 330, 349, 392, 440, 494, },
{0, 523, 587, 659, 698, 783, 880, 987, },
{0, 1046, 1174, 1318, 1396, 1567, 1760, 1975},
{0, 2093, 2349, 2637, 2793, 3135, 3520, 3951},
};
struct Tone {
int level, tone;
double times = 1;
};
const Tone soundlist[]= {
{0, 0, 0},
{4, 1, 2}, {3, 6}, {3, 5}, {3, 3}, {3, 2}, {3, 3, 0.5}, {3, 2, 0.5}, {3, 1, 2}, {0, 0, 2},
{3, 3}, {3, 5}, {4, 1}, {4, 1, 2}, {4, 1}, {4, 2}, {4, 3}, {4, 2}, {4, 1}, {3, 5, 2}, {0, 0, 2},
{4, 1, 2}, {4, 2}, {4, 1}, {3, 6}, {3, 5}, {3, 6, 2}, {0, 0, 2},
{3, 5}, {3, 6}, {4, 1}, {3, 3, 2}, {3, 5}, {3, 2}, {3, 3}, {3, 2}, {3, 1}, {3, 2, 2}, {0, 0, 2},
{3, 3, 2}, {3, 5}, {3, 6, 2}, {3, 5}, {3, 6, 0.5}, {3, 5}, {3, 3}, {3, 2}, {3, 3, 0.5}, {3, 2, 0.5}, {3, 1, 2}, {0, 0, 0.5},
{3, 3}, {3, 5}, {4, 1}, {4, 1, 2}, {4, 1}, {4, 2}, {4, 3}, {4, 2}, {4, 1}, {3, 6, 2}, {0, 0, 2},
{4, 2}, {4, 3}, {4, 1, 2}, {3, 6}, {3, 5, 2}, {3, 6}, {3, 5, 0.5}, {3, 3, 0.5}, {0, 0, 2},
{3, 2}, {3, 2, 2}, {3, 6}, {3, 5}, {3, 3}, {3, 2}, {3, 3, 0.5}, {3, 2, 0.5}, {3, 1}, {0, 0, 2},
};
const int len = sizeof(soundlist) / sizeof(Tone);
const char* s = {"-", "do", "re", "mi", "fa", "sol", "la", "si"};
const char* l = {"null", "lowest", "low", "mid", "high", "highest"};
int main() {
puts("-----Sprinkler-----");
for (int i = 1; i <= len; ++i) {
printf("\r%d%s%s ", soundlist.level, s.tone], l.tone]);
Beep(sounds.level].tone], (soundlist.times) * 300);
}
printf("\rThank you for listening, Create by ZhangJinxuan^_^");
system("pause");
return 0;
}
是不是很像经常在你家门口吵的洒水车?
保证你听一遍唱一遍{:10_250:} 能搞python版吗? 一点沙 发表于 2023-6-7 12:10
能搞python版吗?
python不能直接接触底层库,不好做,你要 exe 我可以发给你。 zhangjinxuan 发表于 2023-6-7 12:10
python不能直接接触底层库,不好做,你要 exe 我可以发给你。
嗯嗯,回头有空告诉你 一点沙 发表于 2023-6-7 12:11
嗯嗯,回头有空告诉你
好的,我也去查查资料 @元豪 @sfqxx 我家门口没有洒水车 liuhongrun2022 发表于 2023-6-7 15:23
我家门口没有洒水车
{:10_306:} {:10_257:} 猜猜这是什么歌曲(Python):
import winsound
import time
for i in range(2):
winsound.Beep(262, 500)
winsound.Beep(294, 500)
winsound.Beep(330, 500)
winsound.Beep(262, 500)
time.sleep(0.2)
for i in range(2):
winsound.Beep(330, 500)
winsound.Beep(349, 500)
winsound.Beep(392, 500)
time.sleep(0.7)
for i in range(2):
winsound.Beep(392, 350)
winsound.Beep(440, 350)
winsound.Beep(392, 350)
winsound.Beep(349, 350)
winsound.Beep(330, 700)
time.sleep(0.1)
winsound.Beep(262, 350)
time.sleep(0.6)
for i in range(2):
winsound.Beep(294, 500)
winsound.Beep(200, 500)
winsound.Beep(262, 500)
time.sleep(0.7) liuhongrun2022 发表于 2023-6-7 16:12
猜猜这是什么歌曲(Python):
光看赫兹猜不出来额{:10_277:} zhangjinxuan 发表于 2023-6-7 16:30
光看赫兹猜不出来额
你运行啊
页:
[1]