Beep(int ,int )怎么用?两个参数的用途分别是什么?

Beep(int ,int )怎么用?两个参数的用途分别是什么?,第1张

BOOL Beep( DWORD dwFreq, // Beep声音频率,单位Hz DWORD dwDuration // Beep声音持续时间,单位毫秒)程序示例: #include <windows.h>int main ( void ) { int i = 2 while ( i-- ) { //Beep函数,使扬声器发出简单声音 //要调用这个函数需要加上头文件windows.h //在Visual C++ 6.0下运行通过 Beep(1000,500)} return 0}Beep是同步播放的,即播放完毕后返回,我都使用线程达到异步播放。

是发声函数,运行后通过主板喇叭唱出旋律,可以试试下面:

TC 试:

#include<dos.h>

#include<conio.h>

#include<stdlib.h>

/* this founction plays sound until hit any key */

void mysound()

{

long freq

while(!kbhit()){/* while no keyboard hit, play sound */

for(freq=200Lfreq<2000Lfreq+=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 试验上两个


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11329823.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存