A group that manages the playback properties of multiple playing sounds.
A mix group component manages the playback parameters for a collection of different
``AudioPlaybackController`` and ``AudioGeneratorController`` instances.
Properties such as ``gain``, ``fade(to:duration:)``, and ``speed``
are multiplicative with the parameters you set on the controller.
You associate audio resources to a mix group by setting the ``mixGroupName`` parameter in the resource's configuration.
For an example, see ``AudioFileResource/Configuration-swift.struct/mixGroupName``.
Enable a mix group by adding it to an ``AudioMixGroupsComponent`` structure on an entity in the scene.
The scene where the component belongs limits the scope of the mix group.
```swift
var mixGroup = AudioMixGroup(name: "myMixGroup")
entity.components.set(AudioMixGroupsComponent(mixGroups: [mixGroup]))
```
Transitions the gain to a value over a time interval using a linear curve.
- Parameters:
- gain: The overall level for audio from a group after the fade is complete.
- duration: The duration of the fade in seconds.
get · iOS 18.0+
gain
TypeScript
get gain(): number
Swift declaration
var gain: Audio.Decibel { get set }
The overall level for all sounds of an audio mix group in relative decibels.
The gain is a value in the range `[-.infinity, .zero]`,
where `-.infinity` is silent and `.zero` is nominal.
set · iOS 18.0+
gain
TypeScript
set gain(value: number)
Swift declaration
var gain: Audio.Decibel { get set }
The overall level for all sounds of an audio mix group in relative decibels.
The gain is a value in the range `[-.infinity, .zero]`,
where `-.infinity` is silent and `.zero` is nominal.
init · iOS 18.0+
init
TypeScript
static init(name: string): AudioMixGroup
Swift declaration
init(name: String)
Creates a mix group.
- Parameters:
- name: The name to associate this group with various audio configurations.
get · iOS 18.0+
name
TypeScript
get name(): string
Swift declaration
let name: String
The name of an audio mix group.
get · iOS 18.0+
speed
TypeScript
get speed(): number
Swift declaration
var speed: Double
The rate of playback for an audio mix group.
The system limits the rate of playback to the range of `[0.25, 4]`.
The default speed is `1`, which is equivalent to a normal playback rate.
- Note: ``AudioGeneratorController`` ignores this value.
set · iOS 18.0+
speed
TypeScript
set speed(value: number)
Swift declaration
var speed: Double
The rate of playback for an audio mix group.
The system limits the rate of playback to the range of `[0.25, 4]`.
The default speed is `1`, which is equivalent to a normal playback rate.
- Note: ``AudioGeneratorController`` ignores this value.
get · iOS 18.0+
isMuted
TypeScript
get isMuted(): boolean
Swift declaration
var isMuted: Bool
A Boolean value that indicates whether an audio mix group emits any sound.
set · iOS 18.0+
isMuted
TypeScript
set isMuted(value: boolean)
Swift declaration
var isMuted: Bool
A Boolean value that indicates whether an audio mix group emits any sound.