Audio

Struct Audio 

Source
pub struct Audio {}
Expand description

A interface of an audio player.

Implementations§

Source§

impl Audio

Source

pub fn set_sound_speed(val: f32)

Sets The speed of the 3D sound.

Source

pub fn get_sound_speed() -> f32

Gets The speed of the 3D sound.

Source

pub fn set_global_volume(val: f32)

Sets The global volume of the audio. The value is between 0.0 and 1.0.

Source

pub fn get_global_volume() -> f32

Gets The global volume of the audio. The value is between 0.0 and 1.0.

Source

pub fn set_listener(val: &dyn INode)

Sets The 3D listener as a node of the audio.

Source

pub fn get_listener() -> Option<Node>

Gets The 3D listener as a node of the audio.

Source

pub fn play(filename: &str, looping: bool) -> i32

Plays a sound effect and returns a handler for the audio.

§Arguments
  • filename - The path to the sound effect file (must be a WAV file).
  • loop - Optional. Whether to loop the sound effect. Default is false.
§Returns
  • i32 - A handler for the audio that can be used to stop the sound effect.
Source

pub fn stop(handle: i32)

Stops a sound effect that is currently playing.

§Arguments
  • handler - The handler for the audio that is returned by the play function.
Source

pub fn play_stream(filename: &str, looping: bool, cross_fade_time: f32)

Plays a streaming audio file.

§Arguments
  • filename - The path to the streaming audio file (can be OGG, WAV, MP3, or FLAC).
  • loop - Whether to loop the streaming audio.
  • crossFadeTime - The time (in seconds) to crossfade between the previous and new streaming audio.
Source

pub fn stop_stream(fade_time: f32)

Stops a streaming audio file that is currently playing.

§Arguments
  • fade_time - The time (in seconds) to fade out the streaming audio.
Source

pub fn set_pause_all_current(pause: bool)

Pauses all the current audio.

§Arguments
  • pause - Whether to pause the audio.
Source

pub fn set_listener_at(at_x: f32, at_y: f32, at_z: f32)

Sets the position of the 3D listener.

§Arguments
  • atX - The X coordinate of the listener position.
  • atY - The Y coordinate of the listener position.
  • atZ - The Z coordinate of the listener position.
Source

pub fn set_listener_up(up_x: f32, up_y: f32, up_z: f32)

Sets the up vector of the 3D listener.

§Arguments
  • upX - The X coordinate of the listener up vector.
  • upY - The Y coordinate of the listener up vector.
  • upZ - The Z coordinate of the listener up vector.
Source

pub fn set_listener_velocity(velocity_x: f32, velocity_y: f32, velocity_z: f32)

Sets the velocity of the 3D listener.

§Arguments
  • velocityX - The X coordinate of the listener velocity.
  • velocityY - The Y coordinate of the listener velocity.
  • velocityZ - The Z coordinate of the listener velocity.

Auto Trait Implementations§

§

impl Freeze for Audio

§

impl RefUnwindSafe for Audio

§

impl Send for Audio

§

impl Sync for Audio

§

impl Unpin for Audio

§

impl UnwindSafe for Audio

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