Script for connecting midi

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Script for connecting midi

Post 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?
nils
Established Member
Posts: 537
Joined: Wed Oct 22, 2008 9:05 pm
Has thanked: 35 times
Been thanked: 94 times
Contact:

Re: Script for connecting midi

Post by nils »

I use this tool for exactly the task you described.

https://github.com/SpotlightKid/jack-matchmaker
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Script for connecting midi

Post by lilith »

Thanks, I see if I get it running.
dave
Established Member
Posts: 11
Joined: Thu Nov 28, 2013 12:47 am

Re: Script for connecting midi

Post 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!
User avatar
bluebell
Established Member
Posts: 1909
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 111 times
Been thanked: 116 times

Re: Script for connecting midi

Post 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

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Script for connecting midi

Post 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?
User avatar
bluebell
Established Member
Posts: 1909
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 111 times
Been thanked: 116 times

Re: Script for connecting midi

Post 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.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Script for connecting midi

Post by lilith »

Thanks, I will play around with it.
Post Reply