2016-06-07 60 views
0

在Ubuntu 15.10中使用pulseaudio,我想將兩個不同的麥克風組合成一個接收器,並讓它們在兩個不同的輸出端上播放組合輸出。下面的腳本會完成第一部分(在網絡上找到它),但輸出似乎只能在單個輸出中播放。Pulseaudio - 組合麥克風在組合揚聲器水槽上播放輸出

做後面的步驟需要什麼?

#!/bin/bash 

# Script to map two pulseaudio hardware input sources as mono inputs 
# to left and right channel of a new loopback-sink respectively. This 
# sink can be used e.g. to use VoIP or record two microphones seperately. 
# Copyright (C) 2013, Henning Hollermann, [email protected] 
# 
# This program is free software: you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation, either version 3 of the License, or 
# (at your option) any later version. 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
# GNU General Public License for more details. 
# 
# You should have received a copy of the GNU General Public License 
# along with this program. If not, see <http://www.gnu.org/licenses/>. 

do_activate() { 
    while [ "x" = "x$LEFT" ]; do 
     echo "Choose Source for left channel by ID" 
     pactl list short sources 
     read ID 
     LEFT=$(pactl list short sources|awk '/^'$ID'/{print $2}') 
    done 
    while [ "x" = "x$RIGHT" ]; do 
     echo "Choose Source for right channel by ID" 
     pactl list short sources | grep -v $LEFT 
     read ID 
     RIGHT=$(pactl list short sources | grep -v $LEFT|awk '/^'$ID'/{print $2}') 
    done 
    # Create the name of the Combined sink 
    NAME="Combined_Mics:_Left:_"$(echo $LEFT|awk -F'.' '$0=$2')"_Right:_"$(echo $RIGHT|awk -F'.' '$0=$2') 

    echo "[LOAD] null sink as \"$NAME\" to connect the two mics to" 
    pactl load-module module-null-sink \ 
      sink_name=combined channels=2 \ 
      sink_properties="device.description=$NAME" 

    echo "[LOAD] map source 1 ($LEFT) to left channel of \"$NAME\"" 
    pactl load-module module-remap-source \ 
      source_name=${LEFT}_left_channel master=$LEFT channels=2 \ 
      master_channel_map=mono,mono channel_map=left,left 
    pactl load-module module-loopback sink=combined source=${LEFT}_left_channel 

    echo "[LOAD] map source 2 ($RIGHT) to right channel of \"$NAME\"" 
    pactl load-module module-remap-source \ 
      source_name=${RIGHT}_right_channel master=$RIGHT channels=2 \ 
      master_channel_map=mono,mono channel_map=right,right 
    pactl load-module module-loopback sink=combined source=${RIGHT}_right_channel 
    echo "[DONE] Now adjust the left and right channel volume of the new sink to be equally loud" 


} 

do_deactivate() { 
    echo "[UNLOAD] pulseaudio modules..." 
    echo "[UNLOAD] module-loopback" 
    pactl unload-module module-loopback 
    echo "[UNLOAD] module-remap-source" 
    pactl unload-module module-remap-source 
    echo "[UNLOAD] module-null-sink" 
    pactl unload-module module-null-sink 
} 

init() { 
    for exe in /usr/bin/pulseaudio /usr/bin/pactl; do 
     if [ ! -x "$exe" ]; then 
      echo "[ERROR] required file $exe not found or not executable" 
      exit 1 
     fi 
    done 
    [ ! -x /usr/bin/pavucontrol ] && echo "[NOTICE] pavucontrol might be very useful." 
} 

# MAIN 
init; 
case $1 in 
activate|enable|start) 
    do_activate;; 
deactivate|disable|stop) 
    do_deactivate;; 
*) 
    echo "Usage: $0 [enable|disable]";; 
esac; 

回答

0

這做了我想要的東西:

pactl load-module module-loopback latency_msec=1 source=alsa_input.pci-0000_00_1b.0.analog-stereo sink=bluez_sink.00_02_5B_00_FF_03 

pactl load-module module-loopback latency_msec=1 source=bluez_source.00_02_5B_00_FF_03 sink=alsa_output.pci-0000_00_1b.0.analog-stereo 
相關問題