aboutsummaryrefslogtreecommitdiff
path: root/sonics/array_tools.udo
blob: 69ea2b96cfd2d4a4a184f8f9faa7b108aecc8929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef UDO_ARRAYTOOLS
#define UDO_ARRAYTOOLS ##
/*
	Array tools
	Slim excerpt for Partial Emergence

	This file is part of the SONICS UDO collection by Richard Knight 2021
		License: GPL-2.0-or-later
		http://1bpm.net
*/


/*
	Get a random value from an array

	ivalue arr_random iarray[]

	ivalue		selected value
	iarray[]	array to evaluate
*/
opcode arr_random, i, i[]
	iarray[] xin
	ivalue = iarray[round(random(0, lenarray(iarray) - 1))]
	xout ivalue
endop

#end