@audio/spatial-midside 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/midside.js +20 -0
- package/package.json +29 -0
package/midside.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Mid/side matrix — encode L/R → M/S and back; the substrate of widening, vocal
|
|
2
|
+
// isolation (@audio/vocals) and M/S processing. decode accepts a width factor.
|
|
3
|
+
|
|
4
|
+
export function encode ([L, R]) {
|
|
5
|
+
for (let i = 0; i < L.length; i++) {
|
|
6
|
+
let m = (L[i] + R[i]) * 0.5, s = (L[i] - R[i]) * 0.5
|
|
7
|
+
L[i] = m; R[i] = s
|
|
8
|
+
}
|
|
9
|
+
return [L, R]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function decode ([M, S], { width = 1 } = {}) {
|
|
13
|
+
for (let i = 0; i < M.length; i++) {
|
|
14
|
+
let m = M[i], s = S[i] * width
|
|
15
|
+
M[i] = m + s; S[i] = m - s
|
|
16
|
+
}
|
|
17
|
+
return [M, S]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default { encode, decode }
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/spatial-midside",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mid/side encode-decode — L/R ↔ M/S matrix with width control",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "midside.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./midside.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"midside.js"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"audio",
|
|
17
|
+
"dsp",
|
|
18
|
+
"spatial",
|
|
19
|
+
"midside"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Dmitry Iv. <dfcreative@gmail.com>",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|