ubuntu 上的工具包没有发出蜂鸣声

发布于 2024-12-04 22:05:08 字数 928 浏览 1 评论 0原文

我在使用 Toolkit 的蜂鸣声时遇到问题。我在 /etc/modprobe.d/blacklist.conf 中注释掉了两条扬声器禁用行。我无法使用控制台代码 7 发出蜂鸣声,因为我需要它在 Swing 中工作,并且我希望它在 Eclipse IDE 中能够听到(而不是在类似控制台的窗格中显示特殊符号)蚀)。当不在 Eclipse IDE 中时,我测试了代码 7 并发现可以听到它的声音,所以我知道这不是连接器松动的问题。我确实通过 .wav 文件获得了不错的声音效果,但有时我只想要一个简单的蜂鸣声,并且不想使用大量 CPU 周期来实现它。目前我正在使用 Runtime.getRuntime().exec("beep") ,但这似乎也有点过度。我用的是ubuntu 10.10。电脑板是技嘉MA 770 UD3。下面是有问题的程序。

import java.awt.Toolkit;

public class Beeper
{
    public static void main(String[] args)
    {
        Toolkit.getDefaultToolkit().beep();
    }
}

来自 blacklist.conf 的内容如下。

# low-quality, just noise when being used for sound playback, causes
# hangs at desktop session start (Ubuntu: #246969)
#blacklist snd_pcsp

# ugly and loud noise, getting on everyone's nerves; this should be done by a
# nice pulseaudio bing (Ubuntu: #77010)
#blacklist pcspkr

I am having problems with Toolkit's beep. I commented out the two speaker disabling lines in /etc/modprobe.d/blacklist.conf. I cannot use the console code 7 to beep because I need it to work in Swing and I would like it to be audible in Eclipse IDE (rather than to show a special symbol in the console-like pane in Eclipse). When not in the Eclipse IDE, I have tested code 7 and found it to be audible so I know it is not a loose connector problem. I do have nice sound effects via .wav files but sometimes I just want a simple beep and I don't want to use a lot of CPU cycles to achieve it. Presently I am using Runtime.getRuntime().exec("beep") but that also seems a bit excessive. I am on ubuntu 10.10. The computer board is a Gigabyte MA 770 UD3. Below is the offending program.

import java.awt.Toolkit;

public class Beeper
{
    public static void main(String[] args)
    {
        Toolkit.getDefaultToolkit().beep();
    }
}

From blacklist.conf is the following.

# low-quality, just noise when being used for sound playback, causes
# hangs at desktop session start (Ubuntu: #246969)
#blacklist snd_pcsp

# ugly and loud noise, getting on everyone's nerves; this should be done by a
# nice pulseaudio bing (Ubuntu: #77010)
#blacklist pcspkr

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻安 2024-12-11 22:05:08

我猜你的 pcspks 模块没有加载...我遇到了同样的问题,发现在我的系统(14.04 LTS)上,它没有加载。

通过执行 lsmod | 检查它是否已加载grep pcspkr 在终端中。如果您得到类似的行,

pcspkr                 12718  0 `

则已加载。如果您没有从命令中得到任何输出,请尝试加载模块:

sudo modprobe pcspkr

这对我来说很有效。

I guess that your pcspks module isn't loaded... I had the same problem and found out that on my system (14.04 LTS), it wasn't.

Check if it's loaded by doing a lsmod | grep pcspkr in a terminal. If you get a line similar to

pcspkr                 12718  0 `

it is loaded. If you do not get any output back from the command, try to load the module:

sudo modprobe pcspkr

That did the trick for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文