MTG / essentia

C++ library for audio and music analysis, description and synthesis, including Python bindings
http://essentia.upf.edu
GNU Affero General Public License v3.0
2.86k stars 534 forks source link

EasyLoader replayGain confusion #1357

Closed jamiebullock closed 8 months ago

jamiebullock commented 1 year ago

I'm a bit confused by how the EasyLoader replayGain works

The documentation says:

replayGain (real ∈ (-∞, ∞), default = -6) : the value of the replayGain that should be used to normalize the signal [dB]

And cites the following source:

[1] Replay Gain - A Proposed Standard, http://replaygain.hydrogenaudio.org/

However, looking at the source code, I'm struggling to see how this is computed.

EasyLoader seems to consist of the following network:

_monoLoader->output("audio")  >>  _trimmer->input("signal");
 _trimmer->output("signal")    >>  _scale->input("signal");

And I see:

Real scalingFactor = db2amp(parameter("replayGain").toReal() + 6.0);
 _scale->configure("factor", scalingFactor);

But, where does "replayGain" come from, and where is it in the network?

dbogdanov commented 8 months ago

RepayGain value to use should be manually specified as a parameter in this algorithm. So it is assumed that you already have a precomputed target replay gain value (for example, it is commonly stored in the audio file metadata).

It would be useful to optionally be able to compute ReplayGain directly inside EasyLoader, but it is not implemented. Also, one might want to use LoudnessEBUR128 instead.