Chris’s dynamic compressor

Update: 1.2.3 version released. See bottom.

I’ve written a program that makes it easier to listen to classical music, or other music that has a wide range of volumes, at low volumes or in high noise conditions (such as in your car) so that you can still hear the soft parts. I’ve also written a plugin version, designed to be used with the free audio editor Audacity. For details on how to use it, see the bottom of this post.

Lots of interesting (really!) exposition

For a long time now, I’ve listened to classical music less than I might like to. A lot of that is because listening to classical music is hard. You have to turn the volume up to hear the soft parts, and then either turn it down when it gets loud or have it be loud enough to be distracting (or painful). For instance, in the car, there’s a lot of noise from the road, so even at normal volumes it can be difficult to hear some of the soft parts. And some albums and songs are so quiet that many players can’t be turned up loud enough to hear the music, even in quiet conditions!

I’ve sort of put up with this problem for a long time, but it really hit home how inconvenient it is the other day when I was driving with some friends. I changed my mp3 player to some Debussy piano solos (from his Children’s Corner suite, really nice stuff) and tried to play some of it for them. Well, it failed pretty miserably. It was so quiet, even with the volume all the way up, that you couldn’t even hear anything below a mezzo-piano, and the tape adapter was already so noisy (not to mention the harmonic distortion) that enjoying the music was basically impossible. And I realized: if only this music were as loud as normal music, they probably would have really liked the tracks. So the low volume of those songs actually turned two people off of classical music. What a shame!

So, what to do? Well, there’s no simple solution, but there is a pretty good one. Using an audio editing program, it’s possible to rip the music off of a CD and change the sound to be louder. Then you can make an MP3 of it or burn it back to a CD. This solution is kind of labor intensive, but after the first CD it can be largely automated (depending on how much you want to tweak it for each song, and that does make a difference), and anyway it’s the sort of thing many people enjoy doing with their music collections. Well, me, at least.

So one day I loaded up a song into my editor and tried applying a dynamic compression effect to it. Dynamic compression, often simply called “compression”, is a technical term in audio editing that refers to a process that raises the volume of the quiet parts of an audio input up to near the volume of the loud parts. This has the effect of compressing, or reducing, the dynamic range—the difference between the soft and the loud—of the signal. The way it does this is usually to detect how loud the input is at a given point and amplify or reduce the output until it’s near the target volume. Now, it doesn’t adjust its amplification instantly. If the signal drops suddenly (as it might in a recording of speaking, after the end of a sentence), the compressor gradually increases the volume over a period of anywhere from .25 seconds to 5 seconds.

However, most dynamic compressors decrease the volume instantly when the signal rises. Well, actually, worse than “instantly”, they actually have a lag. They decrease the volume only after the input starts to rise. This is because most compressors are designed to be used on vocals and solo instruments, in realtime. Even in audio editing programs, where things aren’t realtime, the compression effect is usually designed the same way. Because it’s in realtime, it doesn’t have the option of decreasing amplification before the signal starts to rise. So some of the signal, usually some tenths of a second, is output at a very high volume while the compressor is detecting the loudness and reducing the amplification.

As you might imagine, this doesn’t really sound that great. When I applied that effect to my music, it didn’t turn out well at all. It sounded much too harsh, and sudden loudness usually led to clipping. (Clipping is like when someone speaks loudly into a microphone very close to their mouth, and you can’t understand what they’re saying because of the distortion.) The feel of the music was completely lost.

So I let it be for a few years. The other day, I was thinking some more on the problem, and came up with a design for a compressor that would do the kind of job I really wanted it to. The main idea is to anticipate the loud parts in advance, and start reducing the volume smoothly ahead of time so that it doesn’t get loud too quickly. (Another idea is to support extremely long rise and fall times so that the effect is never too intrusive.) I did some of the math (fifth grade math, albeit, involving finding the intersection of lines—I tried a version with parabolas that didn’t work out) and read up on the programming interface to Nyquist, and within two days I had a nice, working compressor. It does wonders to all sorts of piano solo and orchestral music. It’s possible to listen to things at very low volumes without missing any of the music. It even makes you hear things that you couldn’t otherwise hear even at full volume, because they’re just so quiet. (Things like the sound of the pedals being released on the piano at the end of a soft piece, or the very beginning of Ravel’s Daphne et Chloe.)

End of exposition

For you to hear it in action, I’ve provided three 30 second clips of the fourth piece from Debussy’s Children’s Corner suite, The Snow is Falling. They use version 1.1 of the compressor, so results will differ slightly, and the settings are named differently. The first has no adjustment, the second has compression applied with both rise and fall speed at the default 1.5 dB/s, and the third has compression applied with fall and rise speed set to a more aggressive 5 dB/s.

It was a lot of fun to program. I hope a lot of people get some good use out of it. I hope it allows me, and possibly you, to enjoy our classical music more often, and to more easily share it with our friends.

Download and Use

My program currently comes in two versions. One is a standalone program, both with a GUI and console interface. Download version 1.2 here. It requires the .NET framework version 3.5 (or Mono 1.9). If you’re using the GUI version, check out the commandline version for explanations of the parameters.

