The most reliable method uses metaflac (FLAC utilities) to remove old tags and replaygain to recompute.
Step 1 – Remove existing ReplayGain tags (optional but recommended):
metaflac --remove-replay-gain *.flac
Step 2 – Compute and add new tags:
metaflac --add-replay-gain *.flac
This automatically calculates both track and album gain using the official ReplayGain algorithm (EBU R128 loudness standard in modern versions).
Step 3 – Verify tags:
metaflac --show-tag=REPLAYGAIN_TRACK_GAIN *.flac
Before we fix the problem, we must understand its root. Volume inconsistencies are not a bug; they are a byproduct of the music industry's mastering history.
For batch processing or integration into scripts: flac gain fix
for f in *.flac; do
gain=$(sox "$f" -n stat -loudness 2>&1 | grep "Loudness" | awk 'print $2')
echo "Track: $f, Loudness: $gain"
# Compute correction relative to -23 LUFS (EBU R128)
done
Note: Manual gain application is discouraged; use ReplayGain tags instead of modifying audio data.
Older ReplayGain tools used a reference level of 89 dB. Newer standards (like EBU R128) use LUFS (Loudness Units relative to Full Scale), often targeting -18 LUFS. Some tools write custom fields like REPLAYGAIN_REFERENCE_LOUDNESS that older players ignore. Your player might be looking for REPLAYGAIN_TRACK_GAIN and REPLAYGAIN_ALBUM_GAIN, but the file has something else. The most reliable method uses metaflac (FLAC utilities)
FLAC stores ReplayGain values in Vorbis comments. The relevant keys are: