Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Carol of the Bells" coded for Sonic Pi. Entry for Monthly Challenge #3 on in-thread.sonic-pi.net. Hear it on https://soundcloud.com/rbnsonicpi/carol-of-the-bells
#Carol_of_the_Bells.rb
#coded for Sonic Pi by Robin Newman, Dec 22 2020
use_bpm 2*78 #twice 78rpm!! criterion for Monthly Challenge #3
s=0.95;r=0.1 #set sustain release fractions
pp=0.3;p=0.4;mf=0.6;f=0.8;ff=1 #defeine vol levels
with_fx :reverb,room: 0.8,mix: 0.8 do
use_synth :beep #synth for top part
with_fx :level ,amp: 1.3 do #most toop part relative to the others
with_fx :level,amp: pp do |v1| #set initial volume
set :v1,v1 #pointer to fx_level
#control volume at times specified by "at" this part also has variable slide times
at [12*3,16*3, 24*3,25*3,26*3,27*3,44*3,48*3,56*3,57*3,58*3,59*3],
[[mf,0],[f,0],[ff,3],[mf,3],[f,3],[p,3],[mf,0],[f,0],[ff,3],[mf,3],[f,3],[p,3]] do |vol1|
control get(:v1),amp: vol1[0],amp_slide: vol1[1]
end
a1=[:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:Bf4,:A4,:Bf4,:G4,:D5,:C5,:D5,:Bf4,:D5,:C5,:D5,:Bf4,:D5,:C5,:D5,:Bf4,:D5,:C5,:D5,:Bf4,:G5,:G5,:G5,:F5,:Ef5,:D5,:D5,:D5,:C5,:Bf4,:C5,:C5,:C5,:D5,:C5,:G4,:G4,:G4,:G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.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,12.0]
in_thread do
for i in 0..a1.length-1
play a1[i],sustain: b1[i]*s,release: b1[i]*r,pan: -0.6
sleep b1[i]
end
end
end #level1
end #level part boost
use_synth :blade#for remaining parts
with_fx :level,amp: 0.8 do# balance parts 2-4 reduced
with_fx :level,amp: p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,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,1.0,0.5,0.5,1.0,3.0,3.0,3.0,2.0,1.0,3.0,3.0,3.0,3.0,12.0]
in_thread do
for i in 0..a4.length-1
play a4[i],sustain: b4[i]*s,release: b4[i]*r,pan: 0.6
sleep b4[i]
end
end
end#level4
end#level balance parts 2-4
end#fx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment