1.0.3 • Published 5 years ago

pulsemixer v1.0.3

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

node-pulsemixer

Nodejs wrapper for pulsemixer. Control system's audio through nodeJS.

Requirements (for pulsemixer)

  • Python >= 3
  • PulseAudio >= 1.0

Instalation

npm i pulsemixer

Basic Usage

const Pulsemixer = require('pulsemixer');

(async function () {
    const pulsemixer = new Pulsemixer(); 

    await pulsemixer.mute()
    await pulsemixer.unmute()
    const volume = await pulsemixer.getVolume();
    await pulsemixer.setVolume(25);
})();

API

Constructor

const pulsemixer = new Pulsemixer();

pulsemixer will be an interface for the default sink. In other words it will create an interface for the default audio card that is currently running.

const pulsemixer = new Pulsemixer(a_sink_id);

You can also pass a sink id to control a specific sound card or sound interface.

Instance methods

MethodParametersReturnsDescription
mute-Promise:VoidMutes system volume
unmute-Promise:VoidUnmutes system volume
toggleMute-Promise:VoidToggle mute
getMute-Promise:BooleanGets current mute status
setVolume{Number}Promise:VoidSets system volume
getVolume-Promise:NumberGet current system volume
changeVolume{Number}Promise:VoidIncrease or decrease system volume by a number

Static methods

MethodParametersReturnsDescription
getSinks-Promise:ArrayReturns system's available sinks
const Pulsemixer = require('pulsemixer');
Pulsemixer.getSinks()
    .then(sinks => {
        /*
            An array of the available sound cards (sinks)
            Each sink has an `id` and `name`
            id can be used to instantiate a new Pulsemixer
        */
    })
    .catch(err => console.error('ERROR...', err));