mackron / miniaudio

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

Loopback support on macOS using new CoreAudio tap API #875

Open cryptocode opened 1 month ago

cryptocode commented 1 month 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 1 month 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 1 month 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