Skip to content

Instantly share code, notes, and snippets.

@chmanie
Created January 26, 2021 18:02
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmanie/4f2838f4548d25b9c883f7d6d074f67c to your computer and use it in GitHub Desktop.
Save chmanie/4f2838f4548d25b9c883f7d6d074f67c to your computer and use it in GitHub Desktop.
Connect all MIDI inputs to all MIDI outputs (except themselves). Supports multi-port devices
#!/usr/bin/ruby
t = `aconnect -i -l`
$devices = {}
$device = 0
t.lines.each do |l|
match = /client (\d*)\:((?:(?!client).)*)?/.match(l)
# we skip empty lines and the "Through" port
unless match.nil? || match[1] == '0' || /Through/=~l
$device = match[1]
$devices[$device] = []
end
match = /^\s+(\d+)\s/.match(l)
if !match.nil? && !$devices[$device].nil?
$devices[$device] << match[1]
end
end
$devices.each do |device1, ports1|
ports1.each do |port1|
$devices.each do |device2, ports2|
ports2.each do |port2|
# probably not a good idea to connect a port to itself
unless device1 == device2 && port1 == port2
system "aconnect #{device1}:#{port1} #{device2}:#{port2}"
end
end
end
end
end
@drhitchcockco
Copy link

Has anyone had a Roland TB-03 working with their hub? When I run aconnect -l it can see the device and it's connected but I can't seem to access it from any of my other devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment