iTunes to foobar2000

I got sick of iTunes, and decided to move to foobar2000. The biggest things that annoyed me about iTunes:

  • Speed, or lack of. It is the slowest responding application I use, and I really dislike it
  • No support for global media keys, and the plugin I used to use stopped working too..
  • No Milkdrop support (on Windows, Mac users get projectM at least)
  • Sound check sucks. I got sick of some songs getting way too loud for no reason, because the sound check thought the song was too quiet

The list could go on and on.. but I’ll focus on the migration itself.

First, I installed foobar2000 from the website, no issues. Configured a few options to my liking, got it to use my music folder.

My main step was ReplayGain, so I ran it and let it go for 2 hours. Unlike iTunes however, even when something is being processed, foobar2000 still lets me use the main interface which was great. Unfortunately I couldn’t try components, as they need a restart, so that had to wait till later.

Once all my tracks had their ReplayGain data, I decided to import my play counts, ratings, and other similar data from iTunes. This is where I hit a roadblock. I found a couple of posts that seemed to look OK, but didn’t really work our for me. So I decided to come up with a way and document it.

Note: you need foobar2000, iTunes and the play counts and mass tagger components.

1. Make sure all the files in foobar2000 are also in iTunes, and export a m3u playlist from foobar2000. This playlist is used to generate the ratings+play counts in the correct order for mass tagger (which we’ll use later).

2. Do a find+replace in your m3u playlist, or something similar to make sure all paths are absolute. Eg, your m3u lines should not just be “Music\Artist\song.mp3” but more like “C:\Users\UserName\Music\Artist\song.mp3”. A simple replace of “Music” with “C:\User\UserName\Music” would achieve this.

3. Use this application to generate output for mass tagger. Click the button at the bottom, and select the exported playlist, and it will automatically find all the information using the iTunes COM interface. This will take a while (and the progress bar will go through twice). Once it’s done, you’ll have the mass tagger input data on the left, and any error information on the right. (Errors are not a bad thing, more like warnings for files which won’t have data exported).

3. Load up foobar2000, make sure you select the exact same songs you generated the m3u from, right click, choose Tagging > Manage Scripts. Clear any existing actions. Choose Add -> “Input Data (one line per track)”. For the scheme enter:
In the Input data section, copy and paste all the output from the left box from the earlier application and press OK.
Ensure that the data changes in the output preview look OK, and if so, press “Run”. This will take a while.

4. Now, all the data has been written to your tags. You can select all your tracks, right click, and chosoe Playback Satistics -> Import statistics from file tags. This will import all your data into the play counts component. Once imported, feel free to remove tags added (%rating%, %play_count%, %skip_count%, %last_played%, %last_skipped%, %added%) from the tags using mass tagger again.

And that’s it! Hopefully all your data has been imported into foobar2000.

PS: you can check out the source for the above application here.

Getting around flash streaming sites using a proxy server

Getting around flash-based streaming sites to access the real file can be tricky.

Sites that stream music or videos through Flash interfaces are extremely common, and most of the time can be circumvented easily either using:

  • Online sites created solely for the purpose of extracting the real music or video URL
  • Using Chrome’s developer tools to find the exact resources being loaded, and simply opening the largest file
  • Browsing the source, decompiling the flash, and recreating the exact authenticated etc to access the file as if you were the real client.

This works great for most sites, but I recently came across a site that none of these worked on (grooveshark). For the educational value, I decided to try a new approach: write a simple HTTP proxy server that simply cached the file type that I wanted.

The simplest way was to use Python and Twisted, and I found a great example of intercepting specific requests and modifying them here.

I took the code there, and modified it so that it looked for the Content-Type I was looking for (audio/mpeg), and cached those files. I started up my HTTP server, told my browser to go to Grooveshark, listened to the file I wanted, and done! I had a cached copy of the file.

This method will work with any site that uses HTTP.

Multiclutch Fixes + Better Instructions

Another minor multiclutch 64 bit update.

So I’ve had some fixes to Multiclutch that I never really made a post about, and I figured I might as well post some instructions on exactly how to get this all working so people have less issues.

First of all, the latest download link:

Instructions on how to use this:
1) Install the original Multiclutch plugin using the original beta installer here

2) Install the latest version of SIMBL which includes 64 bit support from here

3) Install my fork of the plugin by copying the bundle file from my zip file above into ~/Library/Application Support/SIMBL/Plugins or /Library/Application Support/SIMBL/Plugins

4) *Important / new step* – remove the original multiclutch input manager from /Library/InputManagers. The latest build supports both 32 bit and 64 bit applications, it is a universal binary.

If you don’t do 4, it is likely that your Firefox / other applications will crash on some gestures.

If you do all of the above, and are still getting crashes, let me know here.

Minor Multitclutch Update

Another little update to multiclutch to allow it to load for all applications through SIMBL.

Update: I have made another post with better instructions and a new build.

Another little update to the changes I made to multiclutch.

I realised I could make the input manager load for all applications by using a * target application identifier for the SIMBL properties (so that is being used now).

I have also built the input manager as a universal application, so that it will now work for 32 bit and 64 bit applications, so the old input manager for MultiClutch in /Library/InputManagers should not be necessary anymore.

