1
0
Fork 0

Add helper to compensate smoother for oversampling

This commit is contained in:
Robbert van der Helm 2022-09-25 17:37:25 +02:00
parent ccff4f1444
commit fae7050113

View file

@ -64,6 +64,18 @@ pub struct SmootherIter<'a, T: Smoothable> {
} }
impl SmoothingStyle { impl SmoothingStyle {
/// Utility function to modify the duration to compensate for an oversampling factor. When using
/// 4x oversampling, the duration needs to be four times as long to compensate for the four
/// times higher effective sample rate.
pub fn for_oversampling_factor(self, factor: f32) -> Self {
match self {
SmoothingStyle::None => SmoothingStyle::None,
SmoothingStyle::Linear(time) => SmoothingStyle::Linear(time * factor),
SmoothingStyle::Logarithmic(time) => SmoothingStyle::Logarithmic(time * factor),
SmoothingStyle::Exponential(time) => SmoothingStyle::Exponential(time * factor),
}
}
/// Compute the number of steps to reach the target value based on the sample rate and this /// Compute the number of steps to reach the target value based on the sample rate and this
/// smoothing style's duration. /// smoothing style's duration.
#[inline] #[inline]