ALSA:如何临时更改输出设备

Bor*_*kov 17 alsa audio pulseaudio

我想在 ALSA 中做一件最简单的事情:让 USB 耳机产生声音,而不是平板电脑的内置扬声器。我不想更改配置文件,例如asound.rcoralsa.confasound.conf并通过更改设备的顺序将耳机永久设置为默认输出设备,我想要一个临时效果,直到我拔掉耳机。奇怪的是,我无法用谷歌搜索答案。有alsamixer能力做到这一点(似乎没有)?

在 Gnome 中,您可以PulseAudio在 GUI 或 CLI 界面中使用 轻松选择当前输出设备,但PulseAudio它本身在 ALSA 之上工作!所以我也想知道,它是如何强制 ALSA 更改输出设备的?

Jar*_*nen 4

如果 USB 设备在系统中被列为声卡,您可能需要检查man amixer并使用unmute参数。

\n\n
amixer -c 1 set Master playback 100% unmute\n
Run Code Online (Sandbox Code Playgroud)\n\n

还要检查其他通道(PCM 等)。手册中的示例是:

\n\n
   amixer -c 1 sset Line,0 80%,40% unmute cap\n          will set the second soundcard\'s left line input volume to 80% and right line\n          input to 40%, unmute it, and select it as a source for capture (recording).\n\n   amixer -c 1 -- sset Master playback -20dB\n          will set the master volume of the second card to -20dB.  If the  master  has\n          multiple channels, all channels are set to the same value.\n\n   amixer -c 1 set PCM 2dB+\n          will  increase  the PCM volume of the second card with 2dB.  When both play\xe2\x80\x90\n          back and capture volumes exist, this is applied to both volumes.\n\n   amixer -c 2 cset iface=MIXER,name=\'Line Playback Volume",index=1 40%\n          will set the third soundcard\'s second line playback volume(s) to 40%\n\n   amixer -c 2 cset numid=34 40%\n          will set the 34th soundcard element to 40%\n
Run Code Online (Sandbox Code Playgroud)\n

  • 这并没有真正解决最初的问题。您可以设置参数,但不会改变音频输出的卡。 (15认同)
  • 如果这确实回答了最初的问题,则需要一个完整的示例。这是如何做到 alsamixer 无法做到的事情的?显然,alsamixer 无法通过不同的声卡切换输出。或者,就我而言,我也想通过相同的声卡但 HDMI 而不是扬声器/耳机输出。Pulseaudio 可以实现这些功能,但是如何实现呢?需要从头到尾举例才能使这个问题成为一个好的答案。 (2认同)
  • 遗憾的是,这已被选为答案 - 问题正是我正在寻找的内容:如何临时更改用于输出的卡。然而,正如@oneself 已经指出的那样,这个答案实际上并没有解释如何做到这一点。现在提出一个标题几乎相同的新问题很可能会因为重复而被关闭。 (2认同)