Skip to main content

MixerHandle

Struct MixerHandle 

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

The game’s half of the mixer: starts, changes and stops voices.

Implementations§

Source§

impl MixerHandle

Source

pub fn set_effects(&mut self, bus: BusId, effects: &[Effect]) -> Result<()>

Replaces a bus’s chain. Preparation may allocate; installation is atomic and sample scheduled. An empty slice removes the chain and its tail immediately.

Source

pub fn set_effect( &mut self, bus: BusId, slot: usize, effect: Effect, fade: Fade, ) -> Result<()>

Ramps all numeric settings of an existing matching slot in place. Type or capacity mismatches and dependency cycles are reported asynchronously. Changing the sidechain key is immediate; gain reduction uses attack/release.

Source§

impl MixerHandle

Source

pub fn set_routing(&mut self, settings: &[BusRouting]) -> Result<RoutingId>

Replace the named-bus routing graph/settings atomically. Empty settings restore legacy flat routing. Preparation allocates; render does not. Audio-only validation is synchronous; actual sidechain dependencies are revalidated on application. Poll the returned ID’s outcome. Each unpolled edit consumes one credit, up to MixerConfig::queue, including retired data.

Source§

impl MixerHandle

Source

pub fn sample_rate(&self) -> u32

Source

pub fn channels(&self) -> usize

Source

pub fn bus(&self, name: &str) -> Option<BusId>

The named bus, if the mixer has it.

Source

pub fn frame(&self) -> u64

Frames the mixer had rendered when it last finished a render.

Source

pub fn voice_status(&self, voice: VoiceId) -> Option<VoiceStatus>

A voice’s state and position as of the mixer’s last render, read without blocking. None if the mixer has not started the voice yet, or if it ended and its slot went to another voice; MixerHandle::poll_event reports endings.

Source

pub fn pause(&mut self, voice: VoiceId, fade: Fade) -> Result<()>

Pauses a voice, fading it out first. It keeps its position, fades and loop.

Source

pub fn resume(&mut self, voice: VoiceId, fade: Fade) -> Result<()>

Resumes a paused voice, fading it in.

Source

pub fn pause_bus(&mut self, bus: BusId, fade: Fade) -> Result<()>

Pauses voices directly assigned to a bus; BusId::MASTER pauses all. A paused group also gates routed input/freezes its inserts, but does not recursively freeze child sources. Use mute for advancing silent playback. Voices started directly on a paused bus wait for it to resume.

Source

pub fn resume_bus(&mut self, bus: BusId, fade: Fade) -> Result<()>

Source

pub fn now(&mut self) -> Commands<'_>

Commands that apply at the start of the next render.

Source

pub fn at(&mut self, frame: u64) -> Commands<'_>

Commands that apply exactly at output frame frame, or at the next render if it has passed.

Source

pub fn play(&mut self, sound: impl Into<Sound>, play: &Play) -> Result<VoiceId>

Source

pub fn stop(&mut self, voice: VoiceId, fade: Fade) -> Result<()>

Source

pub fn stop_all(&mut self, fade: Fade) -> Result<()>

Source

pub fn set_gain(&mut self, voice: VoiceId, gain: f32, fade: Fade) -> Result<()>

Source

pub fn set_pan(&mut self, voice: VoiceId, pan: f32, fade: Fade) -> Result<()>

Set legacy pan. A point emitter uses its direction instead.

Source

pub fn set_rate(&mut self, voice: VoiceId, rate: f32, fade: Fade) -> Result<()>

Source

pub fn set_pitch( &mut self, voice: VoiceId, semitones: f32, fade: Fade, ) -> Result<()>

Source

pub fn set_position( &mut self, voice: VoiceId, position: [f32; 2], fade: Fade, ) -> Result<()>

Moves a voice to position relative to the listener, ramping its pan and distance gain over the fade so a moving sound does not zipper. A fade of about one game frame suits positions updated every frame. A 3D emitter ignores 2D pan/position commands; update it with set_emitter.

Source

pub fn set_emitter( &mut self, voice: VoiceId, emitter: Emitter, fade: Fade, ) -> Result<()>

Enable/update permanent point-source mode. Stereo collapses immediately to (L+R)/2; fade ramps direction, attenuation and Doppler, not that conversion.

Source

pub fn set_listener(&mut self, listener: Listener, fade: Fade) -> Result<()>

Schedule a global listener update; placement is recomputed on application.

Source

pub fn latency(&self) -> u64

Output frames by which the master limiter’s look-ahead delays the sound: a change scheduled at frame f is heard at f + latency(). 0 without a limiter.

Source

pub fn limiter_gain(&self) -> Option<f32>

The lowest gain the master limiter applied during the last render, from 0 to 1 (1 when it did not reduce), for meters. None without a limiter.

Source

pub fn space(&self) -> Space2d

The 2D space that positions use.

Source

pub fn reseed(&mut self, seed: u64)

Restarts the generator of variations from seed.

Source

pub fn set_bus_gain(&mut self, bus: BusId, gain: f32, fade: Fade) -> Result<()>

Source

pub fn poll_event(&mut self) -> Option<MixerEvent>

Returns the next event, freeing finished voices and retired effect/routing edits on this thread. These queues are independent; combined polling order is not a chronological ordering across event kinds.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.