问题描述
在Linux中播放一个简单的哔声,但是我发现所有的东西都不起作用。
I have been looking for a way to play a simple beep in Linux, but all what I found don't work.
我试过\a,\b \7
I've tried the \a, \b \7 but anyone play the beep.
我想播放它,而不使用声音库,后来我会使用任何库更改哔哔声真正的声音,但右现在我只想为测试目的播放哔声。
I would like to play it without the use of sound libraries, later I will change the beep for a real sound using any library, but right now I'm only interested in play a beep for testing purposes
正如我所说,我使用Linux(正是LMDE),所以最简单的Windows方法.h和Beep())不能使用。
As I said, I'm using Linux (exactly LMDE) so the easiest way of Windows (include windows.h and Beep()) can't be used.
那么如何实现呢?一个系统调用或类似的东西。
So how could I implement this? A system call or something like that.
编辑:我结束了使用Java,我已经工作了。谢谢。
I ended doing it in Java and I have it working already. Thank you.
推荐答案
尝试纳入ncurses.h
Try including ncurses.h
#include <ncurses.h>
beep();
使用-lncurses标志编译
compile with the -lncurses flag
参考资料:
这个问题:
编辑:
尝试此命令行
也可以尝试
int ms = 5000;
int freq = 440;
ioctl(fd, KDMKTONE, (ms<<16 | 1193180/freq));
这篇关于(解决)在C ++(Linux)中播放beep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!