@thi.ng/dsp 3.0.28 → 4.0.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +82 -133
  2. package/README.md +66 -58
  3. package/{gen/add.d.ts → add.d.ts} +4 -2
  4. package/{gen/add.js → add.js} +7 -2
  5. package/{comp/addg.d.ts → addg.d.ts} +1 -1
  6. package/{comp/addg.js → addg.js} +0 -0
  7. package/{gen/adsr.d.ts → adsr.d.ts} +1 -1
  8. package/{gen/adsr.js → adsr.js} +22 -2
  9. package/{gen/agen.d.ts → agen.d.ts} +1 -1
  10. package/{gen/agen.js → agen.js} +3 -4
  11. package/{proc/allpass.d.ts → allpass.d.ts} +0 -0
  12. package/{proc/allpass.js → allpass.js} +5 -1
  13. package/{gen/alt.d.ts → alt.d.ts} +0 -0
  14. package/{gen/alt.js → alt.js} +3 -1
  15. package/{util/anti-alias.d.ts → anti-alias.d.ts} +0 -0
  16. package/{util/anti-alias.js → anti-alias.js} +1 -1
  17. package/{proc/aproc.d.ts → aproc.d.ts} +6 -4
  18. package/{proc/aproc.js → aproc.js} +8 -4
  19. package/{proc/biquad.d.ts → biquad.d.ts} +1 -1
  20. package/{proc/biquad.js → biquad.js} +15 -3
  21. package/bounce.d.ts +13 -0
  22. package/bounce.js +18 -0
  23. package/{util/complex.d.ts → complex.d.ts} +1 -1
  24. package/{util/complex.js → complex.js} +1 -1
  25. package/{gen/const.d.ts → const.d.ts} +0 -0
  26. package/{gen/const.js → const.js} +0 -0
  27. package/{util/convert.d.ts → convert.d.ts} +0 -0
  28. package/{util/convert.js → convert.js} +1 -1
  29. package/{gen/cosine.d.ts → cosine.d.ts} +0 -0
  30. package/{gen/cosine.js → cosine.js} +5 -1
  31. package/{gen/curve.d.ts → curve.d.ts} +0 -0
  32. package/{gen/curve.js → curve.js} +0 -0
  33. package/{proc/dcblock.d.ts → dcblock.d.ts} +0 -0
  34. package/{proc/dcblock.js → dcblock.js} +0 -0
  35. package/{proc/delay.d.ts → delay.d.ts} +0 -0
  36. package/{proc/delay.js → delay.js} +6 -2
  37. package/{proc/feedback-delay.d.ts → feedback-delay.d.ts} +0 -0
  38. package/{proc/feedback-delay.js → feedback-delay.js} +2 -1
  39. package/{fft/fft.d.ts → fft.d.ts} +1 -1
  40. package/{fft/fft.js → fft.js} +2 -2
  41. package/{util/filter-response.d.ts → filter-response.d.ts} +1 -1
  42. package/{util/filter-response.js → filter-response.js} +3 -2
  43. package/{proc/foldback.d.ts → foldback.d.ts} +0 -0
  44. package/{proc/foldback.js → foldback.js} +3 -1
  45. package/{gen/impulse-train.d.ts → impulse-train.d.ts} +0 -0
  46. package/{gen/impulse-train.js → impulse-train.js} +5 -0
  47. package/{gen/impulse.d.ts → impulse.d.ts} +0 -0
  48. package/{gen/impulse.js → impulse.js} +2 -0
  49. package/index.d.ts +56 -55
  50. package/index.js +56 -55
  51. package/{proc/integrator.d.ts → integrator.d.ts} +0 -0
  52. package/{proc/integrator.js → integrator.js} +2 -0
  53. package/internal/take.d.ts +3 -0
  54. package/internal/take.js +6 -0
  55. package/{gen/iterable.d.ts → iterable.d.ts} +1 -1
  56. package/{gen/iterable.js → iterable.js} +4 -4
  57. package/{gen/line.d.ts → line.d.ts} +0 -0
  58. package/{gen/line.js → line.js} +0 -0
  59. package/{gen/madd.d.ts → madd.d.ts} +0 -0
  60. package/{gen/madd.js → madd.js} +4 -0
  61. package/{comp/mapg.d.ts → mapg.d.ts} +2 -2
  62. package/{comp/mapg.js → mapg.js} +16 -2
  63. package/{proc/mix.d.ts → mix.d.ts} +0 -0
  64. package/{proc/mix.js → mix.js} +2 -1
  65. package/{gen/mul.d.ts → mul.d.ts} +0 -0
  66. package/{gen/mul.js → mul.js} +3 -0
  67. package/multiplex.d.ts +26 -0
  68. package/{comp/multiplex.js → multiplex.js} +2 -1
  69. package/{proc/onepole.d.ts → onepole.d.ts} +1 -1
  70. package/{proc/onepole.js → onepole.js} +6 -1
  71. package/{osc/additive.d.ts → osc-additive.d.ts} +16 -2
  72. package/{osc/additive.js → osc-additive.js} +16 -2
  73. package/osc-cos.d.ts +3 -0
  74. package/{osc/cos.js → osc-cos.js} +1 -1
  75. package/{osc/dsf.d.ts → osc-dsf.d.ts} +2 -2
  76. package/{osc/dsf.js → osc-dsf.js} +1 -1
  77. package/{osc/mix.d.ts → osc-mix.d.ts} +2 -2
  78. package/{osc/mix.js → osc-mix.js} +1 -1
  79. package/{osc/parabolic.d.ts → osc-parabolic.d.ts} +2 -2
  80. package/{osc/parabolic.js → osc-parabolic.js} +1 -1
  81. package/{osc/rect.d.ts → osc-rect.d.ts} +2 -2
  82. package/{osc/rect.js → osc-rect.js} +1 -1
  83. package/osc-saw.d.ts +3 -0
  84. package/{osc/saw.js → osc-saw.js} +1 -1
  85. package/osc-sin.d.ts +3 -0
  86. package/{osc/sin.js → osc-sin.js} +1 -1
  87. package/osc-tri.d.ts +3 -0
  88. package/{osc/tri.js → osc-tri.js} +1 -1
  89. package/{osc/wavetable.d.ts → osc-wavetable.d.ts} +2 -2
  90. package/{osc/wavetable.js → osc-wavetable.js} +2 -1
  91. package/{gen/osc.d.ts → osc.d.ts} +1 -1
  92. package/{gen/osc.js → osc.js} +6 -2
  93. package/package.json +201 -33
  94. package/{gen/pink-noise.d.ts → pink-noise.d.ts} +1 -1
  95. package/{gen/pink-noise.js → pink-noise.js} +6 -1
  96. package/{comp/pipe.d.ts → pipe.d.ts} +8 -1
  97. package/{comp/pipe.js → pipe.js} +0 -0
  98. package/{fft/power.d.ts → power.d.ts} +1 -1
  99. package/{fft/power.js → power.js} +2 -2
  100. package/{comp/product.d.ts → product.d.ts} +1 -1
  101. package/{comp/product.js → product.js} +0 -0
  102. package/{gen/reciprocal.d.ts → reciprocal.d.ts} +0 -0
  103. package/{gen/reciprocal.js → reciprocal.js} +2 -0
  104. package/serial.d.ts +44 -0
  105. package/{comp/compp.js → serial.js} +20 -10
  106. package/{gen/sincos.d.ts → sincos.d.ts} +0 -0
  107. package/{gen/sincos.js → sincos.js} +6 -1
  108. package/{comp/sum.d.ts → sum.d.ts} +1 -1
  109. package/{comp/sum.js → sum.js} +0 -0
  110. package/{proc/svf.d.ts → svf.d.ts} +1 -1
  111. package/{proc/svf.js → svf.js} +11 -1
  112. package/{gen/sweep.d.ts → sweep.d.ts} +1 -1
  113. package/{gen/sweep.js → sweep.js} +1 -1
  114. package/{proc/waveshaper.d.ts → waveshaper.d.ts} +0 -0
  115. package/{proc/waveshaper.js → waveshaper.js} +5 -1
  116. package/{gen/white-noise.d.ts → white-noise.d.ts} +1 -1
  117. package/{gen/white-noise.js → white-noise.js} +3 -1
  118. package/{fft/window.d.ts → window.d.ts} +1 -1
  119. package/{fft/window.js → window.js} +2 -2
  120. package/comp/compp.d.ts +0 -33
  121. package/comp/multiplex.d.ts +0 -11
  122. package/lib/index.js +0 -1703
  123. package/lib/index.js.map +0 -1
  124. package/lib/index.umd.js +0 -1
  125. package/lib/index.umd.js.map +0 -1
  126. package/osc/cos.d.ts +0 -3
  127. package/osc/saw.d.ts +0 -3
  128. package/osc/sin.d.ts +0 -3
  129. package/osc/tri.d.ts +0 -3
File without changes
File without changes
@@ -11,6 +11,10 @@ import { AGen } from "./agen";
11
11
  */
12
12
  export const madd = (factor, start, offset, clamp) => new MAdd(factor, start, offset, clamp);
13
13
  export class MAdd extends AGen {
14
+ _factor;
15
+ _start;
16
+ _offset;
17
+ _clamp;
14
18
  constructor(_factor = 1, _start = 1, _offset = 0, _clamp) {
15
19
  super(0);
16
20
  this._factor = _factor;
@@ -1,6 +1,6 @@
1
1
  import type { Fn2, Fn3, Fn4, Fn5 } from "@thi.ng/api";
2
- import type { IGen } from "../api";
3
- import { AGen } from "../gen/agen";
2
+ import { AGen } from "./agen";
3
+ import type { IGen } from "./api";
4
4
  export declare function mapG<A, T>(op: Fn2<A, T, T>, a: IGen<A>, init: T): IGen<T>;
5
5
  export declare function mapG<A, B, T>(op: Fn3<A, B, T, T>, a: IGen<A>, b: IGen<B>, init: T): IGen<T>;
6
6
  export declare function mapG<A, B, C, T>(op: Fn4<A, B, C, T, T>, a: IGen<A>, b: IGen<B>, c: IGen<C>, init: T): IGen<T>;
@@ -1,5 +1,5 @@
1
- import { illegalArity } from "@thi.ng/errors";
2
- import { AGen } from "../gen/agen";
1
+ import { illegalArity } from "@thi.ng/errors/illegal-arity";
2
+ import { AGen } from "./agen";
3
3
  export function mapG(op, ...args) {
4
4
  switch (args.length) {
5
5
  case 2:
@@ -15,6 +15,8 @@ export function mapG(op, ...args) {
15
15
  }
16
16
  }
17
17
  export class MapG1 extends AGen {
18
+ _op;
19
+ _a;
18
20
  constructor(_op, _a, init) {
19
21
  super(init);
20
22
  this._op = _op;
@@ -25,6 +27,9 @@ export class MapG1 extends AGen {
25
27
  }
26
28
  }
27
29
  export class MapG2 extends AGen {
30
+ _op;
31
+ _a;
32
+ _b;
28
33
  constructor(_op, _a, _b, init) {
29
34
  super(init);
30
35
  this._op = _op;
@@ -36,6 +41,10 @@ export class MapG2 extends AGen {
36
41
  }
37
42
  }
38
43
  export class MapG3 extends AGen {
44
+ _op;
45
+ _a;
46
+ _b;
47
+ _c;
39
48
  constructor(_op, _a, _b, _c, init) {
40
49
  super(init);
41
50
  this._op = _op;
@@ -48,6 +57,11 @@ export class MapG3 extends AGen {
48
57
  }
49
58
  }
50
59
  export class MapG4 extends AGen {
60
+ _op;
61
+ _a;
62
+ _b;
63
+ _c;
64
+ _d;
51
65
  constructor(_op, _a, _b, _c, _d, init) {
52
66
  super(init);
53
67
  this._op = _op;
File without changes
@@ -1,6 +1,7 @@
1
- import { clamp01 } from "@thi.ng/math";
1
+ import { clamp01 } from "@thi.ng/math/interval";
2
2
  import { AProc2 } from "./aproc";
3
3
  export class Mix extends AProc2 {
4
+ _t;
4
5
  constructor(_t) {
5
6
  super(0);
6
7
  this._t = _t;
File without changes
@@ -11,6 +11,9 @@ import { AGen } from "./agen";
11
11
  */
12
12
  export const mul = (factor, start, clamp) => new Mul(factor, start, clamp);
13
13
  export class Mul extends AGen {
14
+ _factor;
15
+ _start;
16
+ _clamp;
14
17
  constructor(_factor = 1, _start = 1, _clamp) {
15
18
  super(0);
16
19
  this._factor = _factor;
package/multiplex.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { IProc } from "./api";
2
+ import { AProc } from "./aproc";
3
+ /**
4
+ * Higher order {@link IProc}. Constructs a new processor from given procs,
5
+ * which accepts a single input and passes it to each of the given processors,
6
+ * resulting in a tuple output (i.e. the input is processed in parallel (e.g.
7
+ * for multi-band processing), unlike w/ {@link serial}).
8
+ *
9
+ * @remarks
10
+ * In functional programming terms, the equivavelent is `juxt` (see
11
+ * thi.ng/compose)
12
+ *
13
+ * See {@link bounce} for combining results back into a single channel output.
14
+ *
15
+ * @param a
16
+ * @param b
17
+ */
18
+ export declare function multiplex<T, A, B>(a: IProc<T, A>, b: IProc<T, B>): Multiplex<T, [A, B]>;
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]>;
20
+ export declare function multiplex<T, A, B, C, D>(a: IProc<T, A>, b: IProc<T, B>, c: IProc<T, C>, d: IProc<T, D>): Multiplex<T, [A, B, C, D]>;
21
+ export declare class Multiplex<A, B extends any[]> extends AProc<A, B> {
22
+ protected _procs: IProc<A, any>[];
23
+ constructor(procs: IProc<A, any>[]);
24
+ next(x: A): B;
25
+ }
26
+ //# sourceMappingURL=multiplex.d.ts.map
@@ -1,8 +1,9 @@
1
- import { AProc } from "../proc/aproc";
1
+ import { AProc } from "./aproc";
2
2
  export function multiplex(...procs) {
3
3
  return new Multiplex(procs);
4
4
  }
5
5
  export class Multiplex extends AProc {
6
+ _procs;
6
7
  constructor(procs) {
7
8
  super(procs.map((p) => p.deref()));
8
9
  this._procs = procs;
@@ -1,5 +1,5 @@
1
1
  import type { IClear, IReset } from "@thi.ng/api";
2
- import type { FilterConfig, IFilter, OnepoleType } from "../api";
2
+ import type { FilterConfig, IFilter, OnepoleType } from "./api";
3
3
  import { AProc } from "./aproc";
4
4
  export declare const onepoleLP: (fc: number) => OnePole;
5
5
  export declare const onepoleHP: (fc: number) => OnePole;
@@ -1,4 +1,5 @@
1
- import { clamp05, TAU } from "@thi.ng/math";
1
+ import { TAU } from "@thi.ng/math/api";
2
+ import { clamp05 } from "@thi.ng/math/interval";
2
3
  import { AProc } from "./aproc";
3
4
  export const onepoleLP = (fc) => new OnePole("lp", fc);
4
5
  export const onepoleHP = (fc) => new OnePole("hp", fc);
@@ -6,6 +7,10 @@ export const onepoleHP = (fc) => new OnePole("hp", fc);
6
7
  * https://www.earlevel.com/main/2012/12/15/a-one-pole-filter/
7
8
  */
8
9
  export class OnePole extends AProc {
10
+ _type;
11
+ _freq;
12
+ _a0;
13
+ _b1;
9
14
  constructor(_type, _freq) {
10
15
  super(0);
11
16
  this._type = _type;
@@ -1,5 +1,19 @@
1
1
  import type { Fn } from "@thi.ng/api";
2
- import type { StatelessOscillator } from "../api";
2
+ import type { StatelessOscillator } from "./api";
3
+ /**
4
+ * Higher order function to produce an additive version of given
5
+ * {@link StatelessOscillator}. Returns new oscillator function.
6
+ *
7
+ * @remarks
8
+ * The `freqFn` and `ampFn` functions are used to compute respective frequency
9
+ * and amplitude factors for each of the `n` requested harmonics (given in [i,n]
10
+ * range).
11
+ *
12
+ * @param osc
13
+ * @param freqFn
14
+ * @param ampFn
15
+ * @param n
16
+ */
3
17
  export declare const additive: (osc: StatelessOscillator, freqFn: Fn<number, number>, ampFn: Fn<number, number>, n: number) => StatelessOscillator;
4
18
  /**
5
19
  * Interactive graph of this oscillator:
@@ -15,4 +29,4 @@ export declare const squareAdditive: (n?: number) => StatelessOscillator;
15
29
  * @param n - number of octaves
16
30
  */
17
31
  export declare const sawAdditive: (n?: number) => StatelessOscillator;
18
- //# sourceMappingURL=additive.d.ts.map
32
+ //# sourceMappingURL=osc-additive.d.ts.map
@@ -1,5 +1,19 @@
1
- import { gibbs } from "../util/anti-alias";
2
- import { sin } from "./sin";
1
+ import { gibbs } from "./anti-alias";
2
+ import { sin } from "./osc-sin";
3
+ /**
4
+ * Higher order function to produce an additive version of given
5
+ * {@link StatelessOscillator}. Returns new oscillator function.
6
+ *
7
+ * @remarks
8
+ * The `freqFn` and `ampFn` functions are used to compute respective frequency
9
+ * and amplitude factors for each of the `n` requested harmonics (given in [i,n]
10
+ * range).
11
+ *
12
+ * @param osc
13
+ * @param freqFn
14
+ * @param ampFn
15
+ * @param n
16
+ */
3
17
  export const additive = (osc, freqFn, ampFn, n) => {
4
18
  const fcache = [];
5
19
  const acache = [];
package/osc-cos.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { StatelessOscillator } from "./api";
2
+ export declare const cos: StatelessOscillator;
3
+ //# sourceMappingURL=osc-cos.d.ts.map
@@ -1,2 +1,2 @@
1
- import { TAU } from "@thi.ng/math";
1
+ import { TAU } from "@thi.ng/math/api";
2
2
  export const cos = (phase, freq, amp = 1, dc = 0) => dc + amp * Math.cos(phase * freq * TAU);
@@ -1,4 +1,4 @@
1
- import type { StatelessOscillator } from "../api";
1
+ import type { StatelessOscillator } from "./api";
2
2
  /**
3
3
  * Oscillator using Discrete Summation Formula:
4
4
  *
@@ -36,4 +36,4 @@ export declare const dsf: StatelessOscillator;
36
36
  * @param beta
37
37
  */
38
38
  export declare const dsfHOF: (alpha?: number, beta?: number) => StatelessOscillator;
39
- //# sourceMappingURL=dsf.d.ts.map
39
+ //# sourceMappingURL=osc-dsf.d.ts.map
@@ -1,4 +1,4 @@
1
- import { TAU } from "@thi.ng/math";
1
+ import { TAU } from "@thi.ng/math/api";
2
2
  /**
3
3
  * Oscillator using Discrete Summation Formula:
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { StatelessOscillator } from "../api";
1
+ import type { StatelessOscillator } from "./api";
2
2
  /**
3
3
  * HOF oscillator. Takes 2 stateless oscillator fns and returns new
4
4
  * oscillator function which produces an interpolated result of both.
@@ -19,4 +19,4 @@ export declare const mixOsc: (osc1: StatelessOscillator, osc2: StatelessOscillat
19
19
  * @param mix
20
20
  */
21
21
  export declare const mixOscHOF: (osc1: StatelessOscillator, osc2: StatelessOscillator, mix?: number) => StatelessOscillator;
22
- //# sourceMappingURL=mix.d.ts.map
22
+ //# sourceMappingURL=osc-mix.d.ts.map
@@ -1,4 +1,4 @@
1
- import { mix as _mix } from "@thi.ng/math";
1
+ import { mix as _mix } from "@thi.ng/math/mix";
2
2
  /**
3
3
  * HOF oscillator. Takes 2 stateless oscillator fns and returns new
4
4
  * oscillator function which produces an interpolated result of both.
@@ -1,4 +1,4 @@
1
- import type { StatelessOscillator } from "../api";
1
+ import type { StatelessOscillator } from "./api";
2
2
  /**
3
3
  * Parabolic waveform oscillator.
4
4
  *
@@ -12,4 +12,4 @@ import type { StatelessOscillator } from "../api";
12
12
  * @param dc -
13
13
  */
14
14
  export declare const parabolic: StatelessOscillator;
15
- //# sourceMappingURL=parabolic.d.ts.map
15
+ //# sourceMappingURL=osc-parabolic.d.ts.map
@@ -1,4 +1,4 @@
1
- import { fract } from "@thi.ng/math";
1
+ import { fract } from "@thi.ng/math/prec";
2
2
  /**
3
3
  * Parabolic waveform oscillator.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { StatelessOscillator } from "../api";
1
+ import type { StatelessOscillator } from "./api";
2
2
  export declare const rect: StatelessOscillator;
3
3
  /**
4
4
  * Higher order version of {@link rect} with pre-configured `duty` width
@@ -7,4 +7,4 @@ export declare const rect: StatelessOscillator;
7
7
  * @param duty
8
8
  */
9
9
  export declare const rectHOF: (duty?: number) => StatelessOscillator;
10
- //# sourceMappingURL=rect.d.ts.map
10
+ //# sourceMappingURL=osc-rect.d.ts.map
@@ -1,4 +1,4 @@
1
- import { fract } from "@thi.ng/math";
1
+ import { fract } from "@thi.ng/math/prec";
2
2
  export const rect = (phase, freq, amp = 1, dc = 0, duty = 0.5) => dc + amp * (fract(phase * freq) < duty ? 1 : -1);
3
3
  /**
4
4
  * Higher order version of {@link rect} with pre-configured `duty` width
package/osc-saw.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { StatelessOscillator } from "./api";
2
+ export declare const saw: StatelessOscillator;
3
+ //# sourceMappingURL=osc-saw.d.ts.map
@@ -1,2 +1,2 @@
1
- import { fract } from "@thi.ng/math";
1
+ import { fract } from "@thi.ng/math/prec";
2
2
  export const saw = (phase, freq, amp = 1, dc = 0) => dc + amp * (1 - 2 * fract(phase * freq));
package/osc-sin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { StatelessOscillator } from "./api";
2
+ export declare const sin: StatelessOscillator;
3
+ //# sourceMappingURL=osc-sin.d.ts.map
@@ -1,2 +1,2 @@
1
- import { TAU } from "@thi.ng/math";
1
+ import { TAU } from "@thi.ng/math/api";
2
2
  export const sin = (phase, freq, amp = 1, dc = 0) => dc + amp * Math.sin(phase * freq * TAU);
package/osc-tri.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { StatelessOscillator } from "./api";
2
+ export declare const tri: StatelessOscillator;
3
+ //# sourceMappingURL=osc-tri.d.ts.map
@@ -1,2 +1,2 @@
1
- import { fract } from "@thi.ng/math";
1
+ import { fract } from "@thi.ng/math/prec";
2
2
  export const tri = (phase, freq, amp = 1, dc = 0) => dc + amp * (Math.abs(fract(phase * freq) * 4 - 2) - 1);
@@ -1,4 +1,4 @@
1
1
  import type { Fn3, NumericArray } from "@thi.ng/api";
2
- import type { StatelessOscillator } from "../api";
2
+ import type { StatelessOscillator } from "./api";
3
3
  export declare const wavetable: (table: NumericArray, interpolate?: Fn3<number, number, number, number>) => StatelessOscillator;
4
- //# sourceMappingURL=wavetable.d.ts.map
4
+ //# sourceMappingURL=osc-wavetable.d.ts.map
@@ -1,4 +1,5 @@
1
- import { fract, mix as _mix } from "@thi.ng/math";
1
+ import { mix as _mix } from "@thi.ng/math/mix";
2
+ import { fract } from "@thi.ng/math/prec";
2
3
  export const wavetable = (table, interpolate = _mix) => {
3
4
  const n = table.length;
4
5
  const n1 = n - 1;
@@ -1,5 +1,5 @@
1
- import type { IGen, StatelessOscillator } from "../api";
2
1
  import { AGen } from "./agen";
2
+ import type { IGen, StatelessOscillator } from "./api";
3
3
  /**
4
4
  * Higher order oscillator gen, wrapping a {@link StatelessOscillator}
5
5
  * function and supporting either constant or {@link IGen}-based
@@ -1,8 +1,8 @@
1
- import { isNumber } from "@thi.ng/checks";
2
- import { sum } from "../comp/sum";
1
+ import { isNumber } from "@thi.ng/checks/is-number";
3
2
  import { Add, add } from "./add";
4
3
  import { AGen } from "./agen";
5
4
  import { Const } from "./const";
5
+ import { sum } from "./sum";
6
6
  /**
7
7
  * Higher order oscillator gen, wrapping a {@link StatelessOscillator}
8
8
  * function and supporting either constant or {@link IGen}-based
@@ -51,6 +51,10 @@ export const osc = (osc, freq, amp, dc) => new Osc(osc, freq, amp, dc);
51
51
  */
52
52
  export const modOsc = (osc, freq, fmod, amod = 1) => new Osc(osc, sum(fmod, isNumber(freq) ? add(freq) : freq), amod);
53
53
  export class Osc extends AGen {
54
+ _osc;
55
+ _dc;
56
+ _phase;
57
+ _amp;
54
58
  constructor(_osc, freq, amp = 1, _dc = 0) {
55
59
  super(0);
56
60
  this._osc = _osc;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thi.ng/dsp",
3
- "version": "3.0.28",
3
+ "version": "4.0.0",
4
4
  "description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
5
+ "type": "module",
5
6
  "module": "./index.js",
6
- "main": "./lib/index.js",
7
- "umd:main": "./lib/index.umd.js",
8
7
  "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
@@ -24,38 +24,26 @@
24
24
  "author": "Karsten Schmidt <k+npm@thi.ng>",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
28
- "build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
29
- "build:es6": "tsc --declaration",
30
- "build:test": "rimraf build && tsc -p test/tsconfig.json",
31
- "build:check": "tsc --isolatedModules --noEmit",
32
- "test": "mocha test",
33
- "cover": "nyc mocha test && nyc report --reporter=lcov",
34
- "clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib comp fft gen osc proc util",
35
- "doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
36
- "doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf *.js *.d.ts *.map doc",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
37
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
38
- "pub": "yarn build:release && yarn publish --access public"
31
+ "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
+ "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
+ "pub": "yarn build && yarn publish --access public",
34
+ "test": "testament test"
39
35
  },
40
36
  "dependencies": {
41
- "@thi.ng/api": "^7.1.9",
42
- "@thi.ng/checks": "^2.9.10",
43
- "@thi.ng/errors": "^1.3.4",
44
- "@thi.ng/math": "^4.0.5",
45
- "@thi.ng/random": "^2.4.7",
46
- "@thi.ng/transducers": "^7.8.4"
37
+ "@thi.ng/api": "^8.0.0",
38
+ "@thi.ng/checks": "^3.0.0",
39
+ "@thi.ng/errors": "^2.0.0",
40
+ "@thi.ng/math": "^5.0.0",
41
+ "@thi.ng/random": "^3.0.0",
42
+ "@thi.ng/transducers": "^8.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@thi.ng/testament": "^0.1.0"
47
46
  },
48
- "files": [
49
- "*.js",
50
- "*.d.ts",
51
- "lib",
52
- "comp",
53
- "fft",
54
- "gen",
55
- "osc",
56
- "proc",
57
- "util"
58
- ],
59
47
  "keywords": [
60
48
  "allpass",
61
49
  "analysis",
@@ -89,12 +77,192 @@
89
77
  "publishConfig": {
90
78
  "access": "public"
91
79
  },
92
- "sideEffects": false,
80
+ "files": [
81
+ "*.js",
82
+ "*.d.ts",
83
+ "internal"
84
+ ],
85
+ "exports": {
86
+ ".": {
87
+ "import": "./index.js"
88
+ },
89
+ "./add": {
90
+ "import": "./add.js"
91
+ },
92
+ "./addg": {
93
+ "import": "./addg.js"
94
+ },
95
+ "./adsr": {
96
+ "import": "./adsr.js"
97
+ },
98
+ "./agen": {
99
+ "import": "./agen.js"
100
+ },
101
+ "./allpass": {
102
+ "import": "./allpass.js"
103
+ },
104
+ "./alt": {
105
+ "import": "./alt.js"
106
+ },
107
+ "./anti-alias": {
108
+ "import": "./anti-alias.js"
109
+ },
110
+ "./api": {
111
+ "import": "./api.js"
112
+ },
113
+ "./aproc": {
114
+ "import": "./aproc.js"
115
+ },
116
+ "./biquad": {
117
+ "import": "./biquad.js"
118
+ },
119
+ "./bounce": {
120
+ "import": "./bounce.js"
121
+ },
122
+ "./complex": {
123
+ "import": "./complex.js"
124
+ },
125
+ "./const": {
126
+ "import": "./const.js"
127
+ },
128
+ "./convert": {
129
+ "import": "./convert.js"
130
+ },
131
+ "./cosine": {
132
+ "import": "./cosine.js"
133
+ },
134
+ "./curve": {
135
+ "import": "./curve.js"
136
+ },
137
+ "./dcblock": {
138
+ "import": "./dcblock.js"
139
+ },
140
+ "./delay": {
141
+ "import": "./delay.js"
142
+ },
143
+ "./feedback-delay": {
144
+ "import": "./feedback-delay.js"
145
+ },
146
+ "./fft": {
147
+ "import": "./fft.js"
148
+ },
149
+ "./filter-response": {
150
+ "import": "./filter-response.js"
151
+ },
152
+ "./foldback": {
153
+ "import": "./foldback.js"
154
+ },
155
+ "./impulse-train": {
156
+ "import": "./impulse-train.js"
157
+ },
158
+ "./impulse": {
159
+ "import": "./impulse.js"
160
+ },
161
+ "./integrator": {
162
+ "import": "./integrator.js"
163
+ },
164
+ "./iterable": {
165
+ "import": "./iterable.js"
166
+ },
167
+ "./line": {
168
+ "import": "./line.js"
169
+ },
170
+ "./madd": {
171
+ "import": "./madd.js"
172
+ },
173
+ "./mapg": {
174
+ "import": "./mapg.js"
175
+ },
176
+ "./mix": {
177
+ "import": "./mix.js"
178
+ },
179
+ "./mul": {
180
+ "import": "./mul.js"
181
+ },
182
+ "./multiplex": {
183
+ "import": "./multiplex.js"
184
+ },
185
+ "./onepole": {
186
+ "import": "./onepole.js"
187
+ },
188
+ "./osc-additive": {
189
+ "import": "./osc-additive.js"
190
+ },
191
+ "./osc-cos": {
192
+ "import": "./osc-cos.js"
193
+ },
194
+ "./osc-dsf": {
195
+ "import": "./osc-dsf.js"
196
+ },
197
+ "./osc-mix": {
198
+ "import": "./osc-mix.js"
199
+ },
200
+ "./osc-parabolic": {
201
+ "import": "./osc-parabolic.js"
202
+ },
203
+ "./osc-rect": {
204
+ "import": "./osc-rect.js"
205
+ },
206
+ "./osc-saw": {
207
+ "import": "./osc-saw.js"
208
+ },
209
+ "./osc-sin": {
210
+ "import": "./osc-sin.js"
211
+ },
212
+ "./osc-tri": {
213
+ "import": "./osc-tri.js"
214
+ },
215
+ "./osc-wavetable": {
216
+ "import": "./osc-wavetable.js"
217
+ },
218
+ "./osc": {
219
+ "import": "./osc.js"
220
+ },
221
+ "./pink-noise": {
222
+ "import": "./pink-noise.js"
223
+ },
224
+ "./pipe": {
225
+ "import": "./pipe.js"
226
+ },
227
+ "./power": {
228
+ "import": "./power.js"
229
+ },
230
+ "./product": {
231
+ "import": "./product.js"
232
+ },
233
+ "./reciprocal": {
234
+ "import": "./reciprocal.js"
235
+ },
236
+ "./serial": {
237
+ "import": "./serial.js"
238
+ },
239
+ "./sincos": {
240
+ "import": "./sincos.js"
241
+ },
242
+ "./sum": {
243
+ "import": "./sum.js"
244
+ },
245
+ "./svf": {
246
+ "import": "./svf.js"
247
+ },
248
+ "./sweep": {
249
+ "import": "./sweep.js"
250
+ },
251
+ "./waveshaper": {
252
+ "import": "./waveshaper.js"
253
+ },
254
+ "./white-noise": {
255
+ "import": "./white-noise.js"
256
+ },
257
+ "./window": {
258
+ "import": "./window.js"
259
+ }
260
+ },
93
261
  "thi.ng": {
94
262
  "related": [
95
263
  "math"
96
264
  ],
97
265
  "year": 2015
98
266
  },
99
- "gitHead": "3365151f112c39f224541f5ac4cedf3370eb9ba4"
267
+ "gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
100
268
  }
@@ -1,5 +1,5 @@
1
1
  import type { IReset, Tuple } from "@thi.ng/api";
2
- import { IRandom } from "@thi.ng/random";
2
+ import type { IRandom } from "@thi.ng/random";
3
3
  import { AGen } from "./agen";
4
4
  declare type PNoiseCoeffs = Tuple<number, 5>;
5
5
  /**