Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A perl script to rip and normalize songs for iTunes UNIX
I received an iPod for Christmas -- I've admittedly been resisting this convenient technology because I am not satisfied with the audio quality of MP3s, even at the higher bitrates. I've revisited this issue since receiving my gift, however, and I'm mightily impressed with AAC at 256kbps: I've done listening tests of AAC against uncompressed audio with strings, voice, symphonic, and amplified music, and am sold on 256kbps AAC. It requires nice components for me to discern the difference from the original, and I sure can't on the little iPod.

I began converting my CD collection to AAC, but quickly became dissatisfied with Apple's tools to do this, either through iTunes or via Max. Neither does track normalization for a large collection, and Max's rips often produce white noise output for me.

Having used and trusted cdparanoia and cdrdao to obtain high quality rips for years now, I wrote a perl script based on these tools to rip a CD, grab the CDDB information, normalize the tracks, convert everything to a specified codec (AAC, ALAC, flac, mp3, etc.), and add the CDDB information to the resulting files. The script also does the correct UTF-8 conversion for non-English scripts. (I have an extensive Arabic collection from Beirut -- it's pretty neat to have the correct Arabic script appear in iTunes). To use this script, you'll have to download and build your own executables of the following tools (you must know how to type ./configure; make; make install): I've written this script for my own needs, but it's easy to modify to incorporate other formats. To use, save the text to a file named cd2codec, do chmod a+x cd2codec, get/build the required tools, and type cd2codec --help for usage instructions. If you wish to add foreign language scripts to your mp4tags, then also grab a copy of my transliterate perl script, too, which provides the octal UTF-8 transliteration of Arabic and Greek. Cyrillic, Hebrew, and others are possible, too, but not implemented.

[robg adds: I haven't tested this one...]
    •    
  • Currently 1.00 / 5
  You rated: 1 / 5 (3 votes cast)
 
[23,670 views]  

A perl script to rip and normalize songs for iTunes | 14 comments | Create New Account
Click here to return to the 'A perl script to rip and normalize songs for iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A perl script to rip and normalize songs for iTunes
Authored by: jctull on Feb 21, '07 09:05:56AM

Can you or someone else explain the advantages or disadvantages of using normalize versus aacgain/mp3gain for normalizing sound files? TIA



[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: fracai on Feb 21, '07 09:27:55AM

I'd go with mp3gain over normalize.
Normalize rewrites the wav file before encoding, mp3gain adds a gain hint to the file without altering the audio file.
flac also includes this hint capability. I rip my music to "normalized" (hinted) flac and encode from there.

Also, it appears that the way this script uses normalize is to normalize each track independently, such that two tracks on the same album won't play back at the same respective volumes. In other words, all your music will sound the same volume even if one track on an album is meant to be quiet and another track on the same album is meant to be loud. normalize does include support for this case by using batch mode to process all files from an album, preserving their relative volumes.

Actually, looking at the normalize man page seems to indicate that normalize includes support for the mp3 RVA2 tag which non-destructively modifies the volume of mp3 files.

Steve, please correct me if I'm wrong here.

---
i am jack's amusing sig file



[ Reply to This | # ]
Help with MP3 Gain?
Authored by: jiclark on Feb 21, '07 02:43:36PM

I tried that technique, and didn't feel like it made any difference. Is there a place that I can go to get help with that program?

Thanks,
John



[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: stsmith on Feb 25, '07 11:45:51AM
The script uses normalize --peak (distortionless) on the original WAV file, opposed to normalizing the rms values and using a limiter. This simply sets the peak value of each track to peak out a signed 16-bit integer. I've found that this works best for me with a mix of music -- when listenening to the original CD, I listen on a stereo, so adjusting the track volumes isn't an issue, and I have noticed that on most recent recordings, all tracks are peak normalized anyway.

Besides, this is perl. If you don't like the script's behavior, it's easy to change.

[ Reply to This | # ]

What does "normalize" do that iTunes doesn't?
Authored by: plambert on Feb 21, '07 09:25:33AM

What does "normalize" do that the "Sound Check" option in iTunes doesn't?



[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: Laner on Feb 21, '07 12:50:52PM

where can I learn about Fink and compiling/make commands?



[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: stsmith on Feb 25, '07 12:03:22PM
Pretty much RTFM and the README/INSTALL files, but get a copy of XCode and a C compiler before you type ./configure; make; make install.

[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: T0b1 on Feb 21, '07 07:40:08PM
Its correct that AAC is better than mp3, but then again audio experts (producers, musicians, codec programmers, classic musicians, etc.) tried to discern copy and original on 128 bit mp3 with the german magazine CT under lab conditions ... most could tell a difference, but then again some could not could tell which was the original and which was the mp3 - on 256 / 196vbr there is no evidence that anybody can differentiate CD from mp3 anymore.
The only one which could hear / differentiate more than the other participants had a hearing disorder (on a certain frequency), so perhaps you should get your hearing tested.

http://www.heise.de/ct/00/06/092/
http://www.heise.de/ct/02/19/094/default.shtml

[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: stsmith on Feb 25, '07 12:12:50PM
If you prefer MP3 or cannot distinguish the difference, then use --data mp3. You may be interested to test the musicality differences yourself if you have access to a high quality system. Without getting ito a format war, this page is consistent with my own observations.

[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: withinavoid on Mar 02, '07 09:14:58AM

Thanks for this hint. I had been doing this manually and wanting to automate it. I prefer normalize, soundcheck turns the volumes down to low for my tastes.



[ Reply to This | # ]
Where to get cuetools and afconvert?
Authored by: jyncroft on Mar 15, '07 07:00:11AM
Hello,

When I try getting cue tools from SourceForge, I get redirected to http://cuetools.berlios.de/ which doesn't have any code. Looking at cuetools on SF in another way shows that they made the transition to this other server back in 2004. Is the code available on SF current enough to use?

I have Xcode installed but afconvert does not show in Terminal. I see afconvert files in /Developer/Examples/CoreAudio/Services/AudioFileTools/ - do I need to build AudioFileTools.xcodeproj?

Thanks, Jennifer

[ Reply to This | # ]
Where to get cuetools and afconvert?
Authored by: stsmith on Mar 17, '07 01:41:35PM

To build afconvert, search for "afconvert" using OS X's serach utility. Hit "Show All". Hit the little information icon near afconvert.cpp. It should say that this is in the directory /Developer/Examples/CoreAudio/Services/AudioFileTools. Use the Finder to go to that directory, then double click on the build file AudioFileTools.xcodeproj. This will bring up the Xcode application. Highlight afconvert.cpp and hit "Build". This should build the executable afconvert in the directory /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther. Finally, do something like

sudo ln -s /Developer/Examples/CoreAudio/Services/AudioFileTools/build/Development-Panther/afconvert /usr/local/bin/afconvert
to make a symbolic link to the executable that your shell will see.

[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: cinchel on Apr 22, '07 01:16:47PM

could someone post a sample command line for using this. i have tried using it to convert some .aiff files but it would just yell at me.
exapmle
[code]
afconvert -f m4af -d alac -s 2 -r 127 -q 127 sample.wav --verbose sample.m4a
Input file: sample.wav, 10381140 frames
codec quality = 127
strategy = 2
error 'prop': set audio converter property

Error: set audio converter property ('prop')
[code]

there must be something simple that I am not getting. can anyone enlighten me. thank you
cinchel



[ Reply to This | # ]
A perl script to rip and normalize songs for iTunes
Authored by: stsmith on Apr 30, '07 04:31:10AM
Could someone post a sample command line for using this. i have tried using it to convert some .aiff files but it would just yell at me.
afconvert -f m4af -d alac -s 2 -r 127 -q 127 sample.wav --verbose sample.m4a
Input file: sample.wav, 10381140 frames
codec quality = 127
strategy = 2
error 'prop': set audio converter property

Error: set audio converter property ('prop')
You're specifying inconsistent coder settings: ALAC (lossless) coding with a variable bitrate, "-s 2" == "--strategy 2" == VBR. ALAC's bitrate is what it is, so asking for VBR causes afconvert to exit with an error.

The following examples will work:

ALAC (lossless):
afconvert -f m4af -d alac -r 127 -q 127 --verbose sample.wav sample.m4a
AAC (lossy):
afconvert -f m4af -d aac -b 256000 -s 2 -r 127 -q 127 --verbose sample.wav sample.m4a
The script does all this stuff automatically, and adds track information from CDDB.

[ Reply to This | # ]