调用bios喇叭发声
话不多说,上代码:
#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;
}
调用bios喇叭发声的更多相关文章
- 【python】调用机器喇叭发出蜂鸣声(Beep)
##coding:utf-8 import winsound winsound.Beep(600,6000) #其中600表示声音大小,1000表示发生时长,1000为1秒
- CMOS and BIOS
1,cmos简介. cmos是主板上一块可读写的RAM芯片.用途:主要用来保存当前系统的硬件配置和操作人员对某些参数的设定.cmos芯片是由一块纽扣电池供电.因此在关机状态内部信息也不会丢失. 2 ...
- CMOS、BIOS
CMOS主要的功能为记录主板上面的主要参数,包括系统时间.CPU电压与频率.各项设备的I/O地址与IRQ等,由于这些数据的记录要花费电力,因此主板上面才有电池. BIOS为写入到主板上某一块闪存或EE ...
- UEFI BIOS Rootkit Analysis
catalog . BIOS简介 . UEFI BIOS . EFI编程简介 . UEFI Rootkit 1. BIOS简介 BIOS("Basic Input Output System ...
- BIOS备忘录之ASL code常用知识点
_HID:device唯一 _STA:决定device在不在(在DM下面能不能看到) _CRS:描述分配给device的资源 _INI:在OSPM加载描述表的时候运行一次(比如,如果要根据不同情况给d ...
- 软盘相关知识和通过BIOS中断访问软盘
一. 软盘基础知识介绍 (1) 3.5英寸软盘 3.5英寸软盘分为上下两面,每面有80个磁道,每个磁道又分为18个扇区,每个扇区大小为512个字节. 软盘大小计算: 2面 * 80磁道 * 18扇区 ...
- 系统启动时,BIOS与影子内存_5
问题:“当我们按下电源开关时,电源开始供电,芯片组撤去RESET信号,CPU马上就从地址FFFF0H处开始执行指令,这个地址在系统BIOS的地址范围内,无论是Award BIOS还是AMI BIOS, ...
- BIOS和CMOS区别
在网上看到一篇关于CMOS的文章,分享一下. 原文地址:http://jingyan.baidu.com/article/c843ea0b51155d77921e4a7a.html BIOS是什么? ...
- 计算机启动boot
原创博文:转载请标明出处:http://www.cnblogs.com/zxouxuewei 零.boot的含义 先问一个问题,"启动"用英语怎么说? 回答是boot.可是,boo ...
随机推荐
- 初识Vulkan
Vulkan是Khronos组织制定的"下一代"开放的图形显示API,是与DirectX12可以匹敌的GPU API标准.Vulkan是基于AMD的Mantle API演化而来,目 ...
- Python 一个奇特的引用设定
def f(x): print 'original' if x > 0: return f(x-1) return 0 g = f def f(x): print 'new' return x ...
- Windows 为右键菜单瘦身
当你想删除右键菜单中某些选项时,一种比较合适的思路是: 1.如果软件本身提供了控制选项,那么直接在该软件设置即可.没必要在注册表操作.比如360安全卫士和360杀毒都提供了这种机制. 值得一提的是,3 ...
- [文摘]Quick Start to Client side COM and Python
摘自:PyWin32.chm Introduction This documents how to quickly start using COM from Python. It is not a t ...
- Makefile自动生成
automake/autoconf入门作为Linux下的程序开发人员,大家一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile ...
- 自动滚动的TextView
自动滚动的TextView 效果图 XML文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andr ...
- Linux命令—压缩及其他
(1)为了更好的传送和保存文件,需要对某些文件和目录进行压缩和解压缩操作,Linux 提供了强大的压缩.解压缩命令,常用的tar命令. (2)在Linux中,如果要使用储存设备(硬盘.光驱.移动 ...
- BCD码与16进制互转算法
关于这类算法,以前的文章已经讲过类似的:BCD码转二进制 #include <stdio.h> // HEX转BCD //bcd_data(<0x255,>0) unsigne ...
- 海量数据处理算法(top K问题)
举例 有一个1G大小的一个文件,里面每一行是一个词,词的大小不超过16字节,内存限制大小是1M.返回频数最高的100个词. 思路 首先把文件分开 针对每个文件hash遍历,统计每个词语的频率 使用堆进 ...
- iOS中 按钮和标题完美各种排列/完美教程 韩俊强的博客
每日更新关注:http://weibo.com/hanjunqiang 新浪微博! 前言:最近常常用到按钮和相应标题的组合,当按钮设置图片加标题时,触发范围较小,不易触发,最重要的是还要调试偏移量, ...