I have put up the build here:
Multiclutch Universal Build

Let me know how it goes!

Multiclutch X64 SIMBL Plugin

Getting multiclutch working with Safari running in 64 bit mode.

I am a huge fan of Multiclutch, and I have been running Safari in 32 bit mode exclusively just so that I could keep using my multitouch gestures. It makes Safari so much more productive for me.

Anyway, I really wanted to get it working under 64 bit, and the source was open! And, it seems that SIMBL now works in 64 bit! So I decided to port over the Multiclutch code which was available on GitHub to work in SIMBL. This was a very rough port as I don’t code in OSX at all, and I just wanted to get it working!

What I modified:

  • Added MulticlutchPlugin.[hm] to replace the NSApplication_GESTURES, that implements the SIMBL required load
  • Modified Info.Plist to allow SIMBL to load it

Again, it’s very rough, and the developer should clean it up before releasing it. At the moment, it only loads on Safari.

A binary (Intel x64 only) for those who want to test it:
Multiclutch SIMBL Bundle

The bundle has to be copied to ~/Library/Application Support/SIMBL/Plugins as per any other SIMBL plugin.

iTunes Windows Support for PS3 Media Server

iTunes Windows support for PS3 Media Server

I’ve been playing with PS3 Media Server since I got my PS3. It makes the PS3 much better as a media library client, but it still can’t compare to XBMC. Anyway, I was looking around the code for PMS and noticed that there was iTunes support for OSX, but now Windows, so I extended it to work on Windows today.

I created a patch which applies to r358:
iTunes Windows Support Patch

For those who want to test it ASAP:

Download this file:

This zip file contains a “pms.jar” file. To use this, go to your PMS folder, usually C:\Program Files\PS3 Media Server, and rename the existing pms.jar (to pmg.backup.jar) so you have a backup, and then copy the new pms.jar file in.

Now when you restart PS3 Media Server, under General Configuration, you should have a checkbox for “Show iTunes Library”. You can check this, save, and restart PS3 Media Server for it to start loading the iTunes library. Note that it takes a while to load, it took about 10 minutes on my library!

Getting FN keys of Vaio VGN-FS38GP working in Ubuntu 8.10

Ubuntu 8.10 does not support the Vaio FS series by default, and needs a little bit of hacking to get working. The old fsfn program does not work anymore unfortunately. Some poking around found me this error in my dmesg output everytime I pressed a FN key: 

atkbd.c: Use ‘setkeycodes e075 <keycode>’ to make it known.
atkbd.c: Unknown key released (translated set 2, code 0xf5 on isa0060/serio0).

This was repeated multiple times. I also found that a file located at /sys/devices/platform/sony-laptop/fnkey had the right value after a FN key press.

I realised I could combine these to come up with a hack solution that would work. I decided to write a perl script that would be called everytime a fn key was pressed, that would figure out which key was pressed (using the fnkey file) and then do the right thing.

To get the key recognised to start our perl script, we use xbindkeys and we use the setkeycodes command. I made a script that maps all FN keys to keycode 235. I then use this .xbindkeysrc (it must be named .xbindkeysrc in your home directory and you need to install xbindkeys) to start my perl script.

The perl script itself just invokes some scripts that come with ubuntu. At the moment it only supports the volume controls and brightness (as these are what I wanted). The script is located here.

Turns out the ubuntu scripts need root access to run, so I ran the following commands to ensure all executions of the program run as root (I wasn’t too worried about security in this case..)

sudo chmod a+s /etc/acpi/
sudo chmod a+s /usr/bin/acpi_fakekey 

My files use hardcoded paths of /home/prashant so you will have to change those to make it work.

All the files needed can be found here: 

I took a look at the driver (/drivers/misc/sony-laptop.c) and realised that fn keys do not generate any event in the sony-laptop code currently, and seem to only generate normal keyboard events. Unfortunately I don’t have any experience with the linux kernel to figure out how to fix it at the kernel level.

Perl Mail Checker

So I got sick of Outlook eating all my RAM. I have it open all the time during the day, so that I can see when I have new email. However, it also ate are about 140mb of my ram to do this simple task.

I wanted a light replacement. I tried some programs on the net but they used a fair bit of RAM. So decided I would write my own simple client in .NET that did exactly what I wanted.
While I was looking for .NET libraries to access my IMAP mail server, I found 
It looked pretty useful, and I realised perl would be a lot easier.. But I wanted a system tray icon when I had new mail.. Some more googling found me..

So I decided to play with it. And by the end of it, I got myself a nice simple imap mail checker using perl.
The way it works is not like most mail checkers. It does not run all the time. It only runs, checks if there is new mail, and if not, closes. So the way I use it:
  • Task Scheduler starts my script every 3 minutes
  • Script runs, and if there is no mail, closes. If there is mail, show a notify icon (for 2 minutes)
  • I click the notify icon to open Outlook.
The advantage – when there is no new mail, a new process is started every 3 minutes, and it ends straight away. When there is new mail, perl continues running, which takes up barely any ram. (13 mb last time I checked). I click the icon and Outlook starts up, allowing me to read the mail in my usual client.
So, RAM usage has been minimized, yet I am not missing any features. Files for this can be found here.