As we're going to install Pidgin from source, we need to install all development files required to compile Pidgin first (which are the same files as would be needed for Gaim). This is done very easily with:
sudo apt-get build-dep gaim
This will install a bunch of dev packages. Also make sure the package "build-essential" is installed! Now get the Pidgin source from here (by the time of writing it's version 2.02) and unpack it somewhere in a temporary directory. The rest is standard procedure:
sudo make install
This will install Pidgin to /usr/local which should be the preferred location because this way the new files won't interfere with default Ubuntu packages, especially the Gaim files. That's it! You should find a shortcut to Pidgin under "Applications -> Internet". If not, you might want to re-login. If you already used Ubuntu's Gaim all preferences will be automatically imported to Pidgin and stored in ~/.purple.
If you'd like to install the MusicTracker plugin for Pidgin, download the source from here and install it the same way as Pidgin. Once installed you can activate the plugin via Pidgin under "Tools -> Plugins". Done!