This is my cyberhome!

October 15, 2010

How to fix gapless analysis problems in iTunes?

Filed under: Apple,Audio,Software — Manish Bansal @ 3:56 pm

The Problem:
If you use iTunes, on windows or mac, it is inevitable that you’d come across this dialog where iTunes says that it’s Determining Gapless Playback Information. It doesn’t matter whether you want your albums to play gapless or not. iTunes just goes ahead and does it. There is no way to turn it off. It would have been pretty harmless, except for one little thing – it often gets stuck and the only way out is to reboot your computer (and lose any unsaved data, not to mention the frustration caused). Though there is no way to turn this process off, there is a way to make it go smooth. The solution is to repair your corrupt MP3 files.

The Reason:
There are plenty of reasons for MP3 files being corrupt but the most common one is bad encoders. All the modern encoders are ok but those present during Napster era (late 90s and early 2000s) were really bad. So if you have any songs encoded during that period, chances are that they are not as per MP3 encoding standards. These songs would play just fine but otherwise cause a lot of problems in terms of tagging and gapless analysis etc. If you do a scan on your collection, you’d be surprised by the number of songs with potential problems. These kind of files are the reason iTunes gets stuck.

The Fix:
The fix is pretty simple, fortunately. All you need is foobar and a bit of time. Don’t worry. The songs will NOT be re-encoded or subject to anything else which might reduce their audio quality. These operations are completely harmless. You can take a backup in case you’d like to be really careful.

Ok, here we go:

  1. Download and install foobar. Make sure that you choose all the utilities and extras during the install.
  2. Launch foobar and go to ‘File -> Preferences -> Shell Integration’. In the right-hand side pane, enable the option ‘Folder context menus’. In the same pane, type ‘*.mp3’ for ‘Restrict incoming files to’. This will make sure that only MP3 files come into foobar as this fix is not applicable for AAC or WAV files etc.
  3. Go to your songs folder in Windows explorer, right-click and choose ‘Enqueue in foobar2000’. Or you and drag your songs folder to foobar.
  4. In foobar, Select all files, right-click and choose ‘Utilities -> Rebuild MP3 Stream’. This will recreate the MP3 file by removing all the non-standard data and other garbage. It will also fix the tags by rewriting them in a standard-compliant way. It took about 3 hours to fix 20k files on my aging PC. A nice side benefit of this fix is that a few more songs will now show up in your iTunes library because of standards-compliant tags.
  5. Once step 4 is over, select all files again, right-click and choose ‘Utilities -> Fix VBR MP3 Header’. This will add the missing VBR header data to the Variable Bit Rate files. The absence of this header causes problems in seeking and also in calculating the duration of song which impacts gapless analysis. This process also took about 3 hours on my somewhat old PC.
  6. This step is optional but I did it anyway. Clean up your iTunes library and add all the songs again. The only thing I care about is song ratings which I store in BPM field so I don’t lose them even if I clean up the iTunes library.
  7. Let iTunes go through ‘Determining Gapless Playback Information’. Typically it won’t get stuck now but there are chances that it still won’t like a few of the songs. The only fix for these songs is to remove them from iTunes library. In my case, I had about 1000 songs in a particular folder which were giving problems. These were the songs which I had converted from FLAC to MP3 a long time back, prehaps using a crappy non-standard encoder. I just removed these songs from iTunes, re-encoded them from FLAC using Lame and everything went fine.

Notes:
To validate your MP3 files, you can use a free program called MP3val. It can even fix some of the common problems.

July 4, 2006

How to install Mac OS x86 on a PC

Filed under: Apple — Manish Bansal @ 8:34 am

I have finally managed to install and boot into (these are two separate things in this context as will soon become clear) Mac OS x86 on my PC after struggling for more than two weeks. I used HotISO 10.4.6 install DVD. I don’t know much about legal stuff but it is probably illegal to do this without owning apple hardware. I own an iBook G4 so maybe it is ok. I don’t know. Please don’t quote me on this.

Before the install:
These are the things that you have to take care of before you start the install. 90% of people asking for help in the forums are there because they did not pay attention to this part. So before you start-

  1. Make sure that your DVD drive is set up as primary slave. If it is not, you would still be able to install the OS but you won’t be able to boot into it. It would say ‘waitng for root device’ or ‘b0 error’ and just hang there. Or the PC would keep on rebooting itself. Some of these problems can be fixed if you are able to boot from the DVD and go into terminal but you won’t be able to boot from the DVD either (after the install).
  2. Both your keyboard and mouse should either be PS/2 or both should be USB; you cannot mix and match. If you do, you won’t be able to boot into the OS after the install. It would complain about keyboard being not present and just stop there.
  3. Make a primary partition while you are in Windows. You can use Partition Magic or any other such tool to do non-destructive partitioning. Once created, mark this partition as ‘Active’ otherwise you won’t be able to boot into Mac OS X. You don’t have to format it at this point.
    You might want to make the size of the new partition sufficiently different from the size of Windows partition so that they are easy to tell apart in the Mac OS installer. A minimum size of 6GB is needed though.
  4. You don’t need Linux, fdisk, Acronis OS selector or any other such tool. Whatever you need is right there on the DVD itself. Some people suggest sacrificing a goat but I doubt if that’ll be of any help.

Install process:

  1. Boot off the install DVD and keep clicking until it’s time to choose the volume on which to install Mac OS X. The list would be blank as of now. Go to ‘Utilities –> Disk Utility’. The left side of the panel would now show all the partitions. Select the one you want and click on ‘erase’ tab in the right-hand panel. Choose ‘Journaled’ as the file-system, name the volume, and click on the ‘erase’ button. Try to avoid naming this volume with spaces in the name like ‘Mac OS X’ etc. I named this volume as ‘Tiger’. This kind of name would come in handy if you have to launch the terminal and copy files here and there.
  2. The next important panel is ‘Installation Type’. Choose ‘Custom’ and it would show you the list of packages to be installed. Pay attention to the last entry there which contains the patches and other drivers which make this whole exercise possible. Select only those patches here which match your system hardware. So if you have an intel CPU, do NOT select anything related to AMD. This is important. If you are not sure whether your CPU supports SSE2 or SSE3, download this small standalone utility. Again, select SSE3 only if your processor supports it.
  3. Sit back and relax.
  4. Installer would reboot automatically when it’s done and Mac OS X would start. Go through the simple setup process and enjoy.

Post-install:
If only computers were so simple! Post-installtion help forums on OSx86 project are a good place to start if you are having any problems with your setup. Make sure to go through the Technical FAQ first.

Credits:

  1. Niall Douglas’s page on installing Mac OS x86
  2. OSx86 project

May 23, 2006

Kernel Streaming with iTunes.

Filed under: Apple,Audio,Software — Manish Bansal @ 5:36 am

iTunes is considered to be the best music organizer and foobar to be the best music player. But what if you could have the interface of iTunes but guts of foobar in one application? Enter Multi-plugin.

Here is what you’ll need:

  1. foobar (0.9.4) and Kernel Streaming plugin for foobar.
  2. iTunes (for Windows, ver 7.0.1)
  3. Multi-plugin (latest version is 2.4.2 as of September 22, 2006)

Install iTunes, foobar, and Multi-plugin. To install Kernel Streaming plugin for foobar, just copy the file “foo_out_ks.dll” to foobar components directory.

Run foobar, go to file-> preferences -> playback -> output and choose Kernel Streaming as the output method.

Run iTunes, go to Edit -> preferences -> Multi-plugin and make the following changes:

  1. Under “Appearance”, choose the default skin.
  2. Under “Other”, choose “foobar2000 passthrough”.

Now whenever you hit play on a song in iTunes, it would be played through foobar. This means that you get access to all the foobar DSP goodness too. Enjoy!

Notes:

  1. You might get the message “foobar not installed” when you enable “foobar2000 passthrough”. This happens because Multi-plugin looks for foobar information in the wrong place in the registry. It’s pretty easy to fix though. Just transfer the keys from “HKEY_LOCAL_MACHINE\Software\Foobar2000” to “HKEY_CURRENT_USER\Software\Foobar2000”.
    To do that, go to “HKEY_LOCAL_MACHINE\Software\Foobar2000” in the registry and choose File->Export. Then open the resulting *.reg file using notepad and change “HKEY_LOCAL_MACHINE\Software\Foobar2000” to “HKEY_CURRENT_USER\Software\Foobar2000”. Save the file and double-click. Done!
  2. You need to set the volume to maximum in iTunes to avoid any loss of quality because of attenuation.
  3. Even if you don’t notice any improvement in the sound quality, this would at least take care of the songs skipping in iTunes (a big problem in iTunes 7.x.x).
  4. You can not run both foobar and iTunes at the same time. Otherwise you’d get error “KS output error: error opening device”. In fact, you don’t have to run foobar to use Multi-plugin. iTunes would launch it automatically in the background.

Update on September 20, 2006:
Links now point to the latest version of Multi-plugin, 2.4.2.

February 10, 2006

How to rescan a folder in iTunes and keep song ratings.

Filed under: Apple,Audio — Manish Bansal @ 11:13 am

How to update/rescan your iTunes library if you have:-

Added new songs:
This was one of the most frustrating thing about iTunes. I would add a few songs to a folder which had already been added to iTunes but there was no way to tell iTunes to rescan that folder and pick only the updated songs. Every other jukebox software I know has this feature. Winamp even lets you schedule when you want to rescan the folder!
What did I know. This is actually simpler in iTunes. Just add the folder again to iTunes. If you have not moved the existing files from their previous location, have not renamed them, or done anything else to them, they would be ignored and only the new files would be added. All the old songs would maintain their playcount and rating etc. I regularly point iTunes to my top-level song folder and they get added just fine.

Updated tags outside iTunes:
I use GodFather to edit ID3 tags for my mp3s but since iTunes maintains its own database, the changes are not visible in iTunes. You can clean your iTunes library and add those songs again but you’d lose playcount and rating. The correct way to make those changes visible in iTunes is to select all files (using ‘Ctrl-A’), click on ‘Get Info’, and click ‘Ok’. iTunes will pick up all the tag changes without losing playcounts or ratings. Do NOT check any of the checkboxes for any of the tag fields. You’d nuke all your tags. Just click ‘Ok’ and it’d be done.

November 8, 2005

How to fix iPod Eq distortion.

Filed under: Apple,Audio — Manish Bansal @ 6:36 pm

The Problem:
iPod gives a somewhat harsh and metallic sound when the equalizer is turned on. It does not matter which preset you choose (except Flat). If you don’t keep the equalizer off, the sound comes out distorted and is not pleasant to listen to. It happens on all the iPod models, even on the latest 5G one which has the best sound among hard disc based models. The 5G fixes lot of problems with the earlier iPods like Noise Defect and comes with a number of improvements, especially in bass performance but the sound still clips with the equalizer.

The Reason:
There is nothing wrong with iPod. Really.

It has as good a sound as any other player. Though it sounds a little bright, the sound has lot of detail and really insignificant amount of distortion. Even the equalizer is well designed and behaves as it is supposed to. But that metallic sound? That clipping? Well, it’s a classic case of “garbage in garbage out".

It’s those damn mp3s. Or rather the original CDs themselves.

In a race to sound louder and louder, the CD mastering engineers push the recording level to its limits. This is especially true for mainstream pop/rock music. Somehow the producers think that the CDs have to be really loud to make a better impression.

Now when these hot mastered CDs (or mp3s made from them) are played with the equalizer on, the total loudness level goes beyond what an iPod can produce. Some of my mp3s had a loudness level of 99.6db!! Yikes! What can the poor iPod do when presented with this crap? Say I choose Dance preset which would typically apply a boost of 6 db. Add this to 97db (a typical figure) and you get a level of 103 db. Most players have an upper limit of about 95db, some even going till 100db but that’s it. No wonder the sound comes out distorted and harsh.

The Fix:
All we need to do is bring down the loudness level of the mp3s down so that we get a little headroom to apply the Eq. The generally agreed upon loudness level for this is 89db.

Download mp3gain. It’s an open source freeware program. Add the folder containing the mp3s. Choose ‘track gain’ and click on the ‘track analysis’. It will calculate and display the loudness level for each song and also how much correction needs to be applied. When this analysis is done, just hit ‘track gain’ and it will apply the required correction to each song.

Mp3gain does not re-encode or otherwise modify/degrade the file in anyway. All it does is set a flag in the file. When a player reads this flag, it knows how loud to play this song.

This whole correction process is a little slow. It took about one hour per GB on my Pentium 4 machine, 30 hours total for my entire collection. It’s the analysis part that is slow. The correction is instantaneous. So instead of hitting the analysis and waiting for 30 hours to do the correction, a better way to do this is to hit the track gain directly. It will analyze and correct in one step.

After all this is done, erase all the songs from your iPod, resync, and enjoy!

Notes:

  1. You can directly point mp3gain to iPod_control folder on the iPod but it is not recommended. You don't want that tiny hard disc on your iPod to be spinning continously for 30 hours. Moreover, if you do it on the PC, other mp3 players can also use this info.
  2. You can stop/cancel the track gain process anytime you want. Mp3gain will pick up from where it left when you start it next time.
  3. Mp3gain is more accurate at doing normalization than SoundCheck feature found in iTunes/iPod. Mp3gain is based on ReplayGain standard which takes into account the mechanism of how humans perceive loudness. Turns out that human ears use average energy over time to perceive how loud a certain sound is. So mp3gain divides each file into 50ms blocks and calculates the RMS energy value of each of these blocks. These values are then used to arrive at the overall RMS energy of the entire song. This is the value which is then used to normalize the song file.
    SoundCheck works in similar way but it seems to take much longer blocks (fewer samples) to calculate the average RMS energy. This makes it less accurate (but a lot faster) than mp3gain.

Blog at WordPress.com.