[−][src]Struct ears::Music
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 AudioController for Music
[src]
fn play(&mut self)
[src]
Play or resume the Music.
fn pause(&mut self)
[src]
Pause the Music.
fn stop(&mut self)
[src]
Stop the Music.
fn connect(&mut self, reverb_effect: &Option<ReverbEffect>)
[src]
Connect a ReverbEffect to the Music
fn is_playing(&self) -> bool
[src]
fn get_state(&self) -> State
[src]
fn set_volume(&mut self, volume: f32)
[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
fn get_volume(&self) -> f32
[src]
fn set_min_volume(&mut self, min_volume: f32)
[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
fn get_min_volume(&self) -> f32
[src]
fn set_max_volume(&mut self, max_volume: f32)
[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
fn get_max_volume(&self) -> f32
[src]
fn set_looping(&mut self, looping: bool)
[src]
Set the Music looping or not
The default looping is false.
Arguments
looping
- The new looping state.
fn is_looping(&self) -> bool
[src]
fn set_pitch(&mut self, pitch: f32)
[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]
fn get_pitch(&self) -> f32
[src]
fn set_relative(&mut self, relative: bool)
[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.
fn is_relative(&mut self) -> bool
[src]
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])
[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].
fn get_position(&self) -> [f32; 3]
[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].
fn set_direction(&mut self, direction: [f32; 3])
[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.
fn get_direction(&self) -> [f32; 3]
[src]
fn set_max_distance(&mut self, max_distance: f32)
[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]
fn get_max_distance(&self) -> f32
[src]
Get the maximum distance of the Music.
Return
The maximum distance of the Music in the range [0.0, +inf]
fn set_reference_distance(&mut self, ref_distance: f32)
[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.
fn get_reference_distance(&self) -> f32
[src]
fn set_attenuation(&mut self, attenuation: f32)
[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].
fn get_attenuation(&self) -> f32
[src]
Get the attenuation of a Music.
Return
The current attenuation for the Music in the range [0.0, 1.0].
fn set_direct_channel(&mut self, enabled: bool)
[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
fn get_direct_channel(&self) -> bool
[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
fn get_duration(&self) -> Duration
[src]
Returns the duration of the Music.
impl AudioTags for Music
[src]
impl Drop for Music
[src]
Auto Trait Implementations
impl Send for Music
impl Unpin for Music
impl !Sync for Music
impl !UnwindSafe for Music
impl !RefUnwindSafe for Music
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,