<!--
{
  "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/PHASEBlendNodeDefinition",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "PHASE"
    ],
    "preciseIdentifier" : "c:objc(cs)PHASEBlendNodeDefinition"
  },
  "title" : "PHASEBlendNodeDefinition"
}
-->

# PHASEBlendNodeDefinition

A node that smoothly fades between the audio of its child nodes.

```
class PHASEBlendNodeDefinition
```

## Overview

This class defines a threshold and a numeric parameter the app increases and decreases to fade between child nodes. Each child node defines a range within the threshold in which the child node plays audio. As the app moves the blend parameter value between `0` and the threshold, the blend node plays the audio of its child nodes whose range and fade curve overlap at the current value.

![Illustration of a flowchart that represents a sound event node tree. The chart contains three boxes, which represent nodes. At left, a box labeled Blend Node extends an arrow, which points to a box in the upper right that’s labeled, Sampler Node Cobblestone Footstep. The box labeled Random Node extends another arrow, which points to a box in the lower right that’s labeled, Sampler Node Grass Footstep. A verticle bar ranges from top sampler node to the bottom sampler node to indicate the range in which both just one node actively plays audio, or both nodes actively play audio, and to what volume they play. ](images/com.apple.phase/media-3918862@2x.png)

### Play a Blend of Simultaneous Audio Data

To gradually change the audio that a sound event plays, define blend thresholds and a number metaparameter that incrementally increases or decreases between the thresholds. For example, the following code sets up a sound event hierarchy containing two sampler nodes that play audio, with each one modeling a different terrain. The app sets the metaparameter value based on the value of the terrain the player stands on. When the app starts a sound event from this hierarchy, PHASE plays:

- A grass footstep for terrain values between `0` and `0.33`
- A cobblestone footstep for terrain values between `0.67` and `1.0`
- A blend of both footstep sounds for values between `0.33` and `0.67`

```swift
// Create a meta parameter definition that chooses among different terrains.
let terrainBlendParameter = PHASENumberMetaParameterDefinition(
    value: 0.5, 
    minimum: 0.0,
    maximum: 1.0,
    identifier: "terrain")

// Create a blend node and pass in the meta parameter.
let terrainBlendNode = PHASEBlendNodeDefinition(blendMetaParameterDefinition: terrainBlendParameter)

// Add two samples nodes to blend between.
terrainBlendNode.addRangeForInputValuesAbove( 
    value: 0.33,
    fullGainAtValue: 1.0,
    fadeCurveType: .linear,
    subtree:cobblestoneSamplerNode)

terrainBlendNode.addRangeForInputValuesBelow( 
    value: 0.67,
    fullGainAtValue: 0.0,
    fadeCurveType: .linear,
    subtree:grassSamplerNode)

// Create a sound event.
var footstepEvent: PHASESoundEvent?
do { footstepEvent = try PHASESoundEvent(engine: myEngine, assetIdentifier: "terrain") } 
catch { fatalError("Failed to create the sound event due to: \(error)") }        

// Set the "terrain" metaparameter value to a midpoint that 
//  plays audio from both subtrees at an equal volume.
guard let terrainParameter = footstepEvent?.metaParameters["terrain"] else { fatalError() }
terrainParameter.value = 0.5

// Play the sound and hear a mix of both terrains.
footstepEvent?.start() { reason in 
/* Perform completion tasks. */ }
```

## Topics

### Creating a Blend Node

[`-  initWithBlendMetaParameterDefinition:`](/documentation/PHASE/PHASEBlendNodeDefinition/init(blendMetaParameterDefinition:))

Creates a blend node with a maxiumum blend range value.

[`-  initWithBlendMetaParameterDefinition:identifier:`](/documentation/PHASE/PHASEBlendNodeDefinition/init(blendMetaParameterDefinition:identifier:))

Creates a named blend node with a maxiumum blend range value.

[`-  initDistanceBlendWithSpatialMixerDefinition:`](/documentation/PHASE/PHASEBlendNodeDefinition/init(spatialMixerDefinition:))

Creates a blend node for spatial audio output.

[`-  initDistanceBlendWithSpatialMixerDefinition:identifier:`](/documentation/PHASE/PHASEBlendNodeDefinition/init(spatialMixerDefinition:identifier:))

Creates a named blend node for spatial audio output.

### Accessing Blend Properties

[`blendParameterDefinition`](/documentation/PHASE/PHASEBlendNodeDefinition/blendParameterDefinition)

The meta parameter definition that caps the blend range.

[`spatialMixerDefinitionForDistance`](/documentation/PHASE/PHASEBlendNodeDefinition/spatialMixerDefinitionForDistance)

An object that combines spatial audio layers.

### Adding Child Nodes

[`-  addRangeWithEnvelope:subtree:`](/documentation/PHASE/PHASEBlendNodeDefinition/addRange(envelope:subtree:))

Adds a child node with an envelope.

[`-  addRangeForInputValuesAbove:fullGainAtValue:fadeCurveType:subtree:`](/documentation/PHASE/PHASEBlendNodeDefinition/addRangeForInputValuesAbove(value:fullGainAtValue:fadeCurveType:subtree:))

Adds a child node that blends above a given value.

[`-  addRangeForInputValuesBelow:fullGainAtValue:fadeCurveType:subtree:`](/documentation/PHASE/PHASEBlendNodeDefinition/addRangeForInputValuesBelow(value:fullGainAtValue:fadeCurveType:subtree:))

Adds a child node that blends below a given value.

[`-  addRangeForInputValuesBetween:highValue:fullGainAtLowValue:fullGainAtHighValue:lowFadeCurveType:highFadeCurveType:subtree:`](/documentation/PHASE/PHASEBlendNodeDefinition/addRangeForInputValuesBetween(lowValue:highValue:fullGainAtLowValue:fullGainAtHighValue:lowFadeCurveType:highFadeCurveType:subtree:))

Adds a child node that blends between a given high and low value.

## Relationships

### Conforms To

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

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

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

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

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

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

### Inherits From

[`PHASESoundEventNodeDefinition`](/documentation/PHASE/PHASESoundEventNodeDefinition)

---

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)