通过命令行更改音频输出

通过命令行更改音频输出

我需要使用命令行将模拟音频更改为 HDMI 音频。

pacmd list-sources
3 source(s) available.
    index: 131
    name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra3.monitor>
    driver: <module-alsa-card.c>
    flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: 
    priority: 1050
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 64 KiB
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 1
    linked by: 1
    configured latency: 40.00 ms; range is 0.50 .. 371.52 ms
    monitor_of: 122
    card: 0 <alsa_card.pci-0000_01_00.1>
    module: 6
    properties:
        device.description = "Monitor of GF108 High Definition Audio Controller Digital Stereo (HDMI 4)"
        device.class = "monitor"
        alsa.card = "1"
        alsa.card_name = "HDA NVidia"
        alsa.long_card_name = "HDA NVidia at 0xf7efc000 irq 17"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:01:00.1"
        sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1"
        device.bus = "pci"
        device.vendor.id = "10de"
        device.vendor.name = "NVIDIA Corporation"
        device.product.id = "0bea"
        device.product.name = "GF108 High Definition Audio Controller"
        device.string = "1"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
  * index: 132
    name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: 
    priority: 9959
    volume: front-left: 65540 / 100% / 0.00 dB,   front-right: 65540 / 100% / 0.00 dB
            balance 0.00
    base volume: 6554 /  10% / -60.00 dB
    volume steps: 65537
    muted: yes
    current latency: 0.06 ms
    max rewind: 0 KiB
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 1
    linked by: 1
    configured latency: 40.00 ms; range is 8.00 .. 371.52 ms
    card: 1 <alsa_card.pci-0000_00_1b.0>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "ALC892 Analog"
        alsa.id = "ALC892 Analog"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "0"
        alsa.card_name = "HDA Intel MID"
        alsa.long_card_name = "HDA Intel MID at 0xf5ff8000 irq 29"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1b.0"
        sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "3b56"
        device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
        device.form_factor = "internal"
        device.string = "front:0"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "32768"
        device.access_mode = "mmap+timer"
        device.profile.name = "analog-stereo"
        device.profile.description = "Analog Stereo"
        device.description = "Built-in Audio Analog Stereo"
        alsa.mixer_name = "Realtek ALC892"
        alsa.components = "HDA:10ec0892,10438436,00100302"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "audio-input-microphone"
        analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "audio-input-microphone"
        analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
            properties:

    active port: <analog-input-rear-mic>
    index: 242
    name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor>
    driver: <module-alsa-card.c>
    flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: 
    priority: 1950
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 64 KiB
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 2
    linked by: 2
    configured latency: 40.00 ms; range is 0.50 .. 371.52 ms
    monitor_of: 232
    card: 1 <alsa_card.pci-0000_00_1b.0>
    module: 7
    properties:
        device.description = "Monitor of Built-in Audio Analog Stereo"
        device.class = "monitor"
        alsa.card = "0"
        alsa.card_name = "HDA Intel MID"
        alsa.long_card_name = "HDA Intel MID at 0xf5ff8000 irq 29"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1b.0"
        sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "3b56"
        device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
        device.form_factor = "internal"
        device.string = "0"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"

过去,我可以通过以下方式将 MOBO 模拟音频输出更改为 ZOTAC HDMI 音频输出:

pactl set-card-profile 0 output:hdmi-stereo

pacmd set-card-profile 0 output:analog-stereo

但那是在我拥有一个 GPU 时,它通过 SPDIF 将音频从 MOBO 传输到 GPU。现在我拥有一个 GPU,它可直接从 PCIe 插槽获取音频。

我需要使用什么命令?我知道它在 GUI 控件中运行良好。我只需要它通过命令行工作。切换显示的部分已经起作用了。

答案1

这取决于你的情况。我从 HDMI 切换到模拟,

pacmd set-card-profile 0 "output:hdmi-stereo-extra1+input:analog-stereo" # To HDMI

pacmd set-card-profile 0 "output:analog-stereo+input:analog-stereo" # To analog

你可能想要把这些放在alias

查看我的相关回答这里

相关内容