### Install mac-audio-capture via npm Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Install the module directly from GitHub using npm. Alternatively, clone the repository and install locally. ```bash npm install git+https://github.com/sparticleinc/mac-audio-capture.git ``` ```bash git clone https://github.com/sparticleinc/mac-audio-capture.git cd mac-audio-capture npm install ``` -------------------------------- ### Run Example Scripts Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Executes example scripts included in the project. This is useful for demonstrating the module's capabilities. ```bash npm run example ``` -------------------------------- ### Install Mac Audio Capture Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Install the module directly from GitHub or by cloning the repository and building locally. The `postinstall` script automatically runs the Swift build. ```bash # Install from GitHub npm install git+https://github.com/sparticleinc/mac-audio-capture.git # Or clone and install locally git clone https://github.com/sparticleinc/mac-audio-capture.git cd mac-audio-capture npm install # triggers: swift build -c release # Verify build artifact exists ls .build/release/libMacAudioCapture.dylib ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Installs all necessary Node.js dependencies for development and running the project. This command should be run in the project's root directory. ```bash npm install ``` -------------------------------- ### Start Audio Capture and Handle Data Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Start the native CoreAudio Process Tap and begin polling audio data. The `startCapture` method emits `'started'`, `'data'`, and `'error'` events. Audio data is received as Base64-encoded PCM chunks. ```javascript const capture = new AudioCapture({ sampleRate: 48000, channelCount: 2 }); capture.on('started', () => console.log('Capture started')); capture.on('data', (segments) => { // segments: string[] β€” array of Base64-encoded Float32 PCM chunks console.log(`Received ${segments.length} audio segments`); }); capture.on('error', (err) => console.error('Capture error:', err.message)); // Auto-configures if not already configured await capture.startCapture({ interval: 100 }); // poll every 100 ms // Let it run for 5 seconds await new Promise(resolve => setTimeout(resolve, 5000)); await capture.stopCapture(); ``` -------------------------------- ### Advanced Audio Capture and Real-time Processing Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Shows advanced usage including configuring capture settings, starting capture with a specific interval, processing real-time audio data, and saving the captured audio to a WAV file. This example utilizes event listeners for data and demonstrates stopping the capture after a set duration. ```javascript const AudioCapture = require('./lib'); async function advancedCapture() { const capture = new AudioCapture(); // Configure audio capture await capture.configure({ sampleRate: 44100, channelCount: 1, logPath: './logs/audio.log' }); // Start capture await capture.startCapture({ interval: 100 }); // Real-time audio data processing capture.on('data', (audioData) => { console.log(`πŸ“Š Received ${audioData.length} audio segments`); // Process audio data here }); // Record for 3 seconds await new Promise(resolve => setTimeout(resolve, 3000)); // Stop capture await capture.stopCapture(); // Save as WAV file const filePath = await capture.saveToWav('advanced-output.wav'); console.log('File saved:', filePath); } ``` -------------------------------- ### startCapture Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Starts the audio capture process. You can specify an interval for data emission. ```APIDOC ## startCapture Start audio capture ```javascript await capture.startCapture({ interval: 100 }); ``` **Parameters:** - `options` (object): Options for starting capture. - `interval` (number): The interval in milliseconds between audio data emissions. ``` -------------------------------- ### Run Project Tests Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Executes the project's test suite to verify functionality. Ensure all dependencies are installed before running tests. ```bash npm test ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Install the Xcode Command Line Tools, which are required for building native Node.js modules on macOS. This command will prompt you to install them if they are not already present. ```bash xcode-select --install ``` -------------------------------- ### Start Audio Capture Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Initiates the audio capture process with a specified interval for data emission. Ensure configuration is complete before calling this method. ```javascript await capture.startCapture({ interval: 100 }); ``` -------------------------------- ### capture.startCapture(options?) Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Starts the native CoreAudio Process Tap and begins polling audio data. Each poll decodes buffered Base64-encoded PCM frames, appends them to `audioBuffer`, and emits a 'data' event. Throws if capture is already running. ```APIDOC ## capture.startCapture(options?) ### Description Starts the native CoreAudio Process Tap and begins polling audio data from the Swift recorder on the given `interval` (default 200 ms). Each poll decodes buffered Base64-encoded PCM frames from the native side, appends them to `audioBuffer`, and emits a `'data'` event. Throws if capture is already running. ### Parameters #### Options - **interval** (number) - Optional - The polling interval in milliseconds (default: 200). ### Events - **'started'**: Emitted when capture has successfully started. - **'data'**: Emitted when new audio data is received. Receives an array of Base64-encoded PCM chunks (`string[]`). - **'error'**: Emitted on capture error. Receives an error object. ### Request Example ```javascript const capture = new AudioCapture({ sampleRate: 48000, channelCount: 2 }); capture.on('started', () => console.log('Capture started')); capture.on('data', (segments) => { // segments: string[] β€” array of Base64-encoded Float32 PCM chunks console.log(`Received ${segments.length} audio segments`); }); capture.on('error', (err) => console.error('Capture error:', err.message)); // Auto-configures if not already configured await capture.startCapture({ interval: 100 }); // poll every 100 ms // Let it run for 5 seconds await new Promise(resolve => setTimeout(resolve, 5000)); await capture.stopCapture(); ``` ``` -------------------------------- ### configure Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Configures the audio capture settings such as sample rate, channel count, and log file path. This method should be called before starting the capture. ```APIDOC ## configure Configure audio capture ```javascript await capture.configure({ sampleRate: 44100, channelCount: 1, logPath: './audio.log' }); ``` **Parameters:** - `options` (object): Configuration settings. - `sampleRate` (number): The desired sample rate. - `channelCount` (number): The desired number of audio channels. - `logPath` (string): The path to the log file. ``` -------------------------------- ### Clear Audio Buffer Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Empties the internal audio data buffer. Use this to reset the buffer if needed, for example, before starting a new recording. ```javascript capture.clearBuffer(); ``` -------------------------------- ### Record Audio to WAV File Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Use the `record` method for the simplest way to capture audio and save it to a WAV file. It handles starting, stopping, and saving automatically. Ensure the `AudioCapture` instance is configured before calling. ```javascript const capture = new AudioCapture({ sampleRate: 48000, channelCount: 2 }); capture.on('started', () => console.log('Recording…')); capture.on('stopped', () => console.log('Stopped.')); capture.on('saved', (fp) => console.log('Saved to:', fp)); capture.on('error', (err) => console.error('Error:', err.message)); try { // Record 10 seconds, save to output.wav const filePath = await capture.record(10000, './recordings/output.wav'); console.log('File ready:', filePath); // File ready: ./recordings/output.wav } catch (err) { console.error('Recording failed:', err.message); } ``` -------------------------------- ### Configure Audio Capture Settings Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Configures the audio capture with specific sample rate, channel count, and log file path. This method should be called before starting the capture. ```javascript await capture.configure({ sampleRate: 44100, channelCount: 1, logPath: './audio.log' }); ``` -------------------------------- ### record Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Records audio for a specified duration and saves it to a WAV file. This is a convenience method that combines starting capture, waiting, and stopping. ```APIDOC ## record Record audio for specified duration ```javascript const filePath = await capture.record(5000, 'output.wav'); ``` **Parameters:** - `durationMs` (number): The duration in milliseconds to record audio. - `outputPath` (string): The file path to save the recorded WAV file. ``` -------------------------------- ### Configure Audio Capture Settings Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Configure the audio capture settings such as sample rate, channel count, and log path. This must succeed before starting capture. The `configure` method emits `'configured'` on success or `'error'` on failure. ```javascript const capture = new AudioCapture(); capture.on('configured', (config) => { console.log('Configured:', config); // { sampleRate: 48000, channelCount: 2, logPath: './logs/audio.log' } }); capture.on('error', (err) => console.error('Config error:', err.message)); const ok = await capture.configure({ sampleRate: 48000, channelCount: 2, logPath: './logs/audio.log' }); console.log(ok); // true console.log(capture.isConfigured); // true ``` -------------------------------- ### TypeScript Example for Mac Audio Capture Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Use this snippet to integrate Mac Audio Capture in a TypeScript Node.js application. Ensure 'System Audio Recording' permission is granted. The package requires macOS 14.4+. ```typescript import AudioCapture, { AudioCaptureConfig, CaptureOptions } from './lib'; const config: AudioCaptureConfig = { sampleRate: 48000, channelCount: 2, logPath: './audio.log' }; const capture = new AudioCapture(config); capture.on('data', (data: string[]) => console.log(data.length)); capture.on('saved', (fp: string) => console.log(fp)); capture.on('error', (err: Error) => console.error(err)); capture.on('stopped', (buf: string[]) => console.log(buf.length)); const opts: CaptureOptions = { interval: 100 }; await capture.startCapture(opts); await new Promise(r => setTimeout(r, 5000)); await capture.stopCapture(); const path: string = await capture.saveToWav('output.wav'); ``` -------------------------------- ### Record Audio for a Specific Duration Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Records audio for a given duration in milliseconds and saves it to the specified output path as a WAV file. This is a convenience method that combines starting capture, waiting, and stopping. ```javascript const filePath = await capture.record(5000, 'output.wav'); ``` -------------------------------- ### AudioCapture Event Handling Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Handle lifecycle events emitted by the `AudioCapture` instance, which extends `EventEmitter`. Events include 'configured', 'started', 'data', 'stopped', 'saved', and 'error', providing feedback on the capture process. ```javascript const capture = new AudioCapture({ sampleRate: 48000, channelCount: 2 }); // Fired after configure() succeeds β€” payload: the merged config object capture.on('configured', (config) => { console.log('sampleRate:', config.sampleRate); // 48000 }); // Fired after startCapture() arms the native tap capture.on('started', () => console.log('Tap active')); // Fired on each poll cycle that returns data β€” payload: string[] (Base64 PCM chunks) capture.on('data', (segments) => { console.log(`Poll: ${segments.length} new segments`); }); // Fired after stopCapture() β€” payload: full audioBuffer string[] capture.on('stopped', (buf) => { console.log(`Total buffered: ${buf.length}`); }); // Fired after saveToWav() writes the file β€” payload: output file path string capture.on('saved', (fp) => console.log('File:', fp)); // Fired on any internal error β€” payload: Error object capture.on('error', (err) => console.error('ERR:', err.message)); ``` -------------------------------- ### Retrieve Current Audio Data Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Gets the audio data currently held in the buffer. This can be useful for inspecting or processing data without saving it immediately. ```javascript const audioData = capture.getAudioData(); ``` -------------------------------- ### capture.clearBuffer() Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Synchronously empties the internal audio buffer. This is useful for discarding unwanted audio, such as initial silence or countdowns, before starting a new recording session without needing to instantiate a new AudioCapture object. ```APIDOC ## `capture.clearBuffer()` Synchronously empties `audioBuffer`. Use this to discard unwanted audio before starting a new logical recording session without creating a new instance. ### Parameters This method does not accept any parameters. ``` -------------------------------- ### Clear Audio Buffer Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Use `clearBuffer` to synchronously empty the `audioBuffer`. This is useful for discarding unwanted audio, such as an initial countdown or silence, before starting a new logical recording session without needing to instantiate a new `AudioCapture` object. ```javascript await capture.startCapture(); await new Promise(resolve => setTimeout(resolve, 1000)); // Discard the first second (e.g. countdown / silence) capture.clearBuffer(); console.log(capture.audioBuffer.length); // 0 // Continue capturing from a clean slate await new Promise(resolve => setTimeout(resolve, 5000)); await capture.stopCapture(); await capture.saveToWav('./clean-start.wav'); ``` -------------------------------- ### Get Current Audio Data Buffer Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Retrieve the current in-memory audio buffer using `getAudioData`. This returns a copy of the buffer without clearing it, useful for inspecting or forwarding data mid-session, such as sending raw Base64 segments over a WebSocket. ```javascript await capture.startCapture(); await new Promise(resolve => setTimeout(resolve, 2000)); const data = capture.getAudioData(); console.log(`Buffer has ${data.length} segments`); // Buffer has 10 segments (varies by interval and audio activity) // Forward raw base64 segments over a WebSocket, etc. ws.send(JSON.stringify({ type: 'audio', segments: data })); ``` -------------------------------- ### capture.configure(options?) Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Passes sample rate, channel count, and log path to the Swift native layer via FFI. Creates the log directory if it does not exist. Must succeed before startCapture can be called. Emits 'configured' on success or 'error' on failure. ```APIDOC ## capture.configure(options?) ### Description Passes sample rate, channel count, and log path to the Swift native layer via FFI. Creates the log directory if it does not exist. Must succeed before `startCapture` can be called (though `startCapture` will auto-call `configure` with defaults if skipped). Emits `'configured'` on success or `'error'` on failure. ### Parameters #### Options - **sampleRate** (number) - Optional - The desired audio sample rate in Hz. - **channelCount** (number) - Optional - The number of audio channels (1 for mono, 2 for stereo). - **logPath** (string) - Optional - The path to a file for logging audio capture information. ### Events - **'configured'**: Emitted on successful configuration. Receives the configuration object. - **'error'**: Emitted on configuration failure. Receives an error object. ### Request Example ```javascript const capture = new AudioCapture(); capture.on('configured', (config) => { console.log('Configured:', config); // { sampleRate: 48000, channelCount: 2, logPath: './logs/audio.log' } }); capture.on('error', (err) => console.error('Config error:', err.message)); const ok = await capture.configure({ sampleRate: 48000, channelCount: 2, logPath: './logs/audio.log' }); console.log(ok); // true console.log(capture.isConfigured); // true ``` ``` -------------------------------- ### Basic Audio Recording with mac-audio-capture Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Demonstrates basic audio capture by creating an instance, listening to events, and recording 5 seconds of audio to a WAV file. Ensure the AudioCapture class is correctly imported. ```javascript const AudioCapture = require('./lib'); async function captureAudio() { // Create audio capture instance const capture = new AudioCapture({ sampleRate: 48000, channelCount: 2 }); // Listen to events capture.on('started', () => console.log('πŸŽ™οΈ Started capturing')); capture.on('stopped', () => console.log('πŸ›‘ Stopped capturing')); capture.on('error', (error) => console.error('❌ Error:', error.message)); try { // Record 5 seconds of audio const filePath = await capture.record(5000, 'output.wav'); console.log('βœ… Recording completed:', filePath); } catch (error) { console.error('Recording failed:', error.message); } } captureAudio(); ``` -------------------------------- ### Build Project for Development and Production Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Builds the project. Use 'npm run dev' for a development build and 'npm run build' for a production build. ```bash # Development build npm run dev # Production build npm run build ``` -------------------------------- ### Initialize AudioCapture Instance Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Construct an `AudioCapture` instance, which is an `EventEmitter`. The native library is loaded at require-time. You can provide optional configuration for sample rate, channel count, and log path. ```javascript const AudioCapture = require('./lib'); // Default config: 48000 Hz, stereo, log β†’ ./audio_capture.log const captureDefault = new AudioCapture(); // Custom config const capture = new AudioCapture({ sampleRate: 44100, // Hz (e.g. 22050 | 44100 | 48000) channelCount: 1, // 1 = mono, 2 = stereo logPath: './logs/audio_capture.log' }); console.log(capture.isRecording); // false console.log(capture.isConfigured); // false console.log(capture.audioBuffer); // [] ``` -------------------------------- ### new AudioCapture(options?) Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Constructs an AudioCapture instance (an EventEmitter) with optional initial configuration. The native library is loaded at require-time; the constructor itself does not call any native code. ```APIDOC ## new AudioCapture(options?) ### Description Constructs an `AudioCapture` instance (an `EventEmitter`) with optional initial configuration. The native library is loaded at require-time; the constructor itself does not call any native code. ### Parameters #### Options - **sampleRate** (number) - Optional - The desired audio sample rate in Hz (e.g., 22050, 44100, 48000). - **channelCount** (number) - Optional - The number of audio channels (1 for mono, 2 for stereo). - **logPath** (string) - Optional - The path to a file for logging audio capture information. ### Request Example ```javascript const AudioCapture = require('./lib'); // Default config: 48000 Hz, stereo, log β†’ ./audio_capture.log const captureDefault = new AudioCapture(); // Custom config const capture = new AudioCapture({ sampleRate: 44100, channelCount: 1, logPath: './logs/audio_capture.log' }); console.log(capture.isRecording); // false console.log(capture.isConfigured); // false console.log(capture.audioBuffer); // [] ``` ``` -------------------------------- ### AudioCapture Constructor Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Initializes a new instance of the AudioCapture class. You can provide configuration options for sample rate, channel count, and log file path. ```APIDOC ## Constructor ```javascript new AudioCapture(options?: AudioCaptureConfig) ``` **Parameters:** - `options` (optional): Configuration options - `sampleRate`: Sample rate (default: 48000) - `channelCount`: Number of channels (default: 2) - `logPath`: Log file path ``` -------------------------------- ### Run Code Formatting and Linting Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Execute these npm scripts to format the code and run linters. Ensure your development environment is set up with Node.js and npm. ```bash npm run format npm run lint ``` -------------------------------- ### Check Swift Version Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Verify that your Swift version is 5.3 or higher, as required by the project. This is necessary for compiling the Swift components of the native module. ```bash swift --version ``` -------------------------------- ### Manual Audio Capture and Save to WAV Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Control the audio capture lifecycle manually using `startCapture`, `stopCapture`, and `saveToWav`. This method allows for intermediate processing or saving specific audio data snapshots. The output directory is created if it doesn't exist. ```javascript // Manual control flow: start β†’ wait β†’ stop β†’ save const capture = new AudioCapture({ sampleRate: 44100, channelCount: 1 }); await capture.startCapture({ interval: 50 }); await new Promise(resolve => setTimeout(resolve, 3000)); await capture.stopCapture(); try { const filePath = await capture.saveToWav('./out/mono-44k.wav'); console.log('Saved:', filePath); // Saved: ./out/mono-44k.wav } catch (err) { // 'No audio data to save' β€” if buffer is empty console.error(err.message); } // Save a specific data array (e.g. a snapshot taken mid-session) const snapshot = capture.getAudioData(); await capture.saveToWav('./out/snapshot.wav', snapshot); ``` -------------------------------- ### capture.saveToWav(outputPath, audioData?) Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Converts internal audio data or provided audio data to a 16-bit PCM WAV file with proper headers. It can create output directories if they don't exist and emits a 'saved' event upon successful completion. ```APIDOC ## `capture.saveToWav(outputPath, audioData?)` Converts the internal Base64-encoded Float32 PCM buffer (or a provided `audioData` array) to 16-bit PCM and writes a properly-headered WAV file. Creates the output directory if needed. Emits `'saved'` with the resolved path on success. ### Parameters - **outputPath** (string) - Required - The file path for the output WAV file. - **audioData** (Array) - Optional - An array of Base64-encoded Float32 PCM strings to save. If not provided, the internal audio buffer is used. ### Returns - `Promise` - A Promise that resolves with the output file path upon successful saving. ``` -------------------------------- ### Check Node.js Version Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Ensure that your Node.js version is 16 or higher, which is a requirement for running the project and its build tools. ```bash node --version ``` -------------------------------- ### capture.record(durationMs?, outputPath?) Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt A convenience method to record audio for a specified duration, save it to a WAV file, and return the file path. It simplifies the process of capturing and saving audio. ```APIDOC ## `capture.record(durationMs?, outputPath?)` Convenience method that calls `startCapture()`, waits for `durationMs` milliseconds (default 5000), calls `stopCapture()`, then calls `saveToWav(outputPath)`. Returns a Promise that resolves to the saved file path. This is the simplest way to produce a WAV file. ### Parameters - **durationMs** (number) - Optional - The duration in milliseconds to record audio. Defaults to 5000ms. - **outputPath** (string) - Optional - The file path where the WAV file will be saved. If not provided, a default path may be used or an error might occur depending on implementation. ### Returns - `Promise` - A Promise that resolves with the file path of the saved WAV file. ``` -------------------------------- ### saveToWav Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Saves the currently buffered audio data into a WAV file at the specified output path. ```APIDOC ## saveToWav Save audio data as WAV file ```javascript const filePath = await capture.saveToWav('output.wav'); ``` **Parameters:** - `outputPath` (string): The file path where the WAV file will be saved. - `audioData` (optional): The audio data to save. If not provided, the current buffer is used. ``` -------------------------------- ### Save Audio Data to WAV File Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Saves the currently buffered audio data into a WAV file at the specified output path. This method can be used independently after capturing data. ```javascript const filePath = await capture.saveToWav('output.wav'); ``` -------------------------------- ### getAudioData Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Retrieves the current audio data that has been captured and buffered. ```APIDOC ## getAudioData Get current audio data ```javascript const audioData = capture.getAudioData(); ``` **Returns:** - `audioData` (ArrayBuffer or similar): The captured audio data. ``` -------------------------------- ### clearBuffer Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Clears the internal buffer holding the captured audio data. ```APIDOC ## clearBuffer Clear audio buffer ```javascript capture.clearBuffer(); ``` ``` -------------------------------- ### capture.getAudioData() Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Retrieves a copy of the current in-memory audio buffer, which contains Base64-encoded Float32 PCM strings. This method is useful for inspecting or forwarding audio data without clearing the buffer. ```APIDOC ## `capture.getAudioData()` Returns a shallow copy of the current in-memory audio buffer (array of Base64-encoded Float32 PCM strings). Does not clear the buffer. Useful for inspecting or forwarding data mid-session. ### Returns - `Array` - A shallow copy of the audio buffer containing Base64-encoded PCM segments. ``` -------------------------------- ### capture.stopCapture() Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Clears the polling interval, stops the native CoreAudio Process Tap, and sets `isRecording` to `false`. Emits 'stopped' with the full `audioBuffer`. Throws if no capture is in progress. ```APIDOC ## capture.stopCapture() ### Description Clears the polling interval, calls `audio_stop_capture` in the native layer (which invalidates the `SystemAudioTap` and tears down the aggregate device), and sets `isRecording` to `false`. Emits `'stopped'` with the full `audioBuffer`. Throws if no capture is in progress. ### Events - **'stopped'**: Emitted when capture has stopped. Receives the complete `audioBuffer` (`string[]`). ### Request Example ```javascript capture.on('stopped', (audioBuffer) => { console.log(`Stopped. Total segments buffered: ${audioBuffer.length}`); }); try { await capture.stopCapture(); } catch (err) { // 'No audio capture in progress' console.error(err.message); } ``` ``` -------------------------------- ### stopCapture Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Stops the ongoing audio capture process. ```APIDOC ## stopCapture Stop audio capture ```javascript await capture.stopCapture(); ``` ``` -------------------------------- ### Stop Audio Capture Source: https://context7.com/sparticleinc/mac-audio-capture/llms.txt Stop the audio capture process, clear the polling interval, and tear down the native CoreAudio components. The `stopCapture` method emits a `'stopped'` event with the buffered audio data. It throws an error if capture is not in progress. ```javascript capture.on('stopped', (audioBuffer) => { console.log(`Stopped. Total segments buffered: ${audioBuffer.length}`); }); try { await capture.stopCapture(); } catch (err) { // 'No audio capture in progress' console.error(err.message); } ``` -------------------------------- ### Stop Audio Capture Source: https://github.com/sparticleinc/mac-audio-capture/blob/main/README.md Halts the ongoing audio capture process. This should be called to gracefully end the capture session. ```javascript await capture.stopCapture(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.