Skip to content

Sampler

WiredSound edited this page Jan 21, 2022 · 1 revision

The role of the sampler is to take a directed acyclic graph-representation of a namespace and from it produce pseudorandom output data. This process is driven primarily by the Generator trait which is implemented by the core Graph enum as well as various other helper structures that make up the DAG. A generator (as in a structue that implements the Generator trait - this is different to what are referred to as 'generators' in the user documentation) is a stateful stream that uses randomess produced by some peusdorandom number generator (i.e. a type implementing the Rng trait of the rand crate) to produce a sequence of values of some type.

The sampling process begins by calling the Graph::aggregate method which essentially prepares the DAG to be consumed while collecting all its generated values. Next it is traversed until it enters a 'complete' state (GeneratorState::Complete) by repeatedly calling Generator::next. This will yield a nested Value instance which is an abstract representation of Synth-generated data that is independent of any specific export/import strategy.

Clone this wiki locally