Export: find albums with different replay gain/peak values

There may be cases, when the songs of the same album have different replay album gain and album peak values: for example, songs from multiple sources ("Best of...", etc.). To find and correct them, an easy and simple variant:

Variant A: if you organize albums only by tags, and files of the same album may be in different folders (this is the slower way).

1. In Mp3tag, select any file, and click Export > New, give a name "DifferentRG". Choose Edit, and replace the content of this .mte file with... $filename('DifferentRG.m3u8',utf-8)$puts(

 )$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(br,'{br}')$loopend()$replace(
 
 $loop(%albumartist%)$replace(
 $loop(%album%)$replace(
 
 
 $loop(1,1)$replace(
 $puts(first_gain,%replaygain_album_gain%)
 $puts(first_peak,%replaygain_album_peak%)
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 
 $loop($num(%track%,3))$replace(
 $if($or(
 $neql($get(first_gain),%replaygain_album_gain%),
 $neql($get(first_peak),%replaygain_album_peak%)
 ),%_path%$get(br),)
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 
 
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 ,$get(crlf),,$get(br),$get(crlf))

2. Open your whole music library in Mp3tag. Select all files, click Export, choose DifferentRG.
Choose, where to save the playlist.
Important: in Settings must be set the use of BOM at export!

3. In foobar2000 click File > Preferences > Quick search. (You must first install the foo_quicksearch component.) Create (if you don't have) a new entry in Tags table.
Name: Albumartist+album
Value: %albumartist% - %album%
If you have the same songs in different formats, too, then better...
Name: Albumartist+album+codec
Value: %albumartist% - %album%, %codec%
Then don't forget to click on "Add", and "OK" buttons!

4. Create a simple, empty new playlist. Rename it to "DiffRG" (or any else).

5. Open the resulting (from Mp3tag export) DifferentRG.m3u8 playlist in foobar2000.

6. In the DifferentRG.m3u8 playlist, click on the first song, choose from context menu (right click) Quicksearch for same... > Albumartist+album (or Albumartist+album+codec). Select all files, then drag and drop them to the newly created DiffRG playlist.

7. Repeat the previous (No. 6) with all songs of the playlist (but only 1 from each album, of course).

8. Go to the DiffRG playlist. Select all songs, right click > Replay Gain > Scan selection as albums (by tags). When ready, click to write values in tags.

Variant B: if you store your files 1 album / 1 folder, it means, the files of the same album are all strictly in the same folder, and only this album's files are there (this way is much quicker)

(Now working solution - many thanks to DetlevD.)

1. In Mp3tag, select any file, and click Export > New, give a name "DifferentRG". Replace the content of this .mte file with... $filename('DifferentRG.m3u8',utf-8)$puts(

 )$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(br,'{br}')$loopend()$replace(
 
 $loop(%_folderpath%)$replace(
 
 $loop(1,1)$replace(
 $puts(first_gain,%replaygain_album_gain%)
 $puts(first_peak,%replaygain_album_peak%)
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 
 
 $loop($num(%_path%,3))$replace(
 
 $puts(repeated,$if($eql($get(errorpath),%_folderpath%),'TRUE','FALSE'))
 
 $puts(errorpath,$if(
 $or(
 $neql($get(first_gain),%replaygain_album_gain%),
 $neql($get(first_peak),%replaygain_album_peak%)
 ),%_folderpath%,$get(errorpath)))
 
 $if(
 $and(
 $eql($get(repeated),'FALSE'),
 $or(
 $neql($get(first_gain),%replaygain_album_gain%),
 $neql($get(first_peak),%replaygain_album_peak%))),
 %_folderpath%$get(br),)
 
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 
 ,$get(crlf),,$get(br),$get(crlf))$loopend()
 ,$get(crlf),,$get(br),$get(crlf))

2. Open your whole music library in Mp3tag. Select all files, click Export, choose DifferentRG. Choose, where to save the playlist.
Important: in Settings must be set the use of BOM at export!

3. Open the DifferentRG.m3u8 playlist in foobar2000. Select all songs, right click > Replay Gain > Scan selection as albums (by folders). When ready, click to write values in tags.

In the same way you can find any other album-related differents, for example, different YEARs in the same album, DiscId, Publisher, and so on.

(For users: this discussion from here to [including] post No. 8 is already done, the solution above is working.)

DetlevD, for your attention. :slight_smile: It was hard for me to find out this tricky variant, because of...

  1. $puts() does not reflect to $if() conditions - it evaluates allways. So I couldn't use variant "rewrite prev_gain, if changed folder" - it allways rewrites.
  2. Using nested loops, first calculate all nested levels, and only later evaluate $puts(). So my tries in outer loop (one per folder) $puts() peaks and gains, and then, in the inner loop (by files) take compares, were without success.

Am I right, are you agree? And, if yes, why are these limitations? Very frustrating, mostly the $puts()<>$if().

You can use an $if-condition even with $put() or $puts(), when you create the $if-condition within the formatstring expression of the 2nd parameter.

Yes, there are 'limitations' and 'obscurities' in the Mp3tag export scripting language.
And one can react and work only with newly created 'obscurities'.
I have designed a few tricks to outwit some quirks.
For your interest see following script, which is based on the script from your yesterday first proposal.

01: $filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.RG.Album.Diff.m3u8',UTF-8)$puts(

02: )$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(br,'{br}')$loopend()$replace(
03: $puts(Terms_of_Usage,'
04: ====================================================================
05: === This Mp3tag export script creates a M3U8 playlist file of mus
ic track files,...

06: === which differ in their album related replay gain and peak valu
es, within one album.

07: ===
08: === This Mp3tag export script is based on inspiration by Mp3tag u
ser "incifinci".

09: === See also: /t/17004/1
10: === ©Detlev Dalitz.20150629.
11: ====================================================================
12: ')$puts(Terms_of_Usage,)
13:
14: $loop(%ALBUM%)$replace(
15: $loop(%_folderpath%)$replace(
16:
17: $loop(%_folderpath%,1)$replace(
18: $puts(AlbumGain,%REPLAYGAIN_ALBUM_GAIN%)
19: $puts(AlbumPeak,%REPLAYGAIN_ALBUM_PEAK%)
20: ,$get(crlf),,$get(br),$get(crlf))$loopend()
21:
22: '### Album : '%ALBUM%$get(br)
23: '### Folder : '%_folderpath%$get(br)
24: '### RG_File1: '$get(AlbumGain)' | '$get(AlbumPeak)$get(br)$get(br)
25:
26: $loop(%_path%)$replace(
27: $if($or($neql($get(AlbumGain),%REPLAYGAIN_ALBUM_GAIN%)
28: $neql($get(AlbumPeak),%REPLAYGAIN_ALBUM_PEAK%)),
29: %_path%$get(br)
30: '### RG: '%REPLAYGAIN_ALBUM_GAIN%' | '%REPLAYGAIN_ALBUM_PEAK%$get(br)
31: ,)
32: ,$get(crlf),,$get(br),$get(crlf))$loopend()$get(br)
33: ,$get(crlf),,$get(br),$get(crlf))$loopend()
34: ,$get(crlf),,$get(br),$get(crlf))$loopend()
35: ,$get(crlf),,$get(br),$get(crlf))

Note: The script is not perfect yet, take it as an example.
Export.M3U8.TXT_Playlist_ReplayGain_Album_Difference.mte (1.5 KB)
DD.20150630.0855.CEST

Export.M3U8.TXT_Playlist_ReplayGain_Album_Difference.mte (1.5 KB)

Oh, it's nice. :slight_smile:
Thank you very much, Detlev!

EDIT (for users):

My second (short) variant is mistake: it creates repeated lines, if more than 1 differents are in 1 folder. So, or use the first variant, or, if the second, then before opening the playlist in foobar, manually delete the repeated lines.

I tried it, no success. $puts() simply doesn't work, if the 2. parameter is an $if() expression.

It should work and it does ...
see example export scripts in attached mte files ...
_Export.TXT.20150703.Test.put.1.mte (515 Bytes)_Export.TXT.20150703.Test.put.2.mte (505 Bytes)
DD.20150703.1959.CEST

_Export.TXT.20150703.Test.put.1.mte (515 Bytes)

_Export.TXT.20150703.Test.put.2.mte (505 Bytes)

It's driving me crazy. $get(way) is ALLWAYS empty. Can't understand, why.

$filename($getEnv('USERPROFILE')'\Asztal\Hangosításhiba (előadó-lemez-alak alapú).txt',utf-8)$puts(
)$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(sor,'{sor}')$puts(tab,$char(9))$puts(
)$puts(ugr,'{ugr}')$loopend()$replace(

$loop(%albumartist%)$replace(
$loop(%album%)$replace(
$loop(%_extension%)$replace(

$loop(1,1)$replace(
   $puts(prev_gain,%replaygain_album_gain%)
   $puts(prev_peak,%replaygain_album_peak%)
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()


$loop($num(%track%,3))$replace(
$puts(
   way,
   $if(
       $or(
           $neql($get(prev_gain),%replaygain_album_gain%),
           $neql($get(prev_peak),%replaygain_album_peak%)
       ),
       %_folderpath%,
      
   )
)
%_path%$get(sor)       way: $get(way)$get(sor)
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()

,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))

It's empty even so:

$filename($getEnv('USERPROFILE')'\Asztal\Hangosításhiba (előadó-lemez-alak alapú).txt',utf-8)$puts(
)$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(sor,'{sor}')$puts(
)$puts(tab,$char(9))$puts(ugr,'{ugr}')$loopend()$replace(

$loop(%albumartist%)$replace(
$loop(%album%)$replace(
$loop(%_extension%)$replace(

$loop(1,1)$replace(
   $puts(prev_gain,%replaygain_album_gain%)
   $puts(prev_peak,%replaygain_album_peak%)
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()


$loop($num(%track%,3))$replace(
$puts(
   way,
   $if(
       $eql(1,1),
       'TRUE',
       'FALSE'
   )
)
%_path%$get(sor)       way: $get(way)$get(sor)
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()

,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))$loopend()
,$get(crlf),,$get(sor),$get(crlf),$get(tab),,$get(ugr),$get(tab))
Forum machine is buggy. It inserts plus and plus tabs in CODE brackets after every previewing. (In fact, not real tabulators, but 3 spaces, instead.)

PHP is much more complex, of course. And easier! Because of good, big, and well organized documentation, online. Why we have no rights to see Mp3tag scripts' detailed limitations and characteristics, with examples? Mp3tag is an excellent app, but now, already, I think: it's a Mercedes, with documentation from Packard Bell of 1911 year.

My condolences ... probably the summer heat melts the brain.
I looked at your first script, and removed superflous code regarding put/get statements.
The script seems to work for me, please try it out.

01: $filename($getEnv('USERPROFILE')'\Asztal\Hangosításhiba (eloadó-lemez-alak alapú).txt',utf-8)$puts(

02: )$loop(1,1)$puts(crlf,$char(13)$char(10))$puts(sor,'{sor}')$puts(tab,$char(9))$loopend()$replace(
03:
04: $loop(%ALBUMARTIST%)$replace(
05: $loop(%ALBUM%)$replace(
06: $loop(%_extension%)$replace(
07:
08: $loop(1,1)$replace(
09: $puts(prev_gain,%replaygain_album_gain%)
10: $puts(prev_peak,%replaygain_album_peak%)
11: ,$get(crlf),,$get(sor),$get(crlf))$loopend()
12:
13:
14: $loop($num(%TRACK%,3))$replace(
15: $puts(way,
16: $if($or($neql($get(prev_gain),%replaygain_album_gain%),
17: $neql($get(prev_peak),%replaygain_album_peak%)),
18: %_folderpath%,)
19: )
20:
21: %_path%
22: $get(sor)$get(tab)'way: '$get(way)$get(sor)
23:
24: ,$get(crlf),,$get(sor),$get(crlf))$loopend()
25:
26:
27: ,$get(crlf),,$get(sor),$get(crlf))$loopend()
28: ,$get(crlf),,$get(sor),$get(crlf))$loopend()
29: ,$get(crlf),,$get(sor),$get(crlf))$loopend()
30: ,$get(crlf),,$get(sor),$get(crlf))

DD.20150705.1922.CEST

Oh, my Dear Nature!

$put(
   way
$put(way

Like freespace regex and nonfreespace regex...
After you gave me an idea to write nice and comfortable code with your $get(ctlr) etc. solution, I never looked more for free spaces.

I corrected the first two my posts. Detlev, many thanks for your help.