@audio/spectral-flatness 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.
- package/README.md +5 -0
- package/flatness.js +12 -0
- package/package.json +30 -0
package/README.md
ADDED
package/flatness.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Spectral flatness — geometric/arithmetic mean ratio of the POWER spectrum, 0 (tonal) … 1 (noise).
|
|
2
|
+
// Peeters 2004 §6.3; power spectrum per the audio-core fix.
|
|
3
|
+
export default function flatness (mag) {
|
|
4
|
+
let n = mag.length
|
|
5
|
+
if (!n) return 0
|
|
6
|
+
let logSum = 0, sum = 0
|
|
7
|
+
for (let k = 0; k < n; k++) {
|
|
8
|
+
let p = mag[k] * mag[k] + 1e-12
|
|
9
|
+
logSum += Math.log(p); sum += p
|
|
10
|
+
}
|
|
11
|
+
return Math.exp(logSum / n) / (sum / n)
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/spectral-flatness",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Spectral flatness — geometric/arithmetic mean ratio of the POWER spectrum, 0 (tonal) … 1 (noise).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "flatness.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./flatness.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"flatness.js"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"audio",
|
|
17
|
+
"dsp",
|
|
18
|
+
"spectral",
|
|
19
|
+
"features",
|
|
20
|
+
"flatness"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Dmitry Iv. <dfcreative@gmail.com>",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
|
+
}
|