Page 1 of 1

Script for connecting midi

Posted: Fri Jun 14, 2019 7:31 pm
by lilith
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?

Re: Script for connecting midi

Posted: Fri Jun 14, 2019 7:49 pm
by nils
I use this tool for exactly the task you described.

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

Re: Script for connecting midi

Posted: Fri Jun 14, 2019 7:52 pm
by lilith
Thanks, I see if I get it running.

Re: Script for connecting midi

Posted: Sat Jun 15, 2019 4:54 am
by dave
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!

Re: Script for connecting midi

Posted: Sun Jun 16, 2019 11:32 am
by bluebell
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

Re: Script for connecting midi

Posted: Sun Jun 16, 2019 12:15 pm
by lilith
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?

Re: Script for connecting midi

Posted: Sun Jun 16, 2019 12:45 pm
by bluebell
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.

Re: Script for connecting midi

Posted: Sun Jun 16, 2019 2:27 pm
by lilith
Thanks, I will play around with it.