wip audio synthesizer based on the rust crate cpal
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beeper/src/beep/hack.rs

18 lines
385 B

/// Work-around for `f32::clamp()` being unstable
pub(crate) trait StableClamp {
fn clamp_(self, min: f32, max: f32) -> f32;
}
impl StableClamp for f32 {
fn clamp_(self, min: f32, max: f32) -> f32 {
assert!(min <= max);
let mut x = self;
if x < min {
x = min;
}
if x > max {
x = max;
}
x
}
}