#[non_exhaustive]pub struct AudioMix { /* private fields */ }Expand description
Represents an audio source.
Audio is defined by layers, each subsequent layer applies to the computed result of the previous layer.
Implementations§
Source§impl AudioMix
impl AudioMix
Sourcepub fn with_delay(self, duration: Duration) -> Self
pub fn with_delay(self, duration: Duration) -> Self
Plays silence for the duration before starting layers mix.
Sourcepub fn with_total_duration(self, duration: Duration) -> Self
pub fn with_total_duration(self, duration: Duration) -> Self
Set the total duration.
If not set audio plays until all audio and mix layers end. If set audio plays for the duration, if layers end before the duration plays silent at the end, if layers exceed the duration they are clipped.
Note that the duration must account for the initial delay, the initial silence is included in the the total duration.
Sourcepub fn with_audio(self, audio: &AudioTrack) -> Self
pub fn with_audio(self, audio: &AudioTrack) -> Self
Add layer that plays the cached audio.
The audio samples are adapted to the output format and each sample added to the under layers result.
Sourcepub fn with_audio_clip(
self,
audio: &AudioTrack,
skip: Duration,
take: Duration,
) -> Self
pub fn with_audio_clip( self, audio: &AudioTrack, skip: Duration, take: Duration, ) -> Self
Add layer that clips and plays the cached audio.
This is similar to with_audio, but only the range skip..skip + take is played.
Sourcepub fn with_mix(self, mix: impl Into<AudioMix>) -> Self
pub fn with_mix(self, mix: impl Into<AudioMix>) -> Self
Add layer that plays another mix.
The inner mix is sampled as computed audio, that is, samples are computed first and added to the under layers result.
Sourcepub fn with_mix_clip(
self,
mix: impl Into<AudioMix>,
skip: Duration,
take: Duration,
) -> Self
pub fn with_mix_clip( self, mix: impl Into<AudioMix>, skip: Duration, take: Duration, ) -> Self
Add layer that clips and plays another mix.
This is similar to with_mix, but only the range skip..skip + take is played.
Sourcepub fn with_sine_wave(self, frequency: f32, duration: Duration) -> Self
pub fn with_sine_wave(self, frequency: f32, duration: Duration) -> Self
Add layer that generates a sine wave sound.
The generated sound samples are added to the under layers result.
Sourcepub fn with_volume_linear(
self,
start: Duration,
duration: Duration,
start_volume: Factor,
end_volume: Factor,
) -> Self
pub fn with_volume_linear( self, start: Duration, duration: Duration, start_volume: Factor, end_volume: Factor, ) -> Self
Add effect layer that applies a linear volume transition.
When the playback is in range the computed sample of under layers is multiplied by the linear interpolation
between start_volume and end_volume.
Note that outside the volume range is not affected, before and after.
Sourcepub fn with_fade_in(self, transition_duration: Duration) -> Self
pub fn with_fade_in(self, transition_duration: Duration) -> Self
Add an effect layer that fades in from the start over a transition duration.
A linear volume transition at the start raises the volume of under layers from zero to normal over the transition_duration.
Sourcepub fn with_fade_out(
self,
start: Duration,
transition_duration: Duration,
) -> Self
pub fn with_fade_out( self, start: Duration, transition_duration: Duration, ) -> Self
Add an effect layer that fades out the audio after start.
A linear volume transition lowers the volume of under layers after start to zero over transition_duration,
the volume remains zeroed until audio end.
Note that this does not affect the total duration, you must also call with_total_duration to fade out and stop.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AudioMix
impl<'de> Deserialize<'de> for AudioMix
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&AudioTrack> for AudioMix
impl From<&AudioTrack> for AudioMix
Source§fn from(audio: &AudioTrack) -> Self
fn from(audio: &AudioTrack) -> Self
Source§impl From<AudioTrack> for AudioMix
impl From<AudioTrack> for AudioMix
Source§fn from(audio: AudioTrack) -> Self
fn from(audio: AudioTrack) -> Self
impl IntoValue<AudioMix> for AudioMix
impl IntoValue<AudioMix> for AudioTrack
impl StructuralPartialEq for AudioMix
Auto Trait Implementations§
impl Freeze for AudioMix
impl RefUnwindSafe for AudioMix
impl Send for AudioMix
impl Sync for AudioMix
impl Unpin for AudioMix
impl UnwindSafe for AudioMix
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more