pub struct AudioTrack {
clip: AudioClip,
gain: f64,
fade_in_secs: f64,
fade_out_secs: f64,
play_range: Option<Range<f64>>,
}Expand description
A sound’s content data: the clip plus how to play it.
Purely substance — clip trim and gain envelope. Everything time-positional
(placement, window duration, enable, rate warps — including linear speed
changes via with_duration) lives on the cell layer (Unplaced::at,
with_duration, with_rate_func, with_enabled), exactly like a visual
item’s data versus its AnimNode.
Fields§
§clip: AudioClip§gain: f64§fade_in_secs: f64§fade_out_secs: f64§play_range: Option<Range<f64>>Implementations§
Source§impl AudioTrack
impl AudioTrack
Sourcepub fn with_fade_in(self, secs: f64) -> Self
pub fn with_fade_in(self, secs: f64) -> Self
Fade in linearly over the first secs of the track.
Sourcepub fn with_fade_out(self, secs: f64) -> Self
pub fn with_fade_out(self, secs: f64) -> Self
Fade out linearly over the last secs of the track.
Sourcepub fn with_play_secs(self, range: Range<f64>) -> Self
pub fn with_play_secs(self, range: Range<f64>) -> Self
Play only the clip’s seconds within range — a content trim, unlike
the cell layer’s with_duration, which resamples the sound to fit a
new window length.
The range is clamped to the clip: a start before the clip pulls to
zero, an end past the clip’s duration truncates, and an empty or
reversed span collapses to silence. Content-time zero always plays
range.start seconds into the clip.
Sourcefn source_span(&self) -> (f64, f64)
fn source_span(&self) -> (f64, f64)
The clip-second span actually played: play_range clamped to the
clip’s extent.
Sourcepub(crate) fn play_window_secs(&self) -> f64
pub(crate) fn play_window_secs(&self) -> f64
The track’s play length (its whole content axis).
Source§impl AudioTrack
impl AudioTrack
Sourcepub(crate) fn sample_at(&self, own: f64) -> [f32; 2]
pub(crate) fn sample_at(&self, own: f64) -> [f32; 2]
The stereo sample this track produces at content-time own, or
silence when own falls outside the play window.
A pure function of content time — the mixing walk calls it once per output sample. Fades are measured on the same content axis.
Sourcepub(crate) fn mix_span_into(
&self,
a: f64,
b: f64,
g_lo: usize,
g_hi: usize,
sample_rate: f64,
pcm: &mut [f32],
)
pub(crate) fn mix_span_into( &self, a: f64, b: f64, g_lo: usize, g_hi: usize, sample_rate: f64, pcm: &mut [f32], )
Add this track’s samples for global frames [g_lo, g_hi) into pcm
(the whole timeline’s interleaved stereo buffer, absolute frame
indices), where content time is the affine map
t(g) = a + b·(g / sample_rate).
The seal-time bake’s linear fast path: the per-sample math is
identical to AudioTrack::sample_at (window, fades and gain all
measured on the content axis), arranged as one tight loop over the
frames the bake proved audible.
Trait Implementations§
Source§impl Clone for AudioTrack
impl Clone for AudioTrack
Source§fn clone(&self) -> AudioTrack
fn clone(&self) -> AudioTrack
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AudioTrack
impl RefUnwindSafe for AudioTrack
impl Send for AudioTrack
impl Sync for AudioTrack
impl Unpin for AudioTrack
impl UnsafeUnpin for AudioTrack
impl UnwindSafe for AudioTrack
Blanket Implementations§
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> ConditionalSend for Twhere
T: Send,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§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> Pointable for T
impl<T> Pointable for T
Source§impl<T> TransformedExt for T
impl<T> TransformedExt for T
Source§fn transformed<G>(self, transform: G) -> Transformed<Self, G>
fn transformed<G>(self, transform: G) -> Transformed<Self, G>
self wrapped with transform stored exactly as G.