答案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'