我正在尝试合并两个麦克风输入和两个输出以在Skype,Linux CentOS7中使用 我知道我可以使用硬件混合器来做到这一点,但是我想尝试通过软件来实现。
只需完成一个bash脚本来组合输出,它就运行良好。试图合并输入内容使我发疯。
这是两个USB声卡麦克风输入的名称: alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-mono alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device_1.analog-mono
我在pacmd / pactl上找到了很多信息,并测试了许多命令,但没有任何效果。
#!/bin/bash
function getOutputs {
index=""
name=""
#declare -A sinks_list
# Get dirty sinks list
raw_sinks=`pacmd list-sinks`
# Parse the sources list
while IFS= read -r line
do
#Check if index and name are populated
if [ -n "$index" ] && [ -n "$name" ]
then
sinks_list[$index]=$name
index=""
name=""
fi
# Get indexs and index number
if grep -q index: <<<"$line"
then
index=$(echo "$line" | sed 's/[^0-9]*//g')
fi
# Get sound card output name and remove other than c-media soundcards
if grep -q name: <<<"$line" && grep -q stereo <<<"$line" && grep -q C-Media_Electronics_Inc._USB_Audio_Device <<<"$line"
then
name=$(echo "$line" | sed -e "s/name://" | sed 's|[<>,]||g'| tr -d '[:space:]')
fi
done <<< "$raw_sinks"
}
function getInputs {
index=""
name=""
#declare -A sources_list
# Get dirty sources list
raw_sources=`pacmd list-sources`
# Parse the sources list
while IFS= read -r line
do
#Check if index and name are populated
if [ -n "$index" ] && [ -n "$name" ]
then
sources_list[$index]=$name
index=""
name=""
fi
# Get indexs and index number
if grep -q index: <<<"$line"
then
index=$(echo "$line" | sed 's/[^0-9]*//g')
fi
# Get sound card output name and remove other than c-media soundcards
if grep -q name: <<<"$line" && grep -q mono <<<"$line" && grep -q C-Media_Electronics_Inc._USB_Audio_Device <<<"$line"
then
name=$(echo "$line" | sed -e "s/name://" | sed 's|[<>,]||g'| tr -d '[:space:]')
fi
done <<< "$raw_sources"
}
function combineOutputs {
soundcard_names=""
for K in "${!sinks_list[@]}";
do
# Set device default volume
pacmd set-sink-volume ${sinks_list[$K]} 65536
soundcard_names+=${sinks_list[$K]},
done
pacmd load-module module-combine-sink sink_name=MySink slaves=$soundcard_names
# Set default volume
pacmd set-sink-volume MySink 65536
# Set as default source
pacmd set-default-sink MySink
}
function combineInputs {
# Create a null sink to merge signals
pacmd load-module module-null-sink sink_name=MyLoopSink
# One by one add mics to the null sink
for K in "${!sources_list[@]}";
do
pactl load-module module-loopback source=$K sink=MyLoopSink
done
pacmd set-default-source MyLoopSink.monitor
# Create a virtual source. Note: using uplink_sink=MyLoopSink removes all the devices
pacmd load-module module-virtual-source source_name=loop_source
# Set as default source
pacmd set-default-source loop_source
}
# First restart pulseaudio to get sure we are working with a clean configuration
pulseaudio -k
sleep 10
# Combine Inputs
declare -A sources_list
getInputs
# Loop through array values
echo "Soundcard's inputs:"
for K in "${!sources_list[@]}";
do
echo $K --- ${sources_list[$K]}
done
combineInputs
# Combine Outputs
declare -A sinks_list
getOutputs
# Loop through array values
echo "Soundcard's outputs:"
for K in "${!sinks_list[@]}";
do
echo $K --- ${sinks_list[$K]}
done
combineOutputs
有任何线索吗?预先感谢。
答案 0 :(得分:0)
另一种解决方案是将JACK音频服务器与软件混合器和许多其他可用工具一起使用。我与一个小组合作,使用IDJC混合音频(包括Skype呼叫者),并通过Icecast在Internet上广播。 JACK中的图形patchbay不需要正确连接音频,但使它变得更加轻松快捷
pactl
命令应优先于Pulseaudio的脚本控制,但并非所有pacmd
命令在pactl
中都具有等效功能
pacmd
命令在终端外壳中运行,在使用直接命令的脚本中不起作用
echo
命令一起使用,命令将在脚本中工作。这是我在脚本中用于管理Pulseaudio到JACK连接的命令之一:
echo "set-default-sink voip2jack" |pacmd