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

Use a third-party MP3 volume normalization tool in iTunes Apps
There are a couple of options for "normalizing" MP3 volume in iTunes in OS X. The first, of course, is iTunes' own Sound Check. If you use this feature and like it, then you may not need this hint. I disabled it because, with iTunes 9, I had a lot of problems importing large MP3 files -- it would often hang when determing the MP3's volume. Also, I was never able to tell the difference one way or the other -- playlists with songs from different albums still sounded uneven when Sound Check was enabled. If you love Sound Check and don't have any problems with it, this tip is not for you.

Another solution is iVolume, which I've never tried. I read good things about it...but it costs money. Another is what I am going to focus on here: MacMP3Gain, which is a port of the open source command-line program mp3gain for OS X (they also added a GUI).

mp3gain does more than just normalization; it does analysis to determine how quiet or loud an MP3 will sound to the human ear. If you really want to get technical, mp3gain does its analysis based on the Replay Gain algorithm.

mp3gain applies lossless adjustments -- it does not re-encode the MP3. However, MacMP3Gain offers this caveat about mp3gain: "MacMP3Gain modifies MP3 and unprotected AAC files with no provision provided to undo the changes." I haven't had any trouble after using extensively, however.

The MacMP3Gain application does have a GUI, which allows you to process by folder or by iTunes playlist. However, in the spirit of efficiency, I wanted a way to be able to normalize playlists right from iTunes. So I wrote this AppleScript, which can be run right from the iTunes script menu:
(* 

Normalize Playlist

Accepts an itunes playlist as text input,
and normalizes all mp3 files on the playlist
with mp3gain -r (mp3gain itself decides how 
best to normalize).

Prerequisities:

* mp3gain on command-line
* http://homepage.mac.com/beryrinaldo/AudioTron/MacMP3Gain/
* BP Progress Bar
* http://scriptbuilders.net/files/bpprogressbar1.0.html

*)

--Ask the use for the playlist
set myList to the text returned of (display dialog "Enter playlist to normalize " default answer "")

--exit if they didn't enter anyting
if the myList is "" then
 display dialog "No playlist entered" giving up after 2
 return
end if

--make sure itunes is running
--SHOULD BE if it's run from the itunes script menu
--but it could be executed directly
set itunesOK to my itunes_is_running()
if itunesOK is false then
 tell application "iTunes"
  activate
 end tell
end if

tell application "iTunes"
 set oldfi to fixed indexing
 set fixed indexing to true
 
 --see if the playlist exists
 if exists user playlist myList then
  --do nothing for now
 else
  --show error if the playlist doesn't exist
  display dialog "Playlist does not exist" giving up after 2
  return
 end if
 set currentList to playlist myList
 
 --initialize progress bar
 set ProgressBar to load script alias (((path to scripts folder) as text) & "BP Progress Bar Controller.scpt")
 set myTitle to "Normalizing " & myList & " - may take several minutes"
 tell ProgressBar to initialize(myTitle) -- title of progress bar
 -- Start of Script to use ProgressBar Controller
 tell ProgressBar
  barberPole(true)
  setStatusTop to "Initializing Volume Adjustment"
  setStatusBottom to ""
 end tell
 
 --get the number of items on the playlist
 set eop to index of last track of currentList
 
 -- Stop the barber pole, set up for the progress bar
 tell ProgressBar
  barberPole(false)
  setMax to eop -- to match the items to be processed below
  setStatusTop to "Examining playlist"
 end tell
 
 --add a little progress so it doesn't start at 0
 tell ProgressBar to increase by 1
 
 with timeout of 10800 seconds --avoid "event timed out" error
  
  --delete the logfile if it already exists
  do shell script "if [ -e /tmp/mp3gain_output.log ]; then rm -f /tmp/mp3gain_output.log; fi;"
  
  repeat with i from 1 to eop
   
   --write current track to log
   do shell script "echo \"------------ Track " & i & " of " & eop & " ------------\" >> /tmp/mp3gain_output.log"
   
   --get the mac path to the mp3 file, name of the track, and extension
   set i_location to (get location of track i of currentList)
   set i_name to (get name of track i of currentList)
   set theFileInfo to info for i_location
   set ext to name extension of theFileInfo as string
   
   --only do this if it's an mp3
   if ext is "mp3" then
    
    --convert mac path to POSIX path, quote it so we
    --can use it on the cmd line
    set mypath to POSIX path of i_location
    set posixpath to quoted form of mypath
    
    --create our command
    --mp3gain is CPU-intensive, so pass thru nice
    --write output of mp3gain to log
    --this will allow us to report on what changes were made
    set myCmd to "nice mp3gain -r -k -c -q " & posixpath & " >> /tmp/mp3gain_output.log"
    
    --update progress window with status
    tell ProgressBar
     setStatusTop to "Processing file " & i & " of " & eop & " : " & i_name
     setStatusBottom to "Full path: " & mypath
    end tell
    
    --execute the shell command
    do shell script myCmd
   else
    --if track is not an mp3, don't process it
    do shell script "echo \"Track " & posixpath & "is not an mp3...not processing\" >> /tmp/mp3gain_output.log"
    
   end if --end if for is an mp3
   
   tell ProgressBar to increase by 1
   
  end repeat
 end timeout
 
 set fixed indexing to oldfi
end tell

tell ProgressBar to quit

--tell them we're done and ask if they want to see log
set seeLog to (display dialog 
 "Done. Would you like to see the log? " with title 
 "Normalization Complete" buttons {"Yes", "No"} 
 default button "Yes")
set button_name to button returned of seeLog
if button_name is "Yes" then
 --open log in textedit
 tell application "TextEdit"
  activate
  open "/tmp/mp3gain_output.log"
 end tell
end if

--be nice and clean up
do shell script "if [ -e /tmp/mp3gain_output.log ]; then rm -f /tmp/mp3gain_output.log; fi;"

return

--subroutine checks if itunes is running
on itunes_is_running()
 tell application "System Events" to return (exists process "iTunes")
end itunes_is_running
(For possible code updates, as well as a number of screenshots and more detail on the entire process, please see my original blog post.)

The other advantages of this script vs. the MacMP3Gain GUI is that it gives you a proper progress bar (important because it can take a long time to process), and it shows you the output when it's done (so you can see exactly what changes were made to each file).

Prerequisites:
  • MacMP3Gain: Install MacMP3Gain on your Mac. To use this AppleScript, you'll need to create a symlink from the command-line binary to somewhere in your path. This can be done with this command:
    sudo ln -s /Applications/MacMP3Gain.app/Contents/Resources/aacgain /usr/bin/mp3gain
    You can now use mp3gain on the command line. For a complete list of commands, open up Terminal and type mp3gain -?.
  • BP Progress Bar: mp3gain takes roughly 30 seconds to process each MP3. Therefore, it can take a while to process an entire playlist. So, I've configured this script with a handy progress indicator. Applescript has no "native" progress indicator method, but you can access an external app to do this for you.

    Download BP Progress Bar (download link), unzip it, and mount the disk image. Then, copy the app BP Progress Bar to your Applications folder, and the BP Progress Bar Controller.scpt file to your user's Library/Scripts folder, and you're all good to go!
Now, copy and paste the AppleScript to Script Editor, and save it as normalize_playlist.scpt in your user's iTunes scripts directory (/Users » your_user » Library » iTunes » Scripts). This will allow you to run the script from the iTunes script menu within iTunes.

Upon launch, you're prompted to enter a playlist to normalize. As long as you enter a good one, you should see a progress bar come up. Upon completion, you can view the log, which is written to /tmp/mp3gain_output.log.

Enjoy!
    •    
  • Currently 2.38 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (16 votes cast)
 
[27,351 views]  

Use a third-party MP3 volume normalization tool in iTunes | 11 comments | Create New Account
Click here to return to the 'Use a third-party MP3 volume normalization tool in iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use a third-party MP3 volume normalization tool in iTunes
Authored by: excarnate on Jan 07, '10 07:58:43AM

I purchased iVolume, which doesn't have a preference to say "don't check for updates". I noticed this when a major rev came out, I clicked the "never notify again" and everytime he did a minor rev to the new version it would bug me.

As it turns out, iVolume checks in EVERYTIME it launches, which is pretty nasty behavior in my book. I've bought L'il Snitch to block it, frustrating, but I've found L'il Snitch to be an almost must-have for a variety of reasons.

I'm not sure iVolume does anything useful, and older versions aren't available on his website, so if you didn't keep up with v1's revisions, once v2 came out you were screwed.

A good reason to find a FOSS version so I'll be trying your tip, thanks!



[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: jeffbyrnes on Jan 07, '10 12:30:18PM

I've been a user of iVolume for years, and, unlike MacMP3Gain, it doesn't modify the actual audio, just the metadata. It adjusts the property that Apple's Sound Check uses, and it actually uses the same ReplayGain algorithm that mp3gain (and, by extension, MacMP3Gain) uses. If you want your tunes to be even, it's the best possible tool, since it won't alter your audio files themselves (a big no-no, in my book).

---
-Jeff



[ Reply to This | # ]
Don't Give Up on Sound Check
Authored by: salcorn on Jan 07, '10 12:56:20PM

Those having trouble with Sound Check should make sure they have it turned on in both iTunes and their iPod or iPhone. Then give iTunes time to go through and normalized the whole library, and then resync.



[ Reply to This | # ]
Don't Give Up on Sound Check
Authored by: gidds on Jan 07, '10 04:08:08PM

While Sound Check does have some wins (it's built-in, fast, and standard), it has disadvantages too.

For one, it adjusts each track in isolation. I have many albums with continuous music, and I was fed up hearing the volume jump drastically when a loud track ended and a quiet one started. Whereas you can tell iVolume to calculate the level over a whole album and apply the same adjustment to each track in it.

And for another, Sound Check isn't very good at judging how loud a track actually sounds. (A surprisingly difficult task.) So it can still leave unexpected changes in volume between tracks. ReplayGain (as used in iVolume etc.) takes a lot longer to calculate, but does a much better job of approximating human hearing.

iVolume is a pain in some ways (takes forever to start up if you have a lot of music, has its own GUI which doesn't match up with iTunes, and keeps its own database of all your music with details on the adjustments it's made), but I find it just about worth the hassle. I can't compare it with any of the other tools, though.

---
Andy/



[ Reply to This | # ]
Don't Give Up on Sound Check
Authored by: DrLex on Mar 10, '11 06:38:01AM

Sound Check used to be quite good when it was first introduced. But after a few versions, Apple have fiddled with it to make it faster. The main difference between Sound Check and ReplayGain is that Sound Check seems to only sample some parts of each song while RG analyzes the whole song. This makes SC faster but less accurate. If it happens to always sample in the silent parts of a song, it will make the adjustment too loud. And to make it faster, I believe iTunes now samples even more sparsely. I'm not entirely certain of this but it is the best explanation of why it is so much faster than ReplayGain and so much less accurate. I have encountered cases where SC and RG were off by more than 8dB, which is enormous.

I find Sound Check as it is now, useless. It only changes the distribution of too loud and too silent songs. ReplayGain is not perfect either, but it's corresponds much better to what I expect.

There is a middle road between iVolume and (mac)mp3gain, but it's not for the faint of heart. It's a program I wrote myself and it basically does the same as iVolume but without all the fancy GUI stuff, which is why it's free. You need to run the program in a Terminal. Because iTunes' way of handling ID3 tags is plain horrible, it takes specific procedures to make this program work. Reading the ReadMe is a must. But if you have the patience to do it, you can trick iTunes into using the more accurate ReplayGain for its Sound Check adjustment without modifying your MP3 data, for free.



[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: Stormchild on Jan 07, '10 04:09:03PM

Just wanted to say, I've been using iVolume since version 1, and highly recommend it. I'm not a fan of the price doubling with each version, but besides that it's the best tool for the job. It doesn't modify the audio itself (that would be bad, as the audio quality degrades every time you use a lossy compression like MP3 or AAC). Instead, it simply replaces the value of the iTunNorm tag, which is used by iTunes' built-in Sound Check feature -- so it works with iPods as well.

Definitely the way to go, IMO.



[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: mkoreiwo on Jan 07, '10 06:48:18PM

Well, I like the few here, have iVolume, and am up to Version 3. It really is a good program, with a good user interface and lots of flexibility. I've have nothing but good luck with it. I'm not a scripter, so this is an easy way to get the volume adjusted. If the free way works for others - I say thats great, but for those of us a little less savvy, iVolume is worth a look.



[ Reply to This | # ]
The problem with iVolume. (Here's a hint: the developer is delusional)
Authored by: JohnKFisher on Jan 08, '10 01:44:05PM

iVolume is a neat program. it's only drawback is that it's insanely, ridiculously, stupidly, idiotically, delusionally, and insultingly expensive.

If it were a reasonable price, I have no doubt that many more people would buy it. As it is, the developer's greed only means he is LESS successful than he might otherwise be.

I have about 14,000 songs, and I want them all to sound the same, but to spend 30 dollars on an (admittedly excellently executed) wrapper of an open source engine? He's gotta be smoking crack.

Edited on Jan 08, '10 01:49:26PM by JohnKFisher


[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: T0b1 on Jan 09, '10 07:48:51AM

"Note: It has come to my attention that the above "Intel version" of MacMP3Gain is not fully native. The underlying program (aacgain) is still a PowerPC binary and as such, there will be little performance gain. When someone else provides me with an Intel-built version, I'll add the link here. "

-> Better use the Macports version (http://www.macports.org/index.php)
a simple

sudo port install aacgain

is IMHO much nicer than installing an old binary inside an old app.



[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: MacTripper on Jan 20, '10 12:12:34PM

Different EQ settings will change the gain and mess up any attempts to volume level. One has to set a EQ setting across all the songs in a group or genre or playlist, without those songs being included in another. So all Classic Rock can get a Rock EQ, Pop gets a Pop EQ setting and so on without the two genre's mixing. If you mix genres or groups or playlists with different EQ settings, your songs won't be volume leveled anymore. It would be nice to EQ set a playlist that over rides the songs EQ setting though.

Mp3Gain alters the sound files, this is not good. It can only alter the gain so much before clipping occurs and you lose quality and even portions of the songs. If you turn off clipping, then it doesn't truly volume level and you'll get a blast every once in awhile. If you don't care about quality and want to burn cd's then this is the way to go.

iVolume works great and levels the all the songs using the Sound Check feature of iTunes by adjusting to what a person hears. Sound Check levels the gain going out of iTunes or a iPod before it hits speakers or a stereo system without altering the song file itself. As long as you use a device that uses Sound Check, like a iPod or iTunes connected to a stereo system, your fine and won't be grabbing the remote constantly. The price is well worth it in my opinion, I have been happy ever since I iVolumed my 8000 song collection.

And if you update your operating system you have to also update programs as well, so complaining about the price for a update is just idiotic. Snow Leopard offers no real big advantage right now and is prone to a lot of problems.



[ Reply to This | # ]
Use a third-party MP3 volume normalization tool in iTunes
Authored by: mlilback on Mar 10, '11 02:53:19PM

It appears that iVolume is $30 on the developer's website, but $20 in the Mac app store. So I'd have to agree with the conclusion that the developer is delusional.

I'm going to try out id3gain first, though.



[ Reply to This | # ]