如何使用 pactl 分别更改左右音量?

如何使用 pactl 分别更改左右音量?

pactl 手册页声称可以通过使用 set-sink-volume 命令简单地列出每个通道的音量来设置单独的通道音量:

set-sink-volume SINK VOLUME [VOLUME ...]
              Set the volume of the specified sink (identified by its symbolic
              name or numerical index). VOLUME can be specified as an  integer
              (e.g.  2000,  16384),  a linear factor (e.g. 0.4, 1.100), a per‐
              centage (e.g. 10%, 100%) or a decibel value (e.g. 0dB, 20dB). If
              the  volume specification start with a + or - the volume adjust‐
              ment will be relative to the current sink volume. A single  vol‐
              ume  value  affects  all channels; if multiple volume values are
              given their number has to match the sink's number of channels.

但据我所知,这并不起作用。

这有效:

pactl -- set-sink-volume @DEFAULT_SINK@ 125%

但事实并非如此:

pactl -- set-sink-volume @DEFAULT_SINK@ 125% 100%

并给出以下错误信息:You have to specify a sink name/index and a volume

我可以使用 pavucontrol 设置单独的音量,所以我知道硬件可以胜任。(硬件是一台“9 美元的计算机”CHIP 设备,物有所值。)

我是否遗漏了什么语法技巧来让 pactl 接受左右音量?

顺便说一句,pacmd 手册页并未暗示它可以单独设置频道音量——它记录的行为与我观察到的 pactl 非常相似。但我无法使用或测试 pacmd,因为它无法与在“系统”模式下运行的 pulseaudio 服务器(我的服务器就是)配合使用。

为了完整性,“list sinks”的输出(在使用 pavucontrol 设置单独的卷之后)是:

Sink #0
        State: RUNNING
        Name: alsa_output.platform-1c22c00.codec.analog-stereo
        Description: sun4i-codec Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 1
        Mute: no
        Volume: front-left: 92572 / 141% / 9.00 dB,   front-right: 65944 / 101% / 0.16 dB
                balance -0.29
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.platform-1c22c00.codec.analog-stereo.monitor
        Latency: 25624 usec, configured 26000 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "CDC PCM Codec-0"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "sun4i-codec"
                alsa.long_card_name = "sun4i-codec"
                alsa.driver_name = "sun4i_codec"
                device.bus_path = "platform-1c22c00.codec"
                sysfs.path = "/devices/platform/soc@01c00000/1c22c00.codec/sound/card0"
                device.string = "hw:0"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "58800"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "sun4i-codec Analog Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

答案1

回答我自己的问题,因为这个问题无效:我忽略了在我的嵌入式板上运行的 pulseaudio 版本很旧。从 githup pulseaudio repo 来看,这个错误可能在很多年前就被修复了。

如果我使用当前版本的 pactl 从我的设备远程运行,一切都会正常运行。

相关内容