I don't really understand how the rnd-function works! If I run the simple example from the manual I get always the same values, if I add lines to the score I get always the same value sequences. Its output is _not_ as shown in the manual. What does the comment mean in the manual behind the definition "(init- or control-rate only)"? If I put a k-rated variable into the argument, the compiler is complaining.
I wanted to write an intrument which reads randomly from a GEN02-table with 7 values for a sequencer indicating the steps in a major (or minor) scale (C-Major or C-Minor) with each score line. And if I say randomly I mean randomly and not always the same value sequence (Sorry, I'm a little bit frustrated, that basic functions do not work properly).



None of the random functions randomizes
Now I tried other random functions like rand or random and found out the value sequences are always the same. I think a revision of the random functions is absolutely necessary.
Try this...
I rather agree that the random-number opcodes leave something to be desired... (:-/) [Not to mention the associated documentation!]
Your basic problem is that none of the opcodes (except 'rand') allows any seeding of their random sequences, so that (by the nature of pseudo-random generators) they will spew out the same sequence for each run of the program. (Which actually could be what one wants sometimes.)
However, the 'rand' opcode does allow seeding, so you can probably kludge something up to use that. It only works at k-rate or faster, though, so you have to be a bit tricky. Here's a quickie example:
instr 1
krand init 1000 ; start out of range
if krand == 1000 then ;only get one random walue
krand rand 24, 1.1 ; couple of octaves up & down
koct = int(krand)/12 + 8.0 ; convert to oct around middle-C
endif
printk 0.2, koct ; for demonstration...
;.....
endin
HTH
Oops...
Well, you can ignore a lot of what I said in my previous comment -- except the bit about documentation!
A bit of further digging showed up the 'seed' opcode, which does set the seed value for all the randomization opcodes (except 'rnd' which is a function, not an opcode, and apparently does not use the seed value!).
Of course -- aside from the comment in the 'rnd' page that it does not use 'seed' -- I never found any reference to the opcode! [With even deeper digging, I find a note in "Random (Noise) Generators"... Sigh...]
So you can do what I did above much more simply by using 'seed' and 'linrand'. (On my system 'random' does not work, but it may on yours.)
seed 0 ; seed from the system clock
irand linrand 100 ; get a random number between 0..100
;... do what you want with it
print irand