Trait sample::Sample
[−]
[src]
pub trait Sample: Copy + Clone + Default + Debug + PartialOrd + PartialEq + Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + Rem<Output=Self> { fn from_wave(Wave) -> Self; fn to_wave(self) -> Wave; fn sample_format(&self) -> Format; fn format<S: Sample>() -> Format { ... } fn mul_amp(self, amp: f32) -> Self { ... } fn from_sample<S: Sample>(sample: S) -> Self { ... } fn to_sample<S: Sample>(self) -> S { ... } fn zero() -> Self { ... } fn add_buffers(output: &mut [Self], working: &[Self], vol_per_channel: &[Amplitude]) { ... } fn zero_buffer(buffer: &mut [Self]) { ... } }
A trait for working generically across different sample types.
Required Methods
fn from_wave(Wave) -> Self
Construct a sample from a wave sample between -1. and 1.
fn to_wave(self) -> Wave
Convert to a wave sample between -1. and 1.
fn sample_format(&self) -> Format
Return the sample format as a method.
Provided Methods
fn format<S: Sample>() -> Format
Return the format of the sample.
fn mul_amp(self, amp: f32) -> Self
Multiply by a given amplitude.
fn from_sample<S: Sample>(sample: S) -> Self
Construct a sample from an arbitrary Sample type.
fn to_sample<S: Sample>(self) -> S
Construct an arbitrary sample type from a sample of this Self type.
fn zero() -> Self
A silent sample.
fn add_buffers(output: &mut [Self], working: &[Self], vol_per_channel: &[Amplitude])
Sum the working buffer onto the output buffer after multiplying it by volume per channel.
fn zero_buffer(buffer: &mut [Self])
Zero a given buffer of samples.