INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Converting and writing R128 Volume Levelling Values into iTunNORM metadata tags.  (Read 4686 times)

yinmeout

  • Junior Woodchuck
  • **
  • Posts: 52

I posted a few days back, asking how to convert an R128 AlbumGain value into an iTunes Sound Check value (stored in the iTunNORM ID3v2.3 tag).

It seems that this task is beyond the intended scope of JRiver as it is sold today. (which is not a dig or criticism at all). The reasons are that JRiver does not expose the capacity to write to a tag which is not mapped in the MC database. iTunNORM is one such tag that is not stored in the MC database. Also there is no capacity to extrapolate a new tag value from an existing tag value (that I could find).

So this post is aimed at those of you who would like to for one reason or another calculate your own tag value (if like me you use Sonos kit) but currently lack the program to do that.

There are tag editors out there (mp3tag (for mp3, flac, m4a files), kid3 for AIFF and a few others) to name a couple – which can perform almost any operation you can think of on your ID3v2.3 and ID3v2.4 tags, but not the one I needed to perform on AIFF files.

Background:

JRiver’s audio analysis feature does an excellent and fast job of analysing audio against the superior R128 analysis algorithm. However, be aware that they calculate Album Gain dynamically. This means that each track will be played back at roughly similar volume, unless you are using JRiver itself for playback. I read that, If you are using J River for playback, it will work out the loudest track on the album and use that as the reference point for the volume level, for all tracks in the album. This preserves the intended album mastering. What I am suggesting, is a straight conversion of each R128 track levelling calculation into a Sound Check value. This will expose a limitation in the Sonos hardware, which is that Volume Levelling can’t be turned off, and does not seek or use an Album Gain value. For my purposes, this is not an issue as I am only levelling popular music, electronic music and not fine music such as classical. In a future version of this solution I may use Sourceforge R128 gain, calculate R128 Album Gain and then write that value into Sound Check. But the essential point is that with Sonos and sound check, you can’t have it both ways.

To extrapolate SoundCheck (Apple volume levelling) from R128 Volume Level – it is necessary to read the R128 Volume Level tag which J River has produced; then perform a calculation on that, to derive the Sound Check value. Finally write the resultant in to the iTunNORM tag.

To do it:

If you only have m4a and mp3 files – then there is a thread here that you can follow and you can use mp3tag. However, the algorithm they are using does not compute the 2500 milliwatt gain values, only the 1000 milliwatt values. I am not sure at this point, how significant this is. But I am keen to produce something as close as identical in structure, as Apple would produce with iTunes.

If you use WAV or AIFF you will need two programs.

Perl
And
Kid3

There is a thread with the author of Kid3 that explains some changes to that code base that were needed to accommodate the functionality I am describing in this section. Also another thread that discusses a timeout parameter which is not needed here but you might find useful.

You will also need the file attached which is a perl script. R128.txt

Once you have dissected the script, you will see that you have been given a tool that can modify, add, delete, re-write or re-calculate any value in any tag in any file. It is hugely powerful. The kid3-cli executable is the main workhorse, which reads and writes the tags. In this example the convertr128gaintosoundcheck code is written to re-calculate the Volume Levelling data as I explained before.

The syntax:

Assuming you have a perl binary location in your path statement, you will type the following:

Perl c:\users\username\downloads\script.pl “path to music files”

Where c:\users\username\downloads\script.pl = the location of the perl script you downloaded from this post.
and
Where “path to files” = top level directory entry point that you want to scan and operate on. The script is recursive and will find and operate on every file if finds in all subdirectories. Valid syntax is C:\somepath\somefolder or \\server\share\folder\folder or \\server\share or W:\music - basically any legal windows path.

The following part of the perl script needs modification to work correctly on your system.
(it is easier to edit this in notepad ++ )

my $kid3path = "W:\\kid3\\kid3-cli";

The part in “” needs to point to the containing folder of the kid3-cli executable file. Also any backslashes need to be escaped with a backslash. Resulting in the \\ syntax.

Also you can specify which type of files are included in the scan by changing this section – to only include relevant file extensions.

  if (/\.(mp3|m4a|aif)$/) {

I have it set to find files of type mp3, m4a and aif.

Hope this is useful.
Logged

adamt

  • Galactic Citizen
  • ****
  • Posts: 447

I don't know a heck of a lot about volume leveling, but this looks very helpful.  Thanks for posting it.
Logged
Adam Thompson, JRiver

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.

Maybe you can make this a pscriptor scriptlet?  I'll help you if you are interested.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up