The other is an Audacity plugin, currently at version 1.2.2. To use it, download and install Audacity. Download the plugin source (i.e. right click on that link and select “Save target as…” or your browser’s equivalent), and put it in your audacity plugins directory (which should be under the main install directory on windows, and under /usr/[local/]share/audacity/plugins on unix). Your browser, if it sucks, might insist on saving the file with a “.txt” extension behind your back. If it does, you’ll have to remove this to get the plugin installed.

If your music is on CD, use a CD ripping program to make a .wav file of each track. You can encode the wav file (to mp3, ogg, etc.) after you’ve applied the dynamic compression. Use Audacity to open the sound file. Select the whole thing, then go to the Effects menu, to the bottom at Plugins, and select “Dynamic compressor…”. Adjust the settings to your liking, and click OK. To save your changes, you need to go to File \\ Export wav or Export mp3. File \\ Save will not do what you want it to.

Changes in 1.2.3

1.2.2 was broken on longish inputs (more than a few minutes) due to a bug in Nyquist. I was able to work around the bug.

Changes in 1.2.2

Two bugs were fixed. One caused tracks to be truncated sometimes after a period of silence in the track. The other caused inappropriate volume gains on certain parts of the track, usually at the end. (Specifically, the compression was being applied about 1/30 sec too soon.) Neither of these bugs were present in the program version.

Changes in 1.2.1

A simple noise gate is added. The floor is specified in decibels now, instead of linear.

Changes in 1.2

A completely different compression algorithm is used, based on parabolas instead of lines. It strikes a better balance between fast and slow changes, by varying its rate of change so that the envelope doesn’t leave so much empty space (i.e. low-volume sections) without losing too much transparency. You get a couple more parameters to play with. You can emulate the behavior of the old version by setting the exponent parameters to 1. The audacity version has much better memory usage (and thus, speed) on larger inputs than the previous version.

Changes in 1.1

  • Bugfix. It caused some areas to be amplified way too much on files, especially when the rise and fall speed were too high.
  • Renamed existing parameters to more conventional things for compressors.
  • Added a noise floor parameter, which lets you leave alone (apply a constant gain) parts of the audio below a threshold.
  • Added a compression ratio parameter, which lets you not bring everything all the way up to the same level, and also do weird things with ratios outside the normal range.

Code

Download the code using the Bazaar revision control system from http://pdf23ds.net/bzr/Compressor/trunk .

How it works (technical details)

First you resample down by a factor of 1500 or so using the max and abs functions to get a representation of the volume of the sound at any given point (the input envelope); Then you construct a compression envelope around the input envelope that “hugs” it in just the right way, and then you drag up the compression envelope points to 0 dB (and the volume of the input sound with it), i.e. you multiply the input sound by (1 - 1 / the compression envelope) * the compression ratio (or something like that—you get the idea, I think).

My compressor calculates its compression envelope thus: It first calculates a “paraboloid”, which is what I call the function

f(x) = x > 0 ? a1*x^b1 : a2*x^b2

where a1,2 and b1,2 are parameters to the compressor. b1 and b2 are set by default to 4 and 2 respectively, which I think is the key to the compressor’s effectiveness. Then it tries to fit sections of this paraboloid to hug, as closely as possible, the input envelope without going under it (which would cause clipping). It turns out there’s a unique fitting that’s the best, and it’s pretty simple to calculate using lookahead with a trial-and-error technique.

And that’s basically it. In versions earlier than 1.2, I had the simpler idea of using straight lines instead of curves, which gives OK results, but not quite as nice.


88 Responses to “Chris’s dynamic compressor”

Michael L Perry says:

Thanks for this fantastic compressor. I’m using it to level the speech in the latest episode of my podcast. The one built into Audacity must have a non-zero attack time, which results in every new segment of speech beginning with a loud blast. I was actually looking for Nyquist samples so that I could write my own leveler. You’ve not only saved me hours of fine-tuning per episode, but days or weeks of research and development.

I record each person on a separate track, so there are long periods of silence on each track while that person is listening. I’m experiencing a strange artifact during those portions where the volume would turn up and I would hear that person breathing. But I think that adjusting the floor will take care of that problem.

Thanks for all your hard work. It’s a real time saver.

Mike says:

Wow! This is exceedingly convenient. I, for one, appreciate this very very much.

David Gessel says:

Is it possible to set the attack and release to faster than 20db/sec? I have gun shots in a live sound track over voices, and want to avoid hard clipping.

-David

pdf23ds says:

For those, I would definitely try to manually correct for the individual gunshots. (The Nutcracker?) Audacity has a volume envelope tool that you can use to precisely deal with that sort of thing. If you still want to use the plugin to do that, at the very top of the .ny file there’s the definitions for the parameters, that you can edit to change the allowed range.

Dan Jolt says:

Wow, your compressor works really well. I agree with Michael, it’s good enough to use for podcast and (homebrew) radio production.

Hope you don’t mind a feature request:
Is it possible to add a flag, so that the compression would only be performed on a single channel (left/right) based on either the volume of this channel or the combined volume of both?

This would allow mono “talk-over” effects if you record your spoken track on one channel and have music on the other. First you could compress the voice channel and then the music in a way that it whenever something is spoken on the other channel, the music stays in the background to immediately return afterwards.

