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: Syntax for Album Volume (Read 3864 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Syntax for Album Volume

Hi there!

MP3Gain has a column that shows the volume of an album, as shown in the photo below.

Could someone please tell me the syntax to be able to integrate this information in a foobar2000 Playlist View column?

I am grateful in advance.

Re: Syntax for Album Volume

Reply #1
Go to Preferences and add a Custom Column in playlist view with one of these expressions.

dB LUFS, which is more commonly used in various modern tools. 0 = -18 dB
Code: [Select]
$if(%__replaygain_album_gain%,<$puts(temp,$num($sub($replace(%__replaygain_album_gain%,.,,+,),-21800),5))$ifgreater($get(temp),20000,<->,<+>$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),2,3),1)<.$substr($get(temp),4,4)< lufs)

dB RG, 0 = 83 dB as it is currently used
Code: [Select]
$if(%__replaygain_album_gain%,<$puts(temp,$num($sub($replace(%__replaygain_album_gain%,.,,+,),-11700),5))$ifgreater($get(temp),20000,<->,$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),1,3),1)<.$substr($get(temp),4,4)< dB)

dB RG, 0 = 89 dB old standard, apparently matches mp3gain
Code: [Select]
$if(%__replaygain_album_gain%,<$puts(temp,$num($sub($replace(%__replaygain_album_gain%,.,,+,),-11100),5))$ifgreater($get(temp),20000,<->,$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),1,3),1)<.$substr($get(temp),4,4)< dB)

I simply moved the zero point in the proven expression I use, without attempting to make it most compact. You can modify it for track gain if you want.

Re: Syntax for Album Volume

Reply #2
@j7n

Thank you very much!

Very helpful your help, I am very pleased!

Without wanting to abuse your generosity, as for dB LUFS, would it be possible to replace the syntax from 0 = -18 to 0 = -23 dB, as in the EBU R128 standard?

Re: Syntax for Album Volume

Reply #3
These display -1800 when track/album grain is zero.
Code: [Select]
$sub(-1800,$replace(%replaygain_track_gain%,.,))
$sub(-1800,$replace(%replaygain_album_gain%,.,))
So are you wanting to have a track/album gain of zero when the real volume of the file is -23 dB and the track/album gain info in the tags says +5 dB?

I posted the wrong number as the starting point. Another attempt to edit. Hopefully it's just a matter of subtracting the track/album gain from 5. Or is it the other way around...

Code: [Select]
$sub(500,$replace(%replaygain_track_gain%,.,))
$sub(500,$replace(%replaygain_album_gain%,.,))

This is the formatting I use (almost). Change -1800 to 500, %replaygain_track_gain% to %replaygain_album_gain%, and LUFS to dB is it floats your boat.
Code: [Select]
$if(%replaygain_track_gain%,$puts(X,$sub(-1800,$replace(%replaygain_track_gain%,.,)))$ifequal($get(X),0,0,$ifgreater($get(X),0,$replace(+$substr($num($get(X),4),1,2),+0,+),$replace($substr($num($get(X),5),1,3),-0,-))).$substr($num($get(X),5),4,5) LUFS))
Same again, but the playing track is highlighted to match the rest of my playlist columns (I have highlighting is enabled in the default GUI).
Code: [Select]
$if(%replaygain_track_gain%,$puts(X,$sub(-1800,$replace(%replaygain_track_gain%,.,)))$puts(VOLUME,$ifequal($get(X),0,0,$ifgreater($get(X),0,$replace(+$substr($num($get(X),4),1,2),+0,+),$replace($substr($num($get(X),5),1,3),-0,-))).$substr($num($get(X),5),4,5) LUFS)$if(%isplaying%,>>>$get(VOLUME)<<<,$get(VOLUME)))

Re: Syntax for Album Volume

Reply #4
It looks like I was quoting myself while trying to edit my post.

Re: Syntax for Album Volume

Reply #5
It looks like I was quoting myself while trying to edit my post.

Re: Syntax for Album Volume

Reply #6
It looks like I was quoting myself while trying to edit my post.

Re: Syntax for Album Volume

Reply #7
would it be possible to replace the syntax from 0 = -18 to 0 = -23 dB, as in the EBU R128 standard?
The reported value agrees with the standard already. The gain in Foobar is offset from it, and we take that into account. To change the volume at which your files play, adjust the preamp value in Preferences to -5. This does not affect tagging.

Re: Syntax for Album Volume

Reply #8
OK!

@yetanotherid  and @j7n  you were very helpful!

Thank you very much, my problem is very well solved!

Re: Syntax for Album Volume

Reply #9
So...

How could I create a column to measure the volume (loudness) of tracks and albums in LU (not LUFS)?

I know that -23 LUFS = 0 LU, the problem is that I haven't been able to translate this into syntax …

Thank you very much in advance.   :-[

Re: Syntax for Album Volume

Reply #10
Tweak the first big number to move the zero point by 2300.

Code: [Select]
$if(%__replaygain_track_gain%,<$puts(temp,$num($sub($replace(%__replaygain_track_gain%,.,,+,),-19500),5))$ifgreater($get(temp),20000,<->,$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),2,3),1)<.$substr($get(temp),4,4)< lu)

Re: Syntax for Album Volume

Reply #11
I'm not sure I understand the question. I thought LU was like dB, meaningless until it's relative to something, so -23dB is relative to 0dB (fullscale) and -23 LUFS is relative to 0 dB as well.

fb2k only determines the track or album gain and the peak value. A track/album gain of zero means the volume is -18 dB or - 18 LUFS (replaygain is a little louder than the EBU standard of -23 LUFS), so track/album gain would need to be +5dB for the volume to be -23 LUFS.

