Skip to main content

AudioBus

Struct AudioBus 

Source
pub struct AudioBus { /* private fields */ }
Expand description

Cross-platform deterministic game audio mixer queue (bridged to WebAudio / CoreAudio / AAudio / WASAPI).

Implementations§

Source§

impl AudioBus

Sound cue scheduling and frame draining for AudioBus.

Source

pub fn play(&mut self, cue: SoundCue, volume: f32, pan: f32, pitch: f32)

Queues a sound cue with normalized volume, pan, and pitch.

§Arguments
  • &Self - Mutable audio bus.
  • SoundCue - Sound cue to play.
  • f32 - Linear volume [0.0, 1.0].
  • f32 - Stereo pan [-1.0, 1.0].
  • f32 - Pitch multiplier [0.25, 4.0].
Source

pub fn drain(&mut self) -> Vec<AudioCommand>

Drains all queued audio commands for platform audio playback.

§Arguments
  • &Self - Mutable audio bus.
§Returns
  • Vec<AudioCommand> - Ordered commands emitted since the previous drain.
Source

pub fn play_spatial_3d( &mut self, listener: &AudioListener3D, source: &SpatialAudioSource3D, )

Spatializes a 3D sound emitter relative to listener with inverse-distance attenuation, stereo ear panning, and Doppler shift.

§Arguments
  • &Self - Mutable audio bus.
  • &AudioListener3D - Active 3D listener pose.
  • &SpatialAudioSource3D - World-space sound source parameters.
Source§

impl AudioBus

Source

pub fn get_master_volume(&self) -> f32

Source

pub fn get_mut_master_volume(&mut self) -> &mut f32

Source

pub fn set_master_volume(&mut self, val: f32) -> &mut Self

Source

pub fn get_muted(&self) -> bool

Source

pub fn get_mut_muted(&mut self) -> &mut bool

Source

pub fn set_muted(&mut self, val: bool) -> &mut Self

Source

pub fn get_queue(&self) -> &Vec<AudioCommand>

Source

pub fn get_mut_queue(&mut self) -> &mut Vec<AudioCommand>

Source

pub fn set_queue(&mut self, val: Vec<AudioCommand>) -> &mut Self

Source

pub fn get_total_played(&self) -> u64

Source

pub fn get_mut_total_played(&mut self) -> &mut u64

Source

pub fn set_total_played(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for AudioBus

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 Debug for AudioBus

Source§

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

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

impl Default for AudioBus

Default unmuted audio bus at 0.85 master volume.

Source§

fn default() -> Self

Creates a default AudioBus.

§Returns
  • Self - Ready audio bus.

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.