如何使电脑发声
来源:互联网 发布:制作二维码生成器软件 编辑:程序博客网 时间:2024/06/11 09:52
如何使电脑发声
声音的原理,通常,我们可以用C语言主程序调用两个库函数来使PC机发出声音。一个库SOUND( )的功能是:接上扬声器,使它能按要求的频率发声(即给定不同的C值),另一个库函数NOSOUND( )是关掉扬声器以禁止从定时器上向扬声器的输出。下面的主程序,重复的询问用户要产生哪一种声音。程序在设计方法上采用了循环,即询问用户要听什么样声音及听多长时间,重复发音所指定的次数。每种声音都是以一种特定的速率按一种特定的顺序通过一组频率而形成的
#define FALSE 0
#define TRUE 1
#include<dos.h>
main()
{
int snd; /* which sound to produce */
int cnt; /* number of times to repeat sound */
int note; /* Current note, when sweeping frequencies */
while (TRUE) {
/* Male Sure any previous sounds ave turned off. */
nosound();
/* Ask the user for which type of sounf*/
printf ("1-siren;2-overload;3-whoop;4-phaser; 0-exit");
/* read the answer */
scanf ("%d",&snd);
/* if the answer it to exit ,do so. */
if (snd==0)
break;
/* Ask how many times to repast the sound. */
printf ("Nunger of times:");
/* get the answer */
scanf("%d",&cnt);
/* repeat the sound the number of time specifed */
while(cnt--){
/* swich on type of sound to produce*/
switch (snd)
{case 1:
/* do a siren:sweep up */
for (note=1000;note>150;note-=10)
{
sound(note);
delay(20);
}
/* Sweep down */
for (;note<1000;note+=10)
{
sound(note);
delay(20);
}
break;
case 2: /* do an overload. sweep up */
for (note=4000;note>10;note-=10)
{
sound(note);
delay(70);
}
break;
case 3:
/* do a whoop: Sweep up*/
for (note=1000;note>10;note-=10)
{
sound (note);
delay (200);
}
break;
case 4:
/* do a phaser: sweep down */
for (note=60; note<2000;note+=10 )
{
sound (note);
delay(100);
}
break;
default:
/* unknown,ask a gain */
printf ( "Invalid entry;try again /n");
break;
}
}
}
}
- 如何使电脑发声
- C#使Pc喇叭发声
- C++ 发声函数如何成功使用
- Ubuntu的机器如何让beep发声
- 旁白陪你操作电脑 让Win7发声“讲述”
- 编写汇编程序,使PC嗡鸣器按乐谱发声
- 如何让win7系统发声 win7系统讲述人功能
- 如何使电脑进入DOS
- 终于使我的ACER 5583 前置耳麦发声了
- 怎样利用Java代码使主板蜂鸣器发声
- js 发声
- js 发声
- Wince 发声
- 模拟发声
- 省市区。。。。发声!!!
- 如何通过X1使电脑上网
- 如何自学电脑!
- 如何应对电脑辐射
- FileSee:文件查看习惯的革命
- 浪漫的夏季
- 碰撞的小球
- 飘动的红旗
- Eclipse常用热键介绍(zt)
- 如何使电脑发声
- 设置当前目录,并显示
- 声图并茂
- 成功项目的经验(转载)
- 激活中断驻留程序
- 数字音乐
- 过程式设计和面向对象设计的比较
- js常用判断表单合法性的函数
- 通用演奏程序