---
title: PHASEBlendNodeDefinition
framework: phase
role: symbol
role_heading: Class
path: phase/phaseblendnodedefinition
---

# PHASEBlendNodeDefinition

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

## Declaration

```swift
class PHASEBlendNodeDefinition
```

## Overview

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.

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 // 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

- [init(blendMetaParameterDefinition:)](phase/phaseblendnodedefinition/init(blendmetaparameterdefinition:).md)
- [init(blendMetaParameterDefinition:identifier:)](phase/phaseblendnodedefinition/init(blendmetaparameterdefinition:identifier:).md)
- [init(spatialMixerDefinition:)](phase/phaseblendnodedefinition/init(spatialmixerdefinition:).md)
- [init(spatialMixerDefinition:identifier:)](phase/phaseblendnodedefinition/init(spatialmixerdefinition:identifier:).md)

### Accessing Blend Properties

- [blendParameterDefinition](phase/phaseblendnodedefinition/blendparameterdefinition.md)
- [spatialMixerDefinitionForDistance](phase/phaseblendnodedefinition/spatialmixerdefinitionfordistance.md)

### Adding Child Nodes

- [addRange(envelope:subtree:)](phase/phaseblendnodedefinition/addrange(envelope:subtree:).md)
- [addRangeForInputValuesAbove(value:fullGainAtValue:fadeCurveType:subtree:)](phase/phaseblendnodedefinition/addrangeforinputvaluesabove(value:fullgainatvalue:fadecurvetype:subtree:).md)
- [addRangeForInputValuesBelow(value:fullGainAtValue:fadeCurveType:subtree:)](phase/phaseblendnodedefinition/addrangeforinputvaluesbelow(value:fullgainatvalue:fadecurvetype:subtree:).md)
- [addRangeForInputValuesBetween(lowValue:highValue:fullGainAtLowValue:fullGainAtHighValue:lowFadeCurveType:highFadeCurveType:subtree:)](phase/phaseblendnodedefinition/addrangeforinputvaluesbetween(lowvalue:highvalue:fullgainatlowvalue:fullgainathighvalue:lowfadecurvetype:highfadecurvetype:subtree:).md)

### Initializers

- [init(distanceBlendWithSpatialMixerDefinition:)](phase/phaseblendnodedefinition/init(distanceblendwithspatialmixerdefinition:).md)
- [init(distanceBlendWithSpatialMixerDefinition:identifier:)](phase/phaseblendnodedefinition/init(distanceblendwithspatialmixerdefinition:identifier:).md)

## Relationships

### Inherits From

- [PHASESoundEventNodeDefinition](phase/phasesoundeventnodedefinition.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Control Nodes

- [PHASESwitchNodeDefinition](phase/phaseswitchnodedefinition.md)
- [PHASERandomNodeDefinition](phase/phaserandomnodedefinition.md)
- [PHASEContainerNodeDefinition](phase/phasecontainernodedefinition.md)
