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: Track Peak (Read 3641 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Track Peak

OK, here's another Noob question LOL.  I did my Forum search and found nothing that answered my question or that they were too technical and i didn't get it.

I finally have foobar installed, made my own theme and have started rippong my rather small CD collection into FLAC. Thanks FB2K for adding yet another thing in my life that I can that I can OCD on.

Here's the question, I added the Replaygain Album, Replaygain Track, and Replaygain Track Peak columns as Zeos suggested in his YT setup video but there are no values being displayed in the RG Track Peak.  Can someone help me out here. Also is Replaygain Track Peak different than Replaygain Track?

Thanks in Advance


Re: Track Peak

Reply #1
Have you scanned your tracks for ReplayGain in Album mode? This scan detects ALL RG related values. Track scan gives just track value.
And yes, RG Track and RG Track Peak are different values. First gives amplification/attenuation factor required to achieve -18 LUFS loudness level - without taking some other side effects into account. Second gives information about maximal amplitude in track and is used to prevent clipping when RG Tack value is positive.

Re: Track Peak

Reply #2
I added the Replaygain Album, Replaygain Track, and Replaygain Track Peak columns as Zeos suggested in his YT setup video but there are no values being displayed in the RG Track Peak.  Can someone help me out here.

Highlight one of the files, show its properties (bottom of right-click menu, or just press Alt+Enter), select the Details tab. Is there any track peak value at the bottom? If there is, then you have a typo when you formatted the column.



Also is Replaygain Track Peak different than Replaygain Track?
See EpicForever's answer. The difference is analogous between Album Peak and Album Gain.

Re: Track Peak

Reply #3
This is my peak column formatting:
Code: [Select]
$left(%replaygain_track_peak%,5)

Re: Track Peak

Reply #4
Current Track Peak Level display format is eg. 0.399292
I would like to change the way this value is presented to the value that EAC uses (in this case it will be 39.9)
I want to create a custom column with this value. Is there a syntax code that can do this?

Re: Track Peak

Reply #5
Current Track Peak Level display format is eg. 0.399292
I would like to change the way this value is presented to the value that EAC uses (in this case it will be 39.9)

Multiplied by 100, is that what EAC does? There is a $mul(a,b) ... Edit: Argh, it does not support decimal points, it rounds off first. Sorry.

I got this to work, though I am not sure about the parentheses, maybe it messes up ...:
$insert($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,)),.,$sub($len($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,))),1))
There must be a better way. (At least if you are sure that no peak hits 10. That would probably be a malformed mp3 or something?)

Re: Track Peak

Reply #6
I got this to work, though I am not sure about the parentheses, maybe it messes up ...:
$insert($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,)),.,$sub($len($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,))),1))
There must be a better way. (At least if you are sure that no peak hits 10. That would probably be a malformed mp3 or something?)
It works, but I admit it's a bit complicated  :o
Thank you

Re: Track Peak

Reply #7
It works, but I admit it's a bit complicated  :o

Agree ...

So how to dissect this:
- It is a string that starts with one or two figures before the ".". (fb2k has a default value for when RG scanning should fail - I am not sure what it is, it could be <10 though, and besides, it is not given that you used fb2k to calculate and tag.)
So: extract the position of the ".": that is the $strchr(%replaygain_track_peak%,.)
- Take everything up to & including three characters to the right of the dot. The $left takes the left part, and the $add(.........,3) tells how much.
- Remove the ".", that is the $replace. Now the text string can be treated as an integer: I can use fb2k's integer arithmetic functions.
- ... which I want to do in order to remove trailing zeroes: you want 99.3 in the end, not 099.3. Now it is 0993, which becomes "993" when I multiply by 1.
- insert a "." as the second-to-last character. In order to do that, I count the length of what I have, and insert the "." at the length-minus-1 position.

What it does not do, simply because I forgot it:
If the peak is less than 0.01 - i.e., peak does not reach -40 dB - it does not put a "0" in front of the ".". If peak is 0.011, you will get "1.1" out; if peak is 0.09, you will get ".9", not "0.9" You can do that with an $if, if you like.

