pub trait States {
// Required method
fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>;
// Provided methods
fn get(&self, unique_id: &str) -> Option<InternalValue> { ... }
fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32> { ... }
fn get_numeric(&self, unique_id: &str) -> Option<f32> { ... }
fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32> { ... }
fn get_enum(&self, unique_id: &str) -> Option<u32> { ... }
fn switch_by_hash(&self, id_hash: IdHash) -> Option<bool> { ... }
fn get_switch(&self, unique_id: &str) -> Option<bool> { ... }
}
Expand description
Represents a snapshot of all valid parameters at a given point in time.
We use this trait to provide information about parameters when we are
not processing a buffer (for that, we use BufferStates
).
This is passed into crate::synth::Synth::handle_events
and
crate::effect::Effect::handle_parameters
.
For convenience, we provide States::get_numeric
, States::get_enum
,
and States::get_switch
functions, which return the value of the parameter
if it is of the correct type, or None
otherwise.
Note that all parmeter types re-use the same ID
space, so only one of the
specialized get
methods will return a value for a given ParameterID
.
Note that in general, the Conformal wrapper will implement this trait
for you, but we provide a simple implementation called StatesMap
that’s appropriate to use in tests or other cases where you need to
create this trait outside of a Conformal wrapper.
Required Methods§
Sourcefn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
fn get_by_hash(&self, id_hash: IdHash) -> Option<InternalValue>
Get the current value of a parameter by it’s hashed unique ID.
You can get the hash of a unique ID using hash_id
.
If there is no parameter with the given ID, this will return None
.
Provided Methods§
Sourcefn get(&self, unique_id: &str) -> Option<InternalValue>
fn get(&self, unique_id: &str) -> Option<InternalValue>
Get the current value of a parameter by it’s unique ID.
If there is no parameter with the given ID, this will return None
.
Sourcefn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
fn numeric_by_hash(&self, id_hash: IdHash) -> Option<f32>
Get the current numeric value of a parameter by it’s hashed unique ID.
You can get the hash of a unique ID using hash_id
.
If the parameter is not present or is not numeric, this will return None
.
Sourcefn get_numeric(&self, unique_id: &str) -> Option<f32>
fn get_numeric(&self, unique_id: &str) -> Option<f32>
Get the current numeric value of a parameter by it’s unique ID.
If the parameter is not present or is not numeric, this will return None
.
Sourcefn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
fn enum_by_hash(&self, id_hash: IdHash) -> Option<u32>
Get the current enum value of a parameter by it’s hashed unique ID.
You can get the hash of a unique ID using hash_id
.
If the parameter is not present or is not an enum, this will return None
.
Sourcefn get_enum(&self, unique_id: &str) -> Option<u32>
fn get_enum(&self, unique_id: &str) -> Option<u32>
Get the current enum value of a parameter by it’s unique ID.
If the parameter is not present or is not an enum, this will return None
.
Sourcefn switch_by_hash(&self, id_hash: IdHash) -> Option<bool>
fn switch_by_hash(&self, id_hash: IdHash) -> Option<bool>
Get the current switch value of a parameter by it’s hashed unique ID.
You can get the hash of a unique ID using hash_id
.
If the parameter is not present or is not a switch, this will return None
.
Sourcefn get_switch(&self, unique_id: &str) -> Option<bool>
fn get_switch(&self, unique_id: &str) -> Option<bool>
Get the current switch value of a parameter by it’s unique ID.
If the parameter is not present or is not a switch, this will return None
.