pdf23ds says:

Dan, I think that the option you’re looking for is really more of a separate plugin. The basic idea would be to take a volume envelope of the compressed voice track, invert it, and scale the background track to follow the inverted envelope. That sounds like a five line plugin to me, but I’m not up to writing it anytime soon. If I had to guess, it’d look something like

(mult background-snd (invert (snd-avg voice-snd 2000 1000 op-peak)))

where “invert” isn’t actually a Nyquist function, and you extract the “background-snd” and “voice-snd” sounds from the appropriate places.

You could try putting a request to the audacity-nyquist list, though.

links for 2007-10-15 « Where Is All This Leading To? says:

[...] Metablog » Chris’s dynamic compressor (tags: compressor compression audio audacity nyquist plugins opensource freeware mac linux osx windows winxp) [...]

Allen McBride says:

Great plug-in! It’s weird no one has posted since last October. Thanks! —Allen

pdf23ds says:

Heh. I think I had some overzealous spam protection there for a while.

Incidentally, I’m about to release a new version with a new, better algorithm. I have initially written it in C# but could make it work (somewhat more slowly) in Audacity. If you have a standalone tool, would you still want the audacity plug-in? (If I don’t write a new audacity plug-in I’ll leave the old plug-in.)

Allen McBride says:

I’ll look forward to your new version. From my perspective, I think an Audacity plug-in would be useful. To use a standalone tool I assume I’d need to export the audacity project to a single file and then re-import, right? Plus I use a Mac… is my sense correct that it’s hard to make C# programs run on Mac?

Thanks again,
Allen

pdf23ds says:

The Mono framework should allow programs such as mine to run on a Mac. It requires the 1.9 version, though, which is still prerelease and a quite large download—95 MB or so.

Allen McBride says:

Hi Chris,

I’m still getting lots of milage from your compressor. Thanks for the advice about changing the slider ranges; that lets me know for sure my settings are what I want them to be. I have another question about the noise floor, though — I’ve finally realized that it doesn’t behave as I had assumed. Sections of audio beneath the noise floor are still raised, just not quite as much as if you don’t set a noise floor. So if someone doesn’t speak for a couple seconds, you get a little hill of background noise in the middle of the break in speech. So I changed “(defun limit-amp (samp) (if (and (> floor 0) (> samp max-gain)) max-gain samp))” to “(defun limit-amp (samp) (if (and (> floor 0) (> samp max-gain)) 1 samp))”. This sort of does more like what I’d expect, though of course if something just barely breaks the noise floor, up it comes. But I barely read Lisp, so I still don’t know how most of the compressor works, and I thought I’d get your reaction to this, and see if you had any other thoughts.

Thanks,
Allen

pdf23ds says:

Yeah, I think what you’re looking for is a “noise gate”. Lots of compressors have them built in, but I don’t have one in mine because it’s not really appropriate for most classical music recordings, which is what I wrote the plugin for. Alas, it seems that most people use it for speech instead. I’m not sure how I’d go about implementing a good noise gate algorithm, because I haven’t ever thought about it. The naive noise gate algorithm is just what your change consists of, and I’m not sure how much you can improve on that. But you might look for another plugin to apply in a separate pass (probably before compression).

The other thing I might do is decrease the compression ratio and attack/falloff speeds a bit. (Normalizing before compressing would help too.) That way the compression isn’t much harsher overall, but noise isn’t boosted as much.

I guess a more general solution would be to generalize the compression ratio parameter into a function with a domain of input dB and range of output dB, which is how SoundForge’s compressor works. It would probably be relatively easy to implement, but Audacity doesn’t offer a good GUI for that, or a way to create one, so you’d have to tweak the file itself every time you changed the function. The function would just replace “adjust-samp”, and look something like this, I guess:

(defun adjust-samp (db)
  (db-to-linear
    (cond
      ((< db -30) 0)
      (t db))))

“cond” is like a switch statement, with “t” being the default clause. The maximum amplitude and noise floor parameters would become superfluous. The sample function there silences everything below -30 dB and applies no change to everything else. But ideally if you graphed the “adjust-samp” function it would be continuous. I don’t think adjust-samp actually works on samples, btw.

Allen McBride says:

Thanks, Chris! This is helpful. I will play with noise gates, and with the adjust-samp function once I learn enough Nyquist to understand what’s going on. So do you think we’re crazy to use your compressor on speech? The conventional compressors may have some advantages, but the thing I like about yours is that it doesn’t miss any spikes. The Audacity compressor misses spikes (like mic hits or cassette tape artifacts) during compression, but then the spikes keep the normalizer from bringing up the volume, so I end up having to remove the spikes by hand. (Click removal doesn’t really seem to work; I’m not sure why.) Also, what do you mean when you say you don’t think adjust-samp works on samples?

Allen

pdf23ds says:

“So do you think we’re crazy to use your compressor on speech?”

Hey, if it works for you that’s great. I’m not surprised it does better than other sorts of compressors for some things. Nyquist comes with a compressor that’s similar to mine, but Audacity’s repackaging of Nyquist doesn’t include it (or a couple of library functions it uses).

“Click removal doesn’t really seem to work”

