Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: [Request] fb2k additional arithmetic functions (Read 2473 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[Request] fb2k additional arithmetic functions

Hello Peter,

I would love to have some additional arithmetic functions in fb2k to calculate more "audiophile" values for the standard replaygain values.

What is the reason behind my wish?

While current popular music is getting compressed to death by the mastering studios to sound as "loudly" as possible and thus leading to big negative replaygain values, in other genres like classical music or acoustic jazz etc. this is usually not the case (thank God ). Here the replaygain process mostly calculates positive replaygain values which, after application to the musical signal often results in digital levels >1 - meaning distortion. To attenuate this behaviour there is a foobar player function "apply gain and prevent clipping according to peak" - but this function introduces an other nonlinear behaviour to the transfer function which is not compatible with "audiophile law" (to say the least).

So, my idea to circumvent the problems of "old school" replaygain without completely relinquishing its merits for automatic mixes in the environment of big musical collections would be to calculate "audiophile-compatible" replaygain values for RG_TG and RG_AG. These replaygain values avoid digital levels >1 in any case.

These values should be calculated as follows:

(TG - %REPLAYGAIN_TRACK_GAIN%, TP - %REPLAYGAIN_TRACK_PEAK%,
AG - %REPLAYGAIN_ALBUM_GAIN%, AP - %REPLAYGAIN_ALBUM_PEAK%)

I. For TG

if TG>0
[blockquote]TG = min(TG, 20*abs(log(TP)))[/blockquote]

II. For AG

if AG>0
[blockquote]AG = min(AG, 20*abs(log(AP)))[/blockquote]

To build these formulas with fb2k's built-in formatting language three additional arithmetic functions would be required. In contrast to fb2k's already built-in math functions these would have to perform arithmetic on real numbers (thus prefixed with "r_"):

  • $r_abs(a) - positive value of a
  •   $r_log(a) - natural logarithm of a
  •   $r_min(a,b) - minimum of a and b


Needless to say that a smarter alternative to realize the desired "audiophile replaygain" values would be to implement the formulas into the core code of fb2k - and I would greatly appreciate this approach.

During my research in the field of replaygain I found uncounted examples of questionable implementations in software players but also in extremely expensive streamer devices even of sophisticated audiophile brands. Why not make fb2k a real forerunner in the audiophile replaygain world?

/audiogene
Very early adopter - now grown old audiophile.

[Request] fb2k additional arithmetic functions

Reply #1
I thought titleformatting syntax was *not* meant to be used as a general programming language.

[Request] fb2k additional arithmetic functions

Reply #2
To attenuate this behaviour there is a foobar player function "apply gain and prevent clipping according to peak" - but this function introduces an other nonlinear behaviour to the transfer function which is not compatible with "audiophile law" (to say the least).

So, my idea to circumvent the problems of "old school" replaygain without completely relinquishing its merits for automatic mixes in the environment of big musical collections would be to calculate "audiophile-compatible" replaygain values for RG_TG and RG_AG. These replaygain values avoid digital levels >1 in any case.

These values should be calculated as follows:
[...]
[blockquote]TG = min(TG, 20*abs(log(TP)))[/blockquote]
That's exactly how the ReplayGain specification says to handle clipping (replace abs by minus sign (0< TP <= 1), divide by 20, take ten to the power of both sides), except that your formula is missing the pre-gain. I expect the clipping prevention in foobar2000 to work that way. Also, gain adjustment should be handled by the player software, because it should be up to the end user to decide how to handle the case of clipping. At least according to the spec, whether that choice was good is a matter of opinion. Writing non-compliant RG tags will defeat the purpose of the clipping-prevention switch, so after your writing of the "audiophile" RG to your files, your old files won't be compatible with your new choice, as won't any other files.
It's only audiophile if it's inconvenient.