rndpick
Returns an array of randomly selected items from from an array.
Syntax
Usage
rndpick returns an array, inum in length, of randomly selected items from the input array.
Each item is only selected once. The selection will not contain duplicates if inum is less than the length of the input array.
Outputs and arguments
i/koutArr[] -- output array
i/kinArr[] -- input array
i/kndx -- index from which to retrieve the item.
Example
See the example for
rndpick.orc
| rndpick |
|---|
| instr Sound101
;; Sound source
ares fmbell p4,p5,1,1,p6,p7,-1,-1,-1,-1,-1,p3
send ares
endin
patchsig "Sound101", "outs"
;; connect sound to output.
instr Sched14
idur = random:i(5,12)
ichrd[] genarray 0,14,2
;; generate some intervals
itriad[] rndpick ichrd, 3
;; select three random notes from ichrd, ensuring that no duplicate notes are selected.
chrdi fillarray_i(n("Sound101"),0,idur,0.6,0,random:i(0.1,0.466), random:i(3,7)), itriad,-3
;; play the chord
schedule p1, nextbeat(idur*0.7), 1
;; and around again
turnoff
endin
schedule "Sched14", nextbeat(1),1
;; start the show
|