Skip to content

Instantly share code, notes, and snippets.

@bion
Last active February 25, 2024 06:23
Show Gist options
  • Save bion/8fbb2c38d94c8666c54b7cb63d8caf3b to your computer and use it in GitHub Desktop.
Save bion/8fbb2c38d94c8666c54b7cb63d8caf3b to your computer and use it in GitHub Desktop.
Linux audio work environment - supercollider in emacs routed to REAPER via jackd
#! /usr/bin/env bash
set -e
set -m
set +x
output_device="PCH"
if cat /proc/asound/cards | grep -q Scarlett; then
output_device="USB"
fi
jackd -R -d alsa -d "hw:${output_device}" -p 512 &
jackpid=$!
jack_wait -w
a2jmidid -e &
gtk-launch cockos-reaper.desktop > /dev/null 2>&1 &
emacsclient -e "(sclang-start)" > /dev/null 2>&1 &
until lsof -i | grep -q scsynth; do
echo "Waiting for sc to boot..."
sleep 0.5
done
until jack_lsp | grep -q REAPER:in20; do
echo "Waiting for reaper to allocate input channels..."
sleep 0.5
done
echo Connecting scsynth to reaper...
for i in {1..5}; do
jack_connect "SuperCollider:out_${i}" "REAPER:in${i}"
done
echo done
# disown emacsclient
disown %3
# disown reaper
disown %2
function cleanup() {
emacsclient -e "(sclang-stop)" > /dev/null 2>&1 &
killall reaper
killall jackd
}
trap cleanup SIGINT
# foreground jackd
wait $jackpid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment