https://github.com/audiojs/a-weighting
:ear: A-weighting and other noise weighting
https://github.com/audiojs/a-weighting
Last synced: 8 months ago
JSON representation
:ear: A-weighting and other noise weighting
- Host: GitHub
- URL: https://github.com/audiojs/a-weighting
- Owner: audiojs
- License: mit
- Created: 2016-05-21T20:13:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T17:25:09.000Z (over 8 years ago)
- Last Synced: 2025-08-29T15:51:00.138Z (9 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 43
- Watchers: 13
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# a-weighting [](https://travis-ci.org/audiojs/audio) [](http://github.com/badges/stability-badges) [](https://greenkeeper.io/)
Perform A-weighting (and others) for a frequency.
Useful for creating believable spectrum images and audio measurements.

## Usage
[](https://npmjs.org/package/a-weighting/)
```js
var aWeight = require('a-weighting/a');
var ft = require('fourier-transform');
//get a-weighted frequencies
var frequencies = ft(waveform).map(function (magnitude, i, data) {
var frequency = 22050 * i / data;
return aWeight(frequency) * magnitude;
});
```
Note that weight function returns normalized `0..1` weight values, it does not do decibels calculation. If you need to convert weight to decibels, do `20 * Math.log(weight) / Math.log(10)`.
Implemented weights:
* [A-weighting](https://en.wikipedia.org/wiki/A-weighting)
* B-weighting
* C-weighting
* D-weighting
* Z-weighting (zero weighting)
* [M-weighting](https://en.wikipedia.org/wiki/ITU-R_468_noise_weighting)
## Credits
Thanks to all the specialists who researched and described these curves (years of work I guess) and wikipedia for detailed articles on this.
## Related
* [fourier-transform](https://github.com/scijs/fourier-transform) — fft fast implementation.
* [gl-spectrum](https://github.com/audio-lab/gl-spectrum) — spectrum rendering component.
* [Equal-loudness-contours](https://en.wikipedia.org/wiki/Equal-loudness_contour).