// Copyright (c) 2012-2023 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) 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; public: /// /// Gets the active device. /// /// The active device. API_PROPERTY() static AudioDevice* GetActiveDevice(); /// /// Gets the index of the active device. /// /// The active device index. API_PROPERTY() static int32 GetActiveDeviceIndex(); /// /// Sets the index of the active device. /// /// The index. API_PROPERTY() static void SetActiveDeviceIndex(int32 index); 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); public: static void OnAddListener(AudioListener* listener); static void OnRemoveListener(AudioListener* listener); static void OnAddSource(AudioSource* source); static void OnRemoveSource(AudioSource* source); };