@thi.ng/dsp 4.2.24 → 4.2.26
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 +7 -10
- package/agen.d.ts +3 -2
- package/agen.js +3 -2
- package/anti-alias.d.ts +8 -9
- package/anti-alias.js +8 -9
- package/api.d.ts +7 -7
- package/aproc.d.ts +2 -1
- package/aproc.js +2 -1
- package/fft.d.ts +8 -7
- package/osc-additive.d.ts +2 -2
- package/osc-additive.js +2 -2
- package/osc.d.ts +2 -1
- package/osc.js +2 -1
- package/package.json +14 -14
- package/pink-noise.d.ts +1 -1
- package/waveshaper.d.ts +1 -1
- package/white-noise.d.ts +2 -1
- package/white-noise.js +2 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/dsp)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -35,7 +35,7 @@ This project is part of the
|
|
|
35
35
|
|
|
36
36
|
## About
|
|
37
37
|
|
|
38
|
-
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
|
|
38
|
+
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
|
|
39
39
|
|
|
40
40
|
Partially ported from other thi.ng projects (e.g.
|
|
41
41
|
[thi.ng/synstack](https://github.com/thi-ng/synstack),
|
|
@@ -79,11 +79,8 @@ ES module import:
|
|
|
79
79
|
|
|
80
80
|
For Node.js REPL:
|
|
81
81
|
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
node --experimental-repl-await
|
|
85
|
-
|
|
86
|
-
> const dsp = await import("@thi.ng/dsp");
|
|
82
|
+
```js
|
|
83
|
+
const dsp = await import("@thi.ng/dsp");
|
|
87
84
|
```
|
|
88
85
|
|
|
89
86
|
Package sizes (brotli'd, pre-treeshake): ESM: 6.84 KB
|
|
@@ -569,7 +566,7 @@ Desmos](https://www.desmos.com/calculator/lkyf2ag3ta) to experiment.
|
|
|
569
566
|
|
|
570
567
|
## Authors
|
|
571
568
|
|
|
572
|
-
Karsten Schmidt
|
|
569
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
573
570
|
|
|
574
571
|
If this project contributes to an academic publication, please cite it as:
|
|
575
572
|
|
|
@@ -584,4 +581,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
584
581
|
|
|
585
582
|
## License
|
|
586
583
|
|
|
587
|
-
© 2015 - 2022 Karsten Schmidt // Apache
|
|
584
|
+
© 2015 - 2022 Karsten Schmidt // Apache License 2.0
|
package/agen.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IGen } from "./api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Abstract base class for unit gens in this package. Provides
|
|
4
|
-
*
|
|
5
|
-
* `Iterable` implementations to use gens as ES6
|
|
4
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) to obtain
|
|
5
|
+
* the gen's current value and `Iterable` implementations to use gens as ES6
|
|
6
|
+
* iterables.
|
|
6
7
|
*/
|
|
7
8
|
export declare abstract class AGen<T> implements IGen<T> {
|
|
8
9
|
protected _val: T;
|
package/agen.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __take } from "./internal/take.js";
|
|
2
2
|
/**
|
|
3
3
|
* Abstract base class for unit gens in this package. Provides
|
|
4
|
-
*
|
|
5
|
-
* `Iterable` implementations to use gens as ES6
|
|
4
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) to obtain
|
|
5
|
+
* the gen's current value and `Iterable` implementations to use gens as ES6
|
|
6
|
+
* iterables.
|
|
6
7
|
*/
|
|
7
8
|
export class AGen {
|
|
8
9
|
constructor(_val) {
|
package/anti-alias.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { FnN2 } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
3
|
* Reference:
|
|
4
|
-
* -
|
|
5
|
-
* -
|
|
4
|
+
* - https://en.wikipedia.org/wiki/Gibbs_phenomenon
|
|
5
|
+
* - http://www.musicdsp.org/files/bandlimited.pdf
|
|
6
6
|
*
|
|
7
|
-
* Interactive graph
|
|
8
|
-
* {@link https://www.desmos.com/calculator/irugw6gnhy}
|
|
7
|
+
* [Interactive graph](https://www.desmos.com/calculator/irugw6gnhy)
|
|
9
8
|
*
|
|
10
9
|
* @param n - number of octaves
|
|
11
10
|
* @param i - curr octave [1..n]
|
|
@@ -15,9 +14,9 @@ export declare const gibbs: FnN2;
|
|
|
15
14
|
* Fejér weight for `k`-th harmonic in a Fourier series of length `n`.
|
|
16
15
|
*
|
|
17
16
|
* @remarks
|
|
18
|
-
* Used for attenuating the {@link gibbs} factor when summing a Fourier
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Used for attenuating the {@link gibbs} factor when summing a Fourier series.
|
|
18
|
+
* Linearly attentuates higher harmonics, with the first bin receiving a weight
|
|
19
|
+
* on 1 and the last bin `1/n`.
|
|
21
20
|
*
|
|
22
21
|
* @param k -
|
|
23
22
|
* @param n -
|
|
@@ -26,8 +25,8 @@ export declare const fejer: FnN2;
|
|
|
26
25
|
/**
|
|
27
26
|
* Polynomial attenuation to create bandlimited version of a signal.
|
|
28
27
|
*
|
|
29
|
-
* -
|
|
30
|
-
* -
|
|
28
|
+
* - http://research.spa.aalto.fi/publications/papers/smc2010-phaseshaping/
|
|
29
|
+
* - http://www.kvraudio.com/forum/viewtopic.php?t=375517
|
|
31
30
|
*
|
|
32
31
|
* @param dt - time step
|
|
33
32
|
* @param t - normalized phase
|
package/anti-alias.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { HALF_PI } from "@thi.ng/math/api";
|
|
2
2
|
/**
|
|
3
3
|
* Reference:
|
|
4
|
-
* -
|
|
5
|
-
* -
|
|
4
|
+
* - https://en.wikipedia.org/wiki/Gibbs_phenomenon
|
|
5
|
+
* - http://www.musicdsp.org/files/bandlimited.pdf
|
|
6
6
|
*
|
|
7
|
-
* Interactive graph
|
|
8
|
-
* {@link https://www.desmos.com/calculator/irugw6gnhy}
|
|
7
|
+
* [Interactive graph](https://www.desmos.com/calculator/irugw6gnhy)
|
|
9
8
|
*
|
|
10
9
|
* @param n - number of octaves
|
|
11
10
|
* @param i - curr octave [1..n]
|
|
@@ -15,9 +14,9 @@ export const gibbs = (n, i) => Math.cos(((i - 1) * HALF_PI) / n) ** 2;
|
|
|
15
14
|
* Fejér weight for `k`-th harmonic in a Fourier series of length `n`.
|
|
16
15
|
*
|
|
17
16
|
* @remarks
|
|
18
|
-
* Used for attenuating the {@link gibbs} factor when summing a Fourier
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Used for attenuating the {@link gibbs} factor when summing a Fourier series.
|
|
18
|
+
* Linearly attentuates higher harmonics, with the first bin receiving a weight
|
|
19
|
+
* on 1 and the last bin `1/n`.
|
|
21
20
|
*
|
|
22
21
|
* @param k -
|
|
23
22
|
* @param n -
|
|
@@ -26,8 +25,8 @@ export const fejer = (k, n) => (n - k) / n;
|
|
|
26
25
|
/**
|
|
27
26
|
* Polynomial attenuation to create bandlimited version of a signal.
|
|
28
27
|
*
|
|
29
|
-
* -
|
|
30
|
-
* -
|
|
28
|
+
* - http://research.spa.aalto.fi/publications/papers/smc2010-phaseshaping/
|
|
29
|
+
* - http://www.kvraudio.com/forum/viewtopic.php?t=375517
|
|
31
30
|
*
|
|
32
31
|
* @param dt - time step
|
|
33
32
|
* @param t - normalized phase
|
package/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FnN2, IDeref, NumericArray } from "@thi.ng/api";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type StatelessOscillator = (phase: number, freq: number, amp?: number, dc?: number, ...opts: any[]) => number;
|
|
3
|
+
export type ComplexArray = [NumericArray, NumericArray];
|
|
4
|
+
export type WindowFn = FnN2;
|
|
5
5
|
export interface IGen<T> extends Iterable<T>, IDeref<T> {
|
|
6
6
|
next(): T;
|
|
7
7
|
take(num: number, out?: T[], idx?: number): T[];
|
|
@@ -28,8 +28,8 @@ export interface IFilter {
|
|
|
28
28
|
*/
|
|
29
29
|
filterCoeffs(): FilterConfig;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
31
|
+
export type FilterType = "lp" | "hp" | "bp" | "notch" | "peak" | "loshelf" | "hishelf" | "all";
|
|
32
|
+
export type BiquadType = "lp" | "hp" | "bp" | "notch" | "peak" | "loshelf" | "hishelf";
|
|
33
|
+
export type OnepoleType = "lp" | "hp";
|
|
34
|
+
export type SVFType = "lp" | "hp" | "bp" | "notch" | "peak" | "all";
|
|
35
35
|
//# sourceMappingURL=api.d.ts.map
|
package/aproc.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { IXform } from "@thi.ng/transducers";
|
|
|
2
2
|
import type { IProc, IProc2 } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class for processors in this package. Provides
|
|
5
|
-
*
|
|
5
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) to obtain
|
|
6
|
+
* the processor's current value.
|
|
6
7
|
*/
|
|
7
8
|
export declare abstract class AProc<A, B> implements IProc<A, B>, IXform<A, B> {
|
|
8
9
|
protected _val: B;
|
package/aproc.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { map } from "@thi.ng/transducers/map";
|
|
2
2
|
/**
|
|
3
3
|
* Abstract base class for processors in this package. Provides
|
|
4
|
-
*
|
|
4
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) to obtain
|
|
5
|
+
* the processor's current value.
|
|
5
6
|
*/
|
|
6
7
|
export class AProc {
|
|
7
8
|
constructor(_val) {
|
package/fft.d.ts
CHANGED
|
@@ -13,17 +13,18 @@ export declare const complexArray: (n: number) => ComplexArray;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const copyComplex: (complex: ComplexArray) => ComplexArray;
|
|
15
15
|
/**
|
|
16
|
-
* If given a {@link ComplexArray}, computes the complex conjugate,
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* If given a {@link ComplexArray}, computes the complex conjugate, concatenates
|
|
17
|
+
* it in mirrored order to input (excluding bin 0) and returns it as new
|
|
18
|
+
* (complex) array.
|
|
19
19
|
*
|
|
20
20
|
* @remarks
|
|
21
21
|
* The length of the input buffer(s) is assumed to be a power of 2.
|
|
22
22
|
*
|
|
23
|
-
* If given a
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* If given a
|
|
24
|
+
* [`NumericArray`](https://docs.thi.ng/umbrella/api/types/NumericArray.html),
|
|
25
|
+
* the `isImg` arg chooses from one of the following operations: If `true`
|
|
26
|
+
* (default), returns new array with *negated* values concatenated in reverse
|
|
27
|
+
* order. If `false`, returns new array with *original* values concatenated in
|
|
27
28
|
* reverse order.
|
|
28
29
|
*
|
|
29
30
|
* @example
|
package/osc-additive.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ import type { StatelessOscillator } from "./api.js";
|
|
|
17
17
|
export declare const additive: (osc: StatelessOscillator, freqFn: Fn<number, number>, ampFn: Fn<number, number>, n: number) => StatelessOscillator;
|
|
18
18
|
/**
|
|
19
19
|
* Interactive graph of this oscillator:
|
|
20
|
-
*
|
|
20
|
+
* https://www.desmos.com/calculator/irugw6gnhy
|
|
21
21
|
*
|
|
22
22
|
* @param n - number of octaves
|
|
23
23
|
*/
|
|
24
24
|
export declare const squareAdditive: (n?: number) => StatelessOscillator;
|
|
25
25
|
/**
|
|
26
26
|
* Interactive graph of this oscillator:
|
|
27
|
-
*
|
|
27
|
+
* https://www.desmos.com/calculator/irugw6gnhy
|
|
28
28
|
*
|
|
29
29
|
* @param n - number of octaves
|
|
30
30
|
*/
|
package/osc-additive.js
CHANGED
|
@@ -31,14 +31,14 @@ export const additive = (osc, freqFn, ampFn, n) => {
|
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Interactive graph of this oscillator:
|
|
34
|
-
*
|
|
34
|
+
* https://www.desmos.com/calculator/irugw6gnhy
|
|
35
35
|
*
|
|
36
36
|
* @param n - number of octaves
|
|
37
37
|
*/
|
|
38
38
|
export const squareAdditive = (n = 8) => additive(sin, (i) => 2 * (i - 1) + 1, (i) => (1 / (2 * (i - 1) + 1)) * gibbs(n, i), n);
|
|
39
39
|
/**
|
|
40
40
|
* Interactive graph of this oscillator:
|
|
41
|
-
*
|
|
41
|
+
* https://www.desmos.com/calculator/irugw6gnhy
|
|
42
42
|
*
|
|
43
43
|
* @param n - number of octaves
|
|
44
44
|
*/
|
package/osc.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type { IGen, StatelessOscillator } from "./api.js";
|
|
|
13
13
|
* freq and its `dc` offset to `baseFreq * TAU`). Also see {@link fmodOsc} for
|
|
14
14
|
* syntax sugar. The `phase` arg is only used if `freq` is NOT an `IGen`.
|
|
15
15
|
*
|
|
16
|
-
* The oscillator initializes to zero and its
|
|
16
|
+
* The oscillator initializes to zero and its
|
|
17
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html).deref}
|
|
17
18
|
* value is only available / valid after the first invocation of
|
|
18
19
|
* {@link IGen.next}.
|
|
19
20
|
*
|
package/osc.js
CHANGED
|
@@ -16,7 +16,8 @@ import { sum } from "./sum.js";
|
|
|
16
16
|
* freq and its `dc` offset to `baseFreq * TAU`). Also see {@link fmodOsc} for
|
|
17
17
|
* syntax sugar. The `phase` arg is only used if `freq` is NOT an `IGen`.
|
|
18
18
|
*
|
|
19
|
-
* The oscillator initializes to zero and its
|
|
19
|
+
* The oscillator initializes to zero and its
|
|
20
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html).deref}
|
|
20
21
|
* value is only available / valid after the first invocation of
|
|
21
22
|
* {@link IGen.next}.
|
|
22
23
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dsp",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.26",
|
|
4
4
|
"description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
28
|
-
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
28
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc internal",
|
|
29
29
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
31
|
"doc:readme": "yarn doc:stats && tools:readme",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/checks": "^3.3.
|
|
39
|
-
"@thi.ng/errors": "^2.2.
|
|
40
|
-
"@thi.ng/math": "^5.3.
|
|
41
|
-
"@thi.ng/random": "^3.3.
|
|
42
|
-
"@thi.ng/transducers": "^8.3.
|
|
37
|
+
"@thi.ng/api": "^8.6.1",
|
|
38
|
+
"@thi.ng/checks": "^3.3.5",
|
|
39
|
+
"@thi.ng/errors": "^2.2.6",
|
|
40
|
+
"@thi.ng/math": "^5.3.17",
|
|
41
|
+
"@thi.ng/random": "^3.3.19",
|
|
42
|
+
"@thi.ng/transducers": "^8.3.27"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.33.
|
|
46
|
-
"@thi.ng/testament": "^0.3.
|
|
45
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
46
|
+
"@thi.ng/testament": "^0.3.7",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
48
|
"tools": "^0.0.1",
|
|
49
|
-
"typedoc": "^0.23.
|
|
50
|
-
"typescript": "^4.
|
|
49
|
+
"typedoc": "^0.23.22",
|
|
50
|
+
"typescript": "^4.9.4"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"allpass",
|
|
@@ -272,5 +272,5 @@
|
|
|
272
272
|
],
|
|
273
273
|
"year": 2015
|
|
274
274
|
},
|
|
275
|
-
"gitHead": "
|
|
275
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
276
276
|
}
|
package/pink-noise.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IReset, Tuple } from "@thi.ng/api";
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
3
|
import { AGen } from "./agen.js";
|
|
4
|
-
|
|
4
|
+
type PNoiseCoeffs = Tuple<number, 5>;
|
|
5
5
|
/**
|
|
6
6
|
* Pink noise generator with customizable frequency distribution. The
|
|
7
7
|
* default config produces a power spectrum roughly following the `1/f`
|
package/waveshaper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Fn2 } from "@thi.ng/api";
|
|
2
2
|
import { AProc } from "./aproc.js";
|
|
3
|
-
export
|
|
3
|
+
export type WaveShaperFn = Fn2<number, number, number>;
|
|
4
4
|
/**
|
|
5
5
|
* Customizable wave shaper for user defined shaping function supporting
|
|
6
6
|
* one (optional, implementation specific) adjustable curve parameter.
|
package/white-noise.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { IRandom } from "@thi.ng/random";
|
|
|
3
3
|
import { AGen } from "./agen.js";
|
|
4
4
|
/**
|
|
5
5
|
* White noise gen with customizable gain and
|
|
6
|
-
*
|
|
6
|
+
* [`IRandom`](https://docs.thi.ng/umbrella/random/interfaces/IRandom.html)
|
|
7
|
+
* source.
|
|
7
8
|
*
|
|
8
9
|
* @param gain -
|
|
9
10
|
* @param rnd -
|
package/white-noise.js
CHANGED
|
@@ -2,7 +2,8 @@ import { SYSTEM } from "@thi.ng/random/system";
|
|
|
2
2
|
import { AGen } from "./agen.js";
|
|
3
3
|
/**
|
|
4
4
|
* White noise gen with customizable gain and
|
|
5
|
-
*
|
|
5
|
+
* [`IRandom`](https://docs.thi.ng/umbrella/random/interfaces/IRandom.html)
|
|
6
|
+
* source.
|
|
6
7
|
*
|
|
7
8
|
* @param gain -
|
|
8
9
|
* @param rnd -
|