Struct audio_source

Struct Documentation

struct legion::audio::audio_source

Public Types

enum sound_properties

Values:

enumerator pitch
enumerator gain
enumerator playState
enumerator doRewind
enumerator audioHandle
enumerator rollOffFactor
enumerator looping
enum playstate

Values:

enumerator stopped
enumerator playing
enumerator paused

Public Functions

inline void setPitch(float pitch) noexcept

Function to set the pitch for the audio source.

Parameters
  • pitch: new pitch value

inline float getPitch() const noexcept

Function to get the current pitch.

inline void setGain(float gain) noexcept

Function to set the gain for the audio source.

Parameters
  • gain: new gain value

inline float getGain() const noexcept

Function to get the current gain.

inline void setRollOffFactor(float factor) noexcept

Function to set the roll off factor for 3D audio.

Parameters
  • factor: only works for mono audio

inline void disableSpatialAudio() noexcept

Function to disable spatial (3D) Calls setRollOffFactor(0.0f)

inline void enableSpatialAudio() noexcept

Function to enable spatial (3D) Calls setRollOffFactor(1.0f)

inline void play() noexcept

Plays audio.

inline void pause() noexcept

Pauses audio.

inline void stop() noexcept

Stops audio Stopping means that the audio will stop playing (pausing) and rewind.

inline bool isPlaying() const noexcept

Returns whether the audio is playing If false the audio can be paused (isPaused()) or stopped (isStopped())

inline bool isPaused() const noexcept

Returns whether the audio is paused If false the audio can be playing (isPlaying()) or stopped (isStopped())

inline bool isStopped() const noexcept

Returns whether the audio is stopped If false the audio can be playing (isPlaying()) or paused (isPaused())

inline void setAudioHandle(audio_segment_handle handle) noexcept
inline void rewind() noexcept

Rewinds the audio If the audio is playing it will stop/pause If the audio was playing the audio source needs to be stopped or paused before it can play.

inline audio_segment_handle getAudioHandle() const noexcept
inline int getChannels() const

Gets the amount of channels in this audio source.

inline bool isStereo() const noexcept

Returns whether the audio-source is stereo (channels=2)

inline bool isMono() const noexcept

Returns whether the audio-source is mono (channels=1)

inline void setLooping(bool state = false) noexcept

Sets the looping state of the audio-source (true=looping)

inline bool isLooping() const noexcept

Gets the looping state of the audio-source (true=looping)

inline operator ALuint() const

Helper to implicitly convert to OpenAL source.

Friends

friend class AudioSystem