View Single Post
Old 2nd February 2016, 07:52   #471
Join Date: Jul 2005
Posts: 75
I had missed your earlier post. Foobar's behavior is correct, as it is trying to conform with the specs, which are strict about the fact that Opus files 'should not' contain any replaygain fields. The program had to store the data somewhere. It would have been straightforward for Foobar to use the same vorbis comment fields throughout, but they made an exception.

This restriction and unorthodox behavior of Opus compared to all other file formats, which have been use for over a decade, is indeed weird. If anyone is to blame, it is Xiph, who wanted to make sure loudness normalization was always applied by default.

The "original encoder" (either person or software) has no reason to apply any post-encoding level adjustment, so there is actually little conflict. If the creator wants to adjust the level, he can multiply the PCM data, which is much easier to integrate in any workflow. In traditional formats, an adjustment is only possible with MP3, where it is most often done with mp3gain with the same aim to equalize loudness. If I don't agree with this adjustment, of course I make the decision to "override" it.

If I follow correctly, the current standard is to use R128_album_gain and keep the output gain 0. This change means that the gain can now be found in two different fields, depending on which software set it. This seems worse than the previous situation. But you could still handle it in the plugin.

1) If AG is present, report AG+5 and TG+5 to winamp, decode with output gain applied.
2) If AG is not present, and TG is present or outputgain is non-zero, report OutputGain+5 as AG and TG+OutputGain+5 as TG to winamp, decode without applying output gain, and let winamp handle the adjustment.

I had read the Gmane thread last year. It is filled with controversy. For example, this post:

Offtopic: The author asserts that players should not fallback to the other gain, if the preferred is not present. That is not what current players do and should do. For example, I normally use album/audiophile gain, but if I encounter a compilation with unbalanced levels, I only include track gain to even it out. Or if I have a segued/mixed album, I deliberately do not include track gain in it to prevent volume jumps.


I have noticed that when editing tags your plugin removes padding originally present after the comment block. This requires the complete file to be rewritten. Opusenc by default adds 512 bytes of padding, enough to hold a standard set of fields, which is kept by Foobar, and tag editing is instant.

Last edited by j7n; 2nd February 2016 at 10:09. Reason: Add link which explains the position of foobar
j7n is offline   Reply With Quote