@thi.ng/dsp 4.6.10 → 4.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/add.js +3 -0
- package/adsr.js +10 -0
- package/agen.js +1 -0
- package/allpass.js +3 -0
- package/alt.js +3 -1
- package/aproc.js +2 -0
- package/biquad.js +11 -0
- package/cosine.js +4 -0
- package/delay.js +4 -0
- package/feedback-delay.js +1 -0
- package/filter-delay.js +2 -0
- package/foldback.js +2 -0
- package/impulse-train.js +5 -0
- package/impulse.js +2 -0
- package/integrator.js +2 -0
- package/iterable.js +2 -0
- package/madd.js +4 -0
- package/mapg.js +14 -0
- package/merge.js +1 -0
- package/mix.js +1 -0
- package/mul.js +3 -0
- package/multiplex.js +1 -0
- package/onepole.js +4 -0
- package/osc.js +4 -0
- package/package.json +13 -14
- package/pan.js +1 -0
- package/pink-noise.js +5 -0
- package/reciprocal.js +2 -0
- package/ref.js +2 -0
- package/serial.js +10 -0
- package/sincos.js +5 -0
- package/svf.js +9 -0
- package/waveshaper.js +4 -0
- package/white-noise.js +2 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/add.js
CHANGED
|
@@ -11,6 +11,9 @@ import { AGen } from "./agen.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export const add = (step, start, clamp) => new Add(step, start, clamp);
|
|
13
13
|
export class Add extends AGen {
|
|
14
|
+
_step;
|
|
15
|
+
_start;
|
|
16
|
+
_clamp;
|
|
14
17
|
constructor(_step = 1, _start = 0, _clamp) {
|
|
15
18
|
super(0);
|
|
16
19
|
this._step = _step;
|
package/adsr.js
CHANGED
|
@@ -36,6 +36,16 @@ var EnvPhase;
|
|
|
36
36
|
*/
|
|
37
37
|
export const adsr = (opts) => new ADSR(opts);
|
|
38
38
|
export class ADSR extends AGen {
|
|
39
|
+
_phase;
|
|
40
|
+
_curve;
|
|
41
|
+
_atime;
|
|
42
|
+
_dtime;
|
|
43
|
+
_rtime;
|
|
44
|
+
_acurve;
|
|
45
|
+
_dcurve;
|
|
46
|
+
_sustain;
|
|
47
|
+
_speriod;
|
|
48
|
+
_gain;
|
|
39
49
|
constructor(opts) {
|
|
40
50
|
super(0);
|
|
41
51
|
opts = {
|
package/agen.js
CHANGED
package/allpass.js
CHANGED
package/alt.js
CHANGED
|
@@ -3,11 +3,13 @@ export const alt = (n = 1) => new Alt(n, -n);
|
|
|
3
3
|
export const altT = (a, b) => new Alt(a, b);
|
|
4
4
|
export const altB = (x = true) => new Alt(x, !x);
|
|
5
5
|
export class Alt extends AGen {
|
|
6
|
+
_a;
|
|
7
|
+
_b;
|
|
8
|
+
_flip = true;
|
|
6
9
|
constructor(_a, _b) {
|
|
7
10
|
super(_b);
|
|
8
11
|
this._a = _a;
|
|
9
12
|
this._b = _b;
|
|
10
|
-
this._flip = true;
|
|
11
13
|
}
|
|
12
14
|
copy() {
|
|
13
15
|
return new Alt(this._a, this._b);
|
package/aproc.js
CHANGED
|
@@ -5,6 +5,7 @@ import { map } from "@thi.ng/transducers/map";
|
|
|
5
5
|
* the processor's current value.
|
|
6
6
|
*/
|
|
7
7
|
export class AProc {
|
|
8
|
+
_val;
|
|
8
9
|
constructor(_val) {
|
|
9
10
|
this._val = _val;
|
|
10
11
|
}
|
|
@@ -19,6 +20,7 @@ export class AProc {
|
|
|
19
20
|
* Similar to {@link AProc}, but for processors with 2 inputs.
|
|
20
21
|
*/
|
|
21
22
|
export class AProc2 {
|
|
23
|
+
_val;
|
|
22
24
|
constructor(_val) {
|
|
23
25
|
this._val = _val;
|
|
24
26
|
}
|
package/biquad.js
CHANGED
|
@@ -12,6 +12,17 @@ export const biquadPeak = (fc, q, gain = 6) => new Biquad("peak", fc, q, gain);
|
|
|
12
12
|
export const biquadLoShelf = (fc, gain = -6) => new Biquad("loshelf", fc, undefined, gain);
|
|
13
13
|
export const biquadHiShelf = (fc, gain = -6) => new Biquad("hishelf", fc, undefined, gain);
|
|
14
14
|
export class Biquad extends AProc {
|
|
15
|
+
_type;
|
|
16
|
+
_freq;
|
|
17
|
+
_q;
|
|
18
|
+
_gain;
|
|
19
|
+
_a0;
|
|
20
|
+
_a1;
|
|
21
|
+
_a2;
|
|
22
|
+
_b1;
|
|
23
|
+
_b2;
|
|
24
|
+
_z1;
|
|
25
|
+
_z2;
|
|
15
26
|
constructor(_type, _freq, _q = SQRT2_2, _gain = 0) {
|
|
16
27
|
super(0);
|
|
17
28
|
this._type = _type;
|
package/cosine.js
CHANGED
package/delay.js
CHANGED
|
@@ -19,6 +19,10 @@ export const delayT = (n, off) => new Delay(n, off);
|
|
|
19
19
|
* at any delay time (within configured buffer size).
|
|
20
20
|
*/
|
|
21
21
|
export class Delay extends AProc {
|
|
22
|
+
_empty;
|
|
23
|
+
_buf;
|
|
24
|
+
_rpos;
|
|
25
|
+
_wpos;
|
|
22
26
|
/**
|
|
23
27
|
* Constructs new delay line of size `n` and initializes all
|
|
24
28
|
* elements to `empty`. If the latter is a function, the buffer will
|
package/feedback-delay.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Delay } from "./delay.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export const feedbackDelay = (n, feedback) => new FeedbackDelay(n, feedback);
|
|
14
14
|
export class FeedbackDelay extends Delay {
|
|
15
|
+
_feedback;
|
|
15
16
|
constructor(n, _feedback = 0.5) {
|
|
16
17
|
super(n, 0);
|
|
17
18
|
this._feedback = _feedback;
|
package/filter-delay.js
CHANGED
|
@@ -10,6 +10,8 @@ import { Delay } from "./delay.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export const filterFeedbackDelay = (n, filter, feedback) => new FilterFeedbackDelay(n, filter, feedback);
|
|
12
12
|
export class FilterFeedbackDelay extends Delay {
|
|
13
|
+
filter;
|
|
14
|
+
_feedback;
|
|
13
15
|
constructor(n, filter, _feedback = 0.5) {
|
|
14
16
|
super(n, 0);
|
|
15
17
|
this.filter = filter;
|
package/foldback.js
CHANGED
|
@@ -13,6 +13,8 @@ import { AProc } from "./aproc.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export const foldback = (thresh, amp) => new Foldback(thresh, amp);
|
|
15
15
|
export class Foldback extends AProc {
|
|
16
|
+
_thresh;
|
|
17
|
+
_amp;
|
|
16
18
|
constructor(_thresh = 1, _amp = 1 / _thresh) {
|
|
17
19
|
super(0);
|
|
18
20
|
this._thresh = _thresh;
|
package/impulse-train.js
CHANGED
|
@@ -9,6 +9,11 @@ export const impulseTrain = (period, start) => new ImpulseTrain(1, 0, period, st
|
|
|
9
9
|
export const impulseTrainT = (on, off, period, start) => new ImpulseTrain(on, off, period, start);
|
|
10
10
|
export const impulseTrainB = (period, start) => new ImpulseTrain(true, false, period, start);
|
|
11
11
|
export class ImpulseTrain extends AGen {
|
|
12
|
+
_on;
|
|
13
|
+
_off;
|
|
14
|
+
_period;
|
|
15
|
+
_pos;
|
|
16
|
+
_startpos;
|
|
12
17
|
constructor(_on, _off, _period, _pos = 0) {
|
|
13
18
|
super(_off);
|
|
14
19
|
this._on = _on;
|
package/impulse.js
CHANGED
package/integrator.js
CHANGED
|
@@ -8,6 +8,8 @@ import { AProc } from "./aproc.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const integrator = (coeff, start) => new Integrator(coeff, start);
|
|
10
10
|
export class Integrator extends AProc {
|
|
11
|
+
_coeff;
|
|
12
|
+
_start;
|
|
11
13
|
constructor(_coeff = 1, _start = 0) {
|
|
12
14
|
super(_start);
|
|
13
15
|
this._coeff = _coeff;
|
package/iterable.js
CHANGED
|
@@ -15,6 +15,8 @@ import { __take } from "./internal/take.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export const iterable = (src, initial) => new $Iterable(src, initial);
|
|
17
17
|
export class $Iterable {
|
|
18
|
+
_iter;
|
|
19
|
+
_val;
|
|
18
20
|
constructor(src, initial) {
|
|
19
21
|
this._iter = src[Symbol.iterator]();
|
|
20
22
|
this._val = initial;
|
package/madd.js
CHANGED
|
@@ -11,6 +11,10 @@ import { AGen } from "./agen.js";
|
|
|
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;
|
package/mapg.js
CHANGED
|
@@ -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;
|
package/merge.js
CHANGED
|
@@ -9,6 +9,7 @@ import {} from "./api.js";
|
|
|
9
9
|
export const merge = (...channels) => new Merge(channels, 0);
|
|
10
10
|
export const mergeT = (channels, init) => new Merge(channels, init);
|
|
11
11
|
export class Merge extends AGen {
|
|
12
|
+
_channels;
|
|
12
13
|
constructor(_channels, init) {
|
|
13
14
|
super(new Array(_channels.length).fill(init));
|
|
14
15
|
this._channels = _channels;
|
package/mix.js
CHANGED
package/mul.js
CHANGED
|
@@ -11,6 +11,9 @@ import { AGen } from "./agen.js";
|
|
|
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.js
CHANGED
package/onepole.js
CHANGED
|
@@ -7,6 +7,10 @@ export const onepoleHP = (fc) => new OnePole("hp", fc);
|
|
|
7
7
|
* https://www.earlevel.com/main/2012/12/15/a-one-pole-filter/
|
|
8
8
|
*/
|
|
9
9
|
export class OnePole extends AProc {
|
|
10
|
+
_type;
|
|
11
|
+
_freq;
|
|
12
|
+
_a0;
|
|
13
|
+
_b1;
|
|
10
14
|
constructor(_type, _freq) {
|
|
11
15
|
super(0);
|
|
12
16
|
this._type = _type;
|
package/osc.js
CHANGED
|
@@ -57,6 +57,10 @@ export const osc = (osc, freq, amp, dc, phase) => new Osc(osc, freq, amp, dc, ph
|
|
|
57
57
|
*/
|
|
58
58
|
export const modOsc = (osc, freq, fmod, amod = 1, dc, phase) => new Osc(osc, sum(isNumber(fmod) ? new Const(fmod) : fmod, isNumber(freq) ? add(freq) : freq), amod, dc, phase);
|
|
59
59
|
export class Osc extends AGen {
|
|
60
|
+
_osc;
|
|
61
|
+
_dc;
|
|
62
|
+
_phase;
|
|
63
|
+
_amp;
|
|
60
64
|
constructor(_osc, freq, amp = 1, _dc = 0, phase = 0) {
|
|
61
65
|
super(0);
|
|
62
66
|
this._osc = _osc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dsp",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.12",
|
|
4
4
|
"description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -28,25 +28,24 @@
|
|
|
28
28
|
"clean": "rimraf --glob '*.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
|
-
"doc:readme": "
|
|
32
|
-
"doc:stats": "tools:module-stats",
|
|
31
|
+
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
33
32
|
"pub": "yarn npm publish --access public",
|
|
34
|
-
"test": "
|
|
33
|
+
"test": "bun test"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.9.
|
|
38
|
-
"@thi.ng/checks": "^3.4.
|
|
39
|
-
"@thi.ng/errors": "^2.4.
|
|
40
|
-
"@thi.ng/math": "^5.7.
|
|
41
|
-
"@thi.ng/random": "^3.6.
|
|
42
|
-
"@thi.ng/transducers": "^8.8.
|
|
36
|
+
"@thi.ng/api": "^8.9.8",
|
|
37
|
+
"@thi.ng/checks": "^3.4.8",
|
|
38
|
+
"@thi.ng/errors": "^2.4.2",
|
|
39
|
+
"@thi.ng/math": "^5.7.3",
|
|
40
|
+
"@thi.ng/random": "^3.6.14",
|
|
41
|
+
"@thi.ng/transducers": "^8.8.10"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.38.
|
|
46
|
-
"@thi.ng/testament": "^0.
|
|
44
|
+
"@microsoft/api-extractor": "^7.38.2",
|
|
45
|
+
"@thi.ng/testament": "^0.4.1",
|
|
47
46
|
"rimraf": "^5.0.5",
|
|
48
47
|
"tools": "^0.0.1",
|
|
49
|
-
"typedoc": "^0.25.
|
|
48
|
+
"typedoc": "^0.25.3",
|
|
50
49
|
"typescript": "^5.2.2"
|
|
51
50
|
},
|
|
52
51
|
"keywords": [
|
|
@@ -284,5 +283,5 @@
|
|
|
284
283
|
],
|
|
285
284
|
"year": 2015
|
|
286
285
|
},
|
|
287
|
-
"gitHead": "
|
|
286
|
+
"gitHead": "669a3151e4302480244fe3e60eff5e732ea5b7a7\n"
|
|
288
287
|
}
|
package/pan.js
CHANGED
package/pink-noise.js
CHANGED
|
@@ -28,6 +28,11 @@ const PROB = [0.00198, 0.0128, 0.049, 0.17, 0.682];
|
|
|
28
28
|
*/
|
|
29
29
|
export const pinkNoise = (gain, rnd, amp, prob) => new PinkNoise(gain, rnd, amp, prob);
|
|
30
30
|
export class PinkNoise extends AGen {
|
|
31
|
+
_gain;
|
|
32
|
+
_rnd;
|
|
33
|
+
_amp;
|
|
34
|
+
_bins;
|
|
35
|
+
_psum;
|
|
31
36
|
constructor(_gain = 1, _rnd = SYSTEM, _amp = AMP, prob = PROB) {
|
|
32
37
|
super(0);
|
|
33
38
|
this._gain = _gain;
|
package/reciprocal.js
CHANGED
package/ref.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AGen } from "./agen.js";
|
|
|
2
2
|
import { AProc } from "./aproc.js";
|
|
3
3
|
export const refG = (src) => new RefG(src);
|
|
4
4
|
export class RefG extends AGen {
|
|
5
|
+
_src;
|
|
5
6
|
constructor(_src) {
|
|
6
7
|
super(_src.deref());
|
|
7
8
|
this._src = _src;
|
|
@@ -12,6 +13,7 @@ export class RefG extends AGen {
|
|
|
12
13
|
}
|
|
13
14
|
export const refP = (src) => new RefP(src);
|
|
14
15
|
export class RefP extends AProc {
|
|
16
|
+
_src;
|
|
15
17
|
constructor(_src) {
|
|
16
18
|
super(_src.deref());
|
|
17
19
|
this._src = _src;
|
package/serial.js
CHANGED
|
@@ -13,6 +13,8 @@ export function serial(...procs) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export class Serial2 extends AProc {
|
|
16
|
+
_a;
|
|
17
|
+
_b;
|
|
16
18
|
constructor(_a, _b) {
|
|
17
19
|
super(null);
|
|
18
20
|
this._a = _a;
|
|
@@ -23,6 +25,9 @@ export class Serial2 extends AProc {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
export class Serial3 extends AProc {
|
|
28
|
+
_a;
|
|
29
|
+
_b;
|
|
30
|
+
_c;
|
|
26
31
|
constructor(_a, _b, _c) {
|
|
27
32
|
super(null);
|
|
28
33
|
this._a = _a;
|
|
@@ -34,6 +39,10 @@ export class Serial3 extends AProc {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
export class Serial4 extends AProc {
|
|
42
|
+
_a;
|
|
43
|
+
_b;
|
|
44
|
+
_c;
|
|
45
|
+
_d;
|
|
37
46
|
constructor(_a, _b, _c, _d) {
|
|
38
47
|
super(null);
|
|
39
48
|
this._a = _a;
|
|
@@ -46,6 +55,7 @@ export class Serial4 extends AProc {
|
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
export class Serial extends AProc {
|
|
58
|
+
_procs;
|
|
49
59
|
constructor(_procs) {
|
|
50
60
|
super(null);
|
|
51
61
|
this._procs = _procs;
|
package/sincos.js
CHANGED
package/svf.js
CHANGED
|
@@ -17,6 +17,15 @@ export const svfAllpass = (fc, q) => new SVF("all", fc, q);
|
|
|
17
17
|
* - https://en.wikipedia.org/wiki/Trapezoidal_rule
|
|
18
18
|
*/
|
|
19
19
|
export class SVF extends AProc {
|
|
20
|
+
_type;
|
|
21
|
+
_freq;
|
|
22
|
+
_q;
|
|
23
|
+
_a1;
|
|
24
|
+
_a2;
|
|
25
|
+
_c1;
|
|
26
|
+
_c2;
|
|
27
|
+
_g;
|
|
28
|
+
_k;
|
|
20
29
|
constructor(_type, _freq, _q = 0.5) {
|
|
21
30
|
super(0);
|
|
22
31
|
this._type = _type;
|
package/waveshaper.js
CHANGED
|
@@ -26,6 +26,10 @@ import { AProc } from "./aproc.js";
|
|
|
26
26
|
*/
|
|
27
27
|
export const waveShaper = (thresh, amp, map) => new WaveShaper(thresh, amp, map);
|
|
28
28
|
export class WaveShaper extends AProc {
|
|
29
|
+
_coeff;
|
|
30
|
+
_map;
|
|
31
|
+
_amp;
|
|
32
|
+
_autoGain;
|
|
29
33
|
constructor(_coeff = 3, amp = true, _map = waveshapeSigmoid) {
|
|
30
34
|
super(0);
|
|
31
35
|
this._coeff = _coeff;
|
package/white-noise.js
CHANGED