6.4.5. RNBO Compressor Tutorial #1 – Simple Compressor¶

Fig. 6.83 Simple dynamics compressor RNBO patch¶
This example will show how a basic dynamics compressor can be built for the H9000 using RNBO and gen~. In part 2, we’ll add compression ratio, as well as attack and release controls.
Download the maxpat file here: Simple Compressor.
The compressor has three main parts: input gain stage, compression stage, and output gain stage.
Input Gain Stage

Fig. 6.84 Input stage gain scaling¶
This section simply determines the input level to the compression stage. Here linear gain scaling is used (1 = unity gain, the value is high because the soundfile in this case is quiet). You could control this with db gain using the dbtoa object.
Compression Stage

Fig. 6.85 Compression stage¶
There are two parts to the compression stage—gain detection and gain reduction. To detect the gain of the incoming signal, we first take the absolute value of the audio signal. This converts the gain of the input to a positive number regardless of its cycle position. Then, we subtract the threshold (converted to linear amplitude) from the signal amplitude. If the signal is above the threshold, the difference will be positive. If it is below the threshold, the difference will be negative. This value is the overshoot. [>p~ 0.] detects passes the overshoot value if it is greater than 0. Once passed, it is subtracted from 1. (unity gain) to give us our gain reduction factor. Finally, we multiply the original audio signal by the gain reduction factor. This gives us our compressed audio signal.
Output Gain Stage

Fig. 6.86 Output stage with make-up gain¶
Lastly, we scale the compressed audio signal with a makeup gain factor. This allows us to compensate for the overall level decrease caused by the compression stage.

Fig. 6.87 All param obects used by the patch, displayed as three knobs in Emote¶
These param objects in RNBO allow us to control the compressor parameters in Emote after it is exported to the H9000. Params will appear as basic knobs in Emote (currently only knobs are supported when exporting RNBO patches to the H9000). The @min and @max arguments define the minimum and maximum values of the Emote control, @steps defines the number of steps between the min and max values, and @displayname sets what text will appear with the knob in Emote.

Fig. 6.88 UI displayed in Emote, including three knobs corresponding to three param objects¶
We now have a basic compressor designed in RNBO that can be exported to our FX chains on the H9000. You could use this as a simple, low DSP cost way to catch peaks when running very dynamic algorithms on the H9000, or use it as a starting point to design your own dynamics effects!
In parts 2-3, we’ll look at some ways to upgrade our simple compressor.