Is there a way to "get" random seed?

I have composed a beat which has lots of randomness. By chance this randomness sounds really great. The way the randomness seems to work makes it so it plays consistently the same notes every time I restart the song which is exactly what I want.

The problem is that when I add more live loops to the song it somehow changes the random notes that play, it’s as if the random seed has changed.

I have not used “use_random_seed” in my code so I have no idea what this great sounding seed number is. Is there any way I can use “puts” to display it on the screen so I can in turn set the seed to that value with “use_random_seed”?

In the meantime it seems that as long as I call my new live_loops underneath the old live_loops that use the randomness it doesn’t seem to alter the seed. It’s a bit of a organizational headache since I want these new loops to be up top but I’ll make due for now.

Hi Baggy,

Sounds like what you are after is ‘current_random_seed’,

This can be set via the fns use_random_seed and with_random_seed.
It is incremented every time you use the random number generator via
fns such as choose and rand.’

Although I’ve a feeling when a buffer starts, isn’t the random
seed = 0?

Perhaps Robin or Sam know better…

Anyways… put it as the first line of your code and see what
you come up with…

Try this

a = current_random_seed
puts rand
puts '============================='
puts rand
puts rand
puts rand
puts '============================='
puts 'Recovering nice random number'
puts '============================='
use_random_seed a
puts rand
puts '============================='          

Eli…

Thanks. You were right about the random seed being zero. Thats what I suspected too originally. Funnily enough I can’t reproduce this issue I was having before. Now when I add live loops earlier in the code it has no effect on the randomized sequence. I must have been doing something wrong but I have no idea what it could be as I was doing nothing that would have changed the seed from zero… Either way the problem is solved and its good to know about “current_random_seed” since it may come in handy later.

1 Like

#…gypsy…

mn=[];for jn in 1…1024
mn[jn]=hz_to_midi(11*jn)
end; mn[0]=:r

c=[5,6,9,5, 5,6,9,9, 5,6,9,5, 8,9,5,5,
8,5,9,9, 8,5,9,9, 8,5,9,9, 8,9]
m=[2,3,4,5]; o=[1,2,4]
rv=[2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1]
dm=[1,0,0,0,4,0,0,0,1,0,0,0,2,0,2,0]

sn=[ :fm, :pluck, :pretty_bell]
pn=[ 0.0, 1.0, -1.0 ]
lv=[ 1.0, 2, 1 ]
rl=[ 1.0, 1.0, 0.3 ]

use_bpm 110
live_loop :voice1 do
for x in 0…29; for y in 0…3; r=rand_i(3)
synth sn[r], note: mn[c[x]*m[y]*o[r]]-12,
pan: pn[r], release: rl[r], amp: lv[r]
sleep 0.5; end; end; end

use_bpm 55
live_loop :pad do
for x in 0…29
synth :dsaw, note: mn[c[x]]+12, detune: 7, sustain: 1,
release: 0, amp: 0.15
sleep 1; end; end

use_bpm 440
live_loop :percussion do
for x in 0…15;
synth :beep, note: mn[24*dm[x]], release: 0.2
synth :noise, note:127, release: 0.1,
amp: rv[x]/3.0
sleep 1; end; end