Lately I have been experimenting with real time visualizations on the audio I play on my computer (via any arbitrary program, such as Spotify) but I've been using SoundFlower to pipe the output audio in to a fake line in.
What I'm wondering is if there is a way that is native to C/C++ or Java that will allow me to capture whatever audio is sent to my computer's (I'm using a Mac) line out in a similar way to how I can capture a line in (I.E. a sample buffer that is continually filled with PCM data).
I have no desire to emulate the other features of SoundFlower except for reading the line out data.
I suggest having a look at the source code for WavTap, a fork of SoundFlower, which focusses only on capturing the default audio output of the system.
Both SoundFlower and WavTap work by installing a kernel extension, which adds an additional audio device to which audio can be routed. They then captures audio from this device. WavTap makes this the default device when it starts so that the overall output of the system is automatically captured without the user having to explicitly set up the routing.
I believe the WavTap code is MIT licensed and the system extension code is well abstracted so you should be able to adapt it for your own project.
To understand a bit more about how this works, the OS X and iOS Kernel Programming book has an explanation of some of the techniques in Chapter 12 as well as downloadable code for an example audio device and engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With