@thi.ng/dsp 4.1.3 → 4.2.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/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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2022-04-07T14:17:30Z
|
|
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,16 @@ 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.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.2.0) (2022-04-07)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add opt Osc() ctor phase arg, fix [#340](https://github.com/thi-ng/umbrella/issues/340) ([f798c9d](https://github.com/thi-ng/umbrella/commit/f798c9d))
|
|
17
|
+
- update osc() factory fn
|
|
18
|
+
- update Osc.setFreq() signatures
|
|
19
|
+
- add tests
|
|
20
|
+
- add/update docs
|
|
21
|
+
|
|
12
22
|
## [4.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.1.0) (2021-11-17)
|
|
13
23
|
|
|
14
24
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ node --experimental-repl-await
|
|
|
86
86
|
> const dsp = await import("@thi.ng/dsp");
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
Package sizes (gzipped, pre-treeshake): ESM: 7.
|
|
89
|
+
Package sizes (gzipped, pre-treeshake): ESM: 7.56 KB
|
|
90
90
|
|
|
91
91
|
## Dependencies
|
|
92
92
|
|
|
@@ -583,4 +583,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
583
583
|
|
|
584
584
|
## License
|
|
585
585
|
|
|
586
|
-
© 2015 -
|
|
586
|
+
© 2015 - 2022 Karsten Schmidt // Apache Software License 2.0
|
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 = [];
|