If you want dynamic range you'll have to scan with something else, but I don't know what off the top of my head.

Re: Syntax for Album Volume

Reply #12
LU is simply an offset of the chosen target loudness value. It could be -23 or it could be -18, per one's needs. I think it's convenient to see a zero or small number when on target. And replaygain and loudness (in any units) are opposite of one another (multiply by -1). There is not much more to this, although the terminology is often complicated.

Re: Syntax for Album Volume

Reply #13
foobar2000 and this forum were the best things that happened in my life during this pandemic.

Guys, I'm at a loss for words to express all my gratitude.

Re: Syntax for Album Volume

Reply #14
LU is simply an offset of the chosen target loudness value. It could be -23 or it could be -18, per one's needs. I think it's convenient to see a zero or small number when on target. And replaygain and loudness (in any units) are opposite of one another (multiply by -1). There is not much more to this, although the terminology is often complicated.

So in this context do you mean TrackGain 0dB = 0LU = -18 LUFS? That sort of thing?
If so, I get that, but I wasn't certain LU was another term for gain when reading Adil's question. Probably just me having a dumb day.

Cheers.

Re: Syntax for Album Volume

Reply #15
Could be. But LU still has the opposite sign. Gain -1 dB = 1 LU.

Re: Syntax for Album Volume

Reply #16
I just would like to share to enrich this topic. The "LKFS, LUFS & LU" chapter is particularly my favorite:

Loudness Explained

Re: Syntax for Album Volume

Reply #17
So, by my counts (EBU R128 / -23 LUFS = 0 LU):

100.00 dB = -7.00 LUFS = 16.00 LU = 6 DDR

Re: Syntax for Album Volume

Reply #18
And to think, despite all the busy work giving us new terminology, we're still stuck specifying a target volume of 89dB for ReplayGain. It's become a tad embarrassing.
We have an almost universal standard for measuring volume now, yet the opportunity for the entire world to use the same target volume seems to have come and gone. Sigh...

So LU is always relative to the desired target volume, and apparently it's TrackGain's evil twin?
Adil, I have no idea what DDR means.

For the ReplayGain target volume of 89dB
89dB = TrackGain 0dB = -18 LUFS ( = 0 LU? )
Therefore
100dB = TrackGain -11dB = -7 LUFS ( = +11 LU? )

For EBU R128, translated from ReplayGain's track gain
84dB = TrackGain +5dB = - 23 LUFS ( = 0 LU? )

I really dislike LU. I'm old school and prefer a volume such as -10dB or -15 LUFS etc. A volume that's relative to something written in stone. How are you supposed to know which standard LU is relative to, or if it's relative to my cat?
Then again, it's no different to TrackGain in that respect. Not that I was ever crazy about that. The number of times I've had to explain to someone what TrackGain is relative to, usually trying to avoid eye contact while I explain it's relative to a sound pressure level, and how to translate that into what an output meter displays.

Re: Syntax for Album Volume

Reply #19
DDR = Dynamic Range

Re: Syntax for Album Volume

Reply #20
100dB = TrackGain -11dB = -7 LUFS ( = +11 LU? )
Oh... 11 LU... yes, I think you are right. I put 16 LU based on the syntax you provided me...

Is it not even possible to build a syntax that already reflects the value of 11 LU, based on the EBU R128?

I really dislike LU. I'm old school and prefer a volume such as -10dB or -15 LUFS etc.
Me too!

Re: Syntax for Album Volume

Reply #21
Dynamic range has to be measured with another tool. You obviously can't derive it from a single average loudness. Then adjust the display in Foobar depending on the tag format written by that tool.

Quote
Is it not even possible to build a syntax that already reflects the value of 11 LU, based on the EBU R128?
Of course. Just subtract 500 from the number -19500 in my last example, which was relative to the standard -23 dB that you asked for. A column relative to -18 wouldn't be very useful if it showed the same value as RG.

Re: Syntax for Album Volume

Reply #22
Of course. Just subtract 500 from the number -19500 in my last example, which was relative to the standard -23 dB that you asked for.
So would the syntax be like that?
Code: [Select]
$if(%__replaygain_track_gain%,<$puts(temp,$num($sub($replace(%__replaygain_track_gain%,.,,+,),-19000),5))$ifgreater($get(temp),20000,<->,$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),2,3),1)<.$substr($get(temp),4,4)< lu)

Re: Syntax for Album Volume

Reply #23
No, that is -28 dB. Use -20000 if you really want. For this simple case the expression is longer than necessary...

Re: Syntax for Album Volume

Reply #24
I managed to get to the result like this:

Code: [Select]
$if(%replaygain_track_gain%,$puts(X,$sub(000,$replace(%replaygain_track_gain%,.,)))$ifequal($get(X),0,0,$ifgreater($get(X),0,$replace($substr($num($get(X),4),1,2),+0,+),$replace($substr($num($get(X),5),1,3),-0,-))).$substr($num($get(X),5),4,5)))

Is it absurdly incorrect?

In this case, the LU simply contains the opposite signal from Track Gain, eg: Track Gain = -11.0 dB / LU =  +11.00 lu

Apparently, it reaches the same result as yours, but in a different way.

In your way:

Code: [Select]
$if(%__replaygain_track_gain%,<$puts(temp,$num($sub($replace(%__replaygain_track_gain%,.,,+,),-20000),5))$ifgreater($get(temp),20000,<->,$puts(temp,$num($replace($sub($get(temp),20000),-,),5)))$num($substr($get(temp),2,3),1)<.$substr($get(temp),4,4)< lu)