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]
Trait Implementations
impl AudioTags for Music
[src]
impl AudioController for Music
[src]
fn play(&mut self)
Play or resume the Music.
fn pause(&mut self)
Pause the Music.
fn stop(&mut self)
Stop the Music.
fn is_playing(&self) -> bool
fn get_state(&self) -> State
fn set_volume(&mut self, volume: f32)
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.
fn get_volume(&self) -> f32
fn set_min_volume(&mut self, min_volume: f32)
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.
fn get_min_volume(&self) -> f32
fn set_max_volume(&mut self, max_volume: f32)
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.
fn get_max_volume(&self) -> f32
fn set_looping(&mut self, looping: bool)
Set the Music looping or not
The default looping is false.
Arguments
looping
- The new looping state.
fn is_looping(&self) -> bool
fn set_pitch(&mut self, pitch: f32)
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]
fn get_pitch(&self) -> f32
fn set_relative(&mut self, relative: bool)
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.
fn is_relative(&mut self) -> bool
Is the Music relative to the listener or not?
Return
True if the Music is relative to the listener false otherwise
fn set_position(&mut self, position: [f32; 3])
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].
fn get_position(&self) -> [f32; 3]
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].
fn set_direction(&mut self, direction: [f32; 3])
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.
fn get_direction(&self) -> [f32; 3]
fn set_max_distance(&mut self, max_distance: f32)
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]
fn get_max_distance(&self) -> f32
Get the maximum distance of the Music.
Return
The maximum distance of the Music in the range [0., +inf]
fn set_reference_distance(&mut self, ref_distance: f32)
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.
fn get_reference_distance(&self) -> f32
fn set_attenuation(&mut self, attenuation: f32)
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.].
fn get_attenuation(&self) -> f32
impl Drop for Music
[src]
fn drop(&mut self)
Destroy all the resources of the Music.