Gain Shaper Audio Unit
Audio Unit, Mac OS 10.4+, Intel or PPC
(Only tested on 10.6. Please let me know if it doesn't work on older versions.)

What It Does

Compressors and limiters work on small time scales (milliseconds), and the distortion that comes with these micro-adjustments is not always desirable. In some applications, it's better to "manually compress" a wave by drawing a gain envelope on a time scale of seconds (or even minutes!) instead of milliseconds.

This technique is especially useful in recordings with a wide dynamic range, like the piano music I record. It's nice to bring up the volume a bit in the quieter sections, so that the loudest peaks don't limit the overall volume of a piece. Unfortunately, manually drawing volume curves can be quite tedious: there's a lot of trial and error involved in getting the levels right for each section so that nothing goes over the top and quiet sections are consistent with respect to one another.

Part of the problem is that there's not an obvious visual correspondence between a gain curve you draw and the waveform you're trying to shape: when the waveform goes down, the gain curve goes up — and not necessarily by the same distance on the screen!

Enter Gain Shaper. This plug-in just adjusts the volume of your audio — nothing more! — but does it in a way that takes advantage of the on-screen display of the wave. You draw an automation curve that visually matches the shape of your wave, and Gain Shaper will adjust the volume for you based on the curve you draw.

At its strongest setting, in the illustration above, Gain Shaper would pull the whole orange line up to 100% volume. At gentler settings, Gain Shaper would bring (A) up very slightly, and (B) up slightly more — but the softer section would still be softer.

How To Use It

  1. Get your wave into an app that supports automation of Audio Unit parameters, such as Logic.
  2. Add Gain Shaper to your track's effects, and automate the wave shape parameter.
  3. Draw a curve that floats just above the peaks of your audio. You can draw the curve at different time scales to create faster or slower adjustments to taste.
  4. Adjust the zero point position to tell the plugin where silence is. In most apps, this will be 50% — silence is right in the middle.
  5. If you don't want the highest peaks to hit maximum volume, adjust the target level to give yourself some headroom.
  6. If you want to limit how loud the softest sections will be, adjust the max gain.
  7. Listen while playing with the scaling parameter. Smaller values create a subtler effect.

The Algorithm

Here's exactly what the shaper does:

Take the current wave shape, adjusted for the zero point position, to determine the input level in decibels. In the example above, this is -3dB at (A), and -17dB at (B).

Determine how much gain we'd need to adjust the input level to reach the target level. Suppose, for example, that the target level is set to -1dB. That means that we'd need an extra 2dB at (A), and an extra 16dB at (B).

Multiply this gain by the scaling. Suppose that the scaling is 25%; then at (A), the adjusted gain would be 0.25dB, and at (B), it would be 4dB.

Make sure that the adjusted gain does not exceed max gain. If the max gain is 3dB, then (A) would still be raised by 0.25dB, but (B) would only be raised by 3dB.

You can observe the resulting output gain by looking at the gain parameter while the audio is playing. Note that this parameter is read-only — it's just an indicator.

A Warning

Note that Gain Shaper is not a brick wall limiter! It pays attention to the wave shape you draw, and not the actual input level. If you draw the wave shape lower than the actual input level, then the output can exceed your target level. In short, you still need to watch for digital clipping. Use a traditional limiter, or good old manual inspection of your meters, to catch clipping.

Enjoy and use in good health. Patches and suggestions are welcome, though there's no guarantee I'll get to them in a hurry.

Known Bugs

Logic incorrectly displays "Gain" as an adjustable parameter, when in fact it should be displayed as a read-only meter.