Tabla sample drum sequencer with CASE pattern chooser

Exploring the thread below. Here are my take on a tabla sample sequencer.

(By the way when I tried to add a 5. pattern then Sonic Pi wouldnt let my type ENTER to add more lines to the code? So about 264 lines of code are a limit?)

# 220911 0212 Tabla sample drum sequencer with CASE pattern chooser

# Jumping off point https://in-thread.sonic-pi.net/t/can-someone-build-an-efficient-drum-machine/775/15?u=relaxnow
# Drum seq created with split on amp

# My performance https://youtu.be/6XCajFLvq00
# Created by https://linktr.ee/relaxnow

use_bpm 120

def beats(pat)
  pat.delete(' ').split('').map(&:to_i).ring
end

/Change here/
my_patt_tabla1 = 1                           # pattern mixer 1-4

#puts my_patt_tabla1 = rrand_i(1,3)

case my_patt_tabla1

when 1
  patt = {
    # Tabla playing technique https://youtube.com/playlist?list=PLY5SLQd6KECmvj1gBUra1WnKZVtWeeOJN
    
    # 26 samples of Tabla   # Type in amp value 1-9 or "-"             #  "phonetic" on the tabla sound
    
    :bd_fat            => " 9---",# ---- ---- ---- ---- ---- ---- ---- ",
    #:bd_fat            => " 9-9-",# ---- ---- ---- ---- ---- ---- ---- ",
    #:bd_fat            => " 999-",# ---- ---- ---- ---- ---- ---- ---- ",
    #:bd_fat            => " 9",# ---- ---- ---- ---- ---- ---- ---- ",
    #:bd_fat            => " 99-999-999-99",# ---- ---- ---- ---- ---- ---- ---- ",
    #:bd_fat            => " 1-2-3-4-5-6-7-8-",# ---- ---- ---- ---- ---- ---- ---- ",
    
    #:perc_snap         => " ---- 2---",# ---- ---- ---- ---- ---- ---- ---- ",
    #:perc_snap         => " ---- --2-",# ---- ---- ---- ---- ---- ---- ---- ",
    #:drum_snare_soft   => " ---- 4---",# ---- ---- ---- ---- ---- ---- ---- ",
    #:drum_cymbal_pedal => " ---- 4---",# ---- ---- ---- ---- ---- ---- ---- ",
    
    :tabla_dhec        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # te' noise
    
    :tabla_ghe1        => " ---- ---- ---- ---- ---- 5--- ---- ---- ", # bu_u'               # palm on skin + open stroke one finger
    :tabla_ghe2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe4        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    low duuuupp
    :tabla_ghe5        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe6        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe7        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_____
    :tabla_ghe8        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    high duupp'
    
    :tabla_ke1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high   slap '       # muted stroke all finger. Palm resting on skin
    :tabla_ke2         => " ---- -9-- --9- ---- ---- ---- ---- ---- ", # middle slap '
    :tabla_ke3         => " ---- ---- ---- -9-- -9-- ---- ---- ---- ", # deep   slap '
    
    :tabla_na          => " 555- ---- ---- ---- ---- ---- --5- ---- ", # low border          # open edge one finger
    :tabla_na_o        => " ---- --55 ---- ---- ---- ---- ---- ---- ", # low + high egde
    :tabla_na_s        => " ---- ---- ---- ---- ---- ---- ---- 7--- ", # short high  egde '
    
    :tabla_re          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # muted '
    
    :tabla_tas1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high                # open high on black clay
    :tabla_tas2        => " ---- --5- ---- ---- ---- ---- ---- ---- ", # high
    :tabla_tas3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high
    
    :tabla_te_m        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # ke'                 # muted stroke on black clay
    :tabla_te_ne       => " ---- ---- ---- ---- ---- ---- ---- ---- ", # dø'
    :tabla_te1         => " ---- ---- ---- --9- ---- ---- ---- --9- ", # de' higher
    :tabla_te2         => " 9--- ---- 9--- ---- 9--- ---- 9--- ---- ", # de' lower
    
    :tabla_tun1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn               # opens stroke small tabla
    :tabla_tun2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
    :tabla_tun3        => " 6--- ---- --6- ---- ---- ---- ---- ---- ", # duunnn
  }
  
