In this lesson, you will learn how to construct custom ADSR (Attack, Decay, Sustain, Release) envelope generators from scratch using foundational logic nodes within MetaSounds to precisely control amplitude and filter cutoffs.
The Logic of an Envelope
While MetaSounds includes built-in envelope nodes, building your own using logic nodes gives you total control over the shape and behavior of your sound’s volume or frequency. An envelope generator is essentially a state machine that tracks time and output values. To build one, you need to transition through four stages:
- Attack: The value ramps from 0 to 1 over a set time.
- Decay: The value drops from 1 to the Sustain level.
- Sustain: The value holds steady as long as the trigger remains active.
- Release: The value drops from the current level back to 0.
Implementing with Nodes
To build this, use Trigger Select and Switch nodes to route your signal through different Line or Exponential Decay nodes. For example, to handle the Attack phase, you can use a Line node where the Target is 1.0 and the Time is your attack duration.
When you receive an On Note On trigger, you route it to a Trigger Gate that feeds the start of your envelope logic. You then use Compare nodes to check when your envelope value reaches specific thresholds (like 1.0 for the end of Attack) to automatically toggle the state to Decay.
// Conceptual flow for logic node setup
[Trigger On] -> [Switch] -> [Line (Attack Time)] -> [Value Output]
[Value Output] >= 1.0 -> [Trigger] -> [Switch to Decay]
By connecting these logic gates, you create a "brain" that monitors the envelope's current stage. When the user releases a key (On Note Off), you send a trigger to jump immediately to the Release stage logic, forcing the signal to decay to 0 over a specified duration. This approach allows you to modulate anything from a Gain node for volume to a Low Pass Filter frequency, creating expressive, dynamic audio patches that respond perfectly to gameplay events.
Key Takeaway: By chaining logic triggers and mathematical line generators, you can build custom, highly specific envelope curves that provide dynamic, state-driven control over any MetaSound parameter.