Struct ears::Music [] [src]

pub struct Music { /* fields omitted */ }

Play Music easily.

Simple class to play music easily in 2 lines.

Music is played in their own task and the samples are loaded progressively using circular buffers. They aren't associated to a SoundData like Sounds.

Examples

extern crate ears;
use ears::{Music, AudioController};

fn main() -> () {
  let mut msc = Music::new("path/to/music.flac").unwrap();
  msc.play();
}

Methods

impl Music
[src]

Create a new Music

Argument

  • path - The path of the file to load the music

Return

An Option containing Some(Music) on success, None otherwise

Trait Implementations

impl AudioTags for Music
[src]

Get the tags of a Sound.

Return

A borrowed pointer to the internal struct SoundTags

impl AudioController for Music
[src]

Play or resume the Music.

Pause the Music.

Stop the Music.

Check if the Music is playing or not.

Return

True if the Music is playing, false otherwise.

Get the current state of the Music

Return

The state of the music as a variant of the enum State

Set the volume of the Music.

A value of 1.0 means unattenuated. Each division by 2 equals an attenuation of about -6dB. Each multiplicaton by 2 equals an amplification of about +6dB.

Argument

  • volume - The volume of the Music, should be between 0. and 1.

Get the volume of the Music.

Return

The volume of the Music between 0. and 1.

Set the minimal volume for a Music.

The minimum volume allowed for a music, after distance and cone attenation is applied (if applicable).

Argument

  • min_volume - The new minimal volume of the Music should be between 0. and 1.

Get the minimal volume of the Music.

Return

The minimal volume of the Music between 0. and 1.

Set the maximal volume for a Music.

The maximum volume allowed for a Music, after distance and cone attenation is applied (if applicable).

Argument

  • max_volume - The new maximal volume of the Music should be between 0. and 1.

Get the maximal volume of the Music.

Return

The maximal volume of the Music between 0. and 1.

Set the Music looping or not

The default looping is false.

Arguments

looping - The new looping state.

Check if the Music is looping or not

Return

True if the Music is looping, false otherwise.

Set the pitch of the Music.

A multiplier for the frequency (sample rate) of the Music's buffer.

Default pitch is 1.0.

Argument

  • new_pitch - The new pitch of the Music in the range [0.5 - 2.0]

Set the pitch of the Music.

Return

The pitch of the Music in the range [0.5 - 2.0]

Set the position of the Music relative to the listener or absolute.

Default position is absolute.

Argument

relative - True to set Music relative to the listener false to set the Music position absolute.

Is the Music relative to the listener or not?

Return

True if the Music is relative to the listener false otherwise

Set the Music location in three dimensional space.

OpenAL, like OpenGL, uses a right handed coordinate system, where in a frontal default view X (thumb) points right, Y points up (index finger), and Z points towards the viewer/camera (middle finger). To switch from a left handed coordinate system, flip the sign on the Z coordinate.

Default position is [0., 0., 0.].

Argument

  • position - A three dimensional vector of f32 containing the position of the listener [x, y, z].

Get the position of the Music in three dimensional space.

Return

A three dimensional vector of f32 containing the position of the listener [x, y, z].

Set the direction of the Music.

Specifies the current direction in local space.

The default direction is: [0., 0., 0.]

Argument

direction - The new direction of the Music.

Get the direction of the Music.

Return

The current direction of the Music.

Set the maximum distance of the Music.

The distance above which the source is not attenuated any further with a clamped distance model, or where attenuation reaches 0.0 gain for linear distance models with a default rolloff factor.

The default maximum distance is +inf.

Argument

max_distance - The new maximum distance in the range [0., +inf]

Get the maximum distance of the Music.

Return

The maximum distance of the Music in the range [0., +inf]

Set the reference distance of the Music.

The distance in units that no attenuation occurs. At 0.0, no distance attenuation ever occurs on non-linear attenuation models.

The default distance reference is 1.

Argument

  • ref_distance - The new reference distance of the Music.

Get the reference distance of the Music.

Return

The current reference distance of the Music.

Set the attenuation of a Music.

Multiplier to exaggerate or diminish distance attenuation. At 0.0, no distance attenuation ever occurs.

The default attenuation is 1.

Arguments

attenuation - The new attenuation for the Music in the range [0., 1.].

Get the attenuation of a Music.

Return

The current attenuation for the Music in the range [0., 1.].

impl Drop for Music
[src]

Destroy all the resources of the Music.