Aj-snapshot is a small program that can be used to make snapshots of the connections made between JACK and/or ALSA clients. Because JACK can provide both audio and MIDI support to programs, aj-snapshot can store both types of connections for JACK. ALSA, on the other hand, only provides routing facilities for MIDI clients. You can also run aj-snapshot in daemon mode if you want to have your connections continually restored.

Aj-snapshot is meant to be used from the command line. To make a new snapshot, just type:

aj-snapshot filename

in a terminal window, where filename can be any name you choose for your snapshot file. (be careful that you don't overwrite important files)

If the name of this file is the name of an existing file, aj-snapshot will ask if you want to overwrite that file. You can force aj-snapshot to overwrite existing files with the '-f,--force' option.

When you make a snapshot, all the currently active connections are saved in an XML file with your chosen name. Once you have made a snapshot file, you can restore it at any later time with the '-r, --restore' option:

aj-snapshot -r filename

The default behaviour of aj-snapshot is to store/restore both ALSA and JACK connections. When you want aj-snapshot to store/restore only JACK or ALSA connections, you can do this with the '-a,--alsa' or '-j,--jack' options. EXAMPLES:

aj-snapshot -a filename (store ALSA connections to file)
aj-snapshot -ra filename (restore ALSA connections from file)
aj-snapshot -j filename (store JACK connections to file)
aj-snapshot -rj filename (restore JACK connections from file)

When you restore connections with aj-snapshot, the default behaviour is to leave all existing connections untouched, and to add the connections from the snapshot file on top of those. If you want to restore the exact state of the system, you have to tell aj-snapshot to remove all existing connections before doing the restore. This can be done with the '-x,--remove' option. In combination with the -a or -j options, aj-snapshot will only remove the existing ALSA or JACK connections respectively. EXAMPLES:

aj-snapshot -rx filename (remove all existing ALSA and JACK connections before restoring ALSA and JACK connections from filename)
aj-snapshot -rax filename (remove all existing ALSA connections before restoring ALSA connections from filename)
aj-snapshot -rjx filename (remove all existing JACK connections before restoring JACK connections from filename)

When specify the '-x' option, without supplying a filename argument, aj-snapshot will just remove all existing ALSA and/or JACK connections without any further action. EXAMPLES:

aj-snapshot -x (remove all existing ALSA and JACK connections).
aj-snapshot -ax (remove all existing ALSA connections).
aj-snapshot -jx (remove all existing JACK connections).

When you specify the '-d, --daemon' option, aj-snapshot will keep on running until it is stopped, restoring connections while clients and ports appear. EXAMPLE:

aj-snapshot -d filename &

When aj-snapshot starts in daemon mode, it will try to restore the connections from the snapshot file once. After that, aj-snapshot will check if new ports were registered in ALSA or JACK (every second by default), and will try to restore your connections when this happens.

With the '-p, --poll' option, you can control how often aj-snapshot will check if new ports were registered. You can specify a value in milliseconds after this flag. EXAMPLE:

aj-snapshot -d -p 200 filename &

You can ask the daemon to reload the XML file by sending it the HUP signal. This makes it possible to add or remove connections while the daemon is running, store the new connection state by overwriting the existing XML file with another instance of aj-snapshot, and reload the file by sending the HUP signal to the daemon. When combining '-d' and '-x' options, all connections are removed before the daemon reloads the XML file. EXAMPLE:

aj-snapshot -dx filename &
...add more connections...
aj-snapshot -f filename
kill -HUP $(pidof aj-snapshot)

NOTE: When the JACK server shuts down or crashes, aj-snapshot will keep running and wait until JACK becomes available again. If so, it will try to reconnect to JACK. Of course, you will have to restart all the clients that crashed with JACK, so that aj-snapshot can restore the connections between them.

With the '-i, --ignore' option, you can ask aj-snapshot to ignore certain clients. You can repeat this option (upto 50 times). You have to specify one client name as an argument to this option, and the name has to be the exact name of that client. (TIP: you can look it up in the your snapshot file) When the client name contains spaces, or any other special characters, these have to be quoted from the shell. You can ignore clients when you store, or when you restore connections. Ignoring clients when restoring will keep the snapshot file intact. EXAMPLES:

aj-snapshot -i 'Midi Through' -i Ardour2 filename
aj-snapshot -ar -i fluidsynth filename

With the '-q, --quiet' option, you can ask aj-snapshot to not print any information about what happens when storing/restoring connections. This includes the information about failed connections, which are not considered real errors in this context.

If you want to get a recent deb package for Ubuntu, you can add this ppa to your software sources.


Aj-snapshot is available under the GPLv3 licence.