shady_audio/interpolation/
mod.rs

1//! Everything related to the interpolation calculation.
2
3mod context;
4mod cubic_spline;
5mod linear;
6mod nothing;
7
8use std::slice::IterMut;
9
10pub use cubic_spline::CubicSplineInterpolation;
11pub use linear::LinearInterpolation;
12pub use nothing::NothingInterpolation;
13
14pub trait Interpolater {
15    fn interpolate(&mut self, buffer: &mut [f32]);
16
17    fn supporting_points_mut(&mut self) -> IterMut<'_, SupportingPoint>;
18}
19
20pub trait InterpolationInner: Interpolater + Sized {
21    fn new(supporting_points: impl IntoIterator<Item = SupportingPoint>) -> Self;
22
23    fn boxed(supporting_points: impl IntoIterator<Item = SupportingPoint>) -> Box<Self> {
24        Box::new(Self::new(supporting_points))
25    }
26}
27
28#[derive(Debug, Clone, PartialEq)]
29pub struct SupportingPoint {
30    /// The x value of the supporting point
31    pub x: usize,
32
33    /// The y value of the supporting point
34    pub y: f32,
35}
36
37#[derive(Debug, Clone, PartialEq, Eq)]
38struct InterpolationSection {
39    // assuming the supporting points are stored in an indexable data structure.
40    // The attribute stores the index of the supporting point within the data sturcture.
41    pub left_supporting_point_idx: usize,
42
43    /// the amount of points which need to be interpolated
44    /// within this section (up to the next supporting point)
45    pub amount: usize,
46}