Skip to main content

AudioEmitter

Struct AudioEmitter 

Source
#[non_exhaustive]
pub struct AudioEmitter { pub sound: Handle<Sound>, pub params: PlayParams, }
Expand description

A sound that plays at its entity, and follows it as it moves: the system nadir::sound starts it once its sound has loaded, while the entity has a Transform and is within AudioConfig::max_dist of the listener (AudioListener), 800 pixels, where it can be heard. It stops, fading out over 100 ms, when the entity is despawned or loses the emitter or its Transform, or is more than 64 pixels past that distance; back within it, it starts again. A sound that does not loop plays once each time it starts.

Changed, it follows: a new sound, bus, looped, priority or max_instances stops the voice and starts the new one, and a new volume or pitch reaches the voice as it plays. Its pan is not used: where it is pans it.

A voice taken for another when the voices run short stays silent until the emitter starts again. PlayParams::priority protects it only from plays of a lower priority: AudioEmitter::looped’s 192 from sounds played with the default, 128. A sound that failed to load, or that the asset server does not hold, is warned of once, with the entity and its path, and not tried again until the emitter changes.

It is not reflected: a game gives it in code, not in prefabs or levels.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sound: Handle<Sound>

The sound it plays.

§params: PlayParams

How it plays it.

Implementations§

Source§

impl AudioEmitter

Source

pub const fn new(sound: Handle<Sound>, params: PlayParams) -> Self

An emitter of sound, played as params say.

Source

pub fn looped(sound: Handle<Sound>) -> Self

An emitter of sound looped on Bus::Ambience, for a sound of the place, such as water or a fire: at priority 192, and with no limit to the voices of the sound, so that the sound’s limit does not make its emitters take one another’s voices; when all the mixer’s voices play, a play of the same priority or higher still takes the oldest of them (Audio::play_sound). Otherwise as PlayParams::default plays.

Trait Implementations§

Source§

impl Clone for AudioEmitter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for AudioEmitter

Source§

impl Copy for AudioEmitter

Source§

impl Debug for AudioEmitter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AudioEmitter

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AudioEmitter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.