@audio/effect-exciter 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/exciter.js +38 -0
- package/package.json +38 -0
package/exciter.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exciter — psychoacoustic harmonic synthesis for presence/air.
|
|
3
|
+
* Highpass extracts high-band, soft saturation generates harmonics,
|
|
4
|
+
* mixed back into dry signal. Aphex-style aural exciter.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let {sin, tanh, PI} = Math
|
|
8
|
+
|
|
9
|
+
export default function exciter (data, params) {
|
|
10
|
+
let freq = params.freq ?? 3000 // highpass cutoff Hz
|
|
11
|
+
let drive = params.drive ?? 0.5 // saturation 0–1 → 1×–10× gain
|
|
12
|
+
let amount = params.amount ?? 0.5 // exciter mix 0–1
|
|
13
|
+
let fs = params.fs || 44100
|
|
14
|
+
|
|
15
|
+
if (params._lp == null) {
|
|
16
|
+
params._lp = 0
|
|
17
|
+
params._bp = 0
|
|
18
|
+
}
|
|
19
|
+
let lp = params._lp, bp = params._bp
|
|
20
|
+
let f = 2 * sin(PI * freq / fs)
|
|
21
|
+
let q = 0.5 // moderate damping
|
|
22
|
+
let g = 1 + drive * 9 // 1×–10×
|
|
23
|
+
|
|
24
|
+
for (let i = 0, l = data.length; i < l; i++) {
|
|
25
|
+
let x = data[i]
|
|
26
|
+
// Chamberlin SVF — highpass tap generates high-band
|
|
27
|
+
lp += f * bp
|
|
28
|
+
let hp = x - lp - q * bp
|
|
29
|
+
bp += f * hp
|
|
30
|
+
// Tanh saturation synthesizes harmonics above `freq`
|
|
31
|
+
data[i] = x + amount * tanh(hp * g) * 0.5
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
params._lp = lp
|
|
35
|
+
params._bp = bp
|
|
36
|
+
|
|
37
|
+
return data
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/effect-exciter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Exciter — psychoacoustic harmonic synthesis for presence/air",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "exciter.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./exciter.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"exciter.js"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"audio",
|
|
17
|
+
"dsp",
|
|
18
|
+
"effect",
|
|
19
|
+
"exciter"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Dmitry Iv. <dfcreative@gmail.com>",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/audiojs/effect.git",
|
|
26
|
+
"directory": "packages/effect-exciter"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/audiojs/effect/tree/main/packages/effect-exciter",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/audiojs/effect/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|