调用bios喇叭发声
来源:互联网 发布:hifiman supermini知乎 编辑:程序博客网 时间:2024/05/17 08:40
话不多说,上代码:
#include <windows.h>#include <iostream>#include <map>using namespace std;const int DO = 261;const int RE = 293;const int MI = 329;const int FA = 349;const int SO = 392;const int LA = 440;const int TI = 493;const int DO_ = 130;const int RE_ = 147;const int MI_ = 165;const int FA_ = 174;const int SO_ = 186;const int LA_ = 220;const int TI_ = 247;int frequency(char note){ static map<const char,int> table; if(table.size() == 0){ table['1'] = DO; table['2'] = RE; table['3'] = MI; table['4'] = FA; table['5'] = SO; table['6'] = LA; table['7'] = TI; table['c'] = DO_; table['d'] = RE_; table['e'] = MI_; table['f'] = FA_; table['g'] = SO_; table['a'] = LA_; table['b'] = TI_; } return table.find(note) -> second;}class music{ private: string notes; int tenuto; public: music(string &song , int tenuto_) { notes = song; tenuto = tenuto_; play(notes.end(),tenuto);} void play(string::iterator it,int duration );};void music::play(string::iterator it, int duration){ char note = *it; if( it == notes.begin() ) return; if( note == '-') play( it - 1, duration + tenuto); else { if( isalnum(note) ) { play( it - 1, 0); Beep(frequency(note), tenuto + duration); } else play( it - 1, duration); } } string bee = "\ 5 3 3 - | 4 2 2 - | 1 2 3 4 | 5 5 5 - | \ 5 3 3 - | 4 2 2 - | 1 3 5 5 | 3 3 3 - | \ 2 2 2 2 | 2 3 4 - | 3 3 3 3 | 3 4 5 - | \ 5 3 3 - | 4 2 2 - | 1 3 5 5 | 1 3 1 - | \ "; string happynewyear = "\ 1 1 1 - g - | 3 3 3 - 1 - | 1 3 5 - 5 - | \ 4 3 2 - - - | 2 3 4 - 4 - | 3 2 3 - 1 - | \ 1 3 2 - g - | b 2 1 - - - | \ "; int main() { music m(bee, 300); music m2(happynewyear, 200); return 0; }
1 0
- 调用bios喇叭发声
- 控制PC喇叭发声
- 喇叭发声原理
- 喇叭发声原理
- C#使Pc喇叭发声
- [VB.NET]需要一个喇叭发声的音乐,请教
- Ubuntu 8.10 acer 4930 声卡耳机喇叭同时发声的问题解决了
- 通过驱动使应用程序直接操作IO口,通过端口终止PC喇叭发声
- BIOS中断调用
- BIOS功能调用简介
- BIOS功能调用表格
- C# wince 蜂鸣器 发声 C#调用设备驱动函数
- C# wince 蜂鸣器 发声 C#调用设备驱动函数
- DOS和BIOS功能调用
- DOS和BIOS系统调用
- DOS和BIOS功能调用
- bios中断调用查询表
- DOS和BIOS系统调用
- Java_JVM_字节码
- UVa 221 Urban Elevations
- 树状数组+散列
- <C/C++图>单源最短路径:Dijkstra算法
- Android Studio 快捷键
- 调用bios喇叭发声
- POJ 1125 Stockbroker Grapevine(floyd两点间最短距离)
- zookeeper原理(转)
- ubuntu cpu 占有率 100%
- Using the Material Theme
- HTML5之Canvas画正方形
- 黑马程序员————Foundation
- Scala-5 - 1 - Lecture 4.1 - Functions as Objects (8_04)
- 【转载】Java中静态的代码块,静态变量,静态方法