Constructor
new Random()
Don't use. All functions in this class are static.
- Source:
Methods
(static) choice(choices)
Randomly yield one of the given values.
Parameters:
Name | Type | Description |
---|---|---|
choices |
Array | the values to randomly yield |
- Source:
(static) duration(options)
Randomly yield an integer suitable for durations values in a Rhythm.
First a random integer value between min
and max
is calculated, then it's multiplied by the multiplier
.
NOTE: Random durations are currently not supported by Harmony.durations or Rhythm.pattern.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
(static) intensity(options)
Randomly yield a floating point number suitable for intensity values in a Rhythm.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
(static) pitch(options)
Randomly yield an integer suitable for relative pitches in a Part.
The default min and max work well with 3-note chords when the part's mode is arpeggio
.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
(static) weightedChoice(choices, weights)
Randomly yield one of the given values with a probability distribution determined by the given weights.
Parameters:
Name | Type | Description |
---|---|---|
choices |
Array | the values to randomly yield |
weights |
Array | the relative weights for the corresponding values. |
- Source:
Example
weightedChoice([10,20,30], [1,2,1])
// 10 is yielded 25% of the time
// 20 is yielded 50% of the time
// 30 is yielded 25% of the time