Search code examples
macoscore-audio

Intercepting all system level audio in Mac os


I have been working with CoreAudio last couple of days and I'm able to access all the AudioDevices, their properties and receive notifications when something changes. However, I'm now struggling to "intercept" the audio (ideally before it is played) from any application in the mac. I wasn't sure it was possible but this app actually does it. So I'm in search of some guidance. Thank you in advance.


Solution

  • Unfortunately macOS provides no facility to do this.

    The only way to achieve this is to patch lower level frameworks and/or drivers like Audio Hijack does. I will be a messy process.

    Depending on the use case however it might suffice to have an audio loopback virtual audio device so application A can send audio into it while application B can receive the audio from it. This can be done by creating a Core Audio AudioServerPlugin which is a user space audio driver mechanism. For an example please have a look at:

    https://github.com/ExistentialAudio/BlackHole
    https://github.com/kyleneideck/BackgroundMusic

    In regards to the limitations, you can read more about it here:
    https://stackoverflow.com/a/18595698/2576876

    From there you can go in a lot of directions by following the links provided.