@audio/loudness-replaygain 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +32 -0
  2. package/replaygain.js +17 -0
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@audio/loudness-replaygain",
3
+ "version": "1.0.0",
4
+ "description": "ReplayGain 2.0 — track gain to the −18 LUFS reference",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "replaygain.js",
8
+ "exports": {
9
+ ".": "./replaygain.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "replaygain.js"
14
+ ],
15
+ "dependencies": {
16
+ "@audio/loudness-lufs": "^1.0.0"
17
+ },
18
+ "keywords": [
19
+ "audio",
20
+ "dsp",
21
+ "loudness",
22
+ "replaygain"
23
+ ],
24
+ "license": "MIT",
25
+ "author": "Dmitry Iv. <dfcreative@gmail.com>",
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
package/replaygain.js ADDED
@@ -0,0 +1,17 @@
1
+ // ReplayGain 2.0 — track gain relative to the −18 LUFS reference loudness
2
+ // (RG2 spec: gain = reference − measured integrated loudness, BS.1770-based).
3
+
4
+ import lufs from '@audio/loudness-lufs'
5
+
6
+ const REFERENCE = -18
7
+
8
+ /**
9
+ * @param {Float32Array|Float32Array[]} channels
10
+ * @param {object} opts — { fs=48000, weights }
11
+ * @returns {{ gain: number, lufs: number }|null} gain in dB to reach −18 LUFS
12
+ */
13
+ export default function replaygain (channels, opts = {}) {
14
+ let measured = lufs(channels, opts)
15
+ if (measured === null) return null
16
+ return { gain: REFERENCE - measured, lufs: measured }
17
+ }