Alternatively, you could take everything up to & including dot-position+2, remove dot, multiply by 1 to delete leading zero - and then insert a ".", and then the character at dot-position+3. In the following, I put "¤¤¤" where the dot should be for "clarity":
$mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),2)),.,))¤¤¤$substr(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3),$add($strchr(%replaygain_track_peak%,.),3))

The double occurrence of the "$add($strchr(%replaygain_track_peak%,.),3)" is because it is "from" and "to" the same position.

Re: Track Peak

Reply #8
This is what I use to show track peak:
Code: [Select]
$div($add($replace(%replaygain_track_peak%,.,),500),10000).$right($div($add($right(%replaygain_track_peak%,4),500),1000),1)
I worked it out years ago and can't remember how it works, but I remember it taking a while to deal with rounding correctly!

EDIT: Credit to 2E7AH https://hydrogenaud.io/index.php/topic,67814.0.html

Re: Track Peak

Reply #9
Thanks for the link to the interesting thread. I found there a code that interests me but there is a problem because the indications are incorrect. I compared the indications of two codes, one code from the link provided, and the code that @Porcus wrote
Code: [Select]
$ifgreater($num(%replaygain_track_peak%,1),0,100.0,
$insert($div($add($replace(%replaygain_track_peak%,.,),555),1000),.,2)
)
to
Code: [Select]
$insert($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,)),.,$sub($len($mul($replace($left(%replaygain_track_peak%,$add($strchr(%replaygain_track_peak%,.),3)),.,))),1))


The code that Porcus wrote shows the correct values (left side)

Valid values for Pink Floyd - Dark Side of the Moon [Japan] [1st Press] are:
1983 Sony mastering track peak levels: 39.9 / 43.3 / 70.1 / 55.2 / 72.3 / 44.5 / 53.9 / 54.6 / 61.2

Somewhere there is a bug (in code) only I do not know where  :(

Re: Track Peak

Reply #10
A small code modification and all values are displayed correctly  ;D

Code: [Select]
$ifgreater($num(%replaygain_track_peak%,1),0,100.0,
$insert($div($add($replace(%replaygain_track_peak%,.,),555),1000),.,2)
)
to
Code: [Select]
$ifgreater($num(%replaygain_track_peak%,1),0,100.0,
$insert($div($add($replace(%replaygain_track_peak%,.,),100),1000),.,2)
)

Re: Track Peak

Reply #11
I have this CD too. It's true that EAC reports a peak of 43.3% for track 2, but the replaygain track peak is actually 0.433807

So your updated code succeeds in matching the EAC number, but has to do rounding incorrectly to achieve this.

Re: Track Peak

Reply #12
So your updated code succeeds in matching the EAC number, but has to do rounding incorrectly to achieve this.
My goal was to obtain a value that is match with the value generated by EAC. I noticed one more problem with another track.



A small correction of the code corrects this case
Code: [Select]
$ifgreater($num(%replaygain_track_peak%,1),0,100.0,
$insert($div($add($replace(%replaygain_track_peak%,.,),0),1000),.,2)
) '%'


Re: Track Peak

Reply #13
If the sole purpose of this is to replicate the figures reported by a CD ripper (no floating-point!) that rounds down and does only store the largest sample (no intersample "true peak" scanning), then there is precisely one character before ".".
If so, all you need will be the first four characters, insert a decimal point, and then the fifth. Before your decimal point ("your", not the one in the tag) you want to remove leading zeroes. Assuming you want "0.2 %", not ".2 %", then try:
$mul($replace($left(%replaygain_track_gain%),4,.,),1)
(this should return a number from 1 to 100 with no zero first, or the number 0) and then throw in your decimal point and
$substr(%replaygain_track_peak%,5,5)

Those who want sanity checks might want to check for >1.000000 (error or "true peak", so certainly not comparable with what EAC finds on the CD) - and possibly for a peak tag which does not have sufficiently many characters. But you could check your library in advance, maybe?