Files
FlaxEngine/Source/Engine/Audio/Audio.h
T

133 lines
4.3 KiB
C++

// Copyright (c) Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Delegate.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingType.h"
#include "AudioDevice.h"
#include "Types.h"
/// <summary>
/// The audio service used for music and sound effects playback.
/// </summary>
API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API Audio
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(Audio);
friend class AudioStreamingHandler;
friend class AudioClip;
public:
/// <summary>
/// The audio listeners collection registered by the service.
/// </summary>
static Array<AudioListener*> Listeners;
/// <summary>
/// The audio sources collection registered by the service.
/// </summary>
static Array<AudioSource*> Sources;
/// <summary>
/// The all audio devices.
/// </summary>
API_FIELD(ReadOnly) static Array<AudioDevice> Devices;
/// <summary>
/// Event called when audio devices collection gets changed.
/// </summary>
API_EVENT() static Action DevicesChanged;
/// <summary>
/// Event called when the active audio device gets changed.
/// </summary>
API_EVENT() static Action ActiveDeviceChanged;
/// <summary>
/// Event called when a new audio device is connected to the system.
/// </summary>
API_EVENT() static Action DeviceAdded;
/// <summary>
/// Event called when an audio device is disconnected from the system.
/// </summary>
API_EVENT() static Action DeviceRemoved;
public:
/// <summary>
/// Gets the active device.
/// </summary>
/// <returns>The active device.</returns>
API_PROPERTY() static AudioDevice* GetActiveDevice();
/// <summary>
/// Gets the index of the active device. Returns -1 if set to system default mode.
/// </summary>
/// <returns>The active device index.</returns>
API_PROPERTY() static int32 GetActiveDeviceIndex();
/// <summary>
/// Gets the resolved index in Devices array of the device currently playing (resolves system default mode to the actual device index).
/// </summary>
/// <returns>The resolved active device index.</returns>
API_PROPERTY() static int32 GetActiveDeviceResolvedIndex();
/// <summary>
/// Sets the index of the active device.
/// </summary>
/// <param name="index">The index.</param>
API_PROPERTY() static void SetActiveDeviceIndex(int32 index);
/// <summary>
/// Sets the index of the active device without notifying backend.
/// </summary>
/// <param name="index">The index.</param>
static void SetActiveDeviceIndexSilent(int32 index);
/// <summary>
/// Gets the internal device name explicitly selected by the user (empty if using dynamic system default device).
/// </summary>
static const StringAnsi& GetExplicitDeviceName();
/// <summary>
/// Sets the system default internal device name.
/// </summary>
static void SetSystemDefaultDeviceName(const StringAnsi& name);
public:
/// <summary>
/// Gets the master volume applied to all the audio sources (normalized to range 0-1).
/// </summary>
/// <returns>The value</returns>
API_PROPERTY() static float GetMasterVolume();
/// <summary>
/// Sets the master volume applied to all the audio sources (normalized to range 0-1).
/// </summary>
/// <param name="value">The value.</param>
API_PROPERTY() static void SetMasterVolume(float value);
/// <summary>
/// Gets the actual master volume (including all side effects and mute effectors).
/// </summary>
/// <returns>The final audio volume applied to all the listeners.</returns>
API_PROPERTY() static float GetVolume();
/// <summary>
/// Sets the doppler effect factor. Scale for source and listener velocities. Default is 1.
/// </summary>
/// <param name="value">The value.</param>
API_PROPERTY() static void SetDopplerFactor(float value);
/// <summary>
/// Gets the preference to use HRTF audio (when available on platform). Default is true.
/// </summary>
API_PROPERTY() static bool GetEnableHRTF();
/// <summary>
/// Sets the preference to use HRTF audio (when available on platform). Default is true.
/// </summary>
/// <param name="value">The value.</param>
API_PROPERTY() static void SetEnableHRTF(bool value);
};