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

Lossless adjusting of loudness for MP3 and AAC files UNIX
There is a very common problem with modern CDs -- they are all mastered at different volumes. So when you are just listening to one CD, this is OK: you only need to adjust volume once and listen the whole CD. But if you are converting it to MP3 or AAC formats, and intend to listen to tracks from different albums randomly, the situation gets much worse: having to adjust the volume for each track is really annoying. But without adjusting the volume, the music just doesn't sound right -- it's either too quiet or too loud.

iTunes actually has the ability to fix this kind of problem with the Sound Check feature, but unfortunately the method by which Apple corrects the volume is not the best one -- it definitely changes volume, but it still doesn't sound quite right. I'm no expert at this, but smart people say that volume perception by the human brain is not that simple, and to adjust it properly it should be taken into account.

So here comes another open source tool, mp3gain, which uses a lot smarter method of volume adjustment, and relies on an MP3 format feature to adjust volume gain without transcoding. This means that there is no quality loss. Recently mp3gain was further improved to support the AAC format, and now we have our ultimate solution. It's called AACGain, which supports both MP3 and AAC formats, has a port for Linux, and can be compiled on Mac OS X, too. I tried to find a version of aacgian compiled for Mac OS X, but failed, so I made it myself, and put it on my friend's web server [396KB download]. For more details, check the forums on Hydrogen Audio, the mp3gain web page, and the AACGain web page.

Read the rest of the hint for a few notes...

[robg adds: I have mirrored (396KB download from hints) the above file locally on macosxhints, just in case. And since it's a binary from an unknown source (nothing against the author, but I'm paranoid about such things by nature), I tested it prior to publishing this hint for all of you. After downloading, I ran Little Snitch before launching AACGain, blocking all outbound connections to the net. Little Snitch reported no activity when I tested AACGain on an MP3 file, so I think it's fine -- as with any unknown binary, though, use at your own risk.]

A few notes:
  1. I'm no expert, don't know anything and just compiled it on Panther 10.3.8. It worked fine for me -- tested it on 2,500 MP3/AAC files collection for my iPod, and it works perfectly. Listening experience improved so much, that this is almost impossible to believe!
  2. This is a command line tool and you have to run it from Terminal. It doesn't support music from the iTunes store. And you have to disable the SoundCheck option in iTunes and/or the iPod.
  3. Before you do anything to your music files, please back them up!
  4. It's little tricky to run it properly and it takes time. Here's what I use:
    aacgain -r -p -t -k *.mp3 *.m4a
    The above command will adjust every track in curent directory to 89dB volume. -k means automatically lower this number if clipping may occur, -t is required to make the file as compatible as possible with different players (iPod Shuffle may have problems otherwise), -p means preserve timestamp of file (optional). Also during converting, it will create temporary files (because of -t) and will require disk space of the same total amount as size of original files. So if you are trying to convert 1GB of music, make sure you have 1GB of free space in the directory. If you want to avoid this issue, launch it from a shell script for each file separately. For more details, search the forums on hydrogenaudio.org.
  5. It's also possible to adjust on per album basis -- so all tracks from an album will sound relatively the same, and average volume for the whole album will be 89dB. Use -a instead of -r, and specify only tracks from the same album in the command line.
  6. If you adjust tracks which are already part of iTunes library, you'll need to resync them again in iTunes -- select them all, do a "Get Info," mark some empty field which you don't need (I use Comment), and click OK. It will be erased in all tracks, and tracks will be resynced with iTunes database. You may also move needed files to another location, delete them from the library, readjust, and import again.
  7. Did I mention backup? Don't blame me if something goes wrong :)
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[58,508 views]  

Lossless adjusting of loudness for MP3 and AAC files | 77 comments | Create New Account
Click here to return to the 'Lossless adjusting of loudness for MP3 and AAC files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Mike A on Apr 07, '05 11:13:44AM

I'm a bit new to the terminal, but this sounds perfect for what I want!

Is there somewhere in particular the program needs to be placed, or will it run fine from the desktop?



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jiclark on Apr 07, '05 11:55:08AM

I have about 7000 tracks in my iTunes library, of which I'd say maybe 10% need a bit of a boost. I'm very tempted by this hint, but would love to hear some feedback from some more knowledgeable types before I try it out...

Can anyone tell us more about just exactly how this command line tool does it's thing, and better yet, if it has any downsides?

Thanks,
John



[ Reply to This | # ]
I've used this on my collection (>1000 songs)
Authored by: a1291762 on Apr 08, '05 05:43:59AM

I used the Windows version of mp3gain on my entire music collection (my music is stored on a Windows machine at the moment). It's certainly better then "Sound Check" (just remember to turn sound check off or you won't notice a difference). I haven't noticed any problems yet. The only annoying thing will be remembering to mp3gain any new songs I add to my collection.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 07, '05 12:01:50PM

You may put it in your Home directory and call as "~/aacgain" from Terminal. Or if you want to call it from Desktop call it as "~/Desktop/aacgain" .

The best way would be to create "bin" directory in your Home and add this line to the end of your ".bashrc" file in your Home dir:
export PATH=$PATH:$HOME/bin


Then copy aacgain to that "bin" and after restart of the Terminal you should be able to run it as simple "aacgain" without specifying full path. And you may put other command line tools and scripts to that "bin" directory in future.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: withinavoid on Apr 07, '05 12:09:43PM

Thanks for the compile of this app. However I notice it is version 1.2.0 but the aacgain site has the latest as version 1.3. Can you do a recompile using the newer source code? Thanks again.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 07, '05 12:20:05PM

1.3 is not that much different from 1.2 (1.3 assuming -t as default now and some other small changes) and it's not ported to Linux yet, so I cannot just compile it for Mac - it would take a bit more time and I don't want to mess with source code which I don't understand. Actually I was waiting for that 1.3 and after it's release and few questions to it's author I decided that 1.2 is fine for now.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: gzeus on Apr 07, '05 01:19:52PM
Thanks for compiling it. I'm always a bit confused about the difference between album and track gain, but I think I get the strategy now (anyone who wants a graphical representation of what happens to your original cd through either mode, see this graph ). So my strategy would be to separate my files into two groups:
  1. Complete albums
  2. Singles, which includes albums where I've only ripped the tracks I liked and not the entire album
I'd use the -a flag on the first group, and the -r flag for the second group. I'm thinking this would be the optimal way.

[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: pairof9s on Apr 07, '05 01:55:08PM
This may be something completely different than what this hint proposes, but there is a song volume adjustment within iTunes. If you select a song and key Get Info (Cmd + i), you get a tabbed window containing information on that song. Under the "Options" tab is the Volume Adjustment bar which allows to increase or decrease the volume of the song relative to the player's volume output. I've been using this for a couple of years to help offset this various issue of songs being "too soft" or "too loud" in comparison to the previous tune.

Once again, this could be totally off-base to this hint, but it's a nice feature of iTunes for just such a problem.

[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: chabig on Apr 07, '05 05:02:00PM

This hint is actually using the iTunes volume adjustment, which is just a part of the ID3 tag. The magic is that it sets the volume for lots of tracks automatically, rather than you figuring out and setting them manually.

Chris



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: c15zyx on Apr 07, '05 02:40:48PM
For more information about the ReplayGain algorithms used, see this page: http://replaygain.hydrogenaudio.org/technical_outline.html

[ Reply to This | # ]
Effective on iPod Shuffle?
Authored by: bkuestner on Apr 07, '05 02:59:09PM

Will this change affect how songs are playback on the iPod shuffle?

iTunes normalization was good enough for me when I listened to songs from the iBook. But now with the iPod Shuffle I realize just how different my songs are in perceived loudness.

Will this app fix the problem or will it, too, only work in iTunes (just better)?

Thanks



[ Reply to This | # ]
Effective on iPod Shuffle?
Authored by: atverd on Apr 07, '05 04:47:52PM

I should've mentioned this in original post, but forgot - it MUST work with ANY mp3/aac compliant software or hardware player because the frame gain field adjusted by this tool is basic part of mp3 and aac standards.

iTunes has two methods to fight the problem - Sound Check and Volume slider in tracks properties, but both of them are using proprietary tags and will not work with other players. In addition the Volume tag interpretation is broken in all iPods and it makes this feature practically useless when you want to listen same tracks in iPod and iTunes.



[ Reply to This | # ]
Effective on iPod Shuffle?
Authored by: jiclark on Apr 08, '05 11:50:03AM

We're getting a lot of conflicting info here on this. In a reply a few posts above this one, Chris says that this is just another way of implementing the same 'volume slider' adjustment that iTunes uses. Is this true? If so, does it not work for the iPod, like you say iTunes implementation doesn't??

All this contradictory information is making me leery of trying this, though I'd absolutely love to find something that equalizes gain for iPod playback...

Sincerely,
John



[ Reply to This | # ]
Effective on iPod Shuffle?
Authored by: atverd on Apr 08, '05 12:50:50PM

The result should be same, but ways they implemented are totally different. "Volume slider" is proprietary tag in a track header added by iTunes and it can be interpreted by iTunes and iPods. This would be perfect solution if you are not dealing with other players, but unfortunately iPod and iTunes interpret this value in very different way. iVolume tool uses this feature - try it and check details on it's author's site.
aacgain and mp3gain adjusting volume in totally different way - through frame gain field which is integral part of mp3 and aac formats. So this way is absolutely compatible with any proper implementation of mp3 or aac players.

Overall - if you need both hardware and software playback for your music aacgain is the best solution.
If you need to playback only on iTunes or only on iPod - iVolume is very good tool and a lot simpler to use.



[ Reply to This | # ]
Effective on iPod Shuffle?
Authored by: Anonymous on Apr 09, '05 01:45:33AM

I think there is slight difference: ReplayGain stores 3 parameters in in file's tags. Volume slider setting is remembered as one parameter, I presume. I bet ReplayGain is somehow more sophisticated implementation.

Regards,

Polonus



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: qallunaaq on Apr 07, '05 03:38:11PM

Thank you, what a difference, in both convenience and sound!

Is there a way to get aacgain to process directories and sub-directories or is it really limited to dealing directly with files?



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 07, '05 04:27:09PM

It can work only with files directly. For -r option you may call it from "find" (option -exec).



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jiclark on Apr 08, '05 11:52:38AM

I'm sorry, but that answer is simply greek to me...

Can you be a little more explicit on how to get the tool to work on the standard iTunes folder structure (Artist->Album->Song(s))?

Thanks!
John



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 08, '05 01:05:08PM

I cannot teach you how to write shell scripts, sorry :)

But in a simplest case - just go to an Album directory in Terminal, this is where all those tracks are, and run the above command. This will adjust every song individually with different gains. If you want to preserve relative volume of tracks use option -a instead of -r - this will treat album as one huge track and apply same gain to all tracks.

I'd strongly suggest you to backup your collection and play with aacgain a little - you'll get it in the process a lot faster, this is rather simple actually.
And probably hydrogenaudio forums are better place to ask your questions in future.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jiclark on Apr 08, '05 01:40:36PM

thanks atverd,

I really appreciate all the time you're spending here on the comments!

Later,
John



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jctull on Apr 11, '05 04:34:31PM
You can use this command from the Terminal.app. Open Terminal and cd to your directory that has all of your music, e.g. 'cd ~/Music/'. Next, run the command below, all as a single line argument (no returns):

find -iname "*.mp3" -or -iname "*.m4a" -print0 | xargs -0 -n1 aacgain -r -p -k -t

You can tweak the parameters as needed. I run mine as 'aacgain -r -p -k' because I was getting errors with the -t option.

[ Reply to This | # ]

Lossless adjusting of loudness for MP3 and AAC files
Authored by: jctull on Apr 11, '05 05:03:13PM
Sorry, but the command should read:

find -iname "*.mp3" -print0 -or -iname "*.m4a" -print0 | xargs -0 -n1 aacgain -r -p -k -t

Please add corrections if this is not finding all of the files...

VERY IMPORTANT: Requires a newer version of findutils than is installed by default with OS X. I used fink to install a working version of findutils. If you are not familiar with fink, you can find out about it at http://fink.sf.net.

[ Reply to This | # ]

Lossless adjusting of loudness for MP3 and AAC files
Authored by: Xris on Apr 28, '10 03:56:40PM

I just used the built in find (in 10.5.8 that is):

Here is what I used (after changing to a directory that contains album folders):

xris$ find . -iname "*.m4a" -print0 | xargs -0 -n 1 /Users/xris/aacgain -r -p -k -t -m 4

I don't use mp3's, but you can easily add that if you need to. Note the "." (period) after find, that means "the current" directory, and I used the "-m #" to adjust the recomended gain UP slightly.

One interesting feature that can be exploited to great effect is the "-P" switch in xargs. This enables you to launch/start MULTIPLE instances of you comand, aacgain in this case, for every match found with find. I have a Core 2 Duo machine. Using only ONE instance of aacgain is a very lengthy process that does not tax the cpu very much... but with "-P 4" I get almost 100% cpu usage and takes a, well, almost half as long. I probably would get the same result with two, but just for kicks I went with 4!

So, the above looks something like:

find . -iname "*.m4a" -print0 | xargs -P 4 -0 -n 1 /Users/xris/aacgain -r -p -k -t -m 4

BTW: I could't get fink/macports/darwinports to install properly, I gave up on that and just fiddled with the buil-in version to get it to work. Ahh, also, I used the intel version of aacgain linked somewhere in this link.

As far as I'm concerned, aacgain works, although I did adjust the gain slighly up. On some stereos, thru the mini 3.5" plug, even at max volume it was a bit quiet for my taste.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: sanzoghenzo on Feb 10, '11 03:39:39AM

Thanks for the hint!
I prefer to use album gain, and use only mp3 files.
The following will do the job:

find . -type d -exec sh -c 'set -- "$0"/*.mp3; [ -e "$1" ]' {} \; -print0 | xargs -P 4 -0 -n 1 -I % sh -c "aacgain -a -p -k -m 4 \"%\"/*.mp3"

This, in conjunction with beets and pylywi will tidy up your collection from CLI!



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: JayMann on Apr 07, '05 04:34:10PM

As a rookie to the terminal, when I run aacgain, I get an "abort trap." I have been able to run aacgain -? (i.e. get the command screen). And I took a dozen .m4a files and put them into the home directory but even when I completely spell out only one file I get the same error code.

Where am I going wrong?

JayMann



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 07, '05 04:54:46PM

Make sure you don't have files from the iTunes store in that list, also all files must be aac or mp3. If one of them is in Apple Lossless format f.e. it will have m4a extension too, but this is not aac and aacgain will abort. As far as I understand it will abort on any file which it doesn't understand.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: JayMann on Apr 07, '05 10:51:26PM

atverd,

If your checking back, thanks. I was the "other" m4a.

JM



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: neuralstatic on Apr 07, '05 04:58:46PM

i wish someone would make a really nice gui for this.

i've used the windows verson on over 40,000 mp3's, and i really love it. quality, speed and convenience wise.

that being said, it's a great tool for any file on any platform



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: withinavoid on Apr 11, '05 12:52:55PM
There is a GUI here:
MacMP3Gain

It is an older version however, and does not support AAC. The code is available so perhaps someone with the know-how will update it to support the latest aacgain source at some point.

[ Reply to This | # ]
"Lossless" is a red herring
Authored by: chabig on Apr 07, '05 05:04:21PM

The title of this hint is claiming a bit too much. Adjusting the volume of a song is almost always a lossless process. In fact, I am not aware of any way to alter the volume or a digital music track lossily without opening the file in a waveform editor.

Chris



[ Reply to This | # ]
No, it's really lossless
Authored by: gzeus on Apr 07, '05 07:39:25PM
It's a lossless process because it just updates the id3 tag. If you were to rip a cd-audio file to mp3, it would be a lossy copy because you wouldn't be able to get the original back. But aacgain writes to the id3 tag, which is completely reversible. Perhaps you might introduce clipping if you amped up the gain too high, but the windows version of MP3gain will tell you if this happens. Google it to find out more.

[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: mproud on Apr 07, '05 05:51:31PM
I use Octiv's Volume Logic plug-in, which processes the sound level on the fly, and sounds pretty good to me. (30 days to try, $20 to buy.)

[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: caesurae on Apr 08, '05 10:10:15AM
Indeed...I bought the Volume Logic plugin about six months ago or so, very useful little gadget. I'd like to get Octiv's break out box w/ this technology for my TV setup.

[ Reply to This | # ]
iVolume
Authored by: wolfy on Apr 07, '05 06:04:59PM
How does this compare with iVolume, which sounds like it does the same thing, only graphically? Okay, iVolume costs a few bucks to register, but other than that, is there any reason to use AACgain instead?

---
Wolfy

[ Reply to This | # ]

iVolume
Authored by: atverd on Apr 07, '05 06:14:49PM

I bought it some time ago and actually like it, but it has fundamental problems - because of bug in iPods you can adjust your music either for iPod only or for iTunes only (it even has special option for this). Also this method will work only for iTunes and iPod and no other players.
I tried to contact the author and asked him if he is going to implement this method in the tool, but got no answer. Unfortunately it looks like he just lost interest in this project.



[ Reply to This | # ]
iVolume
Authored by: chabig on Apr 07, '05 06:24:56PM

I've been in touch with the author of iVolume. I don't think he lost interest in the project. Apple's DRM killed his ability to process ITMS files.

Chris



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Interactive on Apr 08, '05 01:35:12AM

I would second VolumeLogic for this purpose. It does it as hands-free as can be.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 08, '05 09:35:24AM

I used one of Doug's AppleScripts for iTunes and modified 'Delete Sected Files' script to execute aacgain as a shell command for selected tracks. Unfortunately, the '-t' option for creating temporary file doesn't work and the changes are not written to the track file. Looks like the aacgain tool cannot open temporary file when executed from within AppleScript instead of real command line. Can anyone help with it? Thing works as it is, but there are suggestions it can cause problems with i.e. iPod Shuffle.

---
--
Pawel POLONUS Soltysinski
priv: polonus@webnet.pl



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 08, '05 11:40:55AM

Probably you don't have wright permissions in the directory it's trying to create temp. files.



[ Reply to This | # ]
Wouldn't this screw up burning albums as Audio CD?
Authored by: caesurae on Apr 08, '05 10:16:11AM
This AACGain thing seems like it would screw up burning an album as an Audio CD since each track's gain is adjusted individually. What a mess that would be!

Let me be the 3rd person to suggest that everyone check out Octiv's Volume Logic. This iTunes plugin achieves what Sound Check claims, and much more. Take advantage of the 30 day trial, you won't regret it.

Definitely preferable to editing thousands of mp3 files.

[ Reply to This | # ]

Wouldn't this screw up burning albums as Audio CD?
Authored by: atverd on Apr 08, '05 11:38:45AM

Guys, this volume logic has nothing to do with aacgain - this is iTunes plugin and works only for iTunes and no other software and hardware players. Also it consumes a lot of CPU and changes a lot of things in played music besides volume. I tried it many times before and overall I find it too intrusive into system and sound.



[ Reply to This | # ]
Wouldn't this screw up burning albums as Audio CD?
Authored by: atverd on Apr 08, '05 11:48:12AM

Regarding albums - there is option -a (described in the original post) which is designed specifically for these cases, it will adjust an album as whole and you may burn it later without any problem. For random playing -r would work better, but -a will have positive effect too.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Pedro Estarque on Apr 08, '05 11:20:24AM

I also love Volume Logic, but have you seen how much of a CPU hog it is ?
It can take up to 30% on my 1Ghz G4, while iTunes uses 5%. No more Photoshoping and listening to your songs.
I think its much more useful to analyze the file and save the result then do it in realtime. Although the latter has more potential to produce better output.



[ Reply to This | # ]
About VolumeLogic
Authored by: c15zyx on Apr 08, '05 01:24:57PM

Uhm, there is a significant difference between SoundCheck/Replaygain adjustment and what VolumeLogic does. VolumeLogic can do a better job in making sure all parts of the music are equal volume, but it will *destroy* the dynamic range for more quiet passages of songs. To preserve the dynamic range as it was originally intended, you adjust the perceptual gain for the whole file/album, not specific passages within songs. ie. One song has a louder part followed by an intentionally softer part... normal gain techniques keep this difference, but with VolumeLogic it will applies compression on the softer segment to maintain volume, even though that's not how it's supposed to be!



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 08, '05 02:43:32PM

With AACGain binary as compiled by ATVERD and a couple of Doug's scripts for iTunes I managed to prepare scripts for iTunes to make use of AACGain a lot easier.

So, all the credits must go to original authors of AACGain, ATVERD and Doug Adams (http://www.malcolmadams.com/itunes/).

The modifications are probably of baaad coding ;) but works.

The aacgain binary is put into /Library/iTunes/Scripts folder together with 4 scripts:

AACGain Selected Files
AACGain(+20) Selected Files (this pumps up gain by 20, i liked it with my iPod)
de-AACGain Selected Files

All the best,

Pawel / aka Polonus

You can download the installer here:
http://www.polonus.csv.pl/AACGain_with_iTunesScripts.zip



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 08, '05 04:02:06PM

...and do not try AACGAIN on .m4a lossless files!! It can delete your original files instead of correcting tag values in them :)



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 08, '05 05:31:42PM

aacgain will NOT delete file of unknown type (apple lossless, aiff and so on). It will abort immediately. I tested this.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 08, '05 05:39:22PM

But the original advise is still very good - who knows what it may decide about those formats, just keep it away from non-aac and non-mp3 files.
And backup is your friend :)



[ Reply to This | # ]
I appreciate
Authored by: jmdennis1967 on Apr 09, '05 05:11:04PM

I for one appreciate this. I would like to have one thing added though. It would be nice if you could add a count of some sort so a person knows how many have been done already and that it is working. For me I have an older powerbook and I let this run about 5 hours and all it showed was the area blue where you put the scripts so I could not tell how far it had gotten. I was able to force quit iTunes and found out that about half where done in that time. I know it will not always take this long but it would be helpful to have some sort of way as to know it is actually working. I know that when the iPod is being updated it will go down the list of songs to show you were it is at. It will also from time to time let you know how many songs have been added so far. Some thing like this would be great. I know it is just applescripts but for me it would be nice to see that it is working so I do not quit on it.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: pmbuko on Apr 08, '05 03:52:53PM

Wow. This takes a really long time per track. (I'm on a 1.42Ghz Mac mini.) Also, I let iTunes keep my music library folder organized, so there's no simple command line to convert the entire library. Time to start scripting!



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jctull on Apr 11, '05 04:39:42PM

See my post above using find and xargs.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 08, '05 04:35:51PM

I put under the same address:

http://www.polonus.csv.pl/AACGain_with_iTunesScripts.zip

The new version of scripts installer. This version checks whether track has bitrate higher than 320. If it is higher - doesn't attempt to use AACGAIN since it doesn't know how to handle non MP3 or real AAC file. All lossless files (Apple Lossless, AIFF etc.) have higher bitrate than 320 - so we simply skip them.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: tanvach on Apr 08, '05 08:28:46PM

First of all, thanks for your excellent script. However, I'm having trouble with foreign ID3 songs (Unicode), which would simply give a completion dialog without processing the files! I hope there's an obvious fix to this, but for the moment most of my songs now sound great!



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 09, '05 01:33:04AM

the problem is some of your songs have non ascii characters in the filename. Hmm... I'll look into it, maybe this is to be fixed. Another problem is I need to provide support for music tracks existing on other partition than system's one :) A basic flaw in aacgain itself.

All the best :)

Polonus



[ Reply to This | # ]
One suggestion ...
Authored by: gzeus on Apr 09, '05 03:23:13AM
Great script. In order to allow you to keep track of which songs you've aacgained, here's a change you can make to the script to update the seldom used 'grouping' field. Instead of
set oldcomm to t's comment
set t's comment to " "
set t's comment to oldcomm
use
set t's grouping to " "
set t's grouping to "AACGained" 
(For whatever reason, I had to set the grouping field to " " first before it would accept any further changes.) For the De-AACGain script, you would just change the 3 original lines to
set t's grouping to ""
Now just show the 'Grouping' column in iTunes to see which songs need to be aacgained.

[ Reply to This | # ]
One suggestion ...
Authored by: Anonymous on Apr 09, '05 05:05:48AM

Thank you :)

I used your suggestion, the manipulation with comment was the way to force iTunes to notice there is a change in tags. Using grouping has more sense. I just put new version at the same URL as before. This version includes your suggestion and deals with files on another partitions etc.

Regards,

Pawel /Polonus



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: oink on Apr 09, '05 12:24:11AM

I encountered something strange with this program and my ipod shuffle. I ran it this morning to batch process my 200 or so aac files using just the -r switch. Later in iTunes, I expected to see various volume adjustments within "get info" but they all showed no adjustments. Uploaded some files to the ipod shuffle and they either crashed the ipod, hanged the ipod, or shuffling through silence song files, basically no sound was heard and I didn't seem to be able to do anything but turning it off. I initialized it twice and eventually figured it might have been the adjusted files. I tested it with freshly encoded files from CDs and they work fine on the ipod shuffle. I am trying to undo using the -u switch but it only works with some of the files. Can anyone else confirm this?

---
blurred visionary



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 09, '05 01:29:06AM

it is important to use -t option when processing files for use with iPod Shuffle. You can undo tracks rendered unusable by:

aacgain -t -s d <track file>

Or you can use scripts as I prepared end mentioned them in one of my posts.

Regards,
Polonus



[ Reply to This | # ]
Lossless adjusting & iPod Shuffle
Authored by: blubbernaut on Apr 10, '05 09:26:13PM
iVolume is a lot easier to use (with options to auto detect albums) and works only on the tracks you have currently selected in iTunes. It also remembers which tracks its already analysed, so it doesn't spend time redoing it (unless you ask it). AND most importantly the adjustments get carried over to the iPod shuffle. Make sure you select the iPod option. That means the when played in iTunes, the adjustments aren't as good, but at least your eardrums wont bleed when listening to the shuffle!

[ Reply to This | # ]
Lossless adjusting & iPod Shuffle
Authored by: jmdennis1967 on Apr 11, '05 03:47:52PM

This may be easier but it also cost money to use this program for more then 20 songs. I for one like the other program being free and if you have already done the gain on some songs you can just select the songs you have not done this one and do it on those all for free. I like the look of iVolume but have not really tried it since it will only do 20 songs. I used the free applescript that was written and this seemed to do a great job for me so no need to use iVolume.



[ Reply to This | # ]
Lossless adjusting & iPod Shuffle
Authored by: jctull on Apr 11, '05 05:15:54PM

I paid for iVolume some time ago, but prefer the aacgain approach because (1) it's free, (2) it seems to be more actively developed, and (3) there is not need to futz around with Apple's volume slider bugs with the iPod. Number 3 is a huge pain in the arse. Further, I seem to detect distortion in songs adjusted via iVolume/iTunes Volume Slider.

Number 4 would be the fact that I host my songs on a separate server volume that I access via AFP (either on a LAN or via ssh tunneling on a WAN), and I like being able to run a command line tool to do the work on my server without my attention being required. I execute the command from within 'screen', then I can detach it and let it run without requiring an active ssh connection.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 12, '05 01:18:44AM

I've update aacgain from version 1.2 to 1.4.
There is no need to readjust anything if it worked before!
No changes affecting MP3 - only for AAC.
Changes:

1. For AAC files -t is always assumed now, this is mostly for higher compatibility with iPod Shuffle.

2. Bitrates in AAC headers are not changed any more and should look same in iTunes before and after adjusting.

3. Important fix for temporary AAC files placement - now they will be always placed to the same directory with source file (file looks like tmp*.mp4). Now it's possible to run aacgain from any location against files on other disk volumes.

Link is same.

Thanks to Dave Lasker for fixing these issues and Prakash Punnoor for porting the source code to Unix!

http://www.lexa.ru/andyt/aacgain/aacgain_mac_os_x.zip



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: Anonymous on Apr 12, '05 03:21:24AM

I have replaced the old binary with a new one in my scripts' installer. The location is the same.

Pawel / Polonus



[ Reply to This | # ]
non ascii characters supported?
Authored by: kaz219 on May 03, '05 10:39:18AM

Does the new version of the script work with non ascii characters?
I have russian and chinese music for example, so I need the full unicode set...
Cheers, kaz.



[ Reply to This | # ]
non ascii characters supported?
Authored by: atverd on May 23, '05 01:44:44PM

It works fine with unicode headers. I converted a lot of such AACs and all of them still displayed properly in iTunes and iPod.



[ Reply to This | # ]
non ascii characters supported?
Authored by: kaz219 on May 31, '05 10:45:29AM

The completion dialog is prompted even if there is non ascii characters in it, and the file is still displaying correctly in iTunes, but my question was "Is the file really processed or not?"

In a previous version, it was not, as testified by polonus itself (see his comment on non ascii characters), and I want to know if it does now.

I think I will decide myself to give it a try...



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: joshburnett on Sep 07, '05 05:14:09AM

I'm using v1.4 of aacgain, and I've noticed that the '-s d' option doesn't seem to be doing its job. (That's the option to de-AACgain the file) I've created a copy of my original file (appending ' copy' to the file name), then run 'aacgain -r -p -t -k' on the file. In iTunes I can definitely hear the difference. But when I then run 'aacgain -s d' on the file, I still hear the difference in iTunes.

Also, I've used Polonus' script (nice work!) to try this out, with the same results. I run 'AACgain selected files' followed by 'de-AACgain selected files' and there's still a difference between the original and the modified file.

Any idea what's going on here? Yeah, yeah, I've backed everything up, but I'd still like my changes to be reversible, since the program claims it is.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jhpadilla on Apr 14, '05 11:41:01AM

Ok, something is just wrong. I have the latest ACCGain (1.4) and I have the scripts installed and SoundCheck turned off. No difference whatsover.... Even with Gain +20 I can't hear any difference.

I've also tried deleting the original file from the itunes playlist, modified it, and they re-add it to no effect either....

What am I doing wrong ?!?!

---
PowerBook G4 1.33/SuperDrive/10.3.8/768 MB ram



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Apr 14, '05 02:05:00PM

Try it without scripts first.
1. Copy couple of tracks from iTunes to your Home f.e.
2. Rename original tracks in iTunes in some reversable way (Add "original" to the title end of each track f.e.).
3. Put aacgain to your Home too.
4. Run it like this from Terminal: ./aacgain -r -p -k "name of track1" "name of track2"
Enclose each name in quotes ("") and separate names by space.
5. It should show you a lot of things and among them at the end it will tell how much gain it added or removed. If it says "no adjustment needed" then your track already fine and you will not hear any difference. Otherwise go next.
6. Import them to iTunes and play original and imported - even with gain 1 you should be able to hear the difference.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jhpadilla on Apr 18, '05 11:31:59AM

Thank you very very much for the step-by-step!!!

I will try this out today and let you know the results!

---
PowerBook G4 1.33/SuperDrive/10.3.8/768 MB ram



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jmdennis1967 on May 13, '05 02:06:29PM

I for one would like to see a graphical interface for this kind of like iVolume. It would also be nice to see the changes that were made. I am using the applescripts but it wold be nice to see more then just a comment that they were aacgained. I would like to see exactly what it did to the music. I can hear the difference as now when I listen to my iPod I do not have to turn up the volume or turn it down as each song plays now. I would just like to be able to see what changes were made. I for one like graphical so I can see what is being done and also how far along the process is.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: okto on Jun 02, '05 02:04:04AM
I wrote a shell script to go thru the ~/Music/iTunes/iTunes Music folder and AACGain everything.
I didn't like that Polonus' AACGain iTunes scripts locked up iTunes while they ran (not by fault of the author, that's just how iTunes works--thanks for the work on that, Polonus!), so I thought to myself, "Self, we have a recursing script to write M3U playlists. We could probably hack that into a script to AACGain the contents of the iTunes library, and still be able to play things in iTunes."
Self was right (no, I don't have MPD :P), and here you go.
It's not that complex, just some nested foreaches, but it works well. Feel free to distrubute/modify/include, just drop me a line if you find it useful, modify it, or incorporate it in something else.

#! /bin/tcsh 
#! //okto 2005 
#! Recursively runs aacgain (http://altosdesign.com/aacgain/, 
#! http://www.lexa.ru/andyt/aacgain/aacgain_mac_os_x.zip) 
#! on your iTunes library.

# it breaks otherwise. not quite sure why.
set nonomatch
cd ~/Music/iTunes/iTunes\ Music/

foreach ARTIST ( * )
echo next artist
	if ( ! -d "$ARTIST" ) continue
	echo "artist: $ARTIST"
       cd "$ARTIST"
	foreach ALBUM ( * )
		if ( ! -d "$ALBUM" ) continue
		echo "		album: $ALBUM"
              cd "$ALBUM"
#if you do ``*.mp3 *.m4a'' it fusses about it
		aacgain -r -p -t -k *.m*
		cd ..		
	end
	cd ..
end


[ Reply to This | # ]
Shell script to AACGain files
Authored by: okto on Jun 02, '05 02:05:41AM
I wrote a shell script to go thru the ~/Music/iTunes/iTunes Music folder and AACGain everything.
I didn't like that Polonus' AACGain iTunes scripts locked up iTunes while they ran (not by fault of the author, that's just how iTunes works--thanks for the work on that, Polonus!), so I thought to myself, "Self, we have a recursing script to write M3U playlists. We could probably hack that into a script to AACGain the contents of the iTunes library, and still be able to play things in iTunes."
Self was right (no, I don't have MPD :P), and here you go.
It's not that complex, just some nested foreaches, but it works well. Feel free to distrubute/modify/include, just drop me a line if you find it useful, modify it, or incorporate it in something else.

#! /bin/tcsh 
#! //okto 2005 
#! Recursively runs aacgain (http://altosdesign.com/aacgain/, 
#! http://www.lexa.ru/andyt/aacgain/aacgain_mac_os_x.zip) 
#! on your iTunes library.

# it breaks otherwise. not quite sure why.
set nonomatch
cd ~/Music/iTunes/iTunes\ Music/

foreach ARTIST ( * )
echo next artist
	if ( ! -d "$ARTIST" ) continue
	echo "artist: $ARTIST"
       cd "$ARTIST"
	foreach ALBUM ( * )
		if ( ! -d "$ALBUM" ) continue
		echo "		album: $ALBUM"
              cd "$ALBUM"
#if you do ``*.mp3 *.m4a'' it fusses about it
		aacgain -r -p -t -k *.m*
		cd ..		
	end
	cd ..
end


[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: paxman on Jun 19, '05 08:10:47PM

Does this work for .mov files that have an AAC soundtrack? And I assume that this app physically changes the AAC file's volume tag, rather than just the iTunes database like iVolume seems to do. I would LOVE iVolume if it made changes to the actual music/video file rather than just the iTunes db. Then the volume tags would work in other apps such as Megaseg, etc.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: atverd on Dec 27, '06 12:44:28PM
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jctull on Jul 24, '07 06:40:55PM

I keep getting an "Error: invalid file format" on all of my .m4a files, so this effectively only works on mp3s. This is on a Macbook Pro C2D.



[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: tjbx on Oct 03, '09 07:14:58AM

Anyone know where to get Pawel's applescripts now? The referenced link is dead.



[ Reply to This | # ]