💥 Rework FloatParam and IntParam

They are now two separate types with slightly different options. I had
these merged initially because they're 95% the same, and I thought it
would be fun to have weird distributions for integer parameters, but
that doesn't really work because hosts and the plugin APIs expect the
steps to be linear. And if you're going to have an unstepped integer
parameter, might as well use FloatParam with rounding.

Because non-linear ranges are no longer possible with IntParam, the
types have been split up to make everything much more readable instead
of adding a parameterizing the range type with another type family.
This commit is contained in:
Robbert van der Helm
2022-03-03 19:24:40 +01:00
parent 006dcde313
commit 76369ad1e1
10 changed files with 459 additions and 389 deletions

View File

@@ -5,7 +5,7 @@ use nih_plug::{
formatters, util, Buffer, BufferConfig, BusConfig, ClapPlugin, Plugin, ProcessContext,
ProcessStatus, Vst3Plugin,
};
use nih_plug::{BoolParam, FloatParam, Params, Range, Smoother, SmoothingStyle};
use nih_plug::{BoolParam, FloatParam, FloatRange, Params, Smoother, SmoothingStyle};
use std::f32::consts;
use std::pin::Pin;
@@ -58,7 +58,7 @@ impl Default for SineParams {
gain: FloatParam::new(
"Gain",
-10.0,
Range::Linear {
FloatRange::Linear {
min: -30.0,
max: 0.0,
},
@@ -69,10 +69,10 @@ impl Default for SineParams {
frequency: FloatParam::new(
"Frequency",
420.0,
Range::Skewed {
FloatRange::Skewed {
min: 1.0,
max: 20_000.0,
factor: Range::skew_factor(-2.0),
factor: FloatRange::skew_factor(-2.0),
},
)
.with_smoother(SmoothingStyle::Linear(10.0))