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