mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.05k stars 357 forks source link

Loopback support on macOS using new CoreAudio tap API #875

Open cryptocode opened 3 months ago

cryptocode commented 3 months ago

I'm using miniaudio for a music visualizer, and it's working great.

However, on macOS, I have to ask users to install software like Blackhole to be able to capture system audio. More often than not, my testers can't make it work + they lose the ability to easily adjust volume.

Apple recently introduces capability to capture audio which I suspect miniaudio could utilize for this purpose. This is not documented well yet, but someone made a repository to make it more approachable: https://github.com/insidegui/AudioCap/

(This example asks you to pick a specific pid, so it may be the case that the new API doesn't allow system-wide audio capture)

mackron commented 3 months ago

I noticed the example you linked is in Swift. Is there no way to do it with Obj-C? If it's Swift-only then it'll never be added to miniaudio.

cryptocode commented 3 months ago

I noticed the example you linked is in Swift. Is there no way to do it with Obj-C? If it's Swift-only then it'll never be added to miniaudio.

I believe it's available for Obj-C as well: https://developer.apple.com/documentation/coreaudio/capturing_system_audio_with_core_audio_taps?language=objc

barracuda156 commented 1 month ago

Just for a note, from the link above it seems that the needed functionality is only supported in Sonoma and above. If that is the case, please add it conditionally on macOS version (if it is added).