pub struct Falloff { /* private fields */ }Expand description
Levels that rise at once and fall under gravity, as cava’s bars do:
a level that drops is not followed down at once, but falls faster and
faster, by g more each update, until it meets the
new level. Rises are followed at once. Keep one per view, and update it
once a frame with the new levels (bands).
use rich_ext::dsp::Falloff;
let mut bars = Falloff::gravity(0.1);
assert_eq!(bars.update(&[1.0]), [1.0]);
// Silence: down by 0.1, then 0.2, then 0.3 more, then at the floor.
assert_eq!(bars.update(&[0.0]), [0.9]);
assert!((bars.update(&[0.0])[0] - 0.7).abs() < 1e-12);
assert!((bars.update(&[0.0])[0] - 0.4).abs() < 1e-12);
assert_eq!(bars.update(&[0.0]), [0.0]);
// A rise is shown at once.
assert_eq!(bars.update(&[0.8]), [0.8]);Implementations§
Source§impl Falloff
impl Falloff
Sourcepub fn gravity(g: f64) -> Self
pub fn gravity(g: f64) -> Self
Levels falling g faster each update (in the levels’ units per
update, per update); 0 or less follows every drop at once.
Trait Implementations§
impl StructuralPartialEq for Falloff
Auto Trait Implementations§
impl Freeze for Falloff
impl RefUnwindSafe for Falloff
impl Send for Falloff
impl Sync for Falloff
impl Unpin for Falloff
impl UnsafeUnpin for Falloff
impl UnwindSafe for Falloff
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more