Skip to main content

DspSample

Trait DspSample 

Source
pub trait DspSample:
    Copy
    + Default
    + PartialEq
    + PartialOrd
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Neg<Output = Self> {
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn sat_add(self, rhs: Self) -> Self;
    fn sat_sub(self, rhs: Self) -> Self;
    fn sat_mul(self, rhs: Self) -> Self;
    fn sat_div(self, rhs: Self) -> Self;
    fn abs_val(self) -> Self;
    fn to_f32(self) -> f32;
    fn from_f32(val: f32) -> Self;
}
Expand description

Unified numerical sample trait implemented for floating-point sample types.

Enables writing generic filters, delay lines, oscillators, and processing blocks that operate seamlessly with f32 and f64.

Required Associated Constants§

Source

const ZERO: Self

Additive identity (0.0).

Source

const ONE: Self

Multiplicative identity or normalized unity (1.0).

Required Methods§

Source

fn sat_add(self, rhs: Self) -> Self

Saturating addition.

Source

fn sat_sub(self, rhs: Self) -> Self

Saturating subtraction.

Source

fn sat_mul(self, rhs: Self) -> Self

Saturating multiplication.

Source

fn sat_div(self, rhs: Self) -> Self

Saturating division.

Source

fn abs_val(self) -> Self

Absolute value.

Source

fn to_f32(self) -> f32

Convert to floating-point f32.

Source

fn from_f32(val: f32) -> Self

Convert from floating-point f32.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DspSample for f32

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn sat_add(self, rhs: Self) -> Self

Source§

fn sat_sub(self, rhs: Self) -> Self

Source§

fn sat_mul(self, rhs: Self) -> Self

Source§

fn sat_div(self, rhs: Self) -> Self

Source§

fn abs_val(self) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn from_f32(val: f32) -> Self

Source§

impl DspSample for f64

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn sat_add(self, rhs: Self) -> Self

Source§

fn sat_sub(self, rhs: Self) -> Self

Source§

fn sat_mul(self, rhs: Self) -> Self

Source§

fn sat_div(self, rhs: Self) -> Self

Source§

fn abs_val(self) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn from_f32(val: f32) -> Self

Implementors§

Source§

impl DspSample for q15

Source§

const ZERO: Self = Self::ZERO

Source§

const ONE: Self = Self::MAX

Source§

impl DspSample for q31

Source§

const ZERO: Self = Self::ZERO

Source§

const ONE: Self = Self::MAX