(解决)在C ++(Linux)中播放beep [英] (Solved)Playing beep in C++ (Linux)

查看:1603
本文介绍了(解决)在C ++(Linux)中播放beep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在C on Linux上哔声

在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

参考资料: http://invisible-island.net/ncurses/man/curs_beep.3x .html

这个问题:使用c ++发出声音(哔声)

编辑

尝试此命令行


sudo sh -cecho -e'\a'> / dev / console p>

sudo sh -c "echo -e '\a' > /dev/console"

也可以尝试 http://www.linuxplayer.org/2010/04/beep-your-pc-speaker-in-linux

int ms = 5000;
int freq = 440;
ioctl(fd, KDMKTONE, (ms<<16 | 1193180/freq));

这篇关于(解决)在C ++(Linux)中播放beep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