See this article for more details.
A native Node.js module that provides system-level audio device management and capture capabilities for macOS applications. This module is particularly useful for Electron applications that need to interact with system audio devices and capture audio streams.
- System audio device management and monitoring
- Audio stream capture from system devices
- Permission handling for microphone and audio capture
- Automatic audio device change detection
- Support for aggregate audio devices
- TypeScript type definitions included
First, install the required global dependencies:
npm i -g node-gyp electron-rebuild node-addon-apiThis command configures the project for building with node-gyp.
npm run configure
This command creates a .clangd file in the project root, to make code-intellisense work in vscode.
./setup-clangd.sh
Native nodejs addon has to be built with electron-rebuild. If you are using electron-react-boilerplate, simply put this project under the release/app folder. Add it as dependency in package.json.
"dependencies": {
"native-audio-manager": "file:native-audio-manager"
}
Then run this command inside the release/app folder.
npm install
Returns the current permission status for microphone and audio capture access. The status can be:
notDetermined: Permission hasn't been requested yetauthorized: Permission granteddenied: Permission explicitly deniedrestricted: Permission restricted by system policy
Request system permissions for audio access.
deviceType: Either 'microphone' or 'audio'callback: Function called with permission result
Sets up a callback function to receive captured audio data.
callback: Function that receives audio data as Buffer
Starts capturing system audio. Returns a Promise that resolves when capture begins.
- Throws error if permissions not granted or setup fails
Stops the current audio capture session. Returns a Promise that resolves when stopped.
- Uses macOS Core Audio and AVFoundation frameworks
- Implements TCC (Transparency, Consent, and Control) permission handling
- Supports automatic audio device change detection
- Creates and manages aggregate audio devices when needed
- Handles audio format conversion and buffering
This project is licensed under the MIT License - see the LICENSE file for details.