@audio/effect-exciter 1.2.0 → 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.
Files changed (2) hide show
  1. package/exciter.js +10 -7
  2. package/package.json +1 -1
package/exciter.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * mixed back into dry signal. Aphex-style aural exciter.
5
5
  */
6
6
 
7
- let {sin, tanh, PI} = Math
7
+ let {tan, tanh, min, PI} = Math
8
8
 
9
9
  export default function exciter (data, params = {}) {
10
10
  let fc = params.fc ?? params.freq ?? 3000 // highpass cutoff Hz (`freq`: former name)
@@ -17,16 +17,19 @@ export default function exciter (data, params = {}) {
17
17
  params._bp = 0
18
18
  }
19
19
  let lp = params._lp, bp = params._bp
20
- let f = 2 * sin(PI * fc / fs)
21
- let q = 0.5 // moderate damping
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
- // Chamberlin SVF — highpass tap generates high-band
27
- lp += f * bp
28
- let hp = x - lp - q * bp
29
- bp += f * hp
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
30
33
  // Tanh saturation synthesizes harmonics above `fc`
31
34
  data[i] = x + amount * tanh(hp * g) * 0.5
32
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/effect-exciter",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Exciter — psychoacoustic harmonic synthesis for presence/air",
5
5
  "type": "module",
6
6
  "sideEffects": false,