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 POLYSTAR_POINTS: Self =
25 Self::new(crate::MIN_POLYSTAR_POINTS, crate::MAX_POLYSTAR_POINTS);
26
27 #[must_use]
29 pub const fn new(min: f32, max: f32) -> Self {
30 Self { min, max }
31 }
32
33 #[must_use]
35 pub fn contains(self, value: f32) -> bool {
36 value.is_finite() && self.min <= value && value <= self.max
37 }
38
39 #[must_use]
41 pub const fn clamp(self, value: f32) -> f32 {
42 value.clamp(self.min, self.max)
43 }
44}