@audio/filter-dcblocker 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.
Files changed (2) hide show
  1. package/dc-blocker.js +26 -0
  2. package/package.json +38 -0
package/dc-blocker.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * DC blocking filter
3
+ * H(z) = (1 - z^-1) / (1 - R*z^-1)
4
+ *
5
+ * @module audio-filter/effect/dc-blocker
6
+ */
7
+
8
+ export default function dcBlocker (data, params) {
9
+ let x1 = params.x1 != null ? params.x1 : 0
10
+ let y1 = params.y1 != null ? params.y1 : 0
11
+ let R = params.R
12
+ if (R == null) R = .995
13
+
14
+ for (let i = 0, l = data.length; i < l; i++) {
15
+ let x = data[i]
16
+ let y = x - x1 + R * y1
17
+ x1 = x
18
+ y1 = y
19
+ data[i] = y
20
+ }
21
+
22
+ params.x1 = x1
23
+ params.y1 = y1
24
+
25
+ return data
26
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@audio/filter-dcblocker",
3
+ "version": "1.0.0",
4
+ "description": "DC blocking filter",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "dc-blocker.js",
8
+ "exports": {
9
+ ".": "./dc-blocker.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "dc-blocker.js"
14
+ ],
15
+ "keywords": [
16
+ "audio",
17
+ "dsp",
18
+ "filter",
19
+ "dcblocker"
20
+ ],
21
+ "license": "MIT",
22
+ "author": "Dmitry Iv. <dfcreative@gmail.com>",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/audiojs/filter.git",
26
+ "directory": "packages/filter-dcblocker"
27
+ },
28
+ "homepage": "https://github.com/audiojs/filter/tree/main/packages/filter-dcblocker",
29
+ "bugs": {
30
+ "url": "https://github.com/audiojs/filter/issues"
31
+ },
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }