class Audio

Inherits: Module<Audio>

Provides global functionality relating to sounds and music.

Public

Methods

~Audio

virtual ~Audio() noexcept = default

Play

void Play(const HAudioClip &clip, const Vector3 &position = Vector3::kZero, float volume = 1.F)

Starts playback of the provided audio clip.

This can be used for a quicker way of creating audio sources if you don't need the full control provided by creating AudioSource manually.

clip
Audio clip to play.
position
Position in world space to play the clip at. Only relevant if the clip is 3D.
volume
Volume to play the clip at.

SetVolume

virtual void SetVolume(float volume) = 0

Determines global audio volume.

In range [0, 1].

GetVolume

virtual float GetVolume() const = 0

SetPaused

virtual void SetPaused(bool paused) = 0

Determines if audio reproduction is paused globally.

IsPaused

virtual bool IsPaused() const = 0

SetActiveDevice

virtual void SetActiveDevice(const AudioDevice &device) = 0

Determines the device on which is the audio played back on.

GetActiveDevice

virtual AudioDevice GetActiveDevice() const = 0

GetDefaultDevice

virtual AudioDevice GetDefaultDevice() const = 0

Returns the default audio device identifier.

GetAllDevices

virtual const Vector<AudioDevice> &GetAllDevices() const = 0

Returns a list of all available audio devices.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Internal

Methods

Update

virtual void Update()

Called once per frame.

Queues streaming audio requests.

Protected

Methods

CreateClip

virtual SPtr<AudioClip> CreateClip(const SPtr<DataStream> &samples, u32 streamSize, u32 sampleCount, const AudioClipCreateInformation &createInformation) = 0

Creates a new audio clip.

samples
Stream containing audio samples in format specified in .
streamSize
Size of the audio data in the provided stream, in bytes.
sampleCount
Number of samples in stream.
createInformation
Descriptor describing the type of the audio stream (format, sample rate, etc.).

Returns: Newly created AudioClip. Must be manually initialized.

CreateListener

virtual SPtr<IAudioListenerImplementation> CreateListener() = 0

Creates a new AudioListener.

CreateSource

virtual SPtr<IAudioSourceImplementation> CreateSource() = 0

Creates a new AudioSource.

StopManualSources

void StopManualSources()

Stops playback of all sources started with Audio::Play calls.

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Fields

mManualSources

Vector<SPtr<IAudioSourceImplementation>> mManualSources

mTempSources

Vector<SPtr<IAudioSourceImplementation>> mTempSources