Skip to main content

Sample

Trait Sample 

Source
pub trait Sample:
    Copy
    + Send
    + Sync
    + 'static
    + Sealed {
    const ZERO: Self;
    const IS_F64: bool;

    // Required methods
    fn from_f32(value: f32) -> Self;
    fn to_f32(self) -> f32;
}
Expand description

Audio sample scalar — f32 or f64.

Implemented by f32 and f64 only. The bound exists so the crate::Plugin trait can be parameterised over precision without leaking the full numeric trait surface.

Required Associated Constants§

Source

const ZERO: Self

Zero value of this precision.

Source

const IS_F64: bool

Whether this sample type is f64. Lets format wrappers pick the processSetup::symbolicSampleSize field (VST3) or equivalent without runtime branching past the constant-fold.

Required Methods§

Source

fn from_f32(value: f32) -> Self

Widen a f32 to this precision (f32 → f32 is identity).

Source

fn to_f32(self) -> f32

Narrow to f32 for handing back to the host.

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 Sample for f32

Source§

const ZERO: Self = 0.0

Source§

const IS_F64: bool = false

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

impl Sample for f64

Source§

const ZERO: Self = 0.0

Source§

const IS_F64: bool = true

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Implementors§