Help - Search - Members - Calendar
Full Version: Can clipping be avoided by selective volume changes?
Hydrogenaudio Forums > Hydrogenaudio Forum > General Audio
ASalazar
I've been using mp3Gain on Ubuntu Linux to normalize my music collection.

I'm mostly happy with the result, but there are certain songs that tick me off. For example, songs with low volume except for a few peaks, like classic music. These songs don't get normalized because mp3gain detects they could be louder but refuses to do it in order to avoid clipping.

This made me wonder if some kind of selective volume change could be made, for example, increasing the overall volume of the song, but lowering it on the peaks instead of clipping.

Is there actually any tool that does this?
Mike Giacomelli
Yes, its called dynamic compression. Most audio has this done during the mixing process, classical being the main exception. Theres plenty of tools that can do it.
Junon
While running Kubuntu I use aacgain to apply ReplayGain to both MP3 and AAC files. It should support the same switches as mp3gain does, hence the -c command worked in your case as well. It causes the scanner to ignore any clipping and apply the gain. Note that slight clipping doesn't implicitly have to be audible in practice, mp3gain's detection judges from clipping that occurs in theory.

Though I mostly listen to Hard Rock and Metal, I also have quite a nice bunch of orchestral music in my collection (Classical, Impressionism, orchestrated soundtracks). To my ears, despite its dynamics, the quality of the latter doesn't audibly suffer from applying the gain, and I even go for a ReplayGain value of 92 dB instead of the reference 89 dB one. My command line usually looks like this:

aacgain -a -c -d 3.0 *.mp3

P.S.: Just checked the mp3gain switches, they're indeed identical to the aacgain ones.
greynol
QUOTE(Junon @ Aug 8 2007, 16:15) *
Note that slight clipping doesn't implicitly have to be audible in practice, mp3gain's detection judges from clipping that occurs in theory.
No, not "in theory", the clipping is certainly real; just not necessarily audible.

QUOTE(Junon @ Aug 8 2007, 16:15) *
...I even go for a ReplayGain value of 92 dB instead of the reference 89 dB one.
I do also. smile.gif
ASalazar
QUOTE(Mike Giacomelli @ Aug 8 2007, 17:01) *

Yes, its called dynamic compression. Most audio has this done during the mixing process, classical being the main exception. Theres plenty of tools that can do it.


¿Care to mention one? I'm really new to this normalization thing

QUOTE(Junon @ Aug 8 2007, 17:15) *

While running Kubuntu I use aacgain to apply ReplayGain to both MP3 and AAC files. It should support the same switches as mp3gain does, hence the -c command worked in your case as well. It causes the scanner to ignore any clipping and apply the gain. Note that slight clipping doesn't implicitly have to be audible in practice, mp3gain's detection judges from clipping that occurs in theory.

Though I mostly listen to Hard Rock and Metal, I also have quite a nice bunch of orchestral music in my collection (Classical, Impressionism, orchestrated soundtracks). To my ears, despite its dynamics, the quality of the latter doesn't audibly suffer from applying the gain, and I even go for a ReplayGain value of 92 dB instead of the reference 89 dB one. My command line usually looks like this:

aacgain -a -c -d 3.0 *.mp3

P.S.: Just checked the mp3gain switches, they're indeed identical to the aacgain ones.


I'd prefer to avoid clipping, even if not audible. Some of my tracks would get way too much clipping to get the faint parts loud enough.
Dynamic
Option 1 is to simply use AACgain without clipping prevention. You probably wouldn't notice most of the time unless you push it too far above 89 dB target volume.

Option 2 is to pre-process with a DSP dynamics compressor prior to encoding to AAC. Foobar2000's vlevel plugin is a subtle but safe approach. There are also more traditional dynamics compressor plugins for Foobar 2000 that can be configured for both fast and slow response. These would tend to interfere more with the sound quality and might be prone to noise-pumping and other side effects. FB2K's right-click/Convert menu allows DSPs and Replaygain to be enabled during conversion to AAC.
AndyH-ha
For the circumstances you describe, I find hard limiting to be much easier and more satisfactory. Limiting some relatively few peaks by 3 to 6 dB (maybe more, I haven’t had need to try that), with no boost in the general level, is almost certain to be transparent. Correct compression is very dependent on the particular music, hard to get right without a lot of experience, and will change the overall sound and impact. Hard limiting this way is point and shoot, and nothing but the benefit is likely to be obvious.
slks
I'm not familiar with mp3gain, but simple ReplayGain tags (as foobar does them) contain peak values. Players can use this data to avoid clipping, if configured properly. "Apply gain and prevent clipping according to peak", as they say in foobar.

