Page 2 of 5

Re: adjudting sound levels for all .wav files

Posted: Thu Oct 09, 2014 12:22 am
by Gunnar
steve wrote:Your application will make loud parts of a track quieter and quiet parts louder. The original question was to make tracks of equal loudness - he did not ask to reduce the dynamic range of his tracks
Well, it will make "quiet" parts of the track louder, but it will not (by default) make "loud" parts quieter. Or, more precisely, the "quieter" a part is, the more gain it will get; the "louder" a part is, the less gain it will get. Parts that already have "full" volume will be left as-is. In the end, this means that all parts will have roughly (i.e. as much as possible without applying a psycho-acoustic model) the same volume, which should be pretty close to what has been asked for.

In contrast, with a "traditional" normalization filter it can happen that a single extraordinary peak prevents the entire track from being amplified adequately - which means this track will end up being much quieter than other tracks.
steve wrote:I've read your description of the effect, and tried it for myself, and it does reduce the dynamics. That's fine because that is what you have designed it to do, but it is not what the OP asked for.
If you look at the whole track, then yes, equalizing the volume of "quiet" and "loud" parts is definitely a kind of dynamic reduction. But it's not like a "standard" dynamic range compression filter, where peaks above a certain fixed threshold are cut-off (reduced by a fixed ratio). Instead, each part of the track will get as much gain as possible without clipping. If a certain part already has peaks at 0 dBFS, it won't be modified at all. Peaks are never cut off.

