Cross platform module for interacting with Audio Devices and handling System Audio. Node bindings for the cpvc crate.
- Windows
- Mac OS X
- Linux (PulseAudio only)
Important
cpvcrequires PulseAudio server to work on Linux.
| ✓ | Platform | arch |
|---|---|---|
| ✅ | Windows | x64 |
| ✅ | Windows | x86 |
| ✅ | Windows | arm64 |
| ✅ | macOS | x64 |
| ✅ | macOS | arm64 |
| ✅ | Linux | x64 (gnu) |
| ✅ | Linux | x64 (musl) |
| ✅ | Linux | arm (gnu) |
| ❌ | Linux | arm64 (musl) |
| ❌ | FreeBSD | x64 |
Note: To build package from source,
libasound2-devandlibpulse-devlibraries are required. (eg.sudo apt install libasound2-dev libpulse-dev).
# npm
npm i @touchifyapp/cpvc
# pnpm
pnpm add @touchifyapp/cpvc
#yarn
yarn add @touchifyapp/cpvcimport { getSoundDevices, getMute, setMute, getSystemVolume, setSystemVolume } from "../index.js";
// get system sound devices names
const devices = getSoundDevices();
console.log(devices); // prints ['devicename']
// check whether the system is muted
const muted = getMute();
console.log("is muted:", muted); // prints is muted: false
// set whether the system is muted
setMute(true);
const muted = getMute();
console.log("is muted:", muted); // prints is muted: true
// get current system volume
const volume = getSystemVolume();
console.log("volume:", volume); // prints volume: 30
// set system volume
setSystemVolume(50);
const volume = getSystemVolume();
console.log("volume:", volume); // prints volume: 50- Install the latest
Rust - Install
Node.js@20+which fully supportedNode-API - Run
corepack enable
# clone repository
git clone https://github.com/touchifyapp/node-cpvc
cd node-cpvc
# install packages
pnpm i
# build and test
pnpm build
pnpm testAfter pnpm build command, you can see cpvc.[darwin|win32|linux].node file in project root.
This is the native addon built from lib.rs.
Run pnpm test to testing native addon.
Note: a build is necessary before running
pnpm testif changes were applied on the rust code.
With GitHub Actions, each commit and pull request will be built and tested automatically in [node@20, node@22, node@24] x [macOS, Linux, Windows] matrix.