windows8 中dev-c++ beep函数的头文件

windows8 中dev-c++ beep函数的头文件,第1张

这是一个API函数,不知道DEV C++支不支持,在VC++6.0使用的头文件是#include <windows.h>,你李闭肆可以试一试,看行不行,我没有哪轿装DEV C++,因此不能帮态手你测试。

全部给出,则程序笑者太长了。这里教你关键技术,然后你可以自己写程序。

(1)用 Beep函数 ,要 包含 头文件 #include <windows.h>

(2)Beep函数有2个参数数橡,第一个参数是声音的频率,第二个参数是所发声音长度毫秒

Beep(523,500) -- 中音 多,发0.5秒即500毫秒

Beep(587,500) -- 中音 来

Beep(659,500) -- 中音 米

Beep(698,500) -- 中音 法

Beep(784,500)-- 中音 少

Beep(880,500)-- 中音 拉

Beep(980,500)-- 中音 梯

Beep(1060,500)-- 高音 多

(3)休止符 用 Sleep(时间,单位毫秒)

如果 一拍用500毫秒,休息一拍 则为 Sleep(500)

d出抬棺音乐,则要按曲子一个薯升旁音符一个音符地去写。

例如:

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

int main () {

int t1=500,t05=250,t15=750

Beep(523,t1)Beep(587,t1)Beep(659,t1)

Beep(698,t1)Beep(784,t1)Beep(880,t1)

Beep(980,t1)Beep(1060,t1)

Sleep(t1)

Beep(523,t05)Beep(587,t05)Beep(659,t05)

Beep(698,t05)Beep(784,t05)

return(0)

}

曲子: 1234567高1 发音各500毫秒,停500毫秒, 12345 发音各250毫秒。

不需要头文件,直接调用即可。

MSDN中是这样定义的:

BOOL WINAPI Beep(

__in DWORD dwFreq,

__in DWORD dwDuration

)

Parameters

dwFreq

The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

Windows Me/98/携闭95: The Beep function ignores this parameter.

dwDuration

The duration of the sound, in milliseconds.

Windows Me/98/95: The Beep function ignores this parameter.

第一个参数是频率,其值为拿腔37到32767,单位为Hz

第二个参数是持续时间,单位为毫秒辩敏裂,1秒=1000毫秒。


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

原文地址: http://outofmemory.cn/tougao/12238370.html

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

发表评论

登录后才能评论

评论列表(0条)

保存