Drum Beat Using Arrays In Sonic PI

This Sonic Pi script uses two arrays to produce a drum beat with a cymbal beat at the same time.

use_bpm 100

bassdrum = [1,0,2,2,1,0,1,0,1,0,1,0,1,0,1,0]

live_loop :bassdrum do
  16.times do |i|
    puts i, bassdrum[i]
    sample :drum_heavy_kick if bassdrum[i] == 1
    sample :drum_bass_soft if bassdrum[i] == 2
    sleep 0.25
  end
end

cymbal = [1,1,1,0,1,0,1,0,1,0,1,1,0,1,2,1]

live_loop :cymbal do
  16.times do |i|
    puts i, cymbal[i]
    sample :drum_cymbal_closed if cymbal[i] == 1
    sample :drum_snare_soft if cymbal[i] == 2
    sleep 0.25
  end
end

Use this as a basic beat for your compositions.

Add new comment

The content of this field is kept private and will not be shown publicly.