View TouchOSCKeyboard2.12.0-MidiAlpha-4.rb.rb
#Simple TouchOSC keyboard player for Sonic Pi. Works on iPhone or iPad
#by Robin Newman, May 2017 (This version for SP v2.12.0-midi-alpha4)
#use with TouchOSC and phonekeyboard.touchosc
######## SETUP CONNECTIONS ##################
use_osc "192.168.1.50",9000 #adddress to send osc messafges back to touchOSC
midiport="2" #port for midi connection
#######INITIALISE TouchOSC selectors #########
osc "/kbd/octave/1/2","1" #set octave switch on TouchOSC
octoffset=48 #intial octave offset (4 octaves)
amp=0.5 #initial volume setting
View FyGarRubHerOerWithStraw.rb
#Fy gar her o'er with Straw arranged for Sonic Pi by Robin Newman, May 2017
#anon scottish song
#music from The harpsichord or spinnet miscellany by Robert Bremner (c 1765)
use_synth :blade #makes a good harpsichord sound when gverb added
use_bpm 140
#note values relative to crotchet=1
m=2;cd=1.5;c=1;q=0.5;sq=0.25;dsq=0.125;hdsq=0.0625;qd=0.75
define :shake do |n,d,f=0| #quick entry for ornament
View volumecontrol.rb
#volume control using ramps and rings by Robin Newman May 2017
####following lines illustrate use of * splat operator if uncommented
##| puts range(0, 1.01, 0.01)
##| puts *range(0, 1.01, 0.01)
##| puts (ramp *range(0,1.01,0.01))
v = (ramp *range(0, 1.01, 0.01)) #extended range to 1.01 to include value 1.0
use_bpm 120
View BachThemesFloatingOnBassNotes.rb
#Sonic Pi Bach themes floating on bass notes by Robin Newman, April 2017.
#This piece was inspired by the Music Generator by JLDiaz https://talicopow.blogspot.co.uk/
#I used similar sounds, but superimposed 7 fragments of Bach themes on top. My structure was altogether
#simpler, but I think the end effect is quite pleasing.
use_random_seed 1948 #change this to get different versions
m=2;c=1;q=0.5;sq=0.25 #note relative length values
b1=[:c4,:e4,:g4,:c5,:d4,:b4,:c5,:c4,:c4]
d1=[q]*6+[c]*3
b2=[:e4,:fs4,:g4,:fs4,:gs4,:a4,:gs4,:fs4,:e4,:a4,:g4,:fs4,:g4,:e4,:fs4,:g4,:fs4,:e4,:e5,:as4,:b4,:a4,:g4,:a4]
d2=[m,q,q,m,q,q,q,q,q,m,q,q,q,q,q,q,q,q,c,q,m,q,q,m]
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 https://github.com/llloret/osmid
#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
duration=110
killit=0
with_fx :level do |fade|
View RobinNewmanWithSonicPi.rb
#RobinNewmanWithSonicPi, March 2017
#This piece was generated using the program Muse-O-Matic
#http://nosuch.com/music/matic.htm
#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
a1=[:Ef4,:r,:Ef4,:Bf3,:r,:Ef4,:r,:Ef4,:r,:r,:Bf3,:Ef4,:r,:Ef6,:r,:Bf5,:Ef6,:r,:Ef6,:r,:Cs4,:Gs4,:r,:Cs4,:Cs5,:r,:Gs4,:r,:Gs5,:Gs5,:r,:Cs6,:Gs5,:r,:Cs6,:Ef6,:r,:Cs4,:r,:Cs4,:Cs4,:Ef4,:G3,:D4,:B3,:G3,:r,:G3,:G4,:G3,:r,:r,:G3,:G3,:A3,:D4,:r,:G4,:F4,:F3,:A3,:C4,:F4,:C4,:r,:A4,:Bf3,:F3,:r,:r,:F5,:Bf4,:Bf4,:r,:Bf4,:F4,:r,:Bf3,:F3,:Bf3,:Bf3,:Bf3,:r,:C4,:F4,:Cs5,:Gs4,:Cs4,:Gs3,:F3,:Cs4,:Cs5,:r,:Cs4,:Cs4,:Cs4,:Ef4,:Cs4,:r,:F3,:Cs4,:Gs3,:Gs3,:r,:Gs3,:Gs3,:Cs4,:Ef4,:r,:Gs3,:Cs4,:Cs4,:F3,:Cs4,:Gs3,:Cs4,:Gs3,:r,:r,:Gs3,:Cs4,:Gs4,:r,:r,:Gs4,:Cs4,:Gs3,:r,:Cs4,:Cs5,:Gs4,:F3,:Gs3,:F3,:Cs4,:Bf3,:D4,:F4,:Bf4,:F4,:Bf4,:F4,:F4,:Bf4,:F4,:D4,:F4,:Gs4,:Bf4,:Ef5,:Gs5,:r,:Ef6,:C6,:Gs4,:Gs3,:E
View AmbiTablaSpaceShootout.rb
use_random_seed 2468 #try different values
n= (sample_names :tabla).length
n2=(sample_names :ambi).length
#ramped volume change
vmap=[0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]
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 http://hz.imslp.info/files/imglnks/usimg/6/66/IMSLP02258-Bach_-_BGA_-_BWV_1054.pdf
#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
l=0.0
View BWV651-RF.rb
#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