class AudioClip

Inherits: Resource

Audio clip stores audio data in a compressed or uncompressed format.

Clips can be provided to audio sources or other audio methods to be played.

Public

Methods

~AudioClip

virtual ~AudioClip() noexcept = default

GetBitDepth

u32 GetBitDepth() const

Returns the size of a single sample, in bits.

GetFrequency

u32 GetFrequency() const

Returns how many samples per second is the audio encoded in.

GetChannelCount

u32 GetChannelCount() const

Returns the number of channels provided by the clip.

GetFormat

AudioFormat GetFormat() const

Returns in which format is audio data stored in.

GetReadMode

AudioReadMode GetReadMode() const

Returns how is the audio data read/decoded.

GetLength

float GetLength() const

Returns the length of the audio clip, in seconds.

GetSampleCount

u32 GetSampleCount() const

Returns the total number of samples in the clip (includes all channels).

Is3D

bool Is3D() const

Determines will the clip be played a spatial 3D sound, or as a normal sound (for example music).

staticCreate

static HAudioClip Create(const SPtr<DataStream> &samples, u32 streamSize, u32 sampleCount, const AudioClipCreateInformation &createInformation)

Creates a new AudioClip and populates it with provided samples.

samples
Data streams containing the samples to load. Data will be read starting from the current position in the stream. The samples should be in audio format as specified in the parameter. Ownership of the data stream is taken by the audio clip and the caller must not close it manually.
streamSize
Number of bytes to read from the stream.
sampleCount
Total number of samples (including all channels).
createInformation
Descriptor containing meta-data for the provided samples.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const

Returns an interface you can use to access class' Run Time Type Information.

staticCreateEmpty

static SPtr<AudioClip> CreateEmpty()

Creates an AudioClip with no samples.

You must populate its data manually followed by a call to Initialize().

Internal

Methods

staticCreateShared

static SPtr<AudioClip> CreateShared(const SPtr<DataStream> &samples, u32 streamSize, u32 sampleCount, const AudioClipCreateInformation &createInformation)

Creates a new AudioClip without initializing it.

Use Create() for normal use.

Protected

Constructors

AudioClip

AudioClip(const SPtr<DataStream> &samples, u32 streamSize, u32 sampleCount, const AudioClipCreateInformation &createInformation)

Methods

Initialize

void Initialize() override

Initializes all the internal data of this object.

Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.

IsCompressible

bool IsCompressible() const override

Returns true if the resource can be compressed using a generic compression when saved on a storage device.

Certain resources already have their contents compressed (like audio files) and will not benefit from further compression. Resources supporting streaming should never be compressed, instead such resources can handle compression/decompression locally through their streams.

GetSourceStream

virtual SPtr<DataStream> GetSourceStream(u32 &outSize) = 0

Returns original audio data.

Only available if has been provided on creation.

outSize
Size of the returned stream data, in bytes.

Returns: Stream containing the original audio data.

Fields

mInformation

mSampleCount

u32 mSampleCount

mStreamSize

u32 mStreamSize

mStreamOffset

u32 mStreamOffset

mLength

float mLength

mStreamData

SPtr<DataStream> mStreamData