Created
December 29, 2016 07:48
-
-
Save kristjanvariksoo/fd31f037ecd670976e7c843f3c321e22 to your computer and use it in GitHub Desktop.
Play music mixed together with your microphone through skype. Linux only. Uses pulseaudio.
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
from pulsectl import Pulse | |
import os | |
pulse = Pulse("volume-increaser") | |
N = 0 | |
for sink in pulse.sink_list(): | |
print str(N) + " - " + sink.description + " - " + sink.name | |
N += 1 | |
mainsink = pulse.sink_list()[int(raw_input("Select your preferred sink... "))] | |
print "Selected sink: " + str(mainsink) | |
print "" | |
print "" | |
print "" | |
N = 0 | |
for source in pulse.source_list(): | |
print str(N) + " - " + source.description + " - " + source.name | |
N += 1 | |
mainsource = pulse.source_list()[int(raw_input("Select your preferred source... "))] | |
print mainsource | |
print "" | |
print "" | |
print "" | |
print "Creating null0, Only Music..." | |
cmd = 'pactl load-module module-null-sink sink_name=null0 sink_properties=device.description="OnlyMusic"' | |
print cmd | |
os.system(cmd) | |
print "Created null0." | |
print "Creating null1, MusicANDMic..." | |
cmd = 'pactl load-module module-null-sink sink_name=null1 sink_properties=device.description="MusicANDMic"' | |
print cmd | |
os.system(cmd) | |
print "Created null1." | |
print "Creating loopback from Mic to MusicANDMic..." | |
cmd = 'pactl load-module module-loopback sink=null1 source=' + mainsource.name | |
print cmd | |
os.system(cmd) | |
print "Created loopback." | |
print "Creating loopback from JustMusic to Speakers..." | |
cmd = 'pactl load-module module-loopback sink=' + mainsink.name + ' source=null0.monitor' | |
print cmd | |
os.system(cmd) | |
print "Created loopback." | |
print "Creating loopback from JustMusic to MusicANDMic..." | |
cmd = 'pactl load-module module-loopback sink=null1 source=null0.monitor' | |
print cmd | |
os.system(cmd) | |
print "Created loopback." | |
print "Everything is done... Hopefully..." | |
print "Run pavucontrol and connect music to JustMusic and set Skype(or other similar service) to record from MusicANDMic." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mostly based on info from https://xenotoad.net/blog/?p=5.