Trait rodio::source::Source
[−]
[src]
pub trait Source: Iterator where Self::Item: Sample { fn get_current_frame_len(&self) -> Option<usize>; fn get_channels(&self) -> u16; fn get_samples_rate(&self) -> u32; fn get_total_duration(&self) -> Option<Duration>; fn buffered(self) -> Buffered<Self> where Self: Sized { ... } fn mix<S>(self, other: S) -> Mix<Self, S> where Self: Sized, S: Source, S::Item: Sample { ... } fn repeat_infinite(self) -> Repeat<Self> where Self: Sized { ... } fn take_duration(self, duration: Duration) -> TakeDuration<Self> where Self: Sized { ... } fn delay(self, duration: Duration) -> Delay<Self> where Self: Sized { ... } fn amplify(self, value: f32) -> Amplify<Self> where Self: Sized { ... } fn fade_in(self, duration: Duration) -> FadeIn<Self> where Self: Sized { ... } fn speed(self, ratio: f32) -> Speed<Self> where Self: Sized { ... } fn reverb(self, duration: Duration, amplitude: f32) -> Mix<Self, Delay<Amplify<Self>>> where Self: Sized + Clone { ... } }
A source of samples.
Required Methods
fn get_current_frame_len(&self) -> Option<usize>
Returns the number of samples before the current channel ends. None
means "infinite".
Should never return 0 unless there's no more data.
After the engine has finished reading the specified number of samples, it will assume that
the value of get_channels()
and/or get_samples_rate()
have changed.
fn get_channels(&self) -> u16
Returns the number of channels. Channels are always interleaved.
fn get_samples_rate(&self) -> u32
Returns the rate at which the source should be played.
fn get_total_duration(&self) -> Option<Duration>
Returns the total duration of this source, if known.
None
indicates at the same time "infinite" or "unknown".
Provided Methods
fn buffered(self) -> Buffered<Self> where Self: Sized
Stores the source in a buffer in addition to returning it. This iterator can be cloned.
fn mix<S>(self, other: S) -> Mix<Self, S> where Self: Sized, S: Source, S::Item: Sample
Mixes this source with another one.
fn repeat_infinite(self) -> Repeat<Self> where Self: Sized
Repeats this source forever.
Note that this works by storing the data in a buffer, so the amount of memory used is proportional to the size of the sound.
fn take_duration(self, duration: Duration) -> TakeDuration<Self> where Self: Sized
Takes a certain duration of this source and then stops.
fn delay(self, duration: Duration) -> Delay<Self> where Self: Sized
Delays the sound by a certain duration.
The rate and channels of the silence will use the same format as the first frame of the source.
fn amplify(self, value: f32) -> Amplify<Self> where Self: Sized
Amplifies the sound by the given value.
fn fade_in(self, duration: Duration) -> FadeIn<Self> where Self: Sized
Fades in the sound.
fn speed(self, ratio: f32) -> Speed<Self> where Self: Sized
Changes the play speed of the sound. Does not adjust the samples, only the play speed.
fn reverb(self, duration: Duration, amplitude: f32) -> Mix<Self, Delay<Amplify<Self>>> where Self: Sized + Clone
Adds a basic reverb effect.
This function requires the source to implement Clone
. This can be done by using
buffered()
.
Example
use std::time::Duration; let source = source.buffered().reverb(Duration::from_millis(100), 0.7);
Implementors
impl<R> Source for Decoder<R> where R: Read + Seek
impl<I> Source for Amplify<I> where I: Source, I::Item: Sample
impl<I> Source for Buffered<I> where I: Source, I::Item: Sample
impl<I> Source for Delay<I> where I: Iterator + Source, I::Item: Sample
impl<I> Source for FadeIn<I> where I: Source, I::Item: Sample
impl<I1, I2> Source for Mix<I1, I2> where I1: Source, I1::Item: Sample, I2: Source, I2::Item: Sample
impl<I> Source for Repeat<I> where I: Iterator + Source, I::Item: Sample
impl Source for SineWave
impl<I> Source for Speed<I> where I: Source, I::Item: Sample
impl<I> Source for TakeDuration<I> where I: Iterator + Source, I::Item: Sample
impl<I, D> Source for UniformSourceIterator<I, D> where I: Iterator + Source, I::Item: Sample, D: Sample