pub struct SoundRef { /* private fields */ }
Expand description
A weak reference to a sound.
Methods from Deref<Target = Sound>§
pub fn sound_ref(&self) -> SoundRef
Sourcepub fn get_3d_cone_settings(&self) -> Result<(f32, f32, f32), Error>
pub fn get_3d_cone_settings(&self) -> Result<(f32, f32, f32), Error>
Retrieves the inside and outside angles of the sound projection cone.
Returns (insideconeangle, outsideconeangle, outsidevolume)
.
Sourcepub fn get_3d_min_max_distance(&self) -> Result<(f32, f32), Error>
pub fn get_3d_min_max_distance(&self) -> Result<(f32, f32), Error>
Retrieve the minimum and maximum audible distance for a sound.
Sourcepub fn get_defaults(&self) -> Result<(f32, i32), Error>
pub fn get_defaults(&self) -> Result<(f32, i32), Error>
Retrieves a sound’s default attributes for when it is played on a channel
with Sound::play()
.
Returns (frequency, priority)
.
Sourcepub fn get_format(&self) -> Result<(Type, Format, i32, i32), Error>
pub fn get_format(&self) -> Result<(Type, Format, i32, i32), Error>
Returns format information about the sound.
Returns (type, format, channels, bits)
.
pub fn get_length(&self, timeunit: Timeunit) -> Result<u32, Error>
pub fn get_loop_count(&self) -> Result<i32, Error>
pub fn get_loop_points( &self, loopstarttype: Timeunit, loopendtype: Timeunit, ) -> Result<(u32, u32), Error>
pub fn get_mode(&self) -> Result<Mode, Error>
Sourcepub fn get_open_state(&self) -> Result<(Openstate, u32, bool, bool), Error>
pub fn get_open_state(&self) -> Result<(Openstate, u32, bool, bool), Error>
Retrieves the state a sound is in after Mode::NONBLOCKING
has been used
to open it, or the state of the streaming buffer.
Returns (openstate, percentbuffered, starving, diskbusy)
.
pub fn get_name(&self) -> Result<String, Error>
pub fn get_num_sub_sounds(&self) -> Result<i32, Error>
pub fn get_num_sync_points(&self) -> Result<i32, Error>
Retrieves the number of tags belonging to a sound.
Returns (numtags, numtagsupdated)
:
numtags
– Number of tags in the sound.numtagsupdated
– Number of tags updated since this function was last called.
Sourcepub fn play(
&mut self,
channel_group: Option<&mut ChannelGroup>,
paused: bool,
) -> Result<Channel, Error>
pub fn play( &mut self, channel_group: Option<&mut ChannelGroup>, paused: bool, ) -> Result<Channel, Error>
Start playing this sound, returning a handle to the virtual channel that was assigned.
If another sound is played and there are no free channels, this channel
handle may be stolen, invalidating it and causing all subsequent
Channel
method calls to return Error::ChannelStolen
. The channel
handle will also be invalidated by the next system.update()
if
(non-looping) playback reaches the end of the sound, or if
channel.stop()
is called.
The Channel object will hold a reference to this sound, preventing it from being dropped until the channel is also dropped. Note that this reference will remain active until the channel object is dropped, even if the channel handle has been invalidated.
If the sound is dropped and it is currently playing on some channel(s) (for which no channel object(s) are alive), those channels will cease playback.
Examples found in repository?
12fn main() {
13 println!("fmod example main...");
14
15 let mut system = System::default().unwrap();
16 hex!(fmod::FMOD_VERSION);
17 hex!(system.get_version().unwrap());
18
19 let sound_filename = "bite.wav";
20 println!(" opening {sound_filename:?}");
21 let mut sound = system.create_sound_from_file_default (sound_filename)
22 .unwrap();
23 println!(" playing {sound_filename:?}");
24 let channel = sound.play (None, false).unwrap();
25 while channel.is_playing().unwrap() {
26 std::thread::sleep (std::time::Duration::from_millis (100));
27 }
28 println!("...fmod example main");
29}
Sourcepub fn set_defaults(&self, frequency: f32, priority: u8) -> Result<(), Error>
pub fn set_defaults(&self, frequency: f32, priority: u8) -> Result<(), Error>
Set default frequency and priority with calls to play()
.
priority
is 0-255 with ‘0’ = high priority, ‘128’ = default; note the
low-level FMOD uses an i32
for this argument and accepts a range of
0-256
, here we use a u8
to constrain the range of inputs which also
makes the priority 256
unusable.