让C语言演唱“渴望”
来源:互联网 发布:sql server 表变量 编辑:程序博客网 时间:2024/05/17 08:10
程序简介:TURBOC专门提供了产生声音的函数sound,调用该函数的格式为:void sound(unsigned frequency)该函数的入口参数为产生声音的频率。
****************************************/
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <time.h>
#include <bios.h>
#include <conio.h>
#define N1 64
#define N2 32
#define N4 16
#define N8 8
#define N16 4
#define END 0
enum NOTES
{
C10=131,D10=147,E10=165,F10=175,G10=196,A10=220,B10=247,
C0=262,D0=296,E0=330,F0=349,G0=392,A0=440,B0=494,
C1=523,D1=587,E1=659,F1=698,G1=784,A1=880,B1=988,
C2=1047,D2=1175,E2=1319,F2=1397,G2=1568,A2=1760,B2=1976,
};
typedef enum NOTES SONG;
SONG song[]={
D0,N4,E0,N8,D0,N8,C0,N4,A10,N4,G10,N8,E10,N8,
G10,N8,A10,N8,C0,N2,A10,N4,A10,N8,C0,N8,G10,N8,A0,N8,
E0,N8,G0,N8,D0,N2,E0,N4,D0,N8,E0,N8,G0,N4,E0,N4,G10,
N8,E10,N8,G10,N8,A10,N8,C0,N2,A10,N4,A10,N8,C0,N8,A10,
N8,A10,N8,D10,N8,E10,N8,G10,N2,D0,N4,D0,N4,G0,N4,A0,N8,
G0,N8,F0,N2,G0,N2,A0,N4,G0,N8,E0,N8,D0,N8,E0,N8,C0,N8,
A10,N8,D0,N2,E0,N4,G0,N8,E0,N8,G0,N4,E0,N4,G10,N8,E10,
N8,G10,N8,A10,N8,C0,N4,A10,N4,A10,N8,C0,N8,D0,N8,A10,
N8,C0,N8,E0,N8,D0,N1,END,END
};
void main(void)
{
int note=0,fre,dur,control;
clock_t goal;
while(song[note]!=0)
{
fre=song[note];
dur=song[note+1];
if(kbhit())
{
break;
}
if(fre)
{
outportb(0x43,0xb6);
fre=(unsigned)(1193180L/fre);
outportb(0x42,(char)fre);
outportb(0x42,(char)(fre>>8));
control=inportb(0x61);
outportb(0x61,control|0x3);
}
goal=(clock_t)dur+clock();
while(goal>clock());
if(fre)
outportb(0x61,control);
goal=(clock_t)0;
note+=2;
}
}
- 让C语言演唱“渴望”
- 渴望
- 渴望...
- 渴望
- 渴望
- 渴望
- 2017,让奔跑开始,让冲刺变得渴望
- 让C语言更高效
- 逻辑人渴望控制那些让他们感兴趣的东西
- 让c语言指针不再困扰你
- bnu1285 渴望放假的cc老师 C语言版
- 我用C++Builder,渴望得到帮助,Q:853275606
- 学好C语言、C++,让你掌握自己的未来
- 坦白 陈楚生演唱
- 大肚腩(演唱:阿牛)
- 成就感!让学过C语言的你有成就感!
- 让gedit成为强大的C语言IDE
- c语言很多让我无语的地方
- 输入4个数字从小到大输出(c++)
- 图的链式存储(线性表)
- 在系统菜单中添加菜单项
- 深度优先搜索(图的遍历)
- QT
- 让C语言演唱“渴望”
- C语言老师(*^__^*) 嘻嘻……
- 电脑中常用的快捷键
- Linux操作系统作业
- Android开发中(关机键)power键解决思路
- 新人报到
- 盛大网络 陈天桥力挺360,腾讯再受打击
- 俄只能一直往前走,
- 我心目中的编程高手(完整版)