Peak Limiter

This plug-in is a fast peak limiter with look-ahead.
Rather than “wave shaping” (as the soft clipping limiter does), this limiter is a very fast compression effect.

It is designed to limit short peaks in the waveform (transient peaks) which will then allow the track to be amplified more without clipping.
This effect avoids creating the harmonic distortion that occurs with soft clipping.

Usage is very simple - just set the required threshold level and click “OK”.
Usually the track would be amplified to 0 dB before use, but it may also be used to bring “over zero” transients down to 0 dB in 32-bit mixes.
peak-limiter.ny (952 Bytes)
LATEST VERSION brickwall.ny
For usage instructions for the current version, see this post:


“Brick Wall Limiter…”
A vastly improved peak limiter.
As the name suggests, this is a “brick wall” lookahead limiter.

What’s it for?
You want to make a recording 6 dB louder, but there’s only 2 dB headroom above some of the highest peaks - this is the plug-in for you.

How to use it
Set the amount of amplification that you want to apply (per channel) and press OK.
The amplification will be applied but peaks will not exceed 0 dB (no clipping).

The “Hold” control can normally be left at the default 10 ms.

Will it distort?
Yes you can overdo it. :wink: If you push the effect hard enough you may notice some “weirdness” to the sound due to the gain changing rapidly, but there is negligible harmonic distortion.

What’s the Hold setting for?
The Hold control tells the limiter to keep the gain down at the “limited” level for a minimum length of time before allowing it to rise back up to the normal level.
If there is very low and loud bass notes, the limiter may tend to distort the shape of the waveform as it compresses the peaks of single wave cycles. To avoid such distortion, the Hold setting may be increased, so ensuring that the gain does not change with each cycle of the waveform.

The Hold setting should ideally be as short as possible, but must be greater than half a cycle period of loud low frequencies. 10 ms is good down to 50 Hz. 25 ms is adequate down to 20 Hz. Unless the sound being processed has very heavy low bass, the default setting is likely to work well.
brickwall.ny (1.86 KB)

That’s not what I’m seeing…

I selected a short bit of audio - 2.5 sec of speech - “Effect → Amplify” (level-checking only, I then hit Cancel) showed that the peak was -1.3dB.
I used the Brick Wall Limiter, with the default settings (3dB, 10ms).
I checked “Effect → Amplify” again, and it showed the new peaks as +1.7dB.
I ran “Analyze → Find Clipping” and sure enough, it found many clipped sections.

Did I miss something?

  • Win

Sorry about that - there does seem to be a problem with the version on the forum so I’ve re-uploaded it.
Thanks for letting me know.

Much better - thanks! This will be a welcome addition to the toolbox!

  • Win

I have a track that starts fairly quietly at about -5 dB, but the overall peak is -1 dB. I ask brickwall for a gain of +8 dB. The soft part then has 3 dB more amplification (without clipping) than it could have had using Amplify.

Do I expect the soft part to sound more distorted after brickwall +8 dB than it does if Amplify is used to raise just that section to 0 dB? Subjectively, I think it does sound more distorted after brickwall.


Harmonic distortion using brick wall limiter will never be greater than when using Amplify.
Amplify will result in clipping at 0 dB. Brick wall limiter prevents that from occurring by reducing the gain as necessary.
Does your playback system handle 0 dB signals without distortion?

Can you explain that? That makes it sound like our documentation is incorrect.

What do you mean by “0 dB”? A sine tone generated at 1.0 amplitude has some clipped samples according to View > Show Clipping, but they are below 0 dB according to Sample Data Export.

But generally, no, I don’t hear distortion at “0 dB” if I amplify to there. I keep the computer sound device volume slider high up and attenuate with an amplifier to which is attached rather cheapo JPW “HiFi” speakers.

Maybe I am saying the section of the track in question sounds different when I brickwall the whole track at +8 dB to when I amplify that section on its own to 0 dB. I would call it “distortion” on the basis that I don’t hear that colouration when I use Amplify or Compressor.


32 bit float format:
If you amplify a signal to a peak level of +3dB, then the sound card should handle everything below 0 dB well (no noticeable distortion). The sound card is incapable of handling signals above 0 dB. If it is a well behaved sound card, sample values above 0 dB (+/- 1 linear) will be converted to +/- 1 .
0 dB is the “Threshold of Doom”. Nothing gets beyond it alive.

