@audio/effect-exciter 1.1.4 → 1.2.1
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 +3 -3
- package/audio.d.ts +3 -1
- package/audio.js +2 -2
- package/exciter.d.ts +3 -1
- package/exciter.js +13 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,12 @@ import exciter from '@audio/effect-exciter'
|
|
|
12
12
|
|
|
13
13
|
Aphex-style aural exciter. Extracts the high band via SVF highpass, runs it through tanh saturation to synthesize harmonics, then mixes the harmonic residue back into the dry signal. Adds perceived "air" and "presence" without EQ boost.
|
|
14
14
|
|
|
15
|
-
**`
|
|
15
|
+
**`fc`** highpass cutoff Hz (default 3000; `freq` still accepted) · **`drive`** saturation amount 0–1 (default 0.5, maps to 1–10× gain) · **`amount`** mix-in level 0–1 (default 0.5) · **`fs`** sample rate
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import
|
|
18
|
+
import exciter from '@audio/effect-exciter'
|
|
19
19
|
|
|
20
|
-
let p = {
|
|
20
|
+
let p = { fc: 4000, drive: 0.6, amount: 0.4, fs: 44100 }
|
|
21
21
|
for (let buf of stream) exciter(buf, p)
|
|
22
22
|
```
|
|
23
23
|
|
package/audio.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Liv
|
|
|
11
11
|
/** Chainable-host options for 'exciter' */
|
|
12
12
|
export interface ExciterOptions {
|
|
13
13
|
/** 500..8000 Hz (default 3000) */
|
|
14
|
+
"fc"?: Auto
|
|
15
|
+
/** @deprecated former name of "fc" */
|
|
14
16
|
"freq"?: Auto
|
|
15
17
|
/** 0..1 (default 0.5) */
|
|
16
18
|
"drive"?: Auto
|
|
@@ -25,7 +27,7 @@ export declare const exciter: {
|
|
|
25
27
|
channels: "any"
|
|
26
28
|
params: {
|
|
27
29
|
/** 500..8000 Hz (default 3000) */
|
|
28
|
-
"
|
|
30
|
+
"fc": { type: "number", default: 3000, alias: "freq" }
|
|
29
31
|
/** 0..1 (default 0.5) */
|
|
30
32
|
"drive": { type: "number", default: 0.5 }
|
|
31
33
|
/** 0..1 (default 0.5) */
|
package/audio.js
CHANGED
|
@@ -11,7 +11,7 @@ export const exciter = (ctx) => {
|
|
|
11
11
|
if (!inp || !inp.length) return
|
|
12
12
|
for (let c = 0; c < inp.length; c++) {
|
|
13
13
|
const p = chP[c]
|
|
14
|
-
p.
|
|
14
|
+
p.fc = params.fc[0]
|
|
15
15
|
p.drive = params.drive[0]
|
|
16
16
|
p.amount = params.amount[0]
|
|
17
17
|
out[c].set(inp[c])
|
|
@@ -21,7 +21,7 @@ export const exciter = (ctx) => {
|
|
|
21
21
|
}
|
|
22
22
|
exciter.channels = 'any'
|
|
23
23
|
exciter.params = {
|
|
24
|
-
|
|
24
|
+
fc: { type: 'number', min: 500, max: 8000, default: 3000, unit: 'Hz', curve: 'log', alias: 'freq' },
|
|
25
25
|
drive: { type: 'number', min: 0, max: 1, default: 0.5 },
|
|
26
26
|
amount: { type: 'number', min: 0, max: 1, default: 0.5 },
|
|
27
27
|
}
|
package/exciter.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Exciter — Aphex-style aural exciter; SVF highpass extracts the high band, tanh saturation synthesizes harmonics, mixed back into dry. */
|
|
2
2
|
export interface ExciterOptions {
|
|
3
3
|
/** highpass cutoff, Hz, default 3000 */
|
|
4
|
+
fc?: number
|
|
5
|
+
/** @deprecated former name of `fc` */
|
|
4
6
|
freq?: number
|
|
5
7
|
/** saturation amount, 0–1, maps to 1×–10× gain, default 0.5 */
|
|
6
8
|
drive?: number
|
|
@@ -14,4 +16,4 @@ export interface ExciterOptions {
|
|
|
14
16
|
* Mutates `data` in place and returns the same reference. Pass the same params
|
|
15
17
|
* object across calls — the SVF integrator state persists on it (`_lp`, `_bp`).
|
|
16
18
|
*/
|
|
17
|
-
export default function exciter(data:
|
|
19
|
+
export default function exciter<T extends Float32Array | Float64Array>(data: T, params?: ExciterOptions): T
|
package/exciter.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* mixed back into dry signal. Aphex-style aural exciter.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
let {
|
|
7
|
+
let {tan, tanh, min, PI} = Math
|
|
8
8
|
|
|
9
|
-
export default function exciter (data, params) {
|
|
10
|
-
let
|
|
9
|
+
export default function exciter (data, params = {}) {
|
|
10
|
+
let fc = params.fc ?? params.freq ?? 3000 // highpass cutoff Hz (`freq`: former name)
|
|
11
11
|
let drive = params.drive ?? 0.5 // saturation 0–1 → 1×–10× gain
|
|
12
12
|
let amount = params.amount ?? 0.5 // exciter mix 0–1
|
|
13
13
|
let fs = params.fs || 44100
|
|
@@ -17,17 +17,20 @@ export default function exciter (data, params) {
|
|
|
17
17
|
params._bp = 0
|
|
18
18
|
}
|
|
19
19
|
let lp = params._lp, bp = params._bp
|
|
20
|
-
let
|
|
21
|
-
let
|
|
20
|
+
let w = tan(PI * min(fc, 0.49 * fs) / fs) // prewarped cutoff
|
|
21
|
+
let k = 0.5 // moderate damping (Q 2)
|
|
22
|
+
let a = 1 / (1 + w * (w + k))
|
|
22
23
|
let g = 1 + drive * 9 // 1×–10×
|
|
23
24
|
|
|
24
25
|
for (let i = 0, l = data.length; i < l; i++) {
|
|
25
26
|
let x = data[i]
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
bp
|
|
30
|
-
|
|
27
|
+
// trapezoidal state-variable filter (Zavalishin, The Art of VA Filter Design, ch. 3–4; Simper 2013),
|
|
28
|
+
// highpass tap: stable at any fc below Nyquist, where Chamberlin's form diverged once f² + 2fk > 4
|
|
29
|
+
let v1 = a * (bp + w * (x - lp)), v2 = lp + w * v1
|
|
30
|
+
bp = 2 * v1 - bp
|
|
31
|
+
lp = 2 * v2 - lp
|
|
32
|
+
let hp = x - k * v1 - v2
|
|
33
|
+
// Tanh saturation synthesizes harmonics above `fc`
|
|
31
34
|
data[i] = x + amount * tanh(hp * g) * 0.5
|
|
32
35
|
}
|
|
33
36
|
|