Last active
December 9, 2016 22:08
-
-
Save Castlewood/4bf8e48effda527a1bd36634010096fd to your computer and use it in GitHub Desktop.
Sonic Pi Drums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
live_loop :drums do | |
## Edit BPM and Time Signature ## | |
use_bpm 120 | |
timesignature = [4,4] | |
################################# | |
ts = timesignature[0].to_f/timesignature[1].to_f | |
if ts == 1 | |
##################### 4/4 Pattern ##################### | |
kick = [1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0] | |
snare = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0] | |
hats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0] | |
cowbell = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0] | |
##################### end Pattern ##################### | |
elsif ts == 0.75 | |
############### 3/4 Pattern ############### | |
kick = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | |
snare = [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] | |
hats = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0] | |
cowbell = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1] | |
############### end Pattern ############### | |
else | |
puts "Unrecognised Time Signature" | |
stop | |
end | |
(kick.length).times do |beat| | |
sample :drum_heavy_kick, amp: 10 if kick[beat] == 1 | |
sample :drum_snare_soft, amp: 10 if snare[beat] == 1 | |
sample :drum_cymbal_closed, amp: 10 if hats[beat] == 1 | |
sample :tabla_te_ne, amp: 10 if cowbell[beat] == 1 | |
sleep 1.0/timesignature[1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Designed to be edited 'live' - experiment with switching '1's to '0's to create different patterns.
You can a;so switch between 3/4 and 4/4 Time Signatures