Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bach Gigue in G Minor sample based version for Sonic Pi 2.2 or later (needs part 1 and samples)
#BachGigueInGMinor (part 2) coded by Robin Newman, December 2014
#sample based version. (two parts synced together: staret this part first, then part 1)
sync :part2
use_sample_pack '/Users/rbn/Desktop/samples/GrandPiano/' #select and adjust as necessary
#use_sample_pack '/home/pi/samples/GrandPiano'
#select loud (f) or soft (p) piano samples
#ps="piano_f_"
ps="piano_p_"
s=0
define :setbpm do |n| #set bpm equivalent
s = (1.0 / 8) *(60.0/n.to_f)
end
setbpm(180)
dsq=sq=q=qd=c=cd=cdd=m=md=0
define :lset do
dsq = 1 * s #demi-semi-quaver
sq = 2 * s #semi-quaver
q = 4 * s #quaver
qd = 6 * s #quaver dotted
c = 8 * s #crotchet
cd = 12 * s #crotchet dotted
m = 16 * s #minim
md = 24 * s #minim dotted
end
lset
p=0.15
mp=0.2
mf=0.4
f=0.8
ff=1.6
define :ct do |ptr,lev,slid=0|
control ptr,amp: lev,amp_slide: slid
end
ritq=ritqb=d1=d2=d3=d1b=d2b=d3b=n1=n2=n3=n1b=n2b=n3b=[] #define global scope
define :parts do
ritq=[q*1.02,q*1.04,q*1.06,q*1.08,q*1.1,q*1.12]
ritqb=[q*1.02,q*1.04,q*1.06,q*1.08,q*1.1,q*1.2,q*1.4,q*1.6,q*1.8]
n1=[:d5,:eb5,:d5,:c5,:bb4,:a4,:g4,:fs4,:a4,:d4,:c4,:bb3,:a3,:bb3,:d4,:g4,:a3,:g4,:fs4,:g4,:bb4,:a4,:bb4,:d5,:c5]
d1=[q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q]
#3
n1.concat [:d5,:e5,:f5,:e5,:f5,:g5,:a5,:g5,:f5,:g5,:f5,:e5,:f5,:g5,:a5,:d5,:c5,:bb4,:c5,:d5,:bb4,:c5]
d1.concat [cd+q,q,q,cd+q,q,q,q,q,q,q,q,q,q,q,q,cd+q,q,q,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c3,:r,:d3,:r,:e3,:r,:fs3,:d2,:e2,:fs2,:g2,:r,:a2,:r,:bb2,:r,:c3,:r,:d3,:e3,:fs3,:g2,:a2,:bb2]
d3b.concat [c,q,c,q,c,q,c,q,c,q,c,q,c,q,c,q,c,q,c,q,q,q,q,q,q,q]
#42
n3b.concat [:c3,:d3,:eb3,:fs2,:g2,:a2,:bb2,:eb3,:a2,:d4,:eb4,:d4,:c4,:bb3,:a3,:g3,:fs3,:a3,:d3,:c3,:bb2,:a2,:bb2,:g3,:c3,:d3,:c3,:d3,:g2,:bb2,:d3,:g3]
d3b.concat [q,q,q,q,q,q,c,q,c,q]+[q]*12+ritqb+[c*1.2]
end
define :part1 do
with_fx :level do |x|
in_thread do
ct(x,mf,0)
sleep 13*q
ct(x,mp,6*q)
sleep 6*q
ct(x,mf,6*q)
sleep 30*q #5
ct(x,p,12*q)
sleep 12*q
ct(x,f,6*q)
sleep 3*12*q+3*q #4th 9
ct(x,p,15*q) #end at 11
sleep 15*q+2*q
ct(x,f,22*q) #end at 13
sleep 34*q #till 14
ct(x,ff,6*q)
sleep 6*q
ct(x,f,3*q)
sleep 3*q
ct(x,ff,6*q)
sleep 6*q
ct(x,f,3*q)
sleep 3*q
ct(x,ff,18*q)
sleep 18*q
ct(x,f,6*q)
sleep 6*q #end mid 17
ct(x,ff,9*q)
sleep 9*q
ct(x,f,8*q)
sleep 8*q
ct(x,ff,0) #last q of 18
sleep 25*q
end
in_thread do
plarray(n1,d1)
end
in_thread do
plarray(n2,d2)
end
plarray(n3,d3)
end
end
define :part2 do
with_fx :level do |x|
in_thread do
ct(x,mf,0)
sleep 25*q #end at start 23
ct(x,f,47*q) #end last q of 26
sleep 82*q #till last beat 22
ct(x,mf,21*q) #till 24 3rd beat
sleep 29*q #until 3rd q 25
ct(x,f,10) #till start 26
sleep 16*q
ct(x,p,18*q) #to last q 27
sleep 21*q
ct(x,f,9*q) #to start 29
sleep 18*q
ct(x,mf,9*q)
sleep 15*q
ct(x,f,12*q) #end 31
sleep 12*q
ct(x,mf,6)
sleep 9*q
ct(x,f,3*q)
sleep 3*q
ct(x,p,6*q)
sleep 10*q
ct(x,f,25*q)
sleep 32*q
ct(x,mf,17*q)
end
in_thread do
plarray(n1b,d1b)
end
in_thread do
plarray(n2b,d2b)
end
plarray(n3b,d3b)
end
end
parts
part1
part1
part2
setbpm(170)
lset
parts
part2
@rbnpi

This comment has been minimized.

Copy link
Owner Author

rbnpi commented Dec 28, 2014

This file is used with part 1 and a folder of GrandPiano samples. Part1 is in a separate gist file. The samples can be downloaded from my blog http://rbnrpi.wordpress.com Samples from Sonatina Symphonic Library under CCL1
https://rbnrpi.wordpress.com/2014/12/28/sonic-pi-2-2-plays-bach-gigue-in-g-minor-three-separate-versions/
A separate gist file contains a separate self contained version that plays on the :pulse synth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.