# Searching a easy way to make euclidian Rhythms

**URL:** <https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048>\
**Category:** Support, Help & Resources\
**Created:** [February 24, 2019, 2:18pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048 "2019-02-24T14:18:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![KOSF](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/kosf/32/873_2.png) [@KOSF](https://in-thread.sonic-pi.net/u/KOSF)\
**Post date:** [February 24, 2019, 2:18pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/1 "2019-02-24T14:18:43Z")

</div>

Hey everyone!  
There’s some easy way to make euclidian rhythms as tidal cycle do?  
in this video there’s a better explenation  
https://www.youtube.com/embed/bJ76bjC5AHA?feature=oembed&wmode=opaque&list=PLCBw4oQTHsrD_Pe985ABIMKN-z5Ad54D7  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [February 24, 2019, 3:08pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/2 "2019-02-24T15:08:50Z")

</div>

Hi @KOSF, have you had a look at the `spread` command? Might be what you looking for (see the docs or the following for a practical example: [https://github.com/mbutz/sonic-pi-resources/blob/master/samba-with-spread-and-at.rb](https://github.com/mbutz/sonic-pi-resources/blob/master/samba-with-spread-and-at.rb))

---

<div class="post-metadata">

**Author:** ![KOSF](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/kosf/32/873_2.png) [@KOSF](https://in-thread.sonic-pi.net/u/KOSF)\
**Post date:** [February 24, 2019, 3:14pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/3 "2019-02-24T15:14:18Z")

</div>

Thank you so Much @Martin, i think it’s the command i was looking for!!

---

<div class="post-metadata">

**Author:** ![KOSF](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/kosf/32/873_2.png) [@KOSF](https://in-thread.sonic-pi.net/u/KOSF)\
**Post date:** [February 24, 2019, 10:30pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/4 "2019-02-24T22:30:08Z")

</div>

@Martin I’m so sorry to bother you again but I need a little bit more clarification about this:  
I understand how to use euclidian rythms with sample but now I would like to achieve the same but with an arpeggio.

I tried with these but I’m achieving just rythm but the arpeggio:  
`"live_loop :euclid do play (scale :e3, :minor_pentatonic), release: 0.5 if (spread 3, 8).tick sleep 0.125 end"`

---

<div class="post-metadata">

**Author:** ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)\
**Post date:** [February 25, 2019, 1:43am UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/5 "2019-02-25T01:43:53Z")

</div>

@KOSF I use the spread command a lot but haven’t ever tried using it with different notes, so I was curious to try this out.

Just ticking through the scale and thread will not play the notes in order because even though you are ticking through all the notes in the scale, the spread will only play a note on certain beats therefore not playing some notes as you tick through the scale.

To fix this, you can store the scale in a variable and make another variable to act as a counter.

You then need to put the spread as a conditional before the play (This requires adding an additional ‘end’ since the ‘if’ conditional is a block of code that needs to be closed or else you get an error).

In the conditional, a note will only play on the beats specified in the spread (when the condition equals true). Instead of ticking through the scale, you will use the counter variable to play through the ring index. It will increase each time a note is played instead of each tick which would increase even when a note is not played.

Hope that makes sense. The code is below.

```ruby
sc = scale(:e3, :minor_pentatonic) #scale stored in variable
i = 0 # counter variable
live_loop :euclid do
  if (spread 3, 8).tick # Conditional will play when true
    play sc[i], release: 0.5 # plays note in ring index based on counter
    i = i + 1 # increases counter by 1 after last note is played
  end
  sleep 0.125
end

```

If anyone knows an easier way to do this, I’d love to hear it. I played around with .tick and .look in various combinations but could not replicate the behavior of the code above.

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [February 25, 2019, 6:46am UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/6 "2019-02-25T06:46:53Z")

</div>

Hi, (I’m away and have just my smart phone with me, so I can’t try out anything) instead of an extra counter: what about introducing another ‘tick(:my\_spread)’?

---

<div class="post-metadata">

**Author:** ![KOSF](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/kosf/32/873_2.png) [@KOSF](https://in-thread.sonic-pi.net/u/KOSF)\
**Post date:** [February 25, 2019, 7:19am UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/7 "2019-02-25T07:19:58Z")

</div>

Hi @mrbombmusic! That Can Be a really good solution! I Hope there Is an implementation for something a little bit faster, but for now I think it’s perfect.  
Thank you so much!

---

<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:** [February 25, 2019, 7:45am UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/8 "2019-02-25T07:45:44Z")

</div>

Martin’s idea makes it very compact

```ruby
sc = scale(:e3, :minor_pentatonic) #scale stored in variable
live_loop :euclid do
  play sc.tick(:scl), release: 0.5 if (spread 3, 8).tick 
  sleep 0.125
end

```

The two ticks are independent of each other

---

<div class="post-metadata">

**Author:** ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)\
**Post date:** [February 25, 2019, 1:06pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/9 "2019-02-25T13:06:10Z")

</div>

That def works better! I wasn’t aware you could have multiple ticks working independent of each other. Good to know!

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [February 25, 2019, 2:16pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/10 "2019-02-25T14:16:39Z")

</div>

For reference, there’s a little bit about using multiple ticks within a single live loop in Section 9.4 of the tutorial: [https://sonic-pi.net/tutorial.html#section-9-4](https://sonic-pi.net/tutorial.html#section-9-4)

---

<div class="post-metadata">

**Author:** ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)\
**Post date:** [February 25, 2019, 5:53pm UTC](https://in-thread.sonic-pi.net/t/searching-a-easy-way-to-make-euclidian-rhythms/2048/11 "2019-02-25T17:53:54Z")

</div>

Yes I went and checked that out after @Martin mentioned it. Very helpful!

@samaaron Forgive me for going off-topic, but your experiments with combining hydra with SPi were super inspiring! Was that something that could be implemented by someone less knowledgable than yourself (ie me)? Hoping that may become a feature in the future.🙏🤞
