How to record speaker output on macOS
Recording audio or video on macOS is incredibly simple. There are tools available, out of the box, for both and there are lots of great third-party apps too like Audacity and OpenBroadcasterStudio that you can use. That said, none of these apps can record speaker output. It is beyond the scope of a normal or even advanced recording app to do this since you need to change how audio is routed. What you need is a virtual audio driver. The simplest one that you can use is called BlackHole. It can re-route audio to an app that you can then use to record speaker output. Here’s how it works.
Record speaker output
Download and install BlackHole. It’s going to install as a package and once the installation is complete, you have to open System Preferences.
Go to the Sound preference and you will see a tab for Output, and Input devices. On each tab, select the BlackHole device. What this does is, it sends audio that is being played to Blackhole. This audio can be heard by the input device which is again BlackHole. Between the two virtual input and output devices, there will be zero noise and one will be able to listen to the other. Close System Preferences.
Open an app that can record audio. You can use QuickTime since it’s already on your system but for a good audio app, I recommend using Audacity. Create a new audio recording but change the input device to BlackHole. All recording apps allow you to choose an audio input and output device.
Click record, and any sound that is routed to the speaker will be recorded. You won’t hear any sound yourself since the built-in speakers aren’t receiving any. If you’d like to hear sound from the built-in speakers as well, or maybe you have a Bluetooth speaker you’d like to hear the sound from, you can create an aggregate audio device.
Creating an aggregate audio device is a bit complicated but the app for the job is already present on your Mac so you won’t have to download anything. Ideally, the aggregate device should still give you good audio quality but, to be safe you should do a test recording to see if it picks up any noise or static. If it does, limit yourself to just using BlackHole.
With this trick, you will be able to record any and all sound from the speakers including sound from apps, and system sounds e.g., the sound that is played when you take a screenshot.
Once you’re done recording speaker output, make sure you change the audio input and output devices back.
Hello,
Is there a way to change the device in the c++ code instead of doing manually?
Thanks