Both are free software, Audacity allows you to record and edit audio while Soundflower helps you route sounds to any other Mac app instead of the default speakers. Install Audacity and Soundflower on your Mac. The technique doesn’t require the line-in port and thus works on newer Apple iMac and Macbooks. You can record music from any Internet radio station playing in your browser, system audio or even sounds coming from an application open on your Mac.
This step-by-step tutorial explains how you can capture any sounds coming out of the speakers or your Mac.