#[derive(Debug, Clone)]
pub struct StrainConstants {
pub constant_variables: Vec<ConstantVariable>,
}
impl StrainConstants {
pub fn new_constant(&mut self, name: String, value: f32) -> f32 {
let const_var = ConstantVariable::new(name, value);
self.constant_variables.push(const_var);
value
}
pub fn get_info_from_variables(&self) -> String {
self.constant_variables
.iter()
.map(|var| var.get_variable_info())
.collect::<Vec<_>>()
.join("\n")
}
pub fn new(constant_variables: Option<Vec<ConstantVariable>>) -> Self {
Self {
constant_variables: constant_variables.unwrap_or_default(),
}
}
}
#[derive(Debug, Clone)]
pub struct StrainConstantsKeys {
pub base: StrainConstants,
pub ln_end_threshold_ms: f32,
pub chord_clump_tolerance_ms: f32,
pub graph_interval_size_ms: i32,
pub graph_interval_offset_ms: i32,
pub s_jack_lower_boundary_ms: f32,
pub s_jack_upper_boundary_ms: f32,
pub s_jack_max_strain_value: f32,
pub s_jack_curve_exponential: f32,
pub t_jack_lower_boundary_ms: f32,
pub t_jack_upper_boundary_ms: f32,
pub t_jack_max_strain_value: f32,
pub t_jack_curve_exponential: f32,
pub roll_lower_boundary_ms: f32,
pub roll_upper_boundary_ms: f32,
pub roll_max_strain_value: f32,
pub roll_curve_exponential: f32,
pub bracket_lower_boundary_ms: f32,
pub bracket_upper_boundary_ms: f32,
pub bracket_max_strain_value: f32,
pub bracket_curve_exponential: f32,
pub roll_ratio_tolerance_ms: f32,
pub roll_ratio_multiplier: f32,
pub roll_max_length: f32,
pub roll_length_multiplier: f32,
pub vibro_action_duration_ms: f32,
pub vibro_action_tolerance_ms: f32,
pub vibro_multiplier: f32,
pub vibro_max_length: f32,
pub vibro_length_multiplier: f32,
pub ln_layer_threshold_ms: f32,
pub ln_layer_tolerance_ms: f32,
pub ln_base_multiplier: f32,
pub ln_release_after_multiplier: f32,
pub ln_release_before_multiplier: f32,
pub ln_tap_multiplier: f32,
}
impl StrainConstantsKeys {
pub fn new() -> Self {
let mut base = StrainConstants::new(None);
Self {
base: base.clone(),
ln_end_threshold_ms: 42.0,
chord_clump_tolerance_ms: 8.0,
graph_interval_size_ms: 500,
graph_interval_offset_ms: 100,
s_jack_lower_boundary_ms: base.new_constant("SJackLowerBoundaryMs".to_string(), 40.0),
s_jack_upper_boundary_ms: base.new_constant("SJackUpperBoundaryMs".to_string(), 320.0),
s_jack_max_strain_value: base.new_constant("SJackMaxStrainValue".to_string(), 68.0),
s_jack_curve_exponential: base.new_constant("SJackCurveExponential".to_string(), 1.17),
t_jack_lower_boundary_ms: base.new_constant("TJackLowerBoundaryMs".to_string(), 40.0),
t_jack_upper_boundary_ms: base.new_constant("TJackUpperBoundaryMs".to_string(), 330.0),
t_jack_max_strain_value: base.new_constant("TJackMaxStrainValue".to_string(), 70.0),
t_jack_curve_exponential: base.new_constant("TJackCurveExponential".to_string(), 1.14),
roll_lower_boundary_ms: base.new_constant("RollLowerBoundaryMs".to_string(), 30.0),
roll_upper_boundary_ms: base.new_constant("RollUpperBoundaryMs".to_string(), 230.0),
roll_max_strain_value: base.new_constant("RollMaxStrainValue".to_string(), 55.0),
roll_curve_exponential: base.new_constant("RollCurveExponential".to_string(), 1.13),
bracket_lower_boundary_ms: base.new_constant("BracketLowerBoundaryMs".to_string(), 30.0),
bracket_upper_boundary_ms: base.new_constant("BracketUpperBoundaryMs".to_string(), 230.0),
bracket_max_strain_value: base.new_constant("BracketMaxStrainValue".to_string(), 56.0),
bracket_curve_exponential: base.new_constant("BracketCurveExponential".to_string(), 1.13),
ln_base_multiplier: base.new_constant("LnBaseMultiplier".to_string(), 0.6),
ln_layer_tolerance_ms: base.new_constant("LnLayerToleranceMs".to_string(), 60.0),
ln_layer_threshold_ms: base.new_constant("LnLayerThresholdMs".to_string(), 93.7),
ln_release_after_multiplier: base.new_constant("LnReleaseAfterMultiplier".to_string(), 1.0),
ln_release_before_multiplier: base.new_constant("LnReleaseBeforeMultiplier".to_string(), 1.3),
ln_tap_multiplier: base.new_constant("LnTapMultiplier".to_string(), 1.05),
vibro_action_duration_ms: base.new_constant("VibroActionDurationMs".to_string(), 88.2),
vibro_action_tolerance_ms: base.new_constant("VibroActionToleranceMs".to_string(), 88.2),
vibro_multiplier: base.new_constant("VibroMultiplier".to_string(), 0.75),
vibro_length_multiplier: base.new_constant("VibroLengthMultiplier".to_string(), 0.3),
vibro_max_length: base.new_constant("VibroMaxLength".to_string(), 6.0),
roll_ratio_tolerance_ms: base.new_constant("RollRatioToleranceMs".to_string(), 2.0),
roll_ratio_multiplier: base.new_constant("RollRatioMultiplier".to_string(), 0.25),
roll_length_multiplier: base.new_constant("RollLengthMultiplier".to_string(), 0.6),
roll_max_length: base.new_constant("RollMaxLength".to_string(), 14.0),
}
}
}
#[derive(Debug, Clone)]
pub struct ConstantVariable {
pub name: String,
pub value: f32,
}
impl ConstantVariable {
pub fn new(name: String, value: f32) -> Self {
Self { name, value }
}
pub fn get_variable_info(&self) -> String {
format!("{} = {}", self.name, self.value)
}
}