# Technique for Playing Drum Samples in Pattern

**URL:** <https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332>\
**Category:** Support, Help & Resources\
**Created:** [January 4, 2022, 9:02pm UTC](https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332 "2022-01-04T21:02:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![youphoric-nick](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/youphoric-nick/32/2184_2.png) [@youphoric-nick](https://in-thread.sonic-pi.net/u/youphoric-nick)\
**Post date:** [January 4, 2022, 9:02pm UTC](https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332/1 "2022-01-04T21:02:44Z")

</div>

Hey all,

Long time off and on dabbler in Sonic Pi here. I’ve committed to a 2hr seminar for some high school students in March, so time to pro up a bit. 🙂

I noticed a drum pattern technique in [this DJ Dave performance](https://youtu.be/YvsoWehBbec?t=12) that I don’t recall seeing before. I’ve read about rings and ticks but never seen a string used as a ring, or used to create drum patterns.

```ruby
live_loop :met do
  sleep 1
end

define :pattern do |pattern|
  return pattern.ring.tick == "x"
end

live_loop :kick, sync: :met do
  with_fx :bitcrusher do
    sample :drum_heavy_kick if pattern "x--x--x---x--x--"
  end
  sleep 0.25
end

```

Coming from more of an Ableton background, it resonates with me as a nice way to pattern different drum samples, change them up live, etc. I’m wondering if this technique is documented anywhere? Is it common? Is there a ‘better’ way?

Cheers and Thanks,  
Nick

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 5, 2022, 2:30am UTC](https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332/2 "2022-01-05T02:30:13Z")

</div>

Hey Nick,

> [@](#):
>
> I’m wondering if this technique is documented anywhere?

Nope, not really. It works, but it’s not an ‘official’ Sonic Pi technique 🙂

> [@](#):
>
> Is it common?

There are a bunch of people that use this idea - whether it’s common is harder to answer 😄  
I’d say at least that it’s popular with folks that want to work with a more visual style of pattern representation.

> [@](#):
>
> Is there a ‘better’ way?

Well, there’s no right or wrong here… it comes down to personal preference! 😄  
There are a handful of interesting ways based on the same idea that other folks have used to represent grid patterns - here’s a few more:

> [@Binary Drum Sequencer - new ways to code drums](https://in-thread.sonic-pi.net/t/binary-drum-sequencer-new-ways-to-code-drums/1618):
>
> 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 o…

> [@Hexadecimal/binary rhythmic scheme](https://in-thread.sonic-pi.net/t/hexadecimal-binary-rhythmic-scheme/1899):
>
> Hexadecimal/binary rhythmic scheme Note that “spread” example 3 in documentation live\_loop :euclid\_beat do sample :elec\_bong, amp: 1.5 if (spread 3, 8).tick sample :perc\_snap, amp: 0.8 if (spread 7, 11).look sample :bd\_haus, amp: 2 if (spread 1, 4).look sleep 0.125 end Binary rhythmic scheme # Binary rhythmic scheme def schr(num) num.split(//).collect { |n| n == "1" } end live\_loop :euclid\_beat do sample :elec\_bong, amp: 1.5 if schr('10010010').ring.tick…

> [@Idea for drums management](https://in-thread.sonic-pi.net/t/idea-for-drums-management/4874):
>
> Hello, I’m new here and I want to share with you this implementation I made to handle drums inside a Sonic Pi track, in order to understand if this can be a good solution slight_smile I liked the idea I found around the web (mostly [here](https://www.youtube.com/watch?v=RaJZho7p2Y4) and [here](https://gist.github.com/darinwilson/a3e5909db339838a67fe)) to map the beats inside an array, to emulate somehow the common grids used by real drum machines and simplify the creation of beats. I also wanted to have something that gives the possibility to manage in easy way the evolution of the beats during …

---

<div class="post-metadata">

**Author:** ![youphoric-nick](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/youphoric-nick/32/2184_2.png) [@youphoric-nick](https://in-thread.sonic-pi.net/u/youphoric-nick)\
**Post date:** [January 5, 2022, 9:37pm UTC](https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332/3 "2022-01-05T21:37:39Z")

</div>

Thanks for the great links @ethancrawford! Starting to see that a list might be a little easier to manage syntax-wise.

Also a bit inspired by [this performance](https://www.youtube.com/watch?v=a1RxpJkvqpY) by [Jindřich Mynarz](https://www.youtube.com/channel/UC1KvANWpT6lfTtGjng2V4gQ):

- Use of `spread` for drum patterns
- Use of `ring` and `tick` to influence the played `amp` to create rhythms

Lots of ways to skin this. Thanks again!

-Nick

---

<div class="post-metadata">

**Author:** ![rothen\_s](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/rothen_s/32/3051_2.png) [@rothen\_s](https://in-thread.sonic-pi.net/u/rothen_s)\
**Post date:** [March 9, 2024, 1:29pm UTC](https://in-thread.sonic-pi.net/t/technique-for-playing-drum-samples-in-pattern/6332/4 "2024-03-09T13:29:19Z")

</div>

Hi,  
I liked the idea with the x–x patterns, but I wanted something to influence :amp. I came up with this

```ruby
use_bpm 60

live_loop :kick do
  sample :drum_cymbal_closed, amp: "600203500909".ring.tick.to_f / 4.5
  sample :drum_cymbal_pedal, amp: "000700000900".ring.tick.to_f / 4.5
  sample :drum_heavy_kick, amp: "600009900002".ring.tick.to_f / 4.5
  sleep 0.25
end

```
