node-audio-windows

1.0.1 • Public • Published

Native Node.js volume controls for Windows

A native Windows API binding to control the default audio device. Supports set/get the volume and get the muted state and set the muted state.

npm npm

How to Use

const { volume } = require('node-volume-windows');
 
// the functions the volume controller exposes
const { getVolume, setVolume, isMuted, setMute } = volume;
 
// to get the system volume
const currentVolume = getVolume();
 
// to set the volume to 43.
setVolume(0.43);
 
// to know if the system is muted
isMuted();
 
// to mute
setMute(true);
 
// to unmute
setMute(false);
 
// to toggle mute
setMute(!isMuted());

Note

Windows displays the audio at the scale from 0-100, but the library uses instead the scale 0.0 - 1.0 to match the scale Windows API actually uses.

Development

To build the project you need in Windows to install windows-build-tools in an elevated PowerShell prompt npm install --global --production windows-build-tools and then npm install or if you have node-gyp installed globally

$ node-gyp configure
$ node-gyp build

The repository contains a demo of the usage

$ node demo.js

Next steps

  • Expose the microphone API
  • Support controlling multiple audio devices

Licence & Copyright

Copyright (c) 2018 Jarno Lonardi The package node-audio-windows is licensed under MIT license.

Package Sidebar

Install

npm i node-audio-windows

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

11.6 kB

Total Files

7

Last publish

Collaborators

  • jlonardi