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 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.
Required Methods
fn lerp(first: Self, second: Self, numerator: u32, denominator: u32) -> Self
Linear interpolation between two samples.
The result should be equal to
first * numerator / denominator + second * (1 - numerator / denominator)
.
fn amplify(self, value: f32) -> Self
Multiplies the value of this sample by the given amount.
fn zero_value() -> Self
Returns the value corresponding to the absence of sound.
fn to_i16(&self) -> i16
Converts this sample into a standard i16 sample.
fn to_u16(&self) -> u16
Converts this sample into a standard u16 sample.
fn to_f32(&self) -> f32
Converts this sample into a standard f32 sample.
fn from<S>(&S) -> Self where S: Sample
Converts any sample type to this one by calling to_i16
, to_u16
or to_f32
.