如何使用PC扬声器在Linux? [英] How to use PC speaker in linux?
本文介绍了如何使用PC扬声器在Linux?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用PC扬声器在Linux的C / C ++编程?
我可以控制的蜂鸣时间和频率?
How to use PC speaker in linux for c/c++ programming ? Can I control the beep time and freq?
推荐答案
从这里 措施:
Taken from here:
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/kd.h>
int main(void)
{
int freq[] = { /* C D E F G A B C */
523, 587, 659, 698, 784, 880, 988, 1046 };
int i;
for (i=0; i<8; i++)
{
ioctl(STDOUT_FILENO, KIOCSOUND, 1193180/freq[i]);
usleep(500000);
}
ioctl(STDOUT_FILENO, KIOCSOUND, 0); /*Stop silly sound*/
return 0;
}
这篇关于如何使用PC扬声器在Linux?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文