Only set parameter values on safe mode when needed
Otherwise this resets the filters every time.
This commit is contained in:
parent
035e345e21
commit
d7acd6573a
|
@ -146,33 +146,32 @@ impl SafeModeClamper {
|
||||||
/// CLamp the parameter values to the restricted range when enabling safe mode. This assumes
|
/// CLamp the parameter values to the restricted range when enabling safe mode. This assumes
|
||||||
/// there's no active automation gesture for these parameters.
|
/// there's no active automation gesture for these parameters.
|
||||||
fn restrict_range(&self, cx: &mut EventContext) {
|
fn restrict_range(&self, cx: &mut EventContext) {
|
||||||
cx.emit(ParamEvent::BeginSetParameter(&self.params.filter_stages).upcast());
|
let filter_stages = self.params.filter_stages.unmodulated_plain_value();
|
||||||
cx.emit(
|
let clamped_filter_stages = filter_stages.clamp(
|
||||||
ParamEvent::SetParameter(
|
params::FILTER_STAGES_RESTRICTED_MIN,
|
||||||
&self.params.filter_stages,
|
params::FILTER_STAGES_RESTRICTED_MAX,
|
||||||
self.params.filter_stages.unmodulated_plain_value().clamp(
|
|
||||||
params::FILTER_STAGES_RESTRICTED_MIN,
|
|
||||||
params::FILTER_STAGES_RESTRICTED_MAX,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.upcast(),
|
|
||||||
);
|
);
|
||||||
cx.emit(ParamEvent::EndSetParameter(&self.params.filter_stages).upcast());
|
if clamped_filter_stages != filter_stages {
|
||||||
|
cx.emit(ParamEvent::BeginSetParameter(&self.params.filter_stages).upcast());
|
||||||
|
cx.emit(
|
||||||
|
ParamEvent::SetParameter(&self.params.filter_stages, clamped_filter_stages)
|
||||||
|
.upcast(),
|
||||||
|
);
|
||||||
|
cx.emit(ParamEvent::EndSetParameter(&self.params.filter_stages).upcast());
|
||||||
|
}
|
||||||
|
|
||||||
cx.emit(ParamEvent::BeginSetParameter(&self.params.filter_frequency).upcast());
|
let filter_frequency = self.params.filter_frequency.unmodulated_plain_value();
|
||||||
cx.emit(
|
let clamped_filter_frequency = filter_frequency.clamp(
|
||||||
ParamEvent::SetParameter(
|
params::FILTER_FREQUENCY_RESTRICTED_MIN,
|
||||||
&self.params.filter_frequency,
|
params::FILTER_FREQUENCY_RESTRICTED_MAX,
|
||||||
self.params
|
|
||||||
.filter_frequency
|
|
||||||
.unmodulated_plain_value()
|
|
||||||
.clamp(
|
|
||||||
params::FILTER_FREQUENCY_RESTRICTED_MIN,
|
|
||||||
params::FILTER_FREQUENCY_RESTRICTED_MAX,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.upcast(),
|
|
||||||
);
|
);
|
||||||
cx.emit(ParamEvent::EndSetParameter(&self.params.filter_frequency).upcast());
|
if clamped_filter_frequency != filter_frequency {
|
||||||
|
cx.emit(ParamEvent::BeginSetParameter(&self.params.filter_frequency).upcast());
|
||||||
|
cx.emit(
|
||||||
|
ParamEvent::SetParameter(&self.params.filter_frequency, clamped_filter_frequency)
|
||||||
|
.upcast(),
|
||||||
|
);
|
||||||
|
cx.emit(ParamEvent::EndSetParameter(&self.params.filter_frequency).upcast());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue