iTunes Match Analysis Tool

Update – for the results of this on my iTunes library see here.

This script uses DRC-Meter to compare the dynamic range compression of your ‘old’ mp3s to the ‘new’ iTunes Match .m4as. It could potentially be used to determine if iTunes has replaced any of your ‘original’ mp3s ripped from old CDs with ‘new’ remastered versions where the output is louder or more compressed.

I noticed this on a few songs where clipping was more pronounced in the ‘higher quality’ files than in my original versions. So I wrote this to scan through my old files and compare their DRC to the new versions.

This script could be extended to produce a waveform of each file (in gnuplot, say) or even to calculate the dynamic range using another tool.

#!/bin/sh
# Script to compare my original mp3s to the new 'matched' versions
# Copyright (C) 2012 W Tristan Collins - All Rights Reserved
# Do what the hell you like with this.

SAVEIFS=$IFS # save the old IFS variable
IFS=$'\n\b' # change IFS to cope with spaces in paths/filenames

oldFILES=source/* # directory of old mp3s
newFILES='/Users/Tristan/Music/iTunes/iTunes Music/*' # iTunes music directory

extension='.mp3' # set the extension we are looking for, in this case mp3

# prepare output file
echo Name,Old Dynamic Compression,New Dynamic Compression > out.csv
echo Name Old New

for file in $oldFILES # for each of the original mp3s
do
oldNAME=`basename $file $extension` # strip the path and extension
newNAMEarray=(`find $newFILES -name $oldNAME\*`) # find the corresponding new file
for i in ${newNAMEarray[*]}
do
# echo "$i" # this is where the comparison could be done
# This is a measure of Dynamic Range Compression
# using http://www.pitchtech.ch/DRC-Meter/index.html
# Smaller numbers are better (less obvious compression used)
# updated to run java without an icon appearing on a mac (the headless bit)
procold=$(java -Djava.awt.headless=true -jar DRC-Meter/DRC-Meter.jar "$file" | tail -c 5)
procnew=$(java -Djava.awt.headless=true -jar DRC-Meter/DRC-Meter.jar "$i" | tail -c 5)

echo $oldNAME $procold $procnew
echo $oldNAME,$procold,$procnew >> out.csv
done
done

IFS=$SAVEIFS
exit 0

The output is printed to STDOUT as well as to a csv which can be opened up in excel or something like that for further processing. Smaller numbers are ‘better’, generally indicating less compression.

This has not been optimised at all. I’m sure it would be quicker to pass a huge list of files to the DRC-Meter. On my 2.66 GHz Intel Core Duo MacBook Pro each comparison takes about 15secs. And yes, there is no error processing and what happens when there are multiple file matches. I’m sure there is a better way, but I just threw this together.

The output to STOUT looks like below. Highlighted are some files where the difference is pronounced (remembering lower numbers are better).

$ ./match_analysis.sh
Name Old New
(Take a little) Piece of my heart +2.7 +1.9
01 (I've Had) The Time Of My Life +0.4 +0.7
01 (They Long To Be) Close To You +0.7 +0.5
01 (intro) +0.9 +1.1
01 A Song For A Son +3.4 +3.4
01 A Spaceman Came Travelling +0.3 -0.2
01 About A Girl +2.6 +3.3
01 Ain't Nobody +3.3 +2.4
01 All Along The Watchtower +0.7 +2.3
01 Amado Mio +3.3 +3.0
01 American Idiot +6.6 +6.9 generally thought of as a loud album
01 American Pie +0.1 +2.6
01 Angels +3.6 +3.7
01 Around The World +6.1 +5.6 the RHCP album Califonication gets slightly better
01 Atlantic +3.3 +3.9
01 Ave Maria +0.4 +0.2

Taking a look at the waveforms in the excellent Audacity gives another view of what’s going on.

Hendrix’s Along The Watchtower (old .mp3 on top, new .m4a on bottom):

It is certainly louder with practically no clipping, but still looks reasonably ‘dynamic’.

Don Mclean’s American Pie (old .mp3 on top, new .m4a on bottom):

Just looks a bit louder, no clipping, still very dynamic.

Rufus and Chaka Khan’s Ain’t Nobody:

The new version is drastically better than my old version. Great stuff.

More examples to come when I find some really bad ones.

Updated: the command to run the DRC java code now runs ‘headless’ to stop the annoying icon appearing in the dock at each instance of the command. Also seems to run slightly quicker now too.