1#[derive(Copy, Clone, Debug, PartialEq)]
5pub struct Domain {
6 pub min: f32,
8 pub max: f32,
10}
11
12impl Domain {
13 pub const ANY: Self = Self::new(f32::NEG_INFINITY, f32::INFINITY);
15 pub const UNIT: Self = Self::new(0.0, 1.0);
17 pub const NON_NEGATIVE: Self = Self::new(0.0, f32::INFINITY);
19 pub const PAN: Self = Self::new(-1.0, 1.0);
21 pub const GAIN: Self = Self::new(0.0, crate::MAX_GAIN);
23 pub const POSITIVE: Self = Self::new(f32::from_bits(1), f32::INFINITY);
25 pub const EQ_FREQUENCY_HZ: Self = Self::new(
27 *crate::EQ_FREQUENCY_RANGE_HZ.start(),
28 *crate::EQ_FREQUENCY_RANGE_HZ.end(),
29 );
30 pub const EQ_Q: Self = Self::new(*crate::EQ_Q_RANGE.start(), *crate::EQ_Q_RANGE.end());
32 pub const EQ_GAIN_DB: Self = Self::new(-crate::MAX_EQ_GAIN_DB, crate::MAX_EQ_GAIN_DB);
34 pub const LEVEL_DB: Self = Self::new(crate::MIN_LEVEL_DB, 0.0);
36 pub const COMPRESSOR_RATIO: Self = Self::new(1.0, crate::MAX_COMPRESSOR_RATIO);
38 pub const KNEE_DB: Self = Self::new(0.0, crate::MAX_KNEE_DB);
40 pub const MAKEUP_DB: Self = Self::new(-crate::MAX_MAKEUP_DB, crate::MAX_MAKEUP_DB);
42 pub const EXPANDER_RANGE_DB: Self = Self::new(0.0, crate::MAX_EXPANDER_RANGE_DB);
44 pub const DELAY_FEEDBACK: Self = Self::new(0.0, crate::MAX_DELAY_FEEDBACK);
46 pub const MATRIX_GAIN: Self = Self::new(-crate::MAX_MATRIX_GAIN, crate::MAX_MATRIX_GAIN);
48 pub const POLYSTAR_POINTS: Self =
50 Self::new(crate::MIN_POLYSTAR_POINTS, crate::MAX_POLYSTAR_POINTS);
51
52 #[must_use]
54 pub const fn new(min: f32, max: f32) -> Self {
55 Self { min, max }
56 }
57
58 #[must_use]
60 pub fn contains(self, value: f32) -> bool {
61 value.is_finite() && self.min <= value && value <= self.max
62 }
63
64 #[must_use]
66 pub const fn clamp(self, value: f32) -> f32 {
67 value.clamp(self.min, self.max)
68 }
69}