Friday, February 27, 2009

Thor's Destination Amount

Just an interesting observation I made while developing the noise gate. The "Destination Amount" in each of Thor's routing rows goes from -100 to 100 and modifies the Source signal as it goes to the Destination. However this is not a linear modification. It turns out that it's cubic! 100 is still 100% and -100 is 100% inverted, but smaller values follow a cubic relationship. Therefore, a setting of 80 is actually (80/100)*(80/100)*(80/100) = 0.512, or about 50%.


Figure 1 - Thor Destination Amount

Figure 1 makes this clear. Note that this means values of Dest Amount between about -25 to 25 are very close to zero. The regions between -100 & -80 and 80 & 100 are reasonably close to linear.


Figure 2 - Thor Scale Amount

However the scaling caused by the Scale parameter is linear, as figure 2 shows.

Designing a Noise Gate in Reason 4


Figure 1 - The Noise Gate

While looking around for useful music production tutorials, I came across this article by Francis Preve. Francis describes the operation and control of a noise gate - an often overlooked audio effect device that was originally designed to help remove noise from an audio recording. I won't repeat the article here as it's well written and comprehensive.

The most interesting aspect of the noise gate is the effect you can create by using a second audio source, for example a drum track, to trigger the gate and allow through another signal such as a sustaining pad. When carefully set up, this can result in some great rhythmic dynamic effects.

Propellerhead's Reason 4 "music system" software has many interesting built-in devices but it does not have a noise gate. So I set about designing one.


Figure 2 - Typical Noise Gate Response

This diagram shows the relationship between the input signal and the output signal. The output signal is shaped by the Gate Envelope, which is triggered when the input signal exceeds the threshold. As long as the input is above the threshold, the Gate Envelope rises at the Attack rate to fully-open, where it then sustains. When the input signal falls back below the threshold, the Gate Envelope will hold fully-open for a certain period of time (Hold Time), and then fall back to zero at the Release rate.

The first thing to notice is that this system is non-linear. Excluding infinite sums of cosines, there isn't a way to create this relationship without a step function. The question is, how do we implement this in Reason? Reason has fairly primitive support for addition and subtraction of CV signals, but how can we get a step response?

The answer that I found is to use the Combinator. Normally, a Combi knob (or rotary) is programmed to modify a similar knob or slider on an internal device. But what happens if a knob is used to modify an on/off button or switch? It turns out that the switch will remain off until the Combi knob is at maximum (127), at which point the switch will turn on.

There's a well-known trick with the Combi where you can program a Combi knob to control an aspect of an internal device and then use an LFO or CV signal to control that knob via the port on the back of the Combi. Reason even animates the effects as if you were changing the knob manually. So if a CV signal is set to drive a Combi knob that is programmed to a button, then that button will turn on if and only if that CV signal drives the Combi knob to maximum. If that button is used to trigger the Gate Envelope, then we have the beginnings of a noise gate.

Figure 3 shows my noise gate with all devices except Thor expanded. I'll explain Thor's configuration a bit later.


Figure 3 - Expanded Front View


Figure 4 - Expanded Rear View

The wire routing on the back in figure 4 is pretty confusing, so I have created this diagram to make things easier to follow:


Figure 5 - Rear Connections Simplified

The design is pretty straightforward once you understand how all the parts work together.

First, an input audio signal enters via the Combi Inputs, or via the Side Audio Input - the Spider Audio Merger/Splitter at the top. A Combi only has two audio inputs, so this Spider is used as a secondary input and you use an External Route to connect an audio source.


Figure 6 - Input Mixer

The Input Mixer selects either the main audio input or side audio input, depending on the mode set by the Combi 'Side Channel' button. The result, or Trigger Audio in the image above, is directed into the Scream4 unit. It goes via the Tail Delay effect, which I will explain later.

Normally the Scream is a distortion effect, but in this case it is used purely as an amplitude envelope follower. It takes the incoming audio signal and generates a CV signal that essentially 'joins-the-dots' between each positive peak in the signal. So for example a burst of equal-amplitude sine waves would produce a rectangular-shaped amplitude envelope. This signal emerges via the Auto CV Output port.

This envelope is fed into Thor's CV Input 4. Without explaining the details just yet, it then emerges via CV Output 4 as 'Trigger' and this drives the Modulation Input port for the Combi's Pitch Bend Wheel, causing the Pitch Bend Wheel to respond to the input audio amplitude.

Now, why the Pitch Bend Wheel? Well, it turns out that the Combi's knobs and Mod Wheel have a resolution of 128 steps, 0 to 127. However the Pitch Bend wheel has a resolution of 2000 steps. It sits idle at 1000 and can travel down to 1 or up to 2000. When the incoming CV (it's bipolar remember) is zero, the Pitch Bend wheel sits at 1000, so this is our idle point. As the amplitude envelope of the input audio increases, the Pitch Bend wheel is driven higher towards 2000. If the signal is negative, the wheel goes towards 1. The Combi is programmed so that the Pitch Bend wheel controls Thor's Button 1, labelled "Gate Trigger". When it hits 2000, the Gate Trigger is turned on. Any other value and it's off.

So I am only using half of the Pitch Bend Wheel's resolution (1000 to 2000) but I have found this gives much better results than 128 steps and also frees up a Combi knob for use as a setting.


Thor - The "Computer"

Now I have to explain how Thor is configured. First, I renamed Thor as "Computer", since it does not provide any audio output in this device. It is acting merely as a signal processor. Thor is incredibly useful in this capacity and should be considered far more than just a (great) synthesiser.


Figure 7 - Thor, The "Computer"

You can see six rows configured in the Matrix and almost everything else is turned off.

Row 3 in the left column contains a rule that passes an incoming CV signal on CV In4 out to CV Out4, scaled by the level of Rotary2, labelled "Input Pre-Gain". As mentioned above, this signal is the detected amplitude envelope of the input audio signal. So this rotary acts as a gain control, scaling this envelope signal up or down. This is useful if the input signal is too loud or too quiet for the default calibration of the noise gate.

Row 2 in the right column has a rule that triggers Thor's Global Envelope when Button1 is on. Recall that Button1 is triggered by the input amplitude envelope causing the Combi's Pitch Bend control to hit 2000. Therefore, when the input signal is loud enough, it will trigger the Global Envelope. This envelope becomes the Gate Envelope. Note that the Global Envelope is set to maximum sustain and zero decay so that the gate is fully open once the attack phase is complete.

The Combi knobs 'Attack' and 'Release' are programmed to directly modify the Global Envelope's Attack and Release sliders. In this way, you can shape the Gate Envelope when it opens and closes.


Figure 8 - Combi Programming for Thor


Gate Mixer

This Global Envelope directly drives the Mod Wheel modulation input on the back of the Combi. The Mod Wheel behaves just like a normal Combi knob, with a resolution of 128. I use this control so I have all four normal Combi knobs available for settings. The Mod Wheel is programmed to control the Channel 1 & 2 levels on the Gate Mixer (Figure 9). Normally Channel 1 is unmuted and Channel 2 is muted. When the Mod Wheel is at its lowest, then Channel 1 Level is zero and Channel 2 Level is maximum. As the Mod Wheel increases, so does the Channel 1 level, but Channel 2 Level drops towards zero. Both channels are receiving the audio signal from the main audio input and the Gate Mixer is connected to the Combi audio outputs, so this is how the Global Envelope affects the output signal.


Figure 9 - Gate Mixer

Because Channel 2 operates in the inverted sense, when the "Flip" setting is enabled, Channel 1 is muted and Channel 2 is unmuted. In this mode the gate works 'backwards' - audio is passed through the gate when it is off, and inhibited when the gate is open. This can create some interesting effects.


Threshold

So now we have a device that opens to allow through audio whenever the input amplitude envelope causes the Pitch Bend control to hit 2000. But this corresponds to a particular loudness and it would be much better if this limit, or "threshold" could be configured. The Input Pre-Gain rotary on Thor goes some way to provide this, but it has another role to play as a secondary adjustment. Instead, a constant (or "DC") offset is used to adjust the zero level of Thor's CV 4 Output. I.e. the Pitch Bend bias.

Imagine a sine wave that oscillates between -1 and +1. The average level of this signal is zero. If you add a constant value, say 4 to every point on the sine wave, you get a signal that oscillates between 3 and 5, with an average level of 4. Using this principle, a constant value can be added to the input amplitude envelope to bring it closer to the magic 2000 limit. In this way, the gate can be made to trigger for quieter signals.

For example, normally the Pitch Bend Wheel idles at 1000. If you adjust the threshold you will see this value increase towards 2000. Because it starts closer to this limit, then it should be fairly obvious that it only takes a smaller signal to get there.


Figure 10 - Malström LFOs

The Malström is used to generate this DC signal. LFO1 is set to the constant waveform and this CV output is fed into Thor CV Input 1. Within Thor, the first two rows of routing entries in the left column adjust this DC level and add it to the signal going out via CV Out4. The first row configures Rotary 1 to scale the DC signal that goes to CV Out4. Note that combining routing rules with the same Destination results in simple addition of the signals. The -8 amount is a small adjustment used to calibrate the system.

