Class AudioSpaceComponent

Inheritance Relationships

Base Types

Class Documentation

class AudioSpaceComponent : public csp::multiplayer::ComponentBase, public csp::multiplayer::IEnableableComponent, public csp::multiplayer::IPositionComponent, public csp::multiplayer::IThirdPartyComponentRef

Adds spatial audio to a SpaceEntity.

This component creates immersive soundscapes by playing audio that reacts to the user’s position in the space. Whether it’s background music, sound effects, or voiceovers, the AudioSpaceComponent makes sound more engaging by positioning it in 3D space.

Public Functions

AudioSpaceComponent(SpaceEntity *Parent)

Constructs the audio space component, and associates it with the specified Parent space entity.

Parameters

Parent – The Space entity that owns this component.

AudioPlaybackState GetPlaybackState() const

Gets the current playback state of the audio of this audio component.

Returns

The current playback state of the audio of this audio component.

void SetPlaybackState(AudioPlaybackState Value)

Sets the new playback state of the audio of this audio component.

Parameters

Value – The new playback state of the audio of this audio component.

AudioType GetAudioType() const

Gets the type of the audio of this audio component.

Returns

The type of the audio of this audio component.

void SetAudioType(AudioType Value)

Sets the type of the audio of this audio component.

Parameters

Value – Type of the audio of this audio component.

const csp::common::String &GetAudioAssetId() const

Gets the asset ID for this audio asset.

Returns

The ID of this audio asset.

void SetAudioAssetId(const csp::common::String &Value)

Sets the asset ID for this audio asset.

Parameters

Value – The ID for this audio asset.

const csp::common::String &GetAssetCollectionId() const

Gets the ID of the asset collection associated with this component.

Note

To retrieve this component’s audio asset, both the Asset ID and the Asset Collection ID are required.

Returns

The ID of the asset collection associated with this component.

void SetAssetCollectionId(const csp::common::String &Value)

Sets the ID of the asset collection associated with this component.

Note

To retrieve this component’s audio asset, both the Asset ID and the Asset Collection ID are required.

Parameters

Value – The ID of the asset collection associated with this component.

float GetAttenuationRadius() const

Gets the attenuation for the audio when a spatial audio type.

The radius is the minimum distance between the origin of this audio component and the position of the player, from within which the player can start hearing the spatial audio in range. The radius is expressed in meters.

Returns

The minimum radius in meters from the origin of the audio component to hear the spatial audio.

void SetAttenuationRadius(float Value)

Sets the attenuation for the audio when a spatial audio type.

The radius is the minimum distance between the origin of this audio component and the position of the player, from within which the player can start hearing the spatial audio in range. The radius is expressed in meters.

Parameters

Value – The minimum radius in meters from the origin of the audio component to hear the spatial audio.

bool GetIsLoopPlayback() const

Checks if the audio playback is looping.

Returns

True if the audio loops (i.e. starts from the beginning when ended), false otherwise.

void SetIsLoopPlayback(bool Value)

Sets if the audio playback is looping.

Parameters

Value – True if the audio loops (i.e. starts from the beginning when ended), false otherwise.

float GetTimeSincePlay() const

Gets the timestamp recorded from the moment when the audio clip started playing, in Unix timestamp format.

Returns

The timestamp recorded from the moment when the audio clip started playing, in Unix timestamp format.

void SetTimeSincePlay(float Value)

Sets the timestamp recorded from the moment when the audio clip started playing, in Unix timestamp format.

Parameters

Value – The timestamp recorded from the moment when the audio clip started playing, in Unix timestamp format.

float GetVolume() const

Gets the volume of the audio in a ratio between 0 and 1.

Volume 1 represents the full volume of the audio clip of this component.

Returns

The volume of the audio, in a ratio between 0 and 1.

void SetVolume(float Value)

Sets the volume of the audio in a ratio between 0 and 1.

Volume 1 represents the full volume of the audio clip of this component.

Parameters

Value – The volume of the audio, in a ratio between 0 and 1.