Audio

ALSA:如何臨時更改輸出設備

  • February 17, 2022

我想在 ALSA 中做一件最簡單的事情:讓 USB 耳機而不是平板電腦的內置揚聲器產生聲音。我不想更改配置文件,例如asound.rcor alsa.confasound.conf並通過更改設備的順序將耳機永久設置為預設輸出設備,我想要一個臨時效果,直到我拔下耳機。奇怪的是,我不能用Google搜尋答案。有alsamixer能力做到這一點(似乎沒有)?

PulseAudio在 Gnome 中,您可以在其 GUI 或 CLI 界面中使用 輕鬆選擇目前輸出設備,但PulseAudio它本身可以在 ALSA 之上執行!所以我也想知道,它是如何迫使 ALSA 改變輸出設備的?

如果 USB 設備在系統中被列為音效卡,您可能需要檢查man amixer並使用該unmute參數。

amixer -c 1 set Master playback 100% unmute

還要檢查其他通道(PCM 等)。手冊中的範例如下:

  amixer -c 1 sset Line,0 80%,40% unmute cap
         will set the second soundcard's left line input volume to 80% and right line
         input to 40%, unmute it, and select it as a source for capture (recording).

  amixer -c 1 -- sset Master playback -20dB
         will set the master volume of the second card to -20dB.  If the  master  has
         multiple channels, all channels are set to the same value.

  amixer -c 1 set PCM 2dB+
         will  increase  the PCM volume of the second card with 2dB.  When both play‐
         back and capture volumes exist, this is applied to both volumes.

  amixer -c 2 cset iface=MIXER,name='Line Playback Volume",index=1 40%
         will set the third soundcard's second line playback volume(s) to 40%

  amixer -c 2 cset numid=34 40%
         will set the 34th soundcard element to 40%

引用自:https://unix.stackexchange.com/questions/88118