pub struct Renderer { /* private fields */ }
Expand description
Final mixed samples are pulled from the Renderer.
Samples are delivered via the Renderer to a backend. Different backends are implemented in external crates for different platforms and use cases.
The backend is responsible for:
- storing the renderer
- calling renderer.set_output_channel_count_and_sample_rate()
- periodically calling renderer.on_start_of_batch() followed by some number of renderer.next_sample() calls (normally enough to fill some number of milliseconds of an output buffer).
Implementations§
Trait Implementations§
source§impl Sound for Renderer
impl Sound for Renderer
source§fn next_sample(&mut self) -> Result<NextSample, Error>
fn next_sample(&mut self) -> Result<NextSample, Error>
Get the next sample.
MetadataChanged
will only be returned from Renderer if
set_output_channel_count_and_sample_rate
was called. If Paused
is
returned the backend may choose to pause itself or play silence (e.g.
.next_sample().unwrap_or(0)
). Finished
will be returned if no sounds
are playing and the Manager of the Renderer has been dropped.
source§fn on_start_of_batch(&mut self)
fn on_start_of_batch(&mut self)
Inform the playing or queued sounds that a new batch of samples will be
requested. This must only be called when the next sample to be delivered
from next_sample
is for the first channel.
source§fn channel_count(&self) -> u16
fn channel_count(&self) -> u16
source§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
source§fn next_frame(&mut self) -> Result<Vec<i16>, Result<NextSample, Error>>
fn next_frame(&mut self) -> Result<Vec<i16>, Result<NextSample, Error>>
source§fn append_next_frame_to(
&mut self,
samples: &mut Vec<i16>
) -> Result<(), Result<NextSample, Error>>
fn append_next_frame_to( &mut self, samples: &mut Vec<i16> ) -> Result<(), Result<NextSample, Error>>
next_frame
but samples are appended into an existing Vec. Read moresource§fn into_memory_sound(self) -> Result<MemorySound, Error>where
Self: Sized,
fn into_memory_sound(self) -> Result<MemorySound, Error>where
Self: Sized,
source§fn loop_from_memory(self) -> Result<MemorySound, Error>where
Self: Sized,
fn loop_from_memory(self) -> Result<MemorySound, Error>where
Self: Sized,
source§fn controllable(self) -> (Controllable<Self>, Controller<Self>)where
Self: Sized,
fn controllable(self) -> (Controllable<Self>, Controller<Self>)where
Self: Sized,
Controller
. Read moresource§fn with_async_completion_notifier(
self
) -> (AsyncCompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
fn with_async_completion_notifier(
self
) -> (AsyncCompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
source§fn with_completion_notifier(self) -> (CompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
fn with_completion_notifier(self) -> (CompletionNotifier<Self>, Receiver<()>)where
Self: Sized,
source§fn with_adjustable_volume(self) -> AdjustableVolume<Self>where
Self: Sized,
fn with_adjustable_volume(self) -> AdjustableVolume<Self>where
Self: Sized,
set_volume
.source§fn with_adjustable_volume_of(
self,
volume_adjustment: f32
) -> AdjustableVolume<Self>where
Self: Sized,
fn with_adjustable_volume_of(
self,
volume_adjustment: f32
) -> AdjustableVolume<Self>where
Self: Sized,
set_volume
and set
the initial volume adjustment.source§fn with_adjustable_speed(self) -> AdjustableSpeed<Self>where
Self: Sized,
fn with_adjustable_speed(self) -> AdjustableSpeed<Self>where
Self: Sized,
set_speed
. Read moresource§fn with_adjustable_speed_of(
self,
speed_adjustment: f32
) -> AdjustableSpeed<Self>where
Self: Sized,
fn with_adjustable_speed_of(
self,
speed_adjustment: f32
) -> AdjustableSpeed<Self>where
Self: Sized,
set_speed
and set
the initial speed adjustment. Read moresource§fn pausable(self) -> Pausable<Self>where
Self: Sized,
fn pausable(self) -> Pausable<Self>where
Self: Sized,
set_paused
. Starts unpaused.source§fn paused(self) -> Pausable<Self>where
Self: Sized,
fn paused(self) -> Pausable<Self>where
Self: Sized,
set_paused
. Starts paused.source§fn finish_after(self, duration: Duration) -> FinishAfter<Self>where
Self: Sized,
fn finish_after(self, duration: Duration) -> FinishAfter<Self>where
Self: Sized,
duration
of the sound, then finish even if samples
remain. Read more