c语言中beep函数用法 c语言中begin

c语言中,beep是个什么函数?是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面:
TC 试:
#includedos.h
#includeconio.h
#includestdlib.h
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq2000L;freq+=200L){
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
}
nosound();/* stop playing */
}
void main()
{
mysound() ;
}
---------------
VC++ 试:
#include stdio.h
#include stdlib.h
#include windows.h
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
------
wintc 试验上两个 。
如何在linux中用c语言使用函数beep#include unistd.h // 头文件
int usleep(useconds_t usec); // 函数原型
usec -- 毫秒 。整数 。最大允许值:小于 1000000
返回 0 -- 表示调用执行成功,1 -- 失败 。
c语言中,beep是个什么函数是发声函数,运行后通过主板喇叭唱出旋律 , 可以试试下面:
TC 试:
#includedos.h
#includeconio.h
#includestdlib.h
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq2000L;freq+=200L){
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
}
nosound();/* stop playing */
}
void main()
{
mysound() ;
}
---------------
VC++ 试:
#include stdio.h
#include stdlib.h
#include windows.h
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
------
wintc 试验上两个 。
如何简单的输出不同频率的声音,C语言行吗?用 Beep 函数,参数1是频率,参数2是时间长度 。
下面唱 多来米发少啦西多......
MS VC++ 6.0 编译器
#include stdio.h
#include stdlib.h
#include windows.h
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Beep(880,500);
Beep(980,500);
Beep(1060,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
Beep(int ,int )怎么用?两个参数的用途分别是什么?BOOL
Beep(
DWORD
dwFreq,
//
Beep声音频率,单位Hz
DWORD
dwDuration
//
Beep声音持续时间,单位毫秒
);
程序示例c语言中beep函数用法:
#include
windows.h
int
main
(
void
)
{
int
i
=
2
;
while
(
i--
)
{
//Beep函数c语言中beep函数用法,使扬声器发出简单声音
//要调用这个函数需要加上头文件windows.h
//在Visual
C++
6.0下运行通过
Beep(1000,500);
}
return
0;
}
Beep是同步播放的c语言中beep函数用法,即播放完毕后返回,c语言中beep函数用法我都使用线程达到异步播放 。
beep函数的问题!只要你有乐谱 。根据乐理 , 就可以走在调上 。比如:
你可以写一个文件 , 存储你自己的声音格式:

推荐阅读