pub trait Source: Iterator{
Show 29 methods
// Required methods
fn current_frame_len(&self) -> Option<usize>;
fn channels(&self) -> u16;
fn sample_rate(&self) -> u32;
fn total_duration(&self) -> Option<Duration>;
// Provided methods
fn buffered(self) -> Buffered<Self> ⓘ
where Self: Sized { ... }
fn mix<S>(self, other: S) -> Mix<Self, S> ⓘ
where Self: Sized,
Self::Item: FromSample<S::Item>,
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 skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘ
where Self: Sized { ... }
fn amplify(self, value: f32) -> Amplify<Self> ⓘ
where Self: Sized { ... }
fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘ
where Self: Sized { ... }
fn take_crossfade_with<S: Source>(
self,
other: S,
duration: Duration,
) -> Crossfade<Self, S>
where Self: Sized,
Self::Item: FromSample<S::Item>,
<S as Iterator>::Item: Sample { ... }
fn fade_in(self, duration: Duration) -> FadeIn<Self> ⓘ
where Self: Sized { ... }
fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘ
where Self: Sized { ... }
fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘ
where Self: Sized { ... }
fn periodic_access<F>(
self,
period: Duration,
access: F,
) -> PeriodicAccess<Self, F> ⓘ
where Self: Sized,
F: FnMut(&mut Self) { ... }
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 { ... }
fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
where Self: Sized,
D: Sample { ... }
fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘ
where Self: Sized { ... }
fn stoppable(self) -> Stoppable<Self> ⓘ
where Self: Sized { ... }
fn skippable(self) -> Skippable<Self> ⓘ
where Self: Sized { ... }
fn track_position(self) -> TrackPosition<Self> ⓘ
where Self: Sized { ... }
fn low_pass(self, freq: u32) -> BltFilter<Self> ⓘ
where Self: Sized + Source<Item = f32> { ... }
fn high_pass(self, freq: u32) -> BltFilter<Self> ⓘ
where Self: Sized + Source<Item = f32> { ... }
fn low_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
where Self: Sized + Source<Item = f32> { ... }
fn high_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
where Self: Sized + Source<Item = f32> { ... }
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> { ... }
}
Expand description
A source of samples.
§A quick lesson about sounds
§Sampling
A sound is a vibration that propagates through air and reaches your ears. This vibration can be represented as an analog signal.
In order to store this signal in the computer’s memory or on the disk, we perform what is called sampling. The consists in choosing an interval of time (for example 20µs) and reading the amplitude of the signal at each interval (for example, if the interval is 20µs we read the amplitude every 20µs). By doing so we obtain a list of numerical values, each value being called a sample.
Therefore a sound can be represented in memory by a frequency and a list of samples. The frequency is expressed in hertz and corresponds to the number of samples that have been read per second. For example if we read one sample every 20µs, the frequency would be 50000 Hz. In reality, common values for the frequency are 44100, 48000 and 96000.
§Channels
But a frequency and a list of values only represent one signal. When you listen to a sound, your left and right ears don’t receive exactly the same signal. In order to handle this, we usually record not one but two different signals: one for the left ear and one for the right ear. We say that such a sound has two channels.
Sometimes sounds even have five or six channels, each corresponding to a location around the head of the listener.
The standard in audio manipulation is to interleave the multiple channels. In other words, in a sound with two channels the list of samples contains the first sample of the first channel, then the first sample of the second channel, then the second sample of the first channel, then the second sample of the second channel, and so on. The same applies if you have more than two channels. The rodio library only supports this schema.
Therefore in order to represent a sound in memory in fact we need three characteristics: the frequency, the number of channels, and the list of samples.
§The Source
trait
A Rust object that represents a sound should implement the Source
trait.
The three characteristics that describe a sound are provided through this trait:
- The number of channels can be retrieved with
channels
. - The frequency can be retrieved with
sample_rate
. - The list of values can be retrieved by iterating on the source. The
Source
trait requires that theIterator
trait be implemented as well. When aSource
returns None the sound has ended.
§Frames
The samples rate and number of channels of some sound sources can change by itself from time to time.
Note: As a basic example, if you play two audio files one after the other and treat the whole as a single source, then the channels and samples rate of that source may change at the transition between the two files.
However, for optimization purposes rodio supposes that the number of channels and the frequency
stay the same for long periods of time and avoids calling channels()
and
sample_rate
too frequently.
In order to properly handle this situation, the current_frame_len()
method should return
the number of samples that remain in the iterator before the samples rate and number of
channels can potentially change.
Required Methods§
sourcefn current_frame_len(&self) -> Option<usize>
fn current_frame_len(&self) -> Option<usize>
Returns the number of samples before the current frame ends. None
means “infinite” or
“until the sound ends”.
Should never return 0 unless there’s no more data.
After the engine has finished reading the specified number of samples, it will check
whether the value of channels()
and/or sample_rate()
have changed.
sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Returns the rate at which the source should be played. In number of samples per second.
sourcefn total_duration(&self) -> Option<Duration>
fn 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§
sourcefn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
Stores the source in a buffer in addition to returning it. This iterator can be cloned.
sourcefn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
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.
sourcefn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
Takes a certain duration of this source and then stops.
sourcefn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
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.
sourcefn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
Immediately skips a certain duration of this source.
If the specified duration is longer than the source itself, skip_duration
will skip to the end of the source.
sourcefn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
Amplifies the sound by the given value.
sourcefn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
Applies automatic gain control to the sound.
Automatic Gain Control (AGC) adjusts the amplitude of the audio signal to maintain a consistent output level.
§Parameters
target_level
:
TL;DR: Desired output level. 1.0 = original level, > 1.0 amplifies, < 1.0 reduces.
The desired output level, where 1.0 represents the original sound level.
Values above 1.0 will amplify the sound, while values below 1.0 will lower it.
For example, a target_level of 1.4 means that at normal sound levels, the AGC
will aim to increase the gain by a factor of 1.4, resulting in a minimum 40% amplification.
A recommended level is 1.0
, which maintains the original sound level.
attack_time
:
TL;DR: Response time for volume increases. Shorter = faster but may cause abrupt changes. Recommended: 4.0
seconds.
The time (in seconds) for the AGC to respond to input level increases.
Shorter times mean faster response but may cause abrupt changes. Longer times result
in smoother transitions but slower reactions to sudden volume changes. Too short can
lead to overreaction to peaks, causing unnecessary adjustments. Too long can make the
AGC miss important volume changes or react too slowly to sudden loud passages. Very
high values might result in excessively loud output or sluggish response, as the AGC’s
adjustment speed is limited by the attack time. Balance is key for optimal performance.
A recommended attack_time of 4.0
seconds provides a sweet spot for most applications.
release_time
:
TL;DR: Response time for volume decreases. Shorter = faster gain reduction. Recommended: 0.005
seconds.
The time (in seconds) for the AGC to respond to input level decreases.
This parameter controls how quickly the gain is reduced when the signal level drops.
Shorter release times result in faster gain reduction, which can be useful for quick
adaptation to quieter passages but may lead to pumping effects. Longer release times
provide smoother transitions but may be slower to respond to sudden decreases in volume.
However, if the release_time is too high, the AGC may not be able to lower the gain
quickly enough, potentially leading to clipping and distorted sound before it can adjust.
Finding the right balance is crucial for maintaining natural-sounding dynamics and
preventing distortion. A recommended release_time of 0.005
seconds often works well for
general use, providing a good balance between responsiveness and smooth transitions.
absolute_max_gain
:
TL;DR: Maximum allowed gain. Prevents over-amplification. Recommended: 5.0
.
The maximum gain that can be applied to the signal.
This parameter acts as a safeguard against excessive amplification of quiet signals
or background noise. It establishes an upper boundary for the AGC’s signal boost,
effectively preventing distortion or overamplification of low-level sounds.
This is crucial for maintaining audio quality and preventing unexpected volume spikes.
A recommended value for absolute_max_gain
is 5
, which provides a good balance between
amplification capability and protection against distortion in most scenarios.
Use get_agc_control
to obtain a handle for real-time enabling/disabling of the AGC.
§Example (Quick start)
// Apply Automatic Gain Control to the source (AGC is on by default)
let agc_source = source.automatic_gain_control(1.0, 4.0, 0.005, 5.0);
// Get a handle to control the AGC's enabled state (optional)
let agc_control = agc_source.get_agc_control();
// You can toggle AGC on/off at any time (optional)
agc_control.store(false, std::sync::atomic::Ordering::Relaxed);
// Add the AGC-controlled source to the sink
sink.append(agc_source);
// Note: Using agc_control is optional. If you don't need to toggle AGC,
// you can simply use the agc_source directly without getting agc_control.
sourcefn take_crossfade_with<S: Source>(
self,
other: S,
duration: Duration,
) -> Crossfade<Self, S>
fn take_crossfade_with<S: Source>( self, other: S, duration: Duration, ) -> Crossfade<Self, S>
Mixes this sound fading out with another sound fading in for the given duration.
Only the crossfaded portion (beginning of self, beginning of other) is returned.
sourcefn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
Fades out the sound.
sourcefn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
Applies a linear gain ramp to the sound.
If clamp_end
is true
, all samples subsequent to the end of the ramp
will be scaled by the end_value
. If clamp_end
is false
, all
subsequent samples will not have any scaling applied.
sourcefn periodic_access<F>(
self,
period: Duration,
access: F,
) -> PeriodicAccess<Self, F> ⓘ
fn periodic_access<F>( self, period: Duration, access: F, ) -> PeriodicAccess<Self, F> ⓘ
Calls the access
closure on Self
the first time the source is iterated and every
time period
elapses.
Later changes in either sample_rate()
or channels_count()
won’t be reflected in
the rate of access.
The rate is based on playback speed, so both the following will call access
when the
same samples are reached:
periodic_access(Duration::from_secs(1), ...).speed(2.0)
speed(2.0).periodic_access(Duration::from_secs(2), ...)
sourcefn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
Changes the play speed of the sound. Does not adjust the samples, only the playback speed.
§Note:
- Increasing the speed will increase the pitch by the same factor
- If you set the speed to 0.5 this will halve the frequency of the sound lowering its pitch.
- If you set the speed to 2 the frequency will double raising the pitch of the sound.
- Change in the speed affect the total duration inversely
- If you set the speed to 0.5, the total duration will be twice as long.
- If you set the speed to 2 the total duration will be halve of what it was.
See Speed
for details
sourcefn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
Converts the samples of this source to another type.
sourcefn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
Makes the sound pausable.
sourcefn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
Adds a method Skippable::skip
for skipping this source. Skipping
makes Source::next() return None. Which in turn makes the Sink skip to
the next source.
sourcefn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
fn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
Start tracking the elapsed duration since the start of the underlying source.
If a speedup and or delay is applied after this that will not be reflected
in the position returned by get_pos
.
This can get confusing when using get_pos()
together with Source::try_seek()
as the latter does take all
speedup’s and delay’s into account. Its recommended therefore to apply
track_position after speedup’s and delay’s.
sourcefn low_pass(self, freq: u32) -> BltFilter<Self> ⓘ
fn low_pass(self, freq: u32) -> BltFilter<Self> ⓘ
Applies a low-pass filter to the source. Warning: Probably buggy.
sourcefn low_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
fn low_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
Applies a low-pass filter to the source while allowing the q (bandwidth) to be changed.
sourcefn high_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
fn high_pass_with_q(self, freq: u32, q: f32) -> BltFilter<Self> ⓘ
Applies a high-pass filter to the source while allowing the q (bandwidth) to be changed.
sourcefn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
Attempts to seek to a given position in the current source.
As long as the duration of the source is known seek is guaranteed to saturate
at the end of the source. For example given a source that reports a total duration
of 42 seconds calling try_seek()
with 60 seconds as argument will seek to
42 seconds.
§Errors
This function will return SeekError::NotSupported
if one of the underlying
sources does not support seeking.
It will return an error if an implementation ran into one during the seek.
Seeking beyond the end of a source might return an error if the total duration of the source is not known.
Trait Implementations§
source§impl<S> Source for Box<dyn Source<Item = S>>where
S: Sample,
impl<S> Source for Box<dyn Source<Item = S>>where
S: Sample,
source§fn current_frame_len(&self) -> Option<usize>
fn current_frame_len(&self) -> Option<usize>
None
means “infinite” or
“until the sound ends”.
Should never return 0 unless there’s no more data. Read moresource§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
source§fn total_duration(&self) -> Option<Duration>
fn total_duration(&self) -> Option<Duration>
source§fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
source§fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
source§fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
source§fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
source§fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
source§fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
source§fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
source§fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
source§fn take_crossfade_with<S: Source>(
self,
other: S,
duration: Duration,
) -> Crossfade<Self, S>
fn take_crossfade_with<S: Source>( self, other: S, duration: Duration, ) -> Crossfade<Self, S>
source§fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
source§fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
source§fn periodic_access<F>(
self,
period: Duration,
access: F,
) -> PeriodicAccess<Self, F> ⓘ
fn periodic_access<F>( self, period: Duration, access: F, ) -> PeriodicAccess<Self, F> ⓘ
access
closure on Self
the first time the source is iterated and every
time period
elapses. Read moresource§fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
source§fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
source§fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
source§fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
Skippable::skip
for skipping this source. Skipping
makes Source::next() return None. Which in turn makes the Sink skip to
the next source.source§fn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
fn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
source§impl<S> Source for Box<dyn Source<Item = S> + Send>where
S: Sample,
impl<S> Source for Box<dyn Source<Item = S> + Send>where
S: Sample,
source§fn current_frame_len(&self) -> Option<usize>
fn current_frame_len(&self) -> Option<usize>
None
means “infinite” or
“until the sound ends”.
Should never return 0 unless there’s no more data. Read moresource§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
source§fn total_duration(&self) -> Option<Duration>
fn total_duration(&self) -> Option<Duration>
source§fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
source§fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
source§fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
source§fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
source§fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
source§fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
source§fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
source§fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
source§fn take_crossfade_with<S: Source>(
self,
other: S,
duration: Duration,
) -> Crossfade<Self, S>
fn take_crossfade_with<S: Source>( self, other: S, duration: Duration, ) -> Crossfade<Self, S>
source§fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
source§fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
source§fn periodic_access<F>(
self,
period: Duration,
access: F,
) -> PeriodicAccess<Self, F> ⓘ
fn periodic_access<F>( self, period: Duration, access: F, ) -> PeriodicAccess<Self, F> ⓘ
access
closure on Self
the first time the source is iterated and every
time period
elapses. Read moresource§fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
source§fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
source§fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
source§fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
Skippable::skip
for skipping this source. Skipping
makes Source::next() return None. Which in turn makes the Sink skip to
the next source.source§fn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
fn track_position(self) -> TrackPosition<Self> ⓘwhere
Self: Sized,
source§impl<S> Source for Box<dyn Source<Item = S> + Send + Sync>where
S: Sample,
impl<S> Source for Box<dyn Source<Item = S> + Send + Sync>where
S: Sample,
source§fn current_frame_len(&self) -> Option<usize>
fn current_frame_len(&self) -> Option<usize>
None
means “infinite” or
“until the sound ends”.
Should never return 0 unless there’s no more data. Read moresource§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
source§fn total_duration(&self) -> Option<Duration>
fn total_duration(&self) -> Option<Duration>
source§fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError>
source§fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
fn buffered(self) -> Buffered<Self> ⓘwhere
Self: Sized,
source§fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
fn repeat_infinite(self) -> Repeat<Self> ⓘwhere
Self: Sized,
source§fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
fn take_duration(self, duration: Duration) -> TakeDuration<Self> ⓘwhere
Self: Sized,
source§fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
fn delay(self, duration: Duration) -> Delay<Self> ⓘwhere
Self: Sized,
source§fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
fn skip_duration(self, duration: Duration) -> SkipDuration<Self> ⓘwhere
Self: Sized,
source§fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
fn amplify(self, value: f32) -> Amplify<Self> ⓘwhere
Self: Sized,
source§fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
fn automatic_gain_control(
self,
target_level: f32,
attack_time: f32,
release_time: f32,
absolute_max_gain: f32,
) -> AutomaticGainControl<Self> ⓘwhere
Self: Sized,
source§fn take_crossfade_with<S: Source>(
self,
other: S,
duration: Duration,
) -> Crossfade<Self, S>
fn take_crossfade_with<S: Source>( self, other: S, duration: Duration, ) -> Crossfade<Self, S>
source§fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
fn fade_out(self, duration: Duration) -> FadeOut<Self> ⓘwhere
Self: Sized,
source§fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
fn linear_gain_ramp(
self,
duration: Duration,
start_value: f32,
end_value: f32,
clamp_end: bool,
) -> LinearGainRamp<Self> ⓘwhere
Self: Sized,
source§fn periodic_access<F>(
self,
period: Duration,
access: F,
) -> PeriodicAccess<Self, F> ⓘ
fn periodic_access<F>( self, period: Duration, access: F, ) -> PeriodicAccess<Self, F> ⓘ
access
closure on Self
the first time the source is iterated and every
time period
elapses. Read moresource§fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
fn speed(self, ratio: f32) -> Speed<Self> ⓘwhere
Self: Sized,
source§fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
fn convert_samples<D>(self) -> SamplesConverter<Self, D> ⓘ
source§fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
fn pausable(self, initially_paused: bool) -> Pausable<Self> ⓘwhere
Self: Sized,
source§fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
fn skippable(self) -> Skippable<Self> ⓘwhere
Self: Sized,
Skippable::skip
for skipping this source. Skipping
makes Source::next() return None. Which in turn makes the Sink skip to
the next source.