node-sound-volume

1.0.2 • Public • Published

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)

/node-sound-volume/

    Package Sidebar

    Install

    npm i node-sound-volume

    Weekly Downloads

    0

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    13.5 kB

    Total Files

    3

    Last publish

    Collaborators

    • bommel24