pub struct Speaker { /* private fields */ }Expand description
The headless backend’s sound device: it records what the last frame
played, works out which music “sounds” from the music commands and the
clock, and keeps the sounds started with a handle until they stop (one
that plays once too: it knows no lengths). Like shuyi-app, it mutes
rather than pauses: while suspended its music
clock runs on. It keeps the sounds the game added at run time, and
hears every play of them (added_plays). A voice
clip sounds from its request until it is stopped or replaced, or until
the length a test gave clips has passed
(set_voice_length).
Implementations§
Source§impl Speaker
impl Speaker
Sourcepub fn set_load_delay(&mut self, seconds: f64)
pub fn set_load_delay(&mut self, seconds: f64)
Makes music take seconds to load: a track sounds that long after
the game starts it (at once by default). Negative or NaN counts as
0.
Sourcepub fn set_voice_length(&mut self, seconds: f64)
pub fn set_voice_length(&mut self, seconds: f64)
Makes every voice clip last seconds: it stops sounding that long
after it was asked for. Until this is called a clip sounds until it
is stopped or replaced. Negative or NaN counts as 0.
Sourcepub fn set_silent(&mut self)
pub fn set_silent(&mut self)
Makes no music ever sound, as when the music files are missing.
Sourcepub fn requests(&self) -> &[SoundRequest]
pub fn requests(&self) -> &[SoundRequest]
The sound and voice requests of the last frame that played any audio.
Sourcepub fn music(&self) -> &[MusicCommand]
pub fn music(&self) -> &[MusicCommand]
The music commands of the last frame that played audio.
Sourcepub fn volumes(&self) -> (f32, f32, f32)
pub fn volumes(&self) -> (f32, f32, f32)
The music, sound and voice volumes the last frame played at, 0–1; full before any.
Sourcepub fn sounds_playing(&self) -> &[PlayingSound]
pub fn sounds_playing(&self) -> &[PlayingSound]
The sounds started with a handle and not yet stopped, in id order.
Sourcepub fn suspended(&self) -> bool
pub fn suspended(&self) -> bool
Whether the audio is held because the system suspended the game.
Sourcepub fn added_sounds(&self) -> &BTreeMap<String, SharedSamples>
pub fn added_sounds(&self) -> &BTreeMap<String, SharedSamples>
The sounds the game added at run time and hasn’t removed, by cue.
Sourcepub fn added_plays(&self) -> &[AddedPlay]
pub fn added_plays(&self) -> &[AddedPlay]
Every play and start of a sound the game added, in order, since the speaker was made: what each played.
Trait Implementations§
Source§impl Audio for Speaker
impl Audio for Speaker
Source§fn music_playing(&self, now: Millis) -> Option<(&str, f64)>
fn music_playing(&self, now: Millis) -> Option<(&str, f64)>
now: its cue and the seconds since it really
started (once its file had loaded), or None in silence: nothing
asked for, a track still loading or whose file failed. Of two
tracks sounding (a crossfade), the newest: the old one until the
new one has loaded.Source§fn voice_playing(&self, now: Millis) -> Option<&str>
fn voice_playing(&self, now: Millis) -> Option<&str>
now, by its file
(SoundRequest::Voice), or asked for and still loading: None
once it has ended, and for a clip stopped, replaced, whose file
failed or that loaded too late to be played. A clip held by
suspend still sounds. None by default, for a
device that plays no voices.Source§fn play(&mut self, frame: &AudioFrame<'_>, now: Millis)
fn play(&mut self, frame: &AudioFrame<'_>, now: Millis)
frame of audio at now: the volumes first, then
the requests and the music commands in order. It also checks on
what is still loading, so it is called every frame, with nothing to
play too.Source§fn stop_all(&mut self)
fn stop_all(&mut self)
Source§fn suspend(&mut self)
fn suspend(&mut self)
SystemEvent::Suspend); sound
cues played once finish. Pauses, or mutes where the backend can’t
pause. A second call does nothing. Read moreSource§fn resume(&mut self)
fn resume(&mut self)
suspend held, and leaves a
SoundRequest::PauseSounds pause in place. A call while not
suspended does nothing.