Script for connecting midi

Optimize your system for ultimate performance.

Moderators: khz, MattKingUSA

User avatar
lilith
Established Member
Posts: 1035
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Script for connecting midi

Postby lilith » Fri Jun 14, 2019 7:31 pm

I'm getting a bit tired of connecting my midi keyboard by hand and thought about making a little sh script to do this.
After starting my PC I start my midi interface by hand. Then I start Carla by hand. After

Code: Select all

a2j -e
I get these connections in Catia:

Image

In order not to always connect MPK mini to MIDI through I want to use a script. Can anyone point me to a description how this can be done?
https://soundcloud.com/lilith_93
latest: https://soundcloud.com/lilith_93/days-of-terror
_____________________________
Debian 9 (XFCE) & KXStudio repos

nilshi
Established Member
Posts: 289
Joined: Wed Oct 22, 2008 9:05 pm
Contact:

Re: Script for connecting midi

Postby nilshi » Fri Jun 14, 2019 7:49 pm

I use this tool for exactly the task you described.

https://github.com/SpotlightKid/jack-matchmaker

User avatar
lilith
Established Member
Posts: 1035
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: Script for connecting midi

Postby lilith » Fri Jun 14, 2019 7:52 pm

Thanks, I see if I get it running.
https://soundcloud.com/lilith_93
latest: https://soundcloud.com/lilith_93/days-of-terror
_____________________________
Debian 9 (XFCE) & KXStudio repos

dave
Established Member
Posts: 11
Joined: Thu Nov 28, 2013 12:47 am

Re: Script for connecting midi

Postby dave » Sat Jun 15, 2019 4:54 am

nilshi wrote:I use this tool for exactly the task you described.

https://github.com/SpotlightKid/jack-matchmaker

Image
Dev should rename it, "Jill" (as in Jack & Jill)
Such a missed opportunity!

User avatar
bluebell
Established Member
Posts: 1138
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland & Frankfurt, Germany

Re: Script for connecting midi

Postby bluebell » Sun Jun 16, 2019 11:32 am

I use the following script to connect my MIDI keyboards to qtractor:

Code: Select all

#!/bin/bash

gx1=`aconnect -i | grep 'Client.*GX61' | cut -d " " -f 2 | tr -d ':'`
gx2=`aconnect -i | grep 'Client.*Code 61' | cut -d " " -f 2 | tr -d ':'`
qt=`aconnect -o | grep 'Client.*Qtractor' | cut -d " " -f 2 | tr -d ':'`

for KB in $gx1 $gx2
do
  for I in 0 1 2 3
  do
    aconnect ${KB}:${I} $qt:0
  done
done
Linux – MOTU UltraLite AVB – Qtractor – https://soundcloud.com/suedwestlicht

User avatar
lilith
Established Member
Posts: 1035
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: Script for connecting midi

Postby lilith » Sun Jun 16, 2019 12:15 pm

bluebell wrote:I use the following script to connect my MIDI keyboards to qtractor:

Code: Select all

#!/bin/bash

gx1=`aconnect -i | grep 'Client.*GX61' | cut -d " " -f 2 | tr -d ':'`
gx2=`aconnect -i | grep 'Client.*Code 61' | cut -d " " -f 2 | tr -d ':'`
qt=`aconnect -o | grep 'Client.*Qtractor' | cut -d " " -f 2 | tr -d ':'`

for KB in $gx1 $gx2
do
  for I in 0 1 2 3
  do
    aconnect ${KB}:${I} $qt:0
  done
done


Oops.... Do you have a link where this is explained?
https://soundcloud.com/lilith_93
latest: https://soundcloud.com/lilith_93/days-of-terror
_____________________________
Debian 9 (XFCE) & KXStudio repos

User avatar
bluebell
Established Member
Posts: 1138
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland & Frankfurt, Germany

Re: Script for connecting midi

Postby bluebell » Sun Jun 16, 2019 12:45 pm

lilith wrote:
bluebell wrote:I use the following script to connect my MIDI keyboards to qtractor:

Code: Select all

#!/bin/bash

gx1=`aconnect -i | grep 'Client.*GX61' | cut -d " " -f 2 | tr -d ':'`
gx2=`aconnect -i | grep 'Client.*Code 61' | cut -d " " -f 2 | tr -d ':'`
qt=`aconnect -o | grep 'Client.*Qtractor' | cut -d " " -f 2 | tr -d ':'`

for KB in $gx1 $gx2
do
  for I in 0 1 2 3
  do
    aconnect ${KB}:${I} $qt:0
  done
done


Oops.... Do you have a link where this is explained?


It's basic shell scripting and the use of aconnect. The 3 lines in the beginning use "aconnect -i" for MIDI inputs (my keyboards) and "aconnect -o" for Qtractor as output/destination.

It's all about finding out the client numbers.

grep 'Client.*Qtractor' -> find a line for Qtractor
cut -d " " -f 2 -> get "129:" out of "Client 129: 'Qtractor' [Typ=User]"
tr -d ':' -> remove the ":"

With those number I can run aconnect to make the connections. The "for I in 0 1 2 3" is due to the fact that one of my keaboard has 4 "sub"-clients. Don't know why. Maybe these represent the possible zones I could set on the keyboard.
Linux – MOTU UltraLite AVB – Qtractor – https://soundcloud.com/suedwestlicht

User avatar
lilith
Established Member
Posts: 1035
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: Script for connecting midi

Postby lilith » Sun Jun 16, 2019 2:27 pm

Thanks, I will play around with it.
https://soundcloud.com/lilith_93
latest: https://soundcloud.com/lilith_93/days-of-terror
_____________________________
Debian 9 (XFCE) & KXStudio repos


Return to “System Tuning and Configuration”

Who is online

Users browsing this forum: No registered users and 10 guests