Wherein we expose the operation and control of the ubiquitous ADSR envelope generator.
Hz.ADSR
is a standalone CLAP plugin that is also a component of
other Hz plugins like Hz.Osc and Hz.Samplo.
Its job is to emit a shaping envelope when triggered by a NoteOn
message.
When used in the standalone configuration it is usually wired
into the audio graph as a side-chain connection to Hz.Mix
where it is multiplied by the carrier signal. Hz.ADSR
only produces
non-zero values after it receives NoteOn
events. Moreover, it is
fundamentally, monophonic, producing a single value at any moment.
You can explicitly duplicate and distribute performance events to
cooperating nodes or you can employ Voices API
to do this for you.
Here's a snippet from the Mix.ADSR example.
// Oscillator with built-in ADSR inactive to show side-chaining.
let id = `t${this.GetId()}`;
let scene = await Ascene.BeginFiber(this);
let osc = scene.NewAnode("Hz.Osc", {name:"osc", cfg: "mono"});
let adsr = scene.NewAnode("Hz.ADSR", {name:"adsr"});
let mix = scene.NewAnode("Hz.Mix", {name:"Mix", cfg: "1to2"});
scene.Chain(osc, mix, scene.GetDAC()); // clean
scene.Chain([adsr,0,1], mix); // connect adsr to mix's "sidechain"
await scene.Sync();
scene.VisualizeGraph();
osc.SetParam("/adsr/Active", 0); // deactivate built-in ADSR
This code produces this audio graph:
Here's the GUI for Hz.ADSR
As you'd imagine, tweaking the knobs above the ADSR parameters triggers
an update to the envelope shape at the right. In addition, directly
moving the colored dots update the plot and its curvature-controlling
values: Apow
, Dpow
and Rpow
.
Name | Id | Description | Range |
---|---|---|---|
Active | 212 | Controls whether ADSR is active | 0,1 (1) |
A | 200 | Attack, in Seconds | 0-4 (.1) |
D | 201 | Decay, in Seconds | 0-4 (.2) |
H | 202 | Hold, in Seconds | 0-4 (.1) |
S | 203 | Sustain, in pct of Ampltude | 0-1 (.8) |
R | 204 | Release, in Seconds | 0-4 (.3) |
T | 205 | Tail (after release), in Seconds | 0-12 (0) |
VelocitySensitivity | 206 | 0-1 (1) | |
TremoloGain | 207 | 0-1 (.1) | |
TremoloFreq | 208 | in Hz | 0-10 (.0) |
Apow | 209 | Attack power exponent | -5-5 (-3) |
Dpow | 210 | Decay power exponent | -5-5 (-3) |
Rpow | 211 | Release power exponent | -5-5 (-3) |