Last active
July 20, 2021 22:19
-
-
Save Ozymandias42/b785f3ffc884538ee07b0c0813284cb3 to your computer and use it in GitHub Desktop.
Short Script that creates a streaming setup in pulseaudio.
This file contains hidden or 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
#!/usr/bin/env bash | |
#Short script that creates a streaming setup in pulseaudio. It does the following: | |
#1. Create a null-sink as ApplicationSink to separate a single applications audio from the rest | |
#2. Create remap-source as Virtual Microphone; AppSource | |
#3. Loopback the the ApplicationSink's audio back to the systems default audio output | |
#4. Loopback AppSink into virtual microphone AppSource | |
# ┌────────────┐ | |
# │ AppSource │ | |
# └─────▲──────┘ | |
# │ | |
#┌────────────┐ ┌─────┴──────┐ | |
#│ App2Stream ├────►│ AppSink │ | |
#└────────────┘ └─────┬──────┘ | |
# │ | |
#┌────────────┐ ┌─────▼──────┐ | |
#│ OtherApps ├────►│ SystemOut │ | |
#└────────────┘ └────────────┘ | |
#Function to choose a sink or source | |
function selectSinkOrSource(){ | |
local returnVal | |
select i in $(pactl list $1 short | cut -f2); do returnVal=$i ; break ; done | |
echo $returnVal | |
} | |
#Determine Sink to Redirect to Virtual Microphone | |
echo "Select output to redirect to virtual mic" | |
local selectedSink=$(selectSinkOrSource "sinks") | |
pactl load-module module-null-sink sink_name=ApplicationSink sink_properties=device.description=ApplicationSink | |
pactl load-module module-remap-source master=ApplicationSink.monitor source_name=AppSource source_properties=device.description=AppSource | |
#Loopback Output of ApplicationSink.monitor to System-Default-Out | |
pactl load-module module-loopback source=ApplicationSink.monitor sink="$selectedSink" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment