Chopping a sample randomly via midi keyboard

Hi there,
i had the idea to record samples, like just playing the cminor, and let onset decide which note should be played. implemented some reoccuring randomness to get a melody and now when i press c on my keyboard i get 1 of the semi random picked notes from cminor, did the same with bbminor. gonna expand on that since i think thats pretty cool. ill arrange chords and drums like that too i guess.

My only issue is the randomness, i hope there is a better way to do it, cause i want the random note to jump when i pressed once the key. hope u get what i mean :stuck_out_tongue_winking_eye:

sorry i used samples from my own. ur free to replace them.

live_loop :seeeeds do
  use_random_seed 892
  6.times do
    set :randseeed, (ring 541654,64654164,1235216,51531641,6411163,1646532132,1056847645).choose
    
    puts :randseeed
    
    sleep 0.125
    
    cue :simp
  end
end

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

live_loop :midi_sfx, sync: :simp do
  use_real_time
  note = sync "/midi:piaggero_0:1/note_on"
  
  use_random_seed get(:randseeed)
  if note[0] == 40 then
    1.times do
      sample samps1, "cmin", onset: choose
      sleep 0.125
    end
  end
  
  if note[0] == 41 then
    1.times do
      sample samps1, "bbmin", onset: choose
      sleep 0.125
    end
  end
end

i managed to solve the problem even better than i thought haha here my approach.
any way to improve on that hhaha?



use_random_seed 500456

set :current_state, 0

NOTES = [50, 7896, 45612, 84563, 1237]


RULES = {
  0 => [1,2],
  1 => [3,4],
  2 => [1,3,4],
  3 => [4,0],
  4 => [0,1,2]
}


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

live_loop :midi_sfx do
  use_real_time
  note = sync "/midi:piaggero_0:1/note_on"
  s = get[:current_state]
  use_random_seed NOTES[s]
  
  if note[0] == 40 then
    1.times do
      
      sample samps1, "cmin", onset: choose
      sleep 0.125
      set :current_state, RULES[s].choose
      
    end
  end
end

well i settled for this, its good enough but not exactly what i wanted

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


live_loop :midi_sfx do
  
  
  
  use_real_time
  note = sync "/midi:piaggero_0:1/note_on"
  
  use_random_seed (ring 65465,465467,6567,67676,76576,765431,5465,7687,67).tick(:gf)
  
  if note[0] == 60 then
    
    sample samps1, "cmin", onset: choose
    sleep 0.125
 
  end
end

What is it supposed to do that is exactly what you wanted?

And what is with the collection of random seeds? If you want reproducible results, use a single random seed. If you want a “random” seed, just put in use_random_seed (Time.now).to_i.freeze or something similar.