一个麻将游戏的音频问题

我在游玩KDE下自带的一个棋牌游戏Kajongg,但是我打开它之后提示:
由于缺少 ogg123 程序,游戏中您将听不到声音
这是个软件吗?我用pacman搜不到这个。我要如何呢?请帮我查阅arch相关wiki和KDE相关wiki和其他社区网站,帮我找到解决方法.后来我安装成功ogg123了,我安装成功了,但是好像还是播放不了ogg格式的音频呀:
❯ ogg123 b1.ogg

Audio Device: Advanced Linux Sound Architecture (ALSA) output

Playing: b1.ogg
Ogg Vorbis stream: 2 channel, 44100 Hz
Artist: Petra
Date: 2012
Genre: Speech
ReplayGain Peak (Track): 0.02117040
ReplayGain (Track): +24.88 dB
ReplayGain Peak (Album): 0.04360583
ReplayGain (Album): +26.10 dB
ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
ERROR: Cannot open device alsa.
Sound
Playing gives you a much nicer experience if you hear players claim tiles and announce discards. It also makes playing easier because you can concentrate on your own tiles, you do not have to watch what others discard.

Kajongg comes with voices for different players. It automatically assigns voices to players. For every language there should be four voices, preferably two male and two female. Kajongg tries to use voices in the same language Kajongg runs in. If it finds no voices in that language, Kajongg will fallback to other languages, using the same fallback languages you defined for Kajongg (see Help → Switch Application Language). If no voice files exist yet for your language, you are invited to record and contribute them to Kajongg.

This is how you can generate voices yourself. There is a separate folder for every voice. Please note that those folders may be somewhere else on your system, they depend on how KDE was installed. Only the part starting with kajongg is always the same. There are two groups of voices with different places in the file system:

Predefined voices for every language. They live in a folder like /usr/share/kajongg/voices/LANG where LANG is the code for your language. The voice directories directly under …/kajongg/voices/ are the US-english versions. Predefined voices are randomly assigned to players. Those voices have names like “male1 male2 female1 female2” but those names do not matter, the user will never see them.

User voices can be defined for a specific user. If Kajongg makes use of such a voice, it can automatically be transferred to other players over the internet. Those voices live in a folder like ~/.local/share/apps/kajongg/voices/. So if your login name is joe, this might be /home/joe/.local/share/apps/kajongg/voices/joe/. The folder voices/ might not yet exist - if so, create it.

Now that you know where to place your new voice, generate a new folder for it.

In that subfolder, you can place the sound files. They have to be encoded with the Ogg Vorbis audio compressor, the file names need to have the extension .ogg. A single file has a name like s3.ogg - this is Stone 3. You should define such files for all tiles and for all claims and announcements. But if a sound file is missing, nothing bad happens - you just will not hear that sound. Fallback to other voices or languages only works for entire voices, not for single sound files.

After having defined all sound files for a predefined voice, please make sure that the Kajongg process has write permission in the new voice folder. Start Kajongg and test the voice. After everything is OK, you can revoke write permission (and you should do so for predefined voices). Kajongg will automatically generate a file named md5sum containing a checksum over all sound files. Whenever you change, add or delete a sound file for a voice, Kajongg will try to rewrite that file.

Please make the length of the sound short but speak clearly - this game can be played very fast when you get used to it. It is easier if you first write down a list with everything that should be spoken. Do not read it as a sequence of items, try to pronounce each item as if it were the only one and as you would when playing. Leave room between the items. Reading this needs a little practicing.

This is just one possibility to create the sound files:

Record a sound file with the program qarecord, save it in the WAV format. In this single sound file, speak all of the sounds.

Edit that file with the sound editor audacity. In that editor, use the mouse to mark a range of the sound waves. The editor will play that part. Repeat until you have the correct part selected. This may be easier if you View → Zoom In. Use the menu command File → Export Selection and save in the .ogg format. Under Options, choose low quality - this is sufficient and even wanted because this reduces the time to transfer the sounds to the other players.

The following are the names of the files that you should generate. Always append .ogg to them:

Table 6.1. Sound file names

s1 .. s9 Stone 1 to Stone 9
b1 .. b9 Bamboo 1 to Bamboo 9
c1 .. c9 Character 1 to Character 9
we ws ww wn The winds East, South, West, North
db dr dg The dragons blue/white, red, green
chow pung kong mahjongg The major claims
originalcall violatesoriginalcall Original Call and its violation
dangerousgame A player lets off a cannon (dangerous game)
nochoice A player declares he has no choice but to play dangerous game

Prev Contents Next
Interface Overview Tiles options
Would you like to make a comment or contribute an update to this page?
这是这个游戏中关于声音设置的说明。我现在安装了ogg123,的确不会报错提示了,但是还是没有声音。这些说明有帮助吗?


这是一个典型的配置冲突!非常感谢您提供 /etc/libao.conf 的具体内容。

根据您当前 Arch/KDE 系统的环境以及我们之前对 ogg123 错误的分析(ERROR: Cannot open device alsa),您应该将配置从直接使用 ALSA 切换到使用 PulseAudioPipeWire (通过其 PulseAudio 兼容层)。

请按照以下步骤处理这三行内容:

📝 /etc/libao.conf 处理方案

原配置行 建议修改方式 目的/说明
default_driver=alsa 更改为 default_driver=pulse 关键修改。 强制 ogg123 (通过 libao) 使用您的声音服务器(PulseAudio 或 PipeWire)驱动,以避免直接尝试独占 ALSA 设备而失败。
dev=default 注释掉 (添加 #):#dev=default 关键修改。 搜索结果显示,在某些系统上,保留此行会导致 libao 的 ALSA 驱动(即使是转发到 PulseAudio 的 ALSA 驱动)出现问题。将其注释掉通常是更安全的选择。
quiet 保持不变或注释掉:#quiet 这个选项只是抑制 ogg123 的部分输出信息。您可以选择保留或注释掉。为了调试方便,建议先注释掉或删除,以便在播放时看到更多调试信息,确认驱动是否已切换为 pulse

✍️ 最终文件内容

请用 sudo nano /etc/libao.conf 编辑文件,并将其内容修改为:

代码段

1
2
3
4
# /etc/libao.conf
default_driver=pulse
# dev=default
# quiet # 建议先注释掉,方便确认是否切换到 pulse

🚀 后续步骤

  1. 保存文件并退出 nano

  2. 重新测试 ogg123

    Bash

    1
    ogg123 b1.ogg

    预期输出变化:

    • Audio Device: Advanced Linux Sound Architecture (ALSA) output 应该会变为 Audio Device: PulseAudio Output

    • ERROR: Cannot open device alsa 应该消失,并且您应该能听到声音。

  3. 重新启动 Kajongg 并测试游戏中的声音。

如果仍有问题,请将修改后的 ogg123 b1.ogg 运行结果告诉我。如果声音依然无法播放,我们需要进一步检查您的 PulseAudio/PipeWire 服务状态。

您希望我为您准备检查 PulseAudio 或 PipeWire 状态的命令吗?


一个麻将游戏的音频问题
https://mingzaitown.github.io/2025/11/01/Linux/Arch/一个麻将游戏的音频问题/
作者
MingZai
发布于
2025年11月2日
许可协议