-
Notifications
You must be signed in to change notification settings - Fork 4
Raspberry Pi Instructions
this will result in a rpi that can be run either as headless or with the full scide including VTM gui.
the sclang.yaml file and the autostart.sh script are both in ~/supercolliderStandaloneRPI2.
VTM is in ~/SCClasses and can be updated with git pull
(or overwritten with rsync).
project specific code is in ~/g_16/ting and you edit the autostart.sh to start it at boot.
- burn image or etch .zip (2017-04-10-raspbian-jessie.zip) to SD card https://www.etcher.io/
- connect ethernet, screen, and keyboard
-
sudo raspi-config
- Change User Password
- enable SSH in Interfacing Options
- finish and reboot
sudo apt-get update
-
sudo apt-get upgrade
#optional - takes a while sudo apt-get install tmux xvfb vim
- follow the installation instructions for SuperCollider standalone version: (Copied from here )
sudo apt-get install libqt5webkit5 libqt5sensors5 libqt5positioning5 libqt5concurrent5 libfftw3-bin libcwiid1
git clone https://github.com/redFrik/supercolliderStandaloneRPI2 --depth 1
mkdir -p ~/.config/SuperCollider
cp supercolliderStandaloneRPI2/sc_ide_conf_temp.yaml ~/.config/SuperCollider/sc_ide_conf.yaml
- now start sclang and install the required Quarks
cd supercolliderStandaloneRPI2
-
./sclang -a -l sclang.yaml
#ALT1 - if you have a screen attached -
xvfb-run --auto-servernum ./sclang -a -l sclang.yaml
#ALT2 - if you are logged in via ssh > Quarks.install("UnitTesting")
> Quarks.install("API")
> Quarks.install("Modality-toolkit")
> 0.exit
- install VTM and MIDIDevice from git
mkdir ~/SCClasses && cd ~/SCClasses
git clone https://github.com/blacksound/VTM.git
git clone https://github.com/blacksound/MIDIDevice.git
- then edit and add VTM paths to the sclang.yaml file
-
nano ~/supercolliderStandaloneRPI2/sclang.yaml
includePaths: - ./share/system/SCClassLibrary - ./share/system/Extensions - ./share/user/Extensions - /home/pi/supercolliderStandaloneRPI2/share/user/downloaded-quarks/UnitTesting - /home/pi/supercolliderStandaloneRPI2/share/user/downloaded-quarks/API - /home/pi/supercolliderStandaloneRPI2/share/user/downloaded-quarks/Modality-toolkit - /home/pi/SCClasses/VTM - /home/pi/SCClasses/MIDIDevice excludePaths: [] postInlineWarnings: false
-
NOTE: here could be a good moment to double check that the class library is compiling and then make a copy of the sd card to an image file (see backup below). then you can save setup time by burning this image that now includes raspbian, sc and vtm.
-
sudo raspi-config
- edit Hostname (e.g. ting2)
- finish and reboot
- set up static ip like below
- optionally set up a shutdown script like below
- last edit autostart.sh...
nano /home/pi/supercolliderStandaloneRPI2/autostart.sh
- make it look like this...
#!/bin/sh tmux has-session -t sc if [ $? != 0 ]; then tmux new-session -s sc -d tmux send-keys -t sc 'xvfb-run ./sclang -a -l sclang.yaml ~/g_16/ting/tingStartup.scd' C-m fi
- and make autostart.sh run at boot with
-
crontab -e
#and add the following to the end@reboot cd /home/pi/supercolliderStandaloneRPI2 && xvfb-run ./autostart.sh
-
-
lsusb
- should do the trick - if not then ..
- mounting usb
ls /dev/
sudo mkdir /media/usb
sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usb
ls /media/usb
to have a button turn off the rpi do the following...
- save this python script as 'shutdown.py' in /home/pi
#!/bin/python
import RPi.GPIO as GPIO
import os
pin= 3
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN)
try:
GPIO.wait_for_edge(pin, GPIO.FALLING)
os.system("sudo halt -p")
except:
pass
GPIO.cleanup()
- then edit crontab
-
crontab -e
#and add the following... @reboot python /home/pi/shutdown.py
-
to have the rpi turn off from a network command...
- add this somewhere to your rpi project code...
OSCFunc({|msg| msg.postln; "sudo halt -p".unixCmd}, \shutdown, recvPort: 52705);
- then use a broadcast message like this to turn off all rpis on the network
NetAddr("192.168.1.255", 52705).sendMsg(\shutdown);
note this is for raspbian jessie (things work differently on older versions)
- ssh to a raspberry and edit this file, adding the lines below
-
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
network={ ssid="myssid" psk="mypassword" }
-
- then edit this file, adding the relevant ip addresses...
-
sudo nano /etc/dhcpcd.conf
interface wlan0 static ip_address=192.168.1.150/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1 8.8.8.8
-
run this on osx. it will copy the folder VTM to a raspberry pi and put it in /home/pi/SCClasses. if the files are already there it will only copy over any changes.
rsync -av --delete --exclude='.git/' --exclude='.DS_Store' -e ssh VTM pi@raspberrypi.local:SCClasses
use -nav
to dry-run (the -n flag will make rsync just list what files will be overwritten/deleted).
insert the sd card into a mac osx laptop and type
diskutil list
verify that your sd card is mounted at /dev/disk2 and then do...
sudo dd bs=4m if=/dev/rdisk2 of=/Users/asdf/Desktop/ting2backup20170525.img
with a 16gb card this process takes ~4.5min and it can easily be restored with http://etcher.io
- to boot scsynth you first need to start jackd in a controlled manner. with an usb soundcard connected add this to autostart.sh...
/usr/bin/jackd -P75 -dalsa -dhw:1 -p1024 -n3 -s -r44100 &
- then use
s.waitForBoot
in your project code
with the built in sound use -dhw:0
and when starting manually from ssh do export DISPLAY=:0.0
before trying to start jackd with jackd -P75 -dalsa -dhw:1 -p1024 -n3 -s -r44100 &
connect a hdmi screen (projector or monitor) plus usb keyboard and mouse. start the rpi and open a terminal window.
-
optionally stop any sclang that has been autostarted with...
pkill sclang
-
if you want to use a soundcard start jack with this command in terminal...
qjackctl
- select soundcard (under setup/interfaces)
- if usb soundcard also set periods to 3
- start jack by clicking the play icon
-
open a new terminal window and type the following to start scide...
cd supercolliderStandaloneRPI2
export PATH=.:$PATH
scide
- burn image or etch .zip to SD card https://www.etcher.io/
- boot raspberry ...
-
sudo raspi-config
- go to advanced options and select update - enable VNC (in raspi-config)
- set gpu_mem to
192
via the desktop environment or edit in/boot/config.txt
- if not already done, install cmake
sudo apt-get update && sudo apt-get upgrade
- then
sudo apt-get install cmake
- see https://github.com/redFrik/supercolliderStandaloneRPI2/blob/master/BUILDING_NOTES.md
git clone --recursive git://github.com/supercollider/supercollider --depth 1
git clone --recursive https://github.com/supercollider/sc3-plugins.git --depth 1
cd sc3-plugins
mkdir build && cd build
export CC=/usr/bin/gcc-4.8
export CXX=/usr/bin/g++-4.8
cmake -L -DCMAKE_BUILD_TYPE="Release" -DCMAKE_C_FLAGS="-march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon"
-DCMAKE_CXX_FLAGS="-march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon" -DSC_PATH=../../supercollider/
-DCMAKE_INSTALL_PREFIX=~/supercolliderStandaloneRPI2/share/user/Extensions/sc3-plugins ..
-
make -j 4
leave out flag-j 4on single core rpi models (zero,1,2) sudo make install
cd ~/supercolliderStandaloneRPI2/share/system/Extensions/
sudo chown -R pi SC3plugins
sudo chgrp -R pi SC3plugins
mkdir SC3plugins/bin
mv SC3plugins/lib/SuperCollider/plugins/*.so SC3plugins/bin/
mv SC3plugins/share/SuperCollider/Extensions/SC3plugins/* SC3plugins/
rm -rf SC3plugins/lib
rm -rf SC3plugins/share
rm -rf SC3plugins/local
this is what i did to ting2 - it is now running supercolliderStandaloneRPI2 but with the old code from g_16
- install following the instructions at the top of this page
- but copy over SCClasses and g_16 folders from another ting - replacing the fresh git clones
an example of how to set up a python script that monitor and restart supercollider if it stop sending osc (if it crashed)
- install pyosc if needed
pip install pyosc --pre
- make the below script start at bootup
@reboot cd /home/pi/supercolliderStandaloneRPI2 && python surveillance.py
- save the following python code as '/home/pi/supercolliderStandaloneRPI2/surveillance.py'
#!/usr/bin/env python
#a script for checking if sc is alive
#send it an osc message once every x second
#else sc + jack will be forcefully restarted
#first install pyosc with this command...
# pip install pyosc --pre
import subprocess
from time import sleep
from threading import Thread
from OSC import OSCServer
TIMEOUT= 30 #in seconds
OSCPORT= 50005 #network port
def oscInput(addr, tags, stuff, source):
global received
received= True
def timeout(): #called when no osc message received for x seconds
subprocess.call(['pkill', 'sclang'])
subprocess.call(['pkill', 'scsynth'])
subprocess.call(['pkill', 'jackd'])
p= subprocess.Popen(['xvfb-run', './autostart.sh'])
server= OSCServer(('0.0.0.0', OSCPORT)) #receive from everywhere on port x
server.addDefaultHandlers() #for dealing with unmatched messages
server.addMsgHandler('/alive', oscInput)
server_thread= Thread(target= server.serve_forever)
server_thread.start()
print server
received= True
try:
while received:
received= False
sleep(TIMEOUT)
if not received:
print 'timeout!!!!'
timeout()
received= True
except KeyboardInterrupt:
print 'closing'
server.close()
server_thread.join()
print 'done'
then from sc do something like this to send a keep alive message from sclang
Routine.run({
inf.do{
NetAddr("127.0.0.1", 50005).sendMsg(\alive);
25.wait; //25 seconds
};
});
or let scsynth send the keep alive message via sclang like this
(
SynthDef(\alive, {var dur= 25; SendReply.kr(Impulse.kr(1/dur), '/alive', 1)}).play; //dur in seconds
OSCdef(\alive, {|msg| NetAddr("127.0.0.1", 50005).sendMsg(\alive)}, \alive);
)