Supercollider headless autostart and/or single_click.sh

Hi everyone,

I got my card last Thursday and struggle a bit to make it work with supercollider from command line, I’ll share my script for anyone who faces the same problem in the future.

So under /usr/local/pisound/scripts/pisound-btn

I created two new scripts:

start_sclang.sh

#!/bin/sh

. /usr/local/pisound/scripts/common/common.sh

export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0.0
export JACK_NO_AUDIO_RESERVATION=1

log “Display Set”

sudo su - patch -c “/usr/bin/jackd -P75 -dalsa -dhw:pisound -p64 -n2 -s -r48000 > /home/pi/jack.log 2>&1 &”

sleep 4

sudo su - patch -c “export QT_QPA_PLATFORM="offscreen"; sclang -D /home/pi/start.scd > /home/pi/sc.log 2>&1 &”

flash_leds 100

stop_sclang.sh

#!/bin/sh
. /usr/local/pisound/scripts/common/common.sh
flash_leds 100
sudo su - patch -c “pkill -9 sclang; pkill -9 scsynth”
flash_leds 50

Remember to add permissions to the scripts

sudo chmod +x start_clang.sh
sudo chmod +x stop_clang.sh

Then I modified the config file /etc/pisound.conf

CLICK_1 /usr/local/pisound/scripts/pisound-btn/start_sclang.sh
CLICK_2 /usr/local/pisound/scripts/pisound-btn/stop_sclang.sh

Change the above lines to start sclang instead of puredata.

And now the last part missing… create a SuperCollider file

Create a file start.scd under /home/pi

This is the SuperCollider script that I used to test

s.boot;
s.waitForBoot({{ SinOsc.ar(440) }.play; });

restart your raspberry pi and press one to start sclang it takes a few seconds before you start hearing sound.

press the button twice and the sound should stop.

this gathers a lot of things that I read in this and other threads, it would be nice to create a module specific to SuperCollider used in the console without UI.

And I like prynth webserver idea, it would be greate to have a webclient to comunicate with the scsynth process.

Cheers!

1 Like