Persistent Cadence Jack MIDI connections

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

Post Reply
martibs
Established Member
Posts: 123
Joined: Mon Oct 15, 2018 7:06 pm
Location: Oslo, Norway
Has thanked: 34 times
Been thanked: 15 times

Persistent Cadence Jack MIDI connections

Post by martibs »

I have a home studio solution set up where I have a certain amount of hardware instruments hooked up to my computer, as well as a hardware MIDI sequencer to control all these devices, which is also connected to my computer via USB. I use Cadence to manage my Jack connections, and it works great. I establish the MIDI connections from my sequencer, and all is good:
Screenshot from 2020-01-10 21-11-15.png
Screenshot from 2020-01-10 21-11-15.png (37.63 KiB) Viewed 706 times
I have all of my equipment hooked up to the same power supply, and turn all the gear off when I don't use it, except the computer. When I turn everything on again, both Cadence and Jack is still running, and the devices show up. The connections I made, however are lost, and I have to reconnect them again.
Now, it's not really that many reconnections to make, but it's still a bit of a drag, especially when the software connections are persistent when I stop and start the apps. Is there any way to make the hardware MIDI connections persist as well?
martibs
Established Member
Posts: 123
Joined: Mon Oct 15, 2018 7:06 pm
Location: Oslo, Norway
Has thanked: 34 times
Been thanked: 15 times

Re: Persistent Cadence Jack MIDI connections

Post by martibs »

In case anyone else is facing a similar issue, this is how I solved it. A simple python script hooks the defined connections up. I simply run the script ad hoc. (Needs Jack for Python: https://jackclient-python.readthedocs.io)

Code: Select all

#!/bin/python3

import jack
import re

# List of devices
pyramid = 'Pyramid MIDI USB'
keystep = 'Arturia KeyStep 32'
digitone = 'Elektron Digitone'
digitakt = 'Elektron Digitakt'
timefactor = 'TimeFactor Pedal'
lexicon = 'Lexicon MX400'

# List of connections, out to in
connection_list = [[pyramid, digitone],
    [pyramid, digitakt],
    [pyramid, timefactor],
    [pyramid, lexicon],
    [keystep, pyramid]]

client = jack.Client('MyJackClient')

myPorts = client.get_ports(is_midi=True)
    
for clist in connection_list:
    out_pattern = ".*" + clist[0] + ".*" + "capture"
    in_pattern = ".*" + clist[1] + ".*" + "playback"
    r_out = re.compile(out_pattern)
    r_in = re.compile(in_pattern)
    
    for midiout in myPorts:
        if r_out.match(str(midiout)):
            for midiin in myPorts:
                if r_in.match(str(midiin)):
                    try:
                        client.connect(midiout, midiin)
                        print("Connected: \n" + str(midiout) + " -> " + str(midiin))
                    except jack.JackErrorCode:
                        print("Already connected: \n" + str(midiout) + " -> " + str(midiin))
Post Reply