Well, clicks, pops, and other artifacts may sound similar but methods used to detect them can vary widely. For a microphone hitting something, I usually do a high-pass filter at around 20-50 Hz. It doesn’t get rid of the sound, but it gets rid of the peak in the waveform. For speech, I’d probably do a highpass to the whole thing. For dealing manually with big peaks, it’s pretty easy to use Audacity’s interactive envelope function to scale it way down.

“what do you mean when you say you don’t think adjust-samp works on samples”

The value passed to adjust-samp isn’t an individual sample, but part of the envelope that gets interpolated over the waveform. adjust-samp gets called once for each thousand samples.

Devon says:

Hi,

Very cool to see such a powerful tool for us amateur producers. I work with dance music, often from somewhat degraded MP3s. Any suggested settings for getting a degraded track to sound punchy and full using compression? Thanks.

Henry says:

Thanks for the great tool! We use your dynamic compressor for our PMlessonsLearned.com podcast. We record conference calls and then podcast them as MP3s. Question: We are basically using the compressor to even out the volume of all of our speakers. Since there are many different people on the conference calls using all types of phone equipment, the volume varies all over the map. We just want to correct the volume from all these voices to make them all the same. Can you suggest how to set the compressor settings to make this work the best for our application?

pdf23ds says:

Devon: Sorry, no particular advice.

Henry: If you tell me how you would like it to sound different from the default settings, I might be able to help you.

Henry says:

Our goal is simply to keep the volume even throughout our podcast. Our podcast is a recorded conference call, so we have people calling in that are very loud and others who are very soft and everywhere in between.

We seem to have arrived at some good settings by just using the default settings with one change: we change the first number to .99 - If I interpret your writings correctly, this should allow all areas to be increased in amplification to the full .95 (last setting) very quickly, so we should be able to hear all callers on the conference call at about the same volume.

As far as I can tell, this is true for your “old” plug-in and the “new” one that has more settings.

Changing this one setting seems to cause all of the various “speakers” on our call to be brought to full volume. Which I think is what we want.

I’ve run this on our audio and listened to random spots within and it seems this works well. The only issues are:

1. “quiet” (when nobody is talking) seems to slowly rise in volume. I know that’s what the floor is for, but I don’t think we can get around this because sometimes “quiet” is noisier than some of our callers (you can imagine background noise on someone’s phone who has lots of gain is louder than someone who’s phone has very little gain and is talking). So, I don’t think we can fix this one and it’s not too annoying.

2. Sometimes during “quiet” someone will make a noise we don’t want amplified. For example, I was listening to one piece of the audio where it sounded like someone in the background dropped a bunch of pots and pans in the background. Well, that was amplified too. Again, I don’t see any way to avoid this and it’s not too annoying.

So, I guess my questions are:
1. Did I interpret the first setting correctly: .99 will amplify all parts of the audio all the way up to the value in the last setting (.95) no matter how quiet they are?
2. Do you think changing the ramp up/down values would matter much to get us to full volume quicker? (We’re currently just using the defaults)

Thanks again for this wondrously useful tool!

pdf23ds says:

Henry, your understanding of the compression ratio parameter (the first one) is correct. It is pretty much the same between versions.

The speed at which the quiet parts get louder is determined by the release speed. If you make that a little faster then the noise rising in volume might not be quite so noticable or annoying. The speed and which things get quieter (before loud parts) is the attack. In version 1.0 these were called rise and fall speeds, I forget which were which. Also, the different versions invert the effect of the sliders, I think. In the latest version, I think you want to lower them.

Anyway, the best handling of noise in your case is probably just selecting the quiet parts and using Audacity’s envelope tool to quieten them down manually. That’ll also take care of clumsy callers slipping in their kitchens.

Mauricio Kanada says:

Wonderfull compressor!!! Simply the best!

Can I make a suggestion?

1 - One option to normalize automatically before compression.
2 - Parameters in dB.
3 - A pre-processor to find the parameters that make volume fit in one range of db. Something like ‘minimum volume: 80 db; maximum volume: 96 db;’.

Some time ago, I have read something about K profiles about music compression. You can find more here.

Finally a question. I have my entire music collection that I would like to process it with your compressor. Do you know anything that could do this in batch?

Thanks

Maurício Kanada

pdf23ds says:

Mauricio: I provide above a link to a Windows version of the compressor that is able to process batches of files at a time. (It also has a commandline interface.) Unfortunately, it does not do de/en-coding.

As to your second suggestion, my latest version of the audacity plugin, 1.2.1 (as of two days ago), has ‘floor’ in dB, but the rise and fall parameters don’t relate to dB in any simple way. Noise gate falloff is in dB/s, so I might be able to change it if it’s not already scaled right. So I’m afraid that’s mostly not going to happen.

As to your first and third suggestion, that would require two passes, which would make the plugin much, much slower in Audacity. So I’m not going to do those. If you want to suggest a feature, suggest to the Audacity folks to let you create/save/load chains of effects and maybe even a batch mode. Though it does strike me that there’s not a way to do your third feature with other effects without trial and error.

I might implement the third feature in the windows version, though. Two passes can be handled more efficiently there.

