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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sound-volume

v1.0.2

Published

This module allows you to get and change general information and current volume level for all active sound components on your system, and allows you to mute and unmute them instantly.

Downloads

4

Readme

Node Sound Volume

This module allows you to get and change general information and current volume level for all active sound components on your system, and allows you to mute and unmute them instantly.

Currently only working on windows.

It depends on Nir Sofers work (SoundVolumeView & SoundVolumeCommandLine).

Installation

npm i node-sound-volume

Put the "svcl.exe" file somewhere you remember or into your PATH environment variable and point your constructor there...

const soundVolume = require("node-sound-volume")(
  "C://PortableSoftware//svcl.exe"
);

let volumes = await soundVolume.listSoundVolumes({
  type: "Application",
  direction: "Render",
});
console.log(volumes);

Functions

soundVolume.listSoundVolumes(filter?)

Lists all currently active "sound volume" components on the system. You can filter by any returned key. For example to only show output devices you can do:

soundVolume.listSoundVolumes({ direction: "Render", type: "Device" });

"types" are

Device, Subunit, Application;

"direction" is

Render, Capture;

You can pass any "sound volume" into one of the following functions to manipulate it:

soundVolume.mute(soundVolumes[0]);
soundVolume.unmute(soundVolumes[0]);
soundVolume.setVolume(soundVolumes[0], 50); // set volume to 50 percent
soundVolume.changeVolume(soundVolumes[0], -5); // changes volume -5 percent

Devices only:

soundVolume.setDefaultAll(soundVolumes[0]); // changes default device for all usages
soundVolume.setDefaultConsole(soundVolumes[0]); // changes default device for console usage
soundVolume.setDefaultMultimedia(soundVolumes[0]); // changes default device for multimedia usage (the one that windows shows in its settings)
soundVolume.setDefaultCommunication(soundVolumes[0]); // changes default communication device (windows shows this as communication device in its settings)
soundVolume.setAppDeviceAll(soundVolumes[0], process); // changes device for all usages in this application only (process can an executable name like "chrome.exe" or a process ID like "1234")
soundVolume.setAppDeviceConsole(soundVolumes[0], process); // changes device for console usage in this application only (process can an executable name like "chrome.exe" or a process ID like "1234")
soundVolume.setAppDeviceMultimedia(soundVolumes[0], process); // changes device for multimedia usage in this application only (process can an executable name like "chrome.exe" or a process ID like "1234")
soundVolume.setAppDeviceCommunication(soundVolumes[0], process); // changes device for communication usage in this application only (process can an executable name like "chrome.exe" or a process ID like "1234")
soundVolume.disable(soundVolumes[0]);
soundVolume.enable(soundVolumes[0]);
soundVolume.allowExclusiveControlOverDevice(soundVolumes[0]); // Sets the 'Allow applications to take exclusive control of this device' option for the specified device
soundVolume.preventExclusiveControlOverDevice(soundVolumes[0]); // Unsets the 'Allow applications to take exclusive control of this device' option for the specified device
soundVolume.allowExclusivePriorityOverDevice(soundVolumes[0]); // Sets the 'Give exclusive mode applications priority' option for the specified device
soundVolume.preventExclusivePriorityOverDevice(soundVolumes[0]); // Unsets the 'Give exclusive mode applications priority' option for the specified device
soundVolume.setDefaultFormat(soundVolumes[0], bitsPerSample, sampleRate, channels); //Sets the default format of the device forr example:
soundVolume.setDefaultFormat(soundVolumes[0], 24, 48000, 4); // '4 channel,24 bit, 48000 Hz(Studio Quality)'

Capture devices only:

soundVolume.listenToDevice(soundVolumes[0]); // Sets the 'Listen to this device' value
soundVolume.stopListenToDevice(soundVolumes[0]); // Unsets the 'Listen to this device' value
soundVolume.setPlaybackThroughDevice(soundVolumes[0], soundVolumes[1]); // Sets the 'Playback through this device' value. (First has to be a Capture device and second has to be a render device)