@thi.ng/dsp 4.3.16 → 4.3.19
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 +7 -1
- package/README.md +55 -44
- package/osc-additive.d.ts +1 -1
- package/osc-additive.js +2 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-08-10T12:25:09Z
|
|
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,12 @@ 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.3.17](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.3.17) (2023-08-04)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update `identity` usage in various pkgs ([b6db053](https://github.com/thi-ng/umbrella/commit/b6db053))
|
|
17
|
+
|
|
12
18
|
## [4.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.3.0) (2023-01-10)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
|
+
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
2
3
|
|
|
3
|
-
# 
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/@thi.ng/dsp)
|
|
6
7
|

|
|
@@ -49,12 +50,11 @@ Partially ported from other thi.ng projects (e.g.
|
|
|
49
50
|
|
|
50
51
|
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bdsp%5D+in%3Atitle)
|
|
51
52
|
|
|
52
|
-
Even though this library is now at v2.0.0 and still retains most of the
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
might be ported to WASM.
|
|
53
|
+
Even though this library is now at v2.0.0 and still retains most of the features
|
|
54
|
+
from earlier versions, all recently added features (IGen's, IProc's, composition
|
|
55
|
+
ops etc.) should be considered "beta" and are likely to undergo further
|
|
56
|
+
(hopefully not too drastic) changes in the near future. Also, pending outcomes
|
|
57
|
+
of ongoing experiments, some aspects might be ported to WASM.
|
|
58
58
|
|
|
59
59
|
## Support packages
|
|
60
60
|
|
|
@@ -84,7 +84,7 @@ For Node.js REPL:
|
|
|
84
84
|
const dsp = await import("@thi.ng/dsp");
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 6.
|
|
87
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 6.91 KB
|
|
88
88
|
|
|
89
89
|
## Dependencies
|
|
90
90
|
|
|
@@ -106,6 +106,8 @@ A selection:
|
|
|
106
106
|
| Screenshot | Description | Live demo | Source |
|
|
107
107
|
|:-----------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
|
|
108
108
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fft-synth.png" width="240"/> | Interactive inverse FFT toy synth | [Demo](https://demo.thi.ng/umbrella/fft-synth/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fft-synth) |
|
|
109
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-basics.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-basics) |
|
|
110
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-zoom.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-zoom/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-zoom) |
|
|
109
111
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-spline.png" width="240"/> | Polygon to cubic curve conversion & visualization | [Demo](https://demo.thi.ng/umbrella/poly-spline/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-spline) |
|
|
110
112
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rasterize-blend.jpg" width="240"/> | Steering behavior drawing with alpha-blended shapes | [Demo](https://demo.thi.ng/umbrella/rasterize-blend/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rasterize-blend) |
|
|
111
113
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cubemap.jpg" width="240"/> | WebGL cube maps with async texture loading | [Demo](https://demo.thi.ng/umbrella/webgl-cubemap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cubemap) |
|
|
@@ -117,17 +119,15 @@ A selection:
|
|
|
117
119
|
|
|
118
120
|
### IGen
|
|
119
121
|
|
|
120
|
-
The following unit generators are infinite data sources based on the
|
|
121
|
-
[`IGen`
|
|
122
|
+
The following unit generators are infinite data sources based on the [`IGen`
|
|
122
123
|
interface](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/api.ts)
|
|
123
|
-
with most being resettable too. The interface is similar to ES6
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
result
|
|
124
|
+
with most being resettable too. The interface is similar to ES6 iterators in
|
|
125
|
+
that the next value can be obtained by calling `.next()`, however since `IGen`s
|
|
126
|
+
are always infinite, there's no need to [wrap the result
|
|
127
127
|
value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)
|
|
128
|
-
as is done with ES6 iterables. Furthermore, all gens defined in this
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
as is done with ES6 iterables. Furthermore, all gens defined in this package do
|
|
129
|
+
implement `Symbol.iterator` and so can actually be used as standard iterables as
|
|
130
|
+
well.
|
|
131
131
|
|
|
132
132
|
`IGen` also implements the
|
|
133
133
|
[`IDeref`](https://github.com/thi-ng/umbrella/blob/develop/packages/api/src/api/deref.ts)
|
|
@@ -184,10 +184,10 @@ import { take } from "@thi.ng/transducers";
|
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
- [add](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/add.ts) - adder
|
|
187
|
-
- [adsr](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/
|
|
187
|
+
- [adsr](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/adsr.ts) - timebased ADSR / AD envelope generator
|
|
188
188
|
- [alt](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/alt.ts) - alternating values
|
|
189
189
|
- [constant](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/const.ts) - constant value
|
|
190
|
-
- [cosine](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/
|
|
190
|
+
- [cosine](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/cosine.ts) - trig-free cosine osc
|
|
191
191
|
- [curve](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/curve.ts) - timebased exponential gain/decay (factory for `madd`)
|
|
192
192
|
- [impulse](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/impulse.ts) - impulse gen
|
|
193
193
|
- [impulseTrain](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/impulse-train.ts) - timebased cyclic impulse
|
|
@@ -198,7 +198,7 @@ import { take } from "@thi.ng/transducers";
|
|
|
198
198
|
- [reciprocal](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/reciprocal.ts) - fractional sequence (1, 1/2, 1/3, 1/4 etc.)
|
|
199
199
|
- [sincos](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/sincos.ts) - trig-free sin/cos LFO
|
|
200
200
|
- [sweep](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/sweep.ts) - freq sweep gen w/ phase accumulation for oscillators
|
|
201
|
-
- [whiteNoise](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/
|
|
201
|
+
- [whiteNoise](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/white-noise.ts) - white noise
|
|
202
202
|
|
|
203
203
|
#### Higher order generators
|
|
204
204
|
|
|
@@ -260,18 +260,25 @@ Diagram of the FM/AM osc with some low pass filters applied:
|
|
|
260
260
|
|
|
261
261
|
### IProc
|
|
262
262
|
|
|
263
|
-
The second fundamental interface in this package, similar to `IGen` and
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
The second fundamental interface in this package, similar to `IGen` and used to
|
|
264
|
+
implement processors & transformers of input values (e.g those generated by the
|
|
265
|
+
various `IGen`s available). `IProc` implementations have a `.next(x)` method,
|
|
266
|
+
where `x` is the next input to be processed.
|
|
267
267
|
|
|
268
|
-
The package also provides several approaches to compose multi-step
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
`IXform`
|
|
268
|
+
The package also provides several approaches to compose multi-step processing
|
|
269
|
+
pipelines (see section further below). Furthermore, all implementations in this
|
|
270
|
+
package implement the [@thi.ng/transducers `IXform`
|
|
272
271
|
interface](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/README.md#IXform-interface)
|
|
273
272
|
and so can be directly used in transducer pipelines too.
|
|
274
273
|
|
|
274
|
+
Additional higher order `IProc` implementations:
|
|
275
|
+
|
|
276
|
+
- [bounce](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/bounce.ts) - sum multiple inputs
|
|
277
|
+
- [mix](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/mix.ts) - linear interpolation of 2 inputs
|
|
278
|
+
- [multiplex](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/multiplex.ts) - process 1 input into multiple outs
|
|
279
|
+
- [pipe](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/pipe.ts) - `IGen` & multiple `IProc` pipeline setup
|
|
280
|
+
- [serial](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/serial.ts) - serial processing of multiple `IProc`
|
|
281
|
+
|
|
275
282
|
```ts
|
|
276
283
|
import { comp, push, take, transduce } from "@thi.ng/transducers";
|
|
277
284
|
|
|
@@ -309,7 +316,9 @@ const sig = new Float32Array(
|
|
|
309
316
|
fs.writeFileSync("sig.raw", Buffer.from(sig.buffer));
|
|
310
317
|
```
|
|
311
318
|
|
|
312
|
-
|
|
319
|
+
Use the [@thi.ng/dsp-io-wav
|
|
320
|
+
package](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp-io-wav/)
|
|
321
|
+
to export as WAV, or alternatively use `ffmpeg` for conversion:
|
|
313
322
|
|
|
314
323
|
```bash
|
|
315
324
|
ffmpeg -f f32le -ar 48k -ac 1 -i sig.raw sig.wav -y
|
|
@@ -317,8 +326,8 @@ ffmpeg -f f32le -ar 48k -ac 1 -i sig.raw sig.wav -y
|
|
|
317
326
|
|
|
318
327
|
#### Filters
|
|
319
328
|
|
|
320
|
-
The following diagrams show various combinations of oscillator signals
|
|
321
|
-
|
|
329
|
+
The following diagrams show various combinations of oscillator signals and their
|
|
330
|
+
filtered responses (with different cutoff/center frequencies).
|
|
322
331
|
|
|
323
332
|
All diagrams were generated with [this
|
|
324
333
|
script](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/tools/generate-diagrams.ts).
|
|
@@ -387,7 +396,7 @@ High shelf (gain = -6dB):
|
|
|
387
396
|
|
|
388
397
|
##### State variable filter
|
|
389
398
|
|
|
390
|
-
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/
|
|
399
|
+
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/svf.ts)
|
|
391
400
|
|
|
392
401
|
- `svfLP` - low pass, resonance
|
|
393
402
|
- `svfHP` - high pass, resonance
|
|
@@ -426,10 +435,10 @@ Allpass:
|
|
|
426
435
|
|
|
427
436
|
Using the [Filter response
|
|
428
437
|
utils](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/filter-response.ts),
|
|
429
|
-
the following filter types can be evaluated for analyzing their impact
|
|
430
|
-
|
|
431
|
-
[`IFilter`](https://
|
|
432
|
-
|
|
438
|
+
the following filter types can be evaluated for analyzing their impact on
|
|
439
|
+
specific frequencies (or frequency bands). Any type implementing
|
|
440
|
+
[`IFilter`](https://docs.thi.ng/umbrella/dsp/interfaces/FilterConfig.html) can
|
|
441
|
+
be used, currently:
|
|
433
442
|
|
|
434
443
|
- 1-pole
|
|
435
444
|
- DC-block
|
|
@@ -470,16 +479,16 @@ Basic filter response plot:
|
|
|
470
479
|
|
|
471
480
|
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/delay.ts)
|
|
472
481
|
|
|
473
|
-
Ringbuffer / delay line for arbitrary values and support for single &
|
|
474
|
-
|
|
475
|
-
|
|
482
|
+
Ringbuffer / delay line for arbitrary values and support for single & multi-taps
|
|
483
|
+
at any relative positions. Useful fundamental building block for various other
|
|
484
|
+
effects, filters etc.
|
|
476
485
|
|
|
477
486
|
#### Feedback delay
|
|
478
487
|
|
|
479
488
|
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/feedback-delay.ts)
|
|
480
489
|
|
|
481
|
-
Variation of `delay()` which adds a portion of the delayed value to each
|
|
482
|
-
|
|
490
|
+
Variation of `delay()` which adds a portion of the delayed value to each new
|
|
491
|
+
input and stores result in delay line.
|
|
483
492
|
|
|
484
493
|
#### Filtered feedback delay
|
|
485
494
|
|
|
@@ -492,7 +501,8 @@ Variation of `feedbackDelay()` which processes feedback via given filter /
|
|
|
492
501
|
|
|
493
502
|
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/waveshaper.ts)
|
|
494
503
|
|
|
495
|
-
This operator remaps inputs via a user provided function. The following shaping
|
|
504
|
+
This operator remaps inputs via a user provided function. The following shaping
|
|
505
|
+
functions are provided:
|
|
496
506
|
|
|
497
507
|
- `waveshapeTan` - arctan based (soft-clip/distortion)
|
|
498
508
|
- `waveshapeSigmoid` - sigmoid based, similar to above
|
|
@@ -515,9 +525,10 @@ Sine:
|
|
|
515
525
|
|
|
516
526
|
#### Foldback distortion
|
|
517
527
|
|
|
518
|
-
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/
|
|
528
|
+
[Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/foldback.ts)
|
|
519
529
|
|
|
520
|
-
Recursively folds input into `[-thresh .. +thresh]` interval and amplifies it
|
|
530
|
+
Recursively folds input into `[-thresh .. +thresh]` interval and amplifies it
|
|
531
|
+
with `amp` (default: 1/thresh).
|
|
521
532
|
|
|
522
533
|
Use the [interactive calculator @
|
|
523
534
|
Desmos](https://www.desmos.com/calculator/lkyf2ag3ta) to experiment.
|
package/osc-additive.d.ts
CHANGED
package/osc-additive.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { identity } from "@thi.ng/api/fn";
|
|
1
2
|
import { gibbs } from "./anti-alias.js";
|
|
2
3
|
import { sin } from "./osc-sin.js";
|
|
3
4
|
/**
|
|
@@ -42,4 +43,4 @@ export const squareAdditive = (n = 8) => additive(sin, (i) => 2 * (i - 1) + 1, (
|
|
|
42
43
|
*
|
|
43
44
|
* @param n - number of octaves
|
|
44
45
|
*/
|
|
45
|
-
export const sawAdditive = (n = 8) => additive(sin,
|
|
46
|
+
export const sawAdditive = (n = 8) => additive(sin, identity, (i) => (1 / i) * gibbs(n, i), n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/dsp",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.19",
|
|
4
4
|
"description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/checks": "^3.
|
|
39
|
-
"@thi.ng/errors": "^2.2
|
|
40
|
-
"@thi.ng/math": "^5.5.
|
|
41
|
-
"@thi.ng/random": "^3.5.
|
|
42
|
-
"@thi.ng/transducers": "^8.
|
|
37
|
+
"@thi.ng/api": "^8.9.2",
|
|
38
|
+
"@thi.ng/checks": "^3.4.2",
|
|
39
|
+
"@thi.ng/errors": "^2.3.2",
|
|
40
|
+
"@thi.ng/math": "^5.5.3",
|
|
41
|
+
"@thi.ng/random": "^3.5.3",
|
|
42
|
+
"@thi.ng/transducers": "^8.5.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.
|
|
46
|
-
"@thi.ng/testament": "^0.3.
|
|
45
|
+
"@microsoft/api-extractor": "^7.36.3",
|
|
46
|
+
"@thi.ng/testament": "^0.3.20",
|
|
47
47
|
"rimraf": "^5.0.1",
|
|
48
48
|
"tools": "^0.0.1",
|
|
49
49
|
"typedoc": "^0.24.8",
|
|
50
|
-
"typescript": "^5.1.
|
|
50
|
+
"typescript": "^5.1.6"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"allpass",
|
|
@@ -275,5 +275,5 @@
|
|
|
275
275
|
],
|
|
276
276
|
"year": 2015
|
|
277
277
|
},
|
|
278
|
-
"gitHead": "
|
|
278
|
+
"gitHead": "ad9ac3232c6fc5fc8a0df75ac82fc1e0e9fb0258\n"
|
|
279
279
|
}
|