Trait ears::AudioController [] [src]

pub trait AudioController {
    fn play(&mut self);
fn pause(&mut self);
fn stop(&mut self);
fn is_playing(&self) -> bool;
fn get_state(&self) -> State;
fn set_volume(&mut self, volume: f32);
fn get_volume(&self) -> f32;
fn set_min_volume(&mut self, min_volume: f32);
fn get_min_volume(&self) -> f32;
fn set_max_volume(&mut self, max_volume: f32);
fn get_max_volume(&self) -> f32;
fn set_looping(&mut self, looping: bool);
fn is_looping(&self) -> bool;
fn set_pitch(&mut self, pitch: f32);
fn get_pitch(&self) -> f32;
fn set_relative(&mut self, relative: bool);
fn is_relative(&mut self) -> bool;
fn set_position(&mut self, position: [f32; 3]);
fn get_position(&self) -> [f32; 3];
fn set_direction(&mut self, direction: [f32; 3]);
fn get_direction(&self) -> [f32; 3];
fn set_max_distance(&mut self, max_distance: f32);
fn get_max_distance(&self) -> f32;
fn set_reference_distance(&mut self, ref_distance: f32);
fn get_reference_distance(&self) -> f32;
fn set_attenuation(&mut self, attenuation: f32);
fn get_attenuation(&self) -> f32;
fn set_direct_channel(&mut self, enabled: bool);
fn get_direct_channel(&self) -> bool; }

The functionnality that an Audio Source should provide.

Required Methods

Play or resume the Audio Source.

Pause the Audio Source.

Stop the Audio Source.

Check if the Audio Source is playing or not.

Return

true if the Audio Source is playing, false otherwise.

Get the current state of the Audio Source

Return

The state of the Audio Source as a variant of the enum State

Set the volume of the Audio Source.

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 Audio Source, should be between 0.0 and 1.0

Get the volume of the Audio Source.

Return

The volume of the Audio Source between 0.0 and 1.0

Set the minimal volume for a Audio Source.

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

Argument

  • min_volume - The new minimal volume of the Audio Source should be between 0.0 and 1.0

Get the minimal volume of the Audio Source.

Return

The minimal volume of the Audio Source between 0.0 and 1.0

Set the maximal volume for a Audio Source.

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

Argument

  • max_volume - The new maximal volume of the Audio Source should be between 0.0 and 1.0

Get the maximal volume of the Audio Source.

Return

The maximal volume of the Audio Source between 0.0 and 1.0

Set the Audio Source looping or not

The default looping is false.

Arguments

looping - The new looping state.

Check if the Audio Source is looping or not

Return

True if the Audio Source is looping, false otherwise.

Set the pitch of the source.

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

Default pitch is 1.0.

Argument

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

Set the pitch of the source.

Return

The pitch of the Audio Source in the range [0.5 - 2.0]

Set the position of the Audio Source relative to the listener or absolute.

Default position is absolute.

Argument

relative - True to set Audio Source relative to the listener false to set the Audio Source position absolute.

Is the Audio Source relative to the listener or not ?

Return

True if the Audio Source is relative to the listener false otherwise

Set the Audio Source 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].

Get the position of the Audio Source 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 Audio Source.

Specifies the current direction in local space.

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

Argument

direction - The new direction of the Audio Source.

Get the direction of the Audio Source.

Return

The current direction of the Audio Source.

Set the maximum distance of the Audio Source.

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]

Get the maximum distance of the Audio Source.

Return

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

Set the reference distance of the Audio Source.

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 Audio Source.

Get the reference distance of the Audio Source.

Return

The current reference distance of the Audio Source.

Set the attenuation of a Audio Source.

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 Audio Source in the range [0.0, 1.0].

Get the attenuation of a Sound.

Return

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

Enable or disable direct channel mode for an Audio Source.

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

Returns whether direct channel is enabled or not.

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

Return

true if source is using direct channel mode false otherwise

Implementors