Trait dsp::Sample
[−]
pub trait Sample: Copy + Add<Self, Output=Self> + Sub<Self, Output=Self> + Mul<Self, Output=Self> + Div<Self, Output=Self> + Rem<Self, Output=Self> + PartialEq<Self> + PartialOrd<Self> + Clone + Default + Debug { fn from_wave(f32) -> Self; fn to_wave(self) -> f32; fn sample_format(&self) -> Format; fn format<S>() -> Format where S: Sample { ... } fn mul_amp(self, amp: f32) -> Self { ... } fn from_sample<S>(sample: S) -> Self where S: Sample { ... } fn to_sample<S>(self) -> S where S: Sample { ... } fn zero() -> Self { ... } fn add_buffer(target: &mut [Self], to_add: &[Self]) { ... } fn write_buffer(target: &mut [Self], to_write: &[Self]) { ... } fn add_buffer_with_amp_per_channel(target: &mut [Self], to_add: &[Self], amp_per_channel: &[f32]) { ... } fn zero_buffer(buffer: &mut [Self]) { ... } }
A trait for working generically across different sample types.
Required Methods
fn from_wave(f32) -> Self
Construct a sample from a wave sample between -1. and 1.
fn to_wave(self) -> f32
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>() -> Format where S: Sample
Return the format of the sample.
fn mul_amp(self, amp: f32) -> Self
Multiply by a given amplitude.
fn from_sample<S>(sample: S) -> Self where S: Sample
Construct a sample from an arbitrary Sample type.
fn to_sample<S>(self) -> S where S: Sample
Construct an arbitrary sample type from a sample of this Self type.
fn zero() -> Self
A silent sample.
fn add_buffer(target: &mut [Self], to_add: &[Self])
Sum the to_add
buffer onto the target
buffer.
fn write_buffer(target: &mut [Self], to_write: &[Self])
Write the to_write
buffer to the target
buffer.
fn add_buffer_with_amp_per_channel(target: &mut [Self], to_add: &[Self], amp_per_channel: &[f32])
Sum the working buffer onto the output buffer after multiplying it by amplitude per channel.
fn zero_buffer(buffer: &mut [Self])
Zero a given buffer of samples.