when 2
  patt = {
    # Tabla playing technique https://youtube.com/playlist?list=PLY5SLQd6KECmvj1gBUra1WnKZVtWeeOJN
    
    # 26 samples of Tabla   # Type in amp: value 1-9 or "-"            # my "phonetic" on the tabla sound
    #:bd_haus           => " 5---",# ---- ---- ---- ---- ---- ---- ---- ",
    :bd_ada            => " 9--9 --9-",# ---- ---- ---- ---- ---- ---- ---- ",
    
    :tabla_dhec        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # te' noise
    
    :tabla_ghe1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bu_u'               # palm on skin + open stroke one finger
    :tabla_ghe2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe4        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    low duuuupp
    :tabla_ghe5        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe6        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe7        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_____
    :tabla_ghe8        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    high duupp'
    
    :tabla_ke1         => " ---- ---- ---- ---- ---- 9999 9-9- 9999 ", # high   slap '       # muted stroke all finger. Palm resting on skin
    :tabla_ke2         => " ---- ---- ---- ---- --99 ---- ---- ---- ", # middle slap '
    :tabla_ke3         => " 9-9- 9-9- 9--- ---- ---- ---- -9-9 ---- ", # deep   slap '
    
    :tabla_na          => " ---- ---- 9--- ---- ---- ---- ---- ---- ", # low border          # open edge one finger
    :tabla_na_o        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #  low + high egde
    :tabla_na_s        => " ---- ---- 9--- ---- ---- ---- ---- ---- ", # short high  egde '
    
    :tabla_re          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # muted '
    
    :tabla_tas1        => " ---- --9- ---- ---- ---- ---- ---- ---- ", # high                # open high on black clay
    :tabla_tas2        => " ---- ---9 ---- ---- ---- ---- ---- ---- ", # high
    :tabla_tas3        => " 9--- 9--- 9--- ---- ---- ---- ---- ---- ", # high
    
    :tabla_te_m        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # ke'                 # muted stroke on black clay
    :tabla_te_ne       => " ---- ---- ---- ---- ---- ---- ---- ---- ", # dø'
    :tabla_te1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' higher
    :tabla_te2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' lower
    
    :tabla_tun1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn               # opens stroke small tabla
    :tabla_tun2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
    :tabla_tun3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
  }
  
  
when 3
  patt = {
    # Tabla playing technique https://youtube.com/playlist?list=PLY5SLQd6KECmvj1gBUra1WnKZVtWeeOJN
    
    # 26 samples of Tabla   # Type in amp: value 1-9 or "-"            # my "phonetic" on the tabla sound
    :bd_haus           => " 5---",# ---- ---- ---- ---- ---- ---- ---- ",
    :bd_ada            => " 9--9 --9-",# ---- ---- ---- ---- ---- ---- ---- ",
    
    :tabla_dhec        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # te' noise
    
    :tabla_ghe1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bu_u'               # palm on skin + open stroke one finger
    :tabla_ghe2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe4        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    low duuuupp
    :tabla_ghe5        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe6        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe7        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_____
    :tabla_ghe8        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    high duupp'
    
    :tabla_ke1         => " ---- ---- ---- ---- ---- 9999 9-9- 9999 ", # high   slap '       # muted stroke all finger. Palm resting on skin
    :tabla_ke2         => " ---- ---- ---- ---- --99 ---- ---- ---- ", # middle slap '
    :tabla_ke3         => " 9-9- 9-9- 9--- ---- ---- ---- -9-9 ---- ", # deep   slap '
    
    :tabla_na          => " ---- ---- 9--- ---- ---- ---- ---- ---- ", # low border          # open edge one finger
    :tabla_na_o        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #  low + high egde
    :tabla_na_s        => " ---- ---- 9--- ---- ---- ---- ---- ---- ", # short high  egde '
    
    :tabla_re          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # muted '
    
    :tabla_tas1        => " ---- --9- ---- ---- ---- ---- ---- ---- ", # high                # open high on black clay
    :tabla_tas2        => " ---- ---9 ---- ---- ---- ---- ---- ---- ", # high
    :tabla_tas3        => " 9--- 9--- 9--- ---- ---- ---- ---- ---- ", # high
    
    :tabla_te_m        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # ke'                 # muted stroke on black clay
    :tabla_te_ne       => " ---- ---- ---- ---- ---- ---- ---- ---- ", # dø'
    :tabla_te1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' higher
    :tabla_te2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' lower
    
    :tabla_tun1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn               # opens stroke small tabla
    :tabla_tun2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
    :tabla_tun3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
  }
  
when 4
  patt = {
    # Tabla playing technique https://youtube.com/playlist?list=PLY5SLQd6KECmvj1gBUra1WnKZVtWeeOJN
    
    # 26 samples of Tabla   # Type in amp: value 1-9 or "-"            # my "phonetic" on the tabla sound
    
    :tabla_dhec        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # te' noise
    
    :tabla_ghe1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bu_u'               # palm on skin + open stroke one finger
    :tabla_ghe2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe4        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    low duuuupp
    :tabla_ghe5        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe6        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe7        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_____
    :tabla_ghe8        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    high duupp'
    
    :tabla_ke1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high   slap '       # muted stroke all finger. Palm resting on skin
    :tabla_ke2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # middle slap '
    :tabla_ke3         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep   slap '
    
    :tabla_na          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # low border          # open edge one finger
    :tabla_na_o        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #  low + high egde
    :tabla_na_s        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # short high  egde '
    
    :tabla_re          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # muted '
    
    :tabla_tas1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high                # open high on black clay
    :tabla_tas2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high
    :tabla_tas3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high
    
    :tabla_te_m        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # ke'                 # muted stroke on black clay
    :tabla_te_ne       => " ---- ---- ---- ---- ---- ---- ---- ---- ", # dø'
    :tabla_te1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' higher
    :tabla_te2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' lower
    
    :tabla_tun1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn               # opens stroke small tabla
    :tabla_tun2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
    :tabla_tun3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
  }
  
  
  
  /empty pattern for copying/
when 10
  #Tabla 26 samples
  patt = {
    # Tabla playing technique https://youtube.com/playlist?list=PLY5SLQd6KECmvj1gBUra1WnKZVtWeeOJN
    
    # 26 samples of Tabla   # Type in amp: value 1-9 or "-"            # my "phonetic" on the tabla sound
    
    :tabla_dhec        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # te' noise
    
    :tabla_ghe1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bu_u'               # palm on skin + open stroke one finger
    :tabla_ghe2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_
    :tabla_ghe4        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    low duuuupp
    :tabla_ghe5        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe6        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep long boooomm_
    :tabla_ghe7        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # bauuuu_____
    :tabla_ghe8        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #    high duupp'
    
    :tabla_ke1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high   slap '       # muted stroke all finger. Palm resting on skin
    :tabla_ke2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # middle slap '
    :tabla_ke3         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # deep   slap '
    
    :tabla_na          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # low border          # open edge one finger
    :tabla_na_o        => " ---- ---- ---- ---- ---- ---- ---- ---- ", #  low + high egde
    :tabla_na_s        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # short high  egde '
    
    :tabla_re          => " ---- ---- ---- ---- ---- ---- ---- ---- ", # muted '
    
    :tabla_tas1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high                # open high on black clay
    :tabla_tas2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high
    :tabla_tas3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # high
    
    :tabla_te_m        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # ke'                 # muted stroke on black clay
    :tabla_te_ne       => " ---- ---- ---- ---- ---- ---- ---- ---- ", # dø'
    :tabla_te1         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' higher
    :tabla_te2         => " ---- ---- ---- ---- ---- ---- ---- ---- ", # de' lower
    
    :tabla_tun1        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn               # opens stroke small tabla
    :tabla_tun2        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
    :tabla_tun3        => " ---- ---- ---- ---- ---- ---- ---- ---- ", # duunnn
  }
end




with_fx :level, amp: 4 do
  
  with_fx :reverb do |reverb|
    
    live_loop :mel1 do
      #stop
      tick#(step: [0,1,1,1,1,1,2].choose)  # change step of tick randomly for nice effect
      patt.each{ |key, val|  sample key, amp: beats(val).look / 10.0  }
      sleep 0.25
      control reverb, room: 0.3
    end
    
    
  end
end

There is a limit on buffer size, (which seems slightly bigger on Linux than on Mac). You can bypass it by saving your code in an external file and then using the run_file command to execute it. That way you can process much larger files. Probably over 70% of the files I write for Sonic Pi utilise this process. I even name them using filename-RF.rb to remind me to use run_file to execute them. If you drag the file icon into the buffer window ti automatically shows the path the file and you just stick run_file in front.

1 Like

I think it is possible to come around this limitation by having the functions and constant fields in a separate Editor (thats not the correct term, but i cant find how they are called…caches? tabs? the 0-9 at the bottom of the editor :smiley: ).
In your video you have the complete code in Editor 1, if you split some things into functions and place them in another editor like 2, you can have more in Editor 1.
Before you run Editor 1 you have to run editor 2. Its ok, that nothing happens and the run stops immediately. SonicPi will have the functions loaded.
Now you can start Editor 1

Hope all of that makes sense :smiley:

1 Like