Integer format audio:
If you attempt to amplify a signal to a peak level of +3dB, you can’t do it. Integer format audio runs out of bits, “A bit more than +1.00” is a negative number. A bit less than -1.0 is a positive number - literally “1 bit”.

In both cases 0 dB is the threshold at which digital clipping occurs.

If the original audio had a peak level of -8 dB or less, then there should be no difference.
If the original audio had a peak level greater than -8 dB, amplifying by +8 dB will cause clipping whereas the brick wall limiter will reduce the gain just before the peaks so as to prevent clipping.

Sound that has been heavily limited will sound “different” to sound that has not been limited.
“Extreme” limiting may sound a bit “distorted” because of the rapidly fluctuating gain (any effect can be abused). Excessively rapid gain changes can be moderated by increasing the “Hold” parameter (values greater than 30 ms require a code change.

Without truncating the tops of the waveform as would happen at 16-bit?

What about the correctly represented 32-bit float recordings of cannon shots at +60 dB or whatever? Would a 32-bit float sound card (if such existed) play that at + 60 dB?

An example of the documentation problem: in Compressor in the Manual, the “Make-up Gain” “boosts the resultant audio after compression to a peak level of 0 dB” (by which we mean “without distortion”).

Now I thought -32768 or +32767 at 16-bit meant “just touching” 0 dB (and no distortion). Is a sample at -32768 or +32767 “just touching 0 dB”, or “at 0 dB” (which is what you said)?

The overall peak was -1 dB but the peak of the quiet section was -5 dB.

Here we go again. Do you mean that using Effect > Amplify with “Amplification (dB)” at +8 dB and “New Peak Amplitude” at 0.0 dB will amplify to just below 0 dB (no clipping), or to “touching” 0 dB (no clipping), or to 0 dB (which you say causes clipping)?

If there is no waveshaping, what causes that?

Do you accept that it may sound like a “distortion”? I’m talking about more “refined” genres than dance or house. :slight_smile:

Thanks. I’ll grant that 30 ms “Hold” removes most (not all) of the “difference” compared to using Amplify to 0 dB on the quiet section.

Would +8 dB on the track I mentioned be regarded as “heavy” or “extreme”? And I would be better using “soft knee” on your “Proper” Limiter for subtle material?

Should the “Proper Limiter” also have a “Hold” control?

I don’t understand why the Brickwall lacks a “Threshold” or “Limit” control. What determines the Threshold there?

Sorry for all the questions. Perhaps you’ve got me slightly interested in demoting “Hard Limiter” to non-shipped. :wink:


The “0 dB limit” is a bit like “midnight”. On of those things that fascinated me as a child was the idea that a clock stopped at midnight will tell exactly the correct time twice a day, but a working clock may never be exactly right.

Strictly speaking, positive peaks in 16 bit integer format clip have a maximum possible value of about -0.000265 dB because positive integer values “only” go up to +32767 and not +32768 so strictly speaking they can never reach 0 dB on positive peaks. 32767/32768 in dB. This can be proved by running the following two snippets in the Nyquist Prompt on a 16 bit audio track:

(snd-const 1 0 *sound-srate* 1) ; create samples at +1

(linear-to-db (snd-fetch s)) ; display value of a sound

The Brick Wall Limiter is configured for maximising loudness so the dB limit is fixed at just under 0 dB (about -0.0087 dB or 0.999 linear).

To see the behaviour as will be produced by a 16 bit sound card we can use 16 bit audio tracks:

  1. Create or import audio as a 16 bit track.
  2. Amplify to a peak level of -8 dB
  3. Duplicate the track
  4. Apply “Effect > Amplify” to the first track and amplify as much as possible without clipping (about 8.0 dB)
  5. Apply “Effect > Brick Wall Limiter” to the second track with “input gain = 8 dB”
    The result is virtually identical (there is a tiny bit of difference because Brick Wall Limiter leaves a tiny bit if headroom, so the output level is just below 0 dB).

Now try a similar test:

  1. Create or import audio as a 16 bit track.
  2. Amplify to a peak level of -1 dB
  3. Duplicate the track
  4. Apply “Effect > Amplify” to the first track with gain set to +8 dB and “Allow Clipping” enabled.
  5. Apply “Effect > Brick Wall Limiter” to the second track with “input gain = 8 dB”.
    Zoom in close on some peaks and you will see that the “Amplify” effect has caused visible (and audible) clipping whereas the Brick Wall Limiter has not.

Whether it is “heavy” limiting depends on the material. If there are a few extreme spikes (clicks) that are well above the level of the rest of the audio, then +8 dB is probably not “heavy” at all. For a 'Cello solo that has already been gently compressed and normalized close to 0 dB, +8 dB is probably “extreme”. The measure is “how much of the music are you squashing and by how much”.

The “Soft Knee Limiter” performs best as a subtle effect. If the input has a peak level close to 0 dB then I wouldn’t usually go much over 3 dB with the limiter. I’ve not got it installed at the moment, but if I recall correctly the slider has a maximum range of 10 dB because beyond that it does not sound good.

To achieve maximum loudness one would normally use a compressor effect first, and then use a limiter to squeeze out a little bit more. Typically a limiter can provide an extra 2 or 3 dB gain with little noticeable effect (whereas amplifying to +3 dB will be noticeably clipped/distorted).

Some more “RJH-views” on the subject.
an amplification of 8 dB (7 dB effective) is too much for any limiter. Recommended are 3 to 5 dB (Quote Pro-audio). If one wants to participate in the loudness war, limitors are the worst choice.
I do not know how the inner workings of Steve’s plug-in are, but there are some rules that are based on common physical facts, that can’t be circumvent by any sophisticated algorithm whatsoever.
At least, the possible amplification levels achieveable are quite small, if the sound should still be natural and musical.
Let’s say gayle’s audio was -5 dB in the quiet parts and -2 dB. in the loud parts. We choose a threshold of -8 dB and a make-up-gain of 0 dB (line of doom, how beautiful…).
A “08/15” (brickwall-) limiter is nothing but a compressor with infinite ratio, this means that absolute no amplification is aloud beyond the threshold (-8 dB). In contrast to a compressor, the attack time has to be as small as possible to prevent short peaks to overshoot or slip thru. If the release time is also nearly 0, we have a hard limiter that simply cuts away the caps of our wave form.
A sine wave at -5 dB would be flat from 45° to 135°. Half of the cycle would now be coloured with odd harmonics. With a sine wave at -2 dB it’s even worse, 2/3 of the cycle period is modified.
We can now employ different tricks to improve the results. There is the so called “soft knee”. It would start at about -11 dB and gradually reduce the aplification till -8 dB is reached. The transition is now much more smooth.
Another possibility is too increase the release time. Thus the second half of the waveform is amplified. The result is that the threshold can be moved up (-5 dB for example) but the resulting sound is perceived as equally loud as the -8 dB limited one, with much less distortion.
Unless we really want to eliminate short sharp spikes, the limiter does not work on single wave cycles but rather with an envelope, that rides on the peaks (or is built up with the rms values).
The hardest thing to do is to find the proper release time. The human ear needs some recreational time after loud amplitudes or the following ones are not heard. That is called “pumping”. It begins at about 300 ms. - that’s the right limit for our release time.
One might think that it is enough too reduce this time too get a fiting resolution without pumping.
The problem that now arises is due to the bass amount of the sound. short release times will modify the long wave cycles of the low frequencies themselves. But this direct manipulation introduces distortion in these lower frequency bands.
A possible improvement is “dynamic release time”. The time is now controlled by a filter (12 dB/octave roll off HP). Besides this phenomen is presumably responsible for the “atrocious” (quote from source code) results in Chris’s dynamic processor, when the bass setting is enabled.

I would like to know which approach Steve has chosen to prevent his plug’in from producing unwanted harmonics. Am I wrong in assuming that the peak-limiter works rather in the fashion of an compressor with look ahead, i.e. an attack time?
To what refers the hold factor? can short peaks still occur when it is higher?

In short, if you want to increase the loudness of a piece by 8 dB (7 dB over unity gain in Gayle’s example), one should choose a combination of compression and limiting. The compression with a proper attack time ensures that the characteristics of an instrument are preserved, because the building up phase of the sound is not modified. The remaining peaks can be removed by the limiter (2 dB or so).
This comment refers of course also to the topic for the feature request for a “proper limiter”. The peak limiter will surely be a good option/addition for the different limiter variations (built into one plug-in).

“Lookahead” is not the same as “attack”.

The basic principle of a compressor or limiter is that if the signal gets bigger than a specified level, then the effect applies negative gain.

To simplify the description, let’s take a special case where we have an attack time of 1 second, a threshold of -6 dB and an infinite compression ratio. Loosely speaking (not getting bogged down in technical detail), this means that if the input is -5 dB (+1 dB above the threshold), then the compressor/limiter will apply -1 dB of gain, so that the output will be -6 dB. If the input is -2 dB (+4 dB above the threshold) then -4 dB gain will be applied so that the output is -6 dB. The “infinite ratio” means that input above the threshold level will be “limited” so that it does not exceed that threshold level.

The “attack time” is “how long it takes for the compressor/limiter to reduce the gain”. For this example we said that the attack time was 1 second - to make that more precise, let’s say that the attack time is “1 second for a gain change of 6 dB”.

So let’s take a signal that is below the threshold, then suddenly jumps to a constant level of 0 dB. The compressor/limiter will reduce the gain by -6 dB to compensate and bring the level down to the “limit” of -6 dB. The “1 second attack time” means that it will take 1 second to do this. The sudden increase of the input signal to 0 dB will initially produce an output of 0 dB, but the effect will respond by reducing the gain, so the output level will be reduced over a period of 1 second until it is at the “limit”.

Obviously this is not good if we are trying to keep the peak level below a certain level. There are two ways to combat this problem.
One method is to reduce the “attack time”.

If we use a very short attack time, then as long as the input level does not rise too quickly, the limiter will be able to keep up and adjust the level fast enough to prevent the output from exceeding the specified level.
There are two problems with this method:

  1. If the attack time is too short, then waveforms above the threshold level will be deformed (as described by Robert). The extreme example of this is that an attack time of zero will produce hard clipping.
  2. If the attack time is not short enough, sudden peaks may exceed the specified level because the compressor/limiter does not respond fast enough.

The other method is to use “lookahead”.
With this method, the level detector “looks” at the input signal in advance of playing/processing it.
To take Roberts description of a “gain envelope”, the envelope is time shifted a bit earlier so that when a peak approaches, the effect will start to reduce the gain in anticipation of the peak. When the peak arrives, the gain has already been reduced so that the level of the peak does not exceed the specified level. The amount that the envelope is shifted is called the “lookahead”.

In our previous example of an attack time of 1 second; If the lookahead is also 1 second, then the limiter will start to reduce the gain 1 second before the peak arrives, By the time that the 0 dB signal arrives, the gain has already been reduced by -6 dB, so that the output level does not exceed the specified level.

Both of my limiter plug-ins use “lookahead” to ensure that the level does not exceed the “limit”. The attack time is quite short, but is long enough that there will be little harmonic distortion of frequencies above 20 Hz.

Let’s say that you have a high level, low frequency (bass) sound and we don’t use “hold”.
What will happen is that (with lookahead) the gain will reduce in anticipation of the start of the sound.
Because it is a low frequency sound, the limiter will tend to track the individual waveform peaks, causing a rapid “fluttering” of the gain level. This is undesirable because it distorts the waveform.

Take another example - let’s say that there is a drum roll. Each hit on the drum has a high peak and then the level drops rapidly before the next hit. If we don’t do something clever the gain will be fluttering up and down with each strike, substantially changing the sound of the drum roll.

One way that we can partially address this issue is to use a fairly slow release time so that after each peak the gain returns to “normal” (unity gain) fairly slowly. The problem with this approach is that unless we use an excessively slow release time the gain will still be fluttering (though less so than with a fast release time).

Another way that we can deal with this problem is that when the gain is reduced, it is prevented from rising again for a short period - it is “held” at that level for a short while before the gain is allowed to rise again. This is the “hold” setting. With a hold time of 10 ms, when the gain is reduced it cannot rise again for at least 10 ms, thus preventing fluttering. This does not affect the attack of the limiter. If an even higher peal is encountered, the limiter can still reduce the gain further without waiting for the “hold” time. The “hold” time just defers the release. The “recovery time” for the limiter (not specified in the GUI) is a combination of the hold time and the release rate.

Sorry, I was unprecise. look up is of course not the same as attack time, the former refers to the time before reaching the threshold and the later to that one after.
Besides, Compressors begin to work as limitars when they exceed a ratio of 1:10 or 1:20. In our example of -6 dB, this would result in a signal that lies 0.6 (0.3) dB over threshold. But those are no Brickwall limiters anymore.
I’ve searched for a proper definition of a “leveler” effect, but the opinions seem to differ greatly among manufacturers. Pro Audio sees leveling as a dynamic processing over a long time, i.e an equalization of the loudness over the whole song. The wikipedia article is stumpy and not very enlightening. However, I don’t think that it is realised as a wave shapener, quite the opposite. A simply variation would be to multiply the original signal with the reciprical of the RMS envelope. In this extreme case, all dynamic levels would end up equally. It’s of course not as simple as that.

Yes I know at 16-bit your Brickwall Limiter is superior to an Amplify by an equivalent amount that took the level over 0 dB (if you allowed clipping). “Visually”, it doesn’t appear superior to Amplify at 32-bit float if you look above +/-1.

I was more concerned about where distortion occurs - “touching”, “at” (what you say) or “over” 0 dB (this latter being what the Manual says or implies).

You didn’t give the Nyquist prompt input to create samples at -32768, so I tried in Nyquist prompt:

(snd-const -1 0 *sound-srate* 1)

No doubt you’ll tell me what this produces, but the values in Sample Data Export show as “0.00000” (silence would show as “[-inf]”). Audacity Show Clipping and Meter Toolbar regards these samples as “clipped” as I would expect from that value. One oddity is that Analyze > FInd Clipping does not find these clipped, but it reports values of -1.00000 (as obtained by silencing then dragging samples to the bottom) as clipped.

The Audacity Manual and e.g. regards samples exceeding -32768 or +32767 at 16-bit as clipped.

Although this is kind of academic, can everyone be correct at the same time?

Another BTW:

(snd-const -1 0 *sound-srate* -1)

crashes Audacity. I couldn’t see it here: .


As you correctly deduced, this produces sample values of -1 linear (= 0 dB)

(snd-const -1 0 *sound-srate* 1)

In practical terms, most sound cards will clip a little below 0 dB due to limitations of the hardware. This is one of the reasons for why we recommend making the final export a little below 0 dB.

The theoretical/philosophical problem is like a clock that stops at 12h 0m 0.0000s.
If we look at the clock and it says 11:59:59, then the clock has not yet stopped.
If we look at the clock and it says 12:00:00 then has it stopped or is it exactly 12:00:00? We don’t know.

For 32 bit float format we could count anything over 0dB as clipping (imho this would be the “correct” way to detect clipping for 32 bit float).
32 bit float does not “actually” clip at 0 dB (the waveform can go way above/below 0 dB) but when converted to integer format (as we must do eventually because sound cards all use integer format) it “will” be clipped because integer format has an absolute limit of 0 dB.
(the difference between -0.000265 dB and 0 dB is too small to worry about as it is much less than the noise present no matter how good the recording/playback equipment is).

But that is one of the main points of a limiter. If you try to play those peaks beyond +/- 1 they will be truncated (clipped) and will sound terrible. To correct that problem using the Amplify effect is to negatively amplify so that the peaks do not exceed +/- 1, but then the audio will be much quieter. Dynamic compression, whether by using a limiter or compressor, is about reducing the dynamic range. Reducing the dynamic range means that the overall level can be louder without excessively high peaks.

The main difference between a compressor and a limiter is the time scale - compressors deal with relatively slow changes - the gain is changed relatively slowly to reduce the dynamic range. Limiters work on a very short time scale which makes them more suitable for dealing with “transients” (short peaks).

I can’t reproduce that. Could you posts steps to reproduce in a new topic (or on Bugzilla if more appropriate).

I don’t get a constant value when I execute the following code (on a 16-bit track)

(setf *float-format* "%.15f")
(pprint (snd-fetch (snd-copy s)))
(const -1)

The value changes randomly between -1.0000… and -0.999969482421875
For the positive case, the value is always 0.999969482421875
Any idea what’s behind this?
I guess it’s the dithering. It seems to stay at -1.000… when it is disabled.
But if this is the case and it is in fact the dithering, then it appears that the noise is somewhat odd distributed, on the negative side only. A 17th bit wouldn’t be bad :wink:


It sounds so much better than the “hard limiter” effect that came with Audacity.

The hard limiter that came with Audacity it adds some distortion from clipping in sacrifice of increasing the gain of my guitar signal to a higher signal to noise ratio.

The “brick wall limiter” I hear no distortion. I was always thinking that my pickups were garbage and that’s why it was sounding too distorted in Audacity, but now I see its because your “hard limiter” effect is what was making my guitar sound distorted in a bad way from clipping.

I would vote to leave it at “over 0 dB is clipping”. With the negative and positive maximum 16-bit sample values being different and hardware potentially clipping below 0 dB (soft clipping, anyway) it’s too confusing to say anything else, I think.

I did say this was academic :smiley:


See .