Re you first suggestion, note that you can apply gain by changing the maximum amplitude property. The property isn’t relative to the peak value, but to 0 dB. I believe you can set it > 1. You get clipping if it’s too high, though.

John Fox says:

Chris,

Your ARE a genius. I recorded a telephone interview today and had inadvertently jacked up my microphone volume, hence drowning out my guest. Ugh! I searched high and low to fix the problem …. and then came across your plugin for Audacity. What a godsend.

Many, many sincere thanks!

John Fox, President
Venture Marketing

B2B Marketing Resources for Small Business:
——————————————
http://www.Marketing-Playbook.com The Definitive Guide to B2B Marketing for Small Business

stevethefiddle says:

This really is an awesome compressor. Very nice work.

I usually normalise the audio first using Audacities built in Normalize effect (which is faster than normalising with Nyquist), then the compression settings are more predictable.

This is a 5 star “must have” plug-in for Audacity users.

John Fox says:

I need to reset the compressor back to the default values. Where can I find these settings? Thanks.

pdf23ds says:

Open up the plugin directory, open the compressor.ny file, make a small change, like adding a space, save it, and restart audacity. All your defaults will return.

If you like, you can try to read the parameters. They’re up at the top. I think the first number on the line is the default value.

;control compress-ratio “Compress ratio” real “” .5 -.5 1.25

Koz says:

We’ve been recommending the latest version of your compressor on the Audacity help forums.

I record off-air radio shows and enjoy the station’s compressors which help enormously when I’m listening in the car.

It works less well if I record the streaming version of shows. Those have constant volume variations. Your compressor with the Compression Ratio advanced to 0.77 is almost a dead ringer for the local station’s own processing.

I, too, tried all the existing compression tools and thought they were pretty dreadful. This one is excellent.

Koz

Koz says:

We had an interesting spat with the design of that tool. Did you know that the default is to “normalize” left and right independent of each other? It can seriously damage the stereo image of the show.

I usually normalise the audio first using Audacities built in Normalize effect

Koz

[I think this is what you meant to do --pdf23ds]

pdf23ds says:

I record off-air radio shows and enjoy the station’s compressors which help enormously when I’m listening in the car.

Ha. I knew my classical station had a good compressor.

Koz says:

Actually, I wanted to quote the earlier post and then comment on it. Upside down from the way you patched it for me.

Turns out chicken beak sequences (left, left, left, quoted text, right, right, right) are interpreted as things or actions in this list. Who knew?

I almost didn’t believe them when one of the other Audacity helpers told me about your compressor. It’s so unlikely that a programmer would go through the right-brain exercise of making it sound right instead of just throwing theoretical code modules at it and call it good. It’s not good. Those are usually terrible in execution and then they need post production to make the result useful.

To borrow a Mac phrase, this one ‘just works’.®

Thanks again,

Koz

Allen McBride says:

