@thi.ng/dsp 4.7.33 → 4.7.34
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/CHANGELOG.md +8 -1
- package/README.md +1 -1
- package/adsr.d.ts +1 -0
- package/fft.js +6 -6
- package/filter-response.js +3 -3
- package/package.json +12 -12
- package/pipe.d.ts +1 -1
- package/serial.d.ts +1 -1
- package/window.js +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [4.7.34](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.7.34) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
|
|
17
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
18
|
+
|
|
12
19
|
### [4.7.30](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.7.30) (2024-04-20)
|
|
13
20
|
|
|
14
21
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/adsr.d.ts
CHANGED
package/fft.js
CHANGED
|
@@ -33,7 +33,7 @@ function conjugate(src, isImg = true) {
|
|
|
33
33
|
return dest;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const __swapR = (real, n) => {
|
|
37
37
|
const n2 = n >> 1;
|
|
38
38
|
let ii;
|
|
39
39
|
let jj;
|
|
@@ -55,7 +55,7 @@ const swapR = (real, n) => {
|
|
|
55
55
|
j += k;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
const
|
|
58
|
+
const __swapRI = (real, img, n) => {
|
|
59
59
|
const n2 = n >> 1;
|
|
60
60
|
let ii;
|
|
61
61
|
let jj;
|
|
@@ -80,7 +80,7 @@ const swapRI = (real, img, n) => {
|
|
|
80
80
|
j += k;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
const
|
|
83
|
+
const __transform = (real, img, n) => {
|
|
84
84
|
let step = 1;
|
|
85
85
|
let prevStep;
|
|
86
86
|
let i, j, ii, ip;
|
|
@@ -126,12 +126,12 @@ const fft = (complex, window) => {
|
|
|
126
126
|
}
|
|
127
127
|
const n = real.length;
|
|
128
128
|
if (img) {
|
|
129
|
-
|
|
129
|
+
__swapRI(real, img, n);
|
|
130
130
|
} else {
|
|
131
|
-
|
|
131
|
+
__swapR(real, n);
|
|
132
132
|
img = new Float64Array(n);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
__transform(real, img, n);
|
|
135
135
|
return [real, img];
|
|
136
136
|
};
|
|
137
137
|
const ifft = (src) => {
|
package/filter-response.js
CHANGED
|
@@ -4,15 +4,15 @@ import { magDb } from "./convert.js";
|
|
|
4
4
|
import { line } from "./line.js";
|
|
5
5
|
const filterResponseRaw = (zeroes, poles, freq, db = true) => {
|
|
6
6
|
const w0 = TAU * freq;
|
|
7
|
-
const [cp, sp] =
|
|
8
|
-
const [cz, sz] =
|
|
7
|
+
const [cp, sp] = __convolve(poles, w0);
|
|
8
|
+
const [cz, sz] = __convolve(zeroes, w0);
|
|
9
9
|
const mag = Math.sqrt((cz * cz + sz * sz) / (cp * cp + sp * sp));
|
|
10
10
|
const phase = Math.atan2(sp, cp) - Math.atan2(sz, cz);
|
|
11
11
|
return { freq, phase, mag: db ? magDb(mag) : mag };
|
|
12
12
|
};
|
|
13
13
|
const filterResponse = (coeffs, freq, db) => filterResponseRaw(coeffs.zeroes, coeffs.poles, freq, db);
|
|
14
14
|
const freqRange = (fstart, fend, num) => line(fstart, fend, num - 1).take(num);
|
|
15
|
-
const
|
|
15
|
+
const __convolve = (coeffs, w0) => {
|
|
16
16
|
let c = 0;
|
|
17
17
|
let s = 0;
|
|
18
18
|
for (let i = coeffs.length; i-- > 0; ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dsp",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.34",
|
|
4
4
|
"description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/dsp",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@thi.ng/api": "^8.11.
|
|
41
|
-
"@thi.ng/checks": "^3.6.
|
|
42
|
-
"@thi.ng/errors": "^2.5.
|
|
43
|
-
"@thi.ng/math": "^5.
|
|
44
|
-
"@thi.ng/random": "^3.8.
|
|
45
|
-
"@thi.ng/transducers": "^9.0.
|
|
40
|
+
"@thi.ng/api": "^8.11.3",
|
|
41
|
+
"@thi.ng/checks": "^3.6.5",
|
|
42
|
+
"@thi.ng/errors": "^2.5.8",
|
|
43
|
+
"@thi.ng/math": "^5.11.0",
|
|
44
|
+
"@thi.ng/random": "^3.8.1",
|
|
45
|
+
"@thi.ng/transducers": "^9.0.6"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.
|
|
49
|
-
"esbuild": "^0.21.
|
|
48
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
49
|
+
"esbuild": "^0.21.5",
|
|
50
50
|
"typedoc": "^0.25.13",
|
|
51
|
-
"typescript": "^5.
|
|
51
|
+
"typescript": "^5.5.2"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"allpass",
|
|
@@ -288,5 +288,5 @@
|
|
|
288
288
|
],
|
|
289
289
|
"year": 2015
|
|
290
290
|
},
|
|
291
|
-
"gitHead": "
|
|
291
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
292
292
|
}
|
package/pipe.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare function pipe<A, B>(src: IGen<A>, proc: IProc<A, B>): IGen<B>;
|
|
|
10
10
|
export declare function pipe<A, B, C>(src: IGen<A>, a: IProc<A, B>, b: IProc<B, C>): IGen<C>;
|
|
11
11
|
export declare function pipe<A, B, C, D>(src: IGen<A>, a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>): IGen<D>;
|
|
12
12
|
export declare function pipe<A, B, C, D, E>(src: IGen<A>, a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>): IGen<E>;
|
|
13
|
-
export declare function pipe<A, B, C, D, E>(src: IGen<A>, a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>, ...
|
|
13
|
+
export declare function pipe<A, B, C, D, E>(src: IGen<A>, a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>, ...procs: IProc<any, any>[]): IGen<any>;
|
|
14
14
|
//# sourceMappingURL=pipe.d.ts.map
|
package/serial.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { AProc } from "./aproc.js";
|
|
|
14
14
|
export declare function serial<A, B, C>(a: IProc<A, B>, b: IProc<B, C>): IProc<A, C>;
|
|
15
15
|
export declare function serial<A, B, C, D>(a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>): IProc<A, D>;
|
|
16
16
|
export declare function serial<A, B, C, D, E>(a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>): IProc<A, E>;
|
|
17
|
-
export declare function serial<A, B, C, D, E>(a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>, ...
|
|
17
|
+
export declare function serial<A, B, C, D, E>(a: IProc<A, B>, b: IProc<B, C>, c: IProc<C, D>, d: IProc<D, E>, ...procs: IProc<any, any>[]): IProc<A, any>;
|
|
18
18
|
export declare class Serial2<A, B, C> extends AProc<A, C> {
|
|
19
19
|
protected _a: IProc<A, B>;
|
|
20
20
|
protected _b: IProc<B, C>;
|
package/window.js
CHANGED
|
@@ -27,34 +27,34 @@ const windowLanczos = (i, n) => {
|
|
|
27
27
|
i = PI * (2 * i / n - 1);
|
|
28
28
|
return sin(i) / i;
|
|
29
29
|
};
|
|
30
|
-
const
|
|
30
|
+
const __windowCosSum = (k) => {
|
|
31
31
|
let ik = 1 - k;
|
|
32
32
|
return (i, n) => k - ik * cos(TAU * i / n);
|
|
33
33
|
};
|
|
34
|
-
const
|
|
34
|
+
const __windowCosSum3 = (k1, k2, k3) => (i, n) => {
|
|
35
35
|
i /= n;
|
|
36
36
|
return k1 + k2 * cos(TAU * i) + k3 * cos(PI4 * i);
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const __windowCosSum4 = (k1, k2, k3, k4) => (i, n) => {
|
|
39
39
|
i /= n;
|
|
40
40
|
return k1 + k2 * cos(TAU * i) + k3 * cos(PI4 * i) + k4 * cos(PI6 * i);
|
|
41
41
|
};
|
|
42
|
-
const windowHann =
|
|
43
|
-
const windowHamming =
|
|
44
|
-
const windowBlackman =
|
|
45
|
-
const windowBlackmanHarris =
|
|
42
|
+
const windowHann = __windowCosSum(0.5);
|
|
43
|
+
const windowHamming = __windowCosSum(0.53836);
|
|
44
|
+
const windowBlackman = __windowCosSum3(0.42, -0.5, 0.08);
|
|
45
|
+
const windowBlackmanHarris = __windowCosSum4(
|
|
46
46
|
0.35875,
|
|
47
47
|
-0.48829,
|
|
48
48
|
0.14128,
|
|
49
49
|
0.01168
|
|
50
50
|
);
|
|
51
|
-
const windowNuttall =
|
|
51
|
+
const windowNuttall = __windowCosSum4(
|
|
52
52
|
0.355768,
|
|
53
53
|
-0.487396,
|
|
54
54
|
0.144232,
|
|
55
55
|
-0.012604
|
|
56
56
|
);
|
|
57
|
-
const windowBlackmanNuttall =
|
|
57
|
+
const windowBlackmanNuttall = __windowCosSum4(
|
|
58
58
|
0.3635819,
|
|
59
59
|
-0.4891775,
|
|
60
60
|
0.1365995,
|