Tone.CtrlMarkov

↳ EXTENDS Tone

Tone.CtrlMarkov represents a Markov Chain where each call to Tone.CtrlMarkov.next will move to the next state. If the next state choice is an array, the next state is chosen randomly with even probability for all of the choices. For a weighted probability of the next choices, pass in an object with “state” and “probability” attributes. The probabilities will be normalized and then chosen. If no next options are given for the current state, the state will stay there.

CONSTRUCTOR

new Tone.CtrlMarkov (
values
)
values

An object with the state names as the keys and the next state(s) as the values.

type: Object

EXAMPLE

var chain = new Tone.CtrlMarkov({
	"beginning" : ["end", "middle"],
	"middle" : "end"
});
chain.value = "beginning";
chain.next(); //returns "end" or "middle" with 50% probability

 

EXAMPLE

var chain = new Tone.CtrlMarkov({
	"beginning" : [{"value" : "end", "probability" : 0.8}, 
					{"value" : "middle", "probability" : 0.2}],
	"middle" : "end"
});
chain.value = "beginning";
chain.next(); //returns "end" with 80% probability or "middle" with 20%.
 

Members

.value

String #

The current state of the Markov values. The next state will be evaluated and returned when Tone.CtrlMarkov.next is invoked.

</>

.values

Object #

The Markov values with states as the keys and next state(s) as the values.

</>

Methods

.dispose ( )

#
↪ returns Tone.CtrlMarkov

this

Clean up

</>

.next ( )

#
↪ returns String

Returns the next state of the Markov values.

</>
docs generated Sep 15 2019