pub struct AudioSpec {
pub src: SoundId,
pub volume: f32,
pub looped: bool,
pub paused: bool,
pub finish: bool,
pub tag: Option<Value>,
}Expand description
What an audio node declares each frame (Core::audio_node).
Fields§
§src: SoundId§volume: f32Linear amplitude, 0..1; changes apply to the running playback.
looped: bool§paused: boolHolds the playback (resumes when cleared).
finish: boolWhat the node going away means: false stops the playback, true
releases it — it finishes on its own. See AudioSpec::finish.
tag: Option<Value>Carried back in the ended event; None = no event.
Implementations§
Source§impl AudioSpec
impl AudioSpec
pub fn new(src: SoundId) -> AudioSpec
pub fn volume(self, v: f32) -> AudioSpec
pub fn looped(self) -> AudioSpec
pub fn paused(self, paused: bool) -> AudioSpec
Sourcepub fn finish(self) -> AudioSpec
pub fn finish(self) -> AudioSpec
The node’s removal releases the playback instead of stopping it:
it plays to its end, and a tag still reports ended when it gets
there. Only removal changes — a looped playback still stops (it
has no end to reach), and a changed src still restarts, since that
is a replacement rather than a departure. A playback that is
paused when its node goes has nothing to finish and the driver
holds it forever, so a view that pauses should stop rather than
release. Without this, a one-shot the view wants heard whole has to
stay declared for the asset’s length, which the view does not know.
This is also what
truncated-playback asks for: a
one-shot removed mid-sound raises that warning, and the answer to
it is either this flag or a node kept declared until the ended
event. A node that means to cut the sound off says so by stopping
what it started (Core::stop), which is not reported.
A released playback is not free: it holds one of the device’s 128
voices until its file ends, and the 129th play is refused (reported
as crate::diag::PLAYBACK_REFUSED and, for a tagged node,
{kind:"sound", phase:"refused"}). A loop would hold a voice for
ever, which is why a loop is stopped rather than released.
pub fn tag(self, tag: impl Into<Value>) -> AudioSpec
Trait Implementations§
impl StructuralPartialEq for AudioSpec
Auto Trait Implementations§
impl Freeze for AudioSpec
impl RefUnwindSafe for AudioSpec
impl Send for AudioSpec
impl Sync for AudioSpec
impl Unpin for AudioSpec
impl UnsafeUnpin for AudioSpec
impl UnwindSafe for AudioSpec
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.