#[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) -> AudioMix
pub fn with_delay(self, duration: Duration) -> AudioMix
Plays silence for the duration before starting layers mix.
Sourcepub fn with_total_duration(self, duration: Duration) -> AudioMix
pub fn with_total_duration(self, duration: Duration) -> AudioMix
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) -> AudioMix
pub fn with_audio(self, audio: &AudioTrack) -> AudioMix
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,
) -> AudioMix
pub fn with_audio_clip( self, audio: &AudioTrack, skip: Duration, take: Duration, ) -> AudioMix
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>) -> AudioMix
pub fn with_mix(self, mix: impl Into<AudioMix>) -> AudioMix
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,
) -> AudioMix
pub fn with_mix_clip( self, mix: impl Into<AudioMix>, skip: Duration, take: Duration, ) -> AudioMix
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) -> AudioMix
pub fn with_sine_wave(self, frequency: f32, duration: Duration) -> AudioMix
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,
) -> AudioMix
pub fn with_volume_linear( self, start: Duration, duration: Duration, start_volume: Factor, end_volume: Factor, ) -> AudioMix
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) -> AudioMix
pub fn with_fade_in(self, transition_duration: Duration) -> AudioMix
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,
) -> AudioMix
pub fn with_fade_out( self, start: Duration, transition_duration: Duration, ) -> AudioMix
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<AudioMix, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AudioMix, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<&AudioTrack> for AudioMix
impl From<&AudioTrack> for AudioMix
Source§fn from(audio: &AudioTrack) -> AudioMix
fn from(audio: &AudioTrack) -> AudioMix
Source§impl From<AudioTrack> for AudioMix
impl From<AudioTrack> for AudioMix
Source§fn from(audio: AudioTrack) -> AudioMix
fn from(audio: AudioTrack) -> AudioMix
Source§impl Serialize for AudioMix
impl Serialize for AudioMix
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().