pub struct Mixer {
pub music: Bus,
pub sfx: Bus,
pub ambient: Bus,
pub ui: Bus,
pub master: Bus,
pub limiter: Limiter,
pub compressor: Compressor,
pub listener_pos: Vec3,
pub auto_duck: bool,
/* private fields */
}Expand description
The master audio mixer — manages buses, channels, and effects.
Fields§
§music: Bus§sfx: Bus§ambient: Bus§ui: Bus§master: Bus§limiter: Limiter§compressor: Compressor§listener_pos: Vec3§auto_duck: boolDucking: when SFX is playing loudly, music ducks.
Implementations§
Source§impl Mixer
impl Mixer
pub fn new() -> Self
pub fn bus_mut(&mut self, id: BusId) -> &mut Bus
pub fn bus(&self, id: BusId) -> &Bus
pub fn set_music_volume(&mut self, v: f32)
pub fn set_sfx_volume(&mut self, v: f32)
pub fn set_ambient_volume(&mut self, v: f32)
pub fn set_master_volume(&mut self, v: f32)
pub fn fade_music(&mut self, target: f32, secs: f32)
pub fn mute_all(&mut self)
pub fn unmute_all(&mut self)
Sourcepub fn add_channel(&mut self, position: Vec3, bus: BusId) -> u64
pub fn add_channel(&mut self, position: Vec3, bus: BusId) -> u64
Register a spatial sound channel. Returns its ID.
Sourcepub fn add_oneshot_sfx(&mut self, position: Vec3, duration_s: f32) -> u64
pub fn add_oneshot_sfx(&mut self, position: Vec3, duration_s: f32) -> u64
Add a one-shot SFX at a world position.
Sourcepub fn remove_channel(&mut self, id: u64)
pub fn remove_channel(&mut self, id: u64)
Remove a channel by ID.
pub fn get_channel_mut(&mut self, id: u64) -> Option<&mut ChannelStrip>
Sourcepub fn mix_frame(&mut self, channel_gains: &[(u64, f32)]) -> StereoFrame
pub fn mix_frame(&mut self, channel_gains: &[(u64, f32)]) -> StereoFrame
Mix one stereo output frame from all active channels.
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Number of active channels.
Sourcepub fn update_auto_duck(&mut self)
pub fn update_auto_duck(&mut self)
Auto-duck music when SFX volume exceeds threshold.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mixer
impl RefUnwindSafe for Mixer
impl Send for Mixer
impl Sync for Mixer
impl Unpin for Mixer
impl UnsafeUnpin for Mixer
impl UnwindSafe for Mixer
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.