One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AudioMixGroupsComponent

struct · iOS 18.0+ · SDK 27.1

struct AudioMixGroupsComponent

A component that provides functionality for controlling the playback of audio you assign to mix groups in a scene. When defining an ``AudioMixGroup`` for a scene in the Audio Mixer section of Reality Composer Pro, this component exists on the first descendant ``Entity`` in the scene at runtime. A common use case for `AudioMixGroupsComponent` is to simultaneously control the playback volume of every ``AudioResource`` in an `AudioMixGroup`, such as the sound effects in a scene. The following example sets the playback volume of every `AudioResource` in the `AudioMixGroup` named SFX: ```swift let sceneEntity = Entity(named: "ContainsAudio", in: realityKitContentBundle) // AudioMixGroupsComponent exists on the first descendant Entity in a scene. var audioMixGroupsEntity = sceneEntity.children[0] // If no audio mix groups are configured for this scene in Reality Composer Pro, this component won't exist. guard var audioMixGroupsComponent = audioMixGroupsEntity.components[AudioMixGroupsComponent.self], var sfxGroup = audioMixGroupsComponent.mixGroup(named: "SFX") else { return } // This code remaps a percent value between 0 and 100 to a decibel value between -60.0 and 0.0. // Because -60.0 dB is near the low-end of human hearing ability, this is a good value to use in this example. let volumePercent: Float = 50 let decibels = Audio.Decibel(-40.0 + (20 * log10(volumePercent))) // Control the playback volume with the gain property on an AudioMixGroup. sfxGroup.gain = decibels audioMixGroupsComponent.set(sfxGroup) audioMixGroupsEntity.components.set(audioMixGroupsComponent) ``` To completely silence an `AudioMixGroup`, use the ``AudioMixGroup/isMuted`` property. Use ``AudioMixGroup/fade(to:duration:)`` to fade the volume of an `AudioMixGroup` over time.

Members (4)

init · iOS 18.0+

init

TypeScript
static init(mixGroups?: Array<AudioMixGroup>): AudioMixGroupsComponent
Swift declaration
init(mixGroups: [AudioMixGroup] = [])

Initializes an `AudioMixGroupsComponent`. - Important: If more than one audio mix group have matching names, only one will be used.

method · iOS 18.0+

set

TypeScript
set(mixGroup: AudioMixGroup): void
Swift declaration
mutating func set(_ mixGroup: AudioMixGroup)

Adds the given `AudioMixGroup` to the component. - Important: Adding an audio mix group replaces any existing audio mix group with the same name.

method · iOS 18.0+

remove

TypeScript
remove(name: string): void
Swift declaration
mutating func remove(named name: String)

Removes the audio mix group with the given name, if it exists, from the component.

method · iOS 18.0+

mixGroup

TypeScript
mixGroup(name: string): (AudioMixGroup) | null
Swift declaration
func mixGroup(named name: String) -> AudioMixGroup?

Returns the audio mix group with the given name, if it exists.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →