pub struct Mixer { /* private fields */ }Expand description
The mix (module docs).
Implementations§
Source§impl Mixer
impl Mixer
Sourcepub fn remote(&self, commands: usize) -> (Remote, Inbox)
pub fn remote(&self, commands: usize) -> (Remote, Inbox)
The two ends for commanding this mixer from another thread, with room for
commands commands waiting (queue).
Sourcepub fn put_sound(&mut self, sound: SoundId, pcm: SharedPcm) -> Option<SharedPcm>
pub fn put_sound(&mut self, sound: SoundId, pcm: SharedPcm) -> Option<SharedPcm>
Puts pcm in the place of the bank Remote::reserve_sound named, and gives
back what was there for the caller to free. It neither allocates nor frees, so
a backend’s hand-over can call it on the audio thread.
Sourcepub fn put_stream(
&mut self,
stream: StreamId,
source: Box<dyn Source + Send>,
) -> Option<Box<dyn Source + Send>>
pub fn put_stream( &mut self, stream: StreamId, source: Box<dyn Source + Send>, ) -> Option<Box<dyn Source + Send>>
Holds source in the stream slot Remote::reserve_stream named, and gives
back what was there for the caller to free. It neither allocates nor frees.
Sourcepub fn take_stream(
&mut self,
stream: StreamId,
) -> Option<Box<dyn Source + Send>>
pub fn take_stream( &mut self, stream: StreamId, ) -> Option<Box<dyn Source + Send>>
Takes stream out of its slot, ending what is playing it, for the caller to
free where it may. A mix never frees one.
Sourcepub fn remove_sound(&mut self, sound: SoundId) -> Option<SharedPcm>
pub fn remove_sound(&mut self, sound: SoundId) -> Option<SharedPcm>
Takes sound out of the bank and stops what is playing it. The caller
frees it, on a thread that may.
Sourcepub fn add_stream(
&mut self,
source: Box<dyn Source + Send>,
) -> Result<StreamId, Full>
pub fn add_stream( &mut self, source: Box<dyn Source + Send>, ) -> Result<StreamId, Full>
Holds source ready to play. A slot that a finished stream still holds is
freed for it; a backend with its mixer on the audio thread takes those out
first (take_finished_stream).
Sourcepub fn take_finished_stream(&mut self) -> Option<Box<dyn Source + Send>>
pub fn take_finished_stream(&mut self) -> Option<Box<dyn Source + Send>>
A source whose voice has finished with it, for the caller to free where it may. A mix never frees one.
Sourcepub fn play(&mut self, sound: SoundId, params: Params) -> Result<VoiceId, Full>
pub fn play(&mut self, sound: SoundId, params: Params) -> Result<VoiceId, Full>
Plays sound, or says Full. A sound no longer in the bank plays as one
with no frames.
Sourcepub fn stream(
&mut self,
source: impl Source + Send + 'static,
params: Params,
) -> Result<VoiceId, Full>
pub fn stream( &mut self, source: impl Source + Send + 'static, params: Params, ) -> Result<VoiceId, Full>
Plays source, a stream that has its frames ready, or says Full.
Sourcepub fn play_stream(
&mut self,
stream: StreamId,
params: Params,
) -> Result<VoiceId, Full>
pub fn play_stream( &mut self, stream: StreamId, params: Params, ) -> Result<VoiceId, Full>
Plays a stream add_stream holds, or says Full. A
stream plays once: one that was played, or is gone, plays as one with no
frames.
Sourcepub fn set_volume(&mut self, voice: VoiceId, volume: u16)
pub fn set_volume(&mut self, voice: VoiceId, volume: u16)
Jumps to volume, in 1/4096, ending any fade.
Sourcepub fn fade_to(&mut self, voice: VoiceId, volume: u16, millis: u64)
pub fn fade_to(&mut self, voice: VoiceId, volume: u16, millis: u64)
Goes to volume, in 1/4096, in a straight line, over millis. A fade to
nothing leaves the voice playing silently, for the caller to stop.
Sourcepub fn set_balance(&mut self, voice: VoiceId, left: u16, right: u16)
pub fn set_balance(&mut self, voice: VoiceId, left: u16, right: u16)
Sets the left and right gains, in 1/4096.
Sourcepub fn pause(&mut self, voice: VoiceId)
pub fn pause(&mut self, voice: VoiceId)
Holds voice where it is, its fade too: it sounds nothing until
resume.
Sourcepub fn is_playing(&self, voice: VoiceId) -> bool
pub fn is_playing(&self, voice: VoiceId) -> bool
Whether voice hasn’t ended. A paused voice is playing.
Sourcepub fn volume(&self, voice: VoiceId) -> Option<u16>
pub fn volume(&self, voice: VoiceId) -> Option<u16>
voice’s volume now, in 1/4096, if it is playing.
Sourcepub const fn underrun_frames(&self) -> u64
pub const fn underrun_frames(&self) -> u64
How many frames, added over every stream so far, had nothing to play yet because a worker hadn’t got there. A voice stops where it is for those: a stream is delayed, never skipped.