Struct tetra::audio::SoundInstance
source · pub struct SoundInstance { /* private fields */ }
Expand description
A handle to a single instance of a Sound
.
The audio thread will poll this for updates every 220 samples (roughly every 5ms at a 44100hz sample rate).
Cloning a SoundInstance
will create a new handle to the same instance,
rather than creating a new instance.
Note that dropping a SoundInstance
does not stop playback, and the underlying
data will not be freed until playback has finished. This means that dropping a
repeating SoundInstance
without stopping it
first will cause the sound to loop forever.
Implementations§
source§impl SoundInstance
impl SoundInstance
sourcepub fn stop(&self)
pub fn stop(&self)
Stops the sound. If playback is resumed, it will start over from the beginning.
sourcepub fn pause(&self)
pub fn pause(&self)
Pauses the sound. If playback is resumed, it will continue from the point where it was paused.
sourcepub fn state(&self) -> SoundState
pub fn state(&self) -> SoundState
Returns the current state of playback.
sourcepub fn set_state(&self, state: SoundState)
pub fn set_state(&self, state: SoundState)
sourcepub fn set_volume(&self, volume: f32)
pub fn set_volume(&self, volume: f32)
Sets the volume of the sound.
The parameter is used as a multiplier - for example, 1.0
would result in the
sound being played back at its original volume.
sourcepub fn set_speed(&self, speed: f32)
pub fn set_speed(&self, speed: f32)
Sets the speed (and by extension, the pitch) of the sound.
The parameter is used as a multiplier - for example, 1.0
would result in the
sound being played back at its original speed.
sourcepub fn set_repeating(&self, repeating: bool)
pub fn set_repeating(&self, repeating: bool)
Sets whether the sound should repeat or not.
sourcepub fn toggle_repeating(&self)
pub fn toggle_repeating(&self)
Toggles whether the sound should repeat or not.
Trait Implementations§
source§impl Clone for SoundInstance
impl Clone for SoundInstance
source§fn clone(&self) -> SoundInstance
fn clone(&self) -> SoundInstance
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more