1
0
Fork 0

Move Diopser filter stages range to a function

We'll use this in the safe mode abstraction to clamp the parameter's
range when safe mode is engaged.
This commit is contained in:
Robbert van der Helm 2022-11-22 18:20:36 +01:00
parent fc6fcf4cf5
commit dfd0109205

View file

@ -18,6 +18,14 @@ pub const MIN_AUTOMATION_STEP_SIZE: u32 = 1;
/// expensive, so updating them in larger steps can be useful. /// expensive, so updating them in larger steps can be useful.
pub const MAX_AUTOMATION_STEP_SIZE: u32 = 512; pub const MAX_AUTOMATION_STEP_SIZE: u32 = 512;
/// The filter stages parameter's range. Also used in the safe mode utilities.
pub fn filter_stages_range() -> IntRange {
IntRange::Linear {
min: 0,
max: MAX_NUM_FILTERS as i32,
}
}
/// The filter frequency parameter's range. Also used in the `SpectrumAnalyzer` widget. /// The filter frequency parameter's range. Also used in the `SpectrumAnalyzer` widget.
pub fn filter_frequency_range() -> FloatRange { pub fn filter_frequency_range() -> FloatRange {
FloatRange::Skewed { FloatRange::Skewed {
@ -117,18 +125,12 @@ impl DiopserParams {
.with_string_to_value(formatters::s2v_bool_bypass()) .with_string_to_value(formatters::s2v_bool_bypass())
.make_bypass(), .make_bypass(),
filter_stages: IntParam::new( filter_stages: IntParam::new("Filter Stages", 0, filter_stages_range()).with_callback(
"Filter Stages", {
0, let should_update_filters = should_update_filters.clone();
IntRange::Linear { Arc::new(move |_| should_update_filters.store(true, Ordering::Release))
min: 0,
max: MAX_NUM_FILTERS as i32,
}, },
) ),
.with_callback({
let should_update_filters = should_update_filters.clone();
Arc::new(move |_| should_update_filters.store(true, Ordering::Release))
}),
// Smoothed parameters don't need the callback as we can just look at whether the // Smoothed parameters don't need the callback as we can just look at whether the
// smoother is still smoothing // smoother is still smoothing