Unlock the power of audio recording on macOS 14.4+ with our detailed guide on the new CoreAudio API. Designed to demystify the permission-setting process and the setup necessary for capturing audio from other apps, our documentation is an indispensable resource for developers aiming to enhance their audio applications. Navigate the complexities seamlessly and bring your audio project to life.
AudioCap: Unleash the Power of System Audio Recording on macOS 14.4+
With the release of macOS 14.4, Apple introduced groundbreaking new APIs in CoreAudio that enable applications to capture audio from other apps or from the entire system—provided the user grants permission.
However, diving into this powerful functionality can be daunting due to its lack of documentation and the complexities associated with CoreAudio. This project serves as a resource for developers looking to harness this new audio capture functionality.
Key Features
-
User Permissions Management: Learn to handle audio recording permissions seamlessly. While the
NSAudioCaptureUsageDescription
key needs to be added manually to your app's Info.plist, our project demonstrates how to check and request permissions effectively, utilizing private API from the TCC framework (with optional build-time flags). -
Step-by-Step Process Tap Setup: We provide a comprehensive guide on how to set up and record audio from other applications. Take advantage of methods such as:
- Getting the PID of the desired process
- Translating the PID to
AudioObjectID
- Creating a
CATapDescription
for your audio object - Setting up an aggregate audio device and handling callbacks
Example Usage
Here's a brief code snippet to demonstrate setting up audio capture:
let pid = ... // PID of the process to capture
let audioObjectID = kAudioHardwarePropertyTranslatePIDToProcessObject(pid)
let tapDescription = CATapDescription(audioObjectID: audioObjectID)
// Configure your device
AudioHardwareCreateProcessTap(tapDescription)
// Further setup and begin recording...
Conclusion
By leveraging the AudioCap project, developers can overcome initial hurdles and unlock the audio capture capabilities of macOS 14.4 and beyond. This resource is essential for anyone looking to build audio-centric applications effectively and efficiently.
Special thanks to @WFT for contributions to this project.
For more details and the full implementation, visit AudioCap on GitHub.