(Or in other words: Within each local neighborhood, the full dynamic range will be retained. If we look at the entire file, that's not the case, yes)

Re: adjudting sound levels for all .wav files

Posted: Thu Oct 09, 2014 2:32 am
by steve
Gunnar wrote:Well, it will make "quiet" parts of the track louder,
Which is not what was asked for.

In some types of music (particularly classical music), there can be sections that are, and should be, much louder or quieter than other sections. Your effect reduces that range, and by default it reduces that range very substantially. I'm not saying that is a bad thing - it is a very good thing if that's what the user wants. Reducing the range between loud parts and quiet parts is exactly what a dynamic range compressor does.

You are also assuming, or at least suggesting, that peak level equates directly to perceived loudness. It doesn't. Compare the sound of a click track with a peak amplitude of 0.8 with a 1000 Hz square wave of the same peak amplitude - the square wave sounds much louder than the click track. The same can be found with music. A commercial drum and bass track will sound much louder than an acoustic guitar track that has the same peak level.

Replay Gain is an algorithm that estimates "perceived loudness". The algorithm is used in both MP3Gain and WaveGain to make audio files play with approximately the same loudness. It does so without changing the dynamics - the calculated gain is applied to the entire track (if used in "track" mode) or to the entire album (if used in "album" mode).

To quote the original poster:
Is there a way to make all my .wav and .mp3 files play at the same level?
My interpretation of that question is that he want to make audio files play with approximately the same loudness.

I'm not averse to you promoting your effect. All of us that write effects like to see them used. However, to recommend your effect every time someone asks about normalization or Replay Gain is misleading.

By the way, I also tried your VST version in Audacity 2.0.6 on Windows XP but it did not show up in the Effect menu. Is it not compatible with XP?

Re: adjudting sound levels for all .wav files

Posted: Thu Oct 09, 2014 6:11 am
by Gale Andrews
It seems that you could approximate "standard", "throughout-the-track" normalization by reducing the "Maximum Gain Factor".

When you say that 100% of dynamic range is retained within each section, how long are these sections? Is it the same as a "frame" which you say is typically half a second?

Another question. The GUI of your plug-in as seen in your docs does not appear in Audacity - you only get the text interface in Audacity even if Graphical Mode is enabled.


Gale

Re: adjudting sound levels for all .wav files

Posted: Thu Oct 09, 2014 9:14 am
by Robert J. H.
Gale Andrews wrote:It seems that you could approximate "standard", "throughout-the-track" normalization by reducing the "Maximum Gain Factor".

When you say that 100% of dynamic range is retained within each section, how long are these sections? Is it the same as a "frame" which you say is typically half a second?
It is rather more since 31 frames are gathered as "neighbourhood". However, the whole curve is Gauss-weighted and depends therefore from Sigma.

Although this smoothing is applied, the plug-in seems to have a steppy response.
I can't test it right now but a former test was roughly like this:
- A tone with fade-in applied (20 seconds or so) and a neighbourhood of about 7 frames for the plug-in.
- Compare it to Chris' Compressor with about 0.1 Hardness.

Re: adjudting sound levels for all .wav files

Posted: Fri Oct 10, 2014 6:01 pm
by Gunnar
Gale Andrews wrote:When you say that 100% of dynamic range is retained within each section, how long are these sections? Is it the same as a "frame" which you say is typically half a second?
Yes and no. The smallest "unit" for which the peak value is determined and the maximum possible gain factor is computed is a "frame" (typically 500 milliseconds). You can think of it like this: Cut the input audio into separate frames, apply "traditional" normalization individually on each frame and finally join together the normalized frames again.

However, simply applying the maximum possible gain factor to each frame individually could result in very unsteady gain factor "jumps" between neighboring frames, which sounds bad. That's why a Gaussian smoothing kernel is applied in order to ensure a smooth and steady adaption of the gain factors. The size of the smoothing kernel is expressed in frames. The default is 31, so it will consider the 15 preceding and the 15 subsequent frames around the current one. The "sigma" for the Gaussian filter is computed automatically, based on the selected kernel size. The exact formula used is 1/3 + (((filterSize / 2) - 1) / 3), which is based on the so-called "3-sigma rule".
Gale Andrews wrote:Another question. The GUI of your plug-in as seen in your docs does not appear in Audacity - you only get the text interface in Audacity even if Graphical Mode is enabled.
VST only allows the plug-in to specify the number of parameters. Also, for each parameter we can define a name (max. 8 characters). But that's it! The range of each parameter is always 0.0 to 1.0 and it needs to be mapped to something useful inside the plug-in. How the parameters are presented graphically to user totally depends on the individual application! The screenshots in the manual were made in Acoustica. The graphical interface shown by Audacity is a bit more "stripped-down" compared to what Acoustica offers ;) Alternatively, it's also possible to write your own VST-GUI from the scratch, which then completely replaces the application's "native" interface. But I didn't go that route...
Robert J. H. wrote:Although this smoothing is applied, the plug-in seems to have a steppy response.
Not quite sure what you mean with that :?:

If you look at this chart, it shows the "raw" max. gain factors determined for each frame (blue), the minimum filter values (green) as well as the final smoothed values (orange).

Only the final smoothed values will be applied...
steve wrote:You are also assuming, or at least suggesting, that peak level equates directly to perceived loudness. It doesn't.
Well, as I have mentioned before, ideally we should apply a psycho-acoustic model. That is: We transform everything into the frequency domain and weight each frequency by how sensitive the human ear is for that particular frequency. Though this would be much more complex and much slower compared to the current approach. And, in my experience, the current approach works pretty well. Last but not least, there already is an optional "RMS based" mode available.

Nonetheless, the current code is written in a way that the function, which determines the "frame local" gain factor, can be exchanged easily - like it's already done with "RMS based" mode. More modes to be added in future versions...
steve wrote:Compare the sound of a click track with a peak amplitude of 0.8 with a 1000 Hz square wave of the same peak amplitude - the square wave sounds much louder than the click track.
With such "extreme" synthetic examples the limitations of the current approach are apparent. But with "real world" recordings it is not that much of an issue.
steve wrote:Replay Gain is an algorithm that estimates "perceived loudness". The algorithm is used in both MP3Gain and WaveGain to make audio files play with approximately the same loudness. It does so without changing the dynamics - the calculated gain is applied to the entire track (if used in "track" mode) or to the entire album (if used in "album" mode).
As long as only a single gain factor is computed for the entire track, or even the entire album, we still have the problem that the maximum gain that can be applied (without clipping) is still restricted by the "loudest" peak. That means: Only a single extraordinary peak could prevent the entire track, or even the entire album, from being amplified adequately. And then the affected track/album will sound MUCH quieter than other tracks/album.

(Assuming we do not apply a "compression" filter to destroy the peaks beforehand, of course)
steve wrote:By the way, I also tried your VST version in Audacity 2.0.6 on Windows XP but it did not show up in the Effect menu. Is it not compatible with XP?
It is supposed to work under WinXP, if that is still relevant these days.

You probably know this, but I need to ask anyway: Did you set the VST_PATH environment variable correctly and did you make Audacity re-scan for new VST plug-in's after that?

Re: adjudting sound levels for all .wav files

Posted: Sat Oct 11, 2014 4:16 pm
by Gale Andrews
Gunnar wrote:
steve wrote:By the way, I also tried your VST version in Audacity 2.0.6 on Windows XP but it did not show up in the Effect menu. Is it not compatible with XP?
It is supposed to work under WinXP, if that is still relevant these days.
XP is still relevant in market share.

Your plug-in appears for me on Windows XP SP3.

Gale

Re: adjudting sound levels for all .wav files

Posted: Sat Oct 11, 2014 4:36 pm
by steve
Gale Andrews wrote:Your plug-in appears for me on Windows XP SP3.
How exactly did you install it?

Re: adjudting sound levels for all .wav files

Posted: Sat Oct 11, 2014 5:00 pm
by Gale Andrews
steve wrote:
Gale Andrews wrote:Your plug-in appears for me on Windows XP SP3.
How exactly did you install it?
I just set Audacity to rescan VST effects, dropped "DynamicAudioNormalizerVST.dll" in the Audacity "Plug-Ins" folder and restarted Audacity.

Might you have used the file of the same name in the "x64" folder? Audacity won't see that.


Gale

Re: adjudting sound levels for all .wav files

Posted: Sat Oct 11, 2014 5:08 pm
by steve
Gale Andrews wrote: I just set Audacity to rescan VST effects, dropped "DynamicAudioNormalizerVST.dll" in the Audacity "Plug-Ins" folder and restarted Audacity.
That's exactly what I did, but the effect was not listed in the Effect menu (though that works for other VST effects).

Re: adjudting sound levels for all .wav files

Posted: Sat Oct 11, 2014 5:10 pm
by Gunnar
Another thing to consider: If you use the "DLL" build, then your need both, "DynamicAudioNormalizerVST.dll" and "DynamicAudioNormalizerAPI.dll". However, due to the way how Windows resolves DLL dependencies, you would have to put the "DynamicAudioNormalizerAPI.dll" into the Audacity main directory (where the EXE file is located), putting it into the "Plug-ins" directory does not help. At the same time, the "DynamicAudioNormalizerVST.dll" needs to be located in the "Plug-ins" directory in order to be recognized by Audacity. In addition to that, the Visual C++ 2013 Runtime libraries must be installed, if you haven't done that already.

If you use the "Static" build, the "DynamicAudioNormalizerVST.dll" will work on its own. No dependency on "DynamicAudioNormalizerAPI.dll". No need to installed the Visual C++ Runtime...