Skip to content

Instantly share code, notes, and snippets.

@Castlewood
Last active December 9, 2016 22:08
Show Gist options
  • Save Castlewood/4bf8e48effda527a1bd36634010096fd to your computer and use it in GitHub Desktop.
Save Castlewood/4bf8e48effda527a1bd36634010096fd to your computer and use it in GitHub Desktop.
Sonic Pi Drums
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
@Castlewood
Copy link
Author

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

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