@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.
- package/CHANGELOG.md +82 -133
- package/README.md +66 -58
- package/{gen/add.d.ts → add.d.ts} +4 -2
- package/{gen/add.js → add.js} +7 -2
- package/{comp/addg.d.ts → addg.d.ts} +1 -1
- package/{comp/addg.js → addg.js} +0 -0
- package/{gen/adsr.d.ts → adsr.d.ts} +1 -1
- package/{gen/adsr.js → adsr.js} +22 -2
- package/{gen/agen.d.ts → agen.d.ts} +1 -1
- package/{gen/agen.js → agen.js} +3 -4
- package/{proc/allpass.d.ts → allpass.d.ts} +0 -0
- package/{proc/allpass.js → allpass.js} +5 -1
- package/{gen/alt.d.ts → alt.d.ts} +0 -0
- package/{gen/alt.js → alt.js} +3 -1
- package/{util/anti-alias.d.ts → anti-alias.d.ts} +0 -0
- package/{util/anti-alias.js → anti-alias.js} +1 -1
- package/{proc/aproc.d.ts → aproc.d.ts} +6 -4
- package/{proc/aproc.js → aproc.js} +8 -4
- package/{proc/biquad.d.ts → biquad.d.ts} +1 -1
- package/{proc/biquad.js → biquad.js} +15 -3
- package/bounce.d.ts +13 -0
- package/bounce.js +18 -0
- package/{util/complex.d.ts → complex.d.ts} +1 -1
- package/{util/complex.js → complex.js} +1 -1
- package/{gen/const.d.ts → const.d.ts} +0 -0
- package/{gen/const.js → const.js} +0 -0
- package/{util/convert.d.ts → convert.d.ts} +0 -0
- package/{util/convert.js → convert.js} +1 -1
- package/{gen/cosine.d.ts → cosine.d.ts} +0 -0
- package/{gen/cosine.js → cosine.js} +5 -1
- package/{gen/curve.d.ts → curve.d.ts} +0 -0
- package/{gen/curve.js → curve.js} +0 -0
- package/{proc/dcblock.d.ts → dcblock.d.ts} +0 -0
- package/{proc/dcblock.js → dcblock.js} +0 -0
- package/{proc/delay.d.ts → delay.d.ts} +0 -0
- package/{proc/delay.js → delay.js} +6 -2
- package/{proc/feedback-delay.d.ts → feedback-delay.d.ts} +0 -0
- package/{proc/feedback-delay.js → feedback-delay.js} +2 -1
- package/{fft/fft.d.ts → fft.d.ts} +1 -1
- package/{fft/fft.js → fft.js} +2 -2
- package/{util/filter-response.d.ts → filter-response.d.ts} +1 -1
- package/{util/filter-response.js → filter-response.js} +3 -2
- package/{proc/foldback.d.ts → foldback.d.ts} +0 -0
- package/{proc/foldback.js → foldback.js} +3 -1
- package/{gen/impulse-train.d.ts → impulse-train.d.ts} +0 -0
- package/{gen/impulse-train.js → impulse-train.js} +5 -0
- package/{gen/impulse.d.ts → impulse.d.ts} +0 -0
- package/{gen/impulse.js → impulse.js} +2 -0
- package/index.d.ts +56 -55
- package/index.js +56 -55
- package/{proc/integrator.d.ts → integrator.d.ts} +0 -0
- package/{proc/integrator.js → integrator.js} +2 -0
- package/internal/take.d.ts +3 -0
- package/internal/take.js +6 -0
- package/{gen/iterable.d.ts → iterable.d.ts} +1 -1
- package/{gen/iterable.js → iterable.js} +4 -4
- package/{gen/line.d.ts → line.d.ts} +0 -0
- package/{gen/line.js → line.js} +0 -0
- package/{gen/madd.d.ts → madd.d.ts} +0 -0
- package/{gen/madd.js → madd.js} +4 -0
- package/{comp/mapg.d.ts → mapg.d.ts} +2 -2
- package/{comp/mapg.js → mapg.js} +16 -2
- package/{proc/mix.d.ts → mix.d.ts} +0 -0
- package/{proc/mix.js → mix.js} +2 -1
- package/{gen/mul.d.ts → mul.d.ts} +0 -0
- package/{gen/mul.js → mul.js} +3 -0
- package/multiplex.d.ts +26 -0
- package/{comp/multiplex.js → multiplex.js} +2 -1
- package/{proc/onepole.d.ts → onepole.d.ts} +1 -1
- package/{proc/onepole.js → onepole.js} +6 -1
- package/{osc/additive.d.ts → osc-additive.d.ts} +16 -2
- package/{osc/additive.js → osc-additive.js} +16 -2
- package/osc-cos.d.ts +3 -0
- package/{osc/cos.js → osc-cos.js} +1 -1
- package/{osc/dsf.d.ts → osc-dsf.d.ts} +2 -2
- package/{osc/dsf.js → osc-dsf.js} +1 -1
- package/{osc/mix.d.ts → osc-mix.d.ts} +2 -2
- package/{osc/mix.js → osc-mix.js} +1 -1
- package/{osc/parabolic.d.ts → osc-parabolic.d.ts} +2 -2
- package/{osc/parabolic.js → osc-parabolic.js} +1 -1
- package/{osc/rect.d.ts → osc-rect.d.ts} +2 -2
- package/{osc/rect.js → osc-rect.js} +1 -1
- package/osc-saw.d.ts +3 -0
- package/{osc/saw.js → osc-saw.js} +1 -1
- package/osc-sin.d.ts +3 -0
- package/{osc/sin.js → osc-sin.js} +1 -1
- package/osc-tri.d.ts +3 -0
- package/{osc/tri.js → osc-tri.js} +1 -1
- package/{osc/wavetable.d.ts → osc-wavetable.d.ts} +2 -2
- package/{osc/wavetable.js → osc-wavetable.js} +2 -1
- package/{gen/osc.d.ts → osc.d.ts} +1 -1
- package/{gen/osc.js → osc.js} +6 -2
- package/package.json +201 -33
- package/{gen/pink-noise.d.ts → pink-noise.d.ts} +1 -1
- package/{gen/pink-noise.js → pink-noise.js} +6 -1
- package/{comp/pipe.d.ts → pipe.d.ts} +8 -1
- package/{comp/pipe.js → pipe.js} +0 -0
- package/{fft/power.d.ts → power.d.ts} +1 -1
- package/{fft/power.js → power.js} +2 -2
- package/{comp/product.d.ts → product.d.ts} +1 -1
- package/{comp/product.js → product.js} +0 -0
- package/{gen/reciprocal.d.ts → reciprocal.d.ts} +0 -0
- package/{gen/reciprocal.js → reciprocal.js} +2 -0
- package/serial.d.ts +44 -0
- package/{comp/compp.js → serial.js} +20 -10
- package/{gen/sincos.d.ts → sincos.d.ts} +0 -0
- package/{gen/sincos.js → sincos.js} +6 -1
- package/{comp/sum.d.ts → sum.d.ts} +1 -1
- package/{comp/sum.js → sum.js} +0 -0
- package/{proc/svf.d.ts → svf.d.ts} +1 -1
- package/{proc/svf.js → svf.js} +11 -1
- package/{gen/sweep.d.ts → sweep.d.ts} +1 -1
- package/{gen/sweep.js → sweep.js} +1 -1
- package/{proc/waveshaper.d.ts → waveshaper.d.ts} +0 -0
- package/{proc/waveshaper.js → waveshaper.js} +5 -1
- package/{gen/white-noise.d.ts → white-noise.d.ts} +1 -1
- package/{gen/white-noise.js → white-noise.js} +3 -1
- package/{fft/window.d.ts → window.d.ts} +1 -1
- package/{fft/window.js → window.js} +2 -2
- package/comp/compp.d.ts +0 -33
- package/comp/multiplex.d.ts +0 -11
- package/lib/index.js +0 -1703
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/osc/cos.d.ts +0 -3
- package/osc/saw.d.ts +0 -3
- package/osc/sin.d.ts +0 -3
- package/osc/tri.d.ts +0 -3
package/{gen/line.js → line.js}
RENAMED
|
File without changes
|
|
File without changes
|
package/{gen/madd.js → madd.js}
RENAMED
|
@@ -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
|
|
3
|
-
import {
|
|
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>;
|
package/{comp/mapg.js → mapg.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { illegalArity } from "@thi.ng/errors";
|
|
2
|
-
import { AGen } from "
|
|
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
|
package/{proc/mix.js → mix.js}
RENAMED
|
File without changes
|
package/{gen/mul.js → mul.js}
RENAMED
|
@@ -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 "
|
|
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 "
|
|
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 {
|
|
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 "
|
|
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 "
|
|
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
|
@@ -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 "
|
|
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 type { StatelessOscillator } from "
|
|
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 type { StatelessOscillator } from "
|
|
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 type { StatelessOscillator } from "
|
|
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
|
@@ -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
|
@@ -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
|
@@ -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 "
|
|
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,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
|
package/{gen/osc.js → osc.js}
RENAMED
|
@@ -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
|
+
"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 &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
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
|
-
"
|
|
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": "^
|
|
42
|
-
"@thi.ng/checks": "^
|
|
43
|
-
"@thi.ng/errors": "^
|
|
44
|
-
"@thi.ng/math": "^
|
|
45
|
-
"@thi.ng/random": "^
|
|
46
|
-
"@thi.ng/transducers": "^
|
|
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
|
-
"
|
|
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": "
|
|
267
|
+
"gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
|
|
100
268
|
}
|