Combi "Threshold" knob is programmed to modify Thor's Rotary 1.

So now we can adjust the threshold and cause the gate to trigger at the amplitude level we desire.

Note that the hold period starts at the same time as the attack period, so if the hold period is longer than the attack, the attack will always complete.

Hold

We're almost there. There's just one more control to implement, and that's the Hold control. With a noise gate, the Hold control is used to ensure the gate remains open for a minimum period of time. This stops the gate from rapidly opening and closing (stuttering) if the audio signal crosses the threshold repeatedly and too quickly. There's a hold setting on Thor's Global Envelope but the problem with that is it does not take effect unless the trigger sustains, so it's useless in this situation.


Figure 10 - again

The solution is to use the second LFO on the Malström - a simple square pulse set to 'one-shot' mode. The Combi Hold knob is programmed to adjust the Mod B rate, which in turn affects the duration of the pulse. Within Thor, the gate trigger (Button1) is routed to output a CV signal on CV Out1. This is used to fire the Gate on the Malström and activate the LFO, producing the single square pulse. This pulse is fed back into Thor via CV In2 and used to retrigger the Global Envelope. Fortunately, if the Global Envelope is already active (as it will be in this case) then this simply continues the envelope, holding it in sustain until the pulse has finished, even if the audio envelope trigger has since fallen below the threshold. So in this way, the Hold feature is implemented.

Tail Delay

There's a quirk in the way Reason works. When a device no longer receives any input (and has emptied its delay buffers, if any) then it makes sense to stop outputting anything, since there's nothing coming in to actually process. This is both a CPU-cycle saving feature as well as a consequence of the design. Unfortunately it causes a problem in this device.

The Scream, at least in Auto CV mode, has no internal delay. So when the incoming audio signal suddenly stops (perhaps due to fast release or other gating) the Scream will also suddenly stop processing. This means it does not output the final CV sample - the one that shows the envelope returning to zero! Instead it holds the previous sample which in this case is obviously not zero. So for other devices down the chain, they see this signal as non-zero. If this held value is high enough then this has the side-effect of keeping the gate triggered and therefore open, even when the sound has completely gone. Not good for a noise gate!


Figure 11 - Tail delay

The solution is to use a Delay set to 0% feedback, 1ms delay, and 1% wet. This creates a very, very low single echo 1ms behind the main signal, which is enough to keep the Scream processing for a few more samples beyond a sudden audio cutoff without affecting the envelope. Problem solved.

Monitors


Figure 12 - Real-time Trigger & Gate Monitors

The delay devices labelled "Trigger Monitor" and "Gate Monitor" do not process any signals - instead they provide a visual way to monitor the trigger level and gate envelope in real-time. You can also visualise these signals by watching the movements of the Pitch Bend and Mod Wheel within Thor.

The Combi patch is here.

Calibration

In order to ensure the noise gate is operating correctly, I constructed a Calibration test bench. This involves of a main input signal consisting of a single sinewave at various volumes, with a rectangular amplitude envelope. There is also a similar side-channel input. Use of this test bench verifies the gate's behaviour and also led to the fine tuning seen in routing row two in Thor.

The Calibration RNS file is here.


How To Use

Recall these typical noise gate settings:
- Threshold: set the amplitude level that triggers the gate
- Attack: set the rate at which the gate opens, once triggered
- Hold: set the minimum period of time the gate will remain open.
- Release: set the rate at which the gate closes once the signal has fallen below the threshold and the hold has expired.

A fast attack with slower release and some hold time is reasonable setting.

There are at least three main ways to use a noise gate. All of them take a bit of time to set up, but the results can be quite good.

Firstly, you can use it to simply gate out quiet sounds. When the input signal is below the threshold, nothing gets through. With longer release, a louder sound may trigger the gate and allow subsequent quiet sounds to follow it through.

Secondly, you can use a side input to trigger the gate with a different audio source. This works great with drum loops triggering the gate on a sustaining pad.

Example RNS.
Ogg Vorbis.

Thirdly, you can "flip" the gate so that it only passes audio when it's *not* open. This seems to work best when the attack is set reasonably long and the release is short.

Example RNS.
Ogg Vorbis.

If you put a delay, say 3 steps, on the main or side input, you can generate some extreme weirdness!

Can you think of any more ways to use a noise gate?

If you use this noise gate in a new or great-sounding way, or improve it, please let me know as I'd love to hear about it.

Update: version 11 released.

Welcome

Hello, I am meowsqueak and welcome to my new blog about things related to audio and music production. I like to play with sound in my spare time and occasionally I'll come up with something interesting enough to share here.

If you're here with similar interests, please feel free to browse older posts and perhaps leave a comment or two.