Created
May 20, 2019 23:21
-
-
Save libasoles/5f157f8580ad5c558279c6e50447f505 to your computer and use it in GitHub Desktop.
Connect microKey to Fluid Synth (with ALSA aconnect)
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
# run as: python microKey2FluidSynth.py | |
import os | |
import re | |
alsaOutputs = os.popen("aconnect -o").readlines() | |
def getKeyboardClientID(): | |
return getClientID("microKEY") # could be any other | |
def getFluidSynthClientID(): | |
return getClientID("FLUID Synth") | |
def getClientID(condition): | |
conditions = ["client", condition] | |
for line in alsaOutputs: | |
if all(condition in line for condition in conditions): | |
clientStr = line.split(":")[0] | |
clientID = re.search('\d+', clientStr).group(0) | |
return clientID | |
return -1 | |
keyboardID = getKeyboardClientID() | |
fluidSynthID = getFluidSynthClientID() | |
command = "aconnect {}:0 {}:0".format(keyboardID, fluidSynthID) | |
print(os.popen(command).read()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment