Instantly share code, notes, and snippets.

View apcOSC1.rb
#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 "192.168.1.240",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
#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
#fxControlDemo.rb
#This program demonstrates the control of fx parameters to give smooth fades
#in their effects. Prompted by a thread https://in-thread.sonic-pi.net/t/smooth-parameter-automation/1626
#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|
View broadcastOSC.py
#!/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
#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 hz.imslp.info/files/imglnks/usimg/0/09/IMSLP208409-WIMA.d249-Standgit.mid
#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
#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 "127.0.0.1",8000
set :kill,false
use_real_time
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
use_real_time
View SequencerReadMe.md

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 hexler.net) 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
#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
a1=[]
b1=[]
a1[0]=[:r,:E5,:D5,:E5,:F5,:G5,:A5,:F5,:G5,:F5,:E5,:D5,:E5,:A4,:r,:r,:B4,:C5,:D5,:E5,:F5,:G5,:F5,:E5,:C5,:B4,:C5,:B4,:A4,:r,:r,:A5,:F5,:D5,:E5,:D5,:E5,:F5,:G5,:A5,:F5,:G5,:F5,:E5,:C5,:A4,:B4,:C5,:D5,:E5,:Fs5,:Gs5,:A5,:Gs5,:A5,:E5,:E5,:F5,:F5,:E5,:E5,:E5,:D5,:Cs5,:r,:r,:r,:r,:r,:r,:r,:r,:r,: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