Last active
August 29, 2015 14:18
-
-
Save NQNStudios/7b094e7d468514bbde56 to your computer and use it in GitHub Desktop.
This script uses PulseAudio commands to create a unified audio stream for microphone and system sounds, for live streaming.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a virtual sink for both audio streams | |
SINK_ID=$(pactl load-module module-null-sink sink_name=StreamAudio sink_properties=device.description=StreamAudio) | |
# find microphone source ID | |
MIC_ID=$(pactl list short sources | grep "Snowball" | cut -f1) | |
# loop microphone to the new sink | |
MIC_LOOPBACK_ID=$(pactl load-module module-loopback sink=StreamAudio source=$MIC_ID) | |
# find stereo monitor ID | |
STEREO_ID=$(pactl list short sources | grep "analog-stereo.monitor" | cut -f1) | |
# loop system sounds to the new sink | |
STEREO_LOOPBACK_ID=$(pactl load-module module-loopback sink=StreamAudio source=$STEREO_ID) | |
cleanup() { | |
pactl unload-module $MIC_LOOPBACK_ID | |
pactl unload-module $STEREO_LOOPBACK_ID | |
pactl unload-module $SINK_ID | |
exit | |
} | |
# call cleanup when the program is interrupted | |
trap cleanup INT | |
while [ 1 ]; do | |
# loop until interrupted | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment