# A little experiment with motives

**URL:** https://in-thread.sonic-pi.net/t/a-little-experiment-with-motives/6176
**Category:** Creations & Ideas
**Created:** [November 21, 2021, 10:32am UTC](https://in-thread.sonic-pi.net/t/a-little-experiment-with-motives/6176 "2021-11-21T10:32:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Loopiloop](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/loopiloop/32/2094_2.png) [@Loopiloop](https://in-thread.sonic-pi.net/u/Loopiloop)
#### Post date: [November 21, 2021, 10:32am UTC](https://in-thread.sonic-pi.net/t/a-little-experiment-with-motives/6176/1 "2021-11-21T10:32:13Z")

</div>

Just a very simple melody generator

```ruby
live_loop :main do
  cur_pool = (knit (ring -1), 4) + (ring (ring 0), (ring 1), (ring 2), (ring 3), (ring 4), (ring 5), (ring 6), (ring 7), (ring 8), (ring 9))
  7.times do
    next_pool = (ring)
    8.times do
      next_pool = next_pool + (ring cur_pool.choose + cur_pool.choose)
    end
    cur_pool = next_pool
    puts cur_pool
  end
  (2 ** 7).times do
    if not cur_pool[0][tick] == -1
      synth :blade ,note: (scale :g, :major_pentatonic, num_octaves: 2)[cur_pool[0][look] ] - 12, amp: 0.6
    end
    if (range 0, 4).look == 0
      sample :bd_sone
    end
    sleep 0.25
  end
end

```
