<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PHASE",
  "identifier" : "/documentation/PHASE/PHASEGroup",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "PHASE"
    ],
    "preciseIdentifier" : "c:objc(cs)PHASEGroup"
  },
  "title" : "PHASEGroup"
}
-->

# PHASEGroup

A container that shares audio parameters with a collection of sounds.

```
class PHASEGroup
```

## Overview

With all the sounds it contains, a group shares settings like gain, playback rate, mute, and solo. Groups are nonhierarchical and don’t overlap — that is, each sound event associates with only one group.

### Apply Group Settings to Sounds

You can apply settings to the sounds a group contains. For instance, an app can share volume settings with various sound effects and dialogue audio groups. The following example creates a group for background audio, such as environmental sound layers played with ambient music. By interpolating the group’s gain setting, the audio fade applies to every sound in the group.

```swift
// Allocate an engine and stereo mixer.
let stereoLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Stereo)!
let myEngine = PHASEEngine(updateMode: .automatic)
let stereoMixer = PHASEChannelMixerDefinition(channelLayout:stereoLayout)

// Create a group object.
let bgmGroup = PHASEGroup(identifier:"backgroundMusicGroup")
bgmGroup.register(engine: myEngine)

// Create a sound event node definition for background music.
let backgroundMusicSampler = PHASESamplerNodeDefinition(soundAssetIdentifier: "backgroundMusic", mixerDefinition: stereoMixer)
        
// Add the sound node to the group.
backgroundMusicSampler.group = myEngine.groups["backgroundMusicGroup"]
        
// Set group gain to zero.
bgmGroup.gain = 0
        
// Create a sound event to play the music.
var bgmEvent: PHASESoundEvent?
do {
    try bgmEvent = PHASESoundEvent(engine: myEngine, assetIdentifier: "backgroundMusicEventAsset")
} catch {
    fatalError("Error occurred: \(error.localizedDescription)")
}
        
// Queue the background music to play.
bgmEvent?.start() { reason in
    print("Started. Status: \(reason)")
}
        
// Fade in the music over two seconds.
bgmGroup.fadeGain(gain: 1.0, duration: 2.0, curveType: .linear)
```

## Topics

### Creating a Group

[`-  initWithIdentifier:`](/documentation/PHASE/PHASEGroup/init(identifier:))

Creates a group with a unique name.

### Identifying the Group

[`identifier`](/documentation/PHASE/PHASEGroup/identifier)

A unique name for the group.

### Defining the Group

[`-  registerWithEngine:`](/documentation/PHASE/PHASEGroup/register(engine:))

Adds the group to the engine’s dictionary.

[`-  unregisterFromEngine`](/documentation/PHASE/PHASEGroup/unregisterFromEngine())

Removes the group from the engine’s dictionary.

### Conrolling Loudness

[`gain`](/documentation/PHASE/PHASEGroup/gain)

Modifies the volume of the group’s sounds.

[`-  fadeGain:duration:curveType:`](/documentation/PHASE/PHASEGroup/fadeGain(gain:duration:curveType:))

Adjusts the volume of the sounds in a group gradually.

### Adjusting Playback Speed

[`rate`](/documentation/PHASE/PHASEGroup/rate)

The group’s playback speed.

[`-  fadeRate:duration:curveType:`](/documentation/PHASE/PHASEGroup/fadeRate(rate:duration:curveType:))

Adjusts the playback speed of the sounds in a group gradually.

### Silencing Sounds

[`-  mute`](/documentation/PHASE/PHASEGroup/mute())

Silences the group.

[`-  unmute`](/documentation/PHASE/PHASEGroup/unmute())

Restores the group’s volume.

[`muted`](/documentation/PHASE/PHASEGroup/isMuted)

A Boolean value that indicates whether the app silences the group.

[`-  solo`](/documentation/PHASE/PHASEGroup/solo())

Silences all other groups.

[`-  unsolo`](/documentation/PHASE/PHASEGroup/unsolo())

Restores the other groups’ volume.

[`soloed`](/documentation/PHASE/PHASEGroup/isSoloed)

A Boolean value that indicates whether the app silences all groups other than this group.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)