init
TypeScriptstatic init(gain?: number): AmbientAudioComponentSwift declarationinit(gain: Audio.Decibel = .zero)Configure the behavior of an ambient audio source. - Parameter gain: The overall level for all sounds emitted from an entity.
struct · iOS 18.0+ · SDK 27.1
struct AmbientAudioComponentA 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).
static init(gain?: number): AmbientAudioComponentSwift declarationinit(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 gain(): numberSwift declarationvar 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 gain(value: number)Swift declarationvar 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.
No declarations were skipped in this snapshot.