@audio/dynamics-fet 0.1.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/fet.js +36 -0
- package/package.json +44 -0
package/fet.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// FET compressor model (1176 class) — very fast peak detection (0.2 ms default attack),
|
|
2
|
+
// fixed-style high ratios, firm knee. Character = speed, not color.
|
|
3
|
+
import { envelope } from '@audio/dynamics-envelope'
|
|
4
|
+
import { compressorGain } from '@audio/dynamics-compressor'
|
|
5
|
+
import { writer, concat, db2lin, lin2db, timeCoef } from '@audio/dynamics-core'
|
|
6
|
+
|
|
7
|
+
export default function fet (data, opts) {
|
|
8
|
+
if (!(data instanceof Float32Array)) return writer(fetStream(data))
|
|
9
|
+
let s = fetStream(opts)
|
|
10
|
+
return concat(s.write(data), s.flush())
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function fetStream (opts = {}) {
|
|
14
|
+
let sr = opts.sampleRate || opts.fs || 44100
|
|
15
|
+
let threshold = opts.threshold ?? -18
|
|
16
|
+
let ratio = opts.ratio ?? 8
|
|
17
|
+
let knee = opts.knee ?? 3
|
|
18
|
+
let makeup = opts.makeup ?? 0
|
|
19
|
+
let env = envelope({ ...opts, sampleRate: sr, detector: 'peak', attack: opts.attack ?? 0.2, release: 1 })
|
|
20
|
+
let gr = 0
|
|
21
|
+
let aCoef = timeCoef(opts.attack ?? 0.2, sr)
|
|
22
|
+
let rCoef = timeCoef(opts.release ?? 120, sr)
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
write (chunk) {
|
|
26
|
+
let out = new Float32Array(chunk.length)
|
|
27
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
28
|
+
let target = compressorGain(lin2db(env(chunk[i])), threshold, ratio, knee)
|
|
29
|
+
gr = target < gr ? target + (gr - target) * aCoef : target + (gr - target) * rCoef
|
|
30
|
+
out[i] = chunk[i] * db2lin(gr + makeup)
|
|
31
|
+
}
|
|
32
|
+
return out
|
|
33
|
+
},
|
|
34
|
+
flush () { return new Float32Array(0) }
|
|
35
|
+
}
|
|
36
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/dynamics-fet",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "FET compressor model — 0.2 ms peak attack, high ratios, firm knee (1176 class)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "fet.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./fet.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"fet.js"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@audio/dynamics-core": "^0.1.0",
|
|
17
|
+
"@audio/dynamics-envelope": "^0.1.0",
|
|
18
|
+
"@audio/dynamics-compressor": "^0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"audio",
|
|
22
|
+
"dsp",
|
|
23
|
+
"dynamics",
|
|
24
|
+
"compressor",
|
|
25
|
+
"fet"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"author": "Dmitry Iv. <dfcreative@gmail.com>",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/audiojs/dynamics.git",
|
|
32
|
+
"directory": "packages/dynamics-fet"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/audiojs/dynamics/tree/main/packages/dynamics-fet",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/audiojs/dynamics/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|