Building an Envelope in Reaktor Core, Part III
Welcome to part III of our series on building an envelope in Reaktor Core. In this tutorial, I’ll show how we can improve the envelope we’ve been working on so far. In particular, I’ll be adding a knob called ‘Peak’ which will determine the maximum amplitude reached during the attack phase. In addition, I’ll modify the envelope stages to be logarithmic, a common feature.
ADDING A PEAK KNOB
Having a parameter that controls the peak parameter of an envelope is an idea I stole from Ableton’s FM synth, Operator, although I doubt that was the first synth to use it. The Peak knob allows for some rather strange envelope shapes where the decay section is actually increasing in amplitude, if the Sustain value is set higher than the Peak.
Adding the Peak knob to our existing design is simple enough. Currently, the peak amplitude is simply the incoming gate value. We supply the ‘End’ input of the Attack phase and the ‘Start’ input of the Decay phase with the positive values coming from our MIDI gates.
We could instead replace those values with the value of our Peak knob and be done. However, in that case, the envelope will not scale in amplitude as determined by the velocity of the incoming note. Instead, it works well to multiply the Peak value by the incoming gate. This way the amplitude of the envelope is controlled by the gate:
In this picture, I have also fixed a problem in our previous structure, which was that the Sustain value was not scaled to the gate (IE the envelope was previously sustaining at the exact same amplitude, regardless of the note velocity).
Currently, our envelope is operating in a linear scale, which means that the envelope sections travel directly from their starting point to the end point in a straight line. In reality, our ears don’t work on a linear scale, however.
Natural sounds have a logarithmic decay. Most musicians and audiophiles are familiar with a logarithmic method of measuring amplitude known as the decibel (dB) scale. In the digital realm, 0 dB is considered to be ‘unity gain’, or the maximum level of a sound, equivalent to an amplitude of 1.
[aside title = “Pro Tip”]Natural sounds have a logarithmic decay. [/aside]
From there, every decrease of 6 dB corresponds to an amplitude drop of 50%. For example:
-6dB = 0.5 Amp
-12dB = 0.25 Amp
-18dB = 0.125 Amp, etc…
Of course, no matter how many times you divide the number 1 by 2, it will never equal zero (this is known commonly as Xeno’s paradox and is somewhat contradicted by Calculus, but in this case it’s something to consider). Therefore, there is no dB value that truly corresponds to an amplitude of 0, however different numbers that are ‘close enough’ are often used, most commonly -96dB, or sometimes -120dB. For the purpose of this tutorial, I’ll choose -96 dB to equal an amplitude of 0 (in reality, it is 2^-16, or around .00001)
If you’re having a hard time imagining how our ears hear amplitude logarithmically rather than linearly, consider it like this – Two people applauding is not twice as loud as one person applauding. If it were, being in a crowd with thousands of people would cause you to go deaf!
Fortunately, there is a very simple way to convert our envelope from linear to logarithmic scale – we simply give our envelope logarithmic values to travel between. The envelope will travel between these value linearly like before, but as a last step we can convert the values to an amplitude scale, which will create our curve for us.
One problem that will arise is how we are using our gate velocity to scale the amplitude. Consider an envelope with a Peak knob ranging from -96 to 0. If the knob is set to -12dB, and we get a gate velocity equal to 0.5, if we were to multiply the values together as before we would end up with a new peak value of -6 dB, which is louder than our original peak!
Instead, what we need to do is convert the velocity from it’s amplitude value into the decibel scale, and then add the two together like so:
The log module here converts from amplitude to decibels, and has a base of 1.12202 (which you can set in the properties). Why? Because 1.12202 raised to the 6th power is equal to about 2, which means that increasing the input by 6 will double the output, and a decrease of 6 will halve it, just like with the decibel scale.
Finally, we need to add a simple math element at the end of the macro to convert our envelope from decibel scale back to amplitude:
What I really like about this solution is we’ve pretty much completely avoided any difficult math here, and really we’ve barely altered the structure at all.
Here’s a side by side comparison of two envelopes, the top one is linear, the bottom logarithmic.
Okay, that’s all I’ve got time for today. In the next installment of this series, I’ll show how we can expand upon this work to create an envelope with adjustable curve, something available in many commercial synths, such as Operator and Absynth.
Have a Question or Comment About This Tutorial?
Want to ask a question about this tutorial or perhaps you have something to add?
Click through to our forum post about this tutorial and join the conversation!