The Wub Machine, Revisited
The Wub Machine was a great little auto-remixer project - some audio hackery in Python to make a neat script. Unfortunately, I can probably count on one hand the number of people who actually downloaded the script and tried it on their own songs. So, I decided to make it into a web app. (try it out !)
I opened up my trusty Photoshop, cranked out some multicoloured waves and set “The Wub Machine” in beautiful Proxima Nova. Then I set about the immense task of actually implementing the remixer on the web.
I’d go into the technical impressiveness of the system, and how it’s brilliant and took me months to come up with… but it’s really not. It’s one big hack.
I ended up using:
- PHP to serve the front-end, as well as serve the AJAX progress updates and interface with SoundCloud
- Python to power and tie together all of the processing on the back-end
- the Echo Nest Remix API to do the heavy lifting, audio analysis and beat detection
- FFMPEG to decode & encode the MP3s
- Mutagen and PIL to rewrite the MP3’s metadata, extract artwork, overlay a graphic and put it back in to the final MP3
- Beanstalkd to queue processing jobs and connect PHP to Python
- SQLite3 for logging and some queue intelligence
- HTML5 Audio, used for a beautiful HTML5 player (taken from the extremely impressive Neutron Creations blog)
- Flash for the fallback player on older browsers
- Javascript and jQuery to hold together the very rickety frontend
- CSS3 animations, for the moving waves at the top of the page
- the SoundCloud API for sharing tracks (without putting me at risk of nasty legal issues or pushing storage constraints)
I did have to make a couple changes to the original algorithm, though:
- I realized that audio volume is a nonlinear curve, so I had to account for that and create a new mixing algorithm. The volume of the original track vs. the wubwubs is now almost always about 50%.
- I went back into my dubstep template in Logic Pro and added different types of TransitionFX samples to the intro and the wubs - booms, splashes and such. Although I’m still not happy with certain parts of the template, it’ll have to do for now. I’m not a dubstep producer - I’m a rock/metal/electronica/jazz guy. (for now!)
- I made the algorithm as deterministic as possible. The remixer is essentially a function (depending on the analysis I get back from the Echo Nest) so if you put in the same song, you should get the exact same remix.
- I improved the loudness calculation algorithms, fixed some stupidly-inefficient bugs, killed off a statistically-improbable-but-still-possible infinite loop, added logging, error handling, and progress indicators.
Since my blog post about the initial hack, it’s taken me 3 weeks to assemble this web front end. That said, there’s probably still tons of bugs - it only accepts MP3s at the moment, and it’s probably somewhat unstable. If I push it too hard, or post it to Reddit or Hacker News, my shiny new Linode will probably spontaneously combust. Be gentle!
Go try out the Wub Machine, share your tracks on SoundCloud, and enjoy!