View MidiIntoSP.rb
#experimental program to try out midi in with Sonic-Pi 2.12.0-midi-alpha3 by Robin Newman March 2017
#An Oxygen8 v2 keyboards is connected to my Mac.
#This sends midi signals to the m2o module of osmid which translates the midi to OSC and
#feeds the signals to the osc_cues_port in Sonic Pi
#the midi messages can therefore be detected by judicious use of the sync command
#look at the osmid_m2o and osc_cues logs to figure out the message(s) to intercept
#further useful info in osmid readme files at The osmid distribution is at
#in my case the keyboard was connected to port 2, and I used the first midi channel (0)
set_sched_ahead_time! 0.1 #reduced this to reduce latency
View chordfrazzle.rb
#chordfrazzle by Robin Newman, March 2017
#This piece generates the notes in a randomly selected chord type, and then plays them ascending....
#interspersed with the same sequence rising
#The base note, synth, volume and pan positions of the notes are selected at random for each chord
#certain synths are excluded (mainly "noise" types)
#In this version the live loop is faded out after 110 seconds and then stopped.
use_debug false
with_fx :level do |fade|
View RobinNewmanWithSonicPi.rb
#RobinNewmanWithSonicPi, March 2017
#This piece was generated using the program Muse-O-Matic
#seeded with the "word" RobinNewmanWithSonicPi
#The resulting midi file was converted to SP notation
#and a simple percussion part was added
with_fx :gverb,room: 20,mix: 0.4 do
use_synth :tri
tmp=120 #tempo setting
View AmbiTablaSpaceShootout.rb
use_random_seed 2468 #try different values
n= (sample_names :tabla).length
n2=(sample_names :ambi).length
#ramped volume change
killit=0 #flag to kill live loops
with_fx :gverb,room: 25 do
with_fx :level do |v| #fade volume in and out
control v,amp: 0
sleep 0.05 #settle time to prevent any initial click
View BachClavierConcertoBWV1054-RF.rb
#Bach Clavier Concerto no 3 in D major BWV1054 arranged for Sonic Pi midi output
#by Robin Newman Feb 2017 from score
#parts in MuseScore2, separated out especially Harpsichord to 6 parts
#exported as MusicXML to Processing Script which converted to Sonic Pi format
#output was fed to Logic Pro on a MacBook Pro but will work with other suitable players eg MuseScore2
#asssign instruments to each part
#1=violins1 2=violins2 3=violas 4=basses 5-10 = harpsichords
define :dl do |durations| #return number of crotchet beats in a note durations list
View BWV651-RF.rb
#use run_file "<path to BWV651-RF>" to play
#requires SP 2.11 or greater
#will play in a Raspberry Pi3
#based on an original musescore by Clarin Pedro with permission
use_debug false
use_synth :tri
use_synth_defaults cutoff: 110
with_fx :reverb,room: 0.9,mix: 0.5 do
View bwv542-RF.rb
#bwv542 Great Fantasia and Fugue in G minor verskon for solo Sonic Pi 2.11 or 2.11.1
#use runfile "<path to bwv254-RF.rb>" to run it
use_debug false
use_synth :saw
with_fx :reverb, room: 0.9,mix: 0.6 do
with_fx :level,amp: 0.7 do
View BeatusVirControlled-RFAuto.rb
`/usr/local/bin/sonic_pi stop`
`/usr/local/bin/sonic_pi "run_file '~/Documents/SPfromXML/BeatusVirControlled-RF.rb'"`
View ReadMe.txt
These files accompany a video at which explores the use of a GUI to control a Sonic Pi program
running code to drive an external midi player. (I used Logic Pro) It currently works with SP2.12.0-midi-alpha1 on a Mac,
but may probably break on future versions. It is intended to show some concepts, particularly the use of a GUI written
in processing which can control SP by means of OSC messages. The source code of the processing sketch is included.
It also illustrates a technique to allow a Sonic Pi piece to be started at any bar, by calculating the start note for
each of the parts concerned. It can handle a tied note already playing at the start of the selected bar.
The final technique utilised is to use an external script utilising calls to the Sonic Pi cli interface gem to stop
Sonic Pi running and then to restart the program using a run_file command. In this way, Sonic Pi can respond to
a stop singal from the GUI and then restart playing when a subsequent Play cue is received via
View JazzBach.rb
#Jazz Bach converted for Sonic Pi by Robin Newman Jan 2017
#requires to be used with run_file "path/to/filename/JazzBach.rb"
#using Sonic Pi 2.11 or later
use_synth :piano
with_fx :reverb,room: 0.8,mix: 0.5 do
with_fx :level,amp: 1.2 do #overall boost
with_fx :level do |v| #dynamic control during the piece
in_thread do