I'm not sure if this applies to mp3gain or not.
hushypushy
QUOTE(greynol @ Aug 8 2007, 16:26) *
QUOTE(Junon @ Aug 8 2007, 16:15) *
...I even go for a ReplayGain value of 92 dB instead of the reference 89 dB one.
I do also. smile.gif


What sort of music do you listen to? I listen to mainly modern music, so 95% of what I listen to ends up with a negative ReplayGain value...but there are a few things I have (i.e. classical, C2B3live.com, some MFSL) that are so quiet even at 89dB that I'll get clipping because the RG values are so high (like +3 or +4, or more). Some of them I had to put to 0dB adjustment just so they don't clip ("apply gain and prevent clipping" didn't work for me), maybe I should lower mine to 85dB crying.gif
Hollow
Compression is very song dependent; it'll take a lot of work to apply it to lots of differing tracks. If you're determined to try you can use any digital audio workstation like Cubase; or use Audacity which is a free download.

A limiter sounds more like what you're after, but this can make music very harsh sounding if applied too much, it depends if you're not looking for top quality audio after you've increased the volume.

Compression in the past was applied carefully, but these days producers push for greater and greater compression to make tunes sound louder and louder over the radio. A lot of people regard this as inferior to music in the past, since the difference from loud to quiet is reduced and sounds less and less "live".

You are actually destroying the dynamics of a song when you apply compression and it can make music sound very samey; if you want to listen to the music as the musician intended you'd be best to stay away from compressing.
greynol
QUOTE(hushypushy @ Aug 9 2007, 03:07) *
QUOTE(greynol @ Aug 8 2007, 16:26) *
QUOTE(Junon @ Aug 8 2007, 16:15) *
...I even go for a ReplayGain value of 92 dB instead of the reference 89 dB one.
I do also. smile.gif

What sort of music do you listen to? I listen to mainly modern music, so 95% of what I listen to ends up with a negative ReplayGain value...but there are a few things I have (i.e. classical, C2B3live.com, some MFSL) that are so quiet even at 89dB that I'll get clipping because the RG values are so high (like +3 or +4, or more).

Rock for the most part. I use the same principle with clipping as I do with any other artifacts: I aim for transparency. If I can't tell the difference in a blind test then clipping doesn't matter. Too many people seem to get hung up on things they cannot hear. If you can actually hear clipping which might easily be the case with music that is highly dynamic by composition, then that's a different story.
plnelson
QUOTE(Hollow @ Aug 9 2007, 08:52) *

Compression in the past was applied carefully, but these days producers push for greater and greater compression to make tunes sound louder and louder over the radio. A lot of people regard this as inferior to music in the past, since the difference from loud to quiet is reduced and sounds less and less "live".

Actually music for the radio (assuming you mean FM radio) is REQUIRED to be severely compressed. because the FCC requires commercial broadcasters to maintain a frequency deviation of no more than +/- 75KHz, and the only way you can do this is by compressing the audio down to 40-50 dB dynamic range. (anyone who doesn't quite follow this should reflect for a moment on how Frequency Modulation works)

This is actually a good thing because nowadays people tend to listen to FM radio a lot in their cars, which have a high noise floor so you need compression to hear anything. CD's and MP3's, especially in classical and jazz, are unlistenable in cars without using dynamic range compression. On my iPod I have a playlist called "Driving Music" which consists of songs with narrow enough dynamic range to hear in a car.

I would love to have an analog compander (set to compress) that I could insert between my iPod and my car stereo so I could listen to all my music in my car. I have a perefectly good rack-mount dBX unit at home but it's too big for a car. I have NEVER understood why car stereos that play CD's or other wide dynamic range sources don't all come standard with dynamic range compression built in!

Dynamic
QUOTE
I have NEVER understood why car stereos that play CD's or other wide dynamic range sources don't all come standard with dynamic range compression built in!


I quite agree, especially when DSP effects are getting so common. Even some kind of approximated equal-loudness contour is available on many, so the bass in particular is boosted as you turn down the volume to give a similar perceived tonal balance regardless of the volume knob, yet still no DRC.
2Bdecided
I've been wondering for a while if mp3gain (and other tools) could be modified to drop the gain on blocks that would clip at the setting the user has specified. You could get clever and drop a simple psychoacoustic or distortion analysis model in there to only reduce the gain to the point where the clipping became inaudible, rather than non existant.

The blocks in compressed audio get cross-faded by design, so you're not going to get clicks by riding the gain, but it won't sound as professional as real DRC because you won't have the level of control (time-wise or amplitude-wise). If you push it too far, it will sound awful, but it might help some people.


QUOTE(plnelson @ Aug 9 2007, 18:35) *

Actually music for the radio (assuming you mean FM radio) is REQUIRED to be severely compressed. because the FCC requires commercial broadcasters to maintain a frequency deviation of no more than +/- 75KHz, and the only way you can do this is by compressing the audio down to 40-50 dB dynamic range. (anyone who doesn't quite follow this should reflect for a moment on how Frequency Modulation works)


That's not true. Just because every FM station in the USA is compressed within 0.0001dB of the max doesn't mean it has to be that way!

FM broadcasting existed perfectly happily (given good reception) before Optimod!

Some stations (e.g. BBC Radio 3 in the UK) still use little or no DRC, though sadly even Radio 3 has been increasingly using DRC (especially during daytime broadcasts) in the last few years. The argument is that the full dynamic range version is now available via digital radio. DAB (which has little else to commend it) has switchable DRC metadata sent with the DRC-free audio, allowing the listener to enable or disable DRC, though only a few stations use this. Most just Optimod the audio and send no DRC metadata, since the DAB DRC metadata is broadband gain only, whereas Optimod can be multiband for a punchier+louder sound.


QUOTE
This is actually a good thing because nowadays people tend to listen to FM radio a lot in their cars, which have a high noise floor so you need compression to hear anything. CD's and MP3's, especially in classical and jazz, are unlistenable in cars without using dynamic range compression. On my iPod I have a playlist called "Driving Music" which consists of songs with narrow enough dynamic range to hear in a car.

I would love to have an analog compander (set to compress) that I could insert between my iPod and my car stereo so I could listen to all my music in my car. I have a perefectly good rack-mount dBX unit at home but it's too big for a car. I have NEVER understood why car stereos that play CD's or other wide dynamic range sources don't all come standard with dynamic range compression built in!


I think the music industry is "solving" this problem by making CDs with little dynamic range. However, it is surprising that this feature didn't exist in car stereo in the early 1990s.

Of course now, with your iPod, the solution is simple - apply DRC then encode to mp3. Problem solved. Keep two libraries if you want.

Cheers,
David.
AndyH-ha
Before digital, I remember car radios with AVC. Seemed to be aimed at the same thing.
plnelson
QUOTE
That's not true. Just because every FM station in the USA is compressed within 0.0001dB of the max doesn't mean it has to be that way!

How could it be otherwise and still stay within the deviation limits? Your alternative would be to force all FM receivers to have to use vastly tighter frequency tolerances in order to detect tiny deviations that represented low (audio) signal content and this would dramatically increase the cost of FM radios.

QUOTE
FM broadcasting existed perfectly happily (given good reception) before Optimod!

FM radio has always had this problem - it'sjust more severe with wide-dymamic-range sources like CD's.

What's the deviation limit in the UK?

QUOTE
QUOTE
I have NEVER understood why car stereos that play CD's or other wide dynamic range sources don't all come standard with dynamic range compression built in!

I think the music industry is "solving" this problem by making CDs with little dynamic range.

What makes you think this? I haven't noticed this. Pop/rock/dance/, etc, music has never had much dynamic range because they like to punch it up to make it loud. Classical and jazz (real jazz, not "smooth jazz") has always tended to have wide dynamic range and recent CD's I've bought were no different.

QUOTE
Of course now, with your iPod, the solution is simple - apply DRC then encode to mp3. Problem solved. Keep two libraries if you want.
Too much work to keep two libraries - I have about 8000 tracks - and then I'd also have to keep two iPods - one for my car and one for everyplace else. So, no, the correct solution is inline or realtime compression.


QUOTE(AndyH-ha @ Aug 10 2007, 07:52) *

Before digital, I remember car radios with AVC. Seemed to be aimed at the same thing.
I don't remember this in the US. Are you sure you're not thinking of AGC on AM radios? Almost all AM radios used to have AGC (and probably still do).
ASalazar
Everyone listens to music in their own way. I listen to it 90% of the time in the car, therefore I think DRC will suit me perfectly.

I have a simple script to normalize a whole directory recursively with mp3gain. Maybe I could make another to fine-tune a single song with DRC. Seems like an interesting weekend project.

Thank you all who responded, you've been very helpful.
2Bdecided
QUOTE(plnelson @ Aug 10 2007, 18:31) *

QUOTE
That's not true. Just because every FM station in the USA is compressed within 0.0001dB of the max doesn't mean it has to be that way!

How could it be otherwise and still stay within the deviation limits?

The person playing the CD watches the meters and adjusts the fader to keep levels within the range required. To guard against incompetent people, there's a peak limiter on the output!
QUOTE
Your alternative would be to force all FM receivers to have to use vastly tighter frequency tolerances in order to detect tiny deviations that represented low (audio) signal content and this would dramatically increase the cost of FM radios.

What are you talking about? Does you radio not cope with silence?! That's no deviation!

QUOTE

QUOTE
FM broadcasting existed perfectly happily (given good reception) before Optimod!

FM radio has always had this problem - it'sjust more severe with wide-dymamic-range sources like CD's.

What's the deviation limit in the UK?

I don't know - it's probably the same or similar.

Cheers,
David.
Dynamic
QUOTE(2Bdecided @ Aug 10 2007, 10:39) *

I've been wondering for a while if mp3gain (and other tools) could be modified to drop the gain on blocks that would clip at the setting the user has specified. You could get clever and drop a simple psychoacoustic or distortion analysis model in there to only reduce the gain to the point where the clipping became inaudible, rather than non existant.

The blocks in compressed audio get cross-faded by design, so you're not going to get clicks by riding the gain, but it won't sound as professional as real DRC because you won't have the level of control (time-wise or amplitude-wise). If you push it too far, it will sound awful, but it might help some people.


Nice idea. I've had similar but different thoughts to make use of the loudness and peak information calculated during Replaygain analysis.

I think there could be two options.

Clip-Limiter As you said, clip prevention by frame-wise gain reduction where it's expected to be audible. This could certainly be done if the RG analysis is done on encoder frame intervals, rather than the 50ms of the original ReplayGain proposal.

To some extent look-ahead could be used so that in the worst cases the gain before and after the clipping frame could be scaled back gradually, if this is thought to be beneficial (though I doubt it - the gain pumping is probably least objectionable when confined close to the moment of the transient).

This could be used as a peak limiter for people whose equipment makes them search for target loudness over 89 dB SPL, to limit audible clipping distortion.

Dynamic Range Compression
A second option of what to do with this technique is for some gentle dynamic range compression, e.g. for listening to highly dynamic music in a fairly noisy environment, whilst retaining the punch and impact of transients, just pulling the quieter passages up to an audible level but still a good deal quieter than the loud passages. It would apply equally for night-time quiet listening to avoid disturbing other people.

I like the idea of being able to apply each of these using the global gain value like mp3gain and aacgain or fb2k when applying gain directly to the MP3. Ideally, you could use a normal copy on your PC then when exporting to your DAP or a CD-RW or flash memory for the car, you could apply the appropriate adjustment profile to the MP3 or AAC files on the fly with no re-encoding effort or re-analysis of the decoded data.

To facilitate this, you'd simply could store a frame-by-frame loudness and peak-sample value in a metafile. A text file such as comma-separated values (CSV format), while inefficient compared to a binary encoding, would do just fine, or possibly something based around mp3DirectCut's .mpd Project files. If you have a model that determines where clipping is imperceptible you could store this maximum transparent gain (e.g. +4 would be +6.021 dB (=3 steps of 1.505 dB) in the same manner as mp3gain's format for Undo tags works. You could also store an Undo field to make it reversible, but this would have to apply to the whole file.

If you had frame-by-frame loudness stored to around 0.1 dB accuracy, for example, you could rapidly calculate Album Gain from tracks with Track Gain info stored in this way, or recalculate Album Gain for a double-album that was treated as two separate albums because of (CD1) etc in the Album Title tag. All you have to do is amalgamate the lists of loudness values then sort them and find the 95th percentile, which is the Album's perceived loudness.

The alternative to frame-by-frame storage of such info is not to retain all the loudness values, but simply specify ranges where there is no change, then frames where there is a change and what change is required.
For the dynamic compression option, you'd simply specify which passages require additional gain, and how much, and perhaps specify any fades in much the same manner as mp3DirectCut MPD files.

MPD files also allow multiple files to be joined and pieces to be cut out and rearranged. While this is powerful, it's of limited use for normal stuff, though the most powerful solution would be to incorporate full ReplayGain scanning into mp3DirectCut.


Combined approach
People seeking >89 dB targets because of limited equipment and listening in noisy environments would probably want an extra boost to quiet passages AND an overall gain requiring peak limiting to make it about as loud as possible without too much distortion and with a bit of long-term dynamic variation but not so much that it becomes inaudible behind the background noise.

hushypushy
QUOTE(greynol @ Aug 9 2007, 10:24) *
If you can actually hear clipping which might easily be the case with music that is highly dynamic by composition, then that's a different story.


Yes, that's exactly the problem, unfortunately.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.