@audio/spectral-flux 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 (3) hide show
  1. package/README.md +5 -0
  2. package/flux.js +12 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @audio/spectral-flux
2
+
3
+ > Spectral flux — frame-to-frame magnitude spectrum change
4
+
5
+ Planned — not implemented yet. See the umbrella README for status and sources.
package/flux.js ADDED
@@ -0,0 +1,12 @@
1
+ // Spectral flux — frame-to-frame magnitude change. Euclidean by default (FFmpeg aspectralstats);
2
+ // { rectified: true } sums positive differences only (onset-detection flavour).
3
+ export default function flux (mag, prev, { rectified = false } = {}) {
4
+ if (!prev) return 0
5
+ let v = 0
6
+ for (let k = 0; k < mag.length; k++) {
7
+ let d = mag[k] - (prev[k] || 0)
8
+ if (rectified) { if (d > 0) v += d }
9
+ else v += d * d
10
+ }
11
+ return rectified ? v : Math.sqrt(v)
12
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@audio/spectral-flux",
3
+ "version": "1.0.0",
4
+ "description": "Spectral flux — frame-to-frame magnitude change. Euclidean by default (FFmpeg aspectralstats);",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "flux.js",
8
+ "exports": {
9
+ ".": "./flux.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "flux.js"
14
+ ],
15
+ "keywords": [
16
+ "audio",
17
+ "dsp",
18
+ "spectral",
19
+ "features",
20
+ "flux"
21
+ ],
22
+ "license": "MIT",
23
+ "author": "Dmitry Iv. <dfcreative@gmail.com>",
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ }
30
+ }