---
title: PHASESwitchNodeDefinition
framework: phase
role: symbol
role_heading: Class
path: phase/phaseswitchnodedefinition
---

# PHASESwitchNodeDefinition

A node that passes invocation to only one of its child nodes.

## Declaration

```swift
class PHASESwitchNodeDefinition
```

## Overview

Overview A switch node takes a different path in a sound-event hierarchy depending on the value that the app supplies for the node’s switch metaparameter. You define the available paths ahead of time by calling addSubtree(_:switchValue:) at least twice and supplying the subtree’s unique string name as the switch value. When your app invokes a sound event at runtime, PHASE checks the value of switchMetaParameterDefinition to determine which path to take.

Switch Between Mulitple Node Trees For example, the following diagram represents a node tree that plays one of three grass or sidewalk footstep sounds, depending on the app’s current state. The app sets a value for the switch-node metaparameter according to the terrain on which the player in a game currently stands.

The following code creates a random node subtree for each terrain type and adds each one as a subtree to the switch node. tip: The metaParameters objects affect only one sound event. To propagate a metaparameter change to multiple sound events, register the metaparameter globally using registerGlobalMetaParameter(metaParameterDefinition:), and change its value through the asset registry’s globalMetaParameters dictionary.

## Topics

### Creating a Node

- [init(switchMetaParameterDefinition:)](phase/phaseswitchnodedefinition/init(switchmetaparameterdefinition:).md)
- [init(switchMetaParameterDefinition:identifier:)](phase/phaseswitchnodedefinition/init(switchmetaparameterdefinition:identifier:).md)

### Managing Child Nodes

- [switchMetaParameterDefinition](phase/phaseswitchnodedefinition/switchmetaparameterdefinition.md)
- [addSubtree(_:switchValue:)](phase/phaseswitchnodedefinition/addsubtree(_:switchvalue:).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

- [PHASERandomNodeDefinition](phase/phaserandomnodedefinition.md)
- [PHASEBlendNodeDefinition](phase/phaseblendnodedefinition.md)
- [PHASEContainerNodeDefinition](phase/phasecontainernodedefinition.md)
