|
|
|
|
@@ -15,11 +15,10 @@
|
|
|
|
|
/// </remarks>
|
|
|
|
|
API_CLASS() class FLAXENGINE_API AudioSource : public Actor
|
|
|
|
|
{
|
|
|
|
|
DECLARE_SCENE_OBJECT(AudioSource);
|
|
|
|
|
DECLARE_SCENE_OBJECT(AudioSource);
|
|
|
|
|
friend class AudioStreamingHandler;
|
|
|
|
|
friend class AudioClip;
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Valid states in which AudioSource can be in.
|
|
|
|
|
/// </summary>
|
|
|
|
|
@@ -42,7 +41,6 @@ public:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
Vector3 _velocity;
|
|
|
|
|
Vector3 _prevPos;
|
|
|
|
|
float _volume;
|
|
|
|
|
@@ -61,7 +59,6 @@ private:
|
|
|
|
|
int32 _streamingFirstChunk = 0;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The internal IDs of this audio source used by the audio backend (unique ID per context/listener).
|
|
|
|
|
/// </summary>
|
|
|
|
|
@@ -76,7 +73,6 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the velocity of the source. Determines pitch in relation to AudioListener's position. Only relevant for spatial (3D) sources.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY() FORCE_INLINE const Vector3& GetVelocity() const
|
|
|
|
|
{
|
|
|
|
|
return _velocity;
|
|
|
|
|
@@ -85,7 +81,6 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the volume of the audio played from this source, in [0, 1] range.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="EditorOrder(20), DefaultValue(1.0f), Limit(0, 1, 0.01f), EditorDisplay(\"Audio Source\")")
|
|
|
|
|
FORCE_INLINE float GetVolume() const
|
|
|
|
|
{
|
|
|
|
|
@@ -95,13 +90,11 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the volume of the audio played from this source, in [0, 1] range.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetVolume(float value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the pitch of the played audio. The default is 1.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="EditorOrder(30), DefaultValue(1.0f), Limit(0.5f, 2.0f, 0.01f), EditorDisplay(\"Audio Source\")")
|
|
|
|
|
FORCE_INLINE float GetPitch() const
|
|
|
|
|
{
|
|
|
|
|
@@ -111,13 +104,11 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the pitch of the played audio. The default is 1.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetPitch(float value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the audio clip should loop when it finishes playing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(false), EditorDisplay(\"Audio Source\")")
|
|
|
|
|
FORCE_INLINE bool GetIsLooping() const
|
|
|
|
|
{
|
|
|
|
|
@@ -127,13 +118,11 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the audio clip should loop when it finishes playing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetIsLooping(bool value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the audio clip should auto play on level start.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="EditorOrder(50), DefaultValue(false), EditorDisplay(\"Audio Source\", \"Play On Start\")")
|
|
|
|
|
FORCE_INLINE bool GetPlayOnStart() const
|
|
|
|
|
{
|
|
|
|
|
@@ -143,7 +132,6 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the audio clip should auto play on game start.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetPlayOnStart(bool value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -159,13 +147,11 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the minimum distance at which audio attenuation starts. When the listener is closer to the source than this value, audio is heard at full volume. Once farther away the audio starts attenuating.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetMinDistance(float value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the attenuation that controls how quickly does audio volume drop off as the listener moves further from the source.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="EditorOrder(70), DefaultValue(1.0f), Limit(0, float.MaxValue, 0.1f), EditorDisplay(\"Audio Source\")")
|
|
|
|
|
FORCE_INLINE float GetAttenuation() const
|
|
|
|
|
{
|
|
|
|
|
@@ -175,11 +161,9 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the attenuation that controls how quickly does audio volume drop off as the listener moves further from the source.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
API_PROPERTY() void SetAttenuation(float value);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts playing the currently assigned audio clip.
|
|
|
|
|
/// </summary>
|
|
|
|
|
@@ -198,7 +182,6 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current state of the audio playback (playing/paused/stopped).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY() FORCE_INLINE AudioSource::States GetState() const
|
|
|
|
|
{
|
|
|
|
|
return _state;
|
|
|
|
|
@@ -207,7 +190,6 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current time of playback. If playback has not yet started, it specifies the time at which playback will start at. The time is in seconds, in range [0, ClipLength].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The time.</returns>
|
|
|
|
|
API_PROPERTY(Attributes="HideInEditor") float GetTime() const;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -219,13 +201,11 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if the sound source is three dimensional (volume and pitch varies based on listener distance and velocity).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The value.</returns>
|
|
|
|
|
API_PROPERTY() bool Is3D() const;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if audio clip is valid, loaded and uses dynamic data streaming.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>True if audio clip is using streaming, false otherwise.</returns>
|
|
|
|
|
API_PROPERTY() bool UseStreaming() const;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@@ -234,11 +214,9 @@ public:
|
|
|
|
|
void Restore();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether this audio source started playing audio via audio backend. After audio play it may wait for audio clip data to be loaded or streamed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c> if audio source is actually playing something; otherwise, <c>false</c>.</returns>
|
|
|
|
|
API_PROPERTY() FORCE_INLINE bool IsActuallyPlayingSth() const
|
|
|
|
|
{
|
|
|
|
|
return _isActuallyPlayingSth;
|
|
|
|
|
@@ -247,10 +225,7 @@ public:
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Requests the audio streaming buffers update. Rises tha flag to synchronize audio backend buffers of the emitter during next game logic update.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void RequestStreamingBuffersUpdate()
|
|
|
|
|
{
|
|
|
|
|
_needToUpdateStreamingBuffers = true;
|
|
|
|
|
}
|
|
|
|
|
void RequestStreamingBuffersUpdate();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cleanups the cached data. Called by the Audio manager.
|
|
|
|
|
@@ -258,7 +233,6 @@ public:
|
|
|
|
|
void Cleanup();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
void OnClipChanged();
|
|
|
|
|
void OnClipLoaded();
|
|
|
|
|
|
|
|
|
|
@@ -275,7 +249,6 @@ private:
|
|
|
|
|
void Update();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// [Actor]
|
|
|
|
|
#if USE_EDITOR
|
|
|
|
|
BoundingBox GetEditorBox() const override
|
|
|
|
|
@@ -290,7 +263,6 @@ public:
|
|
|
|
|
bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// [Actor]
|
|
|
|
|
void OnEnable() override;
|
|
|
|
|
void OnDisable() override;
|
|
|
|
|
|