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

# PHASEEnvelope

A collection of segments that connect to graph a complex curve over a linear input.

```
class PHASEEnvelope
```

## Overview

In traditional audio uses, an *envelope* defines a complex graph that determines the volume of audio data over an input duration. PHASE uses envelopes in a similar way. Given a value on the envelope’s input axis, the [`evaluate(x:)`](/documentation/PHASE/PHASEEnvelope/evaluate(x:)) function plots and returns the result on the output axis. The following are possible uses of this class:

- Sound event nodes, such as [`PHASEBlendNodeDefinition`](/documentation/PHASE/PHASEBlendNodeDefinition), can shape their volume using an envelope; see [`addRange(envelope:subtree:)`](/documentation/PHASE/PHASEBlendNodeDefinition/addRange(envelope:subtree:)).
- Distance models shape sounds with a 3D position using an envelope; see [`PHASEEnvelopeDistanceModelParameters`](/documentation/PHASE/PHASEEnvelopeDistanceModelParameters).
- An envelope can do more than shape audio. To gradually change an envelope’s input value over time, use the [`PHASEMappedMetaParameterDefinition`](/documentation/PHASE/PHASEMappedMetaParameterDefinition) class, which creates a function with a metaparameter value as input. An app can use the numeric result for any purpose. For example, the x-axis can be distance and the y-axis can be playback rate.

At runtime, PHASE determines whether a particular member of the [`segments`](/documentation/PHASE/PHASEEnvelope/segments) array slopes up or down along the domain depending on the envelope’s particular use case.

### Create an Envelope and Shape its Curve

To use an envelope in your app, define its shape by defining a series of segments. Each segment specifies a curve that collectively connect to form a graph. The following code creates an envelope with a single segment that’s shaped like the lettter *s:*

```objc
// Create a segments array.
NSMutableArray<PHASEEnvelopeSegment*>* segments = 
    [NSMutableArray new];

// Create a single segment with a sigmoid curve to give "ease in, 
//  ease out" movement along the domain. Define an endpoint of (1, 1).
PHASEEnvelopeSegment* segment = [[PHASEEnvelopeSegment alloc] 
    initWithEndPoint:simd_make_double2(1.0, 1.0) 
    curveType:PHASECurveTypeSigmoid];

// Add the segment to the array.
[segments addObject:segment];

// Create the envelope and set the start point to (-1, -1).
PHASEEnvelope* envelope = [[PHASEEnvelope alloc] 
    initWithStartPoint:simd_make_double2(-1.0, -1.0) 
    segments:segments];
```

The graph flexes at runtime depending on the source content on which the envelope operates. A [`PHASEEnvelope`](/documentation/PHASE/PHASEEnvelope) doesn’t constrain the [`evaluate(x:)`](/documentation/PHASE/PHASEEnvelope/evaluate(x:)) function’s output to predertermined values. Instead, PHASE applies the envelope’s curves to the source content as a rate of change.

## Topics

### Creating an Envelope

[`-  initWithStartPoint:segments:`](/documentation/PHASE/PHASEEnvelope/init(startPoint:segments:))

Creates an envelope with a start point and segments.

### Inspecting the Envelope

[`-  evaluateForValue:`](/documentation/PHASE/PHASEEnvelope/evaluate(x:))

Provides the height of the envelope for an input value.

[`segments`](/documentation/PHASE/PHASEEnvelope/segments)

An array of the envelope’s segments.

[`startPoint`](/documentation/PHASE/PHASEEnvelope/startPoint)

The starting point along the envelope’s duration.

### Bounding the Input

[`domain`](/documentation/PHASE/PHASEEnvelope/domain)

The range of the envelope’s possible input values.

[`range`](/documentation/PHASE/PHASEEnvelope/range)

The bounds of the output value.

## Relationships

### Conforms To

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

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

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

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

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

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

### 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)