@thi.ng/dsp 4.1.4 → 4.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/CHANGELOG.md +11 -1
- package/README.md +2 -2
- package/add.d.ts +3 -3
- package/add.js +3 -3
- package/addg.d.ts +2 -2
- package/addg.js +2 -2
- package/const.d.ts +1 -1
- package/const.js +1 -1
- package/convert.d.ts +13 -13
- package/convert.js +13 -13
- package/dcblock.d.ts +1 -1
- package/dcblock.js +1 -1
- package/delay.d.ts +6 -6
- package/delay.js +6 -6
- package/fft.d.ts +18 -18
- package/fft.js +16 -16
- package/impulse.d.ts +2 -2
- package/impulse.js +2 -2
- package/iterable.d.ts +2 -2
- package/iterable.js +2 -2
- package/multiplex.d.ts +2 -2
- package/osc-additive.d.ts +4 -4
- package/osc-additive.js +4 -4
- package/osc-dsf.d.ts +8 -8
- package/osc-dsf.js +8 -8
- package/osc-mix.d.ts +5 -5
- package/osc-mix.js +5 -5
- package/osc-rect.d.ts +1 -1
- package/osc-rect.js +1 -1
- package/osc.d.ts +16 -16
- package/osc.js +17 -18
- package/package.json +70 -70
- package/pipe.d.ts +2 -2
- package/power.d.ts +11 -11
- package/power.js +11 -11
- package/reciprocal.d.ts +1 -1
- package/reciprocal.js +1 -1
- package/serial.d.ts +2 -2
- package/sweep.d.ts +4 -4
- package/sweep.js +4 -4
- package/window.d.ts +5 -5
- package/window.js +5 -5
package/power.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isComplex } from "./complex.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Computes the sum of the given array.
|
|
5
5
|
*
|
|
6
|
-
* @param window
|
|
6
|
+
* @param window -
|
|
7
7
|
*/
|
|
8
8
|
export const integralT = (window) => {
|
|
9
9
|
let sum = 0;
|
|
@@ -15,7 +15,7 @@ export const integralT = (window) => {
|
|
|
15
15
|
/**
|
|
16
16
|
* Computes the squared sum of given array.
|
|
17
17
|
*
|
|
18
|
-
* @param window
|
|
18
|
+
* @param window -
|
|
19
19
|
*/
|
|
20
20
|
export const integralTSquared = (window) => {
|
|
21
21
|
let sum = 0;
|
|
@@ -27,7 +27,7 @@ export const integralTSquared = (window) => {
|
|
|
27
27
|
/**
|
|
28
28
|
* Computes the `sum(|c(i)|)` for given complex array.
|
|
29
29
|
*
|
|
30
|
-
* @param window
|
|
30
|
+
* @param window -
|
|
31
31
|
*/
|
|
32
32
|
export const integralF = ([real, img]) => {
|
|
33
33
|
let sum = 0;
|
|
@@ -39,7 +39,7 @@ export const integralF = ([real, img]) => {
|
|
|
39
39
|
/**
|
|
40
40
|
* Computes the `sum(|c(i)|^2)` for given complex array.
|
|
41
41
|
*
|
|
42
|
-
* @param window
|
|
42
|
+
* @param window -
|
|
43
43
|
*/
|
|
44
44
|
export const integralFSquared = ([real, img]) => {
|
|
45
45
|
let sum = 0;
|
|
@@ -51,15 +51,15 @@ export const integralFSquared = ([real, img]) => {
|
|
|
51
51
|
/**
|
|
52
52
|
* If `scale` is a number, returns it. Else returns `base / integralT(scale)`.
|
|
53
53
|
*
|
|
54
|
-
* @param scale
|
|
55
|
-
* @param base
|
|
54
|
+
* @param scale -
|
|
55
|
+
* @param base -
|
|
56
56
|
*/
|
|
57
57
|
export const powerScale = (scale, base = 1) => isNumber(scale) ? scale : base / integralT(scale);
|
|
58
58
|
/**
|
|
59
59
|
* If `scale` is a number, returns it. Else returns `integralT(scale) / base`.
|
|
60
60
|
*
|
|
61
|
-
* @param scale
|
|
62
|
-
* @param base
|
|
61
|
+
* @param scale -
|
|
62
|
+
* @param base -
|
|
63
63
|
*/
|
|
64
64
|
export const invPowerScale = (scale, base = 1) => isNumber(scale) ? scale : integralT(scale) / base;
|
|
65
65
|
/**
|
|
@@ -70,7 +70,7 @@ export const invPowerScale = (scale, base = 1) => isNumber(scale) ? scale : inte
|
|
|
70
70
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
71
71
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
72
72
|
*
|
|
73
|
-
* @param window
|
|
73
|
+
* @param window -
|
|
74
74
|
*/
|
|
75
75
|
export const powerSumSquared = (window) => isComplex(window)
|
|
76
76
|
? integralFSquared(window) / window[0].length
|
|
@@ -83,7 +83,7 @@ export const powerSumSquared = (window) => isComplex(window)
|
|
|
83
83
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
84
84
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
85
85
|
*
|
|
86
|
-
* @param window
|
|
86
|
+
* @param window -
|
|
87
87
|
*/
|
|
88
88
|
export const powerMeanSquared = (window) => powerSumSquared(window) /
|
|
89
89
|
(isComplex(window) ? window[0].length : window.length);
|
|
@@ -96,7 +96,7 @@ export const powerMeanSquared = (window) => powerSumSquared(window) /
|
|
|
96
96
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
97
97
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
98
98
|
*
|
|
99
|
-
* @param window
|
|
99
|
+
* @param window -
|
|
100
100
|
*/
|
|
101
101
|
export const powerTimeIntegral = (window, fs) => (isComplex(window) ? integralFSquared(window) : integralTSquared(window)) /
|
|
102
102
|
fs;
|
package/reciprocal.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AGen } from "./agen.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a gen which yield sequence `y(t) = 1 / (y(t - 1) + step)`.
|
|
5
5
|
*
|
|
6
|
-
* @param step
|
|
6
|
+
* @param step -
|
|
7
7
|
*/
|
|
8
8
|
export declare const reciprocal: (step?: number | undefined) => Reciprocal;
|
|
9
9
|
export declare class Reciprocal extends AGen<number> implements IReset {
|
package/reciprocal.js
CHANGED
package/serial.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { AProc } from "./aproc.js";
|
|
|
8
8
|
* @remarks
|
|
9
9
|
* Provides optimized (loop free) versions for 2-4 inputs
|
|
10
10
|
*
|
|
11
|
-
* @param a
|
|
12
|
-
* @param b
|
|
11
|
+
* @param a -
|
|
12
|
+
* @param b -
|
|
13
13
|
*/
|
|
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>;
|
package/sweep.d.ts
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* // [...]
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
* @param start
|
|
22
|
-
* @param end
|
|
23
|
-
* @param steps
|
|
24
|
-
* @param rate
|
|
21
|
+
* @param start -
|
|
22
|
+
* @param end -
|
|
23
|
+
* @param steps -
|
|
24
|
+
* @param rate -
|
|
25
25
|
* @param clamp - true, if clamp at `end` value
|
|
26
26
|
*/
|
|
27
27
|
export declare const sweep: (start: number, end: number, steps: number, rate?: number | undefined, clamp?: boolean) => import("./api.js").IGen<number>;
|
package/sweep.js
CHANGED
|
@@ -20,10 +20,10 @@ import { curve } from "./curve.js";
|
|
|
20
20
|
* // [...]
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @param start
|
|
24
|
-
* @param end
|
|
25
|
-
* @param steps
|
|
26
|
-
* @param rate
|
|
23
|
+
* @param start -
|
|
24
|
+
* @param end -
|
|
25
|
+
* @param steps -
|
|
26
|
+
* @param rate -
|
|
27
27
|
* @param clamp - true, if clamp at `end` value
|
|
28
28
|
*/
|
|
29
29
|
export const sweep = (start, end, steps, rate, clamp = true) => addG(curve(start, end, steps, rate, false, clamp));
|
package/window.d.ts
CHANGED
|
@@ -5,17 +5,17 @@ import type { WindowFn } from "./api.js";
|
|
|
5
5
|
* The buffer size MUST be the same as the signal length given to
|
|
6
6
|
* {@link fft}.
|
|
7
7
|
*
|
|
8
|
-
* @param fn
|
|
9
|
-
* @param lenOfBuf
|
|
8
|
+
* @param fn -
|
|
9
|
+
* @param lenOfBuf -
|
|
10
10
|
*/
|
|
11
11
|
export declare const window: (fn: WindowFn, lenOfBuf: number | FloatArray) => FloatArray;
|
|
12
12
|
/**
|
|
13
13
|
* Takes a `signal` and `window` buffer and multiplies both elementwise. Writes
|
|
14
14
|
* results into `out` (or back into `signal` by default).
|
|
15
15
|
*
|
|
16
|
-
* @param signal
|
|
17
|
-
* @param window
|
|
18
|
-
* @param out
|
|
16
|
+
* @param signal -
|
|
17
|
+
* @param window -
|
|
18
|
+
* @param out -
|
|
19
19
|
*/
|
|
20
20
|
export declare const applyWindow: (signal: NumericArray, window: NumericArray, out?: NumericArray) => NumericArray;
|
|
21
21
|
export declare const windowRect: WindowFn;
|
package/window.js
CHANGED
|
@@ -10,8 +10,8 @@ const cos = Math.cos;
|
|
|
10
10
|
* The buffer size MUST be the same as the signal length given to
|
|
11
11
|
* {@link fft}.
|
|
12
12
|
*
|
|
13
|
-
* @param fn
|
|
14
|
-
* @param lenOfBuf
|
|
13
|
+
* @param fn -
|
|
14
|
+
* @param lenOfBuf -
|
|
15
15
|
*/
|
|
16
16
|
export const window = (fn, lenOfBuf) => {
|
|
17
17
|
const buf = isNumber(lenOfBuf) ? new Float64Array(lenOfBuf) : lenOfBuf;
|
|
@@ -25,9 +25,9 @@ export const window = (fn, lenOfBuf) => {
|
|
|
25
25
|
* Takes a `signal` and `window` buffer and multiplies both elementwise. Writes
|
|
26
26
|
* results into `out` (or back into `signal` by default).
|
|
27
27
|
*
|
|
28
|
-
* @param signal
|
|
29
|
-
* @param window
|
|
30
|
-
* @param out
|
|
28
|
+
* @param signal -
|
|
29
|
+
* @param window -
|
|
30
|
+
* @param out -
|
|
31
31
|
*/
|
|
32
32
|
export const applyWindow = (signal, window, out = signal) => {
|
|
33
33
|
for (let i = signal.length; i-- > 0;) {
|