Skip to content

Instantly share code, notes, and snippets.

@rbnpi
Last active August 4, 2022 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbnpi/17b4eda401a5fb68c417 to your computer and use it in GitHub Desktop.
Save rbnpi/17b4eda401a5fb68c417 to your computer and use it in GitHub Desktop.
Sonic Pi plays 3 16th Century madrigals by Luca Marenzio, arranged for 5 trumpets. uses sample based voices, and features dynamic level variation. Requires SP 2.5 or later. Sample download at http://r.newman.ch/rpi/Marenzio.zip
# Luca Marenzio Madrigal 1553-1599 "Togli dolce ben mio" arranged for 5 trumpets coded for by Robin Newman, April 2015
#uses sample based voice, and also has variable dynamic settings for each part and final rit.
#requires version >=2.9
#Sample requires can be downloaded from http://r.newman.ch/rpi/Marenzio.zip
#This version altered for syntax changes. Wrosk with later versions of SP
use_debug false
path= '~/Desktop/samples/Marenzio/' #path to sample folder
#first deal with selecting and setting up the sample
inst0 = 0 #first (in fact only) sample in folder
samplepitch0=:cs5
#preload the sample
load_sample path,0
#define variable that needs to be used globally
s=0 #note duration scale factor: redefined in use_bpm function
#this function plays the sample at the relevant pitch for the note desired
#the note duration is used to set up the envelope parameters
define :pl do |inst,samplepitch,nv,dv,vol=1,pan=0|
shift=note(nv)-note(samplepitch)
sample path,inst,rate: (pitch_to_ratio shift),sustain: 0.8*dv,release: 0.2*dv,amp: vol,pan: pan
end
#this function plays an array of notes and associated array of durations
#also uses sample name (inst), sample normal pitch,sample start and shift (transpose) parameters
define :plarray do |inst,samplepitch,narray,darray,shift=0,vol=1,pan=0|
narray.zip(darray) do |nv,dv|
if nv != :r
pl(inst,samplepitch,note(nv)+shift,dv*s,vol,pan)
end
sleep dv*s
end
end
define :ct do |ptr,lev,slid=0,timetonext=0| #controls level
control ptr,amp: lev,amp_slide: slid
puts "level "+lev.to_s
sleep timetonext*s #scale for tempo
end
define :plct do |pt,am,amsl,amd| #performs level change for a part
am.zip(amsl,amd) do |amv,amslv,amdv|
ct(pt,amv,amslv,amdv)
end
end
#set_bpm sets bpm required adjusting note duration variables accordingly
define :set_bpm do |n|
s=1.0/8*60/n.to_f
end
#set relative note duration variables
dsq = 1.0 #must be float as divided later
sq = 2
sqd = 3
q = 4
qt = 2.0/3*q
qd = 6
qdd = 7
c = 8
cd = 12
cdd = 14
m = 16
md = 24
mdd = 28
b = 32
bd = 48
#dynamic settings
# p mp mf f ff
pp=0.02
p=0.08
mp=0.2
mf=0.6
f=1.0
ff=1.6
#set up the part lists
n1=[:e5,:fs5,:g5,:g5,:a5,:b5,:b5,:a5,:a5,:g5,:fs5,:fs5,:ds5,:e5,:fs5,:e5,:ds5,:e5,:ds5,:e5,:r,:g5,:a5,:b5,:a5,:g5,:fs5,:g5,:g5]
d1=[b,c,cd,q,c,m,m,c,q,q,m,c,m,c,md,c,c,m,c,b,m,m,c,cd,q,c,m,c,c]
#b12
n1.concat [:fs5,:e5,:fs5,:e5,:ds5,:e5,:fs5,:fs5,:fs5,:fs5,:r,:fs5,:g5,:fs5,:e5,:d5,:e5,:e5,:fs5,:e5,:d5,:cs5,:cs5,:fs5,:e5,:d5,:cs5]
d1.concat [cd,q,c,c,cd,q,c,c,b,b,b*5+m,m,md,c,c,c,b,m,c,q,q,c,c,c,q,q,m]
#b27
n1.concat [:b4,:r,:e5,:e5,:a4,:d5,:b4,:d5,:d5,:g5,:fs5,:e5,:d5,:d5,:g5,:fs5,:e5,:ds5,:e5,:r,:b4,:d5,:e5,:fs5,:e5,:fs5]
d1.concat [b,3*b+m,m,m,c,m,c,b,m,c,q,q,c,c,c,q,q,m,m,c,c,c,c,b,m,b]
#b41
n1.concat [:fs5,:b5,:a5,:g5,:fs5,:fs5,:b5,:a5,:g5,:fs5,:fs5,:b5,:a5,:g5,:fs5,:e5,:d5,:e5,:fs5,:fs5,:b5,:b5,:a5,:g5,:fs5,:e5,:d5,:b4,:e5,:ds5,:cs5,:ds5,:e5]
d1.concat [m,c,q,q,c,c,c,q,q,c,c,md,c,c,q,q,m,m,m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,:fs5,:b5,:a5,:g5,:fs5,:e5,:r,:g5,:a5,:g5,:fs5,:e5,:d5,:cs5,:b4,:cs5]
d4.concat [m,m,c,c,c,q,q,m,m,b,m,c,c,md,c,c,c,b,m,c,q,q,c,c,c,q,q,m,m,c,c,c,c,c,q,q,m,m,b]
#b41
n4.concat [:ds5,:r,:fs4,:fs4,:e4,:d4,:d4,:d5,:d5,:cs5,:b4,:d5,:r,:fs4,:d4,:e4,:fs4,:g4,:fs4,:gs4]
d4.concat [b,m,c,q,q,c,c,c,q,q,m,m,b+m,m,md,c,m,m, b*1.2, b*1.6]
#end
n5=[:r,:e4,:fs4,:g4,:fs4,:e4,:d4,:g3,:a3,:b3,:cs4,:d4,:r,:g4]
d5=[7*b+m,m,c,cd,q,c,m,q,q,q,q,m,c,c]
#b12
n5.concat [:d4,:cs4,:d4,:e4,:b3,:e4,:d4,:b3,:fs4,:b3,:r,:d5,:cs5,:b4,:as4,:as4,:d5,:cs5,:b4,:as4,:b4,:r,:fs4,:d4,:e4,:fs4]
d5.concat [cd,q,c,c,cd,q,c,c,b,b,b*3,c,q,q,c,c,c,q,q,m,b,3*b+md,cd,q,c,m]
#b27
n5.concat [:b3,:g3,:a3,:b3,:c4,:b3,:b4,:r,:b4,:c5,:b4,:a4,:g4,:a4,:a4,:r,:e4,:d4,:e4,:fs4,:g4,:fs4]
d5.concat [b,md,c,m,m,b,m,c,c,md,c,c,c,b,m,2*b+m,m,md,c,m,m,b]
#b41
n5.concat [:b3,:b3,:g3,:a3,:b3,:c4,:b3,:e4]
d5.concat [b,2*b,md,c,m,m,b*3+b*1.2,b*1.6]
#end
#parts dynamic data
a1=[f,mp,mf,f,ff] #levels
as1=[0,0,0,7*c,0]#slide times
ad1=[20*b+m,10*b,2*b,8*b,9*b+m] #sleep durations at level
a2=[f,p,mp,mf,ff]
as2=[0,3*c,0,0,0] #added 0
ad2=[14*b,6*b+m,6*b+c,14*b+c,9*b]
a3=[f,p,mf,f,ff]
as3=[0,3*c,0,7*c,0]
ad3=[14*b,12*b+m,6*b+m,7*b+m,9*b+m]
a4=[f,p,mp,mf,f,ff]
as4=[0,0,0,0,4*c,0]
ad4=[14*b+m,6*b,6*b,6*b+m,8*b+m,8*b+m]
a5=[f,p,mp,mf,f,ff]
as5=[0,4*b,0,0,3*b+m,0]
ad5=[14*b,10*b+3*c,2*b+c,6*b,8*b,9*b]
define :len do |d| #for checking durations of parts
ld=0
d.each do |d|
ld += d
end
return ld
end
define :perform do |x|
in_thread do
with_fx :level do |amp1| #set dynamic level
in_thread do
plct(amp1,a1,as1,ad1)
end
plarray(inst0,samplepitch0,n1,d1,-2,0.8,-0.7) #trumpet I
end
end
in_thread do
with_fx :level do |amp2|
in_thread do
plct(amp2,a2,as2,ad2)
end
plarray(inst0,samplepitch0,n2,d2,-2,0.8,0.7) #trumpet II
end
end
in_thread do
with_fx :level do |amp3|
in_thread do
plct(amp3,a3,as3,ad3)
end
plarray(inst0,samplepitch0,n3,d3,-2,0.8,-0.4) #trumpet III
end
end
in_thread do
with_fx :level do |amp4|
in_thread do
plct(amp4,a4,as4,ad4)
end
plarray(inst0,samplepitch0,n4,d4,-2,0.8,0.4) #trumpet IV
end
end
with_fx :level do |amp5|
in_thread do
plct(amp5,a5,as5,ad5)
end
plarray(inst0,samplepitch0,n5,d5,-2,0.8,0) #trumpet V
end
end
comment do #checks for debugging data input (uncomment)
puts len(d1)
puts len(d2)
puts len(d3)
puts len(d4)
puts len(d5)
puts n4.length
puts d4.length
puts len(ad1)
puts len(ad2)
puts len(ad3)
puts len(ad4)
puts len(ad5)
end
set_bpm(160) #set tempo
with_fx :reverb,room: 0.8,mix: 0.6 do #add some reverb
perform(1)
end
# Luca Marenzio Madrigal 1553-1599 "Crudele Acerba" arranged for 5 trumpets coded for by Robin Newman, April 2015
#uses sample based voice, and also has variable dynamic settings for each part and final rit.
#requires version 2.5 or later
#Sample requires can be downloaded from http://r.newman.ch/rpi/Marenzio.zip
use_debug false
path= '~/Desktop/samples/Marenzio' #path to sample folder adjust location as necessary
#first deal with selecting and setting up the sample
inst0=:trumpet_cs5
samplepitch0=:cs5
#preload the sample
load_sample path,inst0
#define variable that needs to be used globally
s=0 #note duration scale factor: redefined in use_bpm function
#this function plays the sample at the relevant pitch for the note desired
#the note duration is used to set up the envelope parameters
define :pl do |inst,samplepitch,nv,dv,vol=1,pan=0|
shift=note(nv)-note(samplepitch)
sample path,inst,rate: (pitch_to_ratio shift),sustain: 0.95*dv,release: 0.05*dv,amp: vol,pan: pan
end
#this function plays an array of notes and associated array of durations
#also uses sample name (inst), sample normal pitch,sample start and shift (transpose) parameters
define :plarray do |inst,samplepitch,narray,darray,shift=0,vol=1,pan=0|
narray.zip(darray) do |nv,dv|
if nv != :r
pl(inst,samplepitch,note(nv)+shift,dv*s,vol,pan)
end
sleep dv*s
end
end
define :ct do |ptr,lev,slid=0,timetonext=0| #controls level
control ptr,amp: lev,amp_slide: slid
puts "level "+lev.to_s
sleep timetonext*s #scale for tempo
end
define :plct do |pt,am,amsl,amd| #performs level change for a part
am.zip(amsl,amd) do |amv,amslv,amdv|
ct(pt,amv,amslv,amdv)
end
end
#set_bpm sets bpm required adjusting note duration variables accordingly
define :set_bpm do |n|
s=1.0/8*60/n.to_f
end
#set relative note duration variables
dsq = 1.0 #must be float as divided later
sq = 2
sqd = 3
q = 4
qt = 2.0/3*q
qd = 6
qdd = 7
c = 8
cd = 12
cdd = 14
m = 16
md = 24
mdd = 28
b = 32
bd = 48
#dynamic settings
# pp p mp mf f ff
pp=0.02
p=0.08
mp=0.2
mf=0.6
f=1.0
ff=1.6
comment do
pp=0.01
p=0.15
mp=0.2
mf=0.6
f=1.0
ff=1.6
end
ps=1.6 #pause factor
#set up the part lists ADD "settling rest time" of dsq at beginning of all parts for level to set
n1=[:r,:c5,:g5,:g5,:ab5,:g5,:g5,:g5,:d5,:e5,:f5,:f5,:ab5,:ab5,:g5,:f5,:db5,:eb5,:f5,:gb5,:f5,:f5,:e5,:f5]
d1=[dsq,b*2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d4.concat [b,b,b+c,c,c,c,m,m,m,c,c,c,m,c,b,m,m,m,cd,q,b,c,c,b,b,b,m,b,b,b]
#b81
n4.concat [:g5,:ab5,:g5,:r,:bb4,:ab4,:g4,:f4,:g4]
d4.concat [b,b,m,bd,b,bd,m,b,b*ps]
#end
n5=[:r,:c4,:e4,:f4,:g4,:f4,:bb3,:bb3,:f4,:eb4,:db4,:db4,:db4,:db4,:g3,:f4]
d5=[dsq+4*b,b*2,bd,m,b,b,b,b,m,m,b,b,b,b,b,b]
#b20
n5.concat [:r,:f4,:eb4,:db4,:c4,:ab3,:eb4,:c4,:r,:g3,:a3,:b3,:c4,:d4,:eb4,:db4,:c4,:bb3,:ab3,:g3,:r]
d5.concat [b,md,c,b,m,m,b,b,b*2,b,b,m,m,m,b,m,b,b,bd,m,b*3]
#b40
n5.concat [:c4,:g3,:gb3,:g3,:f4,:db4,:d4,:c4,:e4,:f4,:bb3,:r,:c4,:a3,:bb3,:c4,:d4,:eb4,:ab3,:db4,:bb4,:gb3,:bb3,:eb4]
d5.concat [b,b,b,b,b,b,b,bd,m,b,b,bd,m,m,m,bd,m,b,b,bd,m,b,b,b*2] #over by b
#b63 + b
n5.concat [:bb3,:r,:eb4,:bb3,:eb4,:db4,:c4,:f4,:eb4,:db4,:c4,:bb3,:ab3,:ab3,:bb3,:c4,:db4,:c4,:ab4,:g4,:f4,:eb4,:db4]
d5.concat [b,2*b+md,c,c,c,m,b,m,m,b,m,m,b,b,b,b,b,b,m,m,m,c,c]
#b81
n5.concat [:c4,:r,:db4,:eb4,:f4,:db4,:c4]
d5.concat [b,b*2,b,b,b,b*2,b*ps]
#end
#parts dynamic data
a1=[p,mf,mp,p,mf,f,mf,mp,p,pp] #levels
as1=[0,4*b,0,3*b,b,0,3*b,m,3*b,2*b+md,b]#slide times
ad1=[20*b,12*b,7*b+m,9*b+m,15*b+md,7*b+c,3*b+m,bd,6*b,4*b,2*b] #sleep durations at level
a2=[p,mf,p,mf,mp,p,mf,f,mf,mp,p,pp]
as2=[0,4*b+m,0,5*b,0,5*b,0,0,b,3*b,2*b+m,b]
ad2=[18*b+m,4*b+m,5*b,6*b,3*b+m,12*b,14*b+md,7*b+md,5*b,6*b,2*b+m,3*b+m]
a3=[p,mf,p,mf,p,mf,f,mf,mp,p,pp]
as3=[0,5*b,0,6*b,0,0,0,b,0,2*b,b]
ad3=[19*b,8*b,b,6*b,18*b+m,10*b+md,8*b+md,5*b+m,5*b+m,3*b,b,2*b]
a4=[p,mf,p,mf,mp,p,mf,f,mf,mp,p,pp]
as4=[0,5*b,0,4*b,0,2*b,0,0,b,b,0,b]
ad4=[19*b,6*b,3*b,4*b+m,6*b,11*b+c,15*b+m,6*b+md,4*b,8*b,3*b,2*b]
a5=[p,mf,p,mf,p,mf,f,mf,mp,p,pp]
as5=[0,4*b,0,6*b,b,0,0,b,b,b,b]
ad5=[20*b,7*b,2*b,6*b,16*b+m,15*b+c,5*b+c,5*b,6*b,4*b,2*b]
define :len do |d| #for checking durations of parts
ld=0
d.each do |d|
ld += d
end
return ld
end
define :perform do |x|
in_thread do
with_fx :level do |amp1| #set dynamic level
in_thread do
plct(amp1,a1,as1,ad1)
end
plarray(inst0,samplepitch0,n1,d1,-2,0.8,-0.7) #trumpet I
end
end
in_thread do
with_fx :level do |amp2|
in_thread do
plct(amp2,a2,as2,ad2)
end
plarray(inst0,samplepitch0,n2,d2,-2,0.8,0.7) #trumpet II
end
end
in_thread do
with_fx :level do |amp3|
in_thread do
plct(amp3,a3,as3,ad3)
end
plarray(inst0,samplepitch0,n3,d3,-2,0.8,-0.4) #trumpet III
end
end
in_thread do
with_fx :level do |amp4|
in_thread do
plct(amp4,a4,as4,ad4)
end
plarray(inst0,samplepitch0,n4,d4,-2,0.8,0.4) #trumpet IV
end
end
with_fx :level do |amp5|
in_thread do
plct(amp5,a5,as5,ad5)
end
plarray(inst0,samplepitch0,n5,d5,-2,0.9,0) #trumpet V
end
end
comment do #checks for debugging data input
puts len(d1)
puts len(d2)
puts len(d3)
puts len(d4)
puts len(d5)
puts n4.length
puts d4.length
puts len(ad1)
puts len(ad2)
puts len(ad3)
puts len(ad4)
puts len(ad5)
end
set_bpm(132) #set tempo
with_fx :reverb,room: 0.8,mix: 0.6 do #add some reverb
perform(0)
end
# Luca Marenzio Madrigal 1553-1599 "Spring Returns" arranged for 5 trumpets coded for by Robin Newman, April 2015
#uses sample based voice, and also has variable dynamic settings for each part and final rit.
#updated for newer versions of SP > 3 May need run_file on a Mac as quite long.
#Sample requires can be downloaded from http://r.newman.ch/rpi/Marenzio.zip
use_debug false
path = '~/Desktop/samples/Marenzio' #adjust location of sampe directory as necessary
#first deal with selecting and setting up the sample
inst0=:trumpet_cs5
samplepitch0=:cs5
#preload the sample
load_sample path,inst0
#define variable that needs to be used globally
s=0 #note duration scale factor: redefined in use_bpm function
#this function plays the sample at the relevant pitch for the note desired
#the note duration is used to set up the envelope parameters
define :pl do |inst,samplepitch,nv,dv,vol=1,pan=0|
shift=note(nv)-note(samplepitch)
sample path,inst,rate: (pitch_to_ratio shift),sustain: 0.8*dv,release: 0.2*dv,amp: vol,pan: pan
end
#this function plays an array of notes and associated array of durations
#also uses sample name (inst), sample normal pitch,sample start and shift (transpose) parameters
define :plarray do |inst,samplepitch,narray,darray,shift=0,vol=1,pan=0|
narray.zip(darray) do |nv,dv|
if nv != :r
pl(inst,samplepitch,note(nv)+shift,dv*s,vol,pan)
end
sleep dv*s
end
end
define :ct do |ptr,lev,slid=0,timetonext=0| #controls level
control ptr,amp: lev,amp_slide: slid
#puts "level "+lev.to_s #for debugging
sleep timetonext*s #scale for tempo
end
define :plct do |pt,am,amsl,amd| #performs level change for a part
am.zip(amsl,amd) do |amv,amslv,amdv|
ct(pt,amv,amslv,amdv)
end
end
#set_bpm sets bpm required adjusting note duration variables accordingly
define :set_bpm do |n|
s=1.0/8*60/n.to_f
end
#set relative note duration variables
dsq = 1.0 #must be float as divided later
sq = 2
sqd = 3
q = 4
qt = 2.0/3*q
qd = 6
qdd =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9*b,5*b,6*b,7*b+m,6*b+m,4*b,10*b,19*b] #sleep durations at level
a2=[mf,p,f,mp,f,mf,p,mf,f,p,f]
as2=[0,bd,0,b,3*b,0,bd,0,b,2*b,6*b]
ad2=[4*b+m,10*b,2*b+m,9*b,5*b,6*b,8*b+3*c,5*b+c,4*b,10*b,19*b]
a3=[mf,p,f,mp,f,mf,p,mf,f,p,f]
as3=[0,2*b,0,b,4*b,0,2*b,0,b,b,6*b]
ad3=[4*b+m,9*b+m,3*b,8*b,6*b,6*b,8*b,6*b,4*b,10*b,19*b]
a4=[mf,p,f,mp,f,mf,mp,mf,f,p,f]
as4=[0,2*b+m,0,md,3*b,0,2*b,0,b,m,4*b+m]
ad4=[4*b+m,10*b,2*b+m,9*b,4*b+m,6*b+m,7*b,7*b,4*b,11*b+m,17*b+m]
a5=[f,mp,f,mf,mp,mf,p,f]
as5=[0,b,4*b,0,2*b,0,0,4*b]
ad5=[17*b,8*b,6*b,6*b,2*b,16*b,12*b,17*b]
define :len do |d| #for checking durations of parts
ld=0
d.each do |d|
ld += d
end
return ld
end
define :perform do |x|
in_thread do
with_fx :level do |amp1| #set dynamic level
in_thread do
plct(amp1,a1,as1,ad1)
end
plarray(inst0,samplepitch0,n1,d1,-2,0.9,-0.7) #trumpet I
end
end
in_thread do
with_fx :level do |amp2|
in_thread do
plct(amp2,a2,as2,ad2)
end
plarray(inst0,samplepitch0,n2,d2,-2,0.9,0.7) #trumpet II
end
end
in_thread do
with_fx :level do |amp3|
in_thread do
plct(amp3,a3,as3,ad3)
end
plarray(inst0,samplepitch0,n3,d3,-2,0.9,-0.4) #trumpet III
end
end
in_thread do
with_fx :level do |amp4|
in_thread do
plct(amp4,a4,as4,ad4)
end
plarray(inst0,samplepitch0,n4,d4,-2,0.9,0.4) #trumpet IV
end
end
with_fx :level do |amp5|
in_thread do
plct(amp5,a5,as5,ad5)
end
plarray(inst0,samplepitch0,n5,d5,-2,0.9,0) #trumpet V
end
end
comment do #checks for debugging data input (uncomment)
puts len(d1)
puts len(d2)
puts len(d3)
puts len(d4)
puts len(d5)
puts n4.length
puts d4.length
puts len(ad1)
puts len(ad2)
puts len(ad3)
puts len(ad4)
puts len(ad5)
end
set_bpm(160) #set tempo
with_fx :reverb,room: 0.8,mix: 0.6 do #add some reverb
perform(0)
end
comment do #checks for dynamic levels
pp=0.02
p=0.08
mp=0.2
mf=0.6
f=1.0
ff=1.6
[pp,p,mp,mf,f,ff].each do |l|
with_fx :reverb,room: 0.8,mix: 0.6 do #add some reverb
with_fx :level,amp: l do
plarray(inst0,samplepitch0,[:c5],[b*2],-2,0.8,-0.7)
sleep 1.2
end
end
end
end

#Threee 16th Century madriagls by Luca Marenzio arranged for 5 trumpets. Coded for Sonic Pi by Robin Newman April 2015

These three madrigals use a samplebased Trumpet voice. The files also feature the use of a "Level" part which is sued to control the dynamic setting of each of teh 5 voices during teh performance, adjusting for p,mf,f etc and including crescendos and diminuendos. Two of the madrigals also have Rits coded.

They require Sonic Pi version 3 or later to play because of the pitch_shift function. The third madrigal is too long to run on a Mac at present, althouhg can use the run_file command. They are best played on a Pi2 or later. All three updated for syntax to run on later SP > 3 Sample requires can be downloaded from http://r.newman.ch/rpi/Marenzio.zip

Unzip and put in folder /home/pi/samples and/or adjust setting in sonic pi files above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment