# Tabla sample drum sequencer with CASE pattern chooser

**URL:** <https://in-thread.sonic-pi.net/t/tabla-sample-drum-sequencer-with-case-pattern-chooser/7095>\
**Category:** Creations & Ideas\
**Created:** [September 11, 2022, 12:35am UTC](https://in-thread.sonic-pi.net/t/tabla-sample-drum-sequencer-with-case-pattern-chooser/7095 "2022-09-11T00:35:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Relaxnow](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/relaxnow/32/2172_2.png) [@Relaxnow](https://in-thread.sonic-pi.net/u/Relaxnow)\
**Post date:** [September 11, 2022, 12:35am UTC](https://in-thread.sonic-pi.net/t/tabla-sample-drum-sequencer-with-case-pattern-chooser/7095/1 "2022-09-11T00:35:38Z")

</div>

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

> [@Can someone build an efficient drum machine?](https://in-thread.sonic-pi.net/t/can-someone-build-an-efficient-drum-machine/775/15):
>
> Hey @ds604, just stumbled across this, and really like it as a very short & simple yet still visually intuitive drum machine. Here’s an even shorter version, inspired by yours: use\_bpm 120 def beats(pat) pat.delete(' ').split('').map(&:to\_i).ring end patt = { :bd\_klub =\> "9--5 --5- ---- -3-- 9--- ---- 9--- ----", :drum\_snare\_soft =\> "---- ---3 9--- ---- ---- ---- --33 9---", :perc\_snap2 =\> "9--- --11 11-- ---- 5--- 5-11 11-- 9---", :elec\_flip =\> "--5- ---- --5- -…

(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?)

```ruby
# 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

```

[![](https://img.youtube.com/vi/6XCajFLvq00/maxresdefault.jpg "Sonic Pi Tabla sample drum sequencer with CASE pattern chooser") ](https://www.youtube.com/watch?v=6XCajFLvq00)

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [September 11, 2022, 9:56am UTC](https://in-thread.sonic-pi.net/t/tabla-sample-drum-sequencer-with-case-pattern-chooser/7095/2 "2022-09-11T09:56:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![synchron](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@synchron](https://in-thread.sonic-pi.net/u/synchron)\
**Post date:** [September 11, 2022, 6:26pm UTC](https://in-thread.sonic-pi.net/t/tabla-sample-drum-sequencer-with-case-pattern-chooser/7095/3 "2022-09-11T18:26:04Z")

</div>

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 😃 ).  
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 😃
