Skip to content

Instantly share code, notes, and snippets.

@rbnpi rbnpi/BumbleBeePart1.rb
Last active Jun 17, 2017

Embed
What would you like to do?
Flight of the Bumble Bee for Sonic Pi: Read Instructions at the end
#Flight of the Bumble Bee (part 1) coded by Robin Newman Jan 2015
#needs part 2 in a separate workspace. Start part 2 FIRST, THEN switch ws and run this part
#they sync together with cue/sync b2
#adjust sample path and change line 15 for RPi or Mac/PC
use_sample_pack '/home/pi/samples/BumbleBee' #RPi adjust if necessary
#use_sample_pack 'Users/rbn/Desktop/samples/BumbleBee' #Mac adjust if necessary
#use_sample_pack 'c://samples/BumbleBee' #PC adjust if necessary
set_sched_ahead_time! 2
rt=2**(1.0/12) #semitone rate multiplier
irt=1.0/rt #inverse of above to go down semitone
sh=-7 #transpose shift
s = 1.0 / 20 #speed scale factor
loadflag=0 #used to allow sample load time
dtime=18 #for RPi. Change to 5 for Mac or PC
ps="xylophone_"
define :sname do |sn,n| #generates sample name as a symbol
return (sn+n).intern
end
#built sample note array for xylophone
sam = [[:g2,sname(ps,"g2"),1],[:gs2,sname(ps,"g2"),rt]]
sam.concat [[:a2,sname(ps,"as2"),irt],[:as2,sname(ps,"as2"),1],[:b2,sname(ps,"as2"),rt]]
sam.concat [[:c3,sname(ps,"cs3"),irt],[:cs3,sname(ps,"cs3"),1],[:d3,sname(ps,"cs3"),rt]]
sam.concat [[:ds3,sname(ps,"e3"),irt],[:e3,sname(ps,"e3"),1],[:f3,sname(ps,"e3"),rt]]
sam.concat [[:fs3,sname(ps,"g3"),irt],[:g3,sname(ps,"g3"),1],[:gs3,sname(ps,"g3"),rt]]
sam.concat [[:a3,sname(ps,"as3"),irt],[:as3,sname(ps,"as3"),1],[:b3,sname(ps,"as3"),rt]]
sam.concat [[:c4,sname(ps,"cs4"),irt],[:cs4,sname(ps,"cs4"),1],[:d4,sname(ps,"cs4"),rt]]
sam.concat [[:ds4,sname(ps,"e4"),irt],[:e4,sname(ps,"e4"),1],[:f4,sname(ps,"e4"),rt]]
sam.concat [[:fs4,sname(ps,"g4"),irt],[:g4,sname(ps,"g4"),1],[:gs4,sname(ps,"g4"),rt]]
sam.concat [[:a4,sname(ps,"as4"),irt],[:as4,sname(ps,"as4"),1],[:b4,sname(ps,"as4"),rt]]
sam.concat [[:c5,sname(ps,"cs5"),irt],[:cs5,sname(ps,"cs5"),1],[:d5,sname(ps,"cs5"),rt]]
sam.concat [[:ds5,sname(ps,"e5"),irt],[:e5,sname(ps,"e5"),1],[:f5,sname(ps,"e5"),rt]]
sam.concat [[:fs5,sname(ps,"g5"),irt],[:g5,sname(ps,"g5"),1],[:gs5,sname(ps,"g5"),rt]]
sam.concat [[:a5,sname(ps,"as5"),irt],[:as5,sname(ps,"as5"),1],[:b5,sname(ps,"as5"),rt]]
sam.concat [[:c6,sname(ps,"cs5"),irt*2],[:cs6,sname(ps,"cs5"),2],[:d6,sname(ps,"cs5"),rt*2]]
sam.concat [[:ds6,sname(ps,"e5"),irt*2],[:e6,sname(ps,"e5"),2],[:f6,sname(ps,"e5"),rt*2]]
sam.concat [[:fs6,sname(ps,"g5"),irt*2],[:g6,sname(ps,"g5"),2],[:gs6,sname(ps,"g5"),rt*2]]
sam.concat [[:a6,sname(ps,"as5"),irt*2],[:as6,sname(ps,"as5"),2],[:b6,sname(ps,"as5"),rt*2]]
sam.each do |s| #load the samples
load_sample s[1]
end
#add aliases for flats and es,bs
flat=[:ab2,:bb2,:cb2,:db3,:eb3,:fb3,:gb3,:ab3,:bb3,:cb3,:db4,:eb4,:fb4,:gb4,:ab4,:bb4,:cb4,:db5,:eb5,:fb5,:gb5,:ab5,:bb5,:cb5,:db6,:eb6,:fb6,:gb6,:ab6,:bb6,:cb6,]
sharp=[:gs2,:as2,:b2,:cs3,:ds3,:e3,:fs3,:gs3,:as3,:b3,:cs4,:ds4,:e4,:fs4,:gs4,:as4,:b4,:cs5,:ds5,:e5,:fs5,:gs5,:as5,:b5,:cs6,:ds6,:e6,:fs6,:gs6,:as6,:b6]
#add es and bs with aliases
flat.concat [:es3,:es4,:es5,:es6,:bs2,:bs3,:bs4,:bs5]
sharp.concat [:f3,:f4,:f5,:f6,:c3,:c4,:c5,:c6]
extra=[]
flat.zip(sharp).each do |f,s|
extra.concat [[f,(sam.assoc(s)[1]),(sam.assoc(s)[2])]]
end
sam = sam + extra
# now repeat to build piano sample note array
ps="piano_f_"
samp = [[:c1,sname(ps,"c1"),1],[:cs1,sname(ps,"c1"),rt]]
samp.concat [[:d1,sname(ps,"ds1"),irt],[:ds1,sname(ps,"ds1"),1],[:e1,sname(ps,"ds1"),rt]]
samp.concat [[:f1,sname(ps,"fs1"),irt],[:fs1,sname(ps,"fs1"),1],[:g1,sname(ps,"fs1"),rt]]
samp.concat [[:gs1,sname(ps,"a1"),irt],[:a1,sname(ps,"a1"),1],[:as1,sname(ps,"a1"),rt]]
samp.concat [[:b1,sname(ps,"c2"),irt],[:c2,sname(ps,"c2"),1],[:cs2,sname(ps,"c2"),rt]]
samp.concat [[:d2,sname(ps,"ds2"),irt],[:ds2,sname(ps,"ds2"),1],[:e2,sname(ps,"ds2"),rt]]
samp.concat [[:f2,sname(ps,"fs2"),irt],[:fs2,sname(ps,"fs2"),1],[:g2,sname(ps,"fs2"),rt]]
samp.concat [[:gs2,sname(ps,"a2"),irt],[:a2,sname(ps,"a2"),1],[:as2,sname(ps,"a2"),rt]]
samp.concat [[:b2,sname(ps,"c3"),irt],[:c3,sname(ps,"c3"),1],[:cs3,sname(ps,"c3"),rt]]
samp.concat [[:d3,sname(ps,"ds3"),irt],[:ds3,sname(ps,"ds3"),1],[:e3,sname(ps,"ds3"),rt]]
samp.concat [[:f3,sname(ps,"fs3"),irt],[:fs3,sname(ps,"fs3"),1],[:g3,sname(ps,"fs3"),rt]]
samp.concat [[:gs3,sname(ps,"a3"),irt],[:a3,sname(ps,"a3"),1],[:as3,sname(ps,"a3"),rt]]
samp.concat [[:b3,sname(ps,"c4"),irt],[:c4,sname(ps,"c4"),1],[:cs4,sname(ps,"c4"),rt]]
samp.concat [[:d4,sname(ps,"ds4"),irt],[:ds4,sname(ps,"ds4"),1],[:e4,sname(ps,"ds4"),rt]]
samp.concat [[:f4,sname(ps,"fs4"),irt],[:fs4,sname(ps,"fs4"),1],[:g4,sname(ps,"fs4"),rt]]
samp.concat [[:gs4,sname(ps,"a4"),irt],[:a4,sname(ps,"a4"),1],[:as4,sname(ps,"a4"),rt]]
samp.concat [[:b4,sname(ps,"c5"),irt],[:c5,sname(ps,"c5"),1],[:cs5,sname(ps,"c5"),rt]]
samp.concat [[:d5,sname(ps,"ds5"),irt],[:ds5,sname(ps,"ds5"),1],[:e5,sname(ps,"ds5"),rt]]
samp.concat [[:f5,sname(ps,"fs5"),irt],[:fs5,sname(ps,"fs5"),1],[:g5,sname(ps,"fs5"),rt]]
samp.concat [[:gs5,sname(ps,"a5"),irt],[:a5,sname(ps,"a5"),1],[:as5,sname(ps,"a5"),rt]]
samp.concat [[:b5,sname(ps,"c6"),irt],[:c6,sname(ps,"c6"),1],[:cs6,sname(ps,"c6"),rt]]
samp.concat [[:d6,sname(ps,"ds6"),irt],[:ds6,sname(ps,"ds6"),1],[:e6,sname(ps,"ds6"),rt]]
samp.concat [[:f6,sname(ps,"fs6"),irt],[:fs6,sname(ps,"fs6"),1],[:g6,sname(ps,"fs6"),rt]]
samp.concat [[:gs6,sname(ps,"a6"),irt],[:a6,sname(ps,"a6"),1],[:as6,sname(ps,"a6"),rt]]
samp.concat [[:b6,sname(ps,"c7"),irt],[:c7,sname(ps,"c7"),1],[:cs7,sname(ps,"c7"),rt]]
samp.concat [[:d7,sname(ps,"ds7"),irt],[:ds7,sname(ps,"ds7"),1],[:e7,sname(ps,"ds7"),rt]]
samp.concat [[:f7,sname(ps,"fs7"),irt],[:fs7,sname(ps,"fs7"),1],[:g7,sname(ps,"fs7"),rt]]
samp.concat [[:gs7,sname(ps,"a7"),irt],[:a7,sname(ps,"a7"),1],[:as7,sname(ps,"a7"),rt]]
samp.concat [[:b7,sname(ps,"c8"),irt],[:c8,sname(ps,"c8"),1]]
if sample_loaded? :piano_f_c8 then #comment out this and next 2 lines in Windows ver 2.1.1
loadflag=1 #comment out for Windows 2.1.1
end #comment out for windows 2.1.1
samp.each do |s| #load the samples
load_sample s[1]
end
#puts "flag "+ loadflag.to_s #uncomment for test purposes
if loadflag==0 then #allow samples to load completely
sleep dtime
end
#add aliases for flats and es,bs
flatp=[:db1,:eb1,:fb1,:gb1,:ab1,:bb1,:cb2,:db2,:eb2,:fb2,:gb2,:ab2,:bb2,:cb3,:db3,:eb3,:fb3,:gb3,:ab3,:bb3,:cb3,:db4,:eb4,:fb4,:gb4,:ab4,:bb4,:cb4,:db5,:eb5,:fb5,:gb5,:ab5,:bb5,:cb5,:db6,:eb6,:fb6,:gb6,:ab6,:bb6,:cb7,:db7,:eb7,:fb7,:gb7,:ab7,:bb7,:cb8]
sharpp=[:cs1,:ds1,:e1,:fs1,:gs1,:as1,:b1,:cs2,:ds2,:e2,:fs2,:gs2,:as2,:b2,:cs3,:ds3,:e3,:fs3,:gs3,:as3,:b3,:cs4,:ds4,:e4,:fs4,:gs4,:as4,:b4,:cs5,:ds5,:e5,:fs5,:gs5,:as5,:b5,:cs6,:ds6,:e6,:fs6,:gs6,:as6,:b6,:cs7,:ds7,:e7,:fs7,:gs7,:as7,:b7]
#add es and bs with aliases
flatp.concat [:es1,:es2,:es3,:es4,:es5,:es6,:es7,:bs1,:bs2,:bs3,:bs4,:bs5,:bs6,:bs7]
sharpp.concat [:f1,:f2,:f3,:f4,:f5,:f6,:f7,:c2,:c3,:c4,:c5,:c6,:c7,:c8]
extrap=[]
flatp.zip(sharpp).each do |f,s|
extrap.concat [[f,(samp.assoc(s)[1]),(samp.assoc(s)[2])]]
end
samp = samp + extrap #add in flat definitions
#define functions to play piano and xylophone notes
define :plp do |n,d=0.2,pan=0,v=0.8| #piano
sample (samp.assoc(n)[1]),rate: (samp.assoc(n)[2]),attack: 0,sustain: d*0.95,release: d,amp: v,pan: pan
end
define :pl do |n,d=0.2,pan=0,v=0.8|#xylophone
sample (sam.assoc(n)[1]),rate: (sam.assoc(n)[2]),attack: 0,sustain: d*0.95,release: d*0.05,amp: v,pan: pan
end
define :ntosym do |n| #converts note number to sympbol
@note=n % 12
@octave = n / 12 - 1
lookup_notes = {
0 => :c,
1 => :cs,
2 => :d,
3 => :ds,
4 => :e,
5 => :f,
6 => :fs,
7 => :g,
8 => :gs,
9 => :a,
10 => :as,
11 => :b}
return (lookup_notes[@note].to_s + @octave.to_s).to_sym
end
define :tr do |nv,sh| #transposes note by sh
return ntosym(note(nv)+sh)
end
dsq = 1 * s #define note duration values scaled by s
sq = 2 * s
sqd = 3 * s
q = 4 * s
qt = 2.0/3*q
qd = 6 * s
qdd = 7 * s
c = 8 * s
cd = 12 * s
cdd = 14 * s
m = 16 * s
md = 24 * s
mdd = 28 * s
b = 32 * s
bd = 48 * s
define :plarray do |nt,dur,sh=0,vol=0.6,pan=0| #play note/duration array for xylophone
nt.zip(dur).each do |n,d|
if n != :r then
pl(tr(n,sh),d,pan,vol)
end
sleep d
end
end
define :plarrayp do |nt,dur,sh=0,vol=0.6,pan=0| #play note/duration array for piano
nt.zip(dur).each do |n,d|
if n != :r then
plp(tr(n,sh),d,pan,vol)
end
sleep d
end
end
define :ch do |n1,n2,n3| #play a piano chord (all quaver length)
plp(tr(n1,sh),q,0,0.3)
plp(tr(n2,sh),q,0,0.3)
plp(tr(n3,sh),q,0,0.3)
sleep q
end
define :chp do |ca,da| #play array of piano chords ca (each 3 notes) with corresponding "gaps" array da
ca.zip(da).each do |cl,dv|
ch(cl[0],cl[1],cl[2])
sleep dv
end
end
cue :b2 #cue second half of program
#Flight of The Bumble Bee (part 2) coded by Robin Newman Jan 2015
#needs part one in a separate workspace. Start THIS part running THEN switch ws and start part 1
#They sync together
sync :b2
use_sample_pack '/home/pi/samples/BumbleBee' #RPi
#use_sample_pack 'Users/rbn/Desktop/samples/BumbleBee' #Mac
#use_sample_pack 'c://samples/BumbleBee' #PC
#duplicate variable assignments from part 1 for use in part 2
rt=2**(1.0/12)
irt=1.0/rt
sh=-7
s = 1.0 / 20
dsq = 1 * s
sq = 2 * s
sqd = 3 * s
q = 4 * s
qt = 2.0/3*q
qd = 6 * s
qdd = 7 * s
c = 8 * s
cd = 12 * s
cdd = 14 * s
m = 16 * s
md = 24 * s
mdd = 28 * s
b = 32 * s
bd = 48 * s
#start defining note and duration arrays
#xylophone part
nt = [:e6,:ds6,:d6,:cs6,:d6,:cs6,:c6,:b5,:c6,:b5,:bb5,:a5,:gs5,:g5,:fs5,:f5,:e5,:ds5,:d5,:cs5,:d5,:cs5,:c5,:b4]
#b4
nt.concat [:c5,:b4,:bb4,:a4,:gs4,:g4,:fs4,:f4,:e4,:ds4,:d4,:cs4,:d4,:cs4,:c4,:b3,:e4,:ds4,:d4,:cs4,:d4,:cs4,:c4,:b3]
nt.concat [:e4,:ds4,:d4,:cs4,:c4,:f4,:e4,:ds4,:e4,:ds4,:d4,:cs4,:c4,:cs4,:d4,:ds4,:e4,:ds4,:d4,:cs4,:c4,:f4,:e4,:ds4]
#b10
nt.concat [:e4,:ds4,:d4,:cs4,:c4,:cs4,:d4,:ds4,:e4,:ds4,:d4,:cs4,:d4,:cs4,:c4,:b3,:c4,:cs4,:d4,:ds4,:e4,:f4,:e4,:ds4]
nt.concat [:e4,:ds4,:d4,:cs4,:d4,:cs4,:c4,:b3,:c4,:cs4,:d4,:ds4,:e4,:fs4,:g4,:gs4,:a4,:gs4,:g4,:fs4,:f4,:bb4,:a4,:gs4]
#b16
nt.concat [:a4,:gs4,:g4,:fs4,:f4,:fs4,:g4,:gs4,:a4,:gs4,:g4,:fs4,:f4,:bb4,:a4,:gs4,:a4,:gs4,:g4,:fs4,:f4,:fs4,:g4,:gs4]
nt.concat [:a4,:gs4,:g4,:fs4,:g4,:fs4,:f4,:e4,:f4,:fs4,:g4,:gs4,:a4,:bb4,:a4,:gs4,:a4,:gs4,:g4,:fs4,:g4,:fs4,:f4,:e4,:f4,:fs4,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4,:c5,:cs5]
du.concat [sq]*8*20 + [q,sq,sq,sq,sq,sq,sq]
#b81
nt.concat [:d5,:cs5,:c5,:b4,:c5,:b4,:bb4,:a4,:gs4,:a4,:as4,:b4,:c5,:cs5,:d5,:ds5,:e5,:f5,:e5,:ds5,:e5,:f5,:e5,:ds5]
#b84
nt.concat [:e5,:gs4,:a4,:bb4,:b4,:c5,:cs5,:d5,:cs5,:c5,:b4,:c5,:b4,:bb4,:a4,:gs4,:a4,:as4,:b4,:c5,:cs5,:d5,:ds5]
#b87
nt.concat [:e5,:fs5,:gs5,:a5,:b5,:c6,:d6,:ds6,:e6,:f6,:e6,:ds6,:e6,:fs6,:g6,:gs6,:a6,:gs6,:g6,:fs6,:g6,:fs6,:f6,:e6]
#b90
nt.concat [:f6,:e6,:ds6,:d6,:cs6,:c6,:b5,:bb5,:a5,:gs5,:g5,:fs5,:g5,:fs5,:f5,:e5,:f5,:e5,:ds5,:d5,:cs5,:c5,:b4,:bb4]
#b93
nt.concat [:a4,:bb4,:a4,:gs4,:a4,:bb4,:a4,:gs4,:a4,:bb4,:a4,:gs4,:a4,:b4,:c5,:d5,:e5,:f5,:e5,:ds5,:e5,:f5,:e5,:ds5]
#b96
nt.concat [:e5,:f5,:e5,:ds5,:e5,:fs5,:g5,:gs5,:a5,:r,:e4,:f4,:fs4,:g4,:gs4,:a4,:b4,:bs4,:c5,:cs5,:d5,:ds5]
#b99
nt.concat [:e5,:f5,:fs5,:g5,:gs5,:a5,:bb5,:b5,:c6,:cs6,:d6,:ds6,:e6,:fs6,:g6,:gs6,:a6,:r,:a5,:r,:a4,:r]
du.concat [sq]*8*3+[q,sq,sq,sq,sq,sq,sq]+[sq]*8*12+[q,q,sq,sq,sq,sq]+[sq]*8*3+[sq,sq+q+c,c,c,c,c]
#piano part chord array lists
#first section of chords
chlist=[[:e3,:gs5,:b5],[:e2,:d4,:b],[:a2,:e3,:c4],[:a2,:e3,:c4],[:d3,:fs3,:a3],[:a2,:e3,:c4]]
chlist.concat [[:a2,:e3,:c4],[:d3,:fs3,:a3],[:a2,:e3,:c4],[:f3,:a3,:d4],[:e3,:a3,:c4],[:d3,:gs3,:b3]]
chlist.concat [[:c3,:e3,:a3],[:f3,:a3,:d4],[:e3,:a3,:c4],[:d3,:gs3,:b3],[:cs3,:g3,:a3],[:d3,:f3,:a3]]
chlist.concat [[:f3,:a3,:d4],[:d3,:g3,:b3],[:d3,:a3,:d4],[:f3,:a3,:d3],[:d3,:g3,:b3]]
chlist.concat [[:f3,:a3,:d4],[:g3,:bb3,:d4],[:f3,:a3,:d3],[:e3,:g3,:cs4],[:d3,:f3,:d4],[:d3,:g3,:bb3]]
chlist.concat [[:d3,:f3,:a3],[:cs3,:e3,:g3]]
chdur=[q+c+m,q+c+3*m,q+c,q,q,q+c]+[q]*14+[q+c]+[q]*10
#bass note part
bn=[:d3,:r,:d3,:r,:f3,:fs3,:r,:bb3]
bd=[q,q+c+m,c,c+3*m,2*m,q,q+c+5*m,2*m]
#second section of chords
ch2list=[[:g3,:bb3,:d4],[:bb2,:d4,:g4],[:c3,:eb4,:g4],[:bb2,:d4,:g4],[:fs2,:c4,:eb4],[:g2,:bb3,:d4],[:f2,:a3,:d4],[:e2,:gs3,:d4]]
ch2dur=[q+c,q,q,q,q,q,q,q]
#second bass note part
bn2=[:e4,:e4,:e4,:r,:e4,:c4,:a3,:f3,:a3,:c4,:e4,:r,:e4,:c4,:a3,:f3,:a3,:c4,:e4,:r,:e5,:c5,:a4,:f4,:a4,:c5,:e5,:r]
bn2.concat [:e5,:c5,:a4,:f4,:a4,:c5,:e5,:r,:e4,:e4] #end b59
bd2=[c,m]+[q]*17+[q+c+2*m+c]+[q]*14+[m,m*2,c,c]
#third chord section lists
ch3list=[[:a3,:c4,:a4],[:a3,:c4,:a4],[:fs2,:d4,:a4],[:a3,:c4,:a4],[:a3,:c4,:a4],[:fs2,:d4,:a4],[:a3,:c4,:a4]]
#b64b
ch3list.concat [[:f3,:d4,:a4],[:e3,:c4,:a4],[:d3,:b3,:gs4],[:c3,:e4,:a4],[:f3,:d4,:a4],[:e3,:c4,:a4],[:d3,:b3,:fs4]]
#b68
ch3list.concat [[:cs3,:e4,:a4],[:d3,:f4,:a4],[:d3,:f4,:a4],[:b3,:d4,:g4],[:d3,:f4,:a4],[:d3,:f4,:a4],[:b3,:d4,:g4]]
ch3list.concat [[:d4,:f4,:a4],[:bb2,:d4,:g4],[:a3,:d4,:f4],[:g2,:cs4,:e4],[:f2,:d4,:a4],[:d3,:c4,:a4],[:c3,:e4,:a4],[:b2,:d4,:gs4]]
#b76
ch3list.concat [[:a2,:e4,:c5],[:c3,:e4,:c5],[:a2,:e4,:c5],[:fs2,:d4,:a4],[:a2,:e4,:c5],[:c3,:e4,:c5],[:a2,:e4,:c5],[:fs2,:d4,:a4]]#end b79
ch3list.concat [[:a2,:e4,:a4],[:f3,:a3,:d3],[:e3,:c4,:e4],[:e2,:gs3,:d4],[:a2,:e4,:a4],[:f3,:a3,:d4],[:e3,:c4,:a4],[:e3,:d4,:gs4],[:e3,:b3,:d3]]#end b88
ch3list.concat [[:a2,:c4,:e4],[:a2,:cs4,:g4],[:a2,:d4,:f4],[:a2,:e3,:c4],[:a2,:e3,:cs4],[:a2,:f3,:d4],[:a2,:e3,:c4]]#end b 93
ch3dur=[q+c,q,q,q+c]+[q]*14+[q+c]+[q]*10+[0,c,q,q,0,c,q,q] #end b79
ch3dur.concat [q+c]*9 #end 88
ch3dur.concat [q,q,q+c,q,q,q+c,q+c] #end b93
#from start then b80
nt4=[:r]+[:c5,:r,:a4,:f4,:d4,:b3,:d4,:f4,:a4,:r,:e4,:r,:c5,:r,:a4,:f4,:d4,:b3,:d4,:f4,:a4,:r] #then b 94 start
du4=[m*79]+[q]*8+[c,c,q,q+c]+[q]*8+[c,c+7*m] #next b94
nt4.concat [:r,:a4,:r,:e4,:r,:f4,:e4,:f4,:f5,:e5,:fs5,:gs5,:gs5,:a5,:r]#next b98
du4.concat [c]+[q]*4+[sq]*4+[q]*5+[q+c]
############ start playing here ##################
uncomment do #change to comment to remove piano chords and base notes part
in_thread do #piano part with chords and base note parts
chp(chlist,chdur)
plarrayp(bn,bd,sh,0.3)
chp(ch2list,ch2dur)
plarrayp(bn2,bd2,sh,0.3)
chp(ch3list,ch3dur)
end
end
uncomment do #change to comment to remove xylophone and piano 2-4
in_thread do #xylophone part
plarray(nt,du,sh,0.3)
end
in_thread do #piano second section
plarrayp(nt2,du2,sh,0.3)
end
in_thread do #piano third section
plarrayp(nt3,du3,sh,0.8)
end
plarrayp(nt4,du4,sh,0.3) #piano 4th section
end

Flight Of The Bumble Bee by Rimsky Korsakov

You need to download part 1 and part 2 files above to two separate workspaces.

You need to download the samples from http://r.newman.ch/rpi/BumbleBee.zip

The samples are sourced from Sonatina Symphonic Orchestra under CCL1 licence http://sso.mattiaswestlund.net/download.html

Unzip the folder and install it on your Raspberry Pi, Mac or PC in a suitable location

On a Mac I use a folder named samples on my Desktop to contain all other sample folders

This gives the location '/Users/rbn/Desktop/samples/BumbleBee' You can do something similar, substituting your user name for rbn (my initials)

On a Raspberry Pi using the standard Pi user, make a folder samples in the home directory and install there

This has a path '/home/pi/samples/BumbleBee'

On a PC you can install a folder samples at the root of your C drive

This gives a location 'C://samples/BumbleBee'

The samples location needs to be adjusted in BOTH parts of the program

NOTE at present the Windows version is 2.1.1 This does not support the use of the comamnd sample_loaded? in part 1

You can comment out the three lines indicated (83-85) and it will work OK

Version 2.3 due out shortly will work OK.

The first time the programs are run takes longer than subsequent runs, as a delay is built in while the samples load. 18 seconds on the RPi and 5 on the Ma cor PC.

When Running on a Mac, part 2 is close to the length limit. If it doesn't run try deleting some comments to give more room.

The score for this version is based on an arrangement by Bernard Dewagtere, which I have used with the author's permission.

http://www.free-scores.com/download-sheet-music.php?pdf=40094

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.