Skip to content

Instantly share code, notes, and snippets.

@rbnpi
Created September 3, 2016 08:48
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/36fce41e156f6d15d49ba3a470d6e82b to your computer and use it in GitHub Desktop.
Save rbnpi/36fce41e156f6d15d49ba3a470d6e82b to your computer and use it in GitHub Desktop.
Peal of Church bells played by Sonic Pi. Note wobble factor added to give human touch (line 38)
#samples based chimes voice for Sonic Pi by Robin Newman Ocrtober 2014, updated December 2015 and Sep 2016
#program plays a Quarter Peal of Church Bells
#sample from Sonatina Symphonic Orchestra http://sso.mattiaswestlund.net/index.html
#Download and place on Desktop
use_debug false
sname='~/Desktop/Sonatina Symphonic Orchestra/Samples/Percussion/chimes-f#3.wav'
path='/Users/rbn/Desktop/samples/Chimes'
#set_sched_ahead_time! 4
define :pl do |n,d=0.2,pan=0,v=0.8,nodamp=1|
if nodamp!=1
sample sname,rpitch: (n-note(:fs3)),attack: 0,sustain: d*0.95,release: d*0.05,amp: v,pan: pan
else
sample sname,rpitch: (n-note(:fs3)),attack: 0,sustain: 0,release: 1,amp: v,pan: pan
end
end
#=======================define note arrays. Five parts play together=================
obells=[:db3,:eb3,:f3,:gb3,:ab3,:bb3,:c4,:db4]
obells=obells.reverse #reverse order to fit usual number of bells (1 treble to 8 tenor)
#plarray(obells,[0.5]*8)#uncomment to test
puts"Sonic Pi goes bell ringing!"
puts" "
puts"This program uses a sample based chimes voice to simulate a peal of 8 bells"
puts "Bristol Surprise Major Quarter Peal (8 bells)"
puts "Bells tuned as the bells in St. Peter's Oundle"
puts "Peal listed here http://ringing.org/main/pages/method?name=Bristol&class=4&stage=8"
#bell sound order listed in the string ch, consisting of 231 changes of 8 numbers 1-8
ch="123456782143658712346857214386752413685742316587241356784231576824351786234571683254178635247168534276183524678132547618234567812436587142638517462358716432851746238157426318752436815723461875324168572314658732415678231457682134758612435768213456781243658714263857142638574162837514268735416278534612873564218375461238576421358746231578426351872436157823465187326458172346857124365817426385714628375164827315684237518624731568427135648217534628713542681753246187354216837524613857421635874126537814623587412638571462837516482735164827356184725316487523618457326814752386417253681427358641237568421357648231754628135742683175248637154268735146283715648273516847253186745213876425317846521387645123867415326847512364871532468175236418725346812735641823756148325716842375614827351684725318674523186745238176543218675342817635248716534278615432871645237861425387641235867421536847123564872153467825136487523168472513867452318765432178563412758643215768341275863142785613248765314286751324687153428617543268714523861742538167243518764253816745231876543217856342178563427158362417853264715823467518326457813624751863425781643275861423785641328765142386754132685743128675342187654312785634217583624157382614537862413587261453782164573812467583216478531246875132647815362487516342781564327185462317586432718563421758362415738264157382645137284615732486513742685317248635712846531782643571862453781642573861247583164278536124873562147853264175836214573826415372846135274816325784612375481632574186352714685372418657321468753124865713284675318264571386245173684215378624517382641537284613527486135274863125476813524678312564873215467823514768321574862351784632571864352781465372186457328146752384165732486153728416352748613254768123456718243576814253671824356178234516873254617835241687532146783512476853217486351278463152876413257846315274861325476812345678"
puts (ch.length / 8).to_s + " changes"
puts "time taken "+(ch.length.to_f * 0.4/60).to_s+" minutes"
0.upto(ch.length - 1) do |i| #loop performs the ringing
pl(obells[ch[i].to_i - 1],0.4) #bell index offset by -1 to accommodate usual array index numbering from 0
sleep 0.3+rrand(0,0.2) #put a human "wobble" on exact timing to make it sound more realistic
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment