Smoothie for Traktor
No artificial substitutes
Ahhh.. Writing these blog posts feels pretty great, it means I've just finished another one of my little projects. This time, it's an OS X Application called Smoothie. So here's the juice:
A while back a friend and me got into mixing music. We started by using the iPad version of Traktor's DJ software, which besides being fairly comfortable to use has a pretty neat feature: If you are playing a song, the app automatically suggests tracks that would blend well into it. While it's not really transparent as to how this is determined, it seems to use the tempo and musical key metadata of each song to do this.
Fast forwarding a bit, we start playing around with the "real deal", a hardware controller in combination with the desktop client, Traktor Pro. This desktop version of the software however, does not include mentioned feature.
You probably already know where this is going: I wanted that feature so I built it myself.
Easier said than done..
.. because the Traktor Pro desktop application is pretty enclosed. There is no Plugin API, only the possibility to write custom layouts for hardware controllers.
Hence, I had to get a bit creative. Digging around the file system I found Traktor's "collection file". Neat, it contains all the track metadata as xml-parseable data.
But that's the easy part. Yes, I could already use that to build a tool which can receive tracks being dragged into it and look up matching tunes in the collection (and I did that), but what I really wanted was something that updates itself, similar to how the iPad application works.
Looking for ways to tackle this, I stumbled across this GitHub repo. It's a python tool to automatically scrobble whatever you're playing to Last.fm. So how does that work? Well, Traktor has a streaming feature, which sends the current audio output to a server of choice. But not only that, it also sends a tiny amount of metadata once a song changes. It's not a lot, only the track title and artist, but it's enough to be able to look for matching songs in the collection.
So yeah, I open up a local tcp socket, wait for incoming metadata, look for matching tracks in the collection based on tempo and musical key, and display it all in a simple table view. You can then take any of the suggested songs and drag them back into Traktor. Sweet!
The code is 100% pure Swift and was my first attempt at release-quality OSX development. It was pretty cool to see all the lanes and corners where it differs from iOS development. There are more iOS APIs which don't exist on OSX than I expected and the joy of dealing with App Sandboxing is unmatched!