Binary Drum Sequencer - new ways to code drums


#1

Hello!

I’ve been playing around with some new ways to create drum tracks in Sonic Pi. This one is fast and fun and I think some of you will be tempted to try it out.

Briefly, this style of live coding keeps all your drums in a single live_loop, uses a single ticker and a single sleep command. It should save your fingers from working too hard to create complex drum loops.

All it takes is a bit of binary know-how, and some ruby sugar to make it work.

use_bpm 240

live_loop :drums do
  tick
  on 5[look%4] {sample :bd_tek}
  on 3[look%4] {sample :bd_klub}
  on 7[look%4] {sample :bd_boom}
  on 10[look%4] {sample :elec_cymbal, rate: 3}
  sleep 1
end

What’s great about ruby is that when you index into an integer it treats it like a binary number and spits out 1s and 0s. When combined with sonic pi’s ‘on’ which accepts 1s and 0s, you have a fast drum sequencer.

Play with the integers to change the pattern. Change the modulo to create polyrhythms. It’s very flexible that way.

Any feedback would be appreciated. Have a nice day!

Marc


#2

hmm
I got an error using your syntax with { }

Runtime error: NoMethodError
Thread death ±-> :live_loop_drums
undefined method `call’ for Nil:nilClass

Changing to the version below worked

use_bpm 240

live_loop :drums do
  tick
  on 5[look%4] do;sample :bd_tek ;end
  on 3[look%4] do;sample :bd_klub;end
  on 7[look%4] do;sample :bd_boom;end
  on 10[look%4] do;sample :elec_cymbal, rate: 3;end
  sleep 1
end

EDIT or use this alternative using if instead of on

use_bpm 240

live_loop :drums do
  tick
  sample :bd_tek if 5[look%4] >0
  sample :bd_klub if 3[look%5] >0
  sample :bd_boom if 7[look%4] >0
  sample :elec_cymbal, rate: 3 if 10[look%4] >0
  sleep 1
end