"use_random_seed" get stuck

I found two solutions in the forum after digging a bit.

" i= Time.now.to_i"
from More real randomization - #2 by Martin

“i=Random.rand(1…200)”
from More real randomization - #11 by rubertres

use_bpm 90

live_loop :tabla do
  #stop
  
  # Trouble: "i" gets stuck at "126" after some time
  i = rrand_i(1,200)
  
  # Solution 1: Using time as random_seed
  i= Time.now.to_i
  
  # Solution 2: more clear and easier to read + between 1-200
  i=Random.rand(1..200)
  
  puts i
  use_random_seed i
  
  2.times do
    use_random_seed i #200    104  107  40 31
    
    15.times do
      sample  :tabla_tun1, rpitch: (scale :minor_pentatonic).choose, pan: 0.25#+24
      #                                                               #0 5
      sample  :tabla_tun2, rpitch: (scale :minor_pentatonic).choose-12-0, pan: -0.25 if spread(3,5).tick
      sleep 0.25
    end
    sleep 0.25
    
  end
  
end
2 Likes