Skip to main content

PatchGrammarPrior

Struct PatchGrammarPrior 

Source
pub struct PatchGrammarPrior {
    pub source_prob: f64,
    pub max_depth: usize,
    pub max_mod_depth: usize,
    pub source_weights: [f64; 7],
    pub op_weights: [f64; 20],
    pub mod_weights: [f64; 8],
}
Expand description

The typed PCFG over patch terms.

Fields§

§source_prob: f64

Probability that a node (below max depth) is a source leaf.

§max_depth: usize

Maximum tree depth; nodes at this depth are forced to be sources.

§max_mod_depth: usize

Maximum nesting depth of a modulation term: a term at this depth is forced to be a leaf, exactly as Self::max_depth forces #leaf.

This is the mod sort’s only parsimony pressure. The audio tree pays for its own size in prior mass because every extra node is another #leaf/#op draw; a modulation chain pays the same way, but nothing about the audio term’s mass objects to a forty-node CV chain that moves one knob, so the ceiling has to be explicit. 2 means a term may wrap at most two processors before it bottoms out in a leaf.

§source_weights: [f64; 7]

Weights over source kinds [Vco, Supersaw, Noise, Wavetable, Pluck, Formant, Silence].

§op_weights: [f64; 20]

Weights over processor kinds [Mix, Filter, Fold, Delay, Chorus, Reverb, Distortion, Bitcrush, Phaser, RingMod, Flanger, Tremolo, Vibrato, Eq, Granular, Shift, Comp, Duck, Gate, Vocoder].

§mod_weights: [f64; 8]

Weights over modulation kinds [None, Lfo, Env, Rand, Follow, Euclid, Op, Pair].

Implementations§

Source§

impl PatchGrammarPrior

Source

pub fn sample_with_rng<R: Rng>(&self, rng: &mut R) -> PatchTree

Draw a tree with a plain RNG (no trace) — the classic-layer sampler mirroring Self::model. Used by EvolutionaryGenome::generate.

Trait Implementations§

Source§

impl Clone for PatchGrammarPrior

Source§

fn clone(&self) -> PatchGrammarPrior

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PatchGrammarPrior

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PatchGrammarPrior

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GenomePrior for PatchGrammarPrior

Source§

type Genome = PatchTree

The genome type this prior generates.
Source§

fn model(&self) -> Model<PatchTree>

The generative program p(x).
§

fn trace_of(&self, genome: &Self::Genome) -> Trace

Encode a genome as a trace under this prior’s address scheme — the inverse direction of running [Self::model]. The default delegates to the genome’s canonical [TraceGenome::to_trace] encoding, which is correct whenever the prior samples exactly the canonical sites (all the vector priors here). Priors with their own generative scheme — e.g. ArithmeticGrammarPrior’s tree-path grammar — override this so that scoring, weighted traces, and chain warm-starts work for any genome the prior can express.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,