Y15BeTa蜂鸣器唱歌程序-演奏版

最优版,自由演奏你的音乐!

每天进步一点点!

2018-12-09最新版

#include<bits/stdc++.h>
#include<windows.h> using namespace std; int md[8]={0,262,294,330,349,392,440,494}, mz[8]={0,523,587,659,698,784,880,988}, mg[8]={0,1046,1175,1318,1397,1568,1760,1967}; int tot=0; inline void gotoxy(int y,int x); inline void open(); inline int pinglv(string s); inline void ywy_beep(string s); //inline void change_start_music(); inline void gotoxy(int y,int x){ COORD pos; pos.X=x; pos.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } inline void ywy_beep(string s){ if(s=="cls"){ tot=0; system("cls"); return; } else if(s[0]=='B'){//手动,半调及连长音暂时只能用此解决 string a;int b; cin>>a>>b; int p=pinglv(a); if(p!=0)Beep(p,b); else{ int ia=0; for(int i=0;i<=a.size()-1;i++)ia=ia*10+int(a[i])-48; Beep(ia,b); } } else if(s=="rand"){ printf("请输入持续时间(单位:秒)\n"); int ha; scanf("%d",&ha); ha*=5; while(ha--)Beep(abs((rand()+ha*ha)%1500),200); } else if(s[0]=='&'){//微调:换气或隔音 Sleep(50); } else if(s[0]=='0'){//休止符 Sleep(300); } else{ int p=pinglv(s); if(p!=0){ Beep(p,300); } else{ cout<<"震惊*"<<++tot; for(int i=1;i<=tot;i++)cout<<'!'; cout<<endl; } } } inline void open(){ gotoxy(11,30); printf("欢迎进入演奏系统\n"); for(int i=1;i<=3*88889999;i++); gotoxy(24,0); Beep(mz[1],180); Beep(mz[2],190); Beep(mz[3],200); Beep(mz[4],210); Beep(mz[5],700); printf("加载中"); for(int i=1;i<=70;i++){ printf(">"); Sleep(10); } system("cls"); system("pause"); printf("\n\n指引: cls可以清除我的所有记忆:)\n\n祝旅途愉快!\n\n");// system("pause"); } inline int pinglv(string s){ if(s[0]>='1'&&s[0]<='7'&&s.size()==1){//中音 int ha=int(s[0]-'0'); return mz[ha]; } else if(s[0]=='d'&&s[1]>='1'&&s[1]<='7'&&s.size()==2){//低音 int ha=int(s[1]-'0'); return md[ha]; } else if(s[0]=='g'&&s[1]>='1'&&s[1]<='7'&&s.size()==2){//高音 int ha=int(s[1]-'0'); return mg[ha]; } else return 0; } int main(){ srand(time(0)); open(); while(1){ string s; cin>>s; ywy_beep(s); } }

转载于:https://www.cnblogs.com/Y15BeTa/p/FengMingQi__1.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值