There is a free solution for this. It may sound complicated, but be pacient. It really works great, and you only need a little bit of preparation, once, and you'll be set.
I use SoundFlower. It provides virtual input and output audio devices and allows to pipe your mac's audio output to its input. This way you can record whatever sound comes out of your mac without also capturing the sounds in your environment.
SoundFlower can be downloaded for free, from the author, Matt Ingalls:
https://github.com/mattingalls/Soundflower/releases/
Once installed, you can just select your output and your input to Soundflower, then play any sound and record it.
There is a slight inconvenient with this: you won't hear it while recording.
To overcome this, you go to the Audio Midi Setup application (already on your mac), and create a Multi-output device. Include both Soundflower and the built-in output in this device. Then just use it for output: all the audio will be simultaneously played on your normal output and also sent to Soundflower.
Try it!