Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Audio compression

2 views
Skip to first unread message

shay walters

unread,
Aug 11, 2024, 9:27:55 AM8/11/24
to uc...@googlegroups.com
I'm looking for something that does audio compression in the old
analog audio sense. ie: reduces volume of loud passages and increases
volume of low passages. I've run across things like rgain and m3gain
which will take a group of mp3 files and adjust the volume so that all
files are of similar volume, but I'm looking for something that will
take a single file and normalize volume within that file. The
specific problem I'm working on is interview audio that has some
parties in the interview much louder than other people.
I've searched for audio compression but all I seem to turn up is
info on compressing the size of mp3 files, not the actual audio
compression.
I figured it was worth asking about here in case anyone had
previous experience with this sort of problem.

Thanks,
-Shay

Arnold Silvernail

unread,
Aug 11, 2024, 9:50:51 AM8/11/24
to uc...@googlegroups.com
I'm not sure if Audacity will do what you want or not:


--
You received this message because you are subscribed to the Google Groups "Upstate Carolina Linux Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uclug+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uclug/CAKdjT5JRQTPpvYLnMGQKwdRpO2LXAqMZkS7MD0PHke9bwuDd7g%40mail.gmail.com.

Brian Kennedy

unread,
Aug 11, 2024, 9:57:07 AM8/11/24
to uc...@googlegroups.com
Is installed on my machine, so is likely what I used when processing some old studio tapes for my wife.  Normalized music and conversations to good levels.   But... I had to put those through a lot of processing to clean up 70's tape noise, so normalize may not get all the credit.

Logo

Description automatically generated

Brian Kennedy

Sr Platform Engineer

 

O: 864.342.5917



From: shay walters
Sent: Sunday, August 11, 2024 9:27 AM
To: uc...@googlegroups.com
Subject: [UCLUG] Audio compression

Glen Peterson

unread,
Aug 11, 2024, 10:35:38 AM8/11/24
to Upstate Carolina Linux Users Group
How long is the audio and is it practical to adjust the volume of different sections individually?  I use Audacity 3.6.1 installed as a Flatpak:
  • Select section (or entire file)
  • Effect: Volume and Compression: Amplify
  • By default, it will pick an amplification that brings the highest peak up to maximum volume.
  • Click Apply
First I do this on the whole file.

EDIT
The new Compressor plugin allows a lookahead and an "attack" value of zero.  It has a nice input/output graph showing how much you're attenuating the peaks and how sharply that attenuation falls off.  That should be able to clear up your file very quickly.  If the resulting max peak isn't at 1.0, just "amplify" the whole file as explained above.  It still sounds a little squashed, which is why I included my manual techniques below.
END EDIT

Proper mic placement in the room can minimize or eliminate the need for this, but that doesn't help you after the fact.

END OF MESSAGE

I WROTE THIS OUT OF IGNORANCE BUT IT STILL MIGHT BE USEFUL
You can also highlight the softer sections individually and repeat the above instructions.

If there are short sections that are too loud, you can highlight those and select a negative Amplification value to bring it down to the level of the surrounding audio.  Once everything is normalized to the same quiet volume, you can boost the whole file as above.

Sometimes there are pops, or some other sound that causes a very short spike and prevents you from amplifying the surrounding audio.  You can resize the track vertically to make these easier to see.  If it's literally a few samples, I sometimes zoom in until I can see the individual samples, then use the draw tool to just redraw them smaller.  You just need to get them below the height of the "good" sound peaks, then you can boost the whole file as above.  This works particularly well for a 20 minute classical piece with a single cymbal crash, or when there are a few pops from someone touching the microphone by accident.

SOMEWHAT OBSOLETE: The compression plugins I've found do exactly what the "old fashioned" compression used to do, which was designed for real-time compression.  It allows a short spike through, then reduces the subsequent volume for some number of seconds, gradually increasing the volume if there are no more spikes.  This results in a sort of audible sort of "whomp" effect which really bothers me, and still leaves the spikes at their maximum volume.

At one point, I tried to write a plugin that would compress differently.  Maybe there's a name for this and someone has already done it?  I basically want to input a percentage, like 95%.  Then the plugin orders the volume of every sample and figures out the volume that only 5% of the file exceeds.  Then it finds each peak that exceeds that threshold, highlights from the nearest zero before and after that peak, and uses the Amplify plugin as above on that section to bring it down to the level of the rest of the file.  Unfortunately, Audacity uses an older lisp (elisp?) for its plugins and my skills weren't up to the task.  I didn't really know how to debug my work and I didn't try that long before giving up.

There are other tools under Effect: Volume and Compression.  I don't know what they all do.  

Lamar Owen

unread,
Aug 11, 2024, 12:45:47 PM8/11/24
to uc...@googlegroups.com


On Sun, Aug 11, 2024, 09:27 shay walters <shayw...@gmail.com> wrote:
    I'm looking for something that does audio compression in the old
analog audio sense.  ie: reduces volume of loud passages and increases
volume of low passages.   I've run across things like rgain and m3gain
which will take a group of mp3 files and adjust the volume so that all
files are of similar volume, but I'm looking for something that will
take a single file and normalize volume within that file.   The
specific problem I'm working on is interview audio that has some
parties in the interview much louder than other people.

So, there are several ways to deal with this.  I have been a professional Harrison Mixbus user since 2009, and I would use that since I'm used to its workflow and I have a license.  Ardour is the FOSS base from which Mixbus is built, and is a full featured Digital Audio Workstation, and is available in most distributions.  Both of these will let you listen and adjust, and even record the adjustments, live as you're listening to the audio.

Audacity has a normalize, but it doesn't do compression in the sense you're looking for. It also doesn't let you listen to the results of your settings in real time like Ardour or Mixbus does. An emulation of the old LA-2 levelling amplifier would of likely be just the ticket.

From the command line, the lv2proc tool will allow application of any LV2 plugin to the audio in a batch oriented manner.  https://sourceforge.net/projects/naspro/ for the source.  The lv2proc tool is available in multiple distributions and repos.  You then need to select an LV2 compressor; there's a pretty comprehensive list of LV2 plugins at  https://wiki.linuxaudio.org/apps/categories/lv2_plugins

These same LV2 plugins can be used in Ardour/Mixbus; test settings there, and when you're happy with the results apply those settings with that plugin in batch mode with lv2proc.
      

shay walters

unread,
Aug 11, 2024, 3:32:02 PM8/11/24
to uc...@googlegroups.com
Thanks everyone for the suggestions. I'll look into them. They sound
promising. I was looking for something that would run without manual
intervention since one file may have hundreds of transitions from one
speaker to another. (Podcasts of a panel of people.)

Thanks again,
-Shay
> --
> You received this message because you are subscribed to the Google Groups "Upstate Carolina Linux Users Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to uclug+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/uclug/CAG7qr_qM6B3tZamkWgOvefw3cvOhwGowe4zu0n6QnvC0uvw2uA%40mail.gmail.com.

Lamar Owen

unread,
Aug 11, 2024, 4:11:12 PM8/11/24
to uc...@googlegroups.com


On Sun, Aug 11, 2024, 15:32 shay walters <shayw...@gmail.com> wrote:
Thanks everyone for the suggestions.  I'll look into them.  They sound
promising.  I was looking for something that would run without manual
intervention since one file may have hundreds of transitions from one
speaker to another.  (Podcasts of a panel of people.)

My workflow using Mixbus would be to load a file into a track, then work on the channel compressor settings to level it out while playing through a few transitions, then once I'm happy with those export the track and spot check.   It actually would take longer to explain the process than to do it especially with Mixbus and its channel compressor. Set the compressor type to level, activate look ahead, set the gain and threshold to equalize the loudest segment with the softest, and then let it run.  Dialog processing like this is my bread and butter in Mixbus; been doing it for nearly thirty years using one tool or another; Mixbus is the best I've tried.

I don't know of a fully automated tool, though.  It's somewhat of a harder process than it first appears to be, since you have to balance the compressor attack and release to prevent 'pumping' and 'breathing' of the audio.  Pauses in loud sections, for instance, are difficult to distinguish from quiet dialog sections, so you have to set the compressor appropriately.  The more extreme the difference in loudness the more difficult; the more rapid-fire the transitions the more difficult.

Multichannel compression is the standard for broadcast audio processing boxes, and those can get very sophisticated.  LV2 plugins are available for that as well.

If I were to write a fully automated tool for dialog leveling, I would have it split the audio at each major loudness change (programmable time size), average normalize to -18dBFS across all clips, remerge the clips, then run through a programmable leveler to set peak to -0.1dBFS (-0.1 instead of 0, since the output can overshoot 0dBFS between samples, and some audio DACs get upset when that happens, causing audible clipping).  Even then the different clips will sound like they're at a different level from each other, because our hearing is not linear across the audible frequency range.

Welcome to the funky world of digital audio processing!

Robert Meier

unread,
Aug 13, 2024, 10:16:27 AM8/13/24
to uc...@googlegroups.com, Lamar Owen
On 8/11/24 9:27 AM, Shay Walters wrote:
> I've searched for audio compression but all I seem to turn up is
> info on compressing the size of mp3 files, not the actual audio
> compression.

I think what you are searching for is
"automatic volume control" or
"automatic level control"
not --compression-- .

I haven't done sound editting in over 6 years, but I used to use sox[1],
octave[2], and xwave[3]. I believe both are currently available for
linux, Mac, Android, and Windows.

Unfortunately, since automatic volume control is nonlinear,
there is no parameterless description.
sox(1) effect "gain" uses one explicit parameter "dB-gain",
and -r, -h, and -n use unspecified defaults.
octave(1) supports non-linear processing, and
has convenient audio processing functions.
xwave(1) supports splitting and joining audio files with gui.
See the respective manuals for further details.

You will need to trade off your time and effort
versus final quality.
Depending on circumstances, my approach was to
A. If speakers didn't overlap,
1. split the file(s) with xwave into sections by speaker
2. adjust volume for each section
3. concatenate adjusted sections.
B. If speakers not worth separating
1. generate loudness stream using octave abs, log, and filter
2. convolve original with loudness for result
3. repeat with different parameters and pick the best result

[1] SOund eXchange
https://linux.die.net/man/1/sox
https://sourceforge.net/projects/sox

[2] octave
https://octave.org/
https://docs.octave.org/v4.2.2/Audio-Processing.html#Audio-Processing

[3] xwave
https://www.freshports.org/audio/xwave/

Hopefully helpful,

Lamar Owen

unread,
Aug 13, 2024, 10:58:48 AM8/13/24
to Robert Meier, uc...@googlegroups.com


On Tue, Aug 13, 2024, 10:16 Robert Meier <eaglecoa...@gmail.com> wrote:
On 8/11/24 9:27 AM, Shay Walters wrote:
 > I've searched for audio compression but all I seem to turn up is
 > info on compressing the size of mp3 files, not the actual audio
 > compression.

I think what you are searching for is
   "automatic volume control" or
   "automatic level control"
not --compression-- .

The Harrison Mixbus channel compressor does all three compressor modes: limiter, compressor, leveler.  The only difference between the three is the hardness of the 'knee' in the transfer function.  The Harrison leveler is really close to an LA-2 levelling amplifier in sound.

The best LV2 leveler I've used on Linux is the OverTone DSP FC70, which is an emulation of the Fairchild 670.
Reply all
Reply to author
Forward
0 new messages