Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sonic-Pi music files for Raspberry PiGraphic Desktop
THESE FILES WERE WRITTEN FOR SONIC PI VERSION 1
THEY WILL REQUIRE REVISION TO WORK ON VERSION 2
I HAVE OTHER FILES FOR VERSION 2 POSTED ON MY BLOG
SOME OF THESE FILES ARE POSTED THERE IN REVISED VERSIONS
http://rbnrpi.wordpress.com
Posted here will be music files for use with Sonic-Pi on the Raspberry Pi.
If you have the Sonic-Pi music program isntalled (it is on the latest distribution for Raspian) you can start it up from the Graphic Desktop (there is a link under Education on the Start Menu). You can then copy and past the contents of one of the play files into one of the 8 workspace windows and click play to play it.
I will also add some general comment and hints files from time to time.
#Bach Two Part Invention no 1 coded by Robin Newman 23rd October 2013
#score from http://www.free-scores.com/PDF_EN/bach-johann-sebastian-invention-177.pdf
#This illustrates the use of varaibles to allow tempo changes even though using the play_pattern_timed command
#Also shown is the use of multiple short in_thread structures to allow resynchronisation
#of the two hands. Each lasts for one, bar. If a Right Hand in_thread finishes early, then the next one does not start
#until the correct time is reached in the Left Hand part. To prevent the Left Hand part starting a Right Hand
#in_thread early a very short "bodge" sleep is inserted at end of each Left Hand bar. The timing of this "bodge"
#can be adjusted to give the smoothest performance, and in fact I think the very short delay that sometimes results
#enhances the performance.
#Also worth commenting is the use of $ variables which are global
#The with_synth command has to be used at the start of each thread, or it uses the default synth
#Separate variable names are used for the threads and the main program, so Left and Right parts can be different.
#only the saw_beep and beep synths work satisfactorily, withough extraneous clicks and noises in the piece
#Attack times are specified with different variables to the note durations, allowing for stacatto or sustained playing
#tricky bits were producing the ornamental mordents, which had to be written out explicitly.
#The whole piece is played several times allowing different parameter settings to be used
#'this is achieved by using the def tune...end structure, which allows the tune to be played with a single tune command
#setup initial timing variables
$m = 1 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.175 * $m #stacatto quaver attack < or = to $q
$ss = 0.125 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
def tune #define the whole piece as tune so that it can be easily repeated with different parameters
with_synth $synL
in_thread do #b1 RIGHT HAND
with_synth $synR
sleep $s
play_pattern_timed [60,62,64,65,62,64,60],[$s],"attack",$ss
play_pattern_timed [67,72],[$q],"attack",$qs
play_pattern_timed [71,72],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [71],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [72],[$q],"attack",$qs
end
sleep (2 * $c + $s) #b1 LEFT HAND
play_pattern_timed [48,50,52,53,50,52,48],[$s],"attack",$ss
sleep $cr
in_thread do #b2 RIGHT HAND
with_synth $synR
play_pattern_timed [74,67,69,71,72,69,71,67],[$s],"attack",$ss
play_pattern_timed [74,79],[$q],"attack",$qs
play_pattern_timed [77,79],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [77],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [79],[$q],"attack",$qs
end
#b2 LEFT HAND
play_pattern_timed [55,43],[$q],"attack",$qs
sleep ($c + $s)
play_pattern_timed [55,57,59,60,57,59,55],[$s],"attack",$ss
sleep $cr
in_thread do #b3 RIGHT HAND
with_synth $synR
play_pattern_timed [76,81,79,77,76,79,77,81,79,77,76,74,72,76,74,77],[$s],"attack",$ss
end
#b3 start LEFT HAND
play_pattern_timed [60,59,60,62,64,55,57,59],[$q],"attack",$q
sleep $cr
in_thread do #b4 RIGHT HAND
with_synth $synR
play_pattern_timed [76,74,72,71,69,72,71,74,72,71,69,67,66,69,67,71],[$s],"attack",$ss
end
#b4 start LEFT HAND
play_pattern_timed [60,52,54,55,57,59],[$q],"attack",$q
play_pattern_timed [60],[$c],"attack",$c
sleep $cr
in_thread do #b5 RIGHT HAND
with_synth $synR
play_pattern_timed [69,62],[$q],"attack",$qs
play_pattern_timed [72,74],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [72],[($d + $q)],"attack",($ds + $qs)
play_pattern_timed [74,71,69,67,66,64,67,66,69],[$s],"attack",$ss
end
#b5 start LEFT HAND
play_pattern_timed [60,50,52,54,55,52,54,50],[$s],"attack",$ss
play_pattern_timed [55,47,48,50],[$q],"attack",$qs
sleep $cr
in_thread do #b6 RIGHT HAND
with_synth $synR
play_pattern_timed [67,71,69,72,71,74,72,76,74],[$s],"attack",$ss
play_pattern_timed [71,72],[$d],"attack",$ds
play_pattern_timed [74,79],[$s],"attack",$ss
play_pattern_timed [71,72],[($d /2)],"attack",($ds / 2)
play_pattern_timed [71],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [69,67],[$s],"attack",$ss
end
#b6 start LEFT HAND
play_pattern_timed [52,54,55,52],[$q],"attack",$qs
play_pattern_timed [47],[($q + $s)],"attack",($q + $s)
play_pattern_timed [48],[$s],"attack",$s
play_pattern_timed [50,38],[$q],"attack",$q
sleep $cr
in_thread do #b7 RIGHT HAND
with_synth $synR
play_pattern_timed [67],[$q],"attack",$qs
sleep ($c + $q + $s)
play_pattern_timed [67,69,71,72,69,71,67],[$s],"attack",$ss
end
#b7 start LEFT HAND6
sleep $s
play_pattern_timed [43,45,47,48,45,47,43],[$s],"attack",$ss
play_pattern_timed [50,55],[$q],"attack",$qs
play_pattern_timed [54,55],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [54],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [55],[$q],"attack",$qs
sleep $cr
in_thread do #b8 RIGHT HAND
with_synth $synR
play_pattern_timed [66],[$q],"attack",$qs
sleep ($q + $c + $s)
play_pattern_timed [69,71,72,74,71,72,69],[$s],"attack",$ss
end
#b8 start LEFT HAND
play_pattern_timed [57,50,52,54,55,52,54,50],[$s],"attack",$ss
play_pattern_timed [57,62],[$q],"attack",$qs
play_pattern_timed [60,62],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [60],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [62],[$q],"attack",$qs
sleep $cr
in_thread do #b9 RIGHT HAND
with_synth $synR
play_pattern_timed [71],[$q],"attack",$qs
sleep ($q + $c + $s)
play_pattern_timed [74,72,71,69,72,71,74],[$s],"attack",$ss
end
#b9 start LEFT HAND
play_pattern_timed [55,67,65,64,62,65,64,67],[$s],"attack",$ss
play_pattern_timed [65,64,65,62],[$q],"attack",$qs
sleep $cr
in_thread do #b10 RIGHT HAND
with_synth $synR
play_pattern_timed [72],[$q],"attack",$qs
sleep ($q + $c + $s)
play_pattern_timed [76,74,72,71,74,73,76],[$s],"attack",$ss
end
#b10 start LEFT HAND
play_pattern_timed [64,69,67,65,64,67,65,69],[$s],"attack",$ss
play_pattern_timed [67,65,67,64],[$q],"attack",$qs
sleep $cr
in_thread do #b11 RIGHT HAND
with_synth $synR
play_pattern_timed [74,73,74,76,77,69,71,72],[$q],"attack",$qs
end
#b11 start LEFT HAND
play_pattern_timed [65,70,69,67,65,69,67,70,69,67,65,64,62,65,64,67],[$s],"attack",$ss
sleep $cr
in_thread do #b12 RIGHT HAND
with_synth $synR
play_pattern_timed [74,66,68,69,71,72],[$q],"attack",$qs
play_pattern_timed [74],[$c],"attack",$c #full length
end
#b12 start LEFT HAND
play_pattern_timed [65,64,62,60,59,62,60,64,62,60,59,57,56,59,57,60],[$s],"attack",$ss
sleep $cr
in_thread do #b13 RIGHT HAND
with_synth $synR
play_pattern_timed [74,64,66,68,69,66,68,64,76,74,72,76,74,72,71,74],[$s],"attack",$ss
end
#b13 start LEFT HAND
play_pattern_timed [59,52],[$q],"attack",$qs
play_pattern_timed [62,64],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [62],[($d + 2 * $s)],"attack",($ds + 2 * $ss)
play_pattern_timed [64,60,59,57,55,54,57,56,59],[$s],"attack",$ss
sleep $cr
in_thread do #b14 RIGHT HAND
with_synth $synR
play_pattern_timed [72,81,80,83,81,76,77,74,68,77,76,74],[$s],"attack",$ss
play_pattern_timed [72,74],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [72],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [71,69],[$s],"attack",$ss
end
#b14 LEFT HAND
play_pattern_timed [57,60,59,62,60,64,62,65],[$s],"attack",$ss
play_pattern_timed [64,57,64,52],[$q],"attack",$qs
sleep $cr
in_thread do #b15 RIGHT HAND
with_synth $synR
play_pattern_timed [69,81,79,77,76,79,77,81],[$s],"attack",$ss
play_pattern_timed [79],[($c * 2)],"attack",($c * 2) #full length
end
#b15 LEFT HAND
play_pattern_timed [57,45],[$q],"attack",$qs
sleep ($c + $q)
play_pattern_timed [64,62,60,59,62,61,64],[$s],"attack",$ss
sleep $cr
in_thread do #b16 RIGHT HAND
with_synth $synR
play_pattern_timed [79,76,77,79,81,77,79,76],[$s],"attack",$ss
play_pattern_timed [77],[(2 * $c)],"attack",(2 * $c) #full length
end
#b16 start LEFT HAND
play_pattern_timed [62],[(2 * $c)],"attack",(2 * $c) #full length
play_pattern_timed [62,57,59,60,62,59,60,57],[$s],"attack",$ss
sleep $cr
in_thread do #b17 RIGHT HAND
with_synth $synR
play_pattern_timed [77,79,77,76,74,77,76,79],[$s],"attack",$ss
play_pattern_timed [77],[($c * 2)],"attack",($c * 2) #full length
end
#b17 start LEFT HAND
play_pattern_timed [59],[($c * 2)],"attack",($c * 2) #full length
play_pattern_timed [59,62,60,59,57,60,59,62],[$s],"attack",$ss
sleep $cr
in_thread do #b18 RIGHT HAND
with_synth $synR
play_pattern_timed [77,74,76,77,79,76,77,74],[$s],"attack",$ss
play_pattern_timed [76],[($c * 2)],"attack",($c * 2) #full length
end
#b18 start LEFT HAND
play_pattern_timed [60],[($c * 2)],"attack",($c * 2) #full length
play_pattern_timed [60,55,57,58,60,57,58,55],[$s],"attack",$ss
sleep $cr
in_thread do #b19 RIGHT HAND
with_synth $synR
play_pattern_timed [76,72,74,76,77,74,76,72,74,76,77,79,81,77,79,76],[$s],"attack",$ss
end
#b19 start LEFT HAND
play_pattern_timed [57],[$q],"attack",$qs
play_pattern_timed [58,57,55],[$q],"attack",$q #smooth full length
play_pattern_timed [53],[$q],"attack",$qs
play_pattern_timed [62,60,58],[$q],"attack",$q #smooth full length
sleep $cr
in_thread do #b20 RIGHT HAND
with_synth $synR
play_pattern_timed [77,79,81,83,84,81,83,79],[$s],"attack",$ss
play_pattern_timed [84,79],[$q],"attack",$qs
play_pattern_timed [76,77],[($d / 2)],"attack",($ds / 2)
play_pattern_timed [76],[($d + $s)],"attack",($ds + $ss)
play_pattern_timed [74,72],[$s],"attack",$ss
end
#b20 start LEFT HAND
play_pattern_timed [57],[$q],"attack",$qs
play_pattern_timed [65,64,62],[$q],"attack",$q #full length
play_pattern_timed [64,50,52,53,55,52,53,50],[$s],"attack",$ss
sleep $cr
in_thread do #b21 RIGHT HAND
with_synth $synR
play_pattern_timed [72,70,69,67,65,69,67,70,69,71,72,64,62,72,65,71],[$s],"attack",$ss
end
#b21 start LEFT HAND
play_pattern_timed [52,48,50,52],[$q],"attack",$qs
play_pattern_timed [53,50,52,53],[$s],"attack",$ss
play_pattern_timed [55,43],[$q],"attack",$qs
sleep $cr
in_thread do #b22 RIGHT HAND
with_synth $synR
play_chord [52,55,72],"attack",($c * 4)
end
#b22 start LEFT HAND
with_synth "saw_beep" #override synth for the chord
play_chord [36,48],"attack",($c * 4)
sleep $cr
sleep (4 * $c) #bar before next tune
end #of tune definition
########Play tune several times with different settings#######
#slow same synth each hand
$m = 1.6 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.175 * $m #stacatto quaver attack < or = to $q
$ss = 0.125 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.02 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#bit faster, different synth each hand
$m = 1.2 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.2 * $m #stacatto quaver attack < or = to $q
$ss = 0.125 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#little faster, different synths each hand
$m = 1.3 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #stacatto quaver attack < or = to $q
$ss = 0.125 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#fast same synth each hand
$m = 1.2 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #stacatto quaver attack < or = to $q
$ss = 0.120 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#super fast. different synth each hand
$m = 1 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #stacatto quaver attack < or = to $q
$ss = 0.120 * $m #stacatto semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#Bach Two Part Invention no 4 coded by Robin Newman 21st October 2013
#score is here http://www.mutopiaproject.org/ftp/BachJS/BWV775/bach-invention-04/bach-invention-04-a4.pdf
#This illustrates the use of variables to allow tempo changes even though using the play_pattern_timed command
#Also shown is the use of multiple short in_thread structures to allow resynchronisation
#of the two hands. Each lasts for one, bar. If a Right Hand in_thread finishes early, then the next one does not start
#until the correct time is reached in the Left Hand part. To prevent the Left Hand part starting a Right Hand
#in_thread early a very short "bodge" sleep is inserted at end of each Left Hand bar. The timing of this "bodge"
#can be adjusted to give the smoothest performance, and in fact I think the very short delay that sometimes results
#enhances the performance. Occasionally there are two bar patterns to accommodate ties over the barline.
#Also worth commenting is the use of $ variables which are global
#The with_synth command has to be used at the start of each thread, or it uses the default synth
#Separate variable names are used for the threads and the main program, so Left and Right parts can be different.
#only the saw_beep and beep synths work satisfactorily, withough extraneous clicks and noises in the piece
#Attack times are specified with different variables to the note durations, allowing for staccato or sustained playing
#The whole piece is played several times allowing different parameter settings to be used
#'this is achieved by using the def tune...end structure, which allows the tune to be played with a single tune command
#setup initial timing variables
$m = 1 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.175 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
def tune #define the whole piece as tune so that it can be easily repeated with different parameters
with_synth $synL
in_thread do #b1 RIGHT HAND
with_synth $synR
play_pattern_timed [62,64,65,67,69,70],[$s],"attack",$ss
end
sleep (3 * $q) #b1 LEFT HAND
in_thread do #b2 RIGHT HAND
with_synth $synR
play_pattern_timed [61,70,69,67,65,64,62],[$s],"attack",$ss
end
sleep (3 * $q) #b2 LEFT HAND
sleep $cr
in_thread do #b3 RIGHT HAND
with_synth $synR
play_pattern_timed [65,69,74],[$q],"attack",$qs
end
#b4 start LEFT HAND
play_pattern_timed [50,52,53,55,57,58],[$s],"attack",$ss
sleep $cr
in_thread do #b4 RIGHT HAND
with_synth $synR
play_pattern_timed [67,73,76],[$q],"attack",$qs
end
#b4 start LEFT HAND
play_pattern_timed [49,58,57,55,53,52],[$s],"attack",$ss
sleep $cr
in_thread do #b5 RIGHT HAND
with_synth $synR
play_pattern_timed [74,76,77,79,81,82],[$s],"attack",$ss
end
#b5 start LEFT HAND
play_pattern_timed [53,57,62],[$q],"attack",$qs
sleep $cr
in_thread do #b6 RIGHT HAND
with_synth $synR
play_pattern_timed [73,82,81,79,77,76],[$s],"attack",$ss
end
#b6 start LEFT HAND
play_pattern_timed [52,55,61],[$q],"attack",$qs
sleep $cr
in_thread do #b7 RIGHT HAND
with_synth $synR
play_pattern_timed [77,74,76,77,79,81],[$s],"attack",$ss
end
#b7 start LEFT HAND
play_pattern_timed [50,62,53],[$q],"attack",$qs
sleep $cr
in_thread do #b8 RIGHT HAND
with_synth $synR
play_pattern_timed [71,81,79,77,76,74],[$s],"attack",$ss
end
#b8 start LEFT HAND
play_pattern_timed [55,57,58],[$q],"attack",$qs
sleep $cr
in_thread do #b9 RIGHT HAND
with_synth $synR
play_pattern_timed [76,72,74,76,77,79],[$s],"attack",$ss
end
#b9 start LEFT HAND
play_pattern_timed [48,60,52],[$q],"attack",$qs #b9
sleep $cr
in_thread do #b10 RIGHT HAND
with_synth $synR
play_pattern_timed [69,79,77,76,74,72],[$s],"attack",$ss
end
#b10 start LEFT HAND
play_pattern_timed [53,55,57],[$q],"attack",$qs
sleep $cr
in_thread do #b11 RIGHT HAND
with_synth $synR
play_pattern_timed [74,76,77,74,76,77],[$s],"attack",$ss
end
#b11 start LEFT HAND
play_pattern_timed [58,55,57,58,60,62],[$s],"attack",$ss
sleep $cr
in_thread do #b12 RIGHT HAND
with_synth $synR
play_pattern_timed [67],[$q],"attack",$sq
sleep (2 * $q)
end
#b12 start LEFT HAND
play_pattern_timed [52,62,60,58,57,55],[$s],"attack",$ss
sleep $cr
in_thread do #b13 RIGHT HAND
with_synth $synR
play_pattern_timed [72,74,76,72,74,76],[$s],"attack",$ss
end
#b13 start LEFT HAND
play_pattern_timed [57,53,55,57,58,60],[$s],"attack",$ss
sleep $cr
in_thread do #b14 and 15 RIGHT HAND
with_synth $synR
play_pattern_timed [65],[$q],"attack",$qs
sleep $q
play_pattern_timed [70],[$c],"attack",$c
play_pattern_timed [69,67],[$q],"attack",$qs
end
#b14 and 15 start LEFT HAND
play_pattern_timed [50,60,58,57,55,53,52,48,50,52,53,55],[$s],"attack",$ss
sleep $cr
in_thread do #b16 RIGHT HAND
with_synth $synR
play_pattern_timed [72,70,69,67,65,64],[$s],"attack",$ss
end
#b16 start LEFT HAND
play_pattern_timed [45,55,53,52,50,48],[$s],"attack",$ss
sleep $cr
in_thread do #b17 RIGHT HAND
with_synth $synR
play_pattern_timed [65,67],[$s],"attack",$ss
play_pattern_timed [67],[($q +$s)],"attack",($qs+$ss)
play_pattern_timed [65],[$s],"attack",$ss
end
#b17 start LEFT HAND
play_pattern_timed [50.46],[$s],"attack",$ss
play_pattern_timed [48,36],[$q],"attack",$qs
sleep $cr
in_thread do #b18 RIGHT HAND
with_synth $synR
play_pattern_timed [65,72,72],[$q],"attack",$qs
end
#b18 start LEFT HAND
play_pattern_timed [41,43,45,46,48,50],[$s],"attack",$ss
sleep $cr
in_thread do #b19 RIGHT HAND
with_synth $synR
#play_pattern_timed [72,74,72,74,72,74,72,74,72,74,72,74],[$d],"attack",$ds
#alternative trill throughout
play_pattern_timed [72,74],[$d],"attack",$ds
play_pattern_timed [72],[($s + 2 * $q)],"attack",($s + 2 * $q)
end
#b19 start LEFT HAND
play_pattern_timed [40,50,48,46,45,43],[$s],"attack",$ss
sleep $cr
in_thread do #b20 RIGHT HAND
with_synth $synR
play_pattern_timed [72],[(3 * $q)],"attack",(3 * $q)
end
#b20 start LEFT HAND
play_pattern_timed [45,46,48,50,52,53],[$s],"attack",$ss
sleep $cr
in_thread do #b21 RIGHT HAND
with_synth $synR
play_pattern_timed [72],[(3 * $q)],"attack",(3 * $q)
end
#b21 start LEFT HAND
play_pattern_timed [43,53,52,50,48],[$s],"attack",$ss
sleep $cr
in_thread do #b22 RIGHT HAND
with_synth $synR
play_pattern_timed [72,70,69,67,65,64],[$s],"attack",$ss
end
#b22 start LEFT HAND
play_pattern_timed [45,46,48,45,46,48],[$s],"attack",$ss
sleep $cr
in_thread do #b23 RIGHT HAND
with_synth $synR
play_pattern_timed [72,62,64,66,67,69],[$s],"attack",$ss
end
#b23 start LEFT HAND
play_pattern_timed [42],[$q],"attack",$qs
sleep $c
sleep $cr
in_thread do #b24 RIGHT HAND
with_synth $synR
play_pattern_timed [70,69,67,65,64,62],[$s],"attack",$ss
end
#b24 start LEFT HAND
play_pattern_timed [43,45,46,43,45,46],[$s],"attack",$ss
sleep $cr
in_thread do #b25 RIGHT HAND
with_synth $synR
play_pattern_timed [70,60,62,64,65,67],[$s],"attack",$ss
end
#b25 start LEFT HAND
play_pattern_timed [40],[$q],"attack",$qs
sleep $c
sleep $cr
in_thread do #b26 RIGHT HAND
with_synth $synR
play_pattern_timed [69,71,72,74,76,77],[$s],"attack",$ss
end
#b26 start LEFT HAND
play_pattern_timed [41,53,50],[$q],"attack",$qs
sleep $cr
in_thread do #b27 RIGHT HAND
with_synth $synR
play_pattern_timed [68,77,76,74,72,71],[$s],"attack",$ss
end
#b27 start LEFT HAND
play_pattern_timed [47,44,40],[$q],"attack",$qs
sleep $cr
in_thread do #b28 RIGHT HAND
with_synth $synR
play_pattern_timed [72,71,74,72,71,69],[$s],"attack",$ss
end
#b28 start LEFT HAND
play_pattern_timed [45,44,45,47,48,50],[$s],"attack",$ss
sleep $cr
in_thread do #b29 RIGHT HAND
with_synth $synR
play_pattern_timed [68,69,68,66,64,62],[$s],"attack",$ss
end
#b29 start LEFT HAND
play_pattern_timed [52,53],[$d],"attack",$d
play_pattern_timed [52],[($s + 2 * $q)],"attack",($s + 2 * $q)
#play_pattern_timed [52,53,52,53,52,53,52,53,52,53,52,53],[$d],"attack",$d
sleep $cr
in_thread do #b30 RIGHT HAND
with_synth $synR
play_pattern_timed [60,62,64,66,68,69],[$s],"attack",$ss
end
#b30 start LEFT HAND
play_pattern_timed [52],[(3 * $q)],"attack",(3 * $q)
sleep $cr
in_thread do #b31 RIGHT HAND
with_synth $synR
play_pattern_timed [62,72,71,69,68,66],[$s],"attack",$ss
end
#b31 start LEFT HAND
play_pattern_timed [52],[(3 * $q)],"attack",(3 * $q)
sleep $cr
in_thread do #b32 RIGHT HAND
with_synth $synR
play_pattern_timed [64,66,68,69,71,72],[$s],"attack",$ss
end
#b32 start LEFT HAND
play_pattern_timed [52],[(3 * $q)],"attack",(3 * $q)
sleep $cr
in_thread do #b33 RIGHT HAND
with_synth $synR
play_pattern_timed [66,76,74,72,71,69],[$s],"attack",$ss
end
#b33 start LEFT HAND
play_pattern_timed [52],[(3 * $q)],"attack",(3 * $q)
sleep $cr
in_thread do #b34 RIGHT HAND
with_synth $synR
play_pattern_timed [68,69,68,66,64,62],[$s],"attack",$ss
end
#b34 start LEFT HAND
play_pattern_timed [52,64,62],[$q],"attack",$qs
sleep $cr
in_thread do #b35 RIGHT HAND
with_synth $synR
play_pattern_timed [69,77,76,74,72,71],[$s],"attack",$ss
end
#b35 start LEFT HAND
play_pattern_timed [60,59,57],[$q],"attack",$qs
sleep $cr
in_thread do #b36 + b37 RIGHT HAND
with_synth $synR
play_pattern_timed [81,80,78,76],[$s],"attack",$ss
play_pattern_timed [81],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [74],[$s],"attack",$ss
play_pattern_timed [71],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [69],[$s],"attack",$ss
end
#b36 + b37 start LEFT HAND
play_pattern_timed [62,64,65,62,64,52],[$q],"attack",$qs
sleep $cr
in_thread do #b38 RIGHT HAND
with_synth $synR
play_pattern_timed [69],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [69,70,72],[$s],"attack",$ss
end
#b38 start LEFT HAND
play_pattern_timed [57,45,46,48,50,51],[$s],"attack",$ss
sleep $cr
in_thread do #b39 RIGHT HAND
with_synth $synR
play_pattern_timed [62,66,69],[$q],"attack",$qs
end
#b39 start LEFT HAND
play_pattern_timed [42,51,50,48,46,45],[$s],"attack",$ss
sleep $cr
in_thread do #b40 RIGHT HAND
with_synth $synR
play_pattern_timed [70,67,69,70,72,74],[$s],"attack",$ss
end
#b40 start LEFT HAND
play_pattern_timed [43],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [43,45,46],[$s],"attack",$ss
sleep $cr
in_thread do #b41 RIGHT HAND
with_synth $synR
play_pattern_timed [64,74,72,70,69,67],[$s],"attack",$ss
end
#b41 start LEFT HAND
play_pattern_timed [36,43,48],[$q],"attack",$qs
sleep $cr
in_thread do #b42 RIGHT HAND
with_synth $synR
play_pattern_timed [69],[$q],"attack",$qs
play_pattern_timed [77,76],[$s],"attack",$ss
play_pattern_timed [77],[$q],"attack",$qs
end
#b42 start LEFT HAND
play_pattern_timed [53,55,57,59,61,62],[$s],"attack",$ss
sleep $cr
in_thread do #b43 RIGHT HAND
with_synth $synR
play_pattern_timed [67,76],[$q],"attack",$qs
sleep $q
end
#b43 start LEFT HAND
play_pattern_timed [52,62,61,59,57,55],[$s],"attack",$ss
sleep $cr
in_thread do #b44 RIGHT HAND
with_synth $synR
play_pattern_timed [74,76,77,79,81,82],[$s],"attack",$ss
end
#b44 start LEFT HAND
play_pattern_timed [53,57,62],[$q],"attack",$qs
sleep $cr
in_thread do #b45 RIGHT HAND
with_synth $synR
play_pattern_timed [73,82,81,79,77,76],[$s],"attack",$ss
end
#b45 start LEFT HAND
play_pattern_timed [52,55,61],[$q],"attack",$qs
sleep $cr
in_thread do #b46-b47 RIGHT HAND
with_synth $synR
play_pattern_timed [77,74],[$q],"attack",$qs
play_pattern_timed [67],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [74,73,76,69,73],[$s],"attack",$ss
end
#b46-b47 start LEFT HAND
play_pattern_timed [50,52,53,55,57,58,49,58,57,55,53,52],[$s],"attack",$ss
sleep $cr
in_thread do #b48 RIGHT HAND
with_synth $synR
play_pattern_timed [74,71],[$s],"attack",$ss
play_pattern_timed [73],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [74],[$s],"attack",$ss
end
#b48 start LEFT HAND
play_pattern_timed [53,55],[$s],"attack",$ss
play_pattern_timed [57,45],[$q],"attack",$qs
sleep $cr
in_thread do #b49 RIGHT HAND
with_synth $synR
play_pattern_timed [74,72,70,69,67,65],[$s],"attack",$ss
end
#b49 start LEFT HAND
play_pattern_timed [46],[($q + $s)],"attack",($qs + $ss)
play_pattern_timed [48,46,45],[$s],"attack",$ss
sleep $cr
in_thread do #b50 RIGHT HAND
with_synth $synR
play_pattern_timed [70,61,62,64,65,67],[$s],"attack",$ss
end
#b50 start LEFT HAND
play_pattern_timed [43,58,57,55,53,52],[$s],"attack",$ss
sleep $cr
in_thread do #b51 RIGHT HAND
with_synth $synR
play_pattern_timed [69,74],[$s],"attack",$ss
play_pattern_timed [65],[$q],"attack",$qs
play_pattern_timed [64,62],[$s],"attack",$ss
end
#b51 start LEFT HAND
play_pattern_timed [53,55],[$s],"attack",$ss
play_pattern_timed [57,45],[$q],"attack",$qs
sleep $cr
in_thread do #b52 RIGHT HAND
with_synth $synR
play_pattern_timed [62],[(3 * $q)],"attack",(3 * $q) #full length
end
#b52 start LEFT HAND
play_pattern_timed [38],[(3 * $q)],"attack",(3 * $q) #full length
sleep (3 * $q) #bar before next tune
end #of tune definition
########Play tune several times with different settings#######
#slow different synth each hand
$m = 1.4 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.15 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#bit faster, same synth both hands
$m = 1.3 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.2 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#moderate temop, differnt synths each hand
$m = 1.2 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#fast same synth each hand
$m = 1.0 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.120 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#super fast. different synth each hand
$m = 0.8 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$d = 0.0625 * $m #demi-semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.120 * $m #staccato semi attack < or = to$s
$ds = 0.0625 * $m #staccato demi-semi attack < or = to $d
$cr = 0.018125 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#Bach Two Part Invention no 8 coded by Robin Newman 21st October 2013
#score is here http://www.mutopiaproject.org/ftp/BachJS/BWV779/bach-invention-08/bach-invention-08-a4.pdf
#This illustrates the use of variables to allow tempo changes even though using the play_pattern_timed command
#Also shown is the use of multiple short in_thread structures to allow resynchronisation
#of the two hands. Each lasts for one, bar. If a Right Hand in_thread finishes early, then the next one does not start
#until the correct time is reached in the Left Hand part. To prevent the Left Hand part starting a Right Hand
#in_thread early a very short "bodge" sleep is inserted at end of each Left Hand bar. The timing of this "bodge"
#can be adjusted to give the smoothest performance, and in fact I think the very short delay that sometimes results
#enhances the performance.
#Also worth commenting is the use of $ variables which are global
#The with_synth command has to be used at the start of each thread, or it uses the default synth
#Separate synth variable names are used for the threads and the main program, so Left and Right parts can be different.
#only the saw_beep and beep synths work satisfactorily, without extraneous clicks and noises in the piece
#Attack times are specified with different variables to the note durations, allowing for staccato or sustained playing
#The whole piece is played several times allowing different parameter settings to be used
#'this is achieved by using the def tune...end structure, which allows the tune to be played with a single tune command
#setup initial timing variables
$m = 1 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.175 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
def tune #define the whole piece as tune so that it can be easily repeated with different parameters
with_synth $synL
in_thread do #b1 RIGHT HAND
with_synth $synR
sleep $q
play_pattern_timed [65,69,65,72,65],[$q],"attack",$qs
end
sleep (3 * $c) #b1 LEFT HAND
sleep $cr
in_thread do #b2 RIGHT HAND
with_synth $synR
play_pattern_timed [77],[$q],"attack",$ss
play_pattern_timed [76,74,72,74,72,70,69,70,69,67],[$s],"attack",$ss
end
sleep $q #b2 LEFT HAND
play_pattern_timed [53,57,53,60,53],[$q],"attack",$qs
sleep $cr
in_thread do #b3 RIGHT HAND
with_synth $synR
play_pattern_timed [65,69,72,69,77,72],[$q],"attack",$qs
end
#b4 start LEFT HAND
play_pattern_timed [65],[$q],"attack",$qs
play_pattern_timed [64,62,60,62,60,58,57,58,57,55],[$s],"attack",$ss
sleep $cr
in_thread do #b4 RIGHT HAND
with_synth $synR
play_pattern_timed [81,84,82,84,81,84,82,84,81,84,82,84],[$s],"attack",$ss
end
#b4 start LEFT HAND
play_pattern_timed [53,57,60,57,65,60],[$q],"attack",$qs
sleep $cr
in_thread do #b5 RIGHT HAND
with_synth $synR
play_pattern_timed [77,81,79,81,77,81,79,81,77,81,79,81],[$s],"attack",$ss
end
#b5 start LEFT HAND
play_pattern_timed [69,72,70,72,69,72,70,72,69,72,70,72],[$s],"attack",$ss
sleep $cr
in_thread do #b6 RIGHT HAND
with_synth $synR
play_pattern_timed [74,77,76,77,74,77,76,77,74,77,76,77],[$s],"attack",$ss
end
#b6 start LEFT HAND
play_pattern_timed [65,69,67,69,65,69,67,69,65,69,67,69],[$s],"attack",$ss
sleep $cr
in_thread do #b7 RIGHT HAND
with_synth $synR
play_pattern_timed [71,67,74,71,77,74],[$q],"attack",$qs
end
#b7 start LEFT HAND
play_pattern_timed [62,65,64,65,62,65,64,65,62,65,64,65],[$s],"attack",$ss
sleep $cr
in_thread do #b8 RIGHT HAND
with_synth $synR
play_pattern_timed [79,81,79,77,76,77,76,74,72,74,72,70],[$s],"attack",$ss
end
#b8 start LEFT HAND
play_pattern_timed [59,55,60,55,64,60],[$q],"attack",$qs
sleep $cr
in_thread do #b9 RIGHT HAND
with_synth $synR
play_pattern_timed [69],[$q],"attack",$qs
play_pattern_timed [74,72,71,72,71,69,67,69,67,65],[$s],"attack",$ss
end
#b9 start LEFT HAND
play_pattern_timed [65,67,65,64,62,64,62,60,59,60,59,57],[$s],"attack",$ss
sleep $cr
in_thread do #b10 RIGHT HAND
with_synth $synR
play_pattern_timed [64,65,64,62],[$s],"attack",$ss
play_pattern_timed [60],[$q],"attack",$qs
play_pattern_timed [72,71],[$s],"attack",$ss
play_pattern_timed [72,64],[$q],"attack",$qs
end
#b10 start LEFT HAND
play_pattern_timed [55],[$q],"attack",$qs
play_pattern_timed [60,59,57,59,57,55,53,55,53,52],[$s],"attack",$ss
sleep $cr
in_thread do #b11 RIGHT HAND
with_synth $synR
play_pattern_timed [65,72,64,72,62,71],[$q],"attack",$qs
end
#b11 start LEFT HAND
play_pattern_timed [50,52,50,48,55,53,52,53],[$s],"attack",$ss
play_pattern_timed [55,43],[$q],"attack",$qs
sleep $cr
in_thread do #b12 RIGHT HAND
with_synth $synR
play_pattern_timed [72],[$c],"attack",$c #crotchet attack = duration
sleep (2 * $c)
end
#b12 start LEFT HAND
sleep $q
play_pattern_timed [48,52,48,55,48],[$q],"attack",$qs
sleep $cr
in_thread do #b13 RIGHT HAND
with_synth $synR
sleep $q
play_pattern_timed [72,76,72,79,72],[$q],"attack",$qs
end
#b13 start LEFT HAND
play_pattern_timed [60],[$q],"attack",$qs
play_pattern_timed [59,57,55,57,55,53,52,53,52,50],[$s],"attack",$ss
sleep $cr
in_thread do #b14 RIGHT HAND
with_synth $synR
play_pattern_timed [84],[$q],"attack",$qs
play_pattern_timed [83,81,79,81,79,77,76,77,76,74],[$s],"attack",$ss
end
#b14 start LEFT HAND
play_pattern_timed [48,52,55,52,60,55],[$q],"attack",$qs
sleep $cr
in_thread do #b15 RIGHT HAND
with_synth $synR
play_pattern_timed [72,70,72,81,72,81,70,81,72,81,69,81],[$s],"attack",$ss
end
#b15 start LEFT HAND
play_pattern_timed [63,54,63,54,63,54],[$q],"attack",$qs
sleep $cr
in_thread do #b16 RIGHT HAND
with_synth $synR
play_pattern_timed [70,67,70,67,74,67],[$q],"attack",$qs
end
#b16 start LEFT HAND
play_pattern_timed [55],[$q],"attack",$qs
play_pattern_timed [53,51,50,51,50,48,46,48,46,45],[$s],"attack",$ss
sleep $cr
in_thread do #b17 RIGHT HAND
with_synth $synR
play_pattern_timed [79],[$q],"attack",$qs
play_pattern_timed [77,75,74,75,74,72,70,72,70,69],[$s],"attack",$ss
end
#b17 start LEFT HAND
play_pattern_timed [43,55,58,55,62,55],[$q],"attack",$qs
sleep $cr
in_thread do #b18 RIGHT HAND
with_synth $synR
play_pattern_timed [67,70,74,70,79,74],[$q],"attack",$qs
end
#b18 start LEFT HAND
play_pattern_timed [67],[$q],"attack",$qs
play_pattern_timed [65,63,62,63,62,60,58,60,58,57],[$s],"attack",$ss
sleep $cr
in_thread do #b19 RIGHT HAND
with_synth $synR
play_pattern_timed [82,73,82,73,82,73],[$q],"attack",$qs
end
#b19 start LEFT HAND
play_pattern_timed [55,53,55,64,55,64,53,64,55,64,52,64],[$s],"attack",$ss
sleep $cr
in_thread do #b20 RIGHT HAND
with_synth $synR
play_pattern_timed [74,69,77,74,81,77],[$q],"attack",$qs
end
#b20 start LEFT HAND
play_pattern_timed [53,52,53,62,53,62,52,62,53,62,50,62],[$s],"attack",$ss
sleep $cr
in_thread do #b21 RIGHT HAND
with_synth $synR
play_pattern_timed [79,77,79,82,72,82,74,82,76,82,72,82],[$s],"attack",$ss
end
#b21 start LEFT HAND
play_pattern_timed [58,55,52,55,48,52],[$q],"attack",$qs
sleep $cr
in_thread do #b22 RIGHT HAND
with_synth $synR
play_pattern_timed [77,76,77,81,71,81,73,81,74,81,71,81],[$s],"attack",$ss
end
#b22 start LEFT HAND
play_pattern_timed [57,53,50,53,47,50],[$q],"attack",$qs
sleep $cr
in_thread do #b23 RIGHT HAND
with_synth $synR
play_pattern_timed [76,74,76,79,69,79,71,79,73,79,69,79],[$s],"attack",$ss
end
#b23 start LEFT HAND
play_pattern_timed [55,52,49,52,45,49],[$q],"attack",$qs
sleep $cr
in_thread do #b24 RIGHT HAND
with_synth $synR
play_pattern_timed [77,74,70,74,67,77],[$q],"attack",$qs
end
#b24 start LEFT HAND
play_pattern_timed [38,50,48,50,43,50,45,50,46,50,43,50],[$s],"attack",$ss
sleep $cr
in_thread do #b25 RIGHT HAND
with_synth $synR
play_pattern_timed [76,72,69,72,65,75],[$q],"attack",$qs
end
#b25 start LEFT HAND
play_pattern_timed [36,48,46,48,41,48,43,48,45,48,41,48],[$s],"attack",$ss
sleep $cr
in_thread do #b26 RIGHT HAND
with_synth $synR
play_pattern_timed [74,77,75,77,74,77,75,77,74,77,75,77],[$s],"attack",$ss
end
#b26 start LEFT HAND
play_pattern_timed [46,50,53,50,58,53],[$q],"attack",$qs
sleep $cr
in_thread do #b27 RIGHT HAND
with_synth $synR
play_pattern_timed [70,74,72,74,70,74,72,74,70,74,72,74],[$s],"attack",$ss
end
#b27 start LEFT HAND
play_pattern_timed [62,65,63,65,62,65,63,65,62,65,63,65],[$s],"attack",$ss
sleep $cr
in_thread do #b28 RIGHT HAND
with_synth $synR
play_pattern_timed [67,70,69,70,67,70,69,70,67,70,69,70],[$s],"attack",$ss
end
#b28 start LEFT HAND
play_pattern_timed [58,62,60,62,58,62,60,62,58,62,60,62],[$s],"attack",$ss
sleep $cr
in_thread do #b29 RIGHT HAND
with_synth $synR
play_pattern_timed [64,60,67,64,70,67],[$q],"attack",$qs
end
#b29 start LEFT HAND
play_pattern_timed [55,58,57,58,55,58,57,58,55,58,57,58],[$s],"attack",$ss
sleep $cr
in_thread do #b30 RIGHT HAND
with_synth $synR
play_pattern_timed [72,74,72,70,69,70,69,67,65,67,65,63],[$s],"attack",$ss
end
#b30 start LEFT HAND
play_pattern_timed [52,48,53,48,57,53],[$q],"attack",$qs
sleep $cr
in_thread do #b31 RIGHT HAND
with_synth $synR
play_pattern_timed [62],[$q],"attack",$qs
play_pattern_timed [67,65,64,65,64,62,60,62,60,58],[$s],"attack",$ss
end
#b31 start LEFT HAND
play_pattern_timed [58,60,58,57,55,57,55,53,52,53,52,50],[$s],"attack",$ss
sleep $cr
in_thread do #b32 RIGHT HAND
with_synth $synR
play_pattern_timed [57,58,57,55],[$s],"attack",$ss
play_pattern_timed [53],[$q],"attack",$qs
play_pattern_timed [65,64],[$s],"attack",$ss
play_pattern_timed [65,57],[$q],"attack",$qs
end
#b32 start LEFT HAND
play_pattern_timed [48],[$q],"attack",$qs
play_pattern_timed [53,52,50,52,50,48,46,48,46,45],[$s],"attack",$ss
sleep $cr
in_thread do #b33 RIGHT HAND
with_synth $synR
play_pattern_timed [58,65,57,65,55,64],[$q],"attack",$qs
end
#b33 start LEFT HAND
play_pattern_timed [43,45,43,41,48,46,45,46],[$s],"attack",$ss
play_pattern_timed [48,36],[$q],"attack",$qs
sleep $cr
in_thread do #b34 RIGHT HAND
with_synth $synR
play_chord [57,60,65],"attack",$c
sleep (3 * $c)
end
#b34 start LEFT HAND
play_pattern_timed [41],[$c],"attack",$c #attack set to duration here
sleep (2 * $c)
end #of tune definition
########Play tune several times with different settings#######
#slow different synth each hand
$m = 1.4 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.15 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#bit faster, same synth both hands
$m = 1.2 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.2 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#moderate temop, different synths each hand
$m = 1 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.125 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#fast same synth each hand
$m = 0.8 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.120 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "saw_beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#super fast. different synth each hand
$m = 0.6 #multiplier for timing
$c = 0.5 * $m #crotchet ALWAYS THIS VALUE
$q = 0.25 * $m #quaver ALWAYS THIS VALUE
$s = 0.125 * $m #semi-quaver ALWAYS THIS VALUE
$qs = 0.125 * $m #staccato quaver attack < or = to $q
$ss = 0.120 * $m #staccato semi attack < or = to$s
$cr = 0.03625 * $m #sync correction...value by trial and error
$synR = "beep" #set synth as a global named variable for RIGHT hand. Allows single point changing
$synL = "saw_beep" #set synth as a global named variable for LEFT hand.
#play tune
tune
#This file illustrates the use of the play_pattern_timed command with the "attack" parameter. Using this the note sounds throughout its duration. Also illustrated are the use of nn.times do...end loops and the use of in_thread to play a concurrent part.
#This version includes an optional second parallen thread for a pedal base note, but it gives a rather scratchy sounding result
#copy after the dider and paste into Sonic-P
#==================================================
#Eleanor Rigby by John Lennon and Paul McCartney coded for Sonic-Pi by Robin Newman 6 Oct 2013
#the piece illustrates the use of the play_pattern_timed command using the attack paremeter. This enables
#you to have the note playing throughout the duration of the note, by setting the attack number equal
#to the note duration eg play_pattern_timed [60],[0.5],"attack",0.5 would sound a C for half a second
#you can also play stacatto bu reducing the attack number less than the duration of the note as in the fourth bar
#Threads are used so that the left hand part sounds simultaneously with the right hand. The pice also has a base
#drome note which is included in a second in_thread sequence. The Pi finds it hard to handle towe simultaneous
#threads and a certain scratchyness results. If you don't like this you can omit the three threads marked #bass note thread
#nb these are NOT the left hand threads which you DO need to keep
#unlike the Bach Minuet I also coded, this time it is not convenient to code in bar lengths, as there are syncopated
#rhythms across bar lines, but some comments are added to indicate where you are in the music
#where possible sections are repeated using n.times do ......end constructs. These are also used to repeat the verses
#and the intro. The third verse is copy and pasted because it differs in the last two bars
#based on the music version published here http://www.paperbagmusic.com/media/Beatles_all_songs.pdf (page 119)
#intro 4 bars before double bar line with repeat
2.times do
in_thread do #bass note thread (can be removed)
with_synth "pretty_bell"
play_pattern_timed [48],[4],"attack",4
play_pattern_timed [40],[4],"attack",4
end
in_thread do #left hand thread (needed)
with_synth "pretty_bell"
play_pattern_timed [60,55],[0.5],"attack",0.5
play_pattern_timed [60],[3.0],"attack",3.0
play_pattern_timed [52,55,59],[0.5],"attack",0.5
sleep 2.5
end
with_synth "pretty_bell" #play the tune
play_pattern_timed [76],[1.25],"attack",1.25
play_pattern_timed [78,79],[0.25],"attack",0.25
play_pattern_timed [81,79,78,76],[0.5],"attack",0.5
play_pattern_timed [71],[0.375],"attack",0.375
play_pattern_timed [69],[0.125],"attack",0.125
play_pattern_timed [67],[1.25],"attack",1.125
play_pattern_timed [69,71,67,71,69,71,67,71,64,71],[0.25],"attack",0.1
end #repeat here
#after double bar line
#3 verses, two identical, third one differs in last two bars
2.times do
in_thread do #play bass note thread (optional can be removed)
with_synth "pretty_bell"
play_pattern_timed [40],[6],"attack",6
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[7],"attack",7
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[9],"attack",9
play_pattern_timed [40],[8],"attack",8
end
in_thread do #play left hand (needed)
with_synth "pretty_bell"
3.times do #bar is repeated three times
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55],[0.5],"attack",0.5
3.times do #bar is repeated three times
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55,52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
with_synth "pretty_bell" #play the tune
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#repeated
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#b 15
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [76],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67,67],[0.25],"attack",0.25
play_pattern_timed [64],[2.25],"attack",2.25
#repeated
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [79],[0.75],"attack",0.75
play_pattern_timed [76],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,69],[0.25],"attack",0.25
play_pattern_timed [67],[2.25],"attack",2.25
end
#last verse differs in last bar
in_thread do #play bass note thread (optional can be removed)
with_synth "pretty_bell"
play_pattern_timed [40],[6],"attack",6
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[7],"attack",7
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[9],"attack",9
play_pattern_timed [40],[8],"attack",6 #reduced length last time
end
in_thread do #play left hand (needed)
with_synth "pretty_bell"
3.times do
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55],[0.5],"attack",0.5
3.times do
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55,52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
#3rd time bar follows
play_chord [52,55,59,40],"attack",4 #two bars length
end
with_synth "pretty_bell" #play tune
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#repeated
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#b 15
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [76],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67,67],[0.25],"attack",0.25
play_pattern_timed [64],[2.25],"attack",2.25
#repeated
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [79],[0.75],"attack",0.75
play_pattern_timed [76],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,69],[0.25],"attack",0.25
#3rd time bar follows
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [76,71,69],[0.5],"attack",0.5
play_pattern_timed [67],[2],"attack",2
#end of piece
#This version of Eleanor Rigby has the optional pedal base removed. It sounds much cleaner.
#Copy and paste into Sonic-Pi all after the divider
#=========================================================
#Eleanor Rigby by John Lennon and Paul McCartney coded for Sonic-Pi by Robin Newman 6 Oct 2013
#the piece illustrates the use of the play_pattern_timed command using the attack paremeter. This enables
#you to have the note playing throughout the duration of the note, by setting the attack number equal
#to the note duration eg play_pattern_timed [60],[0.5],"attack",0.5 would sound a C for half a second
#you can also play stacatto bu reducing the attack number less than the duration of the note as in the fourth bar
#Threads are used so that the left hand part sounds simultaneously with the right hand. The pice also has a base
#drome note which is included in a second in_thread sequence. The Pi finds it hard to handle towe simultaneous
#threads and a certain scratchyness results. If you don't like this you can omit the three threads marked #bass note thread
#nb these are NOT the left hand threads which you DO need to keep
#unlike the Bach Minuet I also coded, this time it is not convenient to code in bar lengths, as there are syncopated
#rhythms across bar lines, but some comments are added to indicate where you are in the music
#where possible sections are repeated using n.times do ......end constructs. These are also used to repeat the verses
#and the intro. The third verse is copy and pasted because it differs in the last two bars
#based on the music version published here http://www.paperbagmusic.com/media/Beatles_all_songs.pdf (page 119)
#intro 4 bars before double bar line with repeat
2.times do
in_thread do #bass note thread (can be removed)
with_synth "pretty_bell"
play_pattern_timed [48],[4],"attack",4
play_pattern_timed [40],[4],"attack",4
end
in_thread do #left hand thread (needed)
with_synth "pretty_bell"
play_pattern_timed [60,55],[0.5],"attack",0.5
play_pattern_timed [60],[3.0],"attack",3.0
play_pattern_timed [52,55,59],[0.5],"attack",0.5
sleep 2.5
end
with_synth "pretty_bell" #play the tune
play_pattern_timed [76],[1.25],"attack",1.25
play_pattern_timed [78,79],[0.25],"attack",0.25
play_pattern_timed [81,79,78,76],[0.5],"attack",0.5
play_pattern_timed [71],[0.375],"attack",0.375
play_pattern_timed [69],[0.125],"attack",0.125
play_pattern_timed [67],[1.25],"attack",1.125
play_pattern_timed [69,71,67,71,69,71,67,71,64,71],[0.25],"attack",0.1
end #repeat here
#after double bar line
#3 verses, two identical, third one differs in last two bars
2.times do
in_thread do #play bass note thread (optional can be removed)
with_synth "pretty_bell"
play_pattern_timed [40],[6],"attack",6
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[7],"attack",7
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[9],"attack",9
play_pattern_timed [40],[8],"attack",8
end
in_thread do #play left hand (needed)
with_synth "pretty_bell"
3.times do #bar is repeated three times
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55],[0.5],"attack",0.5
3.times do #bar is repeated three times
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55,52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
with_synth "pretty_bell" #play the tune
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#repeated
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#b 15
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [76],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67,67],[0.25],"attack",0.25
play_pattern_timed [64],[2.25],"attack",2.25
#repeated
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [79],[0.75],"attack",0.75
play_pattern_timed [76],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,69],[0.25],"attack",0.25
play_pattern_timed [67],[2.25],"attack",2.25
end
#last verse differs in last bar
in_thread do #play bass note thread (optional can be removed)
with_synth "pretty_bell"
play_pattern_timed [40],[6],"attack",6
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[7],"attack",7
play_pattern_timed [48],[3],"attack",3
play_pattern_timed [40],[9],"attack",9
play_pattern_timed [40],[8],"attack",6 #reduced length last time
end
in_thread do #play left hand (needed)
with_synth "pretty_bell"
3.times do
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55],[0.5],"attack",0.5
3.times do
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
end
play_pattern_timed [60,64,54,64,60,64,59,55,52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
play_pattern_timed [52,55,59,55],[0.5],"attack",0.5
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [61],[1],"attack",1
play_pattern_timed [52,55],[0.5],"attack",0.5
play_pattern_timed [60],[1],"attack",1
#3rd time bar follows
play_chord [52,55,59,40],"attack",4 #two bars length
end
with_synth "pretty_bell" #play tune
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#repeated
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b4
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[0.75],"attack",0.75
play_pattern_timed [67,69,71],[0.25],"attack",0.25 #b5
play_pattern_timed [74],[0.5],"attack",0.5
play_pattern_timed [73,71],[0.25],"attack",0.25
play_pattern_timed [73],[0.5],"attack",0.5
play_pattern_timed [71,69],[0.25],"attack",0.25 #b6
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,67],[0.25],"attack",0.25
play_pattern_timed [69],[2.25],"attack",2.25
play_pattern_timed [67,69,71],[0.25],"attack",0.25
play_pattern_timed [72],[0.75],"attack",0.75
play_pattern_timed [71],[0.5],"attack",0.5
#b 15
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [76],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67,67],[0.25],"attack",0.25
play_pattern_timed [64],[2.25],"attack",2.25
#repeated
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [67],[0.25],"attack",0.25
play_pattern_timed [69],[0.75],"attack",0.75
play_pattern_timed [71],[0.25],"attack",0.25
play_pattern_timed [67],[0.5],"attack",0.5
play_pattern_timed [64],[1.25],"attack",1.25
play_pattern_timed [64],[0.25],"attack",0.25
play_pattern_timed [79],[0.75],"attack",0.75
play_pattern_timed [76],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [69,69],[0.25],"attack",0.25
#3rd time bar follows
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [76,71,69],[0.5],"attack",0.5
play_pattern_timed [67],[2],"attack",2
#end of piece
#alternative FrereJaques using defined methods for each line by Robin Newman 12th October 2013
#played as a three part round. Also use of a global variable
$s = "beep" #synth to use. $s is global variable
def a #first line (played twice)
with_synth $s
play_pattern_timed [62,64,66,62],[0.25]
end
def b #third line of music (played twice)
with_synth $s
play_pattern_timed [66,67,69],[0.25,0.25,0.5]
end
def c #fifth line of music (played twice)
with_synth $s
play_pattern_timed [69,71,69,67,66,62],[0.125,0.125,0.125,0.125,0.25,0.25]
end
def d #7th line of music (played twice)
play_pattern_timed [62,57,62],[0.25,0.25,0.5]
end
#having defined the sections play the tune
a
a
in_thread do #start the second part here
a
a
b
b
c
c
d
d
end #end the second part
b
b
in_thread do #start the third part here
a
a
b
b
c
c
d
d
end #end third part
c
c
d
d #end the first part
#My first piece is Frerejacques played as a two part round. I tried three parts, but Sonic-Pi (on my 256Mb Pi) doesn;t like #having more than one in-thread playing at a time. Copy and paste the tune after the divider.
#=================================================================
# Frere Jacques as a simple two part round
# The second part starts after the first play_pattern_timed
# has completed the first phrase
# The second part is contained in a thread that plays in parallel
# By Robin Newman Sept 2013
# only 1 time in first phrase, as all notes same length, and so only need 1 0.25 in the play_pattern_timed list
play_pattern_timed [60,62,64,60,60,62,64,60],[0.25]
# now start the second part in a parallel thread
in_thread do
#only 1 time in first phrase, as all notes same length, and so only need 1 0.25 in the play_pattern_timed list
play_pattern_timed [60,62,64,60,60,62,64,60],[0.25]
play_pattern_timed [64,65,67,64,65,67],[0.25,0.25,0.5,0.25,0.25,0.5]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [60,55,60,60,55,60],[0.25,0.25,0.5,0.25,0.25,0.5]
end
# the first part continues here, playing in parallel with the thread
play_pattern_timed [64,65,67,64,65,67],[0.25,0.25,0.5,0.25,0.25,0.5]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [60,55,60,60,55,60],[0.25,0.25,0.5,0.25,0.25,0.5]
#frerejacques three part round. This works ok with saw_beep synth
with_synth "saw_beep"
play_pattern_timed [60,62,64,60,60,62,64,60],[0.25]
# now start the second part in a parallel thread
in_thread do
with_synth "saw_beep"
#only 1 time in first phrase, as all notes same length, and so only need 1 0.25 in the play_pattern_timed list
play_pattern_timed [60,62,64,60,60,62,64,60],[0.25]
play_pattern_timed [64,65,67,64,65,67],[0.25,0.25,0.5,0.25,0.25,0.5]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [60,55,60,60,55,60],[0.25,0.25,0.5,0.25,0.25,0.5]
end
# the first part continues here, playing in parallel with the thread
play_pattern_timed [64,65,67,64,65,67],[0.25,0.25,0.5,0.25,0.25,0.5]
#now start the third part in a second parallel thread
in_thread do
with_synth "saw_beep"
#only 1 time in first phrase, as all notes same length, and so only need 1 0.25 in the play_pattern_timed list
play_pattern_timed [60,62,64,60,60,62,64,60],[0.25]
play_pattern_timed [64,65,67,64,65,67],[0.25,0.25,0.5,0.25,0.25,0.5]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [60,55,60,60,55,60],[0.25,0.25,0.5,0.25,0.25,0.5]
end
#the remainder of the main part is here
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [67,69,67,65,64,60],[0.125,0.125,0.125,0.125,0.25,0.25]
play_pattern_timed [60,55,60,60,55,60],[0.25,0.25,0.5,0.25,0.25,0.5]
#GoingBananasWithFMSynth by Robin Newman 19th October 2013
#This program explores the use of the FM Synth in Sonic-Pi (with three chords from saw_beep)
#The basic syntax to play a note is play_synth "fm","note",n,"divisor",d,"release",r
#followed by a sleep command for the note to sound, where n, d and r are numbers
#The program uses n.times do....end loops and variables to cycle through different notes and divisor settings
#in each case an in_thread do.....end is used to play a second sequence of notes at the same time
#NB in order to compute values for the divisor the calculation has to be enclosed in brackets. Thus (n / 4)
#Description of the piece
#The piece is symmetrical with six parts
#an intro of a soft warble and a buzzing note that rise then falls in intensity
#section 1: a pattern of a rising semitone scale over two octaves, played with a similar pattern
#offset by half a beat and falling for two octaves. The divisor settings for the two patterns are different.
#section two a pattern when a note is played with 5 different values for the divisor setting, then raised
#by three tones before being played again. Repeated 24 times
#This is played against the same pattern with the divisors in reverse order, and the notes falling by three tones
#between repetitions
#the symmetrical axis of the piece is a constant saw_beep chord which grows and fades over 8 seconds
#section 3 is a repeat of section 2, but with the order of the five notes for each divisor setting reversed
#section 4 is a repeat of section 1 with the divisor settings for the two patterns swapped over
#a final end sections repeats the two initial notes in reverse order.
#the divisor multipliers used are n/4 n/2 n n*2 and n*4 where n is the pitch of the note
#this will produce some numbers out of range, but the note will still play
#you can experiment with other settings eg n/1.5,n/1.2,n,n*1.2,n*1.5 (NB leave spaces as shown in the program)
#the timing settings can be altered with variables t and s, but as supplied the piece lasts 187.2 seconds
#the whole piece has a mathematical symmetry, although the resulting sounds seem more random
#===========Program starts below =================================
#set timings for first (t) and middle (s) sections
t = 0.8
s = 1
#=====intro section===============================================
play_synth "fm","note",36,"divisor",(12 ),"release",3 #quiet warble
sleep 3
with_synth "saw_beep"
#a buzzing note that rises then falls in intensity
play_chord [24,24.2],"attack",4,"release",4
sleep 8 #sleep time equals sum of attack and release times
#======section 1==================================================
p = 60 #starting pitch
#timings set by t
in_thread do
pt = 84 #starting pitch for thread
sleep (t / 2) #the notes are offset by half a "beat"
24.times do
play_synth "fm","note",pt,"divisor",(pt * 2 ),"release",t
sleep t
pt = pt - 1 #notes fall in pitch by a semitone
end
end #end of thread
24.times do
play_synth "fm","note",p,"divisor",(p / 4 ),"release",t
sleep t
p = p + 1 #notes rise in pitch by a semitone
end
sleep (t / 2) # allows for completion of the offset thread notes
#end of section 1=================================================
in_thread do #thread for section 2
nt = 48 #starting pitch for thread
#timings set by s
12.times do
#play the same note 5 times with different related divisor times
play_synth "fm","note",nt,"divisor",(nt / 4),"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt / 2),"release",s
sleep s
play_synth "fm","note",nt,"divisor",nt ,"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt * 2),"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt * 4),"release",s
sleep s
nt = nt + 6 #increase pitch by 3 tones
end
end #of thread for section 2
n = 120 #starting pitch
#timings set by s
12.times do
#play the same note 5 times with different related divisor times
#order of notes is reversed from that in the thread
play_synth "fm","note",n,"divisor",(4 * n),"release",s
sleep s
play_synth "fm","note",n,"divisor",(2 * n),"release",s
sleep s
play_synth "fm","note",n,"divisor",n ,"release",s
sleep s
play_synth "fm","note",n,"divisor",(n / 2),"release",s
sleep s
play_synth "fm","note",n,"divisor",(n / 4),"release",s
sleep s
n = n - 6 #decrease pitch of the note by 3 tones
end
#end of section 2===============================================
#symmetric axis for the piece...a saw_beep chord
#marks the half way point of the piece
with_synth "saw_beep"
play_chord [72,72.2],"attack",6
sleep 6
#end of symmetric axis note=====================================
#section 3 repeats section 2 but with the order of the 5 notes reversed for each pitch played
in_thread do #section 3 thread start
nt = 120 #starting pitch
#timings set by s
12.times do
#play note five times
play_synth "fm","note",nt,"divisor",(nt / 4),"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt / 2),"release",s
sleep s
play_synth "fm","note",nt,"divisor",nt ,"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt * 2),"release",s
sleep s
play_synth "fm","note",nt,"divisor",(nt * 4),"release",s
sleep s
nt = nt - 6 #pitch changes down three tones
end
end #of thread section 3
n = 48
#timings set by s
12.times do
play_synth "fm","note",n,"divisor",(n * 4),"release",s
sleep s
play_synth "fm","note",n,"divisor",(n * 2),"release",s
sleep s
play_synth "fm","note",n,"divisor",n ,"release",s
sleep s
play_synth "fm","note",n,"divisor",(n / 2),"release",s
sleep s
play_synth "fm","note",n,"divisor",(n / 4),"release",s
sleep s
n = n + 6 #pitch changes up by 3 tones
end
#end of section 3==============================================
#section 4
p = 60 #starting pitch
#timings set by t
in_thread do
sleep (t / 2) #offset by half a "beat"
pt = 84 #thread starting pitch
24.times do
#divisor setting swapped from section 1 with the concurrent loop
play_synth "fm","note",pt,"divisor",(pt / 4 ),"release",t
sleep t
pt = pt - 1 #pitch lowers a semitone
end
end #end of thread for last section
24.times do
play_synth "fm","note",p,"divisor",(p * 2 ),"release",t
sleep t
p = p + 1 #pitch rises a semitone
end
sleep (t / 2)
#end of last section============================================
#finish section
with_synth "saw_beep"
play_chord [24,24.2],"attack",4,"release",4
sleep 8
play_synth "fm","note",48,"divisor",(12 ),"release",3
sleep 3
#end of piece===================================================
#Bach Minuet in G programmed by Robin Newman 2 Oct 2013
#notes: left hand and right hand are programmed separately but played concurrently using threads
#mostly coded using play_pattern_timed
#some bars use play note plus sleep but I don't think the timing is as accurate
#I use a new thread each 8 bars, so that the starts are synchronised more often than if a single thread
#was used for all the left hand part
#mainly coded in bar sections, which makes it easier to debug mistakes
#first line of each bar is commented #b1 #b24 etc
2.times do #each section of the minuet is repeated
#first start a thread for the first 8 bars of the bass left hand part
in_thread do
with_synth("beep")
play_chord [55,59]#b1
sleep 1
play_pattern_timed [57],[0.5]
play_pattern_timed [59],[1.5] #b2
play_pattern_timed [60],[1.5] #b3
play_pattern_timed [59],[1.5] #b4
play_pattern_timed [57],[1.5] #b5
play_pattern_timed [55],[1.5] #b6
play_pattern_timed [62,59,55],[0.5] #b7
play_pattern_timed [62],[0.5] #b8
play_pattern_timed [50,60,59,57],[0.25]
end
#Play concurrently the first 8 bars of the right hand part
with_synth ("beep")
play_pattern_timed [74],[0.5]#b1
play_pattern_timed [67,69,71,72],[0.25]
play_pattern_timed [74,67,67],[0.5]#b2
play_pattern_timed [76],[0.5]#b3
play_pattern_timed [72,74,76,78],[0.25]
play_pattern_timed [79,67,67],[0.5]#b4
play_pattern_timed [72],[0.5] #b5
play_pattern_timed [74,72,71,69],[0.25]
play_pattern_timed [71],[0.5] #b6
play_pattern_timed [72,71,69,67],[0.25]
play_pattern_timed [66],[0.5] #b7
play_pattern_timed [67,69,71,67],[0.25]
play_pattern_timed [71,69],[0.5,1] #b8
#start a new thread for bars 9-16 of the left hand part
in_thread do
with_synth("beep")
play_chord [55,59]#b9=b1
sleep 1
play 57
sleep 0.5
play_pattern_timed [55,59,55],[0.5] #b10
play_pattern_timed [60],[1.5] #b11=b3
play_pattern_timed [59,60,59,57,5],[0.5,0.25,0.25,0.25,0.25] #b12=b4]
play_pattern_timed [57,54],[1,0.5] #b13
play-pattern|_timed [55,59],[1,0.5] #b14
play_pattern_timed [60,62,50],[0.5] #b15
play_pattern_timed [55,43],[1,0.5] #b16
end
#play concurrently bars 9-16 of the right hand part
#the first six bars repeat bars 1-6
play_pattern_timed [74],[0.5]#b9 = b1
play_pattern_timed [67,69,71,72],[0.25]
play_pattern_timed [74,67,67],[0.5]#b10=b2
play_pattern_timed [76],[0.5]#b11=b3
play_pattern_timed [72,74,76,78],[0.25]
play_pattern_timed [79,67,67],[0.5]#b12=b4
play_pattern_timed [72],[0.5] #b13=b5
play_pattern_timed [74,72,71,69],[0.25]
play_pattern_timed [71],[0.5] #b14=b6
play_pattern_timed [72,71,69,67],[0.25]
play_pattern_timed [69],[0.5] #b15
play_pattern_timed [71,69,67,66],[0.25]
play-pattern_timed [67],[1.5] #b16
end
#=======================end of repeat=====
#==========second section starts here======
#the second section is also repeated
2.times do
#start a thread for bars 17-24 of the left hand part
in_thread do
with_synth("beep")
play_pattern_timed [55],[1.5] #b17
play_pattern_timed [54],[1.5] #b18
play_pattern_timed [52,54,52],[0.5] #b19
play_pattern_timed [57,45],[1,0.5] #b20
play_pattern_timed [57],[1.5] #b21
play_pattern_timed [59,62,61],[0.5] #b22
play_pattern_timed [62,54,57],[0.5] #b23
play_pattern_timed [62,50,60],[0.5] #b24
end
#play bars 17 to 24 of the right hand concurrently with the left hand thread
with_synth("beep")
play_pattern_timed [83],[0.5] #b17
play_pattern_timed [79,81,83,79],[0.25]
play_pattern_timed [81],[0.5] #b18
play_pattern_timed [74,76,78,74],[0.25]
play_pattern_timed [79],[0.5] #b19
play_pattern_timed [76,78,79,74],[0.25]
play_pattern_timed [73,71,73,69],[0.5,0.25,0.25,0.5] #b20
play_pattern_timed [69,71,73,74,76,78],[0.25] #b21
play_pattern_timed [79,78,76],[0.5] #b22
play_pattern_timed [78,69,73],[0.5] #b23
play 74 #b24
sleep 1.5
#start a new thread for bars 25-32 of the left hand part
in_thread do
with_synth("beep")
play_pattern_timed [59,62,59],[0.5] #b25
play_pattern_timed [60,64,60],[0.5] #b26
play_pattern_timed [59,57,55],[0.5] #b27
play 62 #b28
sleep 1.5 #includes a rest
play_pattern_timed [50,54],[1,0.5] #b29
play_pattern_timed [52,55,54],[0.5] #b30
play_pattern_timed [55,47,50],[0.5] #b31
play_pattern_timed [55,50,43],[0.5] #b32
end
#play bars 25-32 of the right hand part concurrently with the left hand thread
play_pattern_timed [74,67,66,67],[0.5,0.25,0.25,0.5] #b25
play_pattern_timed [76,67,66,67],[0.5,0.25,0.25,0.5] #b26
play_pattern_timed [74,72,71],[0.5] #b27
play_pattern_timed [69,67,66,67,69],[0.25,0.25,0.25,0.25,0.5] #b28
play_pattern_timed [62,64,66,67,69,71],[0.25] #b29
play_pattern_timed [72,71,69],[0.5] #b30
play_pattern_timed [71,74,67,66],[0.25,0.25,0.5,0.5] #b31
play_chord [67,59] #b32
sleep 1.5
end
#=================end of repeat====================
#============end of entire minuet =================
#spooky loops by Robin Newman for Sonic-Pi October 12th 2013
#This short program explores the use of nested loops and random numbers to generate a never ending rising and falling sound using the fm synth
with_tempo 300 #set the tempo (chosen so that no clicking but not too slow)
with_synth "fm" #set the synth (gives a nice spooky noise)
repeat do #the sequence repeats until you press the stop button
p = 1 #you can use variables in Sonic-Pi This one is set to adjust whether the notes are rising 1 or falling 2
n = 32 #this variable sets the starting octave (c = 32)
2.times do # the sequence is run twice. The first time the notes rise, the second they fall
if p == 1 #this tests if first time p is 1 or second time p is 2. Note the == for comparison
inc = 12 #this variable is the octave increment (midi number up by twelve each octave) first time the octave rises
else
inc = -12 #second time through the octave falls again each time through the next loop
end
6.times do #the sequence goes through six octaves
5.times do #random note patterns are played 5 times, each note is pitched in the current octave at random
play_pattern [ (n + rand * 12),(n + rand * 12),(n + rand * 12),(n + rand * 12)]
end
n = n + inc #set the base value for the next octave
end
n = n - inc #last time through the previous loop we don't want to increase the octave so correct it
p = 2 #set p for the next pass to make the octaves decrease
end #now repeat for the second pass with the octaves decreasing
end #repeat the whole sequence indefinitely until stop is pressed
#strange noises by Robin Newman 9th October 2013
#This piece illustrates the use of the fm synth, using a variable in a loop
#to select note pitches, and use of the reverse and shuffle parameters for a play_pattern
#the piece is enclosed in a repeat do...end loop which runs continuously
#until the stop button is pushed
repeat do #runs until you press stop
play_synth "fm","note",172,"divisor",85,"release",5
sleep 2
n=40
10.times do
play n
sleep 0.2
n = n * 1.1
end
stop
play_synth "fm" ,"note",120,"divisor",200,"release",2
sleep 2
play_synth "fm" ,"note",70,"divisor",100,"release",1
sleep 2
play_synth "fm" ,"note",100,"divisor",333,"release",10
sleep 2
2.times do
with_synth "saw_beep"
with_tempo 900
play_pattern [60,61,62,63,64,65,66,67,68,69,70,71],"attack",0.2
play_pattern [60,61,62,63,64,65,66,67,68,69,70,71].reverse,"attack",0.2
end
3.times do
play_pattern [60,61,62,63,64,65,66,67,68,69,70,71].shuffle,"attack",0.2
end
n=60
20.times do
play n
sleep 0.2
n = n + 2
end
play_synth "fm","note",155,"divisor",15,"release",5
sleep 2
end
#Strawberry Fields Forever (Beatles) coded for sonic-pi by Robin Newman 7th Oct 2013
#music source from http://paperbagmusic.com/media/Beatles_all_songs.pdf page 160
#uses in_thread for left hand played simultaneously with the RH tune
#the thread is split so that it can be resynchronised with the tune in the middle of each section
#to play chords that link, use an attack a bit less than the required duration, and start the chord
#then sleep for the required duration of the chord. A bit of a bodge but seems to work reasonably well
# eg play_chord [n1,n2,n3],"attack",0.8 followed by sleep 1 gives choard effective duration 1
# nn.times do...end used for repeats
#verse section repeated twice. Verse three has different timings to fit the words
2.times do
#left hand thread first 9 bars
in_thread do
with_synth "saw_beep"
play_chord [43,55,59,62],"attack",1.5
sleep 2
play_chord [43,50,43,59],"attack",1.5
sleep 2
play_pattern_timed [43],[0.5],"attack",0.5
play_chord [43,50,57,60],"attack",0.2
sleep 0.5
play_chord [43,50,57,60],"attack",0.8
sleep 1.5
play_pattern_timed [50,53,57],[0.5],"attack",0.5
play_chord [40,50,56,59],"attack",1.8
sleep 2
play_pattern_timed [40,47,53,56],[0.5],"attack",0.5
play_chord [36,52,55],"attack",0.8
sleep 1
play_chord [40,52,59],"attack",0.8
sleep 1
play_pattern_timed [56,57],[0.25],"attack",0.25
play_pattern_timed [59],[0.5],"attack",0.5
play_chord [36,48,55],"attack",0.8
sleep 1
play_chord [43,55,59],"attack",1.3
sleep 1.5
end
#main tune follows first 9 bars
with_synth "saw_beep"
play_pattern_timed [0,0,71,71],[0.25],"attack",0.25
play_pattern_timed [72,71,67],[0.5],"attack",0.5
play_pattern_timed [62,64,69],[0.25],"attack",0.25
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [65],[1],"attack",1
play_pattern_timed [65,67,69],[0.333],"attack",0.333
play_pattern_timed [62,0,0],[1],"attack",1
play_pattern_timed [65,67,68],[0.333],"attack",0.333
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [0,0],[0.5,0.25]
play_pattern_timed [62,74,72,71,69,68,69],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [0],[1]
play_pattern_timed [71,67,64,71,67,64],[0.167],"attack",0.167
play_pattern_timed [69],[0.25],"attack",0.25
play_pattern_timed [67],[1.25],"attack",1.25
play_pattern_timed [0],[0.5]
#bar 10 onwards left hand thread (thread synced here)
in_thread do
with_synth "saw_beep"
play_chord [38,54,57,62],"attack",0.8
sleep 1
play_chord [38,54,57,61],"attack",0.8
sleep 1
play_chord [45,50,54,60],"attack",0.8
sleep 1
play_chord [48,52,55],"attack",0.4
sleep 0.5
play_chord [48,51,54],"attack",0.4
sleep 0.5
play_chord [40,52,55,59],"attack",0.8
sleep 1
play_chord [38,50,52,55,59],"attack",0.8
sleep 1
play_pattern_timed [52,55,52,50],[0.5],"attack",0.5
play_chord [36,48,52],"attack",0.8
sleep 1
play_chord [38,50,60],"attack",0.8
sleep 1
play_chord [43,55,59],"attack",0.8
sleep 1
play_chord [40,52,55,59],"attack",0.4
sleep 0.5
play_chord [38.50],"attack",0.4
sleep 0.5
play_chord [36,48,52],"attack",0.8
sleep 1
play_chord [38,50,57],"attack",0.8
sleep 1
play_chord [36,52,60],"attack",0.4
sleep 0.5
play_chord [36,55],"attack",0.4
sleep 0.5
play_chord [43,50,59],"attack",0.8
sleep 1
end
#rh tune from bar 11
play_pattern_timed [69,69,69,69,69,69],[0.333],"attack",0.333
play_pattern_timed [69],[0.5],"attack",0.5
play_pattern_timed [69],[1.5],"attack",1.5
play_pattern_timed [0,67,67,67,71,69,67,66,69],[0.25],"attack",0.25
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [0,0],[1,0.25]
play_pattern_timed [67,67,67,66,64,62,71,67],[0.25],"attack",0.25
play_pattern_timed [67,67,67,69,67,66],[0.125],"attack",0.125
play_pattern_timed [64],[0.5],"attack",0.5
play_pattern_timed [0,0],[0.5,0.25]
play_pattern_timed [67,67,67,69,67,66,64],[0.25],"attack",0.25
play_pattern_timed [67],[2],"attack",2
end #reepat for verse 2 goes back here
#verse 3 slightly different timings in bars 10-12 to fit words so written out again
#left hand thread first 9 bars
in_thread do
with_synth "saw_beep"
play_chord [43,55,59,62],"attack",1.5
sleep 2
play_chord [43,50,43,59],"attack",1.5
sleep 2
play_pattern_timed [43],[0.5],"attack",0.5
play_chord [43,50,57,60],"attack",0.2
sleep 0.5
play_chord [43,50,57,60],"attack",0.8
sleep 1.5
play_pattern_timed [50,53,57],[0.5],"attack",0.5
play_chord [40,50,56,59],"attack",1.8
sleep 2
play_pattern_timed [40,47,53,56],[0.5],"attack",0.5
play_chord [36,52,55],"attack",0.8
sleep 1
play_chord [40,52,59],"attack",0.8
sleep 1
play_pattern_timed [56,57],[0.25],"attack",0.25
play_pattern_timed [59],[0.5],"attack",0.5
play_chord [36,48,55],"attack",0.8
sleep 1
play_chord [43,55,59],"attack",1.3
sleep 1.5
end
#main tune follows first 9 bars
with_synth "saw_beep"
play_pattern_timed [0,0,71,71],[0.25],"attack",0.25
play_pattern_timed [72,71,67],[0.5],"attack",0.5
play_pattern_timed [62,64,69],[0.25],"attack",0.25
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [65],[1],"attack",1
play_pattern_timed [65,67,69],[0.333],"attack",0.333
play_pattern_timed [62,0,0],[1],"attack",1
play_pattern_timed [65,67,68],[0.333],"attack",0.333
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [0,0],[0.5,0.25]
play_pattern_timed [62,74,72,71,69,68,69],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [0],[1]
play_pattern_timed [71,67,64,71,67,64],[0.167],"attack",0.167
play_pattern_timed [69],[0.25],"attack",0.25
play_pattern_timed [67],[1.25],"attack",1.25
play_pattern_timed [0],[0.5]
#bar 10 onwards left hand thread (thread synced here)
in_thread do
with_synth "saw_beep"
play_chord [38,54,57,62],"attack",0.8
sleep 1
play_chord [38,54,57,61],"attack",0.8
sleep 1
play_chord [45,50,54,60],"attack",0.8
sleep 1
play_chord [48,52,55],"attack",0.4
sleep 0.5
play_chord [48,51,54],"attack",0.4
sleep 0.5
play_chord [40,52,55,59],"attack",0.8
sleep 1
play_chord [38,50,52,55,59],"attack",0.8
sleep 1
play_pattern_timed [52,55,52,50],[0.5],"attack",0.5
play_chord [36,48,52],"attack",0.8
sleep 1
play_chord [38,50,60],"attack",0.8
sleep 1
play_chord [43,55,59],"attack",0.8
sleep 1
play_chord [40,52,55,59],"attack",0.4
sleep 0.5
play_chord [38.50],"attack",0.4
sleep 0.5
play_chord [36,48,52],"attack",0.8
sleep 1
play_chord [38,50,57],"attack",0.8
sleep 1
play_chord [36,52,60],"attack",0.4
sleep 0.5
play_chord [36,55],"attack",0.4
sleep 0.5
play_chord [43,50,59],"attack",0.8
sleep 1
end
#rh tune bar 10 onwards (timimg changed bars 10-12 to fit words
play_pattern_timed [69,69,69,69],[0.5],"attack",0.5 #bar 10 changed timing
play_pattern_timed [69,69],[0.5],"attack",0.5
play_pattern_timed [69,69],[0.25],"attack",0.25
play_pattern_timed [69],[1],"attack",1
play_pattern_timed [67,67,67,67,71,69,67,66,69],[0.25],"attack",0.25 #bar 12 changed notes
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [0,0],[1,0.25]
play_pattern_timed [67,67,67,66,64,62,71,67],[0.25],"attack",0.25
play_pattern_timed [67,67,67,69,67,66],[0.125],"attack",0.125
play_pattern_timed [64],[0.5],"attack",0.5
play_pattern_timed [0,0],[0.5,0.25]
play_pattern_timed [67,67,67,69,67,66,64],[0.25],"attack",0.25
play_pattern_timed [67],[2],"attack",2
#coda section
#left hand thread 1st nine bars same as in verse 1
in_thread do
with_synth "saw_beep"
play_chord [43,55,59,62],"attack",1.5
sleep 2
play_chord [43,50,43,59],"attack",1.5
sleep 2
play_pattern_timed [43],[0.5],"attack",0.5
play_chord [43,50,57,60],"attack",0.2
sleep 0.5
play_chord [43,50,57,60],"attack",0.8
sleep 1.5
play_pattern_timed [50,53,57],[0.5],"attack",0.5
play_chord [40,50,56,59],"attack",1.8
sleep 2
play_pattern_timed [40,47,53,56],[0.5],"attack",0.5
play_chord [36,52,55],"attack",0.8
sleep 1
play_chord [40,52,59],"attack",0.8
sleep 1
play_pattern_timed [56,57],[0.25],"attack",0.25
play_pattern_timed [59],[0.5],"attack",0.5
play_chord [36,48,55],"attack",0.8
sleep 1
play_chord [43,55,59],"attack",0.8
sleep 1
play_chord [40,52,55,59],"attack",0.8
sleep 1
end
#coda section rh tune
#first 9 bars same as in verse 1
with_synth "saw_beep"
play_pattern_timed [0,0,71,71],[0.25],"attack",0.25
play_pattern_timed [72,71,67],[0.5],"attack",0.5
play_pattern_timed [62,64,69],[0.25],"attack",0.25
play_pattern_timed [67],[0.75],"attack",0.75
play_pattern_timed [65],[1],"attack",1
play_pattern_timed [65,67,69],[0.333],"attack",0.333
play_pattern_timed [62,0,0],[1],"attack",1
play_pattern_timed [65,67,68],[0.333],"attack",0.333
play_pattern_timed [62],[1],"attack",1
play_pattern_timed [0,0],[0.5,0.25]
play_pattern_timed [62,74,72,71,69,68,69],[0.25],"attack",0.25
play_pattern_timed [71],[0.5],"attack",0.5
play_pattern_timed [0],[1]
play_pattern_timed [71,67,64,71,67,64],[0.167],"attack",0.167
play_pattern_timed [69],[0.25],"attack",0.25
play_pattern_timed [67],[1.25],"attack",1.25
play_pattern_timed [0],[0.5]
#lh thread last 5 bars time signature changes but beat kept constant length
in_thread do
with_synth "saw_beep"
play_chord [36,48,55],"attack",1.3
sleep 1.5
play_chord [43,55,59],"attack",1.3
sleep 1.5
play_chord [36,48,55],"attack",0.7
sleep 0.75
play_chord [38,50,54,60],"attack",0.7
sleep 0.75
play_chord [36,48,52,55],"attack",0.8
sleep 1
play_chord [36,48,52,55],"attack",0.4
sleep 0.5
play_chord [36,48,52,55],"attack",0.4
sleep 0.5
play_chord [43,50,55,59],"attack",2
sleep 2.5
end
#rh tune bar last 5 bars
play_pattern_timed [71,67,64,71,67,64,69],[0.25],"attack",0.25
play_pattern_timed [67],[1.25],"attack",1.25
play_pattern_timed [71,67,64,74,72,62,64],[0.25],"attack",0.25
play_pattern_timed [67],[1.75],"attack",1.75
play_chord [67,71,74],"attack",2
sleep 2.5
#end of piece
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment