PHASEEnvelope
A collection of segments that connect to graph a complex curve over a linear input.
Declaration
class PHASEEnvelopeOverview
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:) function plots and returns the result on the output axis. The following are possible uses of this class:
Sound event nodes, such as PHASEBlendNodeDefinition, can shape their volume using an envelope; see addRange(envelope:subtree:).
Distance models shape sounds with a 3D position using an envelope; see PHASEEnvelopeDistanceModelParameters.
An envelope can do more than shape audio. To gradually change an envelope’s input value over time, use the 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 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:
The graph flexes at runtime depending on the source content on which the envelope operates. A PHASEEnvelope doesn’t constrain the evaluate(x:) function’s output to predertermined values. Instead, PHASE applies the envelope’s curves to the source content as a rate of change.