Use linear gain params in gain examples

Using the new skewed coefficient calculation function for gain ranges
from a couple commits ago.

Closes #18.
This commit is contained in:
Robbert van der Helm
2022-07-24 21:21:13 +02:00
parent 6a1395e99a
commit fdbff129f8
4 changed files with 53 additions and 35 deletions

View File

@@ -48,17 +48,20 @@ impl Default for GainParams {
Self {
editor_state: EguiState::from_size(300, 180),
// See the main gain example for more details
gain: FloatParam::new(
"Gain",
0.0,
FloatRange::Linear {
min: -30.0,
max: 30.0,
util::db_to_gain(0.0),
FloatRange::Skewed {
min: util::db_to_gain(-30.0),
max: util::db_to_gain(30.0),
factor: FloatRange::gain_skew_factor(-30.0, 30.0),
},
)
.with_smoother(SmoothingStyle::Linear(50.0))
.with_step_size(0.01)
.with_unit(" dB"),
.with_smoother(SmoothingStyle::Logarithmic(50.0))
.with_unit(" dB")
.with_value_to_string(formatters::v2s_f32_gain_to_db(2))
.with_string_to_value(formatters::s2v_f32_gain_to_db()),
some_int: IntParam::new("Something", 3, IntRange::Linear { min: 0, max: 3 }),
}
}
@@ -169,7 +172,7 @@ impl Plugin for Gain {
let gain = self.params.gain.smoothed.next();
for sample in channel_samples {
*sample *= util::db_to_gain(gain);
*sample *= gain;
amplitude += *sample;
}