Instantly share code, notes, and snippets.

View apcOSC1.rb
#Sonic Pi 3 automated parameter control for fx calls controlled by TouchOSC
#developed from an idea by Martin Butz. Code developed by Robin Newman, November 2018
use_osc "",9000 #address of TouchOSC and input port
#initialise some parameters
#these will be updated further by signals from TouchOSC
set :start,0
set :finish,0.5
set :dur,1
set :type,:fade
View apcPROG.rb
#Sonic Pi 3 automated parameter control for fx calls controlled by TouchOSC
#inspired by Martin Butz. Code developed by Robin Newman, November 2018
#programatically controlled fadeing of fx opt levels
use_random_seed 886543
#setup some starting values
set :kill,false
set :finishTime,120 #duration set for the piece
#start values for next input AFTER the initial fade of the 5 fx used
View fxControlDemo.rb
#This program demonstrates the control of fx parameters to give smooth fades
#in their effects. Prompted by a thread
#started by Martin Butz
#Martin Butz's original fade function renamed, and simplified
#for only two fade types fade and wave
#fade up or down is selected automatically from the relation#
#between start and finish values
define :fadeSteps do |start, finish, len, type|
#!/usr/bin/env python3
#broadcast received OSC message
#written by Robin Newman, October 2018
#designed for use with Sonic Pi 3
#requires python-osc
#install with sudo pip3 install python-osc
import argparse
from pythonosc import osc_message_builder
from pythonosc import udp_client
from pythonosc import dispatcher
View SchubertSerenade-RF.rb
#arranged for Sonic Pi by Robin Newman, October 2018
#based on a midi file by Fred Nachbaur (creative Commons 3)
#downloaded from
#first edited in MuseScore 3.2 and then parts converted to Sonic Pi format
#using a processing script
use_bpm 85
with_fx :reverb,room: 0.8,mix: 0.7 do
with_fx :level,amp: 1.5 do
with_fx :level,amp: 0.6 do
View recercadapermera-RF.rb
#Recercada Primera by Diego Ortiz 1553
#arranged for Sonic Pi by Robin Newman, Octover 2018
2.times do #play piece twice through
with_fx :reverb,pre_amp: 1.5,room: 0.65,mix: 0.55 do #add reverb
in_thread do #percussion track (played at half tempo)
use_bpm 220
56.times do
View TroPi2.rb
#drive TroPi board using OSC messages
#by Robin Newman, October 2018
use_osc "",8000
set :kill,false
osc "/clearAll" #clear the display
sleep 0.5
View ToF_ThereminDiscrete.rb
#Sonic Pi theremin using time of flight sensor VL531X
#Discrete note version (c: major {changeable})
#by Robin Newman, August 2018
with_fx :reverb,room: 0.8,mix: 0.7 do
use_synth :tri
#start long note at zero volume: will be controlled later by k
k = play octs(0,2),sustain: 10000,amp: 0
set :k,k #store k in time-state reference :k
live_loop :theremin do

These two files comprise a 16 channel sequencer for Sonic Pi 3, controlled by a TouchOSC screen template. To install the TouchOSC template, download the file index.xml then compress/zip it and rename the resulting file seqeuncer.touchosc

The resulting file can then be loaded into the TouchOSC editor (downloadable from and then uploaded to your tablet using the TouchOSC>app available from the App store. There are versions available for android as well.

The Sonic Pi program sequencer-RF.rb is too long to run from a Sonic Pi buffer on the Mac, and you should use the run_file command to exceute it. eg

run_file "/path/to/file/sequncer-RF.rb"
View GrilloGiovanniBattistaCanzonaI-RF.rb
#arranged for Sonic Pi by Robin Newman, Nuly 2018
use_synth :tri
with_fx :reverb,room: 0.8,mix: 0.65 do
with_fx :level,amp: 0.65 do