Ticking through samples randomly from outside folder

Hi there,

tick is never random, it’s just a basic counter: 0, 1, 2, 3, 4....

For example:

live_loop :foo do
    sample path_to_sample_folder, tick
    sleep 8
end

This will play each successive sample (alphabetically in order) with 8 beats between sample triggers. It will always play them alphabetically as tick will always increase by one every time it is called (assuming there’s only one call to tick in the current live loop).

However, if you want it to pick a random sample, you need to use pick:

live_loop :foo do
    sample path_to_sample_folder, pick
    sleep 8
end

The caveat here is that in Sonic Pi, there’s no real randomness, so that the same code always produces the same sounds. You can manipulate this though by using random seeds. For more information about randomness please see: http://sonic-pi.net/tutorial.html#section-4

I hope that this helps :slight_smile:

1 Like