pub struct SynthStatesMap { /* private fields */ }Expand description
A simple implementation of SynthParamStates that is backed by a HashMap.
This is useful for testing or other places when you want to pass a SynthParamStates
to a component outside of a Conformal wrapper.
Implementations§
Source§impl SynthStatesMap
impl SynthStatesMap
Sourcepub fn new_override_defaults<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
overrides: &HashMap<&str, InternalValue>,
numeric_expression_overrides: &HashMap<NumericGlobalExpression, f32>,
switch_expression_overrides: &HashMap<SwitchGlobalExpression, bool>,
) -> Self
pub fn new_override_defaults<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, overrides: &HashMap<&str, InternalValue>, numeric_expression_overrides: &HashMap<NumericGlobalExpression, f32>, switch_expression_overrides: &HashMap<SwitchGlobalExpression, bool>, ) -> Self
Create a new SynthStatesMap to pass to a synth from a list of Infos and overrides.
This is similar to StatesMap::new_override_defaults, but it also includes expression controllers.
§Examples
let infos = vec![
StaticInfoRef {
title: "Numeric",
short_title: "Numeric",
unique_id: "numeric",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.0,
valid_range: 0.0..=1.0,
units: None,
},
},
];
let overrides = vec![
// You can override declared parameters
("numeric", InternalValue::Numeric(0.5)),
].into_iter().collect();
let numeric_expression_overrides = vec![
// Or you can override control parameters
(NumericGlobalExpression::ModWheel, 0.2),
].into_iter().collect();
let states = SynthStatesMap::new_override_defaults(infos.iter().cloned(), &overrides, &numeric_expression_overrides, &Default::default());
// Overridden parameters get the values you passed in
assert_eq!(states.get_numeric("numeric"), Some(0.5));
assert_eq!(states.get_numeric_global_expression(NumericGlobalExpression::ModWheel), 0.2);
// Other parameters get their default values
assert_eq!(states.get_numeric_global_expression(NumericGlobalExpression::PitchBend), 0.0);Sourcepub fn new_with_per_note<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
overrides: &HashMap<&str, InternalValue>,
numeric_expression_overrides: &HashMap<NumericGlobalExpression, f32>,
switch_expression_overrides: &HashMap<SwitchGlobalExpression, bool>,
per_note_expression_overrides: &HashMap<(NumericPerNoteExpression, NoteID), f32>,
) -> Self
pub fn new_with_per_note<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, overrides: &HashMap<&str, InternalValue>, numeric_expression_overrides: &HashMap<NumericGlobalExpression, f32>, switch_expression_overrides: &HashMap<SwitchGlobalExpression, bool>, per_note_expression_overrides: &HashMap<(NumericPerNoteExpression, NoteID), f32>, ) -> Self
Create a new SynthStatesMap with per-note expression overrides.
This is similar to Self::new_override_defaults, but also allows specifying
per-note expression values for specific notes.
§Examples
let infos = vec![
StaticInfoRef {
title: "Numeric",
short_title: "Numeric",
unique_id: "numeric",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.0,
valid_range: 0.0..=1.0,
units: None,
},
},
];
let note_id = NoteID::from_pitch(60);
let per_note_overrides = vec![
((NumericPerNoteExpression::PitchBend, note_id), 1.5),
].into_iter().collect();
let states = SynthStatesMap::new_with_per_note(
infos.iter().cloned(),
&Default::default(),
&Default::default(),
&Default::default(),
&per_note_overrides,
);
assert_eq!(states.get_numeric_expression_for_note(NumericPerNoteExpression::PitchBend, note_id), 1.5);Sourcepub fn new_defaults<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
) -> Self
pub fn new_defaults<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, ) -> Self
Create a new SynthStatesMap to pass to a synth from a list of Infos.
Each parameter in Infos will be set to its default value.
This is similar to StatesMap::new_defaults, but it also includes expression controllers.
§Examples
let infos = vec![
StaticInfoRef {
title: "Numeric",
short_title: "Numeric",
unique_id: "numeric",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.0,
valid_range: 0.0..=1.0,
units: None,
},
},
];
let states = SynthStatesMap::new_defaults(infos.iter().cloned());
assert_eq!(states.get_numeric("numeric"), Some(0.0));
// Controller parameters will also be included
assert_eq!(states.get_numeric_global_expression(NumericGlobalExpression::ModWheel), 0.0);Trait Implementations§
Source§impl Clone for SynthStatesMap
impl Clone for SynthStatesMap
Source§fn clone(&self) -> SynthStatesMap
fn clone(&self) -> SynthStatesMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SynthStatesMap
impl Debug for SynthStatesMap
Source§impl Default for SynthStatesMap
impl Default for SynthStatesMap
Source§fn default() -> SynthStatesMap
fn default() -> SynthStatesMap
Source§impl States for SynthStatesMap
impl States for SynthStatesMap
Source§fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
Source§fn get(&self, unique_id: &str) -> Option<InternalValue>
fn get(&self, unique_id: &str) -> Option<InternalValue>
Source§fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
Source§fn get_numeric(&self, unique_id: &str) -> Option<f32>
fn get_numeric(&self, unique_id: &str) -> Option<f32>
Source§fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
Source§fn get_enum(&self, unique_id: &str) -> Option<u32>
fn get_enum(&self, unique_id: &str) -> Option<u32>
Source§impl SynthParamStates for SynthStatesMap
impl SynthParamStates for SynthStatesMap
Source§fn get_numeric_global_expression(
&self,
expression: NumericGlobalExpression,
) -> f32
fn get_numeric_global_expression( &self, expression: NumericGlobalExpression, ) -> f32
Source§fn get_switch_global_expression(
&self,
expression: SwitchGlobalExpression,
) -> bool
fn get_switch_global_expression( &self, expression: SwitchGlobalExpression, ) -> bool
Source§fn get_numeric_expression_for_note(
&self,
expression: NumericPerNoteExpression,
note_id: NoteID,
) -> f32
fn get_numeric_expression_for_note( &self, expression: NumericPerNoteExpression, note_id: NoteID, ) -> f32
Auto Trait Implementations§
impl Freeze for SynthStatesMap
impl RefUnwindSafe for SynthStatesMap
impl Send for SynthStatesMap
impl Sync for SynthStatesMap
impl Unpin for SynthStatesMap
impl UnwindSafe for SynthStatesMap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more