npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

process-audio-capture

v1.0.14

Published

Native process-level audio capture for Node.js and Electron applications

Readme

process-audio-capture

English | 中文

Node.js 和 Electron 原生插件,支持捕获指定进程的音频数据

快速开始

系统要求

  • macOS 14.4+
  • Windows 10+
  • Linux 暂不支持

安装

npm install process-audio-capture

使用示例

Electron 应用基本使用

1. 主进程设置

import { setupAudioCaptureIpc } from "process-audio-capture/dist/main";
// 设置 IPC 处理程序
setupAudioCaptureIpc();

2. Preload 脚本

import { exposeAudioCaptureApi } from "process-audio-capture/dist/preload";
// 暴露 API 给渲染进程
exposeAudioCaptureApi();

3. 渲染进程使用

// 使用 window.processAudioCapture 访问所有 API

// 获取进程列表
const processes = await window.processAudioCapture.getProcessList();

// 监听音频数据
window.processAudioCapture.onAudioData((audioData) => {
  console.log("音频数据:", audioData);
});

// 开始捕获指定进程音频
const pid = processes[0].pid; // 示例:捕获第一个进程
await window.processAudioCapture.startCapture(pid);

Electron 应用自定义实现

// 主进程引入 auidioCapture 对象或 AudioCapture 类 
// 自主定义 IPC 处理逻辑
import { audioCapture, AudioCapture } from "process-audio-capture";

Node.js 应用

const {audioCapture} = require("process-audio-capture");

// 检查平台支持
if (audioCapture.isPlatformSupported()) {
  // 请求权限
  const permission = await audioCapture.requestPermission();

  if (permission.status === "authorized") {
    // 获取进程列表
    const processes = audioCapture.getProcessList();

    // 开始捕获音频
    audioCapture.startCapture(processes[0].pid, (audioData) => {
      console.log("音频数据:", audioData);
    });
  }
}

完整示例

API 参考

核心方法

| 方法 | 描述 | 返回值 | | ----------------------------- | ------------------------ | --------------------------- | | isPlatformSupported() | 检查当前平台是否支持 | boolean | | checkPermission() | 检查音频捕获权限 | PermissionStatus | | requestPermission() | 请求音频捕获权限 | Promise<PermissionStatus> | | getProcessList() | 获取可捕获音频的进程列表 | ProcessInfo[] | | startCapture(pid, callback) | 开始捕获指定进程音频 | boolean | | stopCapture() | 停止音频捕获 | boolean |

权限配置

Windows

无需特殊权限配置

macOS

需要 NSAudioCaptureUsageDescription 权限

⚠️ 开发注意事项

  • 只有打包后的应用调用 requestPermission() 才会弹出权限对话框
  • 开发环境下需要将 IDE 或 Electron.app 添加到系统权限中: 系统设置隐私与安全性录屏与系统录音仅系统录音

致谢

感谢以下项目提供的灵感和参考:

相关资源


许可证

MIT License