pub struct PatternMutatorConfig {
pub operations: Vec<MutationOp>,
pub amount: u8,
pub seed: u64,
pub locks: PatternLockSet,
}Expand description
Configuration describing a sequence of pattern mutations and their controls.
Fields§
§operations: Vec<MutationOp>Operations applied in order.
amount: u8Strength of each operation, from 0 to 100.
seed: u64Seed for the deterministic pseudo-random generator.
locks: PatternLockSetSource notes held fixed across all operations.
Implementations§
Source§impl PatternMutatorConfig
impl PatternMutatorConfig
Sourcepub fn new(operations: Vec<MutationOp>) -> Self
pub fn new(operations: Vec<MutationOp>) -> Self
Builds a config from operations with default amount, seed, and locks.
Sourcepub fn with_amount(self, amount: u8) -> Self
pub fn with_amount(self, amount: u8) -> Self
Sets the mutation strength, clamped to at most 100.
Sourcepub fn with_locks(self, locks: PatternLockSet) -> Self
pub fn with_locks(self, locks: PatternLockSet) -> Self
Sets the locked note set.
Sourcepub fn apply(&self, object: &dyn MusicObject) -> Result<Music, TransformError>
pub fn apply(&self, object: &dyn MusicObject) -> Result<Music, TransformError>
Applies the configured mutations to the input and returns the result.
Sourcepub fn from_wire(value: &str) -> Result<Self, PatternMutatorError>
pub fn from_wire(value: &str) -> Result<Self, PatternMutatorError>
Parses a config from its wire string, validating each field.
§Examples
use sim_lib_music_transform::{MutationOp, PatternMutatorConfig};
let config = PatternMutatorConfig::new(vec![MutationOp::Reverse]).with_amount(80);
let wire = config.to_wire();
assert_eq!(PatternMutatorConfig::from_wire(&wire), Ok(config));Trait Implementations§
Source§impl Clone for PatternMutatorConfig
impl Clone for PatternMutatorConfig
Source§fn clone(&self) -> PatternMutatorConfig
fn clone(&self) -> PatternMutatorConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PatternMutatorConfig
impl Debug for PatternMutatorConfig
impl Eq for PatternMutatorConfig
Source§impl PartialEq for PatternMutatorConfig
impl PartialEq for PatternMutatorConfig
impl StructuralPartialEq for PatternMutatorConfig
Auto Trait Implementations§
impl Freeze for PatternMutatorConfig
impl RefUnwindSafe for PatternMutatorConfig
impl Send for PatternMutatorConfig
impl Sync for PatternMutatorConfig
impl Unpin for PatternMutatorConfig
impl UnsafeUnpin for PatternMutatorConfig
impl UnwindSafe for PatternMutatorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more