@thi.ng/dsp 4.1.4 → 4.1.5
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 +1 -1
- package/README.md +1 -1
- 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/package.json +12 -12
- 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/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/add.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { AGen } from "./agen.js";
|
|
|
6
6
|
* given, the resulting output will be clamped to that value (min or max depends
|
|
7
7
|
* on sign of `start - clamp`).
|
|
8
8
|
*
|
|
9
|
-
* @param step
|
|
10
|
-
* @param start
|
|
11
|
-
* @param clamp
|
|
9
|
+
* @param step -
|
|
10
|
+
* @param start -
|
|
11
|
+
* @param clamp -
|
|
12
12
|
*/
|
|
13
13
|
export declare const add: (step?: number | undefined, start?: number | undefined, clamp?: number | undefined) => Add;
|
|
14
14
|
export declare class Add extends AGen<number> implements IReset {
|
package/add.js
CHANGED
|
@@ -5,9 +5,9 @@ import { AGen } from "./agen.js";
|
|
|
5
5
|
* given, the resulting output will be clamped to that value (min or max depends
|
|
6
6
|
* on sign of `start - clamp`).
|
|
7
7
|
*
|
|
8
|
-
* @param step
|
|
9
|
-
* @param start
|
|
10
|
-
* @param clamp
|
|
8
|
+
* @param step -
|
|
9
|
+
* @param start -
|
|
10
|
+
* @param clamp -
|
|
11
11
|
*/
|
|
12
12
|
export const add = (step, start, clamp) => new Add(step, start, clamp);
|
|
13
13
|
export class Add extends AGen {
|
package/addg.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ import type { IGen } from "./api.js";
|
|
|
14
14
|
* // [ 10, 11, 12, 13, 14 ]
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @param step
|
|
18
|
-
* @param start
|
|
17
|
+
* @param step -
|
|
18
|
+
* @param start -
|
|
19
19
|
*/
|
|
20
20
|
export declare const addG: (step: IGen<number>, start?: number) => IGen<number>;
|
|
21
21
|
//# sourceMappingURL=addg.d.ts.map
|
package/addg.js
CHANGED
|
@@ -14,7 +14,7 @@ import { MapG1 } from "./mapg.js";
|
|
|
14
14
|
* // [ 10, 11, 12, 13, 14 ]
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* @param step
|
|
18
|
-
* @param start
|
|
17
|
+
* @param step -
|
|
18
|
+
* @param start -
|
|
19
19
|
*/
|
|
20
20
|
export const addG = (step, start = 0) => new MapG1((a, b) => a + b, step, start - step.deref());
|
package/const.d.ts
CHANGED
package/const.js
CHANGED
package/convert.d.ts
CHANGED
|
@@ -3,29 +3,29 @@ import type { FnN, FnN2 } from "@thi.ng/api";
|
|
|
3
3
|
* Returns frequency `f` normalized to sample rate `fs`:
|
|
4
4
|
* `fnorm = f / fs`
|
|
5
5
|
*
|
|
6
|
-
* @param f
|
|
7
|
-
* @param fs
|
|
6
|
+
* @param f -
|
|
7
|
+
* @param fs -
|
|
8
8
|
*/
|
|
9
9
|
export declare const normFreq: FnN2;
|
|
10
10
|
/**
|
|
11
11
|
* Returns frequency `f` in radians, based on sample rate `fs`.
|
|
12
12
|
* I.e. Nyquist freq = PI
|
|
13
13
|
*
|
|
14
|
-
* @param f
|
|
15
|
-
* @param fs
|
|
14
|
+
* @param f -
|
|
15
|
+
* @param fs -
|
|
16
16
|
*/
|
|
17
17
|
export declare const freqRad: FnN2;
|
|
18
18
|
/**
|
|
19
19
|
* Returns period length in milliseconds for given frequency in Hz.
|
|
20
20
|
*
|
|
21
|
-
* @param f
|
|
21
|
+
* @param f -
|
|
22
22
|
*/
|
|
23
23
|
export declare const freqMs: FnN;
|
|
24
24
|
/**
|
|
25
25
|
* Reverse op of {@link freqRad}.
|
|
26
26
|
*
|
|
27
|
-
* @param rad
|
|
28
|
-
* @param fs
|
|
27
|
+
* @param rad -
|
|
28
|
+
* @param fs -
|
|
29
29
|
*/
|
|
30
30
|
export declare const radFreq: FnN2;
|
|
31
31
|
/**
|
|
@@ -39,28 +39,28 @@ export declare const radFreq: FnN2;
|
|
|
39
39
|
* // 882
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* @param t
|
|
43
|
-
* @param fs
|
|
42
|
+
* @param t -
|
|
43
|
+
* @param fs -
|
|
44
44
|
*/
|
|
45
45
|
export declare const msFrames: FnN2;
|
|
46
46
|
/**
|
|
47
47
|
* Reverse op of {@link msFrames}.
|
|
48
48
|
*
|
|
49
|
-
* @param frames
|
|
50
|
-
* @param fs
|
|
49
|
+
* @param frames -
|
|
50
|
+
* @param fs -
|
|
51
51
|
*/
|
|
52
52
|
export declare const framesMs: FnN2;
|
|
53
53
|
/**
|
|
54
54
|
* Converts given linear magnitude to dBFS (i.e. `20 * log10(x)`)
|
|
55
55
|
*
|
|
56
|
-
* @param x
|
|
56
|
+
* @param x -
|
|
57
57
|
*/
|
|
58
58
|
export declare const magDb: FnN;
|
|
59
59
|
/**
|
|
60
60
|
* Converts given dBFS value to linear magnitude
|
|
61
61
|
* (i.e. `pow(10, x / 20)`)
|
|
62
62
|
*
|
|
63
|
-
* @param x
|
|
63
|
+
* @param x -
|
|
64
64
|
*/
|
|
65
65
|
export declare const dbMag: FnN;
|
|
66
66
|
//# sourceMappingURL=convert.d.ts.map
|
package/convert.js
CHANGED
|
@@ -3,29 +3,29 @@ import { TAU } from "@thi.ng/math/api";
|
|
|
3
3
|
* Returns frequency `f` normalized to sample rate `fs`:
|
|
4
4
|
* `fnorm = f / fs`
|
|
5
5
|
*
|
|
6
|
-
* @param f
|
|
7
|
-
* @param fs
|
|
6
|
+
* @param f -
|
|
7
|
+
* @param fs -
|
|
8
8
|
*/
|
|
9
9
|
export const normFreq = (f, fs) => f / fs;
|
|
10
10
|
/**
|
|
11
11
|
* Returns frequency `f` in radians, based on sample rate `fs`.
|
|
12
12
|
* I.e. Nyquist freq = PI
|
|
13
13
|
*
|
|
14
|
-
* @param f
|
|
15
|
-
* @param fs
|
|
14
|
+
* @param f -
|
|
15
|
+
* @param fs -
|
|
16
16
|
*/
|
|
17
17
|
export const freqRad = (f, fs) => (f / fs) * TAU;
|
|
18
18
|
/**
|
|
19
19
|
* Returns period length in milliseconds for given frequency in Hz.
|
|
20
20
|
*
|
|
21
|
-
* @param f
|
|
21
|
+
* @param f -
|
|
22
22
|
*/
|
|
23
23
|
export const freqMs = (f) => 1000 / f;
|
|
24
24
|
/**
|
|
25
25
|
* Reverse op of {@link freqRad}.
|
|
26
26
|
*
|
|
27
|
-
* @param rad
|
|
28
|
-
* @param fs
|
|
27
|
+
* @param rad -
|
|
28
|
+
* @param fs -
|
|
29
29
|
*/
|
|
30
30
|
export const radFreq = (rad, fs) => (rad / TAU) * fs;
|
|
31
31
|
/**
|
|
@@ -39,27 +39,27 @@ export const radFreq = (rad, fs) => (rad / TAU) * fs;
|
|
|
39
39
|
* // 882
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* @param t
|
|
43
|
-
* @param fs
|
|
42
|
+
* @param t -
|
|
43
|
+
* @param fs -
|
|
44
44
|
*/
|
|
45
45
|
export const msFrames = (t, fs) => t * 0.001 * fs;
|
|
46
46
|
/**
|
|
47
47
|
* Reverse op of {@link msFrames}.
|
|
48
48
|
*
|
|
49
|
-
* @param frames
|
|
50
|
-
* @param fs
|
|
49
|
+
* @param frames -
|
|
50
|
+
* @param fs -
|
|
51
51
|
*/
|
|
52
52
|
export const framesMs = (frames, fs) => (frames / fs) * 1000;
|
|
53
53
|
/**
|
|
54
54
|
* Converts given linear magnitude to dBFS (i.e. `20 * log10(x)`)
|
|
55
55
|
*
|
|
56
|
-
* @param x
|
|
56
|
+
* @param x -
|
|
57
57
|
*/
|
|
58
58
|
export const magDb = (x) => (20 * Math.log(x)) / Math.LN10;
|
|
59
59
|
/**
|
|
60
60
|
* Converts given dBFS value to linear magnitude
|
|
61
61
|
* (i.e. `pow(10, x / 20)`)
|
|
62
62
|
*
|
|
63
|
-
* @param x
|
|
63
|
+
* @param x -
|
|
64
64
|
*/
|
|
65
65
|
export const dbMag = (x) => 10 ** (x / 20);
|
package/dcblock.d.ts
CHANGED
package/dcblock.js
CHANGED
package/delay.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { AProc } from "./aproc.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Delay line of length `n` for numeric values.
|
|
5
5
|
*
|
|
6
|
-
* @param n
|
|
6
|
+
* @param n -
|
|
7
7
|
*/
|
|
8
8
|
export declare const delay: (n: number) => Delay<number>;
|
|
9
9
|
/**
|
|
10
10
|
* Delay line of length `n` for arbitrary typed values.
|
|
11
11
|
*
|
|
12
|
-
* @param n
|
|
12
|
+
* @param n -
|
|
13
13
|
*/
|
|
14
14
|
export declare const delayT: <T>(n: number, off: T | Fn0<T>) => Delay<T>;
|
|
15
15
|
/**
|
|
@@ -27,8 +27,8 @@ export declare class Delay<T> extends AProc<T, T> implements IClear, ILength, IR
|
|
|
27
27
|
* be initialized with the results of that function (called for each
|
|
28
28
|
* element).
|
|
29
29
|
*
|
|
30
|
-
* @param n
|
|
31
|
-
* @param _empty
|
|
30
|
+
* @param n -
|
|
31
|
+
* @param _empty -
|
|
32
32
|
*/
|
|
33
33
|
constructor(n: number, _empty: T | Fn0<T>);
|
|
34
34
|
get length(): number;
|
|
@@ -48,7 +48,7 @@ export declare class Delay<T> extends AProc<T, T> implements IClear, ILength, IR
|
|
|
48
48
|
* be in `(-∞..0)` interval. E.g. `tap(-1)` returns the second
|
|
49
49
|
* most recent value written.
|
|
50
50
|
*
|
|
51
|
-
* @param t
|
|
51
|
+
* @param t -
|
|
52
52
|
*/
|
|
53
53
|
tap(t: number): T;
|
|
54
54
|
/**
|
|
@@ -60,7 +60,7 @@ export declare class Delay<T> extends AProc<T, T> implements IClear, ILength, IR
|
|
|
60
60
|
/**
|
|
61
61
|
* Progresses read & write pos, stores & returns new value.
|
|
62
62
|
*
|
|
63
|
-
* @param x
|
|
63
|
+
* @param x -
|
|
64
64
|
*/
|
|
65
65
|
next(x: T): T;
|
|
66
66
|
/**
|
package/delay.js
CHANGED
|
@@ -4,13 +4,13 @@ import { AProc } from "./aproc.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Delay line of length `n` for numeric values.
|
|
6
6
|
*
|
|
7
|
-
* @param n
|
|
7
|
+
* @param n -
|
|
8
8
|
*/
|
|
9
9
|
export const delay = (n) => new Delay(n, 0);
|
|
10
10
|
/**
|
|
11
11
|
* Delay line of length `n` for arbitrary typed values.
|
|
12
12
|
*
|
|
13
|
-
* @param n
|
|
13
|
+
* @param n -
|
|
14
14
|
*/
|
|
15
15
|
export const delayT = (n, off) => new Delay(n, off);
|
|
16
16
|
/**
|
|
@@ -24,8 +24,8 @@ export class Delay extends AProc {
|
|
|
24
24
|
* be initialized with the results of that function (called for each
|
|
25
25
|
* element).
|
|
26
26
|
*
|
|
27
|
-
* @param n
|
|
28
|
-
* @param _empty
|
|
27
|
+
* @param n -
|
|
28
|
+
* @param _empty -
|
|
29
29
|
*/
|
|
30
30
|
constructor(n, _empty) {
|
|
31
31
|
super(isFunction(_empty) ? _empty() : _empty);
|
|
@@ -69,7 +69,7 @@ export class Delay extends AProc {
|
|
|
69
69
|
* be in `(-∞..0)` interval. E.g. `tap(-1)` returns the second
|
|
70
70
|
* most recent value written.
|
|
71
71
|
*
|
|
72
|
-
* @param t
|
|
72
|
+
* @param t -
|
|
73
73
|
*/
|
|
74
74
|
tap(t) {
|
|
75
75
|
return this._buf[wrap((t | 0) + this._wpos, 0, this._buf.length - 1)];
|
|
@@ -88,7 +88,7 @@ export class Delay extends AProc {
|
|
|
88
88
|
/**
|
|
89
89
|
* Progresses read & write pos, stores & returns new value.
|
|
90
90
|
*
|
|
91
|
-
* @param x
|
|
91
|
+
* @param x -
|
|
92
92
|
*/
|
|
93
93
|
next(x) {
|
|
94
94
|
this.step();
|
package/fft.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type { ComplexArray } from "./api.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new tuple of real/img F64 buffers of given size.
|
|
5
5
|
*
|
|
6
|
-
* @param n
|
|
6
|
+
* @param n -
|
|
7
7
|
*/
|
|
8
8
|
export declare const complexArray: (n: number) => ComplexArray;
|
|
9
9
|
/**
|
|
10
10
|
* Creates a deep copy of given {@link ComplexArray}.
|
|
11
11
|
*
|
|
12
|
-
* @param complex
|
|
12
|
+
* @param complex -
|
|
13
13
|
*/
|
|
14
14
|
export declare const copyComplex: (complex: ComplexArray) => ComplexArray;
|
|
15
15
|
/**
|
|
@@ -53,8 +53,8 @@ export declare const copyComplex: (complex: ComplexArray) => ComplexArray;
|
|
|
53
53
|
* // ]
|
|
54
54
|
* ```
|
|
55
55
|
*
|
|
56
|
-
* @param src
|
|
57
|
-
* @param isImg
|
|
56
|
+
* @param src -
|
|
57
|
+
* @param isImg -
|
|
58
58
|
*/
|
|
59
59
|
export declare function conjugate(src: NumericArray, isImg?: boolean): NumericArray;
|
|
60
60
|
export declare function conjugate(complex: ComplexArray): ComplexArray;
|
|
@@ -74,8 +74,8 @@ export declare function conjugate(complex: ComplexArray): ComplexArray;
|
|
|
74
74
|
* - https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
|
|
75
75
|
* - http://toxi.co.uk/p5/fftDebug/fft4amit.pde
|
|
76
76
|
*
|
|
77
|
-
* @param complex
|
|
78
|
-
* @param window
|
|
77
|
+
* @param complex -
|
|
78
|
+
* @param window -
|
|
79
79
|
*/
|
|
80
80
|
export declare const fft: (complex: NumericArray | ComplexArray, window?: NumericArray | undefined) => ComplexArray;
|
|
81
81
|
/**
|
|
@@ -87,7 +87,7 @@ export declare const fft: (complex: NumericArray | ComplexArray, window?: Numeri
|
|
|
87
87
|
*
|
|
88
88
|
* - https://www.dsprelated.com/showarticle/800.php (method #3)
|
|
89
89
|
*
|
|
90
|
-
* @param complex
|
|
90
|
+
* @param complex -
|
|
91
91
|
*/
|
|
92
92
|
export declare const ifft: (src: NumericArray | ComplexArray) => ComplexArray;
|
|
93
93
|
export declare const scaleFFT: (complex: ComplexArray, scale: number) => ComplexArray;
|
|
@@ -103,8 +103,8 @@ export declare const scaleFFT: (complex: ComplexArray, scale: number) => Complex
|
|
|
103
103
|
* References:
|
|
104
104
|
* - https://holometer.fnal.gov/GH_FFT.pdf
|
|
105
105
|
*
|
|
106
|
-
* @param complex
|
|
107
|
-
* @param window
|
|
106
|
+
* @param complex -
|
|
107
|
+
* @param window -
|
|
108
108
|
*/
|
|
109
109
|
export declare const normalizeFFT: (complex: ComplexArray, window?: number | NumericArray) => ComplexArray;
|
|
110
110
|
/**
|
|
@@ -119,8 +119,8 @@ export declare const normalizeFFT: (complex: ComplexArray, window?: number | Num
|
|
|
119
119
|
* References:
|
|
120
120
|
* - https://holometer.fnal.gov/GH_FFT.pdf
|
|
121
121
|
*
|
|
122
|
-
* @param complex
|
|
123
|
-
* @param window
|
|
122
|
+
* @param complex -
|
|
123
|
+
* @param window -
|
|
124
124
|
*/
|
|
125
125
|
export declare const denormalizeFFT: (complex: ComplexArray, window?: number | NumericArray) => ComplexArray;
|
|
126
126
|
/**
|
|
@@ -135,8 +135,8 @@ export declare const denormalizeFFT: (complex: ComplexArray, window?: number | N
|
|
|
135
135
|
* References:
|
|
136
136
|
* - https://www.gaussianwaves.com/2015/11/interpreting-fft-results-obtaining-magnitude-and-phase-information/
|
|
137
137
|
*
|
|
138
|
-
* @param complex
|
|
139
|
-
* @param eps
|
|
138
|
+
* @param complex -
|
|
139
|
+
* @param eps -
|
|
140
140
|
*/
|
|
141
141
|
export declare const thresholdFFT: (complex: ComplexArray, eps?: number) => ComplexArray;
|
|
142
142
|
/**
|
|
@@ -170,11 +170,11 @@ export declare const spectrumMag: (complex: ComplexArray, n?: number, out?: Nume
|
|
|
170
170
|
* - https://dsp.stackexchange.com/a/14935
|
|
171
171
|
* - https://www.kvraudio.com/forum/viewtopic.php?t=276092
|
|
172
172
|
*
|
|
173
|
-
* @param complex
|
|
174
|
-
* @param db
|
|
175
|
-
* @param window
|
|
176
|
-
* @param n
|
|
177
|
-
* @param out
|
|
173
|
+
* @param complex -
|
|
174
|
+
* @param db -
|
|
175
|
+
* @param window -
|
|
176
|
+
* @param n -
|
|
177
|
+
* @param out -
|
|
178
178
|
*/
|
|
179
179
|
export declare const spectrumPow: (complex: ComplexArray, db?: boolean, window?: number | NumericArray, n?: number, out?: NumericArray) => NumericArray;
|
|
180
180
|
/**
|
package/fft.js
CHANGED
|
@@ -5,7 +5,7 @@ import { applyWindow } from "./window.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns a new tuple of real/img F64 buffers of given size.
|
|
7
7
|
*
|
|
8
|
-
* @param n
|
|
8
|
+
* @param n -
|
|
9
9
|
*/
|
|
10
10
|
export const complexArray = (n) => [
|
|
11
11
|
new Float64Array(n),
|
|
@@ -14,7 +14,7 @@ export const complexArray = (n) => [
|
|
|
14
14
|
/**
|
|
15
15
|
* Creates a deep copy of given {@link ComplexArray}.
|
|
16
16
|
*
|
|
17
|
-
* @param complex
|
|
17
|
+
* @param complex -
|
|
18
18
|
*/
|
|
19
19
|
export const copyComplex = (complex) => [
|
|
20
20
|
complex[0].slice(),
|
|
@@ -140,8 +140,8 @@ const transform = (real, img, n) => {
|
|
|
140
140
|
* - https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
|
|
141
141
|
* - http://toxi.co.uk/p5/fftDebug/fft4amit.pde
|
|
142
142
|
*
|
|
143
|
-
* @param complex
|
|
144
|
-
* @param window
|
|
143
|
+
* @param complex -
|
|
144
|
+
* @param window -
|
|
145
145
|
*/
|
|
146
146
|
export const fft = (complex, window) => {
|
|
147
147
|
let real, img;
|
|
@@ -175,7 +175,7 @@ export const fft = (complex, window) => {
|
|
|
175
175
|
*
|
|
176
176
|
* - https://www.dsprelated.com/showarticle/800.php (method #3)
|
|
177
177
|
*
|
|
178
|
-
* @param complex
|
|
178
|
+
* @param complex -
|
|
179
179
|
*/
|
|
180
180
|
export const ifft = (src) => {
|
|
181
181
|
let complex = isComplex(src)
|
|
@@ -205,8 +205,8 @@ export const scaleFFT = (complex, scale) => {
|
|
|
205
205
|
* References:
|
|
206
206
|
* - https://holometer.fnal.gov/GH_FFT.pdf
|
|
207
207
|
*
|
|
208
|
-
* @param complex
|
|
209
|
-
* @param window
|
|
208
|
+
* @param complex -
|
|
209
|
+
* @param window -
|
|
210
210
|
*/
|
|
211
211
|
export const normalizeFFT = (complex, window = 2 / complex[0].length) => scaleFFT(complex, powerScale(window, 2));
|
|
212
212
|
/**
|
|
@@ -221,8 +221,8 @@ export const normalizeFFT = (complex, window = 2 / complex[0].length) => scaleFF
|
|
|
221
221
|
* References:
|
|
222
222
|
* - https://holometer.fnal.gov/GH_FFT.pdf
|
|
223
223
|
*
|
|
224
|
-
* @param complex
|
|
225
|
-
* @param window
|
|
224
|
+
* @param complex -
|
|
225
|
+
* @param window -
|
|
226
226
|
*/
|
|
227
227
|
export const denormalizeFFT = (complex, window = complex[0].length / 2) => scaleFFT(complex, invPowerScale(window, 2));
|
|
228
228
|
/**
|
|
@@ -237,8 +237,8 @@ export const denormalizeFFT = (complex, window = complex[0].length / 2) => scale
|
|
|
237
237
|
* References:
|
|
238
238
|
* - https://www.gaussianwaves.com/2015/11/interpreting-fft-results-obtaining-magnitude-and-phase-information/
|
|
239
239
|
*
|
|
240
|
-
* @param complex
|
|
241
|
-
* @param eps
|
|
240
|
+
* @param complex -
|
|
241
|
+
* @param eps -
|
|
242
242
|
*/
|
|
243
243
|
export const thresholdFFT = (complex, eps = 1e-12) => {
|
|
244
244
|
const [real, img] = complex;
|
|
@@ -286,11 +286,11 @@ export const spectrumMag = (complex, n = complex[0].length / 2, out = []) => {
|
|
|
286
286
|
* - https://dsp.stackexchange.com/a/14935
|
|
287
287
|
* - https://www.kvraudio.com/forum/viewtopic.php?t=276092
|
|
288
288
|
*
|
|
289
|
-
* @param complex
|
|
290
|
-
* @param db
|
|
291
|
-
* @param window
|
|
292
|
-
* @param n
|
|
293
|
-
* @param out
|
|
289
|
+
* @param complex -
|
|
290
|
+
* @param db -
|
|
291
|
+
* @param window -
|
|
292
|
+
* @param n -
|
|
293
|
+
* @param out -
|
|
294
294
|
*/
|
|
295
295
|
export const spectrumPow = (complex, db = false, window = 2 / complex[0].length, n = complex[0].length / 2, out = []) => {
|
|
296
296
|
const [real, img] = complex;
|
package/impulse.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AGen } from "./agen.js";
|
|
|
4
4
|
* Numeric version of {@link impulseT}, using given `on` (default: 1) as
|
|
5
5
|
* initial value and zero for the remaining values.
|
|
6
6
|
*
|
|
7
|
-
* @param on
|
|
7
|
+
* @param on -
|
|
8
8
|
*/
|
|
9
9
|
export declare const impulse: (on?: number) => Impulse<number>;
|
|
10
10
|
/**
|
|
@@ -19,7 +19,7 @@ export declare const impulseT: <T>(on: T, off: T) => Impulse<T>;
|
|
|
19
19
|
* Boolean version of {@link impulseT}, using given `start` (default:
|
|
20
20
|
* true) as initial value and its inverse for the remaining values.
|
|
21
21
|
*
|
|
22
|
-
* @param start
|
|
22
|
+
* @param start -
|
|
23
23
|
*/
|
|
24
24
|
export declare const impulseB: (start?: boolean) => Impulse<boolean>;
|
|
25
25
|
export declare class Impulse<T> extends AGen<T> implements IReset {
|
package/impulse.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AGen } from "./agen.js";
|
|
|
3
3
|
* Numeric version of {@link impulseT}, using given `on` (default: 1) as
|
|
4
4
|
* initial value and zero for the remaining values.
|
|
5
5
|
*
|
|
6
|
-
* @param on
|
|
6
|
+
* @param on -
|
|
7
7
|
*/
|
|
8
8
|
export const impulse = (on = 1) => new Impulse(on, 0);
|
|
9
9
|
/**
|
|
@@ -18,7 +18,7 @@ export const impulseT = (on, off) => new Impulse(on, off);
|
|
|
18
18
|
* Boolean version of {@link impulseT}, using given `start` (default:
|
|
19
19
|
* true) as initial value and its inverse for the remaining values.
|
|
20
20
|
*
|
|
21
|
-
* @param start
|
|
21
|
+
* @param start -
|
|
22
22
|
*/
|
|
23
23
|
export const impulseB = (start = true) => new Impulse(start, !start);
|
|
24
24
|
export class Impulse extends AGen {
|
package/iterable.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type { IGen } from "./api.js";
|
|
|
10
10
|
* The `initial` value is required to satisfy `.deref()` and the case where the
|
|
11
11
|
* iterable doesn't provide a single value.
|
|
12
12
|
*
|
|
13
|
-
* @param src
|
|
14
|
-
* @param initial
|
|
13
|
+
* @param src -
|
|
14
|
+
* @param initial -
|
|
15
15
|
*/
|
|
16
16
|
export declare const iterable: <T>(src: Iterable<T>, initial: T) => $Iterable<T>;
|
|
17
17
|
export declare class $Iterable<T> implements IGen<T> {
|
package/iterable.js
CHANGED
|
@@ -10,8 +10,8 @@ import { __take } from "./internal/take.js";
|
|
|
10
10
|
* The `initial` value is required to satisfy `.deref()` and the case where the
|
|
11
11
|
* iterable doesn't provide a single value.
|
|
12
12
|
*
|
|
13
|
-
* @param src
|
|
14
|
-
* @param initial
|
|
13
|
+
* @param src -
|
|
14
|
+
* @param initial -
|
|
15
15
|
*/
|
|
16
16
|
export const iterable = (src, initial) => new $Iterable(src, initial);
|
|
17
17
|
export class $Iterable {
|
package/multiplex.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import { AProc } from "./aproc.js";
|
|
|
12
12
|
*
|
|
13
13
|
* See {@link bounce} for combining results back into a single channel output.
|
|
14
14
|
*
|
|
15
|
-
* @param a
|
|
16
|
-
* @param b
|
|
15
|
+
* @param a -
|
|
16
|
+
* @param b -
|
|
17
17
|
*/
|
|
18
18
|
export declare function multiplex<T, A, B>(a: IProc<T, A>, b: IProc<T, B>): Multiplex<T, [A, B]>;
|
|
19
19
|
export declare function multiplex<T, A, B, C>(a: IProc<T, A>, b: IProc<T, B>, c: IProc<T, C>): Multiplex<T, [A, B, C]>;
|
package/osc-additive.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ import type { StatelessOscillator } from "./api.js";
|
|
|
9
9
|
* and amplitude factors for each of the `n` requested harmonics (given in [i,n]
|
|
10
10
|
* range).
|
|
11
11
|
*
|
|
12
|
-
* @param osc
|
|
13
|
-
* @param freqFn
|
|
14
|
-
* @param ampFn
|
|
15
|
-
* @param n
|
|
12
|
+
* @param osc -
|
|
13
|
+
* @param freqFn -
|
|
14
|
+
* @param ampFn -
|
|
15
|
+
* @param n -
|
|
16
16
|
*/
|
|
17
17
|
export declare const additive: (osc: StatelessOscillator, freqFn: Fn<number, number>, ampFn: Fn<number, number>, n: number) => StatelessOscillator;
|
|
18
18
|
/**
|
package/osc-additive.js
CHANGED
|
@@ -9,10 +9,10 @@ import { sin } from "./osc-sin.js";
|
|
|
9
9
|
* and amplitude factors for each of the `n` requested harmonics (given in [i,n]
|
|
10
10
|
* range).
|
|
11
11
|
*
|
|
12
|
-
* @param osc
|
|
13
|
-
* @param freqFn
|
|
14
|
-
* @param ampFn
|
|
15
|
-
* @param n
|
|
12
|
+
* @param osc -
|
|
13
|
+
* @param freqFn -
|
|
14
|
+
* @param ampFn -
|
|
15
|
+
* @param n -
|
|
16
16
|
*/
|
|
17
17
|
export const additive = (osc, freqFn, ampFn, n) => {
|
|
18
18
|
const fcache = [];
|
package/osc-dsf.d.ts
CHANGED
|
@@ -20,20 +20,20 @@ import type { StatelessOscillator } from "./api.js";
|
|
|
20
20
|
* - https://www.desmos.com/calculator/klvl9oszfm
|
|
21
21
|
* - https://ccrma.stanford.edu/files/papers/stanm5.pdf
|
|
22
22
|
*
|
|
23
|
-
* @param phase
|
|
24
|
-
* @param freq
|
|
25
|
-
* @param amp
|
|
26
|
-
* @param dc
|
|
27
|
-
* @param alpha
|
|
28
|
-
* @param beta
|
|
23
|
+
* @param phase -
|
|
24
|
+
* @param freq -
|
|
25
|
+
* @param amp -
|
|
26
|
+
* @param dc -
|
|
27
|
+
* @param alpha -
|
|
28
|
+
* @param beta -
|
|
29
29
|
*/
|
|
30
30
|
export declare const dsf: StatelessOscillator;
|
|
31
31
|
/**
|
|
32
32
|
* Higher order version of {@link dsf} oscillator with pre-configured
|
|
33
33
|
* params. Slightly faster, but not dynamically changeable waveform.
|
|
34
34
|
*
|
|
35
|
-
* @param alpha
|
|
36
|
-
* @param beta
|
|
35
|
+
* @param alpha -
|
|
36
|
+
* @param beta -
|
|
37
37
|
*/
|
|
38
38
|
export declare const dsfHOF: (alpha?: number, beta?: number) => StatelessOscillator;
|
|
39
39
|
//# sourceMappingURL=osc-dsf.d.ts.map
|
package/osc-dsf.js
CHANGED
|
@@ -20,12 +20,12 @@ import { TAU } from "@thi.ng/math/api";
|
|
|
20
20
|
* - https://www.desmos.com/calculator/klvl9oszfm
|
|
21
21
|
* - https://ccrma.stanford.edu/files/papers/stanm5.pdf
|
|
22
22
|
*
|
|
23
|
-
* @param phase
|
|
24
|
-
* @param freq
|
|
25
|
-
* @param amp
|
|
26
|
-
* @param dc
|
|
27
|
-
* @param alpha
|
|
28
|
-
* @param beta
|
|
23
|
+
* @param phase -
|
|
24
|
+
* @param freq -
|
|
25
|
+
* @param amp -
|
|
26
|
+
* @param dc -
|
|
27
|
+
* @param alpha -
|
|
28
|
+
* @param beta -
|
|
29
29
|
*/
|
|
30
30
|
export const dsf = (phase, freq, amp = 1, dc = 0, alpha = 0.5, beta = 1) => {
|
|
31
31
|
const aa = alpha * alpha;
|
|
@@ -40,8 +40,8 @@ export const dsf = (phase, freq, amp = 1, dc = 0, alpha = 0.5, beta = 1) => {
|
|
|
40
40
|
* Higher order version of {@link dsf} oscillator with pre-configured
|
|
41
41
|
* params. Slightly faster, but not dynamically changeable waveform.
|
|
42
42
|
*
|
|
43
|
-
* @param alpha
|
|
44
|
-
* @param beta
|
|
43
|
+
* @param alpha -
|
|
44
|
+
* @param beta -
|
|
45
45
|
*/
|
|
46
46
|
export const dsfHOF = (alpha = 0.5, beta = 1) => {
|
|
47
47
|
const aa = alpha * alpha;
|
package/osc-mix.d.ts
CHANGED
|
@@ -6,17 +6,17 @@ import type { StatelessOscillator } from "./api.js";
|
|
|
6
6
|
* control contributions of either oscillator (default: 0.5 aka 50/50
|
|
7
7
|
* ratio).
|
|
8
8
|
*
|
|
9
|
-
* @param osc1
|
|
10
|
-
* @param osc2
|
|
9
|
+
* @param osc1 -
|
|
10
|
+
* @param osc2 -
|
|
11
11
|
*/
|
|
12
12
|
export declare const mixOsc: (osc1: StatelessOscillator, osc2: StatelessOscillator) => StatelessOscillator;
|
|
13
13
|
/**
|
|
14
14
|
* Similar to {@link mixOsc}, but with `mix` arg ([0..1] range)
|
|
15
15
|
* directly given to HOF and not changeable after.
|
|
16
16
|
*
|
|
17
|
-
* @param osc1
|
|
18
|
-
* @param osc2
|
|
19
|
-
* @param mix
|
|
17
|
+
* @param osc1 -
|
|
18
|
+
* @param osc2 -
|
|
19
|
+
* @param mix -
|
|
20
20
|
*/
|
|
21
21
|
export declare const mixOscHOF: (osc1: StatelessOscillator, osc2: StatelessOscillator, mix?: number) => StatelessOscillator;
|
|
22
22
|
//# sourceMappingURL=osc-mix.d.ts.map
|
package/osc-mix.js
CHANGED
|
@@ -6,16 +6,16 @@ import { mix as _mix } from "@thi.ng/math/mix";
|
|
|
6
6
|
* control contributions of either oscillator (default: 0.5 aka 50/50
|
|
7
7
|
* ratio).
|
|
8
8
|
*
|
|
9
|
-
* @param osc1
|
|
10
|
-
* @param osc2
|
|
9
|
+
* @param osc1 -
|
|
10
|
+
* @param osc2 -
|
|
11
11
|
*/
|
|
12
12
|
export const mixOsc = (osc1, osc2) => (phase, freq, amp = 1, dc = 0, t = 0.5) => _mix(osc1(phase, freq, amp, dc), osc2(phase, freq, amp, dc), t);
|
|
13
13
|
/**
|
|
14
14
|
* Similar to {@link mixOsc}, but with `mix` arg ([0..1] range)
|
|
15
15
|
* directly given to HOF and not changeable after.
|
|
16
16
|
*
|
|
17
|
-
* @param osc1
|
|
18
|
-
* @param osc2
|
|
19
|
-
* @param mix
|
|
17
|
+
* @param osc1 -
|
|
18
|
+
* @param osc2 -
|
|
19
|
+
* @param mix -
|
|
20
20
|
*/
|
|
21
21
|
export const mixOscHOF = (osc1, osc2, mix = 0.5) => (phase, freq, amp = 1, dc = 0) => _mix(osc1(phase, freq, amp, dc), osc2(phase, freq, amp, dc), mix);
|
package/osc-rect.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const rect: StatelessOscillator;
|
|
|
4
4
|
* Higher order version of {@link rect} with pre-configured `duty` width
|
|
5
5
|
* (in the (0..1) range).
|
|
6
6
|
*
|
|
7
|
-
* @param duty
|
|
7
|
+
* @param duty -
|
|
8
8
|
*/
|
|
9
9
|
export declare const rectHOF: (duty?: number) => StatelessOscillator;
|
|
10
10
|
//# sourceMappingURL=osc-rect.d.ts.map
|
package/osc-rect.js
CHANGED
|
@@ -4,6 +4,6 @@ export const rect = (phase, freq, amp = 1, dc = 0, duty = 0.5) => dc + amp * (fr
|
|
|
4
4
|
* Higher order version of {@link rect} with pre-configured `duty` width
|
|
5
5
|
* (in the (0..1) range).
|
|
6
6
|
*
|
|
7
|
-
* @param duty
|
|
7
|
+
* @param duty -
|
|
8
8
|
*/
|
|
9
9
|
export const rectHOF = (duty = 0.5) => (phase, freq, amp, dc) => rect(phase, freq, amp, dc, duty);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dsp",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
4
4
|
"description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/checks": "^3.1.
|
|
39
|
-
"@thi.ng/errors": "^2.1.
|
|
40
|
-
"@thi.ng/math": "^5.
|
|
41
|
-
"@thi.ng/random": "^3.2.
|
|
42
|
-
"@thi.ng/transducers": "^8.
|
|
37
|
+
"@thi.ng/api": "^8.3.4",
|
|
38
|
+
"@thi.ng/checks": "^3.1.4",
|
|
39
|
+
"@thi.ng/errors": "^2.1.4",
|
|
40
|
+
"@thi.ng/math": "^5.3.0",
|
|
41
|
+
"@thi.ng/random": "^3.2.4",
|
|
42
|
+
"@thi.ng/transducers": "^8.3.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.19.
|
|
46
|
-
"@thi.ng/testament": "^0.2.
|
|
45
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
46
|
+
"@thi.ng/testament": "^0.2.4",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
48
|
"tools": "^0.0.1",
|
|
49
|
-
"typedoc": "^0.22.
|
|
50
|
-
"typescript": "^4.
|
|
49
|
+
"typedoc": "^0.22.13",
|
|
50
|
+
"typescript": "^4.6.2"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"allpass",
|
|
@@ -272,5 +272,5 @@
|
|
|
272
272
|
],
|
|
273
273
|
"year": 2015
|
|
274
274
|
},
|
|
275
|
-
"gitHead": "
|
|
275
|
+
"gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
|
|
276
276
|
}
|
package/pipe.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { IGen, IProc } from "./api.js";
|
|
|
3
3
|
* Higher order generator. Composes a new {@link IGen} from given source gen and
|
|
4
4
|
* a number of {@link IProc}s (processed in series, like using {@link serial}).
|
|
5
5
|
*
|
|
6
|
-
* @param src
|
|
7
|
-
* @param proc
|
|
6
|
+
* @param src -
|
|
7
|
+
* @param proc -
|
|
8
8
|
*/
|
|
9
9
|
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>;
|
package/power.d.ts
CHANGED
|
@@ -3,39 +3,39 @@ import type { ComplexArray } from "./api.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 declare const integralT: (window: NumericArray) => number;
|
|
9
9
|
/**
|
|
10
10
|
* Computes the squared sum of given array.
|
|
11
11
|
*
|
|
12
|
-
* @param window
|
|
12
|
+
* @param window -
|
|
13
13
|
*/
|
|
14
14
|
export declare const integralTSquared: (window: NumericArray) => number;
|
|
15
15
|
/**
|
|
16
16
|
* Computes the `sum(|c(i)|)` for given complex array.
|
|
17
17
|
*
|
|
18
|
-
* @param window
|
|
18
|
+
* @param window -
|
|
19
19
|
*/
|
|
20
20
|
export declare const integralF: ([real, img]: ComplexArray) => number;
|
|
21
21
|
/**
|
|
22
22
|
* Computes the `sum(|c(i)|^2)` for given complex array.
|
|
23
23
|
*
|
|
24
|
-
* @param window
|
|
24
|
+
* @param window -
|
|
25
25
|
*/
|
|
26
26
|
export declare const integralFSquared: ([real, img]: ComplexArray) => number;
|
|
27
27
|
/**
|
|
28
28
|
* If `scale` is a number, returns it. Else returns `base / integralT(scale)`.
|
|
29
29
|
*
|
|
30
|
-
* @param scale
|
|
31
|
-
* @param base
|
|
30
|
+
* @param scale -
|
|
31
|
+
* @param base -
|
|
32
32
|
*/
|
|
33
33
|
export declare const powerScale: (scale: number | NumericArray, base?: number) => number;
|
|
34
34
|
/**
|
|
35
35
|
* If `scale` is a number, returns it. Else returns `integralT(scale) / base`.
|
|
36
36
|
*
|
|
37
|
-
* @param scale
|
|
38
|
-
* @param base
|
|
37
|
+
* @param scale -
|
|
38
|
+
* @param base -
|
|
39
39
|
*/
|
|
40
40
|
export declare const invPowerScale: (scale: number | NumericArray, base?: number) => number;
|
|
41
41
|
/**
|
|
@@ -46,7 +46,7 @@ export declare const invPowerScale: (scale: number | NumericArray, base?: number
|
|
|
46
46
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
47
47
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
48
48
|
*
|
|
49
|
-
* @param window
|
|
49
|
+
* @param window -
|
|
50
50
|
*/
|
|
51
51
|
export declare const powerSumSquared: (window: NumericArray | ComplexArray) => number;
|
|
52
52
|
/**
|
|
@@ -57,7 +57,7 @@ export declare const powerSumSquared: (window: NumericArray | ComplexArray) => n
|
|
|
57
57
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
58
58
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
59
59
|
*
|
|
60
|
-
* @param window
|
|
60
|
+
* @param window -
|
|
61
61
|
*/
|
|
62
62
|
export declare const powerMeanSquared: (window: NumericArray | ComplexArray) => number;
|
|
63
63
|
/**
|
|
@@ -69,7 +69,7 @@ export declare const powerMeanSquared: (window: NumericArray | ComplexArray) =>
|
|
|
69
69
|
* - http://www.it.uom.gr/teaching/linearalgebra/NumericalRecipiesInC/c13-4.pdf
|
|
70
70
|
* - http://www.hep.ucl.ac.uk/~rjn/saltStuff/fftNormalisation.pdf
|
|
71
71
|
*
|
|
72
|
-
* @param window
|
|
72
|
+
* @param window -
|
|
73
73
|
*/
|
|
74
74
|
export declare const powerTimeIntegral: (window: NumericArray | ComplexArray, fs: number) => number;
|
|
75
75
|
//# sourceMappingURL=power.d.ts.map
|
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;) {
|