pub trait DspType<T: DspFormatBase>: Copy + Default + Send + Add<Self, Output = Self> + Sub<Self, Output = Self> + PartialOrd {
const PI: Self;
const TAU: Self;
// Required methods
fn zero() -> Self;
fn one() -> Self;
fn dsp_saturating_add(self, rhs: Self) -> Self;
fn multiply(self, rhs: Self) -> Self;
fn divide_by_two(self) -> Self;
fn scale(self, rhs: T::Scalar) -> Self;
}
Expand description
A trait to simplify common operations on DSP Types. This is used to maximize the amount of code that can be agnostic to fixed and floating point
Required Associated Constants§
Required Methods§
sourcefn dsp_saturating_add(self, rhs: Self) -> Self
fn dsp_saturating_add(self, rhs: Self) -> Self
This function will perform a saturating addition for fixed-point types, and a normal addition for floating-point types
Used for when saturation is desired to avoid overflows, not correctness
sourcefn multiply(self, rhs: Self) -> Self
fn multiply(self, rhs: Self) -> Self
Multiply this type with itself. This trait does not provide any specified behavior for fixed-point overflow.
sourcefn divide_by_two(self) -> Self
fn divide_by_two(self) -> Self
Divide a value by two
Object Safety§
This trait is not object safe.