SoundFlower does this, it's open source. It contains a decent chunk of audio routing features that are inexplicably missing from the core OS X.
For instance, you can route application audio out to a Soundflower channel and use that as input for another app.
Edit: just checked, Soundflower rerouting works perfectly with the Shazam Mac app, tried it out on a couple of YouTube songs, and it got it right on 47 out of the current top 50. It's a shame that Shazam is still only useful for mainstream stuff, when I tried it on some random metal, Goa, soundtracks, and industrial... 0 out of 15.