Wow, looks like your compressor is finally getting the attention it deserves. There’s a new thread over at the Audacity forums (http://audacityteam.org/forum/viewtopic.php?f=16&t=9058) about some crash problems. I mention there that I’ve been meaning to write you to say that it seems like the newest version crashes for me when my selected region starts very near, but not at, the beginning of the track. But that I’ve been putting off writing you, because I want to experiment more and describe the problem more precisely. Also, with really long files, I’ve noticed a teensy decrease in the length of the track after using the plug-in. Roughly, compressing an hour of audio seems to make it about .05 seconds shorter. Obviously not a big deal in itself, but I thought you might be interested.

Koz says:

I found a problem (lower case).

Let’s say somebody hands you the file ‘compress.ny’ cold and didn’t tell you what it was. Trace it back to you or your web site.

I bet you can’t do it either.

Koz

pdf23ds says:

Koz, right there near the top in the latest version, at least, is my name and website. Maybe I left it out of an older version; I forget.

Koz says:

There it is. I see it.

Maybe I don’t know enough about how XML works. I see two different version numbers…??

;nyquist plug-in
;version 1
;type process
;name “Compress &dynamics…”

(setf *gc-flag* nil)

;;Version 1.2

;;Authored by Chris Capel (http://pdf23ds.net)

Koz

Koz says:

Another mini-complaint. These are actual quotes from the Audacity help forum.

============================

—Can you tell me where the link is to download the compressor because I looked all through the link you gave me and could not find it.

—12th paragraph:
“The other is an Audacity plugin, currently at version 1.2.1. To use it, download and install Audacity. Download the plugin source, ”

Right click on the link “plugin source” and choose “Save As”, then save, copy, or move the downloaded file into the Audacity plugin folder.

==========================

Koz

Koz says:

There is another similar problem when we actually use the program.

Select some audio in Audacity or Select All.

Effect > Dynamic Processor > Compressor > Compressor > Dynamic Range Compressor (by Dominic Mazzoni)

Oops. That’s not it.

Effect > Utility

Nope.

Effect > Unsorted > Compress Dynamics > Compress &dynamics

Nowhere in the working window does it mention Chris or the web site, or the identity of the program. Keep in mind that the download file is named “compress.ny” and doesn’t have any identity information until line 26 in the code.

Just reading this back to you.

Koz

pdf23ds says:

I see two different version numbers…

The first one is the version of the plugin interface and can be ignored.

I added an anchor to the page so that you can link to http://pdf23ds.net/software/dynamic-compressor#download

In 1.2.6, or when I download the latest beta, I don’t see the menu structure you’re seeing. Particularly, I don’t see any submenus under Effect—I don’t see the Effect \ Unsorted menu at all. I just have a couple of lines in my menu separating different of items at the toplevel. Is there an option you have to turn on to make the menus more confusing?

Koz says:

No, but I’m not surprised. The 1.3 version of Audacity is going through some pretty stiff revisions and the Effects menu in particular has been schizophrenic. You can tell which rev you’re in by the presentation order of the effects.

I didn’t know this would run in 1.2.6. We’ve been sending people to Audacity 1.3 for this. Remember that the shiny new Mac/Intel people will be running 1.2.5, not 1.2.6. this catches about one person every two or three days.

We’ve been pushing many people over here to help with their compression problems, so anything you can do to make the process easier and more obvious is good.

Like calling it ‘Chris’s Compressor’ instead of ‘Compress &dynamics.’

Koz

pdf23ds says:

Heh. The ampersand in 1.2.6 at least lets you press Alt+E+D to get the compressor. An ampersand shows up as an underline under the following character in Windows. Maybe it’s not portable to have that. Mainly it was for testing anyway.

OK, I’ve tweaked the name some. If you let me know what annotations to use in the .ny file to get it sorted right in the Effects menu, I’ll put those in as well.

Koz says:

I have a little more of that, but it can wait.

I was describing to someone how cool this thing was and I ran into a question. I know you piled up all the tools you normally have to painfully execute one at a time to get the show to sound good. This compressor is one stop shopping.

Do you remove DC? I’m guessing yes because I’ve never had DC problems after I applied your compressor…but I’m guessing.

Koz

Koz says:

You are Officially Popular. Google will hit you even if I spell your name wrong.

[Google] –Do you mean “Chris’s Dynamic Compressor?”

Yes.

I do.

Koz

Sergey says:

Hello,
Is there any way to get the source code for the standalone version of the program.
Thanks,
–Sergey

pdf23ds says:

Sergey, see my e-mail and this post.

Koz, no DC removal is done, unless it’s an accidental effect of the algorithm, which I doubt.

Alan Roberts says:

Hello,

Newbie trying to understand this tool, so I can script creation of my mostly-classical FLAC files into a parallel MP3 tree suitable for in-car iPod use.

I’ve tried the Audacity plug-in, and understand the meaning of “attack” and “release” as described.

Does “attack” in the plug-in correspond with “fall” (time and exponent) on the standalone tools, “release” with “rise”? That seems to be the way the default values line up, but the help text for the command-line version seems to associate “fall” with “release.”

Confused, my usual state,
Alan

pdf23ds says:

Alan,

I don’t really know for sure. Sorry. I can tell you that I don’t have the two very straight in my head, and I don’t think they’re named very well either way, so they could very easily be crossed one way or another. I think the best way to tell is to experiment. The default values are probably the best clue.

Otto says:

Is there any way to make this plug in show up in the list of available commands in chains (for batch processing) in the new Audacity beta? This is a fantastic plug-in, and I am enjoying the music in my car so much. Batch processing would make it easier. Thanks, Chris!

pdf23ds says:

Otto, unfortunately, I have no control over that part of the program. You might repeat your suggestion on the main audacity mailing list, though. I’m sure they’re aware of the shortcoming, but it could help to make the request anyway.

Glad you’re enjoying the plugin.

urbanspaceman says:

The plug in produces the sound I’m looking for, which is fantastic, but I’m having a major problem. If I apply it to files longer than about 3 and a half minutes, the rendered file cuts off at that point. I’m using Audacity 1.2.5 on an Intel Mac. Anyone else encounter this?

Koz says:

Could this be a problem with the look—ahead modules? It’s fairly well known that you need to append silence at the end of the show and then cut it off later to avoid the compressor doing very schizophrenic things to that last bit of the performance.

Anne-Lise says:

Thanks for the quality plug in. I was having so much trouble trying to balance clipping with reasonable volume output. Fantastic!

Tom Lenz says:

Thanks so much for making this available. It’s really good. (Using it for speech where speaker alternately whispers and screams)

Do you have a wish list or some way for those of us who would like to drop a token of our appreciation?

Koz says:

<<>>

There are known issues with Audacity 1.2.5 on an Intel machine running Leopard. There are no fixes. Delete the program and install the latest 1.3.8.

Koz
Audacity Elf

Koz says:

I want to change the default compression from 0.5 to 0.77, but the compression code listings have several numbers.

;control compress-ratio “Compress ratio” real “” .5 -.5 1.25

Change the first number, or am I not even in the right place.
Koz

pdf23ds says:

Koz, the first number is indeed the default. You’re on the right track.

Pete says:

Thanks so much for a fantastic compressor! Just a couple of queries based on things I found when trying it out using default settings with the audacity (ver 1.3.9 beta) plugin.

1. It often lifts the last second/half second of music/vocal to an unnatural level compared to the rest of the piece - so that this end section doesnt appear to match. Is there any reason for this and a setting I could change to prevent this?

2. When applied to a piece 90 seconds long it compressed the first 6 seconds of speech then truncated the file at that point so that 1 min 24 of audio was lost. Is there a reason this might happen and a setting I can change to prevent this?

Look forward to any help you can offer

Thanks again,

pete

Koz says:

I think #2 may be a damaged sound file. I use the compressor all the time and I never had that problem. I don’t remember anybody else posting having that problem, either.

However, that end-of-file thing is pretty common. Look-ahead freaks out when it gets to the end of the file. A common work-around is to put Something at the end of the show so the software has something to chew on.

Koz

Steve says:

First off, congratulations on an awesome compressor.

Unfortunately there does appear to be a bug as Pete described in point 2 of his post (September 22nd, 2009).

I have not found an easy way to reproduce the bug on demand, but I have saved a project that exhibits the problem. It is a 4:35 stereo track, and when applying the dynamic compressor to the entire track it gets truncated at 3min 59.

This is the precise point where an audio clip was previously pasted. The project plays perfectly and there are no unusual effects from any other Nyquist effects.

I can send the .AUP file if it will help to track down the problem. I can’t make the entire project public as it is copyright material, so e-mail me if you need the whole thing.
____________________

Re point 1) from the same post by Pete I usually work around by adding a second of generated tone or noise at amplitude 1.0 to the end of the track (then trimming it off after processing). This workaround is only required if the track ends abruptly. It would perhaps be nice if the plug-in could emulate this by setting an amplitude level of 1 at the end of the track when calculating the gain. (I don’t know if this is possible as I don’t fully understanding the code).

In the case where the track ends with a gradual fade out, the fade out may be boosted too much with the default settings, but increasing the “floor” setting fixes that.

pdf23ds says:

Pete,

I really ought to look into 1. Seems a lot of people have that problem. I should be able to reproduce it pretty easily. (Now that I’m temporarily jobless I should have some time to do this!)

2 is another question. It probably indicates a rare bug in my compressor, something I wouldn’t be able to reproduce. If you want me to fix this, you could send me a .wav or .aup file that exhibits the problem, or you could press the “Debug” button when applying the effect and send me the output. A possible workaround is to apply some other effect to the sound first (like normalize, invert, or equalize), which might avoid triggering the bug.

Koz says:

<<>>

We need to remember that the AUP file is only the project manager. To send anything meaningful, you also have to send the _DATA folder. In addition, you have to have had Audacity set to Copy All Music, or the Project still isn’t going to play when it gets here.

Zip it all into one archive so the transfer process doesn’t rape the files.

Koz

Steve says:

[Pete says:
September 22nd, 2009]
<>

This occurs if there is a long section of complete silence (over about 1 second of sample values at zero).

How to work around this:
If you have a track with a long period of silence in it, process it in sections so as to avoid processing the silence.

Hopefully Chris will be able to fix this in a future version, but I am writing a longer description of the workaround on the Audacity help forum. I’ll post a link here when it’s done if that’s OK.

Steve says:

Oops. The software has stripped out part of the above message. I was referring to the problem with processed tracks sometimes getting truncated.

Steve says:

I think I may have cracked the problem.
Change line 289 from “nil” to “0″.

@ Chris, I’ll e-mail you with more details.

Steve

pdf23ds says:

Steve, that’s a pretty good start, though not exactly right. (The if statement just needs to be removed and replaced by the max statement.) But changing it reveals a couple other problems that I’m still looking into. And I’m still trying to fix the weird behavior at the end of the selection.

Steve says:

I thought it was probably not 100% (a bit of a hack really), but you may notice that it does also improve the weird behaviour at the end.

I’ve sent you an e-mail with a few more details and a link to a tiny Audacity project that reliably reproduces the problem.

Steve

pdf23ds says:

OK there. I just released 1.2.2, which fixes both the problems mentioned in the above comments.

Josep Z says:

Hi Chris!

I’ve been using your wonderful compressor for quite some time now, and it has worked fine except for some cases where songs got truncated at the end.
It was great to read that version 1.2.2 would fix this… Unfortunately, the new version has brought some new problems in; Audacity just crashes when trying to apply the compressor to some songs, which makes it absolutely useless for me at the moment. :(
I don’t know if it happens to someone else, but it is very annoying, because now I don’t know where can I get 1.2.1 back.
Hope this gets fixed soon…

Thanks for your efforts and keep up the good work!

pdf23ds says:

Josep, my apologies for somehow breaking it. (Though I have no clue how.) Here’s 1.2.1.

I’ve reproduced the issue compressing a large-ish track, so I should have it fixed pretty quick.

Josep Z says:

Thanks for the file!

I mean Audacity just disappears after applying the compressor. I just started using the new version today and worked fine with the first song; the second crashed every time. I tried to delete the last 2 seconds of the song, which are absolute silence, but it didn’t work.
No errors or anything; Audacity asks me to recover the previous session when opening again but that’s it.

Just in case you need the info, I am currently running Audacity 1.3.5 in Ubuntu Hardy (8.04). I would use a newer version, but building from source in Hardy is a nightmare. There are built packages at Getdeb.net, but they are pretty buggy, so at the moment I am stuck with 1.3.5.

Again, thanks a lot!

pdf23ds says:

OK, the problem with 1.2.2 was due to a bug in Nyquist. I worked around the bug and released 1.2.3.

Song: Good-night Not Good-bye (2009) « My Right Brain says:

[...] The mixing can be better. So can my vocals. But I tried my best. I’ve uploaded 3 versions, with version 1.3 being the latest (was trying out the Normalisation/ Compression/ Amplify settings in Audacity and some new plugins, like this one). [...]

Ivan Chew says:

Hi Chris, I’m not saying anything that you’ve not heard already but I thought I should leave a comment to thank you for sharing this. I’ve been trying to get hold of a free and decent compression/ expander plug-in. Yours is a real boon. Much appreciated.

Ed says:

Chris,
I tried the plugin with Audacity 1.2.6 on a 6 hour file (voice recordings) and got an application error.

I then tried the standalone application on my XP system with the latest .NET 3.5 and got an “Index was outside the bounds of the array”.

The debug info follows. Any thoughts?

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Compressor.Parabaloid.SolveFor(PointF p1, PointF p2)
at Compressor.Sound.c__DisplayClass23.b__22(Int64 i)
at Compressor.Sound.Evaluate(Int64 sample)
at Compressor.Compressor.c__DisplayClass7.b__6(Int64 i)
at Compressor.Compressor.Compress(Stream fileIn, Stream fileOut, Func`3 status)
at Compressor.Compressor.Compress(Stream fileIn, Stream fileOut, Progress progressForm, String status1)
at Compressor.MainForm.Compress(Progress p)
at Compressor.MainForm.c__DisplayClass28.b__26()

Ed says:

Chris,
I should also reference the details of the problem I’m having with the plugin. The good news is that Koz’s help solved the application error:

http://forum.audacityteam.org/viewtopic.php?f=12&t=14576

Trahcwolf says:

I like the idea behind the program, yet when I click to download the Audacity plugin, there’s a screen of words instead of a download link.
Certainly that’s the program, yet I have no clue how to make a screen full of words become a plugin. Help for idiots like me would be greatly appreciated.

pdf23ds says:

Trachwolf, all that’s necessary is to right-click on the “plugin source” link and select “save target as” and then browse to the directory in the instructions and save it there.

Trahcwolf says:

OK
Got it
Downloaded Audacity 1.3.9, installed this plugin and it shows up
Quite nice graph
Looks great, but I am a technical dunce
Any help files for idiots to use it?

Gabriel says:

This plugin seems like exactly what I need, but I am not having any luck installing it to work with Audacity (1.3.9) on a Mac running 10.5.8. I notice that almost all the plugins in both the “plugin” and “nyquist” directories under Audacity end in .ny or .lsp. Do I need to change the filename when I put it in one of these directories? The plugin downloads as compress.ny.txt for me. Thanks!

pdf23ds says:

Gabriel, yes. Internet Explorer sucks. I will make a note in my post.

saiphai says:

GREAT plug-in! The default compressor in Audacity is very lackluster, making me to go though a long process for each track. Yours is much easier to use, faster, and give me much better results without constant tweaking of the parameters. And you’re completely right about the realtime compressors. Yours works much better on signal spikes cause by percussion. Thanks a bunch!

Twitted by digiSal says:

[...] This post was Twitted by digiSal [...]

Solo says:

Saweet!!!! Great plugin!

Mary says:

This is just what I need! Unfortunately, each time I run the compression, Audacity (1.3 beta) crashes. Any suggestions?
Many thanks,
Mary

Lee says:

This is a great plugin, however, Audacity 1.3 beta tends to crash when running ‘Compress dynamics’ on very long music files (greater than 60 minutes). Is there a fix/update?

Lee says:

This is the terminal generated output; I’m running Ubuntu 9.10 64-bit

ERROR: Could not find sinewave.raw in rawwaves. Something is wrong with the installation or configuration.

; loading “/usr/share/audacity/nyquist/init.lsp”
SETDIR: No such file or directory
Set *default-sf-dir* to “/home/xxx” in fileio.lsp
AutoNorm feature is on.
Default sound file is xxx-temp.wav.
system.lsp : *RUNTIME-PATH* = /usr/share/audacity/nyquist/

Nyquist — A Language for Sound Synthesis and Composition
Copyright (c) 1991,1992,1995,2007-2009 by Roger B. Dannenberg
Version 3.03

Russell Wood says:

I’m slowly converting all my old LPs to digital, using Audacity. My old DGG/Karajan version of Dvorak’s ‘New World’ has HUGE swings in volume. Thanks to your dynamic compressor, it’s now listenable without noise-cancelling headphones! Thanks!

Steve D says:

@Lee
Nyquist (in Audacity) was not fully compatible with Linux 64. This should be fixed in the current 1.3.11 version.

If you are not wanting to build Audacity from source, Daily builds for Ubuntu are available here: https://launchpad.net/~audacity-team/+archive/daily

Also, Audacity currently keeps the sound file in memory while processing, so processing very large files can exhaust the computers available RAM.

Leave a Reply

To include an em dash, use three hypens with no surrounding spaces, or two with surrounding spaces.