pub struct Voice { /* private fields */ }
Expand description
Manages a single FMOD Channel for monophonic playback.
When a sound is played by FMOD, it is assigned to play on a virtual channel and a weak handle to the channel is returned.
This handle will be invalidated after the next call to system.update()
if
playback has reached the end of a non-looping sound, or otherwise if
channel.stop()
is called. The channel can also be stolen by the priority
system if a new request to play a sound is made and there are no free
channels.
This type will act as a strong reference for a single playing sound, controlling playback using a single channel and re-acquiring it in the case the channel is stolen or invalidated, and stopping the channel when the voice is dropped.
Implementations§
Source§impl Voice
impl Voice
pub fn new() -> Self
pub const fn channel(&self) -> Option<&Channel>
pub const fn channel_mut(&mut self) -> Option<&mut Channel>
pub const fn channel_group(&self) -> Option<&ChannelGroup>
pub const fn channel_group_mut(&mut self) -> Option<&mut ChannelGroup>
pub fn is_playing(&self) -> Option<bool>
Sourcepub fn play(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
pub fn play(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
Play a 2D sound on a fresh channel.
Note that playing the same sound twice will re-acquire the channel. To restart
playback at the beginning of the sound use trigger()
.
Sourcepub fn loop_(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
pub fn loop_(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
Loop a 2D sound on a fresh channel.
Note that playing the same sound twice will re-acquire the channel. To restart
playback at the beginning of the sound use trigger()
.
Sourcepub fn play_from(
&mut self,
sound: &mut Sound,
channel_group: Option<ChannelGroup>,
position: u32,
)
pub fn play_from( &mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>, position: u32, )
Play a 2D sound on a fresh channel starting from the given position.
Note that playing the same sound twice will re-acquire the channel. To restart
playback at the beginning of the sound use trigger()
.
Sourcepub fn loop_from(
&mut self,
sound: &mut Sound,
channel_group: Option<ChannelGroup>,
position: u32,
)
pub fn loop_from( &mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>, position: u32, )
Play a 2D sound on a fresh channel starting from the given position.
Note that looping will loop back to the beginning of the sound when the end is reached.
Note that playing the same sound twice will re-acquire the channel. To restart
playback at the beginning of the sound use trigger()
.
Sourcepub fn cue(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
pub fn cue(&mut self, sound: &mut Sound, channel_group: Option<ChannelGroup>)
“Play” a 2D sound on a fresh channel with ‘paused = true’.
Sourcepub fn trigger(&mut self) -> Option<bool>
pub fn trigger(&mut self) -> Option<bool>
Set the position to the beginning of the sound in the un-paused state.
Returns Some(true) if the channel was playing and None if this voice is uninitialized.
Sourcepub fn pause(&mut self) -> Option<bool>
pub fn pause(&mut self) -> Option<bool>
Pauses playback.
Returns Some(true) if the channel was playing, and None if the voice was uninitialized.
Sourcepub fn resume(&mut self) -> Option<bool>
pub fn resume(&mut self) -> Option<bool>
Resumes playback.
Returns Some(true) if the channel was already playing, and None if the voice is uninitialized.