plavno 0.4.0

A lightweight terminal music player for Linux, macOS and Windows with service waves and library shuffle
1
2
3
4
5
6
7
8
9
10
/// Exact critically damped spring step for a constant target.
pub fn advance(position: f32, velocity: f32, target: f32, omega: f32, dt: f32) -> (f32, f32) {
    let offset = position - target;
    let inertia = velocity + omega * offset;
    let decay = (-omega * dt).exp();
    (
        target + (offset + inertia * dt) * decay,
        (velocity - omega * inertia * dt) * decay,
    )
}