Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dersimn/node-alsa-volume
https://github.com/dersimn/node-alsa-volume
Last synced: about 14 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/dersimn/node-alsa-volume
- Owner: dersimn
- Created: 2021-03-07T17:19:24.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-08T13:41:30.000Z (almost 3 years ago)
- Last Synced: 2024-11-10T20:40:00.889Z (9 days ago)
- Language: C++
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage
apt install build-essential git libasound2-dev
npm i alsa-volumeExample:
```js
const alsaVolume = require('alsa-volume');console.log('before', alsaVolume.getVolume('default', 'Line')); // Some value
alsaVolume.setVolume('default', 'Line', 42);console.log('after', alsaVolume.getVolume('default', 'Line')); // 42
// Get min/max values for setVolume
const range = alsaVolume.getVolumeRange('default', 'Line');
console.log(range.min);
console.log(range.max);// Mute
alsaVolume.setMute('default', 'Line', false);
alsaVolume.toggleMute('default', 'Line');
console.log(alsaVolume.getMute('default', 'Line')); // true
```Use `alsamixer` to identify mixer names. Usually `Master`, `PCM`, etc.
Combine with [alsa-monitor](https://www.npmjs.com/package/alsa-monitor) to listen for volume changes:
```js
const alsaMonitor = require('alsa-monitor');
const alsaVolume = require('alsa-volume');alsaMonitor.volume.on('change', () => {
console.log(alsaVolume.getVolume('default', 'Line')); // 42
});
```## Usage Dev
apt install build-essential git libasound2-dev
git clone
cd
npm i
npm run-script buildIn a seperate window, run `alsamixer`, then:
node test
## To-Do list
- Implement `snd_mixer_selem_get_playback_volume_range` instead of trial, error and hardcoding. See [1](https://stackoverflow.com/questions/56675099/how-to-change-volume-of-speaker-using-alsa-library), [2](https://www.alsa-project.org/alsa-doc/alsa-lib/group___simple_mixer.html#ga09557e90c11fbd37aeed30938338698b), [3](https://github.com/fcanas/node-native-boilerplate/blob/master/functions.cc).
## Credits
- [alsa-monitor-node](https://github.com/mlaurijsse/alsa-monitor-node)
- [alsa-volume](https://github.com/OpenDingux/alsa-volume)
- [node-native-boilerplate](https://github.com/fcanas/node-native-boilerplate)
- [NodeJS Advanced — How to create a native add-on using C++](https://medium.com/the-guild/nodejs-advanced-how-to-create-a-native-add-on-using-c-588b4f2248cc), [GitHub Project](https://github.com/DAB0mB/node-distance-addon)
- [elamperti](https://github.com/elamperti/node-alsa-volume) for implementing mute & volumeRange functions