User Tools

Site Tools


robust_session_management

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, 2/12/2013) 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 none 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. But like most audio tools for all general-purpose computing platforms, it was not designed for the live stage, it was designed for the studio, so other tools are primary 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.

The initialization script, START-INITIAL

This PC is dedicated to live synth use. When it boots, it does auto-logon, and runs the below.

  • “jack_control” is the command-line binary which controls the DBus version of jack2; the settings were discovered and verified using QjackCTL and (because I have had enough of fooling around with ALSA card numbers) cat /proc/asound/cards.
  • a2j is another tool which permits ALSA MIDI patching to be done on the Jack side; I haven’t been using it much, but it comes in handy.
  • And I want the synth to come up with a patch named SRO, so it runs patch script START-SRO at the end.
#!/bin/bash
 
echo ''
echo 'Starting jackd via dBus and configuring...'
echo ''
 
jack_control start
 
jack_control ds alsa
jack_control dps device hw:NVidia
jack_control dps rate 48000
jack_control dps nperiods 2
jack_control dps period 64
jack_control dps midi-driver seq
jack_control dps inchannels 2
jack_control dps outchannels 2
jack_control eps realtime true
jack_control eps realtime-priority 50
jack_control eps clock-source 1
 
a2j_control ehw
a2j_control start
 
/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. Remove all Jack and ALSA MIDI connections.
  2. Copy the ‘null’ (connection-less) connection set file (AJNull.xml) onto the current connection set file (AJRunning.xml) which aj-snapshot knows about when it runs.
  3. Start aj-snapshot if it’s not running.
  4. Kill all relevant audio generation and filter processes which may exist from a previous patch run.
  5. Start all relevant audio generation and filter processes needed for this patch. 'schedtool' runs them at high priority.
  6. 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).
  7. Tell aj-snapshot to reread 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 Calf's 12-band EQ for timbre, reverb, and compressor. More about this here.

You may also notice ”Combine.py”; this is a Mididings script which allows reliable combination of multiple independent MIDI keyboards into one Jackd MIDI signal.

#!/bin/bash
 
if [ "$(pidof aj-snapshot)" ]
then
	# Remove all jack and alsa connections if running
	echo "Deleting all connections..."
	cp /home/jeb/AJNull.xml /home/jeb/AJRunning.xml
	pkill -1 aj-snapshot
else
	# If aj-snapshot is not running, start and remove all connections
	echo "Starting aj-snapshot and removing all jack and alsa connections..."
	cp /home/jeb/AJNull.xml /home/jeb/AJRunning.xml
	nohup aj-snapshot -dx /home/jeb/AJRunning.xml &
fi
 
# If Combine.py is not running, start it
if [ ! "$(pidof -x Combine.py)" ]
then
	nohup schedtool -R -p 50 -e /home/jeb/Combine.py > /home/jeb/LOGS/Combine.log &
fi
 
# Kill all audio elements
killall -9 -w calfjackhost rakarrack yoshimi fluidsynth
 
# Start all relevant processes
nohup schedtool -R -p 50 -e calfjackhost --client CalfSRO \
	eq12:SRO ! reverb:SRO ! Compressor:SRO > /home/jeb/LOGS/calfjackhost-SRO.log &
nohup schedtool -R -p 50 -e yoshimi -N YoshSRO1 -j -l /home/jeb/YOSHIMI/MegaOrgan1.xmz  > /home/jeb/LOGS/Yoshimi-SRO1.log &
nohup schedtool -R -p 50 -e yoshimi -N YoshSRO2 -j -l /home/jeb/YOSHIMI/MegaOrgan2.xmz  > /home/jeb/LOGS/Yoshimi-SRO2.log &
sleep 2
 
# And lastly, create jackd connections for SRO
cp /home/jeb/AJSRO.xml /home/jeb/AJRunning.xml
pkill -1 aj-snapshot

Control

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:
    /home/username/.config/openbox/lxde-rc.xml
  2. Search for the end of the keyboard setup area, which is marked by:
    </keyboard>
  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">
              <command>/home/username/START-SRO</command>
          </action>
        </keybind>
  4. Log out and back in, or reboot.

For future reference, mididings reportedly has what is needed to run scripts (and therefore switch patches) when triggered appropriately by both MIDI and OSC.

robust_session_management.txt · Last modified: 2013/04/24 13:15 by jeb