Hey all, I’ve been experimenting with dsp programming/audio-effects which is all code that exists outside of my usual sampler-sequencer performance stuffs (candor). I’m a Linux user and like most music-focused users of the operating system, generally each piece of software I use is a client of the JACK server which allows easy manual routing between the sound card and each client’s input/outputs. Since managing multiple dsp/effects-purposed JACK clients I’ve been performing a lot of internal channel routing between my programs. Not a fan of looking at my computer screen when making music, I’m really happy with a method that I use to boot my computer / network my performance software in real-time and I thought I’d share it.
Today, autocable’s public repo has been updated with code to allow piped input and connect/disconnect. While these are trivial changes, piped input makes it really easy to script connections between JACK clients and your sound card on the command line.
Using qjackctl, a gui frontend for JACK, an empty connection graph with a sound card and two clients looks like this:
Then we run:
$ echo "connect system:capture_1 candor:in_2
> connect system:capture_2 candor:in_4
> connect candor:out_1 cyperus_osc_test:in_1
> connect cyperus_osc_test:out_1 system:playback_1
> " | ./autocable
We see connections made:
To disconnect connections, simply use ‘disconnect’ instead of ‘connect’:
$ echo "disconnect system:capture_1 candor:in_2
> disconnect system:capture_2 candor:in_4
> disconnect candor:out_1 cyperus_osc_test:in_1
> disconnect cyperus_osc_test:out_1 system:playback_1
> " | ./autocable
All connections we made are undone:
Now that we’re allowed to automate JACK connections, it’s easy to put these instructions in a startup script so the computer can do it on its own. There are a few different places where code is automatically executed on Linux systems. For example if your GNOME/Cinammon/Xfce/KDE/Unity auto-logs in, you could place the contents of your script in “/home/ < YOUR_USER > /.xinitrc”. If your computer only auto-logs into bash for you, maybe use “~/.bash_profile”, “~/.bash_login”, and “~/.profile” (files executed in that order).
Let’s say our computer auto-logs our user into bash and we’ve chosen “~/.bash_login” to run the instructions. Something like this would work:
tmux new -d -s monome 'serialoscd'
tmux new -d -s jackd 'jackd -d alsa'
sleep 3
tmux new -d -s candor '~/DEV/candor/candor' # jack client 1
sleep 3
tmux new -d -s test_osc '~/DEV/cyperus/test_osc' # jack client 2
sleep 2
echo -e "connect system:capture_1 candor:in_2
connect system:capture_2 candor:in_4
connect candor:out_1 cyperus_osc_test:in_1
connect cyperus_osc_test:out_1 system:playback_1
connect cyperus_osc_test:out_1 system:playback_2
" | ~/DEV/autocable/autocable
Running these instructions will setup intended programs in the correct order for this example (I like to use tmux to launch daemon applications as it avoids the pitfalls of ampersand operators and sleeps in bash).
The sleeps are to wait for application setup (can’t network clients that don’t exist yet).
A script like this could be paired with an arduino or another similar device to provide some kind of indicator (LED) that setup has finished completely.
Hope this was interesting and/or useful!