refactor~(core): use traits and structs for interpolation

We have to now pass the interpolation method as a generic argument to methods.
This commit is contained in:
Anand Balakrishnan 2023-06-07 09:57:56 -04:00
parent 2b16ef9c40
commit 87afc11b90
No known key found for this signature in database
8 changed files with 314 additions and 306 deletions

View file

@ -3,12 +3,13 @@ use core::time::Duration;
use itertools::Itertools;
use super::traits::LinearInterpolatable;
use super::interpolation::Linear;
use super::{InterpolationMethod, Signal};
impl<T> Signal<T>
where
T: Copy + LinearInterpolatable,
T: Copy,
Linear: InterpolationMethod<T>,
{
/// Shift all samples in the signal by `delta` amount to the left.
///
@ -34,7 +35,7 @@ where
if idx > 0 && first_t != &delta {
// The shifted signal will not start at 0, and we have a previous
// index to interpolate from.
let v = self.interpolate_at(delta, InterpolationMethod::Linear).unwrap();
let v = self.interpolate_at::<Linear>(delta).unwrap();
new_samples.push((Duration::ZERO, v));
}
// Shift the rest of the samples