pub struct ConstantBufferStates<S> { /* private fields */ }
Expand description
Simple implementation of BufferStates
trait where every parameter is
constant throughout the whole buffer.
This is in general useful for testing or other scenarios where you need
to create a BufferStates
object outside of a Conformal wrapper.
Implementations§
Source§impl<S: States> ConstantBufferStates<S>
impl<S: States> ConstantBufferStates<S>
Sourcepub fn new(s: S) -> Self
pub fn new(s: S) -> Self
Create a new ConstantBufferStates
object from a States
object.
Source§impl ConstantBufferStates<StatesMap>
impl ConstantBufferStates<StatesMap>
Sourcepub fn new_override_defaults<'a, S: AsRef<str> + 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a,
overrides: &HashMap<&str, InternalValue>,
) -> Self
pub fn new_override_defaults<'a, S: AsRef<str> + 'a>( infos: impl IntoIterator<Item = InfoRef<'a, S>> + 'a, overrides: &HashMap<&str, InternalValue>, ) -> Self
Create a new ConstantBufferStates
object from a list of Info
s and override
s.
This creates a ConstantBufferStates
with all parameters set to default values
for the whole buffer.
Note that if you want to pass this into a synth, you should use
Self::new_override_synth_defaults
instead.
overrides
work exactly as in override_defaults
.
§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![("numeric", InternalValue::Numeric(0.5))].into_iter().collect();
let buffer_states = ConstantBufferStates::new_override_defaults(infos, &overrides);
match buffer_states.get_numeric("numeric") {
Some(NumericBufferState::Constant(0.5)) => (),
_ => panic!("Expected constant value of 0.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 ConstantBufferStates
object from a list of Info
s.
Each parameter in Info
s will be set to its default value for the whole buffer.
Note that if you want to pass this into a synth, you should use
Self::new_synth_defaults
instead.
§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 buffer_states = ConstantBufferStates::new_defaults(infos);
match buffer_states.get_numeric("numeric") {
Some(NumericBufferState::Constant(0.0)) => (),
_ => panic!("Expected constant value of 0.0"),
};
Sourcepub fn new_override_synth_defaults<'a, 'b: 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, &'b str>> + 'a,
overrides: &HashMap<&str, InternalValue>,
) -> Self
pub fn new_override_synth_defaults<'a, 'b: 'a>( infos: impl IntoIterator<Item = InfoRef<'a, &'b str>> + 'a, overrides: &HashMap<&str, InternalValue>, ) -> Self
Create a new ConstantBufferStates
object to pass to a synth from a list of Info
s and override
s.
This is similar to Self::new_override_defaults
, but it also includes the controller parameters
that are common to all synths. (crate::synth::CONTROLLER_PARAMETERS
).
Thus, this is more appropriate to use if you plan to pass the parameters to a synth.
§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)),
// Or you can override control parameters
(MOD_WHEEL_PARAMETER, InternalValue::Numeric(0.2)),
].into_iter().collect();
let buffer_states = ConstantBufferStates::new_override_synth_defaults(infos, &overrides);
// Overridden parameters get the values you passed in
match buffer_states.get_numeric("numeric") {
Some(NumericBufferState::Constant(0.5)) => (),
_ => panic!("Expected constant value of 0.5"),
};
match buffer_states.get_numeric(MOD_WHEEL_PARAMETER) {
Some(NumericBufferState::Constant(0.2)) => (),
_ => panic!("Expected constant value of 0.2"),
};
// Other parameters get their default values
match buffer_states.get_numeric(PITCH_BEND_PARAMETER) {
Some(NumericBufferState::Constant(0.0)) => (),
_ => panic!("Expected constant value of 0.0"),
};
Sourcepub fn new_synth_defaults<'a, 'b: 'a>(
infos: impl IntoIterator<Item = InfoRef<'a, &'b str>> + 'a,
) -> Self
pub fn new_synth_defaults<'a, 'b: 'a>( infos: impl IntoIterator<Item = InfoRef<'a, &'b str>> + 'a, ) -> Self
Create a new ConstantBufferStates
object to pass to a synth from a list of Info
s.
Each parameter in Info
s will be set to its default value for the whole buffer.
This is similar to Self::new_defaults
, but it also includes the controller parameters
that are common to all synths. (crate::synth::CONTROLLER_PARAMETERS
).
Thus, this is more appropriate to use if you plan to pass the parameters to a synth.
§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 buffer_states = ConstantBufferStates::new_synth_defaults(infos);
match buffer_states.get_numeric("numeric") {
Some(NumericBufferState::Constant(0.0)) => (),
_ => panic!("Expected constant value of 0.0"),
};
match buffer_states.get_numeric(MOD_WHEEL_PARAMETER) {
Some(NumericBufferState::Constant(0.0)) => (),
_ => panic!("Expected constant value of 0.0"),
};
Trait Implementations§
Source§impl<S: States> BufferStates for ConstantBufferStates<S>
impl<S: States> BufferStates for ConstantBufferStates<S>
Source§fn get_by_hash(
&self,
id_hash: IdHash,
) -> Option<BufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone, impl Iterator<Item = TimedValue<u32>> + Clone, impl Iterator<Item = TimedValue<bool>> + Clone>>
fn get_by_hash( &self, id_hash: IdHash, ) -> Option<BufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone, impl Iterator<Item = TimedValue<u32>> + Clone, impl Iterator<Item = TimedValue<bool>> + Clone>>
Source§fn get(
&self,
unique_id: &str,
) -> Option<BufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone, impl Iterator<Item = TimedValue<u32>> + Clone, impl Iterator<Item = TimedValue<bool>> + Clone>>
fn get( &self, unique_id: &str, ) -> Option<BufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone, impl Iterator<Item = TimedValue<u32>> + Clone, impl Iterator<Item = TimedValue<bool>> + Clone>>
Source§fn numeric_by_hash(
&self,
param_id: IdHash,
) -> Option<NumericBufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone>>
fn numeric_by_hash( &self, param_id: IdHash, ) -> Option<NumericBufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone>>
Source§fn get_numeric(
&self,
unique_id: &str,
) -> Option<NumericBufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone>>
fn get_numeric( &self, unique_id: &str, ) -> Option<NumericBufferState<impl Iterator<Item = PiecewiseLinearCurvePoint> + Clone>>
Source§fn enum_by_hash(
&self,
param_id: IdHash,
) -> Option<EnumBufferState<impl Iterator<Item = TimedValue<u32>> + Clone>>
fn enum_by_hash( &self, param_id: IdHash, ) -> Option<EnumBufferState<impl Iterator<Item = TimedValue<u32>> + Clone>>
Source§fn get_enum(
&self,
unique_id: &str,
) -> Option<EnumBufferState<impl Iterator<Item = TimedValue<u32>> + Clone>>
fn get_enum( &self, unique_id: &str, ) -> Option<EnumBufferState<impl Iterator<Item = TimedValue<u32>> + Clone>>
Source§fn switch_by_hash(
&self,
param_id: IdHash,
) -> Option<SwitchBufferState<impl Iterator<Item = TimedValue<bool>> + Clone>>
fn switch_by_hash( &self, param_id: IdHash, ) -> Option<SwitchBufferState<impl Iterator<Item = TimedValue<bool>> + Clone>>
Source§fn get_switch(
&self,
unique_id: &str,
) -> Option<SwitchBufferState<impl Iterator<Item = TimedValue<bool>> + Clone>>
fn get_switch( &self, unique_id: &str, ) -> Option<SwitchBufferState<impl Iterator<Item = TimedValue<bool>> + Clone>>
Source§impl<S: Clone> Clone for ConstantBufferStates<S>
impl<S: Clone> Clone for ConstantBufferStates<S>
Source§fn clone(&self) -> ConstantBufferStates<S>
fn clone(&self) -> ConstantBufferStates<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<S: Debug> Debug for ConstantBufferStates<S>
impl<S: Debug> Debug for ConstantBufferStates<S>
Source§impl<S: Default> Default for ConstantBufferStates<S>
impl<S: Default> Default for ConstantBufferStates<S>
Source§fn default() -> ConstantBufferStates<S>
fn default() -> ConstantBufferStates<S>
Auto Trait Implementations§
impl<S> Freeze for ConstantBufferStates<S>where
S: Freeze,
impl<S> RefUnwindSafe for ConstantBufferStates<S>where
S: RefUnwindSafe,
impl<S> Send for ConstantBufferStates<S>where
S: Send,
impl<S> Sync for ConstantBufferStates<S>where
S: Sync,
impl<S> Unpin for ConstantBufferStates<S>where
S: Unpin,
impl<S> UnwindSafe for ConstantBufferStates<S>where
S: UnwindSafe,
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