User Tools

Site Tools


Robust Session Management

For live synth, we have to have the ability to change patches on the fly, in a very reliable and predictable fashion. There are a few projects out there which are striving towards this, but this writer has not (at this writing, 4/26/2014) found any of them bulletproof enough for live stage use. Let’s face it, if we’re live we need to hit a button and know that it will do what we want, period. Some day one or more GUI tools may reach this level, but until then, here is what I am using:

QJackCTL for setup, diagnostics, and testing

QJackCTL is the venerable, generally default, and most complete single tool for setup, testing, and configuration of the Jack audio system and ALSA MIDI interprocess/hardware patching too. There are newer tools which match possibly all of its functionality, but probably not yet its reliability. When building a new OS install, setting up for new hardware, and figuring out what I haven’t got set up right, I use this as primary tool, just as in the Primer. But like most audio tools for general-purpose computing platforms, it was not designed for the live stage, it was designed for the studio, so other tools are needed when it’s time to play the music.

aj-snapshot for management of Jack and ALSA MIDI connections

aj-snapshot is a command-line and background-service tool which easily manipulates as many different Jack and ALSA MIDI connection sets as desired. It is not GUI at all, so often I create a connection set using QJackCTL and then write it to a file for future use in one of my patches with aj-snapshot. It runs in the background at all times to maintain the current connection set.

The DBus version of Jack2

Jack is a background process which connects audio and MIDI applications and hardware. It used to be a simple user-level application, run as needed and then turned off when not. Jack2 is a version rebuilt with multicore CPUs in mind, and the DBus version is more recent yet. I have found the DBus version to be very cleanly and smoothly controllable, especially in the script/automation fashion I need for absolutely predictable startup and solid session management. Recent versions of QJackCTL works with this very well, one just has to make sure that the QJackCTL configuration matches script settings.

Overview of Operation

The idea here is, I want it to run well without keyboard, mouse or screen at all; and if I want to be able to switch patches, I want to just plug in a keyboard and use F-keys. So at powerup, it uses Linux built-in auto-login, starts X automatically, and then runs bash script START-INITIAL. START-INITIAL calls the default patch script, which is START-SRO. After START-SRO runs, it's ready to go, if MIDI and PA are connected it will sing!

The initialization script, START-INITIAL

When this machine boots, it does auto-logon, and runs the below.

  • x11vnc gives me VNC control the machine, so I don't have to plug in a screen for GUI access of the live machine.
  • The logs can build up rather large; deletion is prudent.
  • Before starting Jack, prepare most of its parameters. You'll notice that I'm using a firewire interface now. In order to have MIDI devices visible in Jack, I load the ALSA MIDI device as a secondary, “slave”, driver.
echo ''
echo 'Initiating environment...'
echo ''
nohup /home/jeb/ &
echo ''
echo 'Cleaning up old logs...'
echo ''
rm ~/.log/jack/jackdbus.log
rm ~/.log/a2j/a2j.log
rm ~/.log/lash/lash.log
echo ''
echo 'Starting jackd via dBus and configuring...'
echo ''
jack_control ds firewire
jack_control dps capture 0
jack_control dps playback 0
jack_control dps rate 96000
jack_control dps period 64
jack_control asd alsarawmidi
jack_control start
jack_control eps realtime true
jack_control eps realtime-priority 75
jack_control eps clock-source 1
/home/jeb/START-SRO &

A patch script, START-SRO

There are as many of these as there patches in the current rig. They all work like this:

  1. Kill all relevant audio generation, audio filtration, MIDI, and connection processes. One would think that two of these would not be necessary, and using loops to kill them one at a time has been tested too; for some reason, this way works best!
  2. Kill the jackd process, to erase all jackd connections. Several other methods were tried, this has been the only completely reliable.
  3. Start all relevant audio generation and filter processes needed for this patch. 'schedtool' runs them at high priority. There is much documentation suggesting that this is not necessary and possibly disindicated, but I have many hours of testing to prove otherwise to my satisfaction :-)
  4. Mididings is a programming tool by which one can make a script to combine and multiply MIDI streams reliably (it can do a whole lot more than that as well!). This patch needs it badly, because we have one MIDI source going to three processes; without this, lost keydowns, keyups, pedaldowns, and pedalups have been observed. The contents of will be pasted further down.
  5. Copy the correct connection set file (AJSRO.xml) for this patch, onto the current connection set file which aj-snapshot uses at all times (AJRunning.xml).
  6. Start aj-snapshot, have it read its current connection set file (AJRunning.xml) and make all connections it finds.

This particular patch, SRO, combines two simultaneous Yoshimi processes, running different configurations stored in the Yoshimi storage area (/home/username/YOSHIMI), using a compressor to keep things under control and reverb, both in Rakarrack.

Here is START-SRO:

# Stop any running audio elements
echo "Stop any running audio elements..."
killall -9 -w yoshimi fluidsynth zita-j2a aj-snapshot guitarix calfjackhost non-mixer rakarrack mididings lashd
killall -9 -w yoshimi fluidsynth zita-j2a aj-snapshot guitarix calfjackhost non-mixer rakarrack mididings lashd
# Remove all connections 
echo "Stopping Jackd to remove all connections..."
killall -9 -w jackdbus
killall -9 -w jackdbus
jack_control stop
echo "Starting Jackd..."
jack_control start
sleep 2
# Start all relevant audio elements
echo "Start all relevant audio elements..."
nohup schedtool -R -p 90 -e mididings -f /home/jeb/ 	\
	> /home/jeb/LOGS/Combine.log &
nohup schedtool -R -p 90 -e calfjackhost --client CalfSRO 	\
	eq12:SRO ! reverb:SRO ! Compressor:SRO 			\
	> /home/jeb/LOGS/calfjackhost-SRO.log &
nohup schedtool -R -p 90 -e yoshimi -N YoshSRO1 -j -l /home/jeb/YOSHIMI/SROpart1.xmz  \
	> /home/jeb/LOGS/Yoshimi-SRO1.log &
nohup schedtool -R -p 90 -e yoshimi -N YoshSRO2 -j -l /home/jeb/YOSHIMI/SROpart2.xmz  \
	> /home/jeb/LOGS/Yoshimi-SRO2.log &
nohup schedtool -R -p 90 -e yoshimi -N YoshSRO3 -j -l /home/jeb/YOSHIMI/SROpart3.xmz  \
	> /home/jeb/LOGS/Yoshimi-SRO3.log &
sleep 2
# And lastly, create jackd connections using aj-snapshot
echo "And lastly, create jackd connections using aj-snapshot..."
cp /home/jeb/AJSRO.xml /home/jeb/AJRunning.xml
nohup schedtool -R -p 90 -e aj-snapshot -d AJRunning.xml &

and here is for current Arch Linux. Mididings does have to be installed, it is available in many distros. Some may need /usr/bin/python or another substitution in the first line.

from mididings import *


Solid controllability is always a dire need on the live stage. One simple method is to be to assign function keys to run patch scripts using window manager keymappings. I use LXDE as my window manager for synth, because it places very little burden on the system and yet gives me all the GUI I want to get things done; and happily, LXDE uses a very straightforward XML file for keyboard configuration among other things.

To set a new keystroke to run START-SRO, I do as follows:

  1. Edit the appropriate file:
  2. Search for the end of the keyboard setup area, which is marked by:
  3. Add a keystroke item just before the end of the keyboard area, a la the below, which assigns Ctrl-F12 to run the patch file START-SRO.
        <keybind key="C-F12">
          <action name="Execute">
  4. Log out and back in, or reboot.
robust_session_management.txt · Last modified: 2014/08/29 20:31 by jeb