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]

[src]

Create a new Music

Argument

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

Return

A Result containing Ok(Music) on success, Err(String) if there has been an error.

Trait Implementations

impl AudioTags for Music
[src]

[src]

Get the tags of a Sound.

Return

A borrowed pointer to the internal struct SoundTags

impl AudioController for Music
[src]

[src]

Play or resume the Music.

[src]

Pause the Music.

[src]

Stop the Music.

[src]

Check if the Music is playing or not.

Return

True if the Music is playing, false otherwise.

[src]

Get the current state of the Music

Return

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

[src]

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.0 and 1.0

[src]

Get the volume of the Music.

Return

The volume of the Music between 0.0 and 1.0

[src]

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.0 and 1.0

[src]

Get the minimal volume of the Music.

Return

The minimal volume of the Music between 0.0 and 1.0

[src]

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.0 and 1.0

[src]

Get the maximal volume of the Music.

Return

The maximal volume of the Music between 0.0 and 1.0

[src]

Set the Music looping or not

The default looping is false.

Arguments

looping - The new looping state.

[src]

Check if the Music is looping or not

Return

True if the Music is looping, false otherwise.

[src]

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]

[src]

Set the pitch of the Music.

Return

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

[src]

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.

[src]

Is the Music relative to the listener or not?

Return

True if the Music is relative to the listener false otherwise

[src]

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.0, 0.0].

Argument

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

[src]

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

[src]

Set the direction of the Music.

Specifies the current direction in local space.

The default direction is: [0.0, 0.0, 0.0]

Argument

direction - The new direction of the Music.

[src]

Get the direction of the Music.

Return

The current direction of the Music.

[src]

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.0, +inf]

[src]

Get the maximum distance of the Music.

Return

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

[src]

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.

[src]

Get the reference distance of the Music.

Return

The current reference distance of the Music.

[src]

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.0, 1.0].

[src]

Get the attenuation of a Music.

Return

The current attenuation for the Music in the range [0.0, 1.0].

[src]

Enable or disable direct channel mode for a Music.

Sometimes audio tracks are authored with their own spatialization effects, where the AL's virtualization methods can cause a notable decrease in audio quality.

The AL_SOFT_direct_channels extension provides a mechanism for applications to specify whether audio should be filtered according to the AL's channel virtualization rules for multi-channel buffers.

When set to true, the audio channels are not virtualized and play directly on the matching output channels if they exist, otherwise they are dropped. Applies only when the extension exists and when playing non-mono buffers.

http://kcat.strangesoft.net/openal-extensions/SOFT_direct_channels.txt

The default is false.

Argument

  • enabled - true to enable direct channel mode, false to disable

[src]

Returns whether direct channel is enabled or not for a Music.

Will always return false if the AL_SOFT_direct_channels extension is not present.

Return

true if the Music is using direct channel mode false otherwise

impl Drop for Music
[src]

[src]

Destroy all the resources of the Music.

Auto Trait Implementations

impl Send for Music

impl !Sync for Music