One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AmbientAudioComponent

struct · iOS 18.0+ · SDK 27.1

struct AmbientAudioComponent

A component that configures the ambient rendering of sounds from an entity. Ambient audio sources emit each channel of an audio resource from an angle projected from the entity, without reverberation. Ambient audio sources take into account the relative orientation of the source and the listener. Position is not taken into account; the channels do not get louder as the user moves toward them. The audio resource's front channels (e.g., mono, center) are projected into the entity's -Z direction, with the rear channels projected into +Z. The left channels are laid out in -X and the right channels are laid out in +X. ```swift let entity = Entity() let resource = try AudioFileResource.load(named: "MyAudioFile") entity.ambientAudio = AmbientAudioComponent() entity.playAudio(resource) ``` The `AmbientAudioComponent` allows you to set the overall level of all sounds played from the entity with the `gain` property, in relative Decibels, in the range `-.infinity ... .zero` where `-infinity` is silent and `.zero` is nominal. ```swift entity.ambientAudio?.gain = -10 ``` Ambient audio sources are well suited to play back multichannel content which captures the acoustics of its originating environment in the recording process (e.g., multichannel field recordings of outdoor environments).

Members (3)

init · iOS 18.0+

init

TypeScript
static init(gain?: number): AmbientAudioComponent
Swift declaration
init(gain: Audio.Decibel = .zero)

Configure the behavior of an ambient audio source. - Parameter gain: The overall level for all sounds emitted from an entity.

get · iOS 18.0+

gain

TypeScript
get gain(): number
Swift declaration
var gain: Audio.Decibel { get set }

The overall level for all sounds emitted from an entity. In relative Decibels, in the range `-.infinity ... .zero` where `.zero` is the default.

set · iOS 18.0+

gain

TypeScript
set gain(value: number)
Swift declaration
var gain: Audio.Decibel { get set }

The overall level for all sounds emitted from an entity. In relative Decibels, in the range `-.infinity ... .zero` where `.zero` is the default.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →