Question About ReplayGain Settings
#1
Hi

I've searched and not found an answer to this and ReplayGain is not something I've done a lot with so apologies if it's a daft question! Big Grin

I basically have two kinds of music files that I listen to through Kodi:

  1. CDs ripped to FLAC
  2. Vinyl recorded and saved as MP3

With the high quality FLAC rips I want to use ReplayGain with Album levels so that when listening to an album the relative changes in volume are still present.

With the vinyl I want to use ReplayGain track levels as the majority of my vinyl is 12" singles and due to varying quality in vinyl, recording techniques and the fact that these tracks will usually be listened to as part of a mixed playlist I want them all to play at the same level.

I was going to set Kodi to use Album levels but my question is with this setting how will it handle the vinyl tracks that have been scanned as individual tracks rather than albums. Will the ReplayGain information just be ignored or would it default to using the per track ReplayGain information?

Hopefully that makes sense but if I need to clarify anything let me know.

Cheers
Reply
#2
I have the same question for quite a long time now...
I couldn't find anything about that, yet.
Reply
#3
As far as I understand it, all media types (FLAC, MP3, M4A, etc.) can house "Track Gain" as well as "Album Gain" values at the same time. I use dbPowerAmp to Add ReplayGain tags to my albums & tracks, but I elected ONLY to add "Album Gain" values to my files as I don't generally play single tracks or add single tracks from individual albums to playlists much.

To answer the OP's post, if said 'single' (in so far as Kodi sees it when added to the library) only contains a single full length track of all the songs off the vinyl record, then it will still apply the "Album Gain" value assuming two things are true:

1. The track being played has existing ReplayGain "Album Gain" values.
2. You have selected Album Gain within Kodi as your preferred ReplayGain source.

It's an either/or situation. You can set the option "Volume Adjustments" which is located under "Settings -> Media Playback -> Music" to use either "Use Album Levels", "Use Track Levels" or simply "Off". If the latter is true, then a standard gain value (as determined by the setting below named "Setting for files Without ReplayGain Information" will be applied.

Since Kodi should look at a single track (or single FILE with several tracks) as being an "Album" once it's scraped into the Library's database, logic tells me that, if selected as such in the settings, "Album Gain" should still be applied to that single file, should that be the option you've selected to use. It's not applied "On The Fly" as the file plays, since the "Album Gain" value will only store the peak volume of the file as a whole, as a pose to the tracks contained therein. BUT, the peak volume should be as near as damn it to the set ReplayGain target set in the settings (default: 89db industry standard).

One thing I will point out is that the default standard 89db value only applies to content that originated from CD media. The standard did not exist back in the heyday of vinyl (from what i've read), and movies use 100db as the 'standard' as a pose to the 89db for music. The popularity of multi-channel surround sound (for movies) as a pose to stereo-only (for most music) is likely the reason for the disparity there. The standard is in itself bunk anyhow, I have different CDs with wildly varying volume levels to others. The standard seems to be very loose in it's application (depending on the band / record label / producer / etc).

Therefore, you can only set this option once for all your media in your library. It can either be "Track Gain" OR "Album Gain" OR Disabled (OFF). You cannot have one part of your media collection use "Track Gain" and another Use "Album Gain". The only way you'd get the benefits of either method is by changing the setting (prior to playing the desired content) to the desired method.
Image
Reply
#4
To simplify the above, let's say hypothetically you have an MP3 album with 10 tracks, and you have applied BOTH "Track Gain" AND "Album Gain" values to the tags of all the tracks in that album, and each track is in a seperate file;

Each track (file) will have a tag that lists the peak volume of that single track. However it will also contain a tag with the peak volume of the album as a whole (or rather the peak volume of the loudest track in the album). The original source type is irrelevant, be it CD, or Vinyl.

However, if you have an album that has 10 tracks, but is stored within a single FLAC file (accompanied by a relevant cue-sheet for track names & playback), the album gain tags and track gain tags will be identical, as both methods work at the file level, and each file may only contain one setting for each type of gain value, be it track gain and/or album gain, and ReplayGain only stores the peak volume of the audio contained in that single file, as a pose to listing the variances in volume across the tracks / album.

So while the second example may aid in gapless playback, the volume will be applied univerally across the album, because all the tracks are in the same file.

NOTE: Kodi is a bit misleading in mentioning MP3Gain, as it doesn't in itself follow the "ReplayGain" standard. Instead, MP3Gain uses it's own proprietry tags (based on APEv2 if memory serves) to store values and undo information, and actually normalises the source audio directly. Whereas the true ReplayGain method simply adds tags to the existing ID3v2 tags with peak volume levels, for player software that supports ReplayGain to make the relevent adjustments. Normalising and ReplayGain are not the same thing. Normalising actually modifies the audio data in the file to be as close to the required volume level. ReplayGain tools do not in any way modify the source audio. So if you want to preserve your files, since some audio file validator tools / tagging apps will strip-out / remove MP3Gain's custom tags, thus making it impossible to undo it's changes, avoid using it as a ReplayGain tool, as it's not one and the same thing.
Image
Reply
#5
In general I think this is what is done in Kodi:

Kodi reads 4 tags in song metadata.:

REPLAYGAIN_TRACK_GAIN
REPLAYGAIN_ALBUM_GAIN
REPLAYGAIN_TRACK_PEAK
REPLAYGAIN_ALBUM_PEAK

These tags format are nn.nn which are read as I guess Float32s. How you get these gain values is up to you. You could use something like MP3Gain or its analogs, R128Gain, etc.

There are 3 settings available for gain (iType), NONE (0) ALBUM (1) and TRACK (2)

There is a target dB setting for tracks with (iPreAmp) and without (iNoGainPreAmp) replaygain values.

Function float CAudioDecoder::GetReplayGain(float &peakVal) is used to compute the replaygain.

If the gain iType is NONE it returns 1.0 and no peakVal

If gain iType is ALBUM, it looks for album gain and album peak values from the tags first. If either are missing, it will then look for track gain/peak tags and use those instead.

If gain iType is TRACK it's just the opposite; Looks for track gain/peak first, and if missing then uses album gain/peak.

It uses these to compute a replaydB and peak.

replaydb is computed as

if no gain tags at all, just the target dB for no gain, iNoGainPreAmp (default 89.0)

otherwise if it finds the tags:
replaydb is the target dB for gain, iPreAmp + album or track gain tag value as appropriate

likewise the peak is computed as

if no peak tags at all, 1.0

otherwise if it finds the tags:
peak is the album or track peak tag as appropriate

So now that replaydB is computed, the power function is computed as:
pow(10.0, (replaydB-89.0)*.05)

and the peak is returned as peakVal

this value is logged to kodi.log and returned from the gain function.

I built some test files so far none have a peak gain tag but I tested both album and track gain values in tags, and different target db settings and at least as logged the gain is being correctly computed per above. When I get a chance I will do some recording of the sound output (2 chan) and see what I am getting (WASAPI and DirectSound).

Here's specific test:

1 album gain -5
2 album gain +5
3 no gain
4 track gain +3
5 track gain -3

target gain is 91 for files with gain and 88 for files without gain:

1. DEBUG: AudioDecoder::GetReplayGain - Final Replaygain applied: 0.707946, Track/Album Gain 86.000000, Peak 1.000000
2. DEBUG: AudioDecoder::GetReplayGain - Final Replaygain applied: 2.238721, Track/Album Gain 96.000000, Peak 1.000000
3. DEBUG: AudioDecoder::GetReplayGain - Final Replaygain applied: 0.891251, Track/Album Gain 88.000000, Peak 1.000000
4. DEBUG: AudioDecoder::GetReplayGain - Final Replaygain applied: 0.891251, Track/Album Gain 88.000000, Peak 1.000000
5. DEBUG: AudioDecoder::GetReplayGain - Final Replaygain applied: 1.778279, Track/Album Gain 94.000000, Peak 1.000000

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#6
Thank you two for these deep insights and explanation! Now I have an idea of what is going on with different settings. I, for my part, use some single mp3s which are tagged with track information and a lot of albums, where every track is tagged with album information only. So, what I wished (an it was kinda fulfilled) was, that I set 'use album gain' and kodi would fall back to track gain if album gain was not present.
Reply
#7
OK I did some tests on the actual sound output. What I find on my system (Win 7, realtek drivers to speakers) is that DirectSound doesn't give good results. Tests (all used track gain)

tags / rpg / target dB / measured output
none / 1.0 / 89.0 / 0
-1 / .89 / 88.0 / 0
-3 / .71 / 86.0 / 0
-5 / .56 / 84.0 / -6
-7 / .45 /82.0 / -8

So DirectSound doesn't seem to track well. I can't directly measure WASAPI output, but from ear it seems better. It could be how my driver is set up.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#8
DirectSound's buffer system is somewhat less reliable than WASAPI too from what I understand. If the hardware your using supports WASAPI then I'd use this over DirectSound, regardless of the quality issues it suffers from (vs. WASAPI). I'm pretty sure I read somewhere that to all intents & purposes, DirectSound has been depreciated by MS in favour of WASAPI, so at some point it may be removed altogether. The only downside for Kodi users is that WASAPI in Kodi runs in exclusive mode, so sounds from anything other than Kodi will not be heard when using it.
Image
Reply

Logout Mark Read Team Forum Stats Members Help
Question About ReplayGain Settings0