Sound

Struct Sound 

Source
pub struct Sound { /* private fields */ }
Expand description

A reference counted sound. When the last reference is dropped, the sound will be released.

Implementations§

Source§

impl Sound

Source

pub fn from_raw_parts(raw: *mut FMOD_SOUND, owned: bool, system: System) -> Self

Source

pub fn sound_ref(&self) -> SoundRef

Source

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).

Source

pub fn get_3d_min_max_distance(&self) -> Result<(f32, f32), Error>

Retrieve the minimum and maximum audible distance for a sound.

Source

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).

Source

pub fn get_format(&self) -> Result<(Type, Format, i32, i32), Error>

Returns format information about the sound.

Returns (type, format, channels, bits).

Source

pub fn get_length(&self, timeunit: Timeunit) -> Result<u32, Error>

Source

pub fn get_loop_count(&self) -> Result<i32, Error>

Source

pub fn get_loop_points( &self, loopstarttype: Timeunit, loopendtype: Timeunit, ) -> Result<(u32, u32), Error>

Source

pub fn get_mode(&self) -> Result<Mode, Error>

Source

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).

Source

pub fn get_name(&self) -> Result<String, Error>

Source

pub fn get_num_sub_sounds(&self) -> Result<i32, Error>

Source

pub fn get_num_sync_points(&self) -> Result<i32, Error>

Source

pub fn get_num_tags(&self) -> Result<(i32, 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.
Source

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?
examples/example.rs (line 24)
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}
Source

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.

Source

pub fn set_mode(&mut self, mode: Mode) -> Result<(), Error>

Trait Implementations§

Source§

impl Clone for Sound

Source§

fn clone(&self) -> Sound

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sound

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Sound

Source§

fn eq(&self, other: &Sound) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Sound

Auto Trait Implementations§

§

impl Freeze for Sound

§

impl RefUnwindSafe for Sound

§

impl !Send for Sound

§

impl !Sync for Sound

§

impl Unpin for Sound

§

impl UnwindSafe for Sound

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.