Trait rodio::Sample [] [src]

pub trait Sample: Sample {
    fn lerp(first: Self, second: Self, numerator: u32, denominator: u32) -> Self;
fn amplify(self, value: f32) -> Self;
fn saturating_add(self, other: Self) -> Self;
fn zero_value() -> Self;
fn to_i16(&self) -> i16;
fn to_u16(&self) -> u16;
fn to_f32(&self) -> f32;
fn from<S>(_: &S) -> Self
    where
        S: Sample
; }

Represents a value of a single sample.

This trait is implemented by default on three types: i16, u16 and f32.

  • For i16, silence corresponds to the value 0. The minimum and maximum amplitudes are represented by i16::min_value() and i16::max_value() respectively.
  • For u16, silence corresponds to the value u16::max_value() / 2. The minimum and maximum amplitudes are represented by 0 and u16::max_value() respectively.
  • For f32, silence corresponds to the value 0.0. The minimum and maximum amplitudes are represented by -1.0 and 1.0 respectively.

You can implement this trait on your own type as well if you wish so.

Required Methods

Linear interpolation between two samples.

The result should be equal to first * numerator / denominator + second * (1 - numerator / denominator).

Multiplies the value of this sample by the given amount.

Calls saturating_add on the sample.

Returns the value corresponding to the absence of sound.

Converts this sample into a standard i16 sample.

Converts this sample into a standard u16 sample.

Converts this sample into a standard f32 sample.

Converts any sample type to this one by calling to_i16, to_u16 or to_f32.

Implementors