# Using onset function with recorded scales and chords

**URL:** <https://in-thread.sonic-pi.net/t/using-onset-function-with-recorded-scales-and-chords/6736>\
**Category:** Creations & Ideas\
**Created:** [May 1, 2022, 3:48pm UTC](https://in-thread.sonic-pi.net/t/using-onset-function-with-recorded-scales-and-chords/6736 "2022-05-01T15:48:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![holz](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/holz/32/1664_2.png) [@holz](https://in-thread.sonic-pi.net/u/holz)\
**Post date:** [May 1, 2022, 3:48pm UTC](https://in-thread.sonic-pi.net/t/using-onset-function-with-recorded-scales-and-chords/6736/1 "2022-05-01T15:48:53Z")

</div>

Hi there,  
i recorded me playing scales and chords and used the onset function with random seed, so it picks up random melodys and basslines.

Here ya go:  
(sry had to use custom samples for that)  
[Letter von M. E. (soundcloud.com)](https://soundcloud.com/m-e-160701808/letter)

```ruby
live_loop :metro do
  sleep 2
end

samps2 = "C:/Users/Gott/Desktop/scales1"

live_loop :pro1, sync: :metro do
  #with_fx :slicer, phase: 0.25, pulse_width: 0.85 do
  use_random_seed 520
  8.times do
    with_swing pulse: 6, shift: 0.1 do
      sample samps2, "cmin", onset: choose, amp: 1 if (spread 6,8).tick(:t21)
    end
    sleep 0.25
  end
  use_random_seed 20
  8.times do
    #with_swing pulse: 6, shift: 0.1 do
    sample samps2, "bbmin", onset: choose, amp: 1 if (spread 5,8).tick(:t212)
    #end
    sleep 0.25
  end
end

samps = "C:/Users/Gott/Desktop/scales"

live_loop :pro, sync: :metro do
  #with_fx :slicer, phase: 0.25, pulse_width: 0.85 do
  use_random_seed 50
  8.times do
    # with_swing pulse: 6, shift: 0.1 do
    sample samps, "cmin", onset: choose, amp: 1.5 if (spread 8,8).tick(:t1)
    # end
    sleep 0.25
  end
  use_random_seed 100
  #with_swing pulse: 8, shift: 0.025 do
  8.times do
    sample samps, "bbmin", onset: choose, amp: 1.5 if (spread 8,8).tick(:t44)
    #end
    sleep 0.25
    #end
  end
end

samps1 = "C:/Users/Gott/Desktop/chords"

live_loop :chords, sync: :metro do
  sample samps1, "cmin", amp: 2
  sleep 8
end

live_loop :chords1, sync: :metro, delay: 4 do
  sample samps1, "bbmin", amp: 2
  sleep 8
end

live_loop :drums, sync: :metro do
  use_bpm 240
  tick
  sample :bd_tek if 5[look%4] >0
  sample :bd_klub if 3[look%5] >0
  sample :bd_boom if 7[look%7] >0
  sample :elec_cymbal, rate: 3 if 10[look%4] >0
  sleep 1
end

```
