答案1
1.加載環回模組
pacmd load-module module-loopback latency_msec=5
建立播放和錄音設備。
2. 在pavucontrol中配置設備
在 pavucontrol 中,在記錄選項卡,設定「環回」設備的從輸入設備到接收線路輸入訊號的設備。
在裡面回放選項卡,設定「環回」設備的在輸出設備到您想透過其聽到線路輸入訊號的設備。
3. 故障排除
如果音訊訊號有問題,請移除模組pacmd unload-module module-loopback
並重試更高的latency_msec=
值
補充筆記
您的現代中階電腦可以透過以下選項輕鬆管理較低的延遲latency_msec=1
:
pacmd load-module module-loopback latency_msec=1
這個答案是由這個論壇貼文。謝謝!
答案2
如中所述首選答案
pacmd load-module module-loopback latency_msec=5
應該創建一個播放和錄音設備,但似乎並不在所有情況下都有效。在這種情況下,您可以嘗試
pactl load-module module-loopback latency_msec=5
注意類似的參數,使用 pactl
對我來說,它不適用於 pacmd,但適用於 pactl。
注意:這兩個選項僅適用於脈衝音頻,不適用於 Pipewire
答案3
我這裡也有非常相似的情況! 2 台 PC,一台 Linux 電腦(我的主要電腦)和一台 Windows 電腦。我設定了一些不錯的東西來自動進行雙向音訊連接,使用我的耳機與 Linux 機器和 Pulseaudio,我既能聽到 Windows 機器的聲音,又能透過 Linux 對著麥克風說話,回到 Windows 機器麥克風在。
顯然,這不需要在機器之間連接 1 條 AUX 電纜,而是 2 條 AUX 電纜。但自從我弄清楚它一次以來,它就像一個魅力。為了讓任何有興趣做同樣事情的人都能輕鬆完成,我將在這裡分享我的腳本。要讓它工作,您需要做的就是為您的機器找到兩個特定的音訊接收器名稱,並將它們放入腳本的變數中(如果它們與我的不同)。
#!/usr/bin/env bash
# 2-way audio connection - Slaves 2nd device audio through this device:
# - Directs AUX in to default speakers (connect 2nd device -> AUX).
# - Directs Mic to AUX out (connect AUX out -> 2nd device AUX in).
#
# Then sleeps forever. Stops audio redirection when killed.
#
# Requires:
# sudo apt-get install pactl
#
# Manual Process:
# 1) pavucontrol > Configuration > Built-in Audio > Analog Stereo Duplex
# 2) Find - look for "analog-stereo" (no frills) in both commands:
# pacmd list-sources | grep name:
# pacmd list-sinks | grep name:
# 3) Select - enter found name or ID in this command:
# pactl load-module module-loopback source=$auxinsource source_dont_move=1 sink=$defaultsink
# 4) pavucontrol > Input > Built-in Analog Stereo > Line in (plugged in)
# 5) pavucontrol > Playback > Loopback from Built-in Analog Stereo > SELECT_SPEAKERS
# 6) pavucontrol > Output > Built-in Analog Stereo > Line Out (plugged in)
# 7) pavucontrol > Recording > Loopback to Built-in Analog Stereo > SELECT_HEADSET_MIC
#
# BREAKPOINT:
# read -n 1 -s -r -p 'BREAKPOINT'
auxinsource='alsa_input.pci-0000_00_1f.3.analog-stereo' # Get name of AUX in (Replace these with yours!)
micsink='alsa_output.pci-0000_00_1f.3.analog-stereo' # Get name of AUX out (Replace these with yours!)
set -e
printf '\n 1) Connect Audio IN (Win->)...'
defaultsink=$(pactl get-default-sink) # Get name of currently selected speakers
modulein=$(pactl load-module module-loopback source=$auxinsource source_dont_move=1 sink=$defaultsink) # Locked from manual selection in GUI, will not jump around
#modulein=$(pactl load-module module-loopback source=$auxinsource sink=$defaultsink) # Unlocked for manual selection in GUI, but may jump around
#echo ' ' $defaultsink ' connected!' # Debug output
echo ' connected!'
printf '\n 2) Connect Audio OUT (<-Mic)...'
modulemic=$(pactl load-module module-loopback latency_msec=10 source_dont_move=1 sink=$micsink) # Locked from manual selection in GUI, will not jump around
#modulemic=$(pactl load-module module-loopback latency_msec=10 sink=$micsink) # Unlocked for manual selection in GUI, but may jump around
#echo ' ' $micsink ' connected!' # Debug output
echo ' connected!'
printf '\n CTRL+C to stop' # Flavor text.
function cleanup
{
pactl unload-module $modulemic
if [ ! -z ${modulein+x} ]; then
pactl unload-module $modulein
else
echo
fi
}
trap cleanup EXIT
sleep infinity
對於此設定的逐步故障排除指導(可選),
#!/usr/bin/env bash
# Troubleshooting steps for audioconnect
#
# Requires:
# sudo apt-get install pactl
#
# BREAKPOINT:
# read -n 1 -s -r -p 'BREAKPOINT'
printf ' 1) pavucontrol > Configuration > Built-in Audio > Analog Stereo Duplex'
read -n 1 -s -r -p ''
echo ': OK'
printf ' 2) pavucontrol > Input > Built-in Analog Stereo > Line in (plugged in)'
read -n 1 -s -r -p ''
echo ': OK'
printf ' 3) pavucontrol > Playback > Loopback from Built-in Analog Stereo > SELECT_SPEAKERS'
read -n 1 -s -r -p ''
echo ': OK'
printf ' 4) pavucontrol > Output > Built-in Analog Stereo > Line Out (plugged in)'
read -n 1 -s -r -p ''
echo ': OK'
printf ' 5) pavucontrol > Recording > Loopback to Built-in Analog Stereo > SELECT_MIC'
read -n 1 -s -r -p ''
echo ': OK'