Jack connection saving and restoring
An overview of different tools to save and restore connections with the JACK Audio Connection Kit.
For a current project I needed a tool for automatically saving and restoring Jack connections. It turns out that there are several solutions to this problem, all of which differ slightly from each other. I spent a whole day trying to compare them, so I thought I'd share what I found:
LASH and jack session:
Both tools are only scarcely documented and under heavy development. I haven't tried either of them, but in my understanding both provide Jack session management not only in terms of maintaining audio connections, but they also automatically start the required Jack clients. For my usecase (a three-site network performance with remote Jack clients), this was more than I needed, so I did not investigate these tools in depth.
jmess is a command line tool for saving and loading jack connection setups. It gives a warning if any required clients are not present at the time of loading a setup (and connects all present clients as specified). jmess does not disconnect all existing connections before loading a new setup. You can do so manually using the -d flag, but this requires interactive confirmation by the user. Unfortunately this makes jmess non-scriptable in some situations. In these cases, jack_snapshot (see below) might be more useful. jmess is available for Linux and OS X.
Although this little command line tool is very similar to jmess, it does - by contrast - disconnect all existing connections before a new setup is loaded. This behavior can be overridden with the --noclear option, which needs to go at the very end of the jack_snapshot command. jack_snapshot gives a warning if any required clients are missing when a new setup is loaded (and connects all present clients as specified). There are no compiled binaries on the website, but I managed to compile jack_snapshot for both Linux and Mac OS X without trouble. This requires the 'make' utility, which is part of most Linux distributions and is also included with Apple's XCode Developer Tools. It also requires the pkg-config tool in order to link to Jack itself. pkg-config itself is quite straightforward to compile under OS X, again using 'make'.
If you manually edit a snapshot file made by jack_snapshot, you should be aware that you need to add a new line after the entry for the very last connection, or otherwise jack_snapshot will not recognize that last connection.
This GUI for the Jack server (which only works under OS X) also provides a means of saving and loading what is referred to as Studio Setups (see the File menu). It always disconnects all existing connections before loading a new setup. JackPilot presents a warning dialogue for any required client which is not present, but does connect all present clients as specified. (I had trouble with the 'retry' option of the warning message dialogue, which - after I had started the missing client - kept claiming that it was not available. After deciding to ignore the repeated error message, it turned out that the client did show up in the Connections window.) The JackPilot manual mentions something about 'Automatic Connection Restoration', but I think this only refers to the connection of clients which are temporarily muted (but not entirely gone). In my experience, JackPilot does not automatically restore connections of clients which have disappeared (for example because they crashed) and then restarted. The QJackCtl Patchbay (see below) can do that, however.
The QJackCtl Patchbay is a bit of a mystery, but there is a good article which explains it quite well. Although it works according to a somewhat different paradigm than the other tools discussed here, it is particularly interesting because it automatically connects newly appearing clients which are part of the stored setup. This can be particularly useful in live situations where a client might crash and need to be restarted as quickly as possible. Probably because of this autoconnection feature, QJackCtl does not issue a warning concerning any missing clients when the Patchbay is activated (but connects all present clients as specified). Also note that deactivating the Patchbay does not break any audio connections. In fact, the Patchbay never seems to disconnect anything whatsoever: If you switch from one Patchbay setup to another one, the connections for the second setup are added to the ones for the first setup. If that's not what you want you will have to first deactivate the first Patchbay setup, then manually 'Disconnect All' in the Connections window, and then load and activate the second setup.
The patchbay "profiles" (presets) are a bit tricky to handle, though. While they are in principle saved to standard .xml files, these files also receive an entry in QjackCtl.conf (which under Linux lives in $HOME/.config/rncbc.org/QjackCtl.conf). If you want to delete a profile, that means deleting both the .xml and its entry in QjackCtl.conf - and maybe even a reference to it in the "PatchbayPath" entry of QjackCtl.conf. If you just delete the .xml, you will get a warning message about its disappearance the next time you start QJackCtl.
One question that remains (because I haven't had time to test that yet) is how these tools behave when asked to make a connection which happens to already be present. In other words, are they intelligent enough to not re-connect existing connections? This can be crucial in live situations.