Class AudioClip
Audio clip stores audio data in a compressed or uncompressed format using a binary asset. Clips can be provided to audio sources or other audio methods to be played.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Audio/AudioClip.h
Syntax
public class AudioClip : public BinaryAsset, public StreamableResource
Constructors
~AudioClip()
Fields
AudioHeader
The audio clip header data.
Declaration
public Header AudioHeader
Field Value
Header
|
Buffers
The audio backend buffers (internal ids) collection used by this audio clip.
Declaration
public Array<uint32, FixedAllocation<ASSET_FILE_DATA_CHUNKS>> Buffers
Field Value
Array<uint32, FixedAllocation<ASSET_FILE_DATA_CHUNKS>>
|
StreamingQueue
The streaming cache. Contains indices of chunks to stream. If empty no streaming required. Managed by AudioStreamingHandler and used by the Audio streaming tasks.
Declaration
public Array<int32, FixedAllocation<ASSET_FILE_DATA_CHUNKS>> StreamingQueue
Field Value
Array<int32, FixedAllocation<ASSET_FILE_DATA_CHUNKS>>
|
Methods
CanBeUpdated()
Determines whether this instance can be updated. Which means: no async streaming, no pending action in background.
Declaration
public virtual bool CanBeUpdated() const override
Returns
bool
|
Overrides
CancelStreaming()
Cancels any asynchronous content streaming by this asset (eg. mesh data streaming into GPU memory). Will release any locks for asset storage container.
Declaration
public virtual void CancelStreaming() override
Overrides
CancelStreamingTasks()
Cancels any streaming task (or tasks sequence) started for this resource.
Declaration
public virtual void CancelStreamingTasks() override
Overrides
CreateStreamingTask(int32 residency)
Creates streaming task (or tasks sequence) to perform resource streaming for the desire residency level.
Declaration
public virtual Task* CreateStreamingTask(int32 residency) override
Parameters
int32
residency
The target residency. |
Returns
Task
Async task or tasks that update resource residency level. Must be preceded with UpdateAllocation call. |
Overrides
ExtractData(Array<byte>& resultData, AudioDataInfo& resultDataInfo)
Extracts the source audio data from the asset storage. Loads the whole asset. The result data is in an asset format.
Declaration
public bool ExtractData(Array<byte>& resultData, AudioDataInfo& resultDataInfo)
Parameters
Array<byte>
resultData
The result data. |
AudioDataInfo
resultDataInfo
The result data format header info. |
Returns
bool
True if failed, otherwise false. |
ExtractDataFloat(Array<float>& resultData, AudioDataInfo& resultDataInfo)
Extracts the raw audio data (PCM format) from the asset storage and converts it to the normalized float format (in range [-1;1]). Loads the whole asset.
Declaration
public bool ExtractDataFloat(Array<float>& resultData, AudioDataInfo& resultDataInfo)
Parameters
Array<float>
resultData
The result data. |
AudioDataInfo
resultDataInfo
The result data format header info. That output data has 32 bits float data not the signed PCM data. |
Returns
bool
True if failed, otherwise false. |
ExtractDataRaw(Array<byte>& resultData, AudioDataInfo& resultDataInfo)
Extracts the raw audio data (PCM format) from the asset storage. Loads the whole asset.
Declaration
public bool ExtractDataRaw(Array<byte>& resultData, AudioDataInfo& resultDataInfo)
Parameters
Array<byte>
resultData
The result data. |
AudioDataInfo
resultDataInfo
The result data format header info. |
Returns
bool
True if failed, otherwise false. |
Format()
GetAllocatedResidency()
Gets resource allocated residency level.
Declaration
public virtual int32 GetAllocatedResidency() const override
Returns
int32
|
Overrides
GetBufferStartTime(int32 bufferIndex)
Gets the buffer start time (in seconds).
Declaration
public float GetBufferStartTime(int32 bufferIndex) const
Parameters
int32
bufferIndex
Index of the buffer. |
Returns
float
The buffer start time. |
GetCurrentResidency()
Gets resource current residency level.
Declaration
public virtual int32 GetCurrentResidency() const override
Returns
int32
|
Overrides
GetFirstBufferIndex(float time, float& offset)
Gets the index of the first buffer to bind for the audio source data streaming.
Declaration
public int32 GetFirstBufferIndex(float time, float& offset) const
Parameters
float
time
The time (in seconds). |
float
offset
The offset time from the chunk start time (in seconds). |
Returns
int32
The buffer index. |
GetLength()
Gets the length of the audio clip (in seconds).
Declaration
public float GetLength() const
Returns
float
|
GetMaxResidency()
Gets resource maximum residency level.
Declaration
public virtual int32 GetMaxResidency() const override
Returns
int32
|
Overrides
Info()
Gets the audio data info metadata.
Declaration
public AudioDataInfo Info() const
Returns
AudioDataInfo
|
init(AssetInitData& initData)
Initializes the specified asset.
Declaration
protected virtual bool init(AssetInitData& initData) override
Parameters
AssetInitData
initData
The initialize data. |
Returns
bool
True if cannot init, otherwise false |
Overrides
Is3D()
Returns true if the sound source is three dimensional (volume and pitch varies based on listener distance and velocity).
Declaration
public bool Is3D() const
Returns
bool
|
IsStreamable()
Returns true if the sound is using data streaming.
Declaration
public bool IsStreamable() const
Returns
bool
|
IsStreamingTaskActive()
Returns true if the sound data is during streaming by an async task.
Declaration
public bool IsStreamingTaskActive() const
Returns
bool
|
load()
Load data from the chunks
Declaration
protected virtual LoadResult load() override
Returns
LoadResult
Loading result |
Overrides
unload(bool isReloading)
Unloads asset data
Declaration
protected virtual void unload(bool isReloading) override
Parameters
bool
isReloading
True if asset is reloading data, otherwise false. |
Overrides
UpdateAllocation(int32 residency)
Updates the resource allocation to the given residency level. May not be updated now but in an async operation.
Declaration
public virtual Task* UpdateAllocation(int32 residency) override
Parameters
int32
residency
The target allocation residency. |
Returns
Task
Async task that updates resource allocation or null if already done it. Warning: need